Knowledge-Infused Legal Wisdom: Navigating LLM Consultation through the Lens of Diagnostics and Positive-Unlabeled Reinforcement Learning (2024)

Abstract: The integration of generative Large Language Models (LLMs) into various applications, including the legal domain, has been accelerated by their expansive and versatile nature. However, when facing a legal case, users without a legal background often struggle to formulate professional queries and may inadvertently overlook critical legal factors when presenting their case narrative to LLMs. To address this issue, we propose the Diagnostic Legal Large Language Model (D3LM), which utilizes adaptive lawyer-like diagnostic questions to collect additional case information and then provides high-quality feedback. D3LM incorporates an innovative graph-based Positive-Unlabeled Reinforcement Learning (PURL) algorithm, enabling the generation of critical questions and enhancing user-LLM interactions. Moreover, an integrated LLM-based stopping criterion facilitates precise Court Views Generation (CVG). Our research also introduces a new English-language CVG dataset1 based on the US case law database, enriching the realm of LLM research and deployment with a vital dimension. D3LM surpasses classical LLMs by delivering outstanding performance and a remarkable user experience in the legal domain.

heading: 1 Introduction
text: Recent years have witnessed a substantial increase in the demand for legal services (Gans-Morse, 2017; Purba and Syahrin, 2019). Despite this growing need, legal resources remain scarce, especially for individuals with modest means (Hadfield, 2010). This scarcity has led to a significant rise in the cost of legal assistance (Brescia et al., 2014), making it difficult for ordinary people to afford the necessary legal support. Furthermore, this situation exacerbates the inherent inequities in legal proceedings between the affluent and the underprivileged. Affluent individuals often benefit from dedicated legal
∗Corresponding author 1https://github.com/YANGWU001/US_CVG_dataset.git
teams to represent them in disputes, whereas the economically disadvantaged lack similar access to legal aid (Horwitz, 2020). This discrepancy not only hinders the ability of the poor to seek justice but also perpetuates a system of latent unfairness in legal cases across socio-economic divides.
With the advent of LLMs, ordinary individuals have gained increased access to legal resources and services. However, the current mode of interaction between users and LLMs predominantly remains user-led (Achiam et al., 2023; Touvron et al., 2023), where users input queries and receive responses from LLMs. This interaction mode presents significant limitations, particularly as many users lack a legal background (Zamfirescu-Pereira et al., 2023). Their queries often lack the essential factual details about their legal issues, which in turn, hampers the ability of LLMs to provide effective assistance. Recognizing this challenge, we have developed D3LM, a novel framework designed to act as a legal assistant, as illustrated in Fig. 1. In this toy example, we introduce the D3LM model through a real-life scenario where a client, facing legal charges from a minor altercation, seeks assistance. Initially, the client provides a vague description, prompting a comparison among three different approaches. Traditional LLMs offer a broad perspective of the court’s view, but often overlook critical details due to insufficient information. In contrast, consultations with a lawyer provide a thorough investigation through targeted questions, albeit at a significant cost. D3LM distinguishes itself by autonomously generating specific, case-relevant questions, thereby gaining a deeper understanding of the situation and enhancing the accuracy of legal outcome predictions, all without incurring the high expenses associated with legal counsel. By engaging users in a dialogue to extract detailed information about their legal predicaments, D3LM mirrors the proactive approach of human lawyers in gathering pertinent data to better assist
15542
their clients. This innovative engagement method ensures D3LM delivers highly accurate and costeffective legal insights, demonstrating its potential to transform the provision of legal services.
Moreover, we introduce a novel approach that leverages LLMs to efficiently process and analyze extensive U.S. legal cases. Utilizing LLMs, we generate structured fact-rule graphs and the ’Issue, Rule, Analysis, Conclusion’ (IRAC2) (Gensler, 1985) to transform complex case narratives into concise representations. Our method integrates these graphs into a comprehensive knowledge base, designed to identify and fill in missing factual information in legal scenarios. By employing a reinforcement learning approach, we refine the selection of relevant fact nodes, enhancing the model’s ability to guide users through legal inquiries effectively. This system is rigorously evaluated to ensure its accuracy and practicality in real-world legal settings, showcasing its potential to innovate legal case analysis.
Our contributions in this paper are threefold and can be summarized as follows:
• Novel User-LLM Interaction Paradigm: We introduce a new user-LLM conversion framework in legal contexts by shifting from userled enquiries to LLM-navigated diagnostics. Our approach actively seeks detailed case information from user through targeted questioning, resulting in unparalleled accuracy and efficacy in legal advice.
• Pioneering Positive-Unlabeled Reinforcement Learning (PURL) Algorithm: Leveraging the
2The detailed explanation of IRAC is in Appendix A.2
fusion of LLM and legal graph, PURL identifies crucial factors dynamically for adaptive question generation, which enabling LLM’s information solicitation capabilities in legal contexts.
• Introducing a new English legal dataset: a new focus on US legal cases. Departing from prior studies relying on Chinese data, this dataset establishes a new benchmark for legal AI experiments in the US case law system.

heading: 2 Related Work

heading: 2.1 Legal Assistant
text: Recent advancements in computational methods have significantly impacted judicial decisionmaking, leveraging the text-centric nature of legal data for natural language processing (NLP) applications. Early research by Lin et al. (2012), Zhong et al. (2018), and Hu et al. (2018) treated charge prediction as a classification problem within legal judgments, laying the groundwork for NLP in legal contexts. This foundation expanded to include case retrieval (Chen et al., 2013) and law article recommendation (Chen et al., 2022), enhancing NLP’s scope in legal informatics. The interpretability of legal decisions, explored by Ye et al. (2018) and (Wu et al., 2020), introduced court view generation (CVG) as a means to predict judicial outcomes based on case descriptions, emphasizing the need for nuanced legal text understanding and generation. The introduction of LLMs like Lawformer (Xiao et al., 2021) and Chatlaw (Cui et al., 2023) further advanced this field, demonstrating LLMs’ potential in generating accurate legal texts. Un-
like previous models, our D3LM approach mimics a lawyer’s consultative strategy, engaging in dynamic interaction through targeted questioning to gather comprehensive case details, marking a significant evolution in the application of AI for legal informatics.

heading: 2.2 Enhanced Learning through PU Learning and Reinforcement Learning
text: In the landscape of computational learning, Positive-Unlabeled (PU) Learning has emerged as a key strategy for binary classification, leveraging a mix of a small number of positive instances and a large volume of unlabeled data. This methodology has been applied in diverse areas including chronic disease prediction (Chen et al., 2020; Wu et al., 2023), fake news detection (Liu and Wu, 2020), and recommendation systems (Zhou et al., 2021), utilizing advanced techniques like uPU and nnPU (Kiryo et al., 2017) alongside unbiased risk estimators (Du Plessis et al., 2015) to mitigate data bias. Innovations such as predictive adversarial learning (Hu et al., 2021; Wei and Li, 2018) and Dist-PU (Zhao et al., 2022) further refine this approach by enhancing data generation and label distribution consistency. Additionally, the adaptation of reinforcement learning, particularly bandit learning, has introduced novel training signals and strategies, including context-free (Chapelle and Li, 2011; Auer et al., 2002) and contextual bandits (Chu et al., 2011; Zhou et al., 2020), to improve model outcomes. Our work introduces the PURL framework, integrating the advanced capabilities of LLMs with domain-specific PU models to achieve decision-making precision tailored to unique application contexts, signifying a notable advancement in computational learning methodologies.

heading: 2.3 Large Model Dataset Creation
text: In the NLP field, LLMs have transformed dataset generation, producing extensive datasets that capture diverse linguistic phenomena, enhancing versatility for various NLP tasks. Examples include WANLI (Liu et al., 2022), utilizing GPT-3 for generation and dataset cartography (Swayamdipta et al., 2020) for refining NLI examples, and DISCO (Chen et al., 2023), which creates counterfactual examples through local perturbations. However, deploying LLMs in legal domains, especially for U.S. cases, faces challenges like narrative length and complexity, which exceed LLMs’ token limits, hindering dataset creation and model training
(Jin et al., 2024). Our approach leverages LLMs to streamline U.S. legal narratives, facilitating manageable CVG dataset creation and bridging Englishlanguage resource gaps with legal expert collaboration. This method addresses English legal analysis dataset scarcity, adding significant resources to the domain.

heading: 3 Methodology
text: In this section, we begin by introducing the definition of the CVG problem in Section 3.1. We then proceed to present the overall D3LM framework in Fig. 2 in Section 3.2. Finally, we demonstrate the PURL algorithm in Alg. 1 in detail in Section 3.3. To facilitate understanding and clarity, we provide a summary of the notations used in this paper in Tab. 1.

heading: 3.1 Problem Definition
text: In this study, we address the challenge of generating court views in US criminal cases. Our focus is to formalize this problem through a clear delineation of fact descriptions and court views. Fact Description (D) is the comprehensive narrative of a given legal case, encompassing all pertinent facts and events. We represent fact descriptions as D = ( D1, D2, ..., D|D| ) , where each Di corresponds to the fact description of a unique case. Court Views (C) represent the judicial rationale underlying the court’s verdict for a case. We define court views as C = ( C1, C2, ..., C|C| ) . The primary task in court views generation is to accurately derive C given D.

heading: 3.2 D3LM Framework
text: We elaborate on the D3LM framework as illustrated in Fig. 2. Our framework activates upon receiving a legal query from a client, which is then processed by an advanced Language Model (LLM) to formulate an initial court opinion. However, this opinion is not immediately disclosed; it is contingent on the following procedure. Leveraging the methodology proposed by Schick et al. (2023), we deploy a specialized token to evaluate the completeness of case information provided. This binary token ’Y es’ or ’No’ guides the subsequent actions: a ’No’ activates our PURL algorithm to craft new, case-specific question for client to gather more case information, whereas a ’Y es’ moves the process toward the conclusion and delivery of the court opinion. This dynamic cycle of evaluation and information enhancement continues until a ’Y es’ token signifies the attainment of a fully informed court opinion.
Utilizing a Case-View Generation (CVG) dataset comprising a set of case descriptions D =( D1, D2, ..., D|D| ) and corresponding court opin-
ions C = ( C1, C2, ..., C|C| ) , for each pair ( Di, Ci), we randomly mask certain facts from both Di and Ci to derive Di and Ci. Subsequently, we append the special tokens ei at the end of each court view, as:
e =< T >→ token < / T > (1)
where "< T >", "→", and "< / T >" are fixed special tokens3."token" is "Y es" for original Ci and "No" for masked Ci. This augmented dataset serves to fine-tune the LLM. During the inference phase, regular decoding proceeds until the finetuned LLM outputs the "→", which dictates the decision to either continue or conclude the information gathering process. By prompting users to provide detailed responses through case-specific questions, the D3LM framework iteratively refines the court view, ensuring that the final advice is accurate and tailored to the client’s needs. This innovative method enhances the model’s ability to collect pertinent information, leading to more precise legal guidance.
3In practice, we use the token sequences "[", "]" and "->" to represent "< T >", "< / T >" and "→"

heading: 3.3 Positive-unlabeled Reinforcement Learning (PURL) Question Generation
text: In this section, we showcase our PURL framework for next question generation through Fig. 3 and detail its training process in Alg. 1.
As illustrated in Fig. 3, for each extensive legal caselaw document, denoted as Casei, we utilize an LLM to extract a fact-rule graph Gi representing the case4. Concurrently, we apply the legal IRAC strategy to summarize the case’s fact description Di and court views Ci. Subsequently, the LLM generates a set of questions Qi based on the text of Ci. For model training, we randomly mask some fact nodes in Gi to create a masked graph Gi, and then use the LLM to reconstruct the fact description and corresponding court view as Di and Ci, respectively. Based on the nodes in Gi, we extract an N-hop subgraph G′ from the knowledge graph G, which is a merged graph comprising{ G1, G2, . . . , G|G| } . We then define the candidate
fact set as Fi = { v |v ∈ VG′i − VGi } , where VG′i , VGi represent the nodes in G ′ i and Gi, respectively. The task involves selecting the most relevant node from Fi for the masked case description Di. Following node selection, we use a prompt-based approach to transform the selected node into a casespecific question to client. The detailed process for CVG data generation is formalized in Alg. 2.
4The detailed fact-rule graph generation prompt is in Appendix A.2

heading: 3.3.1 Domain Positive-Unlabeled Model Training
text: Given a masked case description Di and its corresponding subgraph G′, we initialize the text embedding hi using RoBERTa (Liu et al., 2019) and randomly initialize the node embeddings as a matrix Hi ∈ Rn×d, where n denotes the number of nodes and d denotes the embedding dimension. After processing the node embeddings through several DiGCN layers (Tong et al., 2020), a node attention5 network is applied to capture semantic relationships between case description text and candidate fact nodes. Subsequently, a Multilayer Perceptron (MLP) is utilized to compute the probability scores.
For each {hi, Hji } pair, we designate the set of masked nodes as positive instances and the remaining nodes as unlabeled instances. During the training process, we employ the nnPU (Kiryo et al., 2017) risk estimator, which is defined as follows:
Riskpu(g) = πp np
np∑
i=1
l(g(xpi ),+1)+
max(0, 1
nu
nu∑
i=1
l(g(xui ),−1)−
πp np
np∑
i=1
l(g(xpi ),−1))
(2)
where π is the positive class prior, l(·, ·) is any 5The detailed information of node attention design is in
Appendix A.1
surrogate loss of zero-one loss (Du Plessis et al., 2015), np represents the number of labeled positive instances, nu represents the number of unlabeled instances, xpi and x u i denote instances in the labeled positive set and the unlabeled set, respectively. All cases shared the same domain model layer in training process. The details are formalized in Alg. 3.
Algorithm 1 PURL Training Input: Training cases fact descriptions set D; N-hop sub-
graphs set G′; positive class priors set π; training epochs E; step size η; discount factor γ; LLM Output: Domain_pu model parameters θ and case-specific NeuralUCB parameters set {ϕ1, ϕ2, . . . , ϕ|X|}
1: Randomly initialize θ and {ϕ1, ϕ2, . . . , ϕ|X|} 2: θ = Train_Domain_PU(D,G′, π, E, η, γ) using Alg. 3 3: Calculate reward R based on Eq. 4 4: for i = 1, 2, . . . , |X| do 5: for t = 1, 2, . . . , T do 6: Observe { x t,F
j i } F
j i ∈Fi
7: Select action F ji with the largest upper confidence bound using NeuralUCB (Zhou et al., 2020) 8: Play action F ji and observe reward R(F j i ) 9: Update NeuralUCB parameters ϕi using{ xz,(Fi)z }t z = 1 and { Rz,(Fi)z }t z = 1 10: end for 11: end for 12: Return Domain_pu model with updated parameters θ
and case-specific NeuralUCB with updated parameters set {ϕ1, ϕ2, . . . , ϕ|X|}

heading: 3.3.2 LLM Reading Comprehension
text: For each masked case description Di and its corresponding candidate facts set Fi, we utilize the
reading comprehension capabilities of the LLM to assess the significance of each candidate fact F ji ∈ Fi. Incorporating F j i into the masked description aims to enrich the case narrative by reconstructing the fact description and generating an enhanced court view Ci(+F j i ). This enhanced view, Ci(+F j i ), is then used to answer the questions set Qi, derived from the original court views text Ci. We evaluate the reading comprehension score of F ji for case Di as:
RCScore ( Di, F j i ; LLM ) =
∣∣∣S ( Ci + F j i , Qi )∣∣∣ |Qi| (3)
where S ( Ci + F j i , Qi ) is a subset of Qi that consists of questions correctly answered using Ci(+F j i ).

heading: 3.3.3 Model Training
text: For each case description text Di and candidate fact nodes Fi, we denote their corresponding embeddings are hi and Hi (Hi is matrix of all fact nodes embeddings). We calculate two types of rewards: 1)Rpu, the probability score from the domain-
specific PU model, calculated as P ( hi, H j i ; θ ) , where θ is the domain positive-unlabeled model; 2) Rlmrc, the language model reading comprehension score calculated as Eq. 3. To optimize fact node selection, we employ reinforcement learning (bandit), which allows the model to refine its choice dynamically. The selected fact node is then formulated as the next query for the legal client. The overall reward function is:
Rtotal = Rpu + λRlmrc (4)
where λ adjusts the contribution of the LMRC score to the total reward, and we set 0.5 in our model. By leveraging bandit learning for its flexibility, our model surpasses traditional methods by better handling uncertainty in selecting the most relevant fact node for next question generation.

heading: 3.3.4 Model Inference
text: During inference, the process involves mapping the provided case description text to its corresponding fact-rule graph. From this graph, a subgraph is extracted from the overarching knowledge graph, which yields a set of candidate facts. For each of these facts, the corresponding bandit algorithm is employed to facilitate the selection process.

heading: 4 Experiments

heading: 4.1 Data Construction
text: Addressing the notable absence of Englishlanguage datasets for court views generation (CVG), our research introduces the first US-CVG dataset, derived from criminal legal documents (Caselaw Access Project, 2024). Unlike the structured format of Chinese legal documents, U.S. case law’s complexity and length (averaging over 7694 tokens) pose significant challenges for CVG tasks, often surpassing the token limits of advanced LLMs.
Our dataset leverages the IRAC framework to process US caselaw documents, using GPT-4.0 to summarize and extract fact descriptions and court views, which enables the reduction of the total token length to a structured IRAC format. Additionally, we create fact-rule graphs for each case to support complex analysis. The dataset’s integrity is ensured through meticulous review by three legal professionals, after which it is segmented into training, validation, and test sets in an 8:1:1 ratio.
This pioneering dataset fills a critical void for English-language CVG research, offering a structured approach to legal document analysis that paves the way for future computational legal studies.

heading: 4.2 Experimental Settings
text: The experimental setup for our D3LM model utilized the Llama2-13B as the base architecture. The sampling parameters were set with a temperature of 0.8 and a top_p value for nucleus sampling at 0.9, alongside a maximum token count of 4096. We initialized word embeddings with RoBERTa, while node embeddings were randomly generated. The model’s Positive-Unlabeled learning component consisted of six Multi-Layer Perceptron (MLP) layers. The learning rate for the PURL was established at 1e−4, paired with a batch size of 2000. Conducted on an NVIDIA A100 GPU, our experiments spanned over 100 epochs to ensure comprehensive training.

heading: 4.3 Comparisons with Baselines
text: Evaluation Metrics. To evaluate our model, we implemented both automatic and human assessment methods. For automatic evaluation, we used Rouge (Rouge-1, Rouge-2, and Rouge-L for LCS-based statistics) and BLEU scores (BLEU-1, BLEU-2, and an average of BLEU-1 to BLEU-4, denoted as BLEU-N), which are benchmarks in natural language generation tasks. Furthermore, human judgment focused on three aspects: 1) fluency, 2) accuracy, and 3) adoptable of rationales in generating court views, rated on a five-point scale (with 5 being the highest). This evaluation was conducted by three legal professionals, ensuring a comprehensive and expert assessment of the model’s performance in producing contextually accurate and legally coherent text. This streamlined approach balances thoroughness with brevity, maintaining the integrity of the evaluation process while ensuring clarity and conciseness.
Baselines. We implement the following baselines for comparison: • BM25 (Robertson and Walker, 1994) is a classic retrieval baseline that identifies the most closely related text content between case fact descriptions and court views’ rationale sections. In our study, we treat all court views data (train, dev, test) as a database, retrieving the court views with the highest relevance score to each case’s fact description using BM25 as our baseline model. • AC-NLG (Wu et al., 2020)is an attention and
counterfactual-based generative model, designed to transform fact descriptions into court views by training with these elements as input and output, respectively. • Llama2-13B-ST (Touvron et al., 2023) is a LLM developed by Meta, which utilizes prompts and fact descriptions as inputs to generate court views responses. (ST means single-turn interaction between user and LLM.) • FT-Llama2-13B-ST is a fine-tuned version of Llama2-13B-ST. We use the training data to finetune the model, employing fact descriptions as input and court views as output in the fine-tune process. • GPT4.0-ST (Achiam et al., 2023)is an LLM created by OpenAI, employing prompts and fact descriptions to interactively produce court views responses. • D3LMw/oPU is a variant of our proposed D3LM model that does not incorporate positive-unlabeled learning in its framework. • D3LMw/oLMRC is a variant of our proposed D3LM model excluding the use of language model reading comprehension. • D3LMw/oRF is a variant of our proposed D3LM model that operates without the integration of reinforcement learning. Experimental Result. In the automatic evaluation detailed in Tab. 3, the D3LM model showcases superior performance in generating U.S. court views, achieving the highest ROUGE and BLEU scores. Notably, GPT4.0-ST stands out as a particularly strong competitor, especially in terms of ROUGE metrics. Furthermore, the variant D3LMw/oRF registers impressively high BLEU scores, highlighting its adeptness at capturing the subtle linguistic qualities of the generated court views. The comparison between D3LM and its ablated versions underlines the significance of each individual module, con-
firming that every element plays a vital role in the overall success of the model in the complex task of legal text generation.
In the human evaluation, as illustrated by Tab. 4, our D3LM model demonstrates superior performance in accuracy and adaptability, achieving scores of 4.48 and 4.19, respectively, which marginally exceed those of GPT4.0-ST by about 0.1 points in each metric. GPT4.0-ST, however, takes the lead in fluency with a score of 4.74, proving to be a formidable competitor in semantic coherence. This could be attributed, in part, to our model’s foundation on the Llama2-13B architecture. Despite this, the results emphasize D3LM’s capability to generate precise and contextually adaptable court views, underlining its efficacy in comparison to a notably strong rival in legal text generation.

heading: 4.4 Human Acceptability
text: To ensure fairness when comparing our model’s metrics with those of traditional LLMs, we conducted a usability testing to gauge user experience and perceptions regarding our approach, which involves greater interaction with legal clients and thus, allows our model to gather more case-specific information. We invited 69 participants to evaluate their experiences and opinions on the state-ofthe-art LLM, GPT-4.0, versus our model, D3LM, across three key metrics: 1) Reliability (Reli.), the perceived reliability of the models; 2) Satisfaction
(Sati.), the level of satisfaction with the models; and 3) Preference (Pref.), their preference for either model. We employed a five-point scale for both reliability and satisfaction assessments (where 5 represents the highest rating), and participants were asked to indicate a preference between GPT4.0 and D3LM.
The findings, detailed in Table 5, revealed that on legal tasks, users reported approximately 0.5 points higher reliability and satisfaction scores for D3LM compared to GPT-4.0. Moreover, 62.3% of participants expressed a preference for using D3LM over GPT-4.0. These results underscore the acceptance and appreciation for our model’s interactive questioning approach, highlighting D3LM’s enhanced accuracy and reliability in legal applications.

heading: 4.5 Case Study
text: Fig. 4 presents a comparison of court views generated by GPT4.0 and the proposed D3LM method for a masked fact description in a specific US criminal case. Upon comparison with the actual court’s view, it is evident that our PURL feature within D3LM can precisely recover the fact "Alibi" and systematically generate questions to elicit further information about the case. Consequently, D3LM produces a more accurate court view than GPT4.0.

heading: 5 Conclusion and Future Work
text: Our study introduces D3LM, an innovative approach in legal assistant systems for court view generation, diverging from traditional methods by simulating real lawyer-client interactions. By innovatively employing Diagnostic Analysis through continuous user engagement, we enable the generation of more accurate and case-specific court
views. The introduction of our PURL algorithm significantly enhances the precision of information extraction. Additionally, we contribute a novel English-language dataset for American legal cases, meticulously validated by legal professionals, addressing the scarcity in legal analysis datasets and setting new benchmarks in legal informatics. Future work will explore extending this model to other domains, such as medical and consultancy, leveraging its capabilities for broader application.
Limitations
In our study, we explored the potential of Large Language Models (LLMs) to improve legal assistance through active engagement with clients, prompting for case-specific details. However, our findings underscore several limitations: the PURL algorithm’s effectiveness is confined to the criminal cases domain due to its reliance on a specialized knowledge graph, which is not only resourceintensive to create but also limits cross-domain applicability. Moreover, our evaluation was restricted to English language cases, overlooking the model’s performance in diverse linguistic contexts-a critical consideration for global legal system applicability. Furthermore, the model demands significant computational and human annotation resources, with its operational speed lagging behind that of existing large models, potentially hindering its practicality in time-sensitive settings. These challenges underscore the need for future research to focus on optimizing computational efficiency, broadening linguistic and domain applicability, and reducing resource dependencies, aiming to enhance the practicality and accessibility of LLMs in legal assistance across a wider range of contexts.

heading: Acknowledgements

heading: A Appendix
text: A.1 node attention Given a masked case description embedding hi and its corresponding subgraph node embeddings Hi. We conduct node embedding as following:
eij = σ ( W · [ hi , H j i ] + b ) (5)
αij = exp
( σ ( W · [ hi , H j i ] + b )) ∑
k∈Hi exp ( σ ( W · [ hi , Hki ] + b )) (6)
Zi = ∑
j∈Hi
αijhij (7)
where σ denotes Relu activation function, [., .] represents embedding concatenation. Furthermore, we concatenate the Zi with each fact node embedding Hji , and pass through a MLP to obtain output probability as:
P ( hi, H j i ) = ϕ ([ Zi, H j i ]) (8)
A.2 Prompt details A.2.1 Case type classification "Please select the most appropriate category from the following options: Contract Law, Criminal Law, Property Law, Intellectual Property Law, Business Law, Tax Law, Estate and Trust Law, Family Law, Administrative Law, Civil Law, Tort Law, Bankruptcy Law, Environmental Law. Provide the category name that best fits the case described below."
A.2.2 IRAC summarization "Based on the case description, please generate legal case IRAC (Issue, Rule, Analysis, Conclusion) in following pattern: **Issue:** Identifying the legal question or questions that need to be addressed in the legal case. **Rule:**
Stating the applicable legal rules, statutes, regulations, or case law that pertain to the identified issue. **Analysis:** Applying the relevant legal rules to the facts or circumstances of the case. This involves explaining how the rules should be interpreted and applied. **Conclusion:** Summarizing the court judgement to the legal issue."
A.2.3 Fact-Rule graph extraction "I’m developing a project to analyze legal cases deeply by distilling case texts into concise formats for graphical representation. Help me extract key facts influencing court decisions, the applicable rules, and the relationships between them without considering the decision’s outcome. Facts should be generalized (e.g., "Contract", "Damages") and rules brief (e.g., "Civil Law", "Contract Law"). Edges should either show a fact’s dependency on another fact ("Depends On") or its compliance with or violation of a rule ("Complies With"/"Violates"). Provide three Python lists for networkx: facts, rules, and edges, with edges formatted as (’Fact’, ’Rule’, ’relation’: ’Relation Type’). Ensure edges accurately reflect the connections without adding nonexistent links. Respond in English with only the lists in a single Python chunk, without extra text or explanation."
A.2.4 Case reconstruction "I have a detailed description of a legal case, including the Issue, Rule, and Analysis of the case. I would like you to help me rewrite this case’s IRA, but please disregard the specific aspects that I will mention below."
A.2.5 LLM reading comprehension Question generation: "I will provide a conclusion of a legal case, please generate 10 unique questions and corresponding answers based on the conclusion information. Please do not give me explanation of the question, greeting words and any annotation words, just give me generated questions."
Scoring: "I will provide a conclusion of a legal case, and 10 unique questions and golden answers, please use the given conclusion to answer the 10 questions, if the conclusion can correctly answer one question, it will get one score, the maximum score is 10, please tell me the final score of the conclusion:"
A.3 Comparison between PU and PN
To verify the effectiveness of our positive-unlabel module, we conducted a comparative experiment between the PU (Positive-Unlabeled) approach and the PN (Positive-Negative) approach. In the PN setting, all unlabeled candidate nodes are treated as negative. The results of the experiment are presented in Table 6. The accuracy, recall, precision, F1, F2, and AUC scores for PU are significantly higher than those for PN.
A.4 CVG dataset generation algorithm
Algorithm 2 CVG Dataset Generation via LLM Input: Legal cases set X Output: CVG dataset {D,C,D,Q, F, Ĝ,G′, G, G} 1: Initialize D,C,D,Q, F, Ĝ,G′, G,G are all as empty
lists 2: for i = 1, 2, . . . , |X| do 3: Gi = LLMextract(Xi) 4: Di , Ci = LLMsummarize(Xi) 5: Qi = LLMgenerate(Ci) 6: Gi = Masked(Gi) 7: Di = LLMreconstruct(Di) 8: D ← D +Di C ← C + Ci
D ← Di +Di Q← Q+Qi Ĝ← Ĝ+Gi Gi ← G+Gi
9: end for 10: G = Merge(Ĝ) 11: for i = 1, 2, . . . , |X| do 12: G′i = GN-hop(Gi) 13: Fi = Extract(G′i) 14: G′ ← G′ +G′i F ← F + Fi 15: end for 16: Human_Check {D,C,D,Q, F, Ĝ,G′, G,G} 17: Return LLM-Generated CVG dataset {D,C,D,Q, F, Ĝ,G′, G,G}
A.5 Domain PU model training
Algorithm 3 Train_Domain_PU Input: Training cases fact descriptions set D; N-hop sub-
graphs set G′; positive class priors set π; training epochs E; step size η; discount factor γ Output: Domain_pu model parameters θ 1: Randomly initialize θ 2: Let A be an external SGD-like stochastic optimization
algorithm such as Adam (reference) 3: for e = 1, 2, . . . , E do 4: for i = 1, 2, . . . , |D| do 5: hi = Roberta(Di) 6: Hi = DiGCN(G′i) 7: Denote positive instances in Hi as xip, unlabeled instances in Hi as xiu 8: if R̂−u ( g; xiu ) − πpR̂−p ( g; xip ) ≥ 0 then 9: Set gradient∇θR̂pu ( g; xip, x i u
) 10: Update θ by A with current step size η 11: else 12: Set gradient∇θ(πpR̂−p ( g; xip ) − R̂−u ( g; xiu ) )
13: Update θ by A with discounted step size γη 14: end if 15: end for 16: end for 17: Return Domain_pu model with updated parameters θ

heading: Future Work
text: Future work will explore extending this model to other domains, such as medical and consultancy, leveraging its capabilities for broader application. Limitations
In our study, we explored the potential of Large Language Models (LLMs) to improve legal assistance through active engagement with clients, prompting for case-specific details. However, our findings underscore several limitations: the PURL algorithm’s effectiveness is confined to the criminal cases domain due to its reliance on a specialized knowledge graph, which is not only resourceintensive to create but also limits cross-domain applicability. Moreover, our evaluation was restricted to English language cases, overlooking the model’s performance in diverse linguistic contexts-a critical consideration for global legal system applicability. Furthermore, the model demands significant computational and human annotation resources, with its operational speed lagging behind that of existing large models, potentially hindering its practicality in time-sensitive settings. These challenges underscore the need for future research to focus on optimizing computational efficiency, broadening linguistic and domain applicability, and reducing resource dependencies, aiming to enhance the practicality and accessibility of LLMs in legal assistance across a wider range of contexts