<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Legal Drafting supported by AI: enhancing LEOS</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Monica Palmirani</string-name>
          <email>monica.palmirani@unibo.it</email>
          <xref ref-type="aff" rid="aff0">0</xref>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Fabio Vitali</string-name>
          <email>fabio.vitali@unibo.it</email>
          <xref ref-type="aff" rid="aff0">0</xref>
          <xref ref-type="aff" rid="aff2">2</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Generoso Longo</string-name>
          <email>generoso.longo@studio.unibo.it</email>
          <xref ref-type="aff" rid="aff0">0</xref>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Emanuele Di Sante</string-name>
          <email>emanuele.disante@studio.unibo.it</email>
          <xref ref-type="aff" rid="aff0">0</xref>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Aurora Brega</string-name>
          <email>aurora.brega@stuido.unibo.it</email>
          <xref ref-type="aff" rid="aff0">0</xref>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Andrea D'Arpa</string-name>
          <email>andrea.darpa@studio.unibo.it</email>
          <xref ref-type="aff" rid="aff0">0</xref>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Michele Corazza</string-name>
          <email>michele.corazza@unibo.it</email>
          <xref ref-type="aff" rid="aff0">0</xref>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Ital-IA 2024: 4th National Conference on Artificial Intelligence</institution>
          ,
          <addr-line>organized by CINI</addr-line>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>University of Bologna</institution>
          ,
          <addr-line>ALMA-AI, via Galliera 3, Bologna, 40121</addr-line>
          ,
          <country country="IT">Italy</country>
        </aff>
        <aff id="aff2">
          <label>2</label>
          <institution>University of Bologna</institution>
          ,
          <addr-line>DISI, via Mura Anteo Zamboni 7, Bologna, 40126</addr-line>
          ,
          <country country="IT">Italy</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>Legal drafting is a complex activity that involves different actors and end-users, usually belonging to the administration staff. AI tools could support this activity by providing useful aid for various tasks. This paper presents two scenarios where the AI add-on supports the legal drafting activity conducted using the LEOS web editor, developed by the EU Commission for EU legislation. The two scenarios are the following: i) retrieving the relevant existing normative definitions connected with the ongoing bill, by using algorithms based on semantic similarity; ii) suggesting the normative more pertinent references when some information is missing (e.g., the year); iii) aiding the drafter in following templates for improving clearness and regularity in the norms (e.g., modifications). Additionally, it is crucial to model a user interface that is capable of guaranteeing some foundational principles: accessibility, transparency, usability, user experience, and explicability. This paper presents the output of this project conducted in collaboration with the DG Informatics of the EU Commission.</p>
      </abstract>
      <kwd-group>
        <kwd>eol&gt;Akoma Ntoso</kwd>
        <kwd>LEOS</kwd>
        <kwd>similarity</kwd>
        <kwd>AI</kwd>
        <kwd>1</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>1. Introduction</title>
      <p>
        The legal drafting activity is a crucial task in the
legislative procedure in any deliberative assembly.
The goals of this task are many: i) to support the
political decision-makers; ii) to standardize the
language with the legal tradition, adopting
multilingual translations when necessary; iii) to apply
drafting rules to improve quality, and clearness; iv) to
guarantee the Rule of Law and the theory of law
principles; v) to track the modifications happening
over time due to the the legislative process. In the last
15 years many specialized editors have been
developed [13],[
        <xref ref-type="bibr" rid="ref5">5</xref>
        ],[
        <xref ref-type="bibr" rid="ref3">3</xref>
        ],[
        <xref ref-type="bibr" rid="ref1">1</xref>
        ], in order to support these
important goals using Natural language processing
technology [6]. Among the proposed solutions some
use the Semantic Web approach [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ], while others
apply Symbolic AI based on rules [12]. LEOS [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ], [10]
is one of the most promising web editors for legal
drafting, it has been developed by the EU Commission
to support the internal legal drafting activities but also
with the aim to serve the Member States as well.
      </p>
      <p>LEOS is an open-source web editor specific for
legal drafting, it is written in Angular and it is oriented
to manage all the law-making process [15].</p>
      <p>
        The aim of this work is to develop a framework
architecture that is capable of enhancing LEOS with
add-ons, developed with AI technologies, that
improve the quality of the legal content, help the legal
drafters, and manage the law-making process. The
two add-ons provide the following features
[7],[
        <xref ref-type="bibr" rid="ref4">4</xref>
        ][
        <xref ref-type="bibr" rid="ref4">4</xref>
        ],[14]:
      </p>
      <p>0000-0002-8557-8084 (M. Palmirani); 0000-0002-7562-5203
(F. Vitali); 0000-0002-7288-6635 (M. Corazza);
© 2023 Copyright for this paper by its authors. Use permitted under
Creative Commons License Attribution 4.0 International (CC BY 4.0).
(i)
(ii)
(iii)
(iv)
(i)
(ii)
(iii)</p>
      <p>Suggest the pertinent normative
definitions using similarity with the bill
topic;
Suggest the pertinent normative
reference using the thematic similarity
with the bill;
Take into consideration the temporal
information and the nested normative
references;
Use the metadata of ELI2 and
EUROVOC3 to improve the similarity.</p>
      <p>Reduce manual/error-prone work
typing the normative references, also
avoiding repetitions in legislative
citations;
Maximising reuse of similar legal
concepts (e.g., definition);
Increasing transparency and
searchability of the existing legal
knowledge included in the corpora.
of:</p>
      <p>The aim is also to create a user interface capable</p>
    </sec>
    <sec id="sec-2">
      <title>2. Methodology</title>
      <p>The adopted methodology is based on hybrid AI [11],
and it uses multiple techniques for achieving its goals.
We do not generate new text (e.g., using LLM o
generative AI), but we intend to suggest pertinent,
contextual, and significant existing legal knowledge
extracted by the legal corpora, using a similarity index
according to the bill parameters that the legal drafter
is writing. We also use the EUROVOC classification and
other contextual information provided by the experts
during the drafting process (e.g., type of provision).</p>
      <p>Secondly, the approach takes into consideration
the temporal validity of the normative provisions,
excluding those that are repealed, or suggesting the
appropriate versions of the consolidated text
according to the view date typed by the end-user. If
the author seeks the normative definition of “privacy”
before the GDPR, they can set the date of view before
the 5 May of 2016 (the date of entering into force of
the act) and the system will respect this setting.</p>
      <p>Thirdly, we resolve the normative references in
order to include in the model of indexing the text cited
in the recursive way as well (only the first level),
allowing us to grasp more information, especially
when the definition is limited in the text and it
consists only of normative citations to another
2 ELI: https://eur-lex.europa.eu/eli-register/about.html
provision (e.g., “For the purposes of this Directive, the
definitions laid down in Article 2 of Directive
2000/60/EC shall apply”).</p>
      <p>Fourthly, the context is important for providing
the relevant output of the suggestion. A definition
depends on the topic of the bill. For example, we have
many definitions of ‘accuracy’ and it depends on the
topic of the document.</p>
      <p>Fifthly, the user interface is a fundamental pillar
for guaranteeing good usability, transparency, and
explicability of the AI behaviors and output [8].</p>
      <p>Finally, we use Akoma Ntoso [9] serialization for
fostering the structure of the legal documents, the
normative references, the metadata of the lifecycle of
the document, the date of entry into force, into
operation, and the date of repeal.</p>
    </sec>
    <sec id="sec-3">
      <title>3. Dataset</title>
      <p>The dataset used is composed by 10 years of European
legislation (2010-2021), about 15.000 regulations
and directives. It was provided by the European
Publication Office in Formex 3.0 XML format. We have
converted all the documents in Akoma Ntoso, and
using a natural language processing approach we
have annotated the definitions and the normative
references.</p>
      <p>The dataset includes about 899 documents with
definitions. For definitions, we have considered only
the explicit provisions usually titled “Definitions” or
where a regular pattern can surely identify the
relationship between a term (definiens) and
description (definiendum) (e.g., ‘definiens’ means
definiendum, “‘domain’ means one or several data
sets that cover specific topics;”). The definitions that
include normative references are managed by
navigating the link to include the complete
information (e.g. ‘personal data’ means personal data
as defined in point (1) of Article 4 of Regulation (EU)
2016/679).</p>
    </sec>
    <sec id="sec-4">
      <title>4. Use Cases</title>
      <sec id="sec-4-1">
        <title>4.1. Normative References</title>
        <p>Normative references are qualified citations used for
mentioning other documents or provisions relevant
for the normative discourse. The errors during the
typing of the normative references produce incorrect
links and additional effort in the control phases.</p>
        <p>The system permits to type incomplete normative
references and to retrieve and rank the existing and
3 EUROVOC:
https://eurlex.europa.eu/browse/eurovoc.html?locale=it
into force references which are similar to the
information requested by the end-user. In the case a
citation of the form “Regulation 406”, for example, the
system returns all the Regulation which are valid, into
force, numbered 406 and pertinent to the EUROVOC
of the bill. The system completes the reference (e.g.,
Regulation 406/2010) and returns the title of the
document and other information for identifying the
act as well.</p>
        <p>Due to the evolution of the European institutions,
the references have changed syntax and patterns over
time. For this reason, the end-user can easily make a
mistake in the citation format. Our tool helps the
enduser to compose the reference according to the
historical period of the document cited. For example,
a Regulation before 1968 is cited using
number/yy/EEC (e.g., Regulation No 1009/67/EEC);
after 1968 we have number/yy (e.g. Regulation (EEC)
No 2195/91) and after 2009 we have yyyy/number
(e.g., Regulation (EU) 2016/679).</p>
      </sec>
      <sec id="sec-4-2">
        <title>4.2. Legal Definitions</title>
        <p>Legal definitions are a sensitive part of the law
because they define new legal concepts, new
terminologies, equivalences between different other
definitions, and exceptions in the case of specific
cases. In EU legislation, we usually have a clear article
called “Definitions”, but sometimes we could also find
technical definitions in the last part of the act or in the
annexes.</p>
        <p>Additionally, we could have definitions organized
in a long list of points, which might be connected to
each other. Definitions are composed of three main
parts: definiens (term); definiendum (description);
legal concept (abstract class of concept). The use of
the same term for multiple definitions is not
infrequent, and the term might have completely
different meaning in different domains (e.g., pollution
has different definitions according to the domain like
water, energy, industry, etc.).</p>
        <p>For this reason, the tool calculates the similarity of
a given term (which can also be composed of multiple
words) with the existing, valid, and updated (present
in consolidated versions of documents ) definitions in
the legal corpus, using the similarity index as a
criterion.</p>
      </sec>
    </sec>
    <sec id="sec-5">
      <title>5. Architecture</title>
      <p>The overall architecture (see Figure 1) is composed
of an XML database that includes the Akoma Ntoso
4 eXist is an XML database that is indexed using Lucine and
querable with XQuery.</p>
      <p>XML documents and an SQL database containing the
correspondence between each document and its
EUROVOC categorization. Each EUROVOC is
associated with an average of the Word2Vec [16]
embeddings of the words composing it. The eXist
database including all the AKN-XML documents4 can
also use Lucene Java library to calculate the index of
the document text and in particular to the definitions
(defBody elements). When a new document enters the
eXist database it is also indexed in the SQLDB and the
Word2Vec representation of its definitions is stored.
If the document does not have EUROVOC tags, we
extract them from CELLAR and we serialize the
information in the metadata of the Akoma Ntoso
documents.</p>
      <p>During legal drafting, if the end-user wants to get
a suggestion (e.g., normative reference or definition),
they need to provide some parameters as inputs, in
order to calculate the corresponding indexes like the
title and the EUROVOC keywords of the bill (proposal
of law). The dynamic input typed by the end user (e.g.,
incomplete normative reference or definition
keywords) is parsed to compare the content with the
existing document collection in eXist. After a first filter
using traditional Information Retrieval techniques for
grasping the relevant documents, the similarity score
is calculated based on the text retrieved and
compared with the embeddings of the input
parameters stored in the SQL DB (for EUROVOC
values) and using the similarity algorithm of Lucine
for the definitions. The ranking is based on the index
score, the temporal parameters, considering the
normative citations included in the normative
provision retrieved as well.</p>
      <p>Lucene Similarity class implements the scoring
model. The library offers several already-built
implementations of the Similarity class, which reflect
different scoring models developed in the field of
Information Retrieval. Our implementation adopts
Default Similarity class, which combines the Boolean
model, adopted to filter documents matching the
query, and a readjustment of the Vector Space model,
based on TF-IDF weights, for scoring results. In
particular, VSM is refined by Lucene taking into
account the corpus statistics contained in the inverted
index, the number of terms that correspond to the
query, and the multiplying enhancement factors
expressed in the research. This class is also exploited
by the process chain of indexing, since it deals with the
calculation of the normalization factors, which
depend on the length of the fields and the boost
factors specified in the configuration(Similarity
(Lucene 3.6.1 API) (apache.org)).</p>
    </sec>
    <sec id="sec-6">
      <title>7. Conclusions</title>
    </sec>
    <sec id="sec-7">
      <title>6. User-interface</title>
      <p>The user interface (see Figure 2) is a fundamental
part of this application. LEOS is enriched with an
addon that enables these functionalities in a selective
way. The suggestions are offered in a portion of the
window that allows the end-user to confirm or discard
the output, or to integrate the results in the drafting
text.</p>
      <p>Our custom components are organised in a
dedicated application folder, comprising new
components (stored in .component.ts,
.component.html, and .component.scss files), new
classes (.ts files), and service (in a .service.ts file). This
service manages the essential methods and global
variables used by our approach.</p>
      <p>To maintain consistency, we adopted a style for
our extension that closely imitates the original
application's design. Many of the components used
were taken from the eUI library, and we followed the
guidelines and suggestions provided by the eUI
framework. The version of the eUI library used is 14,
the same one adopted by LEOS and used in its native
components. Therefore, both the shape and color of
the interface elements are consistent with those
indicated by the framework.</p>
      <p>The components we added, we always provide
feedback to the user, displaying results when
generated, an error message if the service responses
raise an issue, and an alert if the user's request is not
executed correctly, accordingly with the functionality
we aim to provide. We designed it so that the user
knows the reasons for an incomplete or incorrect
request and is given the opportunity to make any
necessary corrections. We also strive to maintain
consistency in the terms used in the labels, ensuring
that each element is identified by a unique name and
avoiding multiple elements with the same name.</p>
      <p>The end user of the service is an expert in
legislative matters, so we prioritised making the
interface simple and intuitive but also very specific for
professional tasks in drafting, considering that the
user has clear knowledge of the subject matter being
addressed. We created mockups of the interface to
evaluate it before implementation, ensuring that it is
indeed usable and effective. The end-user is
constantly involved in the evaluation with regular
meetings where the usability is tested and feedback is
incorporated in the software.</p>
      <p>The current paper presents two add-ons
integrated into LEOS web editor to enhance legal
drafting tasks using AI applications. The user interface
is a fundamental component of this work that is
designed to incorporate the principles of
transparency, accessibility, user experience, and
explicability. The methodology is to not generate new
text (e.g., like LLMs) to avoid hallucinations, which
could affect the democratic rules of the law-making
process.</p>
      <p>We aim to extract and offer to the legal drafters the
legal knowledge stored in the corpus, which is
sometimes difficult to find due to the large volume of
documents, and to return the relevant information
accompanied with a particular index score based on
temporal parameters, similarity of text using qualified
legal provisions like definitions and normative
references. The first results were evaluated by legal
experts and they are promising and pertinent to the
drafting text. Moreover, the end-users appreciated the
provided suggestions, which could retrieve pertinent
information using topic similarity, cutting repetitive
work and focusing on higher-level tasks.</p>
    </sec>
    <sec id="sec-8">
      <title>Acknowledgements</title>
      <p>This project is co-funded by DG Informatics of the
European Commission inside of the larger project
LEOS and with the support of the European
Commission funds within ERC HyperModeLex. Grant
agreement ID: 101055185.
law-and-security/solution/leos-open-sourcesoftware-editing-legislation
[6] Lesmo Leonardo, Alessandro Mazzei, Monica
Palmirani, Daniele Paolo Radicioni: TULSI: an
NLP system for extracting legal modificatory
provisions. Artif. Intell. Law 21(2): 139-172
(2013)
[7] Lorello Laura, La qualità della legislazione
diventa un’esigenza bicamerale : considerazioni
sul nuovo Comitato per la legislazione del Senato
della Repubblica nel primo semestre di attività,
Federalismi.it : rivista di diritto pubblico
italiano, comunitario e comparato. - 2023, n. 27,
p. 17-45
[8] Palmirani M., Vitali F, Legislative Drafting
Systems, in: Usability in Government Systems,
NEW YORK, Morgan Kaufmann, 2012, pp. 133
151
[9] Palmirani Monica (2011). Legislative change
management with Akoma Ntoso. In Legislative
XML for the semantic Web, 101–130. Springer
[10] Palmirani Monica et. al. Drafting legislation in
the era of AI and digitisation,
https://joinup.ec.europa.eu/sites/default/files
/document/202206/Drafting%20legislation%20in%20the%20e
ra%20of%20AI%20and%20digitisation%20%
E2%80%93%20study.pdf
[11] Palmirani Monica, F Sovrano, D Liga, S Sapienza,
F Vitali, Hybrid AI Framework for Legal Analysis
of the EU Legislation Corrigenda, Legal
Knowledge and Information Systems, 68-75
[12] Palmirani Monica, Luca Cervone, Octavian Bujor,
Marco Chiappetta: RAWE: An Editor for Rule
Markup of Legal Texts. RuleML (2) 2013
[13] Palmirani Monica, Raffaella Brighi: An XML
Editor for Legal Information Management. EGOV
2003: 421-429
[14] Tafani Laura, Federico Ponte, Le tecniche
legislative statali, regionali e dell'Unione
europea a confronto : per un auspicabile
ravvicinamento, Osservatorio sulle fonti. - 2022,
n. 1, p. 447-497
[15] Leos Manual
https://joinup.ec.europa.eu/collection/justicelaw-and-security/solution/leos-open-sourcesoftware-editing-legislation/releases
[16] Tomas Mikolov, Ilya Sutskever, Kai Chen, Greg
Corrado, and Jeffrey Dean. Distributed
Representations of Words and Phrases and their
Compositionality. In Proceedings of NIPS, 2013.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>Agnoloni</given-names>
            <surname>Tommaso</surname>
          </string-name>
          ,
          <string-name>
            <given-names>E</given-names>
            <surname>Francesconi</surname>
          </string-name>
          ,
          <string-name>
            <surname>P Spinosa</surname>
          </string-name>
          ,
          <article-title>xmLegesEditor: an opensource visual XML editor for supporting legal national standards Proceedings of the V legislative XML workshop</article-title>
          , 239-
          <fpage>251</fpage>
          ,
          <year>2007</year>
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <surname>Casanovas</surname>
          </string-name>
          , Pompeu; Palmirani, Monica; Peroni, Silvio; Van Engers, Tom; Vitali, Fabio,
          <article-title>Semantic Web for the Legal Domain: The'next step, «</article-title>
          <source>SEMANTIC WEB»</source>
          ,
          <year>2016</year>
          , 7, pp.
          <fpage>213</fpage>
          -
          <lpage>227</lpage>
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <given-names>Grant</given-names>
            <surname>Vergottini</surname>
          </string-name>
          , https://xcential.com/legispro/standards/
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <given-names>Griglio</given-names>
            <surname>Elena - Marchetti Carlo</surname>
          </string-name>
          ,
          <article-title>La "specialità" delle sfide tecnologiche applicate al drafting parlamentare : dal quadro comparato all'esperienza del Senato italiano / Elena Griglio, Carlo Marchetti, Osservatorio sulle fonti</article-title>
          .
          <source>- 2022, n. 3</source>
          , p.
          <fpage>361</fpage>
          -
          <lpage>386</lpage>
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>[5] LEOS https://joinup.ec.europa.eu/collection/justice-</mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>