A method and system for generating legal case summaries based on knowledge-guided prompts and fine-tuning.

By constructing a legal knowledge graph and using cross-attention coding technology, the problems of factual omissions and logical fallacies in legal case summary generation were solved, enabling the generation of professional-level legal summaries and improving the model's adaptability and generation effect.

CN121501992BActive Publication Date: 2026-04-03SHANDONG UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2026-01-12
Publication Date
2026-04-03

AI Technical Summary

Technical Problem

Existing technologies suffer from problems such as bias in extracting factual elements, logical fallacies, and insufficient understanding of professional terminology in generating legal case summaries. Furthermore, traditional hard hint methods lack flexibility, their effectiveness depends on the quality of template design, and they cannot achieve deep knowledge understanding and complex reasoning.

Method used

By constructing a structured legal knowledge graph and a computable prompt template library, relevant knowledge subgraphs are dynamically retrieved and cross-attention encoding is performed. Combined with soft prompting technology, a language model is trained to generate knowledge-enhanced representations, achieving deep semantic fusion of knowledge in text and professional in-depth summarization.

Benefits of technology

It significantly enhances the professionalism and reliability of legal summaries, accurately covering key facts and logical elements, adapting to different case scenarios, and generating more insightful summaries.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121501992B_ABST
    Figure CN121501992B_ABST
Patent Text Reader

Abstract

This invention belongs to the fields of computer artificial intelligence and natural language processing technology, and provides a method and system for generating legal case summaries based on knowledge-guided prompts and fine-tuning. The technical solution involves the structuring and vectorization of legal knowledge. For the original legal documents in the training samples, relevant knowledge subgraphs are dynamically retrieved and filled into the prompt template to obtain prompt text. The concatenated prompt text, the original legal document, and the relevant knowledge subgraphs are encoded to obtain text representations and knowledge representations. A cross-attention mechanism is used to inject the knowledge representation into the text representation to generate a knowledge-enhanced representation. Based on the knowledge-enhanced representation and using a prompt fine-tuning strategy, a language model is trained to obtain a trained language model. The knowledge-enhanced representation of the new legal document to be summarized is extracted, and the trained language model parameters and soft prompt parameters are loaded to generate the final legal case summary. This can generate summaries with greater professional depth and insight.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of computer artificial intelligence and natural language processing technology, and in particular relates to a method and system for generating legal case summaries based on knowledge-guided prompts and fine-tuning. Background Technology

[0002] The statements in this section are merely background information related to the present invention and do not necessarily constitute prior art.

[0003] Legal texts possess a high degree of professionalism, rigorous logic, and unique expression paradigms. When general pre-trained models that have not undergone targeted optimization are directly applied to legal case summary generation, their performance often fails to meet practical requirements, primarily due to the following reasons:

[0004] Bias in fact element extraction: General models tend to identify "important" information based on the statistical regularities of general texts, which can easily lead to omissions or misjudgments of key fact elements in legal documents. This results in the generated summary failing to accurately anchor the core facts and points of contention in the case, and there is a risk of incomplete or distorted factual reconstruction.

[0005] Logical fallacy: Legal summaries not only require a list of facts, but also emphasize establishing a logical connection between facts and legal norms. Common models lack an understanding of the inherent logic of legal argumentation frameworks and the theory of elements of a crime, making it difficult to organize summaries that conform to the "fact-dispute-reason-conclusion" legal argumentation chain. The resulting content often manifests as a simple accumulation of facts or a logically confused narrative.

[0006] Insufficient understanding of legal terminology: The legal field is filled with numerous specialized terms and constituent elements with precise legal connotations, such as "indirect intent," "bona fide acquisition," and "serious circumstances." General models typically understand these concepts only superficially or at the level of common semantics, failing to grasp their deeper legal implications. This results in unprofessional, inaccurate, and potentially misleading summaries.

[0007] To alleviate the aforementioned problems, existing technologies guide models by introducing domain knowledge. A common approach is to add manually designed static prompt templates (i.e., "hard prompts") before the input text. While this method can provide initial guidance for the model's generation direction, it is essentially an addition of external instructions rather than an enhancement of the model's intrinsic capabilities, and has inherent drawbacks: First, the prompt templates are fixed in form and lack flexibility, making it difficult to cover the ever-changing specific case scenarios and diverse summarization needs; second, its effectiveness is highly dependent on the quality of the template design, relying on empirical adjustments and lacking universality and stability; more importantly, this method cannot enable the model to truly "internalize" legal domain knowledge at the parameter level, failing to achieve deep knowledge understanding and complex reasoning. Summary of the Invention

[0008] To address at least one of the technical problems existing in the background art, the present invention provides a method and system for generating legal case summaries based on knowledge-guided prompts and fine-tuning, which effectively reduces factual omissions, deviations and logical fallacies, and significantly improves the legal value and reliability of the summaries.

[0009] To achieve the above objectives, the present invention adopts the following technical solution:

[0010] The first aspect of the present invention provides a method for generating legal case summaries based on knowledge-guided prompts and fine-tuning, comprising the following steps:

[0011] The structuring and vectorization of legal knowledge includes constructing a structured legal knowledge graph and designing a computable prompt template library containing knowledge slots;

[0012] For the original legal documents in the training samples, relevant knowledge subgraphs are dynamically retrieved and populated into the prompt template to obtain prompt text; the concatenated prompt text, the original legal documents, and the relevant knowledge subgraphs are encoded to obtain text representation and knowledge representation; the knowledge representation is injected into the text representation through a cross-attention mechanism to generate knowledge-enhanced representation; the language model is trained based on the knowledge-enhanced representation and a prompt fine-tuning strategy to obtain a trained language model;

[0013] Extract the knowledge-enhanced representation of the new legal document to be summarized, and load the trained language model parameters and soft cue parameters to generate the final legal case summary.

[0014] Furthermore, the construction of the structured legal knowledge graph specifically includes:

[0015] Define multiple node types, including entities representing specific case objects, legal concepts representing the cause of action, elements representing the conditions required for the establishment of a legal concept, and circumstances representing the determination of liability;

[0016] Define various relationship edge types between nodes, including HasElement (representing inclusion), IsA (representing dependency), RelatedTo (representing participation), and Precondition (representing prior dependency).

[0017] Furthermore, the computable prompt template library containing knowledge slots includes at least one parameterized prompt template, which includes a cause of action slot for filling in specific causes of action, a constituent element slot for filling in relevant legal constituent elements, a plot slot for filling in relevant plot elements, and a {document} placeholder for placing the original text of the legal document.

[0018] Furthermore, for the original legal documents in the training samples, relevant knowledge subgraphs are dynamically retrieved and populated into the prompt template to obtain prompt text, including:

[0019] Each sample in the training dataset includes the original legal document D and its corresponding standard summary S written by experts;

[0020] A lightweight model was used to initially identify key legal information from the original text D;

[0021] Based on the identified key legal information, relevant knowledge subgraphs are retrieved from the constructed legal knowledge graph;

[0022] The knowledge slots of the prompt template are filled with knowledge instances from the relevant knowledge subgraphs retrieved, forming specific input prompt text that is highly relevant to the case.

[0023] Furthermore, a dual-path encoding structure is used to encode the concatenated prompt text, the original legal document, and the relevant knowledge subgraph, respectively, to obtain text representation and knowledge representation, including:

[0024] The combined text, including the prompt text P_instance and the original legal document D, is input into the encoder of the pre-trained language model. Through the processing of multiple Transformer encoding blocks, the deep contextual semantic representation H_text of the text is obtained.

[0025] The retrieved knowledge subgraph G_sub is encoded using a graph neural network encoder to obtain a node representation H_graph that contains its own attributes and local topological structure information.

[0026] Furthermore, the process of injecting knowledge representation into text representation through a cross-attention mechanism to generate knowledge-enhanced representation includes:

[0027] Using the text representation H_text as the query vector and the knowledge node representation H_graph as both the key vector and value vector, the attention weight matrix is ​​calculated. Based on the attention weight matrix, the knowledge representation is weighted and summed to obtain the knowledge-enhanced representation corresponding to each position in the text sequence.

[0028] Furthermore, a multi-task loss function is used during language model training, specifically:

[0029] ,

[0030] in, Loss is generated for summarizing. For knowledge consistency / feature coverage constraint loss, To compare learning loss, , These are the weighting coefficients.

[0031] A second aspect of the present invention provides a legal case summary generation system based on knowledge-guided prompts and fine-tuning, comprising:

[0032] The knowledge base construction module is used for the structuring and vectorization of legal knowledge, including building a structured legal knowledge graph and designing a computable prompt template library containing knowledge slots;

[0033] The training module is used to dynamically retrieve relevant knowledge subgraphs from the original legal documents in the training samples and populate them into the prompt template to obtain prompt text; the concatenated prompt text, the original legal documents, and the relevant knowledge subgraphs are encoded to obtain text representation and knowledge representation respectively; the knowledge representation is injected into the text representation through a cross-attention mechanism to generate knowledge-enhanced representation; the language model is trained based on the knowledge-enhanced representation and a prompt fine-tuning strategy to obtain a trained language model;

[0034] The reasoning module is used to extract knowledge-enhanced representations of new legal documents to be summarized, and load pre-trained language model parameters and soft cue parameters to generate the final legal case summary.

[0035] A third aspect of the present invention provides a computer-readable storage medium.

[0036] A computer-readable storage medium having a computer program stored thereon that, when executed by a processor, implements the steps of the knowledge-guided prompting-based legal case summary generation method described above.

[0037] A fourth aspect of the present invention provides a computer device.

[0038] A computer device includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the steps in the knowledge-guided prompting-based legal case summary generation method described above.

[0039] Compared with the prior art, the beneficial effects of the present invention are:

[0040] 1. Unlike traditional hard-hint keyword matching, this invention deeply integrates the structured knowledge of the graph with the semantics of the text at the deep representation level of the model through graph attention encoding and cross-attention injection. It is no longer a simple keyword search, but rather a dynamic and selective absorption and association of relevant knowledge in the process of understanding the meaning of the text. This achieves a leap from "knowledge retrieval" to "knowledge understanding", thereby generating more professional and insightful summaries.

[0041] 2. Innovatively combining soft cueing technology with knowledge injection, through end-to-end training, the model not only learns to generate summaries, but also learns how to "direct" the attention mechanism to call external knowledge. The optimized soft cueing parameters become a transferable task inducer specifically for legal summarization tasks. Even when faced with rare situations not appearing in the training data, it can effectively handle them through its learned "ability to call knowledge", greatly enhancing the model's expressive power and adaptability.

[0042] 3. Through explicit definitions and relational links of "elements" and "plot points" in the knowledge graph, combined with attention injection, the model is forced to focus on these core elements crucial to legal characterization during the generation process. This algorithmically ensures that the generated summary covers key facts, and in organizing these facts, it implicitly incorporates the legal reasoning logic of "fact-elements" matching, effectively reducing factual omissions, biases, and logical fallacies, and significantly improving the legal value and reliability of the summary.

[0043] Advantages of additional aspects of the invention will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. Attached Figure Description

[0044] The accompanying drawings, which form part of this invention, are used to provide a further understanding of the invention. The illustrative embodiments of the invention and their descriptions are used to explain the invention and do not constitute an improper limitation of the invention.

[0045] Figure 1 This is a flowchart of a legal case summary generation method based on knowledge-guided prompts and fine-tuning provided in an embodiment of the present invention;

[0046] Figure 2 This is a schematic diagram of the knowledge enhancement extraction process for the fusion knowledge prompting fine-tuning training provided in the embodiments of the present invention. Detailed Implementation

[0047] The present invention will be further described below with reference to the accompanying drawings and embodiments.

[0048] It should be noted that the following detailed description is illustrative and intended to provide further explanation of the invention. Unless otherwise specified, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains.

[0049] It should be noted that the terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the scope of exemplary embodiments according to the invention. As used herein, the singular form is intended to include the plural form as well, unless the context clearly indicates otherwise. Furthermore, it should be understood that when the terms "comprising" and / or "including" are used in this specification, they indicate the presence of features, steps, operations, devices, components, and / or combinations thereof.

[0050] Example 1

[0051] like Figure 1 As shown, this embodiment provides a method for generating legal case summaries based on knowledge-guided prompts and fine-tuning, including the following steps:

[0052] Step 1: Structuring and vectorizing legal knowledge, including building a structured legal knowledge graph and designing a computable hint template library containing knowledge slots;

[0053] Step 101: Construct a structured legal knowledge graph, specifically including:

[0054] Define various node types, including entities representing specific case objects, legal concepts representing the cause of action, requirements representing the conditions necessary for the establishment of a legal concept, and details representing the circumstances of liability determination, etc.

[0055] Specifically, entities representing specific case objects can be extracted from documents through named entity recognition, such as "Company C" and "Motor Vehicle D";

[0056] The legal concept indicating the cause of action is a top-level concept in knowledge organization, mainly referring to the cause of action defined by legal departments;

[0057] These are the requirements for the establishment of a legal concept. Each requirement can be further refined into more specific elements. For example, the requirements for a case include the subject, subjective aspect, and objective aspect.

[0058] The circumstances indicating liability determination refer to the specific circumstances in a case that affect the determination of liability.

[0059] Define various types of relationship edges between nodes, including HasElement relation representing inclusion relationship, IsA relation representing dependency relationship, RelatedTo relation representing participation relationship, and Precondition relation representing precondition dependency relationship;

[0060] The HasElement relation, which represents an inclusion relationship, indicates that a legal concept contains a certain element, or that an element contains a certain sub-element.

[0061] The IsA relation, which represents a subordinate relationship, indicates that an instance belongs to a certain type, or that a specific plot belongs to a certain type of plot.

[0062] The RelatedTo relationship, which indicates a participation relationship, represents a participation relationship between an entity and a legal concept or other entities.

[0063] The Precondition relationship indicates the prerequisite relationship between requirements.

[0064] In this embodiment, the graph can be manually constructed by parsing legal provisions and typical cases, or automatically constructed from semi-structured data using information extraction technology, which can be selected according to those skilled in the art; the final graph is stored in graph databases such as Neo4j and JanusGraph, or converted to RDF format for storage.

[0065] Step 102: Design a library of computable prompt templates containing knowledge slots;

[0066] In this embodiment, the design principle of the computable prompt template library is that the templates should be able to clearly guide the model to focus on the core elements of the legal summary.

[0067] Specifically, the computable prompt template library contains at least one parameterized prompt template, which includes a

Case

Constituent Elements

Plot

[0068] Different template libraries can be designed for different tasks, and the most suitable template can be automatically selected based on the type of input document.

[0069] Step 2: Knowledge-integrated prompt fine-tuning training: For the original legal documents in the training samples, relevant knowledge subgraphs are dynamically retrieved and filled into the prompt template to obtain prompt text; a dual-path encoding structure is used to encode the concatenated prompt text, the original legal documents, and the relevant knowledge subgraphs to obtain text representation and knowledge representation; the knowledge representation is injected into the text representation through a cross-attention mechanism to generate knowledge-enhanced representation; the language model is trained based on the knowledge-enhanced representation and using a prompt fine-tuning strategy to obtain a trained language model;

[0070] like Figure 2 As shown, the specific steps include the following:

[0071] Step 201: For the original legal document D in the training sample, dynamically retrieve the relevant knowledge subgraph G_sub and fill it into the prompt template to obtain the prompt text P_instance;

[0072] In this embodiment, each sample in the training dataset includes the original legal document D and its corresponding standard summary S written by experts;

[0073] First, a lightweight model is used to initially identify key legal information from the original text D;

[0074] For example, BERT-based text classification models are used to identify the cause of action, while BiLSTM-CRF-based named entity recognition models are used to identify entities such as people, places, and property.

[0075] Then, based on the identified core information such as the "cause of action," relevant knowledge subgraphs G_sub are retrieved from the constructed legal knowledge graph; for a specific case, all its constituent elements and a list of common sentencing factors are retrieved. The retrieval process can be implemented using a graph query language (such as Cypher).

[0076] Finally, the knowledge slots of the prompt template are filled with specific knowledge instances retrieved. For example, the [cause of action], [elements of a crime], and [sentencing circumstances] are replaced with the corresponding identified content to form specific input prompt text P_instance that is highly relevant to the case.

[0077] This invention dynamically retrieves the most relevant knowledge subgraphs based on the specific case content, rather than using a fixed, massive global knowledge base. This mechanism enables the system to accurately handle cases with different causes of action and has a strong generalization ability. Whether it is a common case or a complex intellectual property dispute, it can call on the corresponding professional knowledge to handle it, avoiding the redundancy and noise interference of a static knowledge base.

[0078] Step 202: Use a dual-path encoding structure to encode the concatenated prompt text P_instance, the original legal document D, and the knowledge subgraph G_sub respectively, to obtain the text representation H_text and the knowledge representation H_graph;

[0079] Specifically, it includes:

[0080] Text encoding path: The combined text, including the prompt text P_instance and the original legal document D, is input into the encoder of the pre-trained language model. Through the processing of multiple Transformer encoding blocks, the deep contextual semantic representation H_text of the text is obtained, with the dimension of [sequence length n, hidden layer dimension d];

[0081] In this embodiment, the encoder of the pre-trained language model adopts a model with architectures such as LLaMA and ChatGLM.

[0082] Knowledge Encoding Path: The retrieved knowledge subgraph G_sub is encoded using a graph neural network encoder to obtain a node representation H_graph containing its own attributes and local topological structure information;

[0083] Preferably, a graph attention network (GAT) is used because it can distinguish the importance of neighboring nodes through an attention mechanism. GAT encodes each node in the graph to generate a node representation H_graph that contains its own attributes and local topological structure information, with dimensions of [number of nodes in the graph m, hidden layer dimension d].

[0084] Step 203: Inject the knowledge representation H_graph into the text representation H_text through a cross-attention mechanism to generate the knowledge-enhanced representation H_fused;

[0085] In this embodiment, a cross-attention layer is designed as a bridge connecting text semantics and structured knowledge, specifically including:

[0086] Using text representation H_text as the query vector (Query, Q), this means that the model actively "asks" the knowledge base at each position when generating or understanding the text. Knowledge node representation H_graph serves as both the key vector (Key, K) and value vector (Value, V). An attention weight matrix is ​​calculated, and the knowledge representations are weighted and summed based on this matrix to obtain the knowledge-enhanced representation H_fused. The key is used to calculate the similarity to the query, and the value is used to generate the final knowledge-enhanced representation.

[0087] The formula for calculating cross attention is:

[0088] ,

[0089] ,

[0090] ,

[0091] ,

[0092] in, , , d_k is a learnable linear projection matrix used to map H_text and H_graph to the same attention space; d_k is a scaling factor, typically taken from the key vector. Dimensions. This represents the output of the scaled dot product attention, meaning: first calculate and The dot product similarity is calculated, divided by √d_k, and then normalized using softmax to obtain the attention weight matrix. Finally, the attention weight matrix is ​​calculated. The output is obtained by performing a weighted summation, thereby injecting the knowledge node information most relevant to the current token into the corresponding text representation.

[0093] The computational result of this mechanism is to generate a knowledge-enhanced representation H_fused for each token in the text sequence. For example, when the model processes a fragment in the original text describing a certain behavior, the attention mechanism assigns higher weights to the knowledge nodes associated with that behavior, thereby injecting the information of those nodes into the corresponding text representation.

[0094] Step 204: Train the language model based on knowledge-enhanced representation and using a prompting fine-tuning strategy to obtain a trained language model;

[0095] In this embodiment, when training the language model using a cue fine-tuning strategy, the cue fine-tuning strategy includes using the vector identifiers corresponding to the knowledge slots in the cue template as trainable soft cue parameters. These parameters are randomly initialized at the start of training and optimized through gradient descent to update the soft cue parameters and the trainable parameters of the language model.

[0096] A multi-task loss function is used based on the summary generation results. Backpropagation is used to update the soft cue parameters and the trainable parameters of the language model using gradient descent, and this process is repeated iteratively until the stopping condition is met.

[0097] Multi-task loss function Represented as:

[0098] ,

[0099] in, Loss is generated for summarizing. For knowledge consistency / feature coverage constraint loss, To compare learning loss, , These are the weighting coefficients;

[0100] Specifically, the knowledge-enhanced representation H_fused can be input into the decoder of a pre-trained language model (for an Encoder-Decoder architecture) or used directly for generation (for a Decoder-only architecture) to generate summary text in an autoregressive manner, and the various training losses can be calculated accordingly.

[0101] Among them, the summary generation loss Standard text generation cross-entropy loss can be used, for example: ;in, For the true summary in the first i The target word at each position (or its one-hot representation). This represents the model's predicted probability at that location.

[0102] Knowledge consistency / feature coverage loss To ensure that the generated summary maintains consistency with the retrieved knowledge instances such as causes of action, constituent elements, and plot points, and covers key elements, this can be achieved through a coverage penalty for knowledge slot elements or a discriminator loss for the consistency of the "summary-knowledge subgraph"; contrastive learning loss. Representations for bringing similar case types / similar elements closer together and distancing dissimilar sample representations can be constructed using InfoNCE or supervised contrastive learning.

[0103] The criteria for determining whether training has reached its optimal state are: optimally monitoring the validation set. And task evaluation metrics (such as ROUGE, BERTScore, or legal element coverage), select the model parameters and soft cue parameters that are optimal for the validation set metrics as the final parameters; when the validation set... When the performance no longer declines or the evaluation metric stabilizes after several consecutive rounds, an early stopping strategy can be used to terminate training, thereby avoiding overfitting and ensuring optimal results from cue-based fine-tuning. Compared to full-parameter fine-tuning, cue-based fine-tuning only requires optimizing a small number of parameters (soft cues and some layers), significantly reducing training costs and resource consumption, while achieving results comparable to or even surpassing full-parameter fine-tuning. Graph encoders are also typically lighter than language models, and dual-path encoding does not impose excessive computational burden, making this approach easy to deploy in practical applications.

[0104] Step 3: Application Reasoning: For the new legal document D_new to be summarized, perform the same dynamic knowledge retrieval and dual-path encoding process as in Step 2 to obtain the corresponding knowledge-enhanced representation H_fused_new, and load the model parameters and soft hint parameters trained in Step 2 to generate the final legal case summary.

[0105] Specifically, it includes:

[0106] Step 301: For the new legal document D_new to be summarized, dynamically retrieve relevant knowledge and fill in the prompt template to obtain P_new and G_sub_new;

[0107] Step 302: P_new+D_new and G_sub_new are processed through a pre-trained dual-path encoding and attention injection module to obtain the knowledge-enhanced representation H_fused_new;

[0108] Step 303: Load the trained final model parameters, including the optimized LLM parameters and the optimized soft cue parameters, input H_fused_new into the decoder, and generate the final professional legal summary.

[0109] This embodiment significantly improves the coverage of key legal elements such as constituent elements and the rigor of reasoning logic in the abstract by using dynamic retrieval and dual-path fusion.

[0110] This embodiment verifies the effectiveness of the case summary generation method and system based on knowledge-guided prompts and fine-tuning proposed in this invention using a real legal dataset, to illustrate the performance advantages and applicability of this invention in practical applications. To this end, experimental evaluations are conducted on a publicly available criminal judgment document dataset, and the results are explained through both quantitative indicators and qualitative analysis.

[0111] In terms of experimental setup, approximately 5,000 criminal judgments from a publicly available court judgment platform were selected as the dataset. For each judgment, a human-generated or authoritative summary was used as a reference summary to evaluate the quality of the model's generated results. The experiment employed multiple evaluation metrics, including ROUGE-1, ROUGE-2, and ROUGE-L, to measure the overlap between the generated summary and the reference summary at the word and phrase levels; the BERTScore metric was used to assess the semantic similarity between the generated summary and the reference summary; the legal element coverage metric was used, with human annotation to evaluate the coverage of key legal elements such as the cause of action, constituent elements, and sentencing factors in the generated summary; and several experts with legal backgrounds were invited to subjectively rate the generated summary on a scale of 1 to 5 in terms of professionalism, logic, and readability, serving as a professionalism evaluation metric.

[0112] To demonstrate the improved effects of this invention, several comparative methods were set up in the experiment. First, a general pre-trained model without incorporating a legal knowledge graph (such as Bidirectional and Auto-Regressive Transformers, BART) was directly fine-tuned on the legal summarization task, serving as baseline one. Second, a static prompt template was simply introduced at the input without soft prompt learning, serving as baseline two. Third, a dedicated legal model pre-trained on legal corpora (LawGPT, etc.) was directly used for summary generation, serving as baseline three. Under the same training data and evaluation metrics, the performance of the method of this invention was compared with each baseline method, as shown in Table 1.

[0113] Table 1 Performance comparison of the method of this invention with various baseline methods

[0114] method ROUGE-1 ROUGE-2 ROUGE-L BERTScore Factor coverage professionalism Baseline 1 0.412 0.287 0.389 0.835 68.3% 3.2 Baseline 2 0.435 0.302 0.401 0.847 72.1% 3.5 Baseline 3 0.451 0.318 0.415 0.856 75.6% 3.8 This invention 0.487 0.356 0.443 0.882 86.4% 4.5

[0115] Experimental results show that the method of this invention outperforms the baseline methods mentioned above in both ROUGE and BERTScore metrics. Particularly in cases involving complex elements of a crime and sentencing factors, the generated summary demonstrates significantly improved coverage of key legal elements and a higher level of professionalism. From the subjective evaluation of legal experts, the summaries generated by the method of this invention perform better in terms of factual completeness, emphasis on key legal points, and logical coherence, making them more suitable for the reading habits and usage needs of legal practitioners.

[0116] As can be seen from the above experiments, the method and system described in this embodiment can significantly improve the professionalism and accuracy of legal summaries while ensuring generation efficiency. It has practical application value for improving the automation level of judicial institutions, law firms and other entities in the process of processing massive amounts of legal documents.

[0117] Example 2

[0118] This embodiment provides a legal case summary generation system based on knowledge-guided prompts and fine-tuning, including:

[0119] The knowledge base construction module is used for the structuring and vectorization of legal knowledge, including building a structured legal knowledge graph and designing a computable prompt template library containing knowledge slots;

[0120] The training module is used to dynamically retrieve relevant knowledge subgraphs from the original legal documents in the training samples and populate them into the prompt template to obtain prompt text; the concatenated prompt text, the original legal documents, and the relevant knowledge subgraphs are encoded to obtain text representation and knowledge representation respectively; the knowledge representation is injected into the text representation through a cross-attention mechanism to generate knowledge-enhanced representation; the language model is trained based on the knowledge-enhanced representation and a prompt fine-tuning strategy to obtain a trained language model;

[0121] The reasoning module is used to extract knowledge-enhanced representations of new legal documents to be summarized, and load pre-trained language model parameters and soft cue parameters to generate the final legal case summary.

[0122] It should be noted that the specific implementation of the legal case summary generation system based on knowledge-guided prompts and fine-tuning in this embodiment of the invention is similar to the specific implementation of the legal case summary generation method based on knowledge-guided prompts and fine-tuning in this embodiment of the invention. For details, please refer to the description in the method section. To reduce redundancy, it will not be repeated here.

[0123] Example 3

[0124] This embodiment provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps in the knowledge-guided prompting-based legal case summary generation method described above.

[0125] Example 4

[0126] This embodiment provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, it implements the steps in the knowledge-guided prompting-based legal case summary generation method described above.

[0127] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of hardware embodiments, software embodiments, or embodiments combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage and optical storage) containing computer-usable program code.

[0128] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0129] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0130] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0131] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. The storage medium can be a magnetic disk, optical disk, read-only memory (ROM), or random access memory (RAM), etc.

[0132] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.

Claims

1. A method for generating legal case summaries based on knowledge-guided prompts and fine-tuning, characterized in that: Includes the following steps: Step 1: Structuring and vectorizing legal knowledge, including building a structured legal knowledge graph and designing a computable hint template library containing knowledge slots; Step 2: For the original legal documents in the training samples, dynamically retrieve relevant knowledge subgraphs and populate them into the prompt template to obtain the prompt text. This includes: each sample in the training dataset contains the original legal document D and its corresponding standard summary S written by experts; a lightweight model is used to initially identify key legal information from the original document D; based on the identified key legal information, relevant knowledge subgraphs are retrieved from the constructed legal knowledge graph; knowledge instances from the retrieved relevant knowledge subgraphs are used to populate the knowledge slots in the prompt template, forming the input prompt text related to the case; a dual-path encoding structure is used to separately encode the concatenated prompt text, the original legal document, and the relevant knowledge subgraphs. The encoding process yields text and knowledge representations, including: inputting the combined text, including the prompt text P_instance and the original legal document D, into the encoder of a pre-trained language model; processing the text through multiple Transformer encoding blocks to obtain a deep contextual semantic representation H_text; encoding the retrieved knowledge subgraph G_sub using a graph neural network encoder to obtain a node representation H_graph containing its own attributes and local topological structure information; injecting the knowledge representation into the text representation through a cross-attention mechanism to generate a knowledge-enhanced representation; and training the language model based on the knowledge-enhanced representation and using a prompting fine-tuning strategy to obtain a trained language model. Step 3: Perform the same dynamic knowledge retrieval and dual-path encoding process as in Step 2, extract the knowledge-enhanced representation of the new legal document to be summarized, load the trained language model parameters and soft cue parameters, and generate the final legal case summary.

2. The legal case summary generation method based on knowledge-guided prompts and fine-tuning as described in claim 1, characterized in that, The construction of the structured legal knowledge graph specifically includes: Define multiple node types, including entities representing specific case objects, legal concepts representing the cause of action, requirements representing the conditions necessary for the establishment of a legal concept, and details representing the determination of liability; Define various relationship edge types between nodes, including HasElement (representing inclusion), IsA (representing dependency), RelatedTo (representing participation), and Precondition (representing prior dependency).

3. The legal case summary generation method based on knowledge-guided prompts and fine-tuning as described in claim 1, characterized in that, The computable prompt template library containing knowledge slots includes at least one parameterized prompt template, which includes a cause of action slot for filling in specific causes of action, a constituent element slot for filling in relevant legal constituent elements, a plot slot for filling in relevant plot elements, and a {document} placeholder for placing the original text of the legal document.

4. The legal case summary generation method based on knowledge-guided prompts and fine-tuning as described in claim 1, characterized in that, The process of injecting knowledge representation into text representation through a cross-attention mechanism to generate knowledge-enhanced representation includes: Using the text representation H_text as the query vector and the knowledge node representation H_graph as both the key vector and value vector, the attention weight matrix is ​​calculated. Based on the attention weight matrix, the knowledge representation is weighted and summed to obtain the knowledge-enhanced representation corresponding to each position in the text sequence.

5. The legal case summary generation method based on knowledge-guided prompts and fine-tuning as described in claim 1, characterized in that, The language model is trained using a multi-task loss function, specifically: , in, Loss is generated for summarizing. The knowledge consistency / element coverage constraint loss is used to constrain the generated summary against the retrieved cause of action, constituent elements, and plot, ensuring that the knowledge instances remain consistent and cover key elements. To compare learning loss, , These are the weighting coefficients.

6. A legal case summary generation system based on knowledge-guided prompts and fine-tuning, characterized in that: include: The knowledge base construction module is used for the structuring and vectorization of legal knowledge, including building a structured legal knowledge graph and designing a computable prompt template library containing knowledge slots; The training module dynamically retrieves relevant knowledge subgraphs from the original legal documents in the training samples and populates them into the prompt template to obtain prompt text. This includes: each sample in the training dataset contains the original legal document D and its corresponding standard summary S written by experts; a lightweight model is used to initially identify key legal information from the original document D; based on the identified key legal information, relevant knowledge subgraphs are retrieved from the constructed legal knowledge graph; knowledge instances from the retrieved relevant knowledge subgraphs are used to fill the knowledge slots in the prompt template, forming case-related input prompt text; a dual-path encoding structure is used to separately encode the concatenated prompt text, the original legal document, and the relevant knowledge subgraphs. Encoding is performed to obtain text representation and knowledge representation, including: inputting the combined text, including the prompt text P_instance and the original legal document D, into the encoder of a pre-trained language model; processing through multiple layers of Transformer encoding blocks to obtain a deep contextual semantic representation H_text; encoding the retrieved knowledge subgraph G_sub using a graph neural network encoder to obtain a node representation H_graph containing its own attributes and local topological structure information; injecting the knowledge representation into the text representation through a cross-attention mechanism to generate a knowledge-enhanced representation; training the language model based on the knowledge-enhanced representation and using a prompt fine-tuning strategy to obtain a trained language model. The reasoning module is used to extract the knowledge-enhanced representation of the new legal document to be summarized by the method of generating knowledge-enhanced representations from the original text of the legal documents in the training samples, and load the trained language model parameters and soft prompt parameters to generate the final legal case summary.

7. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the steps in the legal case summary generation method based on knowledge-guided prompts and fine-tuning as described in any one of claims 1-5.

8. A computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the steps in the legal case summary generation method based on knowledge-guided prompts and fine-tuning as described in any one of claims 1-5.

Citation Information

Patent Citations

  • Law text abstract generation method based on graph neural network

    CN115374270A

  • Industrial injury auxiliary identification method and system based on dual-channel retrieval enhanced generation

    CN121171540A