<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Publishing DTD v1.1 20151215//EN" "http://jats.nlm.nih.gov/publishing/1.1/JATS-journalpublishing1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:mml="http://www.w3.org/1998/Math/MathML" xml:lang="en" article-type="research-article" dtd-version="1.1">
<front>
<journal-meta>
<journal-id journal-id-type="pmc">CMES</journal-id>
<journal-id journal-id-type="nlm-ta">CMES</journal-id>
<journal-id journal-id-type="publisher-id">CMES</journal-id>
<journal-title-group>
<journal-title>Computer Modeling in Engineering &#x0026; Sciences</journal-title>
</journal-title-group>
<issn pub-type="epub">1526-1506</issn>
<issn pub-type="ppub">1526-1492</issn>
<publisher>
<publisher-name>Tech Science Press</publisher-name>
<publisher-loc>USA</publisher-loc>
</publisher>
</journal-meta>
<article-meta>
<article-id pub-id-type="publisher-id">73258</article-id>
<article-id pub-id-type="doi">10.32604/cmes.2025.073258</article-id>
<article-categories>
<subj-group subj-group-type="heading">
<subject>Article</subject>
</subj-group>
</article-categories>
<title-group>
<article-title>A Keyword-Guided Training Approach to Large Language Models for Judicial Document Generation</article-title>
<alt-title alt-title-type="left-running-head">A Keyword-Guided Training Approach to Large Language Models for Judicial Document Generation</alt-title>
<alt-title alt-title-type="right-running-head">A Keyword-Guided Training Approach to Large Language Models for Judicial Document Generation</alt-title>
</title-group>
<contrib-group>
<contrib id="author-1" contrib-type="author" corresp="yes">
<name name-style="western"><surname>Peng</surname><given-names>Yi-Ting</given-names></name><xref ref-type="aff" rid="aff-1">1</xref><email>164193@mail.fju.edu.tw</email></contrib>
<contrib id="author-2" contrib-type="author">
<name name-style="western"><surname>Lei</surname><given-names>Chin-Laung</given-names></name><xref ref-type="aff" rid="aff-2">2</xref></contrib>
<aff id="aff-1"><label>1</label><institution>Department of Computer Science and Information Engineering, Fu Jen Catholic University</institution>, <addr-line>New Taipei, 242062</addr-line>, <country>Taiwan</country></aff>
<aff id="aff-2"><label>2</label><institution>Department of Electrical Engineering, National Taiwan University</institution>, <addr-line>Taipei, 106319</addr-line>, <country>Taiwan</country></aff>
</contrib-group>
<author-notes>
<corresp id="cor1"><label>&#x002A;</label>Corresponding Author: Yi-Ting Peng. Email: <email>164193@mail.fju.edu.tw</email></corresp>
</author-notes>
<pub-date date-type="collection" publication-format="electronic">
<year>2025</year>
</pub-date>
<pub-date date-type="pub" publication-format="electronic">
<day>23</day><month>12</month><year>2025</year>
</pub-date>
<volume>145</volume>
<issue>3</issue>
<fpage>3969</fpage>
<lpage>3992</lpage>
<history>
<date date-type="received">
<day>14</day>
<month>09</month>
<year>2025</year>
</date>
<date date-type="accepted">
<day>30</day>
<month>10</month>
<year>2025</year>
</date>
</history>
<permissions>
<copyright-statement>&#x00A9; 2025 The Authors.</copyright-statement>
<copyright-year>2025</copyright-year>
<copyright-holder>Published by Tech Science Press.</copyright-holder>
<license xlink:href="https://creativecommons.org/licenses/by/4.0/">
<license-p>This work is licensed under a <ext-link ext-link-type="uri" xlink:type="simple" xlink:href="https://creativecommons.org/licenses/by/4.0/">Creative Commons Attribution 4.0 International License</ext-link>, which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.</license-p>
</license>
</permissions>
<self-uri content-type="pdf" xlink:href="TSP_CMES_73258.pdf"></self-uri>
<abstract>
<p>The rapid advancement of Large Language Models (LLMs) has enabled their application in diverse professional domains, including law. However, research on automatic judicial document generation remains limited, particularly for Taiwanese courts. This study proposes a keyword-guided training framework that enhances LLMs&#x2019; ability to generate structured and semantically coherent judicial decisions in Chinese. The proposed method first employs LLMs to extract representative legal keywords from absolute court judgments. Then it integrates these keywords into Supervised Fine-Tuning (SFT) and Reinforcement Learning with Human Feedback using Proximal Policy Optimization (RLHF-PPO). Experimental evaluations using models such as Chinese Alpaca 7B and TAIDE-LX-7B demonstrate that keyword-guided training significantly improves generation quality, achieving ROUGE-1, ROUGE-2, and ROUGE-L score gains of up to 17%, 16%, and 20%, respectively. The results confirm that the proposed framework effectively aligns generated judgments with human-written legal logic and structural conventions. This research advances domain-adaptive LLM fine-tuning strategies and establishes a technical foundation for AI-assisted judicial document generation in the Taiwanese legal context. This research provides empirical evidence that domain-adaptive LLM fine-tuning strategies can significantly improve performance in complex, structured legal text generation.</p>
</abstract>
<kwd-group kwd-group-type="author">
<kwd>Legal AI</kwd>
<kwd>large language models</kwd>
<kwd>natural language processing</kwd>
<kwd>generative AI</kwd>
<kwd>legal document generation</kwd>
</kwd-group>
</article-meta>
</front>
<body>
<sec id="s1">
<label>1</label>
<title>Introduction</title>
<p>The rapid advancement of big data and computing capability has propelled the development of artificial intelligence. Since the emergence of Convolutional Neural Networks (CNNs), Recurrent Neural Networks (RNNs), and Transformers, along with the continuous advancements in hardware computing speeds, various Large Language Models (LLMs) have been progressively developed. For example, OpenAI&#x2019;s ChatGPT, Meta&#x2019;s Llama, Taiwan National Science and Technology Council&#x2019;s TAIDE, and Anthropic&#x2019;s Claude.</p>
<p>In addition to standard applications such as customer service dialogues and foreign language translation, LLMs have gradually been introduced into specialized domains, including healthcare, tourism, and law [<xref ref-type="bibr" rid="ref-1">1</xref>&#x2013;<xref ref-type="bibr" rid="ref-4">4</xref>]. However, research on legal text generation in Taiwan remains limited. Most existing studies focus on English corpora, while Chinese legal documents are comparatively underexplored. Moreover, the absence of a comprehensive Chinese legal corpus makes it difficult for general-purpose language models to capture the semantic and structural features of legal texts. Therefore, a keyword-guided training approach is necessary to enhance the quality of text generation. Given these challenges, this study aims to bridge the gap by adapting large language models to the Taiwanese legal context. Specifically, a keyword-guided training approach is proposed to enhance the quality of text generation.</p>
<p>The advent of LLMs has significantly transformed workflows in many industries, including law. However, existing LLMs cannot be directly applied in specialized fields due to their lack of domain-specific knowledge. Moreover, most research focuses on English legal texts, leaving a gap for Chinese-language judicial documents. This study addresses this gap by introducing a keyword-guided training framework for generating Taiwanese court judgments. The research fine-tuned LLMs and employed the case fact descriptions to generate judgments automatically.</p>
<p>Research indicates that Taiwan District Court judges close between 56 and 80 cases monthly. The data reveals the substantial caseload shouldered by Taiwanese judges, who handle more than three cases daily. Tasks such as case adjudication and judgment drafting significantly burden judicial personnel.<xref ref-type="fn" rid="fn-1"><sup>1</sup></xref><fn id="fn-1">
<label>1</label><p>Hoyle &#x0026; Chuan-Fen, 2019, <italic>The Death Penalty Project</italic> (policy report).</p></fn></p>
<p>However, legal documents such as judicial judgments present challenges, including their extensive length, abundance of specialized legal terminology, and high standards for accuracy. When traditional Sequence-to-Sequence generation methods use lengthy case descriptions as direct input, the model can easily overlook crucial details, focus excessively on repetitive sentences, leading to factual deviations, or even have errors in legal understanding.</p>
<p>Therefore, this study proposes a &#x201C;keyword-guided training framework&#x201D; to generate Chinese legal judgments. Before text generation, we first utilize LLMs to extract the key legal points of a case as keywords. This approach offers two main advantages: First, they serve as semantic guides, compelling the model to structure the generated content around the most critical persons, places, events, and legal concepts. This ensures the relevance of the content and its factual basis. Second, it deconstructs the complex task of &#x201C;long-text generation&#x201D; into a more controllable &#x201C;Concept-to-Text&#x201D; task, effectively mitigating the risk of the model producing factual hallucinations. This framework is designed to guide the model to not only learn the superficial forms of language but also to master the inherent structure and logic of legal documents, thereby enhancing the quality and practical utility of the generated draft judgments.</p>
<p>This research focuses on criminal court judgments from Taiwan and validates the approach&#x2019;s technical feasibility, and offers a practical method to alleviate judicial workloads through AI-assisted document generation. As shown in <xref ref-type="fig" rid="fig-1">Fig. 1</xref>, a comparison is made between the traditional judgment production process and the proposed framework. Furthermore, given the high societal impact of judicial decisions, this study acknowledges and discusses ethical considerations such as fairness, accountability, and transparency. Therefore, this work contributes to the technical advancement of legal Natural Language Processing (NLP) and the broader discourse on the responsible deployment of artificial intelligence in sensitive domains.</p>
<fig id="fig-1">
<label>Figure 1</label>
<caption>
<title>The concept of the proposed method</title>
</caption>
<graphic mimetype="image" mime-subtype="tif" xlink:href="CMES_73258-fig-1.tif"/>
</fig>
</sec>
<sec id="s2">
<label>2</label>
<title>Related Work</title>
<p>In this section, we introduce two parts of the literature review relevant to our proposed method: the technologies and applications of LLMs, particularly their applications in the legal domain, and research related to document drafting, explicitly focusing on their applications in the legal domain. As discussed in the previous section, the generation of judicial documents poses unique challenges for LLMs due to linguistic complexity and domain-specific semantics. To situate our proposed approach within the existing research landscape, this section reviews two major lines of related work: (1) applications of LLMs in the legal domain, and (2) prior studies on legal document drafting.</p>
<sec id="s2_1">
<label>2.1</label>
<title>LLMs in the Legal Domain</title>
<p>Applying AI to the legal domain is inherently complex due to the field&#x2019;s technical nature and jurisdictional variations. Research into utilizing AI in this field has become a popular topic in many countries. Examples include employing BERT (Bidirectional Encoder Representations from Transformers) on Taiwanese court rulings for Legal Judgment Prediction (LJP) [<xref ref-type="bibr" rid="ref-5">5</xref>], developing a Virtual Legal Assistant (VLA) based on Indian law [<xref ref-type="bibr" rid="ref-6">6</xref>], using Pre-trained Language Models for Chinese legal document classification [<xref ref-type="bibr" rid="ref-7">7</xref>], and focusing on EU legislation through the Artificial Intelligence Act (AIA) to address challenges posed by Generative AI [<xref ref-type="bibr" rid="ref-8">8</xref>]. Since the introduction of LLMs, the growth of AI in the legal domain has accelerated even further. Before delving into LLMs, it is essential to understand that the architecture of recent LLMs is typically based on the Transformer architecture. The Transformer was introduced by Google in 2017 [<xref ref-type="bibr" rid="ref-9">9</xref>].</p>
<p>Currently, LLMs are being applied in various professional fields more frequently. For example, Rasmy et al. pre-trained a BERT model using health records and applied it to disease prediction [<xref ref-type="bibr" rid="ref-10">10</xref>]. Peng et al. introduced LLMs into the healthcare domain and proposed GatorTronGPT, which uses a GPT-3 architecture for biomedical natural language processing (NLP) and text generation in healthcare [<xref ref-type="bibr" rid="ref-11">11</xref>]. Savelka et al. applied GPT-4 to analyzing textual data in a task focused on interpreting legal concepts [<xref ref-type="bibr" rid="ref-12">12</xref>]. Wu et al. used existing LLM in the finance domain and proposed an LLM model named BloombergGPT [<xref ref-type="bibr" rid="ref-13">13</xref>]. Each LLM has different training parameters and data sources [<xref ref-type="bibr" rid="ref-14">14</xref>]. Ashish Chouhan and Michael Gertz proposed a &#x201C;LexDrafter&#x201D; framework that uses RAG (Retrieval-Augmented Generation) and LLMs to define terminology in these legal documents [<xref ref-type="bibr" rid="ref-15">15</xref>].</p>
<p>LLMs may produce answers that are not applicable due to differences in the training data of the original LLMs, especially in the legal domain, where laws vary by country. For example, legal professionals in the United Kingdom using ChatGPT may find that ChatGPT responses are primarily based on US law rather than UK law [<xref ref-type="bibr" rid="ref-16">16</xref>]. Therefore, existing generative LLMs cannot be directly applied in the legal domain; they must be supplemented with legal data and undergo SFT to be applicable in different countries. El Hamdani et al. added legal data to multiple LLMs and trained multiple LLMs, and the experimental results demonstrated improved performance [<xref ref-type="bibr" rid="ref-17">17</xref>].</p>
<p>In 2019, Ziegler et al. proposed Reinforcement Learning from Human Feedback (RLHF) [<xref ref-type="bibr" rid="ref-18">18</xref>]. Training LLMs typically involve three stages: Pre-training Language Model, Supervised Fine-Tuning (SFT), and RLHF (Reinforcement Learning from Human Feedback).</p>
<p>RLHF (Reinforcement Learning with Human Feedback) was used in this experiment, and the model was optimized using PPO (Proximal Policy Optimization) [<xref ref-type="bibr" rid="ref-18">18</xref>&#x2013;<xref ref-type="bibr" rid="ref-21">21</xref>]. Zheng et al. pointed out that under the RLHF framework, implementing policy constraints through the PPO algorithm can improve the effectiveness of PPO&#x2019;s results [<xref ref-type="bibr" rid="ref-22">22</xref>]. The study by Rahmani et al. shows that the judgments generated by fine-tuned LLMs have the highest correlation with human judgments. Therefore, this study also uses LLM-generated judgments for PPO training, enabling the LLM&#x2019;s outputs to become increasingly closer to human-written judgments [<xref ref-type="bibr" rid="ref-23">23</xref>].</p>
<p>Adopting the Reinforcement Learning with Human Feedback using Proximal Policy Optimization (RLHF-PPO) strategy. RLHF can be divided into three phases: pre-training and a language model. Training a reward model and fine-tuning the LM with reinforcement learning. While the aforementioned studies focus on adapting LLM architectures and training methods for legal understanding, fewer works have explored how these models can be applied to the actual drafting of legal documents. Therefore, the following subsection reviews research addressing document generation and drafting within the legal domain.</p>
</sec>
<sec id="s2_2">
<label>2.2</label>
<title>Document Drafting in the Legal Domain</title>
<p>In the 1990s, the main difficulty of drafting documents in the legal domain is that the intended objectives and the stylistic guidelines are often unclear [<xref ref-type="bibr" rid="ref-24">24</xref>]. However, with the advancement of AI and computing resources in recent years, legal syntax and sentence structure issues that were once difficult to handle can now be addressed by incorporating LLMs. Therefore, document drafting is one of the legal applications of LLMs. Here, document drafting differs from traditional legal drafting. Butt define legal drafting as the written form of legal rights, privileges, functions, obligations, or statuses [<xref ref-type="bibr" rid="ref-25">25</xref>]. Savelka utilized GPT to extract legal text and semantic annotation of legal documents. Experimental results demonstrated that this approach is highly effective [<xref ref-type="bibr" rid="ref-26">26</xref>]. Deroy et al. believe that generative LLMs generally outperform extractive methods. However, experiments and analyses conducted on legal documents from the United States, the United Kingdom, and India have revealed inconsistencies and hallucinations in the outputs of these generative LLMs [<xref ref-type="bibr" rid="ref-27">27</xref>].</p>
<p>Furthermore, studies have indicated that LLMs significantly improve their performance on legal issues after training. However, they still face challenges with specific and detailed tasks, such as legal document drafting. Generating legal documents must create a reasoning tree, which adds complexity. Branting et al. utilized domain and discourse knowledge to establish a document design model [<xref ref-type="bibr" rid="ref-28">28</xref>]. Markovi&#x0107; and Gostoji propose the LEDAS (LEgal Document Assembly System) for the interactive assembly of legal documents [<xref ref-type="bibr" rid="ref-29">29</xref>]. Narendra et al. proposed a large language model (LLM) based approach for comparing legal contracts [<xref ref-type="bibr" rid="ref-30">30</xref>]. Westermann creates a framework to establish semistructured legal reasoning and drafting [<xref ref-type="bibr" rid="ref-31">31</xref>]. Castano et al. proposed e a knowledge-based service architecture for legal document building based on Natural Language Processing and learning techniques, to semantically analyze a database of ingested legal documents and propose the most prominent and pertinent textual suggestions for new document composition [<xref ref-type="bibr" rid="ref-32">32</xref>]. Liu et al. proposed a method that can generate high-quality summaries of court judgment documents [<xref ref-type="bibr" rid="ref-33">33</xref>].</p>
<p>However, these works primarily focus on information extraction or summarization, rather than direct generation of full judgments. Moreover, most research has concentrated on English-language corpora, while Chinese legal documents&#x2014;which exhibit distinct linguistic and structural characteristics&#x2014;remain underexplored. Existing approaches also tend to apply generic pre-trained models directly, lacking mechanisms for domain-specific semantic adaptation. Consequently, generated texts often suffer from factual inconsistencies and poor logical coherence. This study introduces a keyword-guided fine-tuning framework that explicitly incorporates key legal terms into the LLM training process to address these gaps. By aligning the model&#x2019;s generation with Taiwanese judicial judgments&#x2019; semantic and structural conventions, the proposed method seeks to improve the factual accuracy and discourse consistency of automatically generated legal documents. Building upon the limitations identified in the previous section, this study designs a keyword-guided fine-tuning framework that integrates keyword extraction, supervised fine-tuning (SFT), and reinforcement learning with human feedback (RLHF-PPO) to improve judgment generation quality.</p>
</sec>
</sec>
<sec id="s3">
<label>3</label>
<title>Materials and Methods</title>
<sec id="s3_1">
<label>3.1</label>
<title>Materials</title>
<p>The data used in this study includes judgments from the Judicial Yuan and the criminal law code. This study uses the injury judgments as the experimental dataset. This dataset is a judgments dataset collected and compiled in a previous study [<xref ref-type="bibr" rid="ref-5">5</xref>]. The injury dataset comprises 9103 records. Considering computational resources, we trained the model using the first 500 and 1000 words of the judgments in our dataset. Since extracting keywords from Taiwanese court judgments requires language models that align with linguistic characteristics, language model choice is crucial. Therefore, this study uses the Taiwan official trained TAIDELX-7B as the LLM for keyword extraction, with the process outlined in <xref ref-type="fig" rid="fig-2">Fig. 2</xref>. After the keyword extraction step, data cleaning is conducted using the LLM. This involves removing records where keyword extraction with TAIDELX-7B failed. Such failures include generating blank keywords or duplicating the original main text of the judgment, both of which are categorized as unsuccessful data entries. After the data processing stage, 7607 complete records were obtained and used to train the Reward Model. Additionally, to evaluate the accuracy of our method, we compare the generation performance of different Generative Large Language Models (Generative LLMs). The experimental results are measured using ROUGE-1, ROUGE-2, and ROUGE-L as evaluation metrics.</p>
<fig id="fig-2">
<label>Figure 2</label>
<caption>
<title>The concept diagram for the judgments issue of the generative language model research</title>
</caption>
<graphic mimetype="image" mime-subtype="tif" xlink:href="CMES_73258-fig-2.tif"/>
</fig>
<p>The main text of the original injury judgments is referred to as the &#x2018;main text&#x2019;. This study employs LLMs to extract keywords from the main text, referred to as &#x2018;Key words&#x2019;. Subsequently, this study utilizes LLMs to automatically generate judicial judgments, referred to as &#x2018;Generative judgment&#x2019;, and compares the performance of multiple different LLMs in generating judgments.</p>
</sec>
<sec id="s3_2">
<label>3.2</label>
<title>Proposed Method</title>
<p>The data used in this study primarily consists of judgments from the Judicial Yuan, with injury case judgments serving as the experimental dataset. This dataset, a collection of judgments compiled in a previous study, comprises 9103 records. Considering computational resource constraints and to establish a foundational proof-of-concept, this study focuses on generating the initial and most critical parts of the judgments; hence, length limits of 500 and 1000 words were set for model training.</p>
<p>This study uses generative language models to support legal judgment generation. Specifically, Meta&#x2019;s LLM Llama [<xref ref-type="bibr" rid="ref-34">34</xref>] and TAIDE-LX-7B [<xref ref-type="bibr" rid="ref-35">35</xref>] are adopted for comparative experiments. These models automatically generate judgments based on objective trial conditions, existing judgments, and legal texts. In general content-generation tasks, the primary approach involves using pre-trained LLMs to produce text. However, many large language models are designed with AGI-oriented objectives and lack sufficient datasets of Taiwanese judgments written in Chinese. We propose a keyword-based training method combining SFT and RLHF-PPO to address this limitation and enhance model performance.</p>
<p>The methodological workflow is illustrated in <xref ref-type="fig" rid="fig-2">Fig. 2</xref>. After collecting the judgments and processing them in the data processing stage, keywords are extracted using LLMs. Subsequently, these extracted judgment keywords are used to generate judgments. The generated judgments and original judgments are then used to train a reward model. This reward model is utilized for PPO training, ultimately resulting in the RLHF-PPO model. The experiment result will show the ROUGE scores of each LLM after SFT and the ROUGE scores of the RLHF-PPO model. The calculation max reward of RLHF is shown in <xref ref-type="disp-formula" rid="eqn-1">Eq. (1)</xref> [<xref ref-type="bibr" rid="ref-19">19</xref>].
<disp-formula id="eqn-1"><label>(1)</label><mml:math id="mml-eqn-1" display="block"><mml:munder><mml:mo movablelimits="true" form="prefix">max</mml:mo><mml:mrow><mml:msub><mml:mi>&#x03C0;</mml:mi><mml:mi>&#x03B8;</mml:mi></mml:msub></mml:mrow></mml:munder><mml:msub><mml:mrow><mml:mi mathvariant="double-struck">E</mml:mi></mml:mrow><mml:mrow><mml:mi>x</mml:mi><mml:mo>&#x223C;</mml:mo><mml:mrow><mml:mi>&#x1D49F;</mml:mi></mml:mrow><mml:mo>,</mml:mo><mml:mi>y</mml:mi><mml:mo>&#x223C;</mml:mo><mml:msub><mml:mi>&#x03C0;</mml:mi><mml:mi>&#x03B8;</mml:mi></mml:msub><mml:mo stretchy="false">(</mml:mo><mml:mi>y</mml:mi><mml:mrow><mml:mo stretchy="false">|</mml:mo></mml:mrow><mml:mi>x</mml:mi><mml:mo stretchy="false">)</mml:mo></mml:mrow></mml:msub><mml:mstyle scriptlevel="0"><mml:mrow><mml:mo maxsize="2.047em" minsize="2.047em">[</mml:mo></mml:mrow></mml:mstyle><mml:msub><mml:mi>r</mml:mi><mml:mi>&#x03D5;</mml:mi></mml:msub><mml:mo stretchy="false">(</mml:mo><mml:mi>x</mml:mi><mml:mo>,</mml:mo><mml:mi>y</mml:mi><mml:mo stretchy="false">)</mml:mo><mml:mstyle scriptlevel="0"><mml:mrow><mml:mo maxsize="2.047em" minsize="2.047em">]</mml:mo></mml:mrow></mml:mstyle><mml:mo>&#x2212;</mml:mo><mml:mi>&#x03B2;</mml:mi><mml:msub><mml:mrow><mml:mi mathvariant="double-struck">D</mml:mi></mml:mrow><mml:mrow><mml:mrow><mml:mtext>KL</mml:mtext></mml:mrow></mml:mrow></mml:msub><mml:mstyle scriptlevel="0"><mml:mrow><mml:mo maxsize="1.2em" minsize="1.2em">[</mml:mo></mml:mrow></mml:mstyle><mml:msub><mml:mi>&#x03C0;</mml:mi><mml:mi>&#x03B8;</mml:mi></mml:msub><mml:mo stretchy="false">(</mml:mo><mml:mi>y</mml:mi><mml:mrow><mml:mo stretchy="false">|</mml:mo></mml:mrow><mml:mi>x</mml:mi><mml:mo stretchy="false">)</mml:mo><mml:mo fence="false" stretchy="false">&#x2016;</mml:mo><mml:msub><mml:mi>&#x03C0;</mml:mi><mml:mrow><mml:mrow><mml:mtext>ref</mml:mtext></mml:mrow></mml:mrow></mml:msub><mml:mo stretchy="false">(</mml:mo><mml:mi>y</mml:mi><mml:mrow><mml:mo stretchy="false">|</mml:mo></mml:mrow><mml:mi>x</mml:mi><mml:mo stretchy="false">)</mml:mo><mml:mstyle scriptlevel="0"><mml:mrow><mml:mo maxsize="1.2em" minsize="1.2em">]</mml:mo></mml:mrow></mml:mstyle></mml:math></disp-formula></p>
<sec id="s3_2_1">
<label>3.2.1</label>
<title>Parameter-Efficient Fine-Tuning (PEFT) and Low-Rank Adaptation (LoRA)</title>
<p>Fine-tuning large pre-trained models is often prohibitively costly due to their scale. Hence, reducing pre-training LLMs&#x2019; parameters is becoming increasingly important. Lin et al. use the residual adapter layers to apply LLM in some task-specific [<xref ref-type="bibr" rid="ref-36">36</xref>]. Parameter-efficient fine-tuning (PEFT) methods enable the efficient adaptation of large pre-trained models to various downstream applications by only fine-tuning a small number of (extra) model parameters instead of all the model&#x2019;s parameters [<xref ref-type="bibr" rid="ref-37">37</xref>,<xref ref-type="bibr" rid="ref-38">38</xref>]. LoRA primarily reduces the number of parameters that need to be trained, making it possible to achieve LLM training objectives within limited resources. As shown in <xref ref-type="fig" rid="fig-3">Fig. 3</xref>, by keeping the original weight matrix W unchanged and only adding an AB matrix, the training parameters are significantly reduced, thereby achieving the training goals [<xref ref-type="bibr" rid="ref-39">39</xref>]. In this study, the Chinese alpaca 7B and Chinese alpaca 13B are models trained from Llama 2 7B and Llama 2 13B using Parameter-Efficient Fine-Tuning (PEFT) and Low-Rank Adaptation (LoRA).</p>
<fig id="fig-3">
<label>Figure 3</label>
<caption>
<title>LoRA training parameter structure</title>
</caption>
<graphic mimetype="image" mime-subtype="tif" xlink:href="CMES_73258-fig-3.tif"/>
</fig>
</sec>
<sec id="s3_2_2">
<label>3.2.2</label>
<title>Process of Extracting Keywords</title>
<p>In this study, the collected judgments cannot be directly subjected to the keyword extraction phase because the original judgment documents require noise reduction. For example, the raw judgment data may contain irrelevant fields. These irrelevant fields must first be processed during the data processing stage to extract the necessary judgment text before proceeding to the keyword extraction module. The model was then prompted with the following instruction: &#x2018;Extract 10 important keywords, each not exceeding 10 words.&#x2019;</p>
<p><xref ref-type="fig" rid="fig-4">Fig. 4</xref> illustrates the keyword extraction process used in this study, which primarily involves extracting the first 500 words and the first 1000 words of the main text for experiments. Given the judgment text <inline-formula id="ieqn-1"><mml:math id="mml-ieqn-1"><mml:msub><mml:mi>T</mml:mi><mml:mi>i</mml:mi></mml:msub></mml:math></inline-formula>, the LLM extracts a set of salient legal keywords:<disp-formula id="eqn-2"><label>(2)</label><mml:math id="mml-eqn-2" display="block"><mml:msub><mml:mi>K</mml:mi><mml:mi>i</mml:mi></mml:msub><mml:mo>=</mml:mo><mml:msub><mml:mi>f</mml:mi><mml:mrow><mml:mrow><mml:mtext>extract</mml:mtext></mml:mrow></mml:mrow></mml:msub><mml:mo stretchy="false">(</mml:mo><mml:msub><mml:mi>T</mml:mi><mml:mi>i</mml:mi></mml:msub><mml:mo>;</mml:mo><mml:mspace width="thinmathspace" /><mml:msub><mml:mi>&#x03B8;</mml:mi><mml:mi>e</mml:mi></mml:msub><mml:mo stretchy="false">)</mml:mo></mml:math></disp-formula>where <inline-formula id="ieqn-2"><mml:math id="mml-ieqn-2"><mml:msub><mml:mi>K</mml:mi><mml:mi>i</mml:mi></mml:msub><mml:mo>=</mml:mo><mml:mo fence="false" stretchy="false">{</mml:mo><mml:msub><mml:mi>k</mml:mi><mml:mrow><mml:mi>i</mml:mi><mml:mo>,</mml:mo><mml:mn>1</mml:mn></mml:mrow></mml:msub><mml:mo>,</mml:mo><mml:mspace width="thinmathspace" /><mml:msub><mml:mi>k</mml:mi><mml:mrow><mml:mi>i</mml:mi><mml:mo>,</mml:mo><mml:mn>2</mml:mn></mml:mrow></mml:msub><mml:mo>,</mml:mo><mml:mo>&#x2026;</mml:mo><mml:mo>,</mml:mo><mml:mspace width="thinmathspace" /><mml:msub><mml:mi>k</mml:mi><mml:mrow><mml:mi>i</mml:mi><mml:mo>,</mml:mo><mml:mi>m</mml:mi></mml:mrow></mml:msub><mml:mo fence="false" stretchy="false">}</mml:mo></mml:math></inline-formula> and <inline-formula id="ieqn-3"><mml:math id="mml-ieqn-3"><mml:msub><mml:mi>&#x03B8;</mml:mi><mml:mi>e</mml:mi></mml:msub></mml:math></inline-formula> denote the parameters of the extraction model. The generative model produces the predicted judgment <inline-formula id="ieqn-4"><mml:math id="mml-ieqn-4"><mml:msub><mml:mrow><mml:mover><mml:mi>Y</mml:mi><mml:mo stretchy="false">&#x005E;</mml:mo></mml:mover></mml:mrow><mml:mi>i</mml:mi></mml:msub></mml:math></inline-formula> based on keywords:
<disp-formula id="eqn-3"><label>(3)</label><mml:math id="mml-eqn-3" display="block"><mml:msub><mml:mrow><mml:mover><mml:mi>Y</mml:mi><mml:mo stretchy="false">&#x005E;</mml:mo></mml:mover></mml:mrow><mml:mi>i</mml:mi></mml:msub><mml:mo>=</mml:mo><mml:msub><mml:mi>f</mml:mi><mml:mrow><mml:mrow><mml:mtext>gen</mml:mtext></mml:mrow></mml:mrow></mml:msub><mml:mo stretchy="false">(</mml:mo><mml:msub><mml:mi>K</mml:mi><mml:mi>i</mml:mi></mml:msub><mml:mo>;</mml:mo><mml:mspace width="thinmathspace" /><mml:msub><mml:mi>&#x03B8;</mml:mi><mml:mi>g</mml:mi></mml:msub><mml:mo stretchy="false">)</mml:mo><mml:mo>,</mml:mo></mml:math></disp-formula>where <inline-formula id="ieqn-5"><mml:math id="mml-ieqn-5"><mml:msub><mml:mi>&#x03B8;</mml:mi><mml:mi>g</mml:mi></mml:msub></mml:math></inline-formula> represents the parameters of the generative model.</p>
<fig id="fig-4">
<label>Figure 4</label>
<caption>
<title>The flowchart of keyword extraction</title>
</caption>
<graphic mimetype="image" mime-subtype="tif" xlink:href="CMES_73258-fig-4.tif"/>
</fig>
</sec>
<sec id="s3_2_3">
<label>3.2.3</label>
<title>Reward Model</title>
<p>In the Reward Model phase, two types of outputs are required, and it is necessary to label which output is better or worse. The main text of the original judgment produced by the court is extracted and named &#x2018;Completion yj&#x2019;. Then, a judgment is generated using TAIDE-LX-7B and the keywords generated in the previous stage as prompts. The judgment obtained at this stage is named &#x2018;Completion yk&#x2019;. The original judgment is labeled as the higher-quality judgment (Completion yj), while the judgment generated using TAIDE-LX-7B is labeled as the lower-quality judgment (Completion yk) to train the Reward Model. The loss value is calculated as shown in <xref ref-type="disp-formula" rid="eqn-4">Eq. (4)</xref> [<xref ref-type="bibr" rid="ref-40">40</xref>].
<disp-formula id="eqn-4"><label>(4)</label><mml:math id="mml-eqn-4" display="block"><mml:mrow><mml:mtext>Loss</mml:mtext></mml:mrow><mml:mo>=</mml:mo><mml:mo>&#x2212;</mml:mo><mml:mi>log</mml:mi><mml:mo>&#x2061;</mml:mo><mml:mrow><mml:mo>(</mml:mo><mml:mi>&#x03C3;</mml:mi><mml:mrow><mml:mo>(</mml:mo><mml:msub><mml:mi>R</mml:mi><mml:mrow><mml:mrow><mml:mtext>Completion&#xA0;</mml:mtext></mml:mrow><mml:mi>y</mml:mi><mml:mi>j</mml:mi></mml:mrow></mml:msub><mml:mo>&#x2212;</mml:mo><mml:msub><mml:mi>R</mml:mi><mml:mrow><mml:mrow><mml:mtext>Completion&#xA0;</mml:mtext></mml:mrow><mml:mi>y</mml:mi><mml:mi>k</mml:mi></mml:mrow></mml:msub><mml:mo>)</mml:mo></mml:mrow><mml:mo>)</mml:mo></mml:mrow></mml:math></disp-formula></p>
<p>This experiment uses the BERT model as the base model to train the reward model [<xref ref-type="bibr" rid="ref-41">41</xref>]. The completions <italic>yj</italic> and <italic>yk</italic> are separately input into the BERT model to calculate the loss values. The process is shown in <xref ref-type="fig" rid="fig-5">Fig. 5</xref>.</p>
<fig id="fig-5">
<label>Figure 5</label>
<caption>
<title>The flowchart of reward model</title>
</caption>
<graphic mimetype="image" mime-subtype="tif" xlink:href="CMES_73258-fig-5.tif"/>
</fig>
</sec>
</sec>
</sec>
<sec id="s4">
<label>4</label>
<title>Results</title>
<p>This study aims to evaluate the effectiveness of a keyword-guided training approach for generating Taiwanese legal judgments. This section will present the experimental results and provide a discussion from multiple perspectives, including model performance, the effectiveness of the training methods, and qualitative analysis. Considering computational costs and the openness of LLMs&#x2019; source code, this experiment compares eight LLMs: Llama 2 7B, Llama 2 13B, Chinese alpaca 2 7B, Chinese alpaca 2 13B, TAIDE-LX-7B, Llama 3 Taiwan-8B, Llama 3 8B, and Llama 3 Chinese 8B. The experimental results indicate that when using Llama 3 Taiwan-8B, the ROUGE-1, ROUGE-2, and ROUGE-L scores are the highest. We believe this is related to the original training process of Llama 3 Taiwan-8B, which included a large amount of data from the Taiwanese government and judicial departments. The experimental results, summarized in <xref ref-type="table" rid="table-1">Tables 1</xref> and <xref ref-type="table" rid="table-2">2</xref>, compare the generation performance of different LLMs.</p>
<table-wrap id="table-1">
<label>Table 1</label>
<caption>
<title>ROUGE scores of the original models and SFT-tuned models (500-word judgment)</title>
</caption>
<table>
<colgroup>
<col align="center"/>
<col align="center"/>
<col align="center"/>
<col align="center"/>
<col align="center"/>
</colgroup>
<thead>
<tr>
<th></th>
<th>Models/Metrics</th>
<th>ROUGE-1</th>
<th>ROUGE-2</th>
<th>ROUGE-L</th>
</tr>
</thead>
<tbody>
<tr>
<td rowspan="10">Llama 2</td>
<td>Llama 2 7B</td>
<td>0.3109</td>
<td>0.1226</td>
<td>0.2483</td>
</tr>
<tr>
<td>Llama 2 7B(SFT)</td>
<td>0.3076</td>
<td>0.1718</td>
<td>0.2879</td>
</tr>
<tr>
<td>Llama 2 13B</td>
<td>0.3795</td>
<td>0.141</td>
<td>0.2985</td>
</tr>
<tr>
<td>Llama 2 13B(SFT)</td>
<td>0.3694</td>
<td>0.2327</td>
<td>0.3488</td>
</tr>
<tr>
<td>Chinese alpaca 2 7B</td>
<td>0.3623</td>
<td>0.2379</td>
<td>0.3358</td>
</tr>
<tr>
<td>Chinese alpaca 2 7B (SFT)</td>
<td>0.4241</td>
<td>0.2765</td>
<td>0.4019</td>
</tr>
<tr>
<td>Chinese alpaca 2 13B</td>
<td>0.34</td>
<td>0.2117</td>
<td>0.3191</td>
</tr>
<tr>
<td><bold>Chinese alpaca 2 13B (SFT)</bold></td>
<td><bold>0.4716</bold></td>
<td><bold>0.3177</bold></td>
<td><bold>0.4412</bold></td>
</tr>
<tr>
<td>TAIDE-LX-7B</td>
<td>0.3741</td>
<td>0.2217</td>
<td>0.3343</td>
</tr>
<tr>
<td>TAIDE-LX-7B (SFT)</td>
<td>0.4358</td>
<td>0.2871</td>
<td>0.4007</td>
</tr>
<tr>
<td rowspan="6">Llama 3</td>
<td>Llama 3 Taiwan-8B</td>
<td>0.3834</td>
<td>0.2219</td>
<td>0.3445</td>
</tr>
<tr>
<td><bold>Llama 3 Taiwan-8B (SFT)</bold></td>
<td><bold>0.4886</bold></td>
<td><bold>0.3224</bold></td>
<td><bold>0.4476</bold></td>
</tr>
<tr>
<td>Llama 3 8B</td>
<td>0.1639</td>
<td>0.1016</td>
<td>0.1479</td>
</tr>
<tr>
<td>Llama 3 8B (SFT)</td>
<td>0.3737</td>
<td>0.2411</td>
<td>0.3431</td>
</tr>
<tr>
<td>Llama 3 Chinese 8B</td>
<td>0.3512</td>
<td>0.2312</td>
<td>0.3210</td>
</tr>
<tr>
<td>Llama 3 Chinese 8B (SFT)</td>
<td>0.4471</td>
<td>0.2747</td>
<td>0.4062</td>
</tr>
</tbody>
</table>
<table-wrap-foot>
<fn id="table-1fn1" fn-type="other">
<p>Note: Bold values indicate the optimal value of ROUGE-1, ROUGE-2 and ROUGE-L.</p>
</fn>
</table-wrap-foot>
</table-wrap><table-wrap id="table-2">
<label>Table 2</label>
<caption>
<title>ROUGE scores of the original models and SFT-tuned models (1000-word judgment)</title>
</caption>
<table>
<colgroup>
<col align="center"/>
<col align="center"/>
<col align="center"/>
<col align="center"/>
<col align="center"/>
</colgroup>
<thead>
<tr>
<th></th>
<th>Models/Metrics</th>
<th>ROUGE-1</th>
<th>ROUGE-2</th>
<th>ROUGE-L</th>
</tr>
</thead>
<tbody>
<tr>
<td rowspan="10">Llama 2</td>
<td>Llama 2 7B</td>
<td>0.306</td>
<td>0.1302</td>
<td>0.237</td>
</tr>
<tr>
<td>Llama 2 7B(SFT)</td>
<td>0.3939</td>
<td>0.2752</td>
<td>0.3598</td>
</tr>
<tr>
<td>Llama 2 13B</td>
<td>0.3095</td>
<td>0.1755</td>
<td>0.281</td>
</tr>
<tr>
<td><bold>Llama 2 13B(SFT)</bold></td>
<td><bold>0.4923</bold></td>
<td><bold>0.3495</bold></td>
<td><bold>0.4511</bold></td>
</tr>
<tr>
<td>Chinese alpaca 2 7B</td>
<td>0.3212</td>
<td>0.1982</td>
<td>0.2904</td>
</tr>
<tr>
<td>Chinese alpaca 2 7B (SFT)</td>
<td>0.4799</td>
<td>0.3398</td>
<td>0.4448</td>
</tr>
<tr>
<td>Chinese alpaca 2 13B</td>
<td>0.3083</td>
<td>0.1753</td>
<td>0.2817</td>
</tr>
<tr>
<td>Chinese alpaca 2 13B (SFT)</td>
<td>0.4777</td>
<td>0.3374</td>
<td>0.4352</td>
</tr>
<tr>
<td>TAIDE-LX-7B</td>
<td>0.1532</td>
<td>0.06056</td>
<td>0.1263</td>
</tr>
<tr>
<td>TAIDE-LX-7B (SFT)</td>
<td>0.403</td>
<td>0.2934</td>
<td>0.3687</td>
</tr>
<tr>
<td rowspan="6">Llama 3</td>
<td>Llama 3 Taiwan-8B</td>
<td>0.3263</td>
<td>0.1905</td>
<td>0.2898</td>
</tr>
<tr>
<td><bold>Llama 3 Taiwan-8B (SFT)</bold></td>
<td><bold>0.5293</bold></td>
<td><bold>0.3665</bold></td>
<td><bold>0.4726</bold></td>
</tr>
<tr>
<td>Llama 3 8B</td>
<td>0.1131</td>
<td>0.06308</td>
<td>0.1017</td>
</tr>
<tr>
<td>Llama 3 8B (SFT)</td>
<td>0.3965</td>
<td>0.2367</td>
<td>0.3444</td>
</tr>
<tr>
<td>Llama 3 Chinese 8B</td>
<td>0.2631</td>
<td>0.1651</td>
<td>0.2373</td>
</tr>
<tr>
<td>Llama 3 Chinese 8B (SFT)</td>
<td>0.4613</td>
<td>0.3165</td>
<td>0.4179</td>
</tr>
</tbody>
</table>
<table-wrap-foot>
<fn id="table-2fn1" fn-type="other">
<p>Note: Bold values indicate the optimal value of ROUGE-1, ROUGE-2 and ROUGE-L.</p>
</fn>
</table-wrap-foot>
</table-wrap>
<sec id="s4_1">
<label>4.1</label>
<title>Performance Metrics</title>
<p>This study uses ROUGE (Recall-Oriented Understudy for Gisting Evaluation) as our metric for evaluating LLM models. This section primarily uses ROUGE-N and ROUGE-L, where N denotes the n-gram length. Countmatch(gramn_nn) represents the maximum number of n-gram overlaps between the candidate summary and the set of reference summaries. When N &#x003D; 1, the metric is ROUGE-1, and so forth. We employ ROUGE-1, ROUGE-2, and ROUGE-L, with their formulas presented in <xref ref-type="disp-formula" rid="eqn-5">Eqs. (5)</xref>&#x2013;<xref ref-type="disp-formula" rid="eqn-7">(7)</xref>.
<disp-formula id="eqn-5"><label>(5)</label><mml:math id="mml-eqn-5" display="block"><mml:mtable columnalign="right left right left right left right left right left right left" rowspacing="3pt" columnspacing="0em 2em 0em 2em 0em 2em 0em 2em 0em 2em 0em" displaystyle="true"><mml:mtr><mml:mtd /><mml:mtd><mml:mrow><mml:mtext>ROUGE-1</mml:mtext></mml:mrow><mml:mo>=</mml:mo><mml:mfrac><mml:mrow><mml:munder><mml:mo>&#x2211;</mml:mo><mml:mrow><mml:mrow><mml:mtext>unigram</mml:mtext></mml:mrow><mml:mo>&#x2208;</mml:mo><mml:mrow><mml:mtext>Ref</mml:mtext></mml:mrow></mml:mrow></mml:munder><mml:mo movablelimits="true" form="prefix">min</mml:mo><mml:mstyle scriptlevel="0"><mml:mrow><mml:mo maxsize="1.2em" minsize="1.2em">(</mml:mo></mml:mrow></mml:mstyle><mml:msub><mml:mrow><mml:mtext>Count</mml:mtext></mml:mrow><mml:mrow><mml:mrow><mml:mtext>Ref</mml:mtext></mml:mrow></mml:mrow></mml:msub><mml:mo stretchy="false">(</mml:mo><mml:mrow><mml:mtext>unigram</mml:mtext></mml:mrow><mml:mo stretchy="false">)</mml:mo><mml:mo>,</mml:mo><mml:msub><mml:mrow><mml:mtext>Count</mml:mtext></mml:mrow><mml:mrow><mml:mrow><mml:mtext>Gen</mml:mtext></mml:mrow></mml:mrow></mml:msub><mml:mo stretchy="false">(</mml:mo><mml:mrow><mml:mtext>unigram</mml:mtext></mml:mrow><mml:mo stretchy="false">)</mml:mo><mml:mstyle scriptlevel="0"><mml:mrow><mml:mo maxsize="1.2em" minsize="1.2em">)</mml:mo></mml:mrow></mml:mstyle></mml:mrow><mml:mrow><mml:munder><mml:mo>&#x2211;</mml:mo><mml:mrow><mml:mrow><mml:mtext>unigram</mml:mtext></mml:mrow><mml:mo>&#x2208;</mml:mo><mml:mrow><mml:mtext>Ref</mml:mtext></mml:mrow></mml:mrow></mml:munder><mml:msub><mml:mrow><mml:mtext>Count</mml:mtext></mml:mrow><mml:mrow><mml:mrow><mml:mtext>Ref</mml:mtext></mml:mrow></mml:mrow></mml:msub><mml:mo stretchy="false">(</mml:mo><mml:mrow><mml:mtext>unigram</mml:mtext></mml:mrow><mml:mo stretchy="false">)</mml:mo></mml:mrow></mml:mfrac></mml:mtd></mml:mtr></mml:mtable></mml:math></disp-formula>
<disp-formula id="eqn-6"><label>(6)</label><mml:math id="mml-eqn-6" display="block"><mml:mtable columnalign="right left right left right left right left right left right left" rowspacing="3pt" columnspacing="0em 2em 0em 2em 0em 2em 0em 2em 0em 2em 0em" displaystyle="true"><mml:mtr><mml:mtd /><mml:mtd><mml:mrow><mml:mtext>ROUGE-2</mml:mtext></mml:mrow><mml:mo>=</mml:mo><mml:mfrac><mml:mrow><mml:munder><mml:mo>&#x2211;</mml:mo><mml:mrow><mml:mrow><mml:mtext>bigram</mml:mtext></mml:mrow><mml:mo>&#x2208;</mml:mo><mml:mrow><mml:mtext>Ref</mml:mtext></mml:mrow></mml:mrow></mml:munder><mml:mo movablelimits="true" form="prefix">min</mml:mo><mml:mstyle scriptlevel="0"><mml:mrow><mml:mo maxsize="1.2em" minsize="1.2em">(</mml:mo></mml:mrow></mml:mstyle><mml:msub><mml:mrow><mml:mtext>Count</mml:mtext></mml:mrow><mml:mrow><mml:mrow><mml:mtext>Ref</mml:mtext></mml:mrow></mml:mrow></mml:msub><mml:mo stretchy="false">(</mml:mo><mml:mrow><mml:mtext>bigram</mml:mtext></mml:mrow><mml:mo stretchy="false">)</mml:mo><mml:mo>,</mml:mo><mml:msub><mml:mrow><mml:mtext>Count</mml:mtext></mml:mrow><mml:mrow><mml:mrow><mml:mtext>Gen</mml:mtext></mml:mrow></mml:mrow></mml:msub><mml:mo stretchy="false">(</mml:mo><mml:mrow><mml:mtext>bigram</mml:mtext></mml:mrow><mml:mo stretchy="false">)</mml:mo><mml:mstyle scriptlevel="0"><mml:mrow><mml:mo maxsize="1.2em" minsize="1.2em">)</mml:mo></mml:mrow></mml:mstyle></mml:mrow><mml:mrow><mml:munder><mml:mo>&#x2211;</mml:mo><mml:mrow><mml:mrow><mml:mtext>bigram</mml:mtext></mml:mrow><mml:mo>&#x2208;</mml:mo><mml:mrow><mml:mtext>Ref</mml:mtext></mml:mrow></mml:mrow></mml:munder><mml:msub><mml:mrow><mml:mtext>Count</mml:mtext></mml:mrow><mml:mrow><mml:mrow><mml:mtext>Ref</mml:mtext></mml:mrow></mml:mrow></mml:msub><mml:mo stretchy="false">(</mml:mo><mml:mrow><mml:mtext>bigram</mml:mtext></mml:mrow><mml:mo stretchy="false">)</mml:mo></mml:mrow></mml:mfrac></mml:mtd></mml:mtr></mml:mtable></mml:math></disp-formula>
<disp-formula id="eqn-7"><label>(7)</label><mml:math id="mml-eqn-7" display="block"><mml:mtable columnalign="right left right left right left right left right left right left" rowspacing="3pt" columnspacing="0em 2em 0em 2em 0em 2em 0em 2em 0em 2em 0em" displaystyle="true"><mml:mtr><mml:mtd /><mml:mtd><mml:mrow><mml:mtext>ROUGE-N</mml:mtext></mml:mrow><mml:mo>=</mml:mo><mml:mfrac><mml:mrow><mml:munder><mml:mo>&#x2211;</mml:mo><mml:mrow><mml:mi>S</mml:mi><mml:mo>&#x2208;</mml:mo><mml:mo fence="false" stretchy="false">{</mml:mo><mml:mrow><mml:mtext>ReferenceSummaries</mml:mtext></mml:mrow><mml:mo fence="false" stretchy="false">}</mml:mo></mml:mrow></mml:munder><mml:munder><mml:mo>&#x2211;</mml:mo><mml:mrow><mml:msub><mml:mrow><mml:mtext>gram</mml:mtext></mml:mrow><mml:mi>n</mml:mi></mml:msub><mml:mo>&#x2208;</mml:mo><mml:mi>S</mml:mi></mml:mrow></mml:munder><mml:msub><mml:mrow><mml:mtext>Count</mml:mtext></mml:mrow><mml:mrow><mml:mrow><mml:mtext>match</mml:mtext></mml:mrow></mml:mrow></mml:msub><mml:mo stretchy="false">(</mml:mo><mml:msub><mml:mrow><mml:mtext>gram</mml:mtext></mml:mrow><mml:mi>n</mml:mi></mml:msub><mml:mo stretchy="false">)</mml:mo></mml:mrow><mml:mrow><mml:munder><mml:mo>&#x2211;</mml:mo><mml:mrow><mml:mi>S</mml:mi><mml:mo>&#x2208;</mml:mo><mml:mo fence="false" stretchy="false">{</mml:mo><mml:mrow><mml:mtext>ReferenceSummaries</mml:mtext></mml:mrow><mml:mo fence="false" stretchy="false">}</mml:mo></mml:mrow></mml:munder><mml:munder><mml:mo>&#x2211;</mml:mo><mml:mrow><mml:msub><mml:mrow><mml:mtext>gram</mml:mtext></mml:mrow><mml:mi>n</mml:mi></mml:msub><mml:mo>&#x2208;</mml:mo><mml:mi>S</mml:mi></mml:mrow></mml:munder><mml:mrow><mml:mtext>Count</mml:mtext></mml:mrow><mml:mo stretchy="false">(</mml:mo><mml:msub><mml:mrow><mml:mtext>gram</mml:mtext></mml:mrow><mml:mi>n</mml:mi></mml:msub><mml:mo stretchy="false">)</mml:mo></mml:mrow></mml:mfrac></mml:mtd></mml:mtr></mml:mtable></mml:math></disp-formula></p>
<p>ROUGE-L, which stands for Longest Common Subsequence, is primarily used to measure the degree of match between the longest common subsequences of the automatically generated summary and those of the reference summary. ROUGE-L can assess the relationships between sentences. In the <xref ref-type="disp-formula" rid="eqn-8">Eqs. (8)</xref>&#x2013;<xref ref-type="disp-formula" rid="eqn-10">(10)</xref>, the <italic>R</italic><sub>lcs</sub> is recall and <italic>P</italic><sub>lcs</sub> is accuracy and <italic>F</italic><sub>lcs</sub> is ROUGE-L.
<disp-formula id="eqn-8"><label>(8)</label><mml:math id="mml-eqn-8" display="block"><mml:mtable columnalign="right left right left right left right left right left right left" rowspacing="3pt" columnspacing="0em 2em 0em 2em 0em 2em 0em 2em 0em 2em 0em" displaystyle="true"><mml:mtr><mml:mtd /><mml:mtd><mml:msub><mml:mi>R</mml:mi><mml:mrow><mml:mrow><mml:mtext>lcs</mml:mtext></mml:mrow></mml:mrow></mml:msub><mml:mo>=</mml:mo><mml:mfrac><mml:mrow><mml:mrow><mml:mtext>LCS</mml:mtext></mml:mrow><mml:mo stretchy="false">(</mml:mo><mml:mi>X</mml:mi><mml:mo>,</mml:mo><mml:mi>Y</mml:mi><mml:mo stretchy="false">)</mml:mo></mml:mrow><mml:mi>m</mml:mi></mml:mfrac></mml:mtd></mml:mtr></mml:mtable></mml:math></disp-formula>
<disp-formula id="eqn-9"><label>(9)</label><mml:math id="mml-eqn-9" display="block"><mml:mtable columnalign="right left right left right left right left right left right left" rowspacing="3pt" columnspacing="0em 2em 0em 2em 0em 2em 0em 2em 0em 2em 0em" displaystyle="true"><mml:mtr><mml:mtd /><mml:mtd><mml:msub><mml:mi>P</mml:mi><mml:mrow><mml:mrow><mml:mtext>lcs</mml:mtext></mml:mrow></mml:mrow></mml:msub><mml:mo>=</mml:mo><mml:mfrac><mml:mrow><mml:mrow><mml:mtext>LCS</mml:mtext></mml:mrow><mml:mo stretchy="false">(</mml:mo><mml:mi>X</mml:mi><mml:mo>,</mml:mo><mml:mi>Y</mml:mi><mml:mo stretchy="false">)</mml:mo></mml:mrow><mml:mi>n</mml:mi></mml:mfrac></mml:mtd></mml:mtr></mml:mtable></mml:math></disp-formula>
<disp-formula id="eqn-10"><label>(10)</label><mml:math id="mml-eqn-10" display="block"><mml:mtable columnalign="right left right left right left right left right left right left" rowspacing="3pt" columnspacing="0em 2em 0em 2em 0em 2em 0em 2em 0em 2em 0em" displaystyle="true"><mml:mtr><mml:mtd /><mml:mtd><mml:msub><mml:mi>F</mml:mi><mml:mrow><mml:mrow><mml:mtext>lcs</mml:mtext></mml:mrow></mml:mrow></mml:msub><mml:mo>=</mml:mo><mml:mfrac><mml:mrow><mml:mo stretchy="false">(</mml:mo><mml:mn>1</mml:mn><mml:mo>+</mml:mo><mml:msup><mml:mi>&#x03B2;</mml:mi><mml:mn>2</mml:mn></mml:msup><mml:mo stretchy="false">)</mml:mo><mml:msub><mml:mi>R</mml:mi><mml:mrow><mml:mrow><mml:mtext>lcs</mml:mtext></mml:mrow></mml:mrow></mml:msub><mml:msub><mml:mi>P</mml:mi><mml:mrow><mml:mrow><mml:mtext>lcs</mml:mtext></mml:mrow></mml:mrow></mml:msub></mml:mrow><mml:mrow><mml:msub><mml:mi>R</mml:mi><mml:mrow><mml:mrow><mml:mtext>lcs</mml:mtext></mml:mrow></mml:mrow></mml:msub><mml:mo>+</mml:mo><mml:msup><mml:mi>&#x03B2;</mml:mi><mml:mn>2</mml:mn></mml:msup><mml:msub><mml:mi>P</mml:mi><mml:mrow><mml:mrow><mml:mtext>lcs</mml:mtext></mml:mrow></mml:mrow></mml:msub></mml:mrow></mml:mfrac></mml:mtd></mml:mtr></mml:mtable></mml:math></disp-formula></p>
</sec>
<sec id="s4_2">
<label>4.2</label>
<title>General Efficacy of Keyword-Guided Fine-Tuning</title>
<p>The experimental results clearly show that for models based on the Llama 2 and Llama 3 frameworks, performance on the judgment generation task improved significantly after keyword-guided Supervised Fine-Tuning (SFT). As seen in <xref ref-type="table" rid="table-1">Tables 1</xref> and <xref ref-type="table" rid="table-2">2</xref>, the SFT-tuned models show substantial increases across the ROUGE-1, ROUGE-2, and ROUGE-L metrics compared to the original base models.</p>

<p>A case in point is the Llama 3 8B model. Its original version, primarily trained on English corpora, performed poorly on the Chinese legal text generation task, with a ROUGE-1 score of only 0.1639. After this study&#x2019;s SFT process, its ROUGE-1 score surged to 0.3737, reaching a level comparable to that of native Chinese models.</p>
<p>This demonstrates that the SFT framework can effectively guide and adapt a general-purpose model&#x2019;s linguistic capabilities to the highly specialized domain of Taiwanese law, enabling it to master specific vocabulary, syntax, and document structures.</p>
<p>Firstly, we conducted Supervised Fine-Tuning (SFT) over five epochs, training for 300 steps using Llama 2 7B and Llama 2 13B. As shown in the loss curves in <xref ref-type="fig" rid="fig-6">Fig. 6</xref>, both LLMs exhibited a clear downward trend in loss values during the training process, with the loss values stabilizing between approximately 240 and 260 steps.</p>
<fig id="fig-6">
<label>Figure 6</label>
<caption>
<title>(<bold>A</bold>) Llama 2 7B and (<bold>B</bold>) Llama 2 13B curves of loss value in 500-word judgments</title>
</caption>
<graphic mimetype="image" mime-subtype="tif" xlink:href="CMES_73258-fig-6.tif"/>
</fig>
<p>Since Llama 2 7B is primarily trained on English datasets, we performed Supervised Fine-Tuning (SFT) using the Chinese version of Llama 2 7B, namely Chinese alpaca 2 7B. As shown in <xref ref-type="fig" rid="fig-7">Fig. 7</xref>, the loss values also exhibited a consistently downward trend.</p>
<fig id="fig-7">
<label>Figure 7</label>
<caption>
<title>(<bold>A</bold>) Chinese alpaca 2 7B and (<bold>B</bold>) Chinese alpaca 2 13B curves of loss value in 500-word judgments</title>
</caption>
<graphic mimetype="image" mime-subtype="tif" xlink:href="CMES_73258-fig-7.tif"/>
</fig>
<p><xref ref-type="fig" rid="fig-8">Fig. 8</xref> shows the loss values obtained from experiments conducted with Llama 3 8B and Llama 3 Chinese 8B. It can be observed that during the Supervised Fine-Tuning (SFT) of these LLMs, the loss values exhibit similar trends, stabilizing between 240 and 260 steps without significant further decreases. Therefore, this experiment&#x2019;s maximum number of training steps is 260.</p>
<fig id="fig-8">
<label>Figure 8</label>
<caption>
<title>(<bold>A</bold>) Llama 3 8B and (<bold>B</bold>) Llama 3 Chinese 8B curves of loss value in 500-word judgments</title>
</caption>
<graphic mimetype="image" mime-subtype="tif" xlink:href="CMES_73258-fig-8.tif"/>
</fig>
<p><xref ref-type="fig" rid="fig-9">Fig. 9</xref> shows the loss values obtained from experiments conducted with TAIDE-LX-7B and Llama-3-Taiwan-8B. It can be observed that during the Supervised Fine-Tuning (SFT) of these LLMs, the loss values exhibit similar trends, stabilizing between 200 and 260 steps without significant further decreases. Therefore, this experiment&#x2019;s maximum number of training steps is 260.</p>
<fig id="fig-9">
<label>Figure 9</label>
<caption>
<title>(<bold>A</bold>) TAIDE-LX-7B and (<bold>B</bold>) Llama-3-Taiwan-8B curves of loss value in 500-word judgments</title>
</caption>
<graphic mimetype="image" mime-subtype="tif" xlink:href="CMES_73258-fig-9.tif"/>
</fig>
<p>Considering computational resources, we take Chinese alpaca 7B and TAIDE LX-7B, trained in Chinese and based on Llama 2 7B, as examples. Using the generation of 500-word judgments for the experiment and employing RLHF-PPO training, the ROUGE-1, ROUGE-2, and ROUGE-L scores of both models are listed in <xref ref-type="table" rid="table-3">Table 3</xref>. We believe that TAIDE LX-7B&#x2019;s inclusion of Taiwanese training data results in slightly better performance than that of Chinese alpaca 7B. <xref ref-type="fig" rid="fig-10">Fig. 10</xref> compares the ROUGE-1, ROUGE-2, and ROUGE-L scores of the original Chinese alpaca 7B and TAIDE LX-7B models shown in <xref ref-type="table" rid="table-1">Table 1</xref>, with those obtained after SFT and RLHF-PPO training, as presented in <xref ref-type="table" rid="table-3">Table 3</xref>, <xref ref-type="table" rid="table-1">Table 1</xref> presents examples of the datasets used and generated during this study&#x2019;s SFT. The &#x2019;main text&#x2019; consists of the first 500 words of the judgment&#x2019;s main text, and the &#x2019;generative judgment&#x2019; is generated as an example within 500 words. From <xref ref-type="table" rid="table-1">Table 1</xref>, after SFT, Llama 3 Taiwan-8B achieves the highest ROUGE-1, ROUGE-2, and ROUGE-L scores. The Llama 3 Taiwan-8B model primarily focuses on Taiwanese data. Similarly, among models in the Chinese language family, Chinese alpaca 2 13B outperforms Llama 3 Chinese 8B, as Chinese alpaca 2 13B is trained from the Alpaca 13B model. The results show that Chinese alpaca 2 13B slightly outperforms Llama 3 Chinese 8B in terms of performance.</p>
<table-wrap id="table-3">
<label>Table 3</label>
<caption>
<title>ROUGE scores of models fine-tuned through RLHF-PPO training. (500-word judgment)</title>
</caption>
<table>
<colgroup>
<col align="center"/>
<col align="center"/>
<col align="center"/>
<col align="center"/>
</colgroup>
<thead>
<tr>
<th>Models/Metrics</th>
<th>ROUGE 1</th>
<th>ROUGE 2</th>
<th>ROUGE L</th>
</tr>
</thead>
<tbody>
<tr>
<td>Chinese alpaca 2 7B (RLHF-PPO)</td>
<td>0.4627</td>
<td>0.3239</td>
<td>0.3318</td>
</tr>
<tr>
<td>TAIDE LX-7B (RLHF-PPO)</td>
<td>0.5207</td>
<td>0.3383</td>
<td>0.3362</td>
</tr>
</tbody>
</table>
</table-wrap><fig id="fig-10">
<label>Figure 10</label>
<caption>
<title>Loss value curve of TAIDE LX-7B after RLHF-PPO</title>
</caption>
<graphic mimetype="image" mime-subtype="tif" xlink:href="CMES_73258-fig-10.tif"/>
</fig>
</sec>
<sec id="s4_3">
<label>4.3</label>
<title>Domain-Adapted Base Models</title>
<p>This study&#x2019;s findings demonstrate that including important public data from Taiwanese government and judicial resources during the pre-training stage plays a vital role. This highlights an important insight: the performance of LLMs in domain-specific applications depends not only on fine-tuning strategies but is also profoundly influenced by the knowledge base established during pre-training and through a &#x201C;localized&#x201D; pre-training process. Llama 3 Taiwan-8B acquired a preliminary understanding of Taiwanese legal terminology, document rituals, and contextual patterns even before fine-tuning. As a result, it could absorb new knowledge more effectively than general-purpose Chinese models (e.g., Chinese Alpaca 2) or English-based models (e.g., Llama 3 8B), thereby achieving a higher performance ceiling after fine-tuning. This result reaffirms that, in specialized domains, selecting a base model with a pre-training data distribution highly relevant to the target domain is one of the key determinants of achieving optimal performance.</p>
</sec>
<sec id="s4_4">
<label>4.4</label>
<title>Further Refinement of Generation Quality with RLHF-PPO</title>
<p>In the experiments of this section, the study employs TAIDE-LX-7B and Chinese Llama 2 7B as examples, employing a dataset of 1000 samples to perform Reinforcement Learning with Human Feedback using Proximal Policy Optimization (RLHF-PPO). The loss values of RLHF-PPO are shown in <xref ref-type="fig" rid="fig-10">Fig. 10</xref>.</p>

<p>In <xref ref-type="table" rid="table-4">Table 4</xref>, we provide examples of judgments generated by Chinese Llama 2 7B after RLHF-PPO training. Using approximately 500 Chinese words as a reference, it can be observed that the structure of the generated judgments is nearly complete. The plaintiff, defendant, criminal facts, and the stated charges exhibit coherent continuity.</p>
<table-wrap id="table-4">
<label>Table 4</label>
<caption>
<title>Comparison of source text, extracted keywords, and generated judgment for SFT and RLHF-PPO</title>
</caption>
<table>
<colgroup>
<col align="center"/>
<col align="center"/>
</colgroup>
<thead>
<tr>
<th>Type</th>
<th>Content</th>
</tr>
</thead>
<tbody>
<tr>
<td>Keywords</td>
<td>&#x201C;19 December 2020&#x201D;, &#x201C;Abrasion on the left cheek&#x201D;, &#x201C;Abrasion on the right forearm&#x201D;, &#x201C;Contusion and abrasion on the fourth finger of the left hand&#x201D;, &#x201C;Multiple abrasions on the right lower limb&#x201D;, &#x201C;Defendant &#x2018;Mr. A&#x201D;&#x2019;, &#x201C;Article 277, Paragraph 1 of the Criminal Code&#x201D;, &#x201C;Offense of injury&#x201D;, &#x201C;Complainant &#x2018;Mr. B&#x201D;&#x2019;, &#x201C;Reconciliation&#x201D;, &#x201C;Junior high school graduate&#x201D;, &#x201C;Unemployed&#x201D;, &#x201C;Monthly income of approximately NT30,000 to NT40,000&#x201D;, &#x201C;Needs to support mother and spouse&#x201D;, &#x201C;Family&#x2019;s financial and living conditions&#x201D;, &#x201C;Punishment as stated in the main text&#x201D;, &#x201C;Conversion rate for fines&#x201D;, &#x201C;Criminal record report of the defendant by the Taiwan High Court&#x201D;, &#x201C;Intentional crime&#x201D;, &#x201C;Imprisonment or more severe punishment&#x201D;</td>
</tr>
<tr>
<td>Keywords (Chinese)</td>
<td><inline-graphic mime-subtype="tif" xlink:href="CMES_73258-inline-1.tif"/></td>
</tr>
<tr>
<td>Main text (Extract the first 500 words of the main text)</td>
<td>The facts of the crime and the evidence in this case: Except for the correction of &#x201C; 19 December 2020&#x201D; in the first line of the crime facts column to &#x201C; 19 December 2019,&#x201D; and the supplementation of &#x201C;abrasion on the left cheek, abrasion on the right forearm, contusion and abrasion on the fourth finger of the left hand, multiple abrasions on the right lower limb&#x201D; in lines 6 to 7 to &#x201C;abrasion on the left cheek (0.5 cm), abrasion on the right forearm (0.3 cm/1 cm), contusion and abrasion on the fourth finger of the left hand (0.5 cm), multiple abrasions on the right lower limb (0.5 cm)&#x201D;; and the addition of &#x201C;Defendant Mr. A&#x2019;s confession during the court preparation procedures&#x201D; as evidence, the remainder adopts the indictment as stated by the prosecutor (as attached). 2. The defendant&#x2019;s actions constitute the injury offense under Article 277, Paragraph 1 of the Criminal Code. Therefore, based on the perpetrator&#x2019;s responsibility, it is considered that the defendant failed to resolve disputes rationally and control emotions, committing this injury offense over trivial matters, which should be condemned. However, considering that the defendant admitted the offense after committing it and reached a reconciliation with the complainant Mr. B, and taking into account the defendant&#x2019;s criminal motive, methods, personal conduct, the injuries suffered by the complainant, as well as the defendant&#x2019;s self-reported educational level as a junior high school graduate, current unemployment, previous employment as a postal worker with a monthly income of approximately NT30,000 to NT40,000, and the need to support his mother and spouse in his family&#x2019;s economic and living conditions (see page 33 of the court file), all these circumstances are weighed, and the punishment is determined as stated in the main text, with the applicable conversion standard for fines being duly notified. 3. The defendant has never been sentenced to imprisonment or a more severe punishment for intentional crimes, as verified by the attached criminal record report from the Taiwan High Court. The court considers that the defendant acted impulsively, thereby violating the law, admitted the offense afterward, and reconciled with the complainant.</td>
</tr>
<tr>
<td>Main text (Extract the first 500 words of the main text)</td>
<td><inline-graphic mime-subtype="tif" xlink:href="CMES_73258-inline-2.tif"/></td>
</tr>
<tr>
<td>Generative judgment (Generate within 500 words)</td>
<td>Main text: The defendant, Mr. A, is found guilty of the offense of injury under Article 277, Paragraph 1 of the Criminal Code. He is sentenced to eight months of imprisonment or, alternatively, a fine calculated at NT30,000 per day. Facts: On 19 December 2020, at an undisclosed location, the defendant, Mr. A, became involved in a verbal altercation with the complainant, Mr. B. During the dispute, the defendant proceeded to assault the complainant by striking him with his fists on the left cheek, right forearm, left fourth finger, and right lower limb. These actions resulted in abrasions to the complainant&#x2019;s left cheek, abrasions to the right forearm, contusions and abrasions to the left fourth finger, and multiple abrasions to the right lower limb. The defendant&#x2019;s actions led the complainant to file a criminal complaint, which this court subsequently heard and adjudicated. Result: After deliberation, this court found that the defendant, Mr. A, had committed the offense of injury and should have been sentenced to eight months. Alternatively, he may be fined NT30,000 per day. Reasoning: The defendant, Mr. A, engaged in a verbal dispute with the complainant and subsequently lost control, resulting in the assault of the complainant and causing multiple injuries. The defendant&#x2019;s actions constitute the offense of injury, and he bears criminal responsibility. After careful consideration, this court concludes that the defendant is guilty of the offense of injury and should be sentenced to eight months of imprisonment or, alternatively, a fine calculated at NT30,000 per day. Appendix: Taiwan High Court Defendant&#x2019;s Prior Case Record Form</td>
</tr>
<tr>
<td>Generative judgment-Generate within 500 words (Chinese)</td>
<td><inline-graphic mime-subtype="tif" xlink:href="CMES_73258-inline-3.tif"/></td>
</tr>
</tbody>
</table>
</table-wrap>
<p>After SFT and RLHF-PPO, Chinese alpaca 2 7B saw its ROUGE-1 score increase from 0.3623 to 0.4627 and its ROUGE-2 score from 0.2379 to 0.3239, while the ROUGE-L score showed no significant change. Similarly, TAIDE-LX-7B experienced an increase in ROUGE-1 from 0.3741 to 0.5207 and ROUGE-2 from 0.2217 to 0.3383 after SFT and RLHF-PPO, but ROUGE-L did not show a significant increase. <xref ref-type="fig" rid="fig-11">Fig. 11</xref> shows a comparison of the ROUGE scores for Chinese alpaca 2 7B.</p>
<fig id="fig-11">
<label>Figure 11</label>
<caption>
<title>A comparison of the ROUGE scores for Chinese alpaca 2 7B and TAIDE-LX-7B in the original models, SFT, and RLHF-PPO</title>
</caption>
<graphic mimetype="image" mime-subtype="tif" xlink:href="CMES_73258-fig-11.tif"/>
</fig>
<p>To align the model&#x2019;s generated output more closely with judgments written by human judges, we introduced Reinforcement Learning with Human Feedback using Proximal Policy Optimization (RLHF-PPO) training. As shown in <xref ref-type="table" rid="table-3">Table 3</xref>, compared to using only SFT, the Chinese Alpaca 2 7B and TAIDE-LX-7B models improved further in their ROUGE-1 and ROUGE-2 scores after RLHF-PPO training. An impressive phenomenon worthy of in-depth discussion is that while RLHF-PPO significantly boosted ROUGE-1 and ROUGE-2 scores, its impact on the ROUGE-L score was minimal. The reasoning is as follows:
<list list-type="bullet">
<list-item>
<p>Improvement in ROUGE-1/2: This reflects the model&#x2019;s increased accuracy in generating key terms and phrases (e.g., charges, legal articles, names). The RLHF phase treats the original judgment as the &#x201D;preferred&#x201D; output, rewarding the model for generating content with similar wording. This leads to better performance in unigram and bigram overlap.</p>
</list-item>
<list-item>
<p>Stagnation in ROUGE-L: ROUGE-L measures the longest common subsequence and focuses more on sentence structure and overall flow. The RLHF aims to make the generated text more &#x201D;human-like&#x201D; and natural. This may lead the model to learn to express the same legal meaning using different sentence structures rather than strictly replicating the original judgment. Therefore, although the qualitative merit of the generated text might be higher, the similarity of its sentence-level structure to the reference text does not increase, resulting in no significant improvement in the ROUGE-L score. This suggests that RLHF may be optimizing for text &#x201C;readability&#x201D; and &#x201C;naturalness,&#x201D; qualitative improvements that are difficult to measure with the ROUGE-L metric.</p></list-item>
</list></p>
</sec>
<sec id="s4_5">
<label>4.5</label>
<title>Qualitative Analysis: From Lexical Overlap to Legal Meaning</title>
<p>This section provides a qualitative analysis of the generated samples. As a case study, we examine the Chinese Llama 2 7B output after RLHF-PPO training.
<list list-type="bullet">
<list-item>
<p>Structural Learning: The generated judgment draft (e.g., <xref ref-type="table" rid="table-5">Table 5</xref>) is structurally complete, correctly distinguishing between sections like &#x201C;Facts&#x201D; and &#x201C;Reasons&#x201D;. It successfully extracts key elements, such as the defendant &#x201C;Mr. C,&#x201D; the victim &#x201C;Mr. D,&#x201D; and key actions like &#x201C;pushed down by hand&#x201D; and &#x201C;trespassing&#x201D; organizing them into coherent paragraphs. This indicates that the model has learned not only to generate words but also to handle the discourse patterns of legal judgments.</p>
</list-item>
<list-item>
<p>The Risk of &#x201C;Hallucination&#x201D;: A closer look at the generated text reveals potential risks. For instance, in the case from <xref ref-type="table" rid="table-4">Table 4</xref>, the model&#x2019;s generated judgment states, &#x201C;He is sentenced to eight months of imprisonment or a fine calculated at NT30,000 per day&#x201D;. However, the original input text (the first 500 words) only mentions that &#x201C;the punishment is determined as stated in the main text,&#x201D; without specifying the exact sentence. This is a classic example of hallucination, where the model &#x201C;invents&#x201D; a plausible but factually non-existent judgment.</p>
</list-item>
</list></p>
<table-wrap id="table-5">
<label>Table 5</label>
<caption>
<title>The example of generative judgment after RLHF-PPO</title>
</caption>
<table>
<colgroup>
<col align="center"/>
<col align="center"/>
</colgroup>
<thead>
<tr>
<th>Type</th>
<th>The content of judgments</th>
</tr>
</thead>
<tbody>
<tr>
<td>Reference text</td>
<td>Both Mr. C and Mr. D are residents of the &#x2019;Wangzhu Community&#x2019; (located at No. OO to 87, OO Road, OO District, New Taipei City). On 12 July 2020, at approximately 8:00 a.m., with the intent to inflict bodily harm, Mr. C, while in the corridor of the staircase outside the residence of Mr. D on the 4th floor at No. OO, OO Road, OO District, New Taipei City (hereinafter referred to as &#x2019;the residence at issue&#x2019;), took the opportunity-while Mr. D was opening the door to the residence at issue and arguing with him-to push Mr. D down by hand. As a result, Mr. D fell onto the floor of the residence at issue and sustained contusions to his right forearm and right hip. Subsequently, with the intent to unlawfully enter another person&#x2019;s residence, immediately after pushing Mr. D down, Mr. C entered the residence at issue from the corridor without Mr. D&#x2019;s consent, thereby trespassing in another person&#x2019;s dwelling.</td>
</tr>
<tr>
<td>Reference text (cont.)</td>
<td>Reasons admissibility of evidence</td>
</tr>
<tr>
<td></td>
<td>1. The statements or written testimonies made outside the Court by persons other than the defendant, Mr. C, as cited below by this Court, all constitute hearsay evidence. However, the prosecutor and the defendant have consented to their admissibility (see p. 60 of this Court&#x2019;s 110-Year No. 959 case file, hereinafter referred to as &#x2019;the Indictment Case File&#x2019;). Upon reviewing the circumstances under which this evidence was produced, the Court finds no illegality, impropriety, or glaringly inadequate probative value. Therefore, it is deemed appropriate to use such evidence, and Article 159-5 Paragraph 1 of the Code of Criminal Procedure holds that all such evidence is admissible.</td>
</tr>
<tr>
<td></td>
<td>2. The non-testimonial evidence cited by this Court below is relevant to the facts of this case, and no evidence suggests it was obtained by a public official in violation of lawful procedures. Moreover, both the prosecutor and the defendant have consented to its admissibility (see p. 60 of the Indictment Case File). Hence, the Court finds that such evidence is also admissible.</td>
</tr>
<tr>
<td></td>
<td>II. Merits Basis for Finding the Criminal Facts Underlying the Charges</td>
</tr>
<tr>
<td>Generated text</td>
<td>Mr. C and Mr. D are both residents of the &#x2019;Wangzhu Community.&#x2019; On 12 July 2020, at approximately 8:00 a.m., prompted by the intent to inflict bodily harm and trespass into another&#x2019;s residence, Mr. C took advantage of the moment when Mr. D was opening the door and arguing with him in the corridor outside Mr. D&#x2019;s residence on the 4th floor at No. 00, OO Road, OO District, New Taipei City. He pushed Mr. D with his bare hands, causing Mr. D to fall to the ground and sustain bruises to his right forearm and right hip. Subsequently, still intending to trespass into another&#x2019;s residence, Mr. C, without Mr. D&#x2019;s consent, walked from the corridor into Mr. D&#x2019;s residence, thereby intruding into another person&#x2019;s home.</td>
</tr>
<tr>
<td></td>
<td>During the trial of this case, both the prosecutor and the defendant, Mr. C, agreed that the following non-testimonial evidence is admissible:</td>
</tr>
<tr>
<td></td>
<td>1. Although word, the statement of Witness A complies with the conditions stipulated in Paragraph 1, Article 159-5 of the Code of Criminal Procedure and is therefore admissible. 2. The statement of Witness B is relevant to the facts of this case, and there is no evidence indicating it was obtained through any unlawful means by government officials.</td>
</tr>
<tr>
<td>Generated text-Chinese</td>
<td><inline-graphic mime-subtype="tif" xlink:href="CMES_73258-inline-4.tif"/></td>
</tr>
</tbody>
</table>
</table-wrap>
<p>This case study powerfully highlights the danger of relying solely on ROUGE scores. The generated text might achieve a high ROUGE score because it contains many correct keywords, yet its core legal outcome is incorrect. This not only validates the necessity of human review by legal professionals but also points to a future research direction: what is needed are not just models that achieve high textual similarity, but models equipped with</p>
</sec>
</sec>
<sec id="s5">
<label>5</label>
<title>Ethical and Legal Implications</title>
<p>While the proposed keyword-guided training approach offers significant advancements in the automation of judicial document generation, its application in sensitive legal contexts necessitates a thorough examination of the associated ethical and legal implications. The deployment of Large Language Models (LLMs) in the judicial process is not merely a technical challenge but also raises fundamental questions regarding fairness, accountability, transparency, and the potential for legal error.</p>
<p>Bias and Fairness Inherent biases present in this study&#x2019;s training data could be perpetuated and even amplified by the LLM. The model is trained based on historical judgment data from Taiwan&#x2019;s Judicial Yuan, which may reflect pre-existing biases. If not carefully addressed, the model might generate disadvantageous judgment drafts to specific groups, thereby undermining judicial fairness and trust.</p>
<p>Accountability and Transparency Due to LLMs&#x2019; &#x201C;black box&#x201D; nature, their transparency is subject to significant questioning. The reasoning process behind the legal text generated by the AI model used in this study is often opaque. If the AI-generated drafts contain misinterpreted evidence or suggest incorrect conclusions, the attribution of responsibility becomes more complex. Therefore, whether the responsibility lies with the presiding judge who uses the tool, the developers of the model, or the institution that deploys the system is an issue worthy of discussion.</p>
<p>Legal Risk and Accuracy As with any generative AI, the model produced in this study carries a risk of &#x201C;hallucination&#x201D;&#x2014;generating factually incorrect or nonsensical content, which could cause the resulting judgment to deviate significantly from the judge&#x2019;s original intent. In generating a judgment, this could manifest as citing non-existent legal precedents, misstating case facts, or incorrectly applying legal statutes. Such inaccuracies could have severe consequences, potentially leading to wrongful convictions or unjust rulings. As noted in this study, AI-generated judgments still require manual revision to correct for such errors and ensure their legal validity.</p>
<p>Mitigation Strategies Addressing these challenges requires a multifaceted approach. A crucial step is implementing a &#x201C;human-in-the-loop&#x201D; framework, where the AI is an assistive tool to generate initial drafts. However, the final legal reasoning, verification, and judgment remain firmly in the hands of qualified judicial personnel. Furthermore, future research can also develop Explainable AI (XAI) techniques tailored for the legal domain, which would help illuminate the model&#x2019;s decision-making process. Before integrating such technologies into the judicial workflow, continuous auditing of training data for biases and rigorous, context-aware performance evaluations are also essential.</p>
</sec>
<sec id="s6">
<label>6</label>
<title>Discussion</title>
<p>The emergence of LLMs has encouraged many researchers to explore their applications and conduct studies. However, due to the specialization and complexity of the legal domain, research on applying LLMs in law still needs to be completed. Harasta et al. analyzed generative AI, and the results indicate that legal documents written by humans generally outperform those generated by AI. [<xref ref-type="bibr" rid="ref-42">42</xref>] Currently, AI cannot fully generate legal documents. In addition to AI, hallucinations, syntax, and awkward phrasing frequently occur. Legal documents generated by AI still require manual revisions.</p>
<p>This study emphasizes the importance of cultural and legal context in judicial text generation. Taiwan&#x2019;s judicial system is rooted in the custom of civil law, and its judgments feature a standardized format that differs from judgments in mainland China and common law opinions. By using a keyword-guided training framework and leveraging models pre-trained on Taiwanese data, we can ensure that the generated text aligns more closely with local linguistic conventions and legal reasoning patterns. This is instrumental in improving the credibility and relevance of AI-assisted judgment drafting in real-world judicial practice.</p>
<p>This study conducted experiments with a small-scale dataset, and there are several research limitations:
<list list-type="bullet">
<list-item>
<p>This study is limited to legal judgments of injury cases with lengths of 500 and 1000 words. Expanding the model&#x2019;s ability to handle longer documents will be an important direction for future research.</p></list-item>
<list-item>
<p>The content generated by LLMs still carries the risk of hallucination, which may lead to legal inaccuracies. Therefore, outputs produced by LLMs must be reviewed by legal professionals and should only serve as an auxiliary tool.</p></list-item>
<list-item>
<p>Due to computational resource constraints, the RLHF-PPO stage was validated only on two small-scale models. Future work should extend this approach to larger models (e.g., 13B or 70B parameters) to evaluate their generalization ability and scalability.</p></list-item>
<list-item>
<p>The current evaluation relies on ROUGE scores, which cannot assess the correctness of legal reasoning. Future research should incorporate human evaluation conducted by legal experts to validate the value of generated content more comprehensively.</p></list-item>
</list></p>
</sec>
<sec id="s7">
<label>7</label>
<title>Conclusion and Future Works</title>
<p>Therefore, this study uses LLMs to generate judicial decisions. Considering the constraints of computational resources and the judicial crew, this research uses training LLMs to generate judgments. The research introduces LLMs to decompose judgments into keywords and subsequently uses these keywords to train LLMs to generate judgments. The experimental results demonstrate that the method proposed in this study enhances the performance of judgment generation, including metrics such as judgment generation success rate, ROUGE-1, ROUGE-2, and ROUGE-L scores. In the first phase of this study, we trained the judgment generation capability using Supervised Fine-Tuning (SFT) with commonly used LLMs within the Llama framework. As summarized in <xref ref-type="table" rid="table-1">Tables 1</xref> and <xref ref-type="table" rid="table-2">2</xref>, we found that the performance of each LLM improved after SFT, thereby providing preliminary evidence of the feasibility of this study. In the Llama 2 series of models, the best generation results for 500 words and 1000 words were produced by Chinese alpaca 2 13B and Chinese alpaca 2 7B, respectively. In the Llama 3 series of models, for both the 500-word and 1000-word outputs, Llama 3 Taiwan-8B performed the best.</p>

<p>Furthermore, after performing Supervised Fine-Tuning (SFT) on the LLMs, they were further trained using RLHF-PPO to develop new LLMs. Small-scale data experiments demonstrated the feasibility of using RLHF-PPO. By comparing ROUGE scores, it was found that using RLHF-PPO could further enhance performance compared to using SFT alone. Therefore, the model underwent additional training through RLHF-PPO to align its outputs with human feedback.</p>
<p>This study has experimentally demonstrated that training an LLM to generate judicial decisions using a keyword-based approach involves obtaining keyword combinations from judicial decisions through the use of LLMs. Subsequently, the LLM is trained using SFT and RLHF-PPO, ultimately improving ROUGE scores.</p>
</sec>
</body>
<back>
<ack>
<p>None.</p>
</ack>
<sec>
<title>Funding Statement</title>
<p>The authors received no specific funding for this study.</p>
</sec>
<sec>
<title>Author Contributions</title>
<p>Study conception and design: Yi-Ting Peng, Chin-Laung Lei; Literature review and data collection: Yi-Ting Peng; Analysis and interpretation of literature: Yi-Ting Peng; Visualization and graphical representation: Yi-Ting Peng; Draft manuscript preparation: Yi-Ting Peng. All authors reviewed the results and approved the final version of the manuscript.</p>
</sec>
<sec sec-type="data-availability">
<title>Availability of Data and Materials</title>
<p>The data for this study is sourced from <ext-link ext-link-type="uri" xlink:href="https://opendata.judicial.gov.tw/">https://opendata.judicial.gov.tw/</ext-link> (accessed on 20 March 2023).</p>
</sec>
<sec>
<title>Ethics Approval</title>
<p>Not applicable.</p>
</sec>
<sec sec-type="COI-statement">
<title>Conflicts of Interest</title>
<p>The authors declare no conflicts of interest to report regarding the present study.</p>
</sec>
<ref-list content-type="authoryear">
<title>References</title>
<ref id="ref-1"><label>[1]</label><mixed-citation publication-type="journal"><person-group person-group-type="author"><string-name><surname>Singhal</surname> <given-names>K</given-names></string-name>, <string-name><surname>Azizi</surname> <given-names>S</given-names></string-name>, <string-name><surname>Tu</surname> <given-names>T</given-names></string-name>, <string-name><surname>Mahdavi</surname> <given-names>SS</given-names></string-name>, <string-name><surname>Wei</surname> <given-names>J</given-names></string-name>, <string-name><surname>Chung</surname> <given-names>HW</given-names></string-name>, <etal>et al</etal></person-group>. <article-title>Large language models encode clinical knowledge</article-title>. <source>Nature</source>. <year>2023</year>;<volume>620</volume>(<issue>7972</issue>):<fpage>172</fpage>&#x2013;<lpage>80</lpage>. doi:<pub-id pub-id-type="doi">10.1038/s41586-023-06291-2</pub-id>; <pub-id pub-id-type="pmid">37438534</pub-id></mixed-citation></ref>
<ref id="ref-2"><label>[2]</label><mixed-citation publication-type="journal"><person-group person-group-type="author"><string-name><surname>Hsu</surname> <given-names>CHC</given-names></string-name>, <string-name><surname>Tan</surname> <given-names>G</given-names></string-name>, <string-name><surname>Stantic</surname> <given-names>B</given-names></string-name></person-group>. <article-title>A fine-tuned tourism-specific generative AI concept</article-title>. <source>Ann Tour Res</source>. <year>2024</year>;<volume>104</volume>:<fpage>103723</fpage>. doi:<pub-id pub-id-type="doi">10.1016/j.annals.2023.103723</pub-id>.</mixed-citation></ref>
<ref id="ref-3"><label>[3]</label><mixed-citation publication-type="book"><person-group person-group-type="author"><string-name><surname>Wan</surname> <given-names>Z</given-names></string-name>, <string-name><surname>Zhang</surname> <given-names>Y</given-names></string-name>, <string-name><surname>Wang</surname> <given-names>Y</given-names></string-name>, <string-name><surname>Cheng</surname> <given-names>F</given-names></string-name>, <string-name><surname>Kurohashi</surname> <given-names>S</given-names></string-name></person-group>. <chapter-title>Reformulating domain adaptation of large language models as adapt-retrieve-revise: a case study on Chinese legal domain</chapter-title>. In: <person-group person-group-type="editor"><string-name><surname>Ku</surname> <given-names>LW</given-names></string-name>, <string-name><surname>Martins</surname> <given-names>A</given-names></string-name>, <string-name><surname>Srikumar</surname> <given-names>V</given-names></string-name></person-group>, editors. <source>Findings of the association for computational linguistics: ACL 2024</source>. <publisher-loc>Bangkok, Thailand</publisher-loc>: <publisher-name>Association for Computational Linguistics</publisher-name>; <year>2024</year>. p. <fpage>5030</fpage>&#x2013;<lpage>41</lpage>.</mixed-citation></ref>
<ref id="ref-4"><label>[4]</label><mixed-citation publication-type="other"><person-group person-group-type="author"><string-name><surname>Li</surname> <given-names>D</given-names></string-name>, <string-name><surname>Jiang</surname> <given-names>B</given-names></string-name>, <string-name><surname>Huang</surname> <given-names>L</given-names></string-name>, <string-name><surname>Beigi</surname> <given-names>A</given-names></string-name>, <string-name><surname>Zhao</surname> <given-names>C</given-names></string-name>, <string-name><surname>Tan</surname> <given-names>Z</given-names></string-name>, <etal>et al.</etal></person-group> <article-title>From generation to judgment: opportunities and challenges of LLM-as-a-judge</article-title>. <comment>arXiv:2411.16594. 2024</comment>.</mixed-citation></ref>
<ref id="ref-5"><label>[5]</label><mixed-citation publication-type="journal"><person-group person-group-type="author"><string-name><surname>Peng</surname> <given-names>Y</given-names></string-name>, <string-name><surname>Lei</surname> <given-names>C</given-names></string-name></person-group>. <article-title>Using bidirectional encoder representations from transformers (BERT) to predict criminal charges and sentences from Taiwanese court judgments</article-title>. <source>PeerJ Comput Sci</source>. <year>2024</year>;<volume>10</volume>:<fpage>e1841</fpage>. doi:<pub-id pub-id-type="doi">10.7717/peerj-cs.1841</pub-id>; <pub-id pub-id-type="pmid">38435559</pub-id></mixed-citation></ref>
<ref id="ref-6"><label>[6]</label><mixed-citation publication-type="conf-proc"><person-group person-group-type="author"><string-name><surname>Jain</surname> <given-names>N</given-names></string-name>, <string-name><surname>Goel</surname> <given-names>G</given-names></string-name></person-group>. <article-title>An approach to get legal assistance using artificial intelligence</article-title>. In: <conf-name>2020 8th International Conference on Reliability, Infocom Technologies and Optimization (Trends and Future Directions) (ICRITO); 2020 Jun 4&#x2013;5</conf-name>; <publisher-loc>Noida, India</publisher-loc>. p. <fpage>768</fpage>&#x2013;<lpage>71</lpage>.</mixed-citation></ref>
<ref id="ref-7"><label>[7]</label><mixed-citation publication-type="conf-proc"><person-group person-group-type="author"><string-name><surname>Qin</surname> <given-names>R</given-names></string-name>, <string-name><surname>Huang</surname> <given-names>M</given-names></string-name>, <string-name><surname>Luo</surname> <given-names>Y</given-names></string-name></person-group>. <article-title>A comparison study of pre-trained language models for chinese legal document classification</article-title>. In: <conf-name>2022 5th International Conference on Artificial Intelligence and Big Data (ICAIBD); 2022 May 27&#x2013;30</conf-name>; <publisher-loc>Chengdu, China</publisher-loc>. p. <fpage>444</fpage>&#x2013;<lpage>9</lpage>.</mixed-citation></ref>
<ref id="ref-8"><label>[8]</label><mixed-citation publication-type="journal"><person-group person-group-type="author"><string-name><surname>Novelli</surname> <given-names>C</given-names></string-name>, <string-name><surname>Casolari</surname> <given-names>F</given-names></string-name>, <string-name><surname>Hacker</surname> <given-names>P</given-names></string-name>, <string-name><surname>Spedicato</surname> <given-names>G</given-names></string-name>, <string-name><surname>Floridi</surname> <given-names>L</given-names></string-name></person-group>. <article-title>Generative AI in EU law: liability, privacy, intellectual property, and cybersecurity</article-title>. <source>Comput Law Secur Rev</source>. <year>2024</year>;<volume>55</volume>:<fpage>106066</fpage>. doi:<pub-id pub-id-type="doi">10.1016/j.clsr.2024.106066</pub-id>.</mixed-citation></ref>
<ref id="ref-9"><label>[9]</label><mixed-citation publication-type="conf-proc"><person-group person-group-type="author"><string-name><surname>Vaswani</surname> <given-names>A</given-names></string-name>, <string-name><surname>Shazeer</surname> <given-names>N</given-names></string-name>, <string-name><surname>Parmar</surname> <given-names>N</given-names></string-name>, <string-name><surname>Uszkoreit</surname> <given-names>J</given-names></string-name>, <string-name><surname>Jones</surname> <given-names>L</given-names></string-name>, <string-name><surname>Gomez</surname> <given-names>AN</given-names></string-name>, <etal>et al.</etal></person-group> <article-title>Attention is all you need</article-title>. In: <conf-name>NIPS&#x2019;17: Proceedings of the 31st International Conference on Neural Information Processing Systems; 2017 Dec 4&#x2013;9</conf-name>; <publisher-loc>Long Beach, CA, USA</publisher-loc>. p. <fpage>6000</fpage>&#x2013;<lpage>10</lpage>.</mixed-citation></ref>
<ref id="ref-10"><label>[10]</label><mixed-citation publication-type="journal"><person-group person-group-type="author"><string-name><surname>Rasmy</surname> <given-names>L</given-names></string-name>, <string-name><surname>Xiang</surname> <given-names>Y</given-names></string-name>, <string-name><surname>Xie</surname> <given-names>Z</given-names></string-name>, <string-name><surname>Tao</surname> <given-names>C</given-names></string-name>, <string-name><surname>Zhi</surname> <given-names>D</given-names></string-name></person-group>. <article-title>Med-BERT: pretrained contextualized embeddings on large-scale structured electronic health records for disease prediction</article-title>. <source>npj Digital Med</source>. <year>2021</year>;<volume>4</volume>(<issue>1</issue>):<fpage>86</fpage>. doi:<pub-id pub-id-type="doi">10.1038/s41746-021-00455-y</pub-id>; <pub-id pub-id-type="pmid">34017034</pub-id></mixed-citation></ref>
<ref id="ref-11"><label>[11]</label><mixed-citation publication-type="journal"><person-group person-group-type="author"><string-name><surname>Peng</surname> <given-names>C</given-names></string-name>, <string-name><surname>Yang</surname> <given-names>X</given-names></string-name>, <string-name><surname>Chen</surname> <given-names>A</given-names></string-name>, <string-name><surname>Smith</surname> <given-names>KE</given-names></string-name>, <string-name><surname>PourNejatian</surname> <given-names>N</given-names></string-name>, <string-name><surname>Costa</surname> <given-names>AB</given-names></string-name>, <etal>et al</etal></person-group>. <article-title>A study of generative large language model for medical research and healthcare</article-title>. <source>npj Digit Med</source>. <year>2023</year>;<volume>6</volume>(<issue>1</issue>):<fpage>210</fpage>. doi:<pub-id pub-id-type="doi">10.1038/s41746-023-00958-w</pub-id>; <pub-id pub-id-type="pmid">37973919</pub-id></mixed-citation></ref>
<ref id="ref-12"><label>[12]</label><mixed-citation publication-type="conf-proc"><person-group person-group-type="author"><string-name><surname>Savelka</surname> <given-names>J</given-names></string-name>, <string-name><surname>Agarwal</surname> <given-names>A</given-names></string-name>, <string-name><surname>Bogart</surname> <given-names>C</given-names></string-name>, <string-name><surname>Song</surname> <given-names>Y</given-names></string-name>, <string-name><surname>Sakr</surname> <given-names>M</given-names></string-name></person-group>. <article-title>Can generative pre-trained transformers GPT pass assessments in higher education programming courses?</article-title> In: <conf-name>Proceedings of the 2023 Conference on Innovation and Technology in Computer Science Education V. 1; 2023 Jul 7&#x2013;12</conf-name>; <publisher-loc>Turku, Finland</publisher-loc>. p. <fpage>117</fpage>&#x2013;<lpage>23</lpage>. doi:<pub-id pub-id-type="doi">10.1145/3587102.3588792</pub-id>.</mixed-citation></ref>
<ref id="ref-13"><label>[13]</label><mixed-citation publication-type="other"><person-group person-group-type="author"><string-name><surname>Wu</surname> <given-names>S</given-names></string-name>, <string-name><surname>Irsoy</surname> <given-names>O</given-names></string-name>, <string-name><surname>Lu</surname> <given-names>S</given-names></string-name>, <string-name><surname>Dabravolski</surname> <given-names>V</given-names></string-name>, <string-name><surname>Dredze</surname> <given-names>M</given-names></string-name>, <string-name><surname>Gehrmann</surname> <given-names>S</given-names></string-name>, <etal>et al.</etal></person-group> <article-title>BloombergGPT: a large language model for finance</article-title>. <comment>arXiv:2303.17564. 2023</comment>.</mixed-citation></ref>
<ref id="ref-14"><label>[14]</label><mixed-citation publication-type="journal"><person-group person-group-type="author"><string-name><surname>Ray</surname> <given-names>PP</given-names></string-name></person-group>. <article-title>ChatGPT: a comprehensive review on background, applications, key challenges, bias, ethics, limitations and future scope</article-title>. <source>Internet of Things Cyber-Phys Syst</source>. <year>2023</year>;<volume>3</volume>:<fpage>121</fpage>&#x2013;<lpage>54</lpage>. doi:<pub-id pub-id-type="doi">10.1016/j.iotcps.2023.04.003</pub-id>.</mixed-citation></ref>
<ref id="ref-15"><label>[15]</label><mixed-citation publication-type="conf-proc"><person-group person-group-type="author"><string-name><surname>Chouhan</surname> <given-names>A</given-names></string-name>, <string-name><surname>Gertz</surname> <given-names>M</given-names></string-name></person-group>. <article-title>LexDrafter: terminology drafting for legislative documents using retrieval augmented generation</article-title>. In: <conf-name>Proceedings of the LREC-COLING 2024. European Language Resources Association (ELRA); 2024 May 20&#x2013;25</conf-name>; <publisher-loc>Torino, Italia</publisher-loc>. p. <fpage>10448</fpage>&#x2013;<lpage>58</lpage>.</mixed-citation></ref>
<ref id="ref-16"><label>[16]</label><mixed-citation publication-type="journal"><person-group person-group-type="author"><string-name><surname>Contini</surname> <given-names>F</given-names></string-name></person-group>. <article-title>Unboxing generative AI for the legal professions: functions, impacts and governance</article-title>. <source>Int J Court Adm</source>. <year>2024</year>;<volume>15</volume>(<issue>2</issue>):<fpage>1</fpage>.</mixed-citation></ref>
<ref id="ref-17"><label>[17]</label><mixed-citation publication-type="conf-proc"><person-group person-group-type="author"><string-name><surname>El Hamdani</surname> <given-names>R</given-names></string-name>, <string-name><surname>Bonald</surname> <given-names>T</given-names></string-name>, <string-name><surname>Malliaros</surname> <given-names>FD</given-names></string-name>, <string-name><surname>Holzenberger</surname> <given-names>N</given-names></string-name>, <string-name><surname>Suchanek</surname> <given-names>F</given-names></string-name></person-group>. <article-title>The factuality of large language models in the legal domain</article-title>. In: <conf-name>Proceedings of the 33rd ACM International Conference on Information and Knowledge Management. CIKM &#x2019;24; 2024 Oct 21&#x2013;25</conf-name>; <publisher-loc>Boise, ID, USA. New York, NY, USA</publisher-loc>: <publisher-name>Association for Computing Machinery</publisher-name>; <year>2024</year>. p. <fpage>3741</fpage>&#x2013;<lpage>6</lpage>. doi:<pub-id pub-id-type="doi">10.1145/3627673.3679961</pub-id>.</mixed-citation></ref>
<ref id="ref-18"><label>[18]</label><mixed-citation publication-type="other"><person-group person-group-type="author"><string-name><surname>Ziegler</surname> <given-names>DM</given-names></string-name>, <string-name><surname>Stiennon</surname> <given-names>N</given-names></string-name>, <string-name><surname>Wu</surname> <given-names>J</given-names></string-name>, <string-name><surname>Brown</surname> <given-names>TB</given-names></string-name>, <string-name><surname>Radford</surname> <given-names>A</given-names></string-name>, <string-name><surname>Amodei</surname> <given-names>D</given-names></string-name>, <etal>et al.</etal></person-group> <article-title>Fine-tuning language models from human preferences</article-title>. <comment>arXiv:1909.08593. 2020</comment>.</mixed-citation></ref>
<ref id="ref-19"><label>[19]</label><mixed-citation publication-type="other"><person-group person-group-type="author"><string-name><surname>Schulman</surname> <given-names>J</given-names></string-name>, <string-name><surname>Wolski</surname> <given-names>F</given-names></string-name>, <string-name><surname>Dhariwal</surname> <given-names>P</given-names></string-name>, <string-name><surname>Radford</surname> <given-names>A</given-names></string-name>, <string-name><surname>Klimov</surname> <given-names>O</given-names></string-name></person-group>. <article-title>Proximal policy optimization algorithms</article-title>. <comment>arXiv:1707.06347. 2027</comment>.</mixed-citation></ref>
<ref id="ref-20"><label>[20]</label><mixed-citation publication-type="conf-proc"><person-group person-group-type="author"><string-name><surname>Ouyang</surname> <given-names>L</given-names></string-name>, <string-name><surname>Wu</surname> <given-names>J</given-names></string-name>, <string-name><surname>Jiang</surname> <given-names>X</given-names></string-name>, <string-name><surname>Almeida</surname> <given-names>D</given-names></string-name>, <string-name><surname>Wainwright</surname> <given-names>C</given-names></string-name>, <string-name><surname>Mishkin</surname> <given-names>P</given-names></string-name>, <etal>et al.</etal></person-group> <article-title>Training language models to follow instructions with human feedback</article-title>. In: <conf-name>NIPS&#x2019;22: Proceedings of the 36th International Conference on Neural Information Processing Systems; 2022 Nov 28&#x2013;Dec 9</conf-name>; <publisher-loc>New Orleans, LA, USA</publisher-loc>. p. <fpage>27730</fpage>&#x2013;<lpage>4</lpage>.</mixed-citation></ref>
<ref id="ref-21"><label>[21]</label><mixed-citation publication-type="conf-proc"><person-group person-group-type="author"><string-name><surname>Rafailov</surname> <given-names>R</given-names></string-name>, <string-name><surname>Sharma</surname> <given-names>A</given-names></string-name>, <string-name><surname>Mitchell</surname> <given-names>E</given-names></string-name>, <string-name><surname>Manning</surname> <given-names>CD</given-names></string-name>, <string-name><surname>Ermon</surname> <given-names>S</given-names></string-name>, <string-name><surname>Finn</surname> <given-names>C</given-names></string-name></person-group>. <article-title>Direct preference optimization: your language model is secretly a reward model</article-title>. In: <conf-name>NIPS &#x2019;23: Proceedings of the 37th International Conference on Neural Information Processing Systems; 2023 Dec 10&#x2013;16</conf-name>; <publisher-loc>New Orleans, LA, USA</publisher-loc>. p. <fpage>53728</fpage>&#x2013;<lpage>41</lpage>.</mixed-citation></ref>
<ref id="ref-22"><label>[22]</label><mixed-citation publication-type="other"><person-group person-group-type="author"><string-name><surname>Zheng</surname> <given-names>R</given-names></string-name>, <string-name><surname>Dou</surname> <given-names>S</given-names></string-name>, <string-name><surname>Gao</surname> <given-names>S</given-names></string-name>, <string-name><surname>Hua</surname> <given-names>Y</given-names></string-name>, <string-name><surname>Shen</surname> <given-names>W</given-names></string-name>, <string-name><surname>Wang</surname> <given-names>B</given-names></string-name>, <etal>et al.</etal></person-group> <article-title>Secrets of RLHF in large language models Part I: PPO</article-title>. <comment>arXiv:2307.04964. 2023</comment>.</mixed-citation></ref>
<ref id="ref-23"><label>[23]</label><mixed-citation publication-type="other"><person-group person-group-type="author"><string-name><surname>Rahmani</surname> <given-names>HA</given-names></string-name>, <string-name><surname>Siro</surname> <given-names>C</given-names></string-name>, <string-name><surname>Aliannejadi</surname> <given-names>M</given-names></string-name>, <string-name><surname>Craswell</surname> <given-names>N</given-names></string-name>, <string-name><surname>Clarke</surname> <given-names>CLA</given-names></string-name>, <string-name><surname>Faggioli</surname> <given-names>G</given-names></string-name>, <etal>et al.</etal></person-group> <article-title>Judging the judges: a collection of LLM-Generated relevance judgements</article-title>. <comment>arXiv:2502.13908. 2025</comment>.</mixed-citation></ref>
<ref id="ref-24"><label>[24]</label><mixed-citation publication-type="book"><person-group person-group-type="author"><string-name><surname>Branting</surname> <given-names>LK</given-names></string-name>, <string-name><surname>Lester</surname> <given-names>JC</given-names></string-name>, <string-name><surname>Callaway</surname> <given-names>CB</given-names></string-name></person-group>. <article-title>Automating judicial document drafting: a discourse-based approach</article-title>. In: <person-group person-group-type="editor"><string-name><surname>Sartor</surname> <given-names>G</given-names></string-name>, <string-name><surname>Branting</surname> <given-names>K</given-names></string-name>,</person-group> editors. <source>Judicial Applications of Artificial Intelligence</source>. <publisher-loc>Dordrecht, The Netherlands</publisher-loc>: <publisher-name>Springer</publisher-name>; <year>1998</year>. doi:<pub-id pub-id-type="doi">10.1007/978-94-015-9010-5_2</pub-id>.</mixed-citation></ref>
<ref id="ref-25"><label>[25]</label><mixed-citation publication-type="book"><person-group person-group-type="author"><string-name><surname>Butt</surname> <given-names>P</given-names></string-name></person-group>. <source>Modern legal drafting: a guide to using clearer language</source>. <edition>3rd ed</edition>. <publisher-loc>Cambridge, UK</publisher-loc>: <publisher-name>Cambridge University Press</publisher-name>; <year>2013</year>.</mixed-citation></ref>
<ref id="ref-26"><label>[26]</label><mixed-citation publication-type="conf-proc"><person-group person-group-type="author"><string-name><surname>Savelka</surname> <given-names>J</given-names></string-name></person-group>. <article-title>Unlocking practical applications in legal domain: evaluation of GPT for zero-shot semantic annotation of legal texts</article-title>. In: <conf-name>Proceedings of the Nineteenth International Conference on Artificial Intelligence and Law. ICAIL &#x2019;23; 2023 Jun 19&#x2013;23</conf-name>; <publisher-loc>Braga, Portugal. New York, NY, USA</publisher-loc>: <publisher-name>Association for Computing Machinery; 2023</publisher-name>. p. <fpage>447</fpage>&#x2013;<lpage>51</lpage>. doi:<pub-id pub-id-type="doi">10.1145/3594536.3595161</pub-id>.</mixed-citation></ref>
<ref id="ref-27"><label>[27]</label><mixed-citation publication-type="journal"><person-group person-group-type="author"><string-name><surname>Deroy</surname> <given-names>A</given-names></string-name>, <string-name><surname>Ghosh</surname> <given-names>K</given-names></string-name>, <string-name><surname>Ghosh</surname> <given-names>S</given-names></string-name></person-group>. <article-title>Applicability of large language models and generative models for legal case judgement summarization</article-title>. <source>Artif Intell Law</source>. <year>2024 Jul</year>;<volume>32</volume>:<fpage>231</fpage>. doi:<pub-id pub-id-type="doi">10.1007/s10506-024-09411-z</pub-id>.</mixed-citation></ref>
<ref id="ref-28"><label>[28]</label><mixed-citation publication-type="conf-proc"><person-group person-group-type="author"><string-name><surname>Branting</surname> <given-names>LK</given-names></string-name>, <string-name><surname>Callaway</surname> <given-names>CB</given-names></string-name>, <string-name><surname>Mott</surname> <given-names>BW</given-names></string-name>, <string-name><surname>Lester</surname> <given-names>JC</given-names></string-name></person-group>. <article-title>Integrating discourse and domain knowledge for document drafting</article-title>. In: <conf-name>Proceedings of the 7th International Conference on Artificial Intelligence and Law. ICAIL &#x2019;99; 1999 Jun 14&#x2013;17</conf-name>; <publisher-loc>Oslo, Norway. New York, NY, USA</publisher-loc>: <publisher-name>Association for Computing Machinery; 1999</publisher-name>. p. <fpage>214</fpage>&#x2013;<lpage>20</lpage>. doi:<pub-id pub-id-type="doi">10.1145/323706.323800</pub-id>.</mixed-citation></ref>
<ref id="ref-29"><label>[29]</label><mixed-citation publication-type="journal"><person-group person-group-type="author"><string-name><surname>Markovi</surname> <given-names>M</given-names></string-name>, <string-name><surname>Gostoji</surname> <given-names>S</given-names></string-name></person-group>. <article-title>Legal document assembly system for introducing law students with legal drafting</article-title>. <source>Artif Intell Law</source>. <year>2023 Dec</year>;<volume>31</volume>(<issue>4</issue>):<fpage>829</fpage>&#x2013;<lpage>63</lpage>. doi:<pub-id pub-id-type="doi">10.1007/s10506-022-09339-2</pub-id>; <pub-id pub-id-type="pmid">36407875</pub-id></mixed-citation></ref>
<ref id="ref-30"><label>[30]</label><mixed-citation publication-type="conf-proc"><person-group person-group-type="author"><string-name><surname>Narendra</surname> <given-names>S</given-names></string-name>, <string-name><surname>Shetty</surname> <given-names>K</given-names></string-name>, <string-name><surname>Ratnaparkhi</surname> <given-names>A</given-names></string-name></person-group>. <article-title>Enhancing contract negotiations with LLM-based legal document comparison</article-title>. In: <conf-name>Proceedings of the Natural Legal Language Processing Workshop 2024</conf-name>. <publisher-loc>Miami, FL, USA</publisher-loc>: <publisher-name>Association for Computational Linguistics</publisher-name>; <year>2024</year>. p. <fpage>143</fpage>&#x2013;<lpage>53</lpage>.</mixed-citation></ref>
<ref id="ref-31"><label>[31]</label><mixed-citation publication-type="conf-proc"><person-group person-group-type="author"><string-name><surname>Westermann</surname> <given-names>H</given-names></string-name></person-group>. <article-title>Dallma: semi-structured legal reasoning and drafting with large language models</article-title>. In: <conf-name>Proceedings of the 2nd Workshop on Generative AI and Law, Co-Located with the International Conference on Machine Learning (ICML)</conf-name>. <publisher-loc>Vienna, Austria</publisher-loc>; <year>2024</year>.</mixed-citation></ref>
<ref id="ref-32"><label>[32]</label><mixed-citation publication-type="conf-proc"><person-group person-group-type="author"><string-name><surname>Castano</surname> <given-names>S</given-names></string-name>, <string-name><surname>Ferrara</surname> <given-names>A</given-names></string-name>, <string-name><surname>Montanelli</surname> <given-names>S</given-names></string-name>, <string-name><surname>Picascia</surname> <given-names>S</given-names></string-name>, <string-name><surname>Riva</surname> <given-names>D</given-names></string-name></person-group>. <article-title>A knowledge-based service architecture for legal document building</article-title>. In: <conf-name>2nd Workshop on Knowledge Management and Process Mining for Law, Co-Located with FOIS 2023; 2023 Jul 19&#x2013;20</conf-name>; <publisher-loc>Sherbrooke, QC, Canada</publisher-loc>: <publisher-name>CEUR Workshop Proceedings</publisher-name>; <year>2023</year>.</mixed-citation></ref>
<ref id="ref-33"><label>[33]</label><mixed-citation publication-type="journal"><person-group person-group-type="author"><string-name><surname>Liu</surname> <given-names>S</given-names></string-name>, <string-name><surname>Cao</surname> <given-names>J</given-names></string-name>, <string-name><surname>Li</surname> <given-names>Y</given-names></string-name>, <string-name><surname>Yang</surname> <given-names>R</given-names></string-name>, <string-name><surname>Wen</surname> <given-names>Z</given-names></string-name></person-group>. <article-title>Low-resource court judgment summarization for common law systems</article-title>. <source>Inform Process Manage</source>. <year>2024</year>;<volume>61</volume>(<issue>5</issue>):<fpage>103796</fpage>. doi:<pub-id pub-id-type="doi">10.1016/j.ipm.2024.103796</pub-id>.</mixed-citation></ref>
<ref id="ref-34"><label>[34]</label><mixed-citation publication-type="other"><person-group person-group-type="author"><string-name><surname>Touvron</surname> <given-names>H</given-names></string-name>, <string-name><surname>Lavril</surname> <given-names>T</given-names></string-name>, <string-name><surname>Izacard</surname> <given-names>G</given-names></string-name>, <string-name><surname>Martinet</surname> <given-names>X</given-names></string-name>, <string-name><surname>Lachaux</surname> <given-names>MA</given-names></string-name>, <string-name><surname>Lacroix</surname> <given-names>T</given-names></string-name>, <etal>et al.</etal></person-group> <article-title>LLaMA: open and efficient foundation language models</article-title>. <comment>arXiv:2302.13971. 2023</comment>.</mixed-citation></ref>
<ref id="ref-35"><label>[35]</label><mixed-citation publication-type="other"><person-group person-group-type="author"><collab>TAIDE</collab></person-group>. <article-title>TAIDE-LX-7B: a large language model</article-title>. 2024 [cited 2024 Jun 9]. Available from: <ext-link ext-link-type="uri" xlink:href="https://huggingface.co/taide/TAIDE-LX-7B">https://huggingface.co/taide/TAIDE-LX-7B</ext-link>.</mixed-citation></ref>
<ref id="ref-36"><label>[36]</label><mixed-citation publication-type="book"><person-group person-group-type="author"><string-name><surname>Lin</surname> <given-names>Z</given-names></string-name>, <string-name><surname>Madotto</surname> <given-names>A</given-names></string-name>, <string-name><surname>Fung</surname> <given-names>P</given-names></string-name></person-group>. <chapter-title>Exploring versatile generative language model via parameter-efficient transfer learning</chapter-title>. In: <source>Findings of the association for computational linguistics: EMNLP 2020; 2020 Nov 16&#x2013;20</source>; <publisher-loc>Online. Stroudsburg, PA, USA</publisher-loc>: <publisher-name>Association for Computational Linguistics</publisher-name>; <year>2020</year>. p. <fpage>441</fpage>&#x2013;<lpage>59</lpage>.</mixed-citation></ref>
<ref id="ref-37"><label>[37]</label><mixed-citation publication-type="other"><person-group person-group-type="author"><string-name><surname>Xu</surname> <given-names>L</given-names></string-name>, <string-name><surname>Xie</surname> <given-names>H</given-names></string-name>, <string-name><surname>Qin</surname> <given-names>SZJ</given-names></string-name>, <string-name><surname>Tao</surname> <given-names>X</given-names></string-name>, <string-name><surname>Wang</surname> <given-names>FL</given-names></string-name></person-group>. <article-title>Parameter-efficient fine-tuning methods for pretrained language models: a critical review and assessment</article-title>. <comment>arXiv:2312.12148. 2023</comment>.</mixed-citation></ref>
<ref id="ref-38"><label>[38]</label><mixed-citation publication-type="other"><person-group person-group-type="author"><string-name><surname>Han</surname> <given-names>Z</given-names></string-name>, <string-name><surname>Gao</surname> <given-names>C</given-names></string-name>, <string-name><surname>Liu</surname> <given-names>J</given-names></string-name>, <string-name><surname>Zhang</surname> <given-names>J</given-names></string-name>, <string-name><surname>Zhang</surname> <given-names>SQ</given-names></string-name></person-group>. <article-title>Parameter-efficient fine-tuning for large models: a comprehensive survey</article-title>. <comment>arXiv:2403.14608. 2024</comment>.</mixed-citation></ref>
<ref id="ref-39"><label>[39]</label><mixed-citation publication-type="other"><person-group person-group-type="author"><string-name><surname>Hu</surname> <given-names>EJ</given-names></string-name>, <string-name><surname>Shen</surname> <given-names>Y</given-names></string-name>, <string-name><surname>Wallis</surname> <given-names>P</given-names></string-name>, <string-name><surname>Allen-Zhu</surname> <given-names>Z</given-names></string-name>, <string-name><surname>Li</surname> <given-names>Y</given-names></string-name>, <string-name><surname>Wang</surname> <given-names>S</given-names></string-name>, <etal>et al.</etal></person-group> <article-title>LoRA: low-rank adaptation of large language models</article-title>. <comment>arXiv:2106.09685. 2021</comment>.</mixed-citation></ref>
<ref id="ref-40"><label>[40]</label><mixed-citation publication-type="conf-proc"><person-group person-group-type="author"><string-name><surname>Stiennon</surname> <given-names>N</given-names></string-name>, <string-name><surname>Ouyang</surname> <given-names>L</given-names></string-name>, <string-name><surname>Wu</surname> <given-names>J</given-names></string-name>, <string-name><surname>Ziegler</surname> <given-names>D</given-names></string-name>, <string-name><surname>Lowe</surname> <given-names>R</given-names></string-name>, <string-name><surname>Voss</surname> <given-names>C</given-names></string-name>, <etal>et al.</etal></person-group> <article-title>Learning to summarize with human feedback</article-title>. In: <conf-name>NIPS&#x2019;20: Proceedings of the 34th International Conference on Neural Information Processing Systems; 2020 Dec 6&#x2013;12</conf-name>; <publisher-loc>Vancouver, BC, Canada</publisher-loc>. p. <fpage>3008</fpage>&#x2013;<lpage>21</lpage>.</mixed-citation></ref>
<ref id="ref-41"><label>[41]</label><mixed-citation publication-type="conf-proc"><person-group person-group-type="author"><string-name><surname>Devlin</surname> <given-names>J</given-names></string-name>, <string-name><surname>Chang</surname> <given-names>MW</given-names></string-name>, <string-name><surname>Lee</surname> <given-names>K</given-names></string-name>, <string-name><surname>Toutanova</surname> <given-names>K</given-names></string-name></person-group>. <article-title>BERT: pre-training of deep bidirectional transformers for language understanding</article-title>. In: <conf-name>Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies; 2019 Jun 2&#x2013;7</conf-name>; <publisher-loc>Minneapolis, MN, USA</publisher-loc>: <publisher-name>Association for Computational Linguistics</publisher-name>; <year>2019</year>. p. <fpage>4171</fpage>&#x2013;<lpage>86</lpage>.</mixed-citation></ref>
<ref id="ref-42"><label>[42]</label><mixed-citation publication-type="journal"><person-group person-group-type="author"><string-name><surname>Harasta</surname> <given-names>J</given-names></string-name>, <string-name><surname>Novotn&#x00E1;</surname> <given-names>T</given-names></string-name>, <string-name><surname>Savelka</surname> <given-names>J</given-names></string-name></person-group>. <article-title>It cannot be right if it was written by AI: on lawyers&#x2019; preferences of documents perceived as authored by an LLM vs a human</article-title>. <source>Artif Intell Law</source>. <year>2024 Dec</year>;<volume>25</volume>:<fpage>1087</fpage>. doi:<pub-id pub-id-type="doi">10.1007/s10506-024-09422-w</pub-id>.</mixed-citation></ref>
</ref-list>
</back></article>