A knowledge embedding-based legal auxiliary case judgment model parameter adjustment method
Patent Information
- Application Number
- CN202611175798.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-04
- Publication Date
- 2026-10-23
AI Technical Summary
[0004]有鉴于此,本发明提供了一种基于知识嵌入的法律辅助判案模型参数调整方法,以解决现有技术中法律辅助模型响应速度较慢,延迟较高的问题
通过本发明提供的基于知识嵌入的法律辅助判案模型参数调整方法,通过收集原始法律判案数据生成相应的问答数据和法律知识三元组,然后基于问答数据对预设基座模型进行第一参数调整,构造第一法律模型,再将法律知识三元组对第一法律模型的注意力层进行法律知识嵌入,在固定第一法律模型参数的情况下,既保留第一法律模型的推理能力,又使得第一法律模型学会如何利用外部的法律知识,在模型推理过程中无需单独的检索步骤,实现了端到端的知识运用,显著降低了模型响应延迟。最后再对知识嵌入的第一法律模型进行强化学习,优化法律模型的输出效果,得到最终的法律辅助判案模型,提高了模型的辅助判案能力。
Smart Images

Figure CN122965688A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of model optimization technology, and in particular to a method for adjusting parameters of a legal aid judgment model based on knowledge embedding. Background Technology
[0002] Currently, legal adjudication requires adherence to strict legal logic (such as syllogistic reasoning), involving multi-dimensional argumentation including legal citation, case comparison, and evidence analysis. This process is cumbersome and demands extremely high accuracy. Legal professionals handle a large number of complex cases, needing not only to accurately match legal provisions but also to consider precedent principles and the specificities of each case. The time and mental burden of manual adjudication are significant. Traditional manual adjudication methods are no longer sufficient to meet the demands of efficient justice, necessitating the use of intelligent tools to improve both efficiency and accuracy.
[0003] Existing legal aid models generally suffer from the following problems: (1) The reasoning process cannot be transparently displayed, and only the conclusion can be output, making it difficult for legal professionals to trace the logical chain, resulting in insufficient credibility of the model; (2) It lacks flexible output adaptation capabilities and cannot generate content according to specific norms such as judicial document format and evidence analysis requirements, thus limiting its practicality; (3) In order to improve the accuracy of legal judgments, the RAG architecture is often used. However, legal knowledge is highly specialized and complex, and the number of legal provisions is huge. In complex searches, "missed detection" or "false detection" is likely to occur. Especially when the case involves cross-legal provisions or new legal issues, the relevance and comprehensiveness of the search results are difficult to guarantee. The model response speed may also be slow due to the time spent on the search, which may not meet the judge's need for quick judgment. Summary of the Invention
[0004] In view of this, the present invention provides a method for adjusting parameters of a legal aid judgment model based on knowledge embedding, in order to solve the problems of slow response speed and high latency in existing legal aid models.
[0005] The technical solution adopted in this invention is: This invention provides a method for adjusting parameters of a legal aid judgment model based on knowledge embedding, including: Obtain raw legal judgment data and preprocess the raw legal judgment data to obtain preprocessed legal judgment data; The preprocessed legal case data is hierarchically labeled to obtain case elements and case decision logic, and then the case elements and case decision logic are input into a large language model to generate question and answer data; Obtain the text of legal clauses from preprocessed legal case data and convert the text of legal clauses into structured legal knowledge triples; Based on the question-and-answer data, the first parameter of the preset base model is adjusted to construct the first legal model; The legal knowledge triples are input into the first legal model for vector transformation to obtain knowledge tags. Attention is adjusted on the first legal model based on the knowledge tags, and the first legal model is fine-tuned using question-and-answer data and knowledge tags to obtain the fine-tuned first legal model. By using question-and-answer data to train the finely tuned first legal model through reinforcement learning, a legal aid judgment model is obtained.
[0006] Furthermore, the question-and-answer data includes question data and answer data; the step of adjusting the first parameter of the preset base model based on the question-and-answer data to construct the first legal model includes: A cosine decay learning rate strategy is adopted to input the problem data into the preset base model for forward propagation, and the forward propagation output of the preset base model is obtained. Calculate the first cross-entropy loss based on the forward propagation output and the response data; The gradient of the first cross-entropy loss with respect to the preset base model parameters is calculated using the backpropagation algorithm. The preset base model parameters are then updated using the optimizer based on the gradient. The preset base model parameters are gradually adjusted to minimize the loss, thus obtaining the first legal model.
[0007] Furthermore, the first legal model includes a sentence encoder, a linear adapter, and an attention layer; the step of inputting the legal knowledge triples into the first legal model for vector transformation to obtain knowledge tags includes: The sentence encoder using the first legal model transforms each input legal knowledge triple into a continuous basic key embedding vector and a basic value embedding vector; where names and attributes are encoded as key vectors and values are encoded as value vectors. By using a linear adapter, the basic key embedding vector and the basic value embedding vector are mapped to a fixed length to construct key-value vector pairs, which are then used as knowledge tags. The dimensions of the key vector and the value vector in the key-value vector pair are the same as the dimension of the attention layer in the first legal model.
[0008] Furthermore, the attention adjustment of the first legal model based on knowledge tags includes: The attention layer of the first legal model is adjusted. When calculating the attention output, the q-value of the current input token is used to calculate the attention weights with the key-value vector pairs of other input tokens besides the current input token and the key-value vector pairs in the knowledge tags, so as to obtain the attention output that integrates context and legal knowledge.
[0009] Furthermore, the step of fine-tuning the first legal model using question-and-answer data and knowledge tags to obtain the fine-tuned first legal model includes: Using the weights of the linear adapter in the first legal model as learnable parameters, and employing a training method of instruction fine-tuning, the question data from the question-answering data is input into the attention-adjusted first legal model, and combined with knowledge tags, the model outputs the answer. The second cross-entropy loss is calculated based on the model output answer and the answer data in the question-and-answer data. Based on the second cross-entropy loss, the weights of the linear adapter are fine-tuned using the gradient descent method to obtain the fine-tuned first legal model.
[0010] Furthermore, the method of using question-and-answer data to train the fine-tuned first legal model through reinforcement learning to obtain a legal aid judgment model includes: The fine-tuned first legal model is defined as an agent, and the environment and state of the agent, as well as the agent's actions and reward functions, are defined based on the question-and-answer data. A legal question is randomly selected from the question data of the question-and-answer data, and the legal question is converted into a vector as the state input of the current environment; The agent generates a response text based on the current state input of the environment through forward propagation; The answer text is scored according to the preset reward function to obtain a reward score value, and the reward score value is used as a reward feedback signal. Based on the reward signal, the parameters of the fine-tuned first legal model are iteratively updated using a reinforcement learning algorithm until the preset model convergence condition is met, at which point the reinforcement learning training stops, and the second legal model is obtained.
[0011] Furthermore, the process of acquiring raw legal judgment data and preprocessing it to obtain preprocessed legal judgment data includes: Obtain open-source raw legal judgment data and perform noise cleaning on the raw legal judgment data; The terminology of the original legal judgment data after noise cleaning is standardized, and a category balancing strategy is used to balance the categories of the original legal judgment data to obtain preprocessed legal judgment data.
[0012] In summary, the beneficial effects of the present invention are as follows: The method for adjusting parameters of a legal aid judgment model based on knowledge embedding provided by this invention generates corresponding question-and-answer data and legal knowledge triples by collecting original legal judgment data. Then, based on the question-and-answer data, the first parameter of a preset base model is adjusted to construct a first legal model. Next, the legal knowledge triples are embedded into the attention layer of the first legal model. With fixed parameters, this method retains the reasoning ability of the first legal model while enabling it to learn how to utilize external legal knowledge. No separate retrieval step is required during model reasoning, achieving end-to-end knowledge application and significantly reducing model response latency. Finally, reinforcement learning is applied to the knowledge-embedded first legal model to optimize its output, resulting in the final legal aid judgment model, which improves the model's ability to assist in judgment. Attached Figure Description
[0013] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the embodiments of the present invention will be briefly introduced below. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort, and these are all within the protection scope of the present invention.
[0014] Figure 1 This is a flowchart of the parameter adjustment method for a knowledge-embedded legal aid judgment model according to the present invention. Detailed Implementation
[0015] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Unless otherwise specified, the present invention and the various features in the embodiments can be combined with each other, all of which are within the protection scope of the present invention.
[0016] The detailed implementation process of this invention is shown in the following embodiments.
[0017] Example 1: Refer to Figure 1 As shown, Figure 1 This is a flowchart of the parameter adjustment method for a knowledge-embedded legal aid judgment model according to the present invention. (Refer to...) Figure 1 As shown, the method of this embodiment of the invention includes: S1: Obtain the original legal judgment data and preprocess the original legal judgment data to obtain preprocessed legal judgment data; S2: Perform hierarchical annotation on the preprocessed legal case data to obtain case elements and case decision logic, and input the case elements and case decision logic into the large language model to generate question and answer data; S3: Obtain the legal clause text from the preprocessed legal judgment data and convert the legal clause text into structured legal knowledge triples; S4: Adjust the first parameter of the preset base model based on the question-and-answer data to construct the first legal model; S5: Input the legal knowledge triples into the first legal model for vector transformation to obtain knowledge tags. Adjust the attention of the first legal model based on the knowledge tags, and fine-tune the first legal model with instructions using question-and-answer data and knowledge tags to obtain the fine-tuned first legal model. S6: Use question-and-answer data to train the finely tuned first legal model through reinforcement learning to obtain a legal aid judgment model.
[0018] In this embodiment, step S1 involves acquiring the original legal judgment data and preprocessing it to obtain preprocessed legal judgment data, specifically including: Obtain open-source raw legal judgment data and perform noise cleaning on the raw legal judgment data; The terminology of the original legal judgment data after noise cleaning is standardized, and a category balancing strategy is used to balance the categories of the original legal judgment data to obtain preprocessed legal judgment data.
[0019] Specifically, in this embodiment, when acquiring open-source original legal judgment data, open-source legal judgment data is collected from case and legal databases such as China Judgments Online, People's Court Case Database, and International Legal Database. Then, the original legal judgment data is cleaned and preprocessed to remove noise information (such as duplicate cases and irrelevant text). Next, the preprocessed data undergoes terminology standardization to unify legal terminology (e.g., "XX crime" is standardized to a standard crime name). Finally, data bias is addressed through category balancing to avoid an overabundance of data from certain types of cases (such as contract disputes), which could lead to insufficient generalization ability of the model for niche cases (such as intellectual property cases).
[0020] Specifically, step S2 in this embodiment involves: judges, lawyers, and other professionals performing layered annotation on the pre-processed legal judgment data to extract judgment elements and judgment decision logic. Judgment elements include key elements such as parties involved, charges, amounts involved, and time. The judgment decision logic is derived by annotating logical relationships such as "behavior-result," "causal relationship," and "legal provision citation association" in the pre-processed legal judgment data to obtain the legal basis for application and sentencing reasons in the case judgment.
[0021] Then, Deepseek-R1-671B or other large-parameter models are adopted as the large language model, the hierarchically labeled case-adjudication elements and case-adjudication decision logic are input into the large language model to generate question-and-answer data with a specific structure. The question-and-answer data includes question data and answer data, and the design of the question-and-answer data follows the "syllogism" case-adjudication process, which specifically includes: major premise, the bill of indictment and relevant evidence; minor premise, relevant legal provisions; conclusion, the model judges whether the facts conform to the elements of the legal provisions to generate a legal conclusion.
[0022] Specifically, step S3 in this embodiment is specifically: converting the legal provision texts in the preprocessed legal case-adjudication data into structured legal knowledge triples, and each legal knowledge triple includes <entity name>, <attribute> and <value>, with an example being <xx Law>, <Article xx>, <specific content of Article xx>.
[0023] In some embodiments of the present invention, examples of the question data and the answer data in the above question-and-answer data are provided, which are specifically as follows: The example of the question data is: [Task Instruction] The user will provide you with a bill of indictment. Please analyze the content of the bill of indictment, extract the key information therein and conduct case adjudication, and output the result in JSON format.
[0024] [Processing Steps] 1. Analyze and extract the main content of the bill of indictment; 2. Find applicable legal provisions; 3. Analyze relevant evidence; 4. Render a legal judgment.
[0025] [Output Format] { "claim":<plaintiff's litigation claim>, "law":<applicable legal provision>, "evidence":<analyze the sufficiency of evidence>, "conclusion":<legal judgment>, } [Input] Current content of the bill of indictment and relevant legal provisions.
[0026] The example of the answer data is: <think>Okay, I now need to process this legal analysis task provided by the user. First, the user provided the contents of an indictment and relevant legal provisions, requesting the extraction of key information and the generation of a judgment, outputting it in JSON format. Based on the processing steps, I need to analyze it step by step.
[0027] First, there are X points in the claims section, and I need to analyze the type of each claim one by one. The first claim is XXX, which is a payment request, and the liable party is XXX. The second claim is XXX, which is also a payment request, and the liable party is also XXX. The third claim is XXX, which is a XXX, and the liable party is XXX.
[0028] Next, we need to find the applicable legal provisions. The plaintiff's claim is that their right to health has been violated, and the corresponding legal basis should be the tort liability clauses in the relevant law, such as Article XXXX regarding the obligation to ensure safety in public places. Additionally, the insurance policy mentions XXX liability insurance, which may involve clauses in the insurance contract, such as reimbursement of medical expenses according to medical insurance standards, and standards for nursing care expenses. These could constitute grounds for obstructing the plaintiff's rights.
[0029] Next, we analyze the relevant evidence. First, we examine whether the plaintiff's or defendant's evidence is sufficient, then we check whether all essential facts have been proven, filtering out irrelevant evidence. For example, is the plaintiff's rehabilitation treatment cost supported by a medical order, and how relevant is it? Furthermore, we must pay attention to the admissibility of evidence. For instance, electronic evidence requires the original medium; otherwise, it may not be admissible. If the hotel photos are forwarded, they may lack the original medium, affecting their probative value. Also, one of the plaintiff's medical receipts has a mismatched name, which may lead to its exclusion.
[0030] Finally, a judgment is reached, supporting one party. For example, if the hotel cannot sufficiently prove that ground safety measures were in place, while the plaintiff proved injury and treatment, then the plaintiff's case may be supported. Whether the insurance company needs to pay compensation depends on the insurance terms and whether the hotel's liability is established.
[0031] These analyses now need to be compiled into JSON format to ensure that each point of contention corresponds to the correct evidence and analysis, and that the conclusions are logically sound. This may require multiple checks to ensure no evidence is missing, the analysis is thorough, and the conclusions are reasonable.
[0032] < / think> ```json { "claim": "Claim 1, Claim 2", "law": Article xxxx of the "xxx" law. "evidence":<1. The plaintiff's inpatient medical records (E1), medical bills (E2), and diagnosis (E3) objectively prove the medical facts arising from the fall and are admissible.\n 2. The defendant's submitted photos of the incident site (E4) cannot directly prove the ground condition at the time of the incident because the original carrier was not provided; therefore, their admissibility is questionable.>, Conclusion: The plaintiff has preliminarily proven that the damage was related to site safety. The defendant failed to provide sufficient evidence that it had fully fulfilled its safety management obligations (e.g., it failed to provide valid evidence of the ground condition at the time of the incident). Therefore, the first defendant is found to be negligent. The damage falls within the scope of public liability insurance, but compensation will be determined according to the contract terms. } ] In this embodiment, step S4, which involves adjusting the first parameter of the preset base model based on question-and-answer data to construct the first legal model, specifically includes the following steps: S41: A cosine decay learning rate strategy is employed. Problem data is input into a pre-defined base model for forward propagation, yielding the forward propagation output of the pre-defined base model. The pre-defined base model is selected based on the computational resources and performance requirements of the application scenario. Available open-source models include DeepSeek, Qwen, and LLaMA. For lightweight scenarios, Qwen-7B or DeepSeek-7B can be selected, and LoRA technology can be used to reduce fine-tuning parameters; for high-performance scenarios, large models such as LLaMA-2-70B can be used, combined with PEFT technology to reduce training costs.
[0033] Specifically, the cosine decay learning rate strategy includes setting the initial learning rate to 5e - 5 (using the 7B model as an example), warming up with the first 10% of steps; setting a higher learning rate (e.g., 1e - 4) for the knowledge embedding layer and output layer; setting the batch size to 16; and a total of 3-5 training rounds. Problem data is then fed into the model for forward propagation to obtain the model's forward propagation output.
[0034] S42: Calculate the first cross-entropy loss based on the forward propagation output and the response data.
[0035] S43: Calculate the gradient of the first cross-entropy loss with respect to the preset base model parameters using the backpropagation algorithm. Use an optimizer (such as AdamW) to update the preset base model parameters based on the gradient. Gradually adjust the preset base model parameters to minimize the loss and obtain the first legal model.
[0036] In this embodiment, the first legal model includes a sentence encoder, a linear adapter, and an attention layer; in step S5, the legal knowledge triples are input into the first legal model for vector transformation to obtain knowledge tags, including: The sentence encoder using the first legal model transforms each input legal knowledge triple into a continuous base key embedding vector and a base value embedding vector; where names and attributes are encoded as key vectors (i.e., k), and values are encoded as value vectors, providing the actual content (i.e., v).
[0037] By using a linear adapter, the basic key embedding vector and the basic value embedding vector are mapped to a fixed length (i.e., mapped to the key-value embedding space of the first legal model) to construct key-value vector pairs, which are then used as knowledge tags. The dimensions of the key vector and the value vector in the key-value vector pair are the same as the dimension of the attention layer of the first legal model, which facilitates the embedding of legal knowledge.
[0038] In this embodiment, after the knowledge tags are constructed, they can be augmented into the attention of the first legal model in a scalable and dynamic manner. The specific process of adjusting the attention of the first legal model based on the knowledge tags is as follows: The attention layer of the first legal model is adjusted by calculating the attention weights of the q-value of the current input token, the key-value vector pairs of other input tokens besides the current input token, and the key-value vector pairs in the knowledge tags, to obtain an attention output that integrates context and legal knowledge.
[0039] Specifically, when calculating the attention output, not only the input tokens are considered, but also the calculations of all knowledge tags. That is, the q-value of the input token is calculated not only with the k / v values of other input tokens, but also with the k / v values of the knowledge tags. The core calculation in the attention layer is accomplished through three vectors: Query (Q), Key (K), and Value (V), essentially calculating the "association strength between input tokens." This embodiment introduces the interaction of knowledge tags during the attention calculation process. The core is to expand the sources of K and V; that is, in addition to the original input token's k / v, the knowledge tag's k / v is also added. This allows the model's attention layer output to integrate information from the input context and external knowledge. When generating answers, the model can more accurately combine external knowledge such as legal provisions and cases, rather than relying solely on the information in the input text itself.
[0040] In this embodiment, step S5 uses question-and-answer data and knowledge tags to fine-tune the first legal model, resulting in a fine-tuned first legal model, including: Using the weights of the linear adapter in the first legal model as learnable parameters, and employing a training method of instruction fine-tuning, the question data from the question-answering data is input into the attention-adjusted first legal model, and combined with knowledge tags, the model outputs the answer. The second cross-entropy loss is calculated based on the model's output answer and the answer data in the question-and-answer data. Then, based on this second cross-entropy loss, the weights of the linear adapter are fine-tuned using gradient descent to obtain the fine-tuned first legal model. By fixing the parameters of the first legal model, its reasoning ability is preserved, while also allowing the model to learn how to utilize external knowledge.
[0041] In this embodiment, by directly embedding legal knowledge into the attention layer of the first legal model, no separate retrieval step is required during the reasoning process, achieving end-to-end knowledge application, significantly reducing latency, greatly simplifying the process, realizing a closer integration of knowledge and reasoning, and breaking through the limitation of model context length.
[0042] At the same time, the model has extremely high scalability, and legal knowledge can be easily updated, deleted or added as needed. The computational complexity (memory and time) increases linearly with the number of triples.
[0043] In this embodiment, step S6 uses question-and-answer data to perform reinforcement learning training on the fine-tuned first legal model to obtain a legal aid judgment model, including but not limited to the following sub-steps: S61: Define the fine-tuned first legal model as an agent, and define the agent's environment and state, as well as the agent's actions and reward functions, based on the question-and-answer data.
[0044] Specifically, this embodiment uses a reinforcement learning algorithm to perform reinforcement learning on the fine-tuned first legal model. The core elements of the reinforcement learning algorithm are defined as follows: The agent, or fine-tuned first legal model, aims to generate answers based on input legal questions. The environment includes the problem dataset, the calculation logic of the reward function, and the rules for the interaction between the model and the data; State represents the environmental information currently faced by the agent. In this scenario, it includes: the text content of the input legal question, the model's previous answers (if there are multiple rounds of interaction), and possible contextual information (such as the type of question, relevant legal provisions, etc.). Action: The decision output of the agent, i.e., the text of the model's response to a legal question; The reward function, a key evaluation metric, is used to quantify the quality of the model's responses and needs to be designed in accordance with the characteristics of the legal field.
[0045] S62: Randomly select a legal question from the question data of the question-answering data, and convert the legal question into a vector as the state input of the current environment.
[0046] S63: The agent generates a response text based on the current state input of the environment through forward propagation.
[0047] S64: Based on the preset reward function, score the answer text to obtain the reward score value, and use the reward score value as a reward feedback signal to guide the model optimization strategy.
[0048] S65: Based on the reward signal, use a reinforcement learning algorithm to iteratively update the fine-tuned parameters of the first legal model until the preset model convergence condition is met, then stop the reinforcement learning training to obtain the second legal model.
[0049] Among these, reinforcement learning algorithms such as PPO, DDPG, and Q-Learning can be used. There are three preset model convergence conditions. During reinforcement learning training and parameter optimization, satisfying any one of these three conditions is sufficient. The specific preset model convergence conditions are as follows: (1) The model's average reward on the problem dataset no longer improves significantly; (2) The legal accuracy and relevance of the answers reach the preset threshold; (3) The number of training rounds reaches the upper limit (e.g., 100,000 iterations).
[0050] Specifically, the reward function designed in this embodiment includes format rewards and content rewards. Format rewards include whether the thought process is output and whether it is output in the prescribed JSON format. Content rewards include whether the thought process is detailed, whether the litigation claims are extracted without omission, whether the legal provisions are selected appropriately, whether the evidence is sufficiently analyzed, whether the final judgment is reasonable, whether there are any loopholes in the argumentation process, whether the reasoning conforms to legal logic, and whether the expression is professional, concise, and unambiguous.
[0051] This embodiment enhances the logical reasoning and structured output capabilities of the legal model by performing supervised fine-tuning (SFT) and reinforcement learning on the model, thereby improving the model's ability to assist in case adjudication.
[0052] This embodiment collects professional data through multiple channels, generates question-and-answer pairs and legal knowledge triples from the collected data to support subsequent model parameter adjustments; trains a base model based on the question-and-answer pairs to obtain a first legal model; performs knowledge embedding based on the legal knowledge triples; and adjusts the model based on reinforcement learning and knowledge embedding to obtain a second legal model, namely a legal aid judgment model, which can greatly reduce latency while enhancing model performance and achieving efficient assistance in legal judgment.
[0053] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for adjusting parameters in a legal aid judgment model based on knowledge embedding, characterized in that, include: Obtain raw legal judgment data and preprocess the raw legal judgment data to obtain preprocessed legal judgment data; The preprocessed legal case data is hierarchically labeled to obtain case elements and case decision logic, and then the case elements and case decision logic are input into a large language model to generate question and answer data; Obtain the text of legal clauses from preprocessed legal case data and convert the text of legal clauses into structured legal knowledge triples; Based on the question-and-answer data, the first parameter of the preset base model is adjusted to construct the first legal model; The legal knowledge triples are input into the first legal model for vector transformation to obtain knowledge tags. Attention is adjusted on the first legal model based on the knowledge tags, and the first legal model is fine-tuned using question-and-answer data and knowledge tags to obtain the fine-tuned first legal model. By using question-and-answer data to train the finely tuned first legal model through reinforcement learning, a legal aid judgment model is obtained.
2. The parameter adjustment method for a legal aid judgment model based on knowledge embedding according to claim 1, characterized in that, The question-and-answer data includes question data and answer data; The step of adjusting the first parameter of the preset base model based on question-and-answer data to construct the first legal model includes: A cosine decay learning rate strategy is adopted to input the problem data into the preset base model for forward propagation, and the forward propagation output of the preset base model is obtained. Calculate the first cross-entropy loss based on the forward propagation output and the response data; The gradient of the first cross-entropy loss with respect to the preset base model parameters is calculated using the backpropagation algorithm. The preset base model parameters are then updated using the optimizer based on the gradient. The preset base model parameters are gradually adjusted to minimize the loss, thus obtaining the first legal model.
3. The parameter adjustment method for a legal aid judgment model based on knowledge embedding according to claim 1, characterized in that, The first legal model includes a sentence encoder, a linear adapter, and an attention layer; The step of inputting the legal knowledge triples into the first legal model for vector transformation to obtain knowledge tags includes: The sentence encoder using the first legal model transforms each input legal knowledge triple into a continuous basic key embedding vector and a basic value embedding vector; where names and attributes are encoded as key vectors and values are encoded as value vectors. By using a linear adapter, the basic key embedding vector and the basic value embedding vector are mapped to a fixed length to construct key-value vector pairs, which are then used as knowledge tags. The dimensions of the key vector and the value vector in the key-value vector pair are the same as the dimension of the attention layer in the first legal model.
4. The parameter adjustment method for a legal aid judgment model based on knowledge embedding according to claim 1, characterized in that, The attention adjustment of the first legal model based on knowledge tags includes: The attention layer of the first legal model is adjusted. When calculating the attention output, the q-value of the current input token is used to calculate the attention weights with the key-value vector pairs of other input tokens besides the current input token and the key-value vector pairs in the knowledge tags, so as to obtain the attention output that integrates context and legal knowledge.
5. The parameter adjustment method for a legal aid judgment model based on knowledge embedding according to claim 1, characterized in that, The step of fine-tuning the first legal model using question-and-answer data and knowledge tags to obtain the fine-tuned first legal model includes: Using the weights of the linear adapter in the first legal model as learnable parameters, and employing a training method of instruction fine-tuning, the question data from the question-answering data is input into the attention-adjusted first legal model, and combined with knowledge tags, the model outputs the answer. The second cross-entropy loss is calculated based on the model output answer and the answer data in the question-and-answer data. Based on the second cross-entropy loss, the weights of the linear adapter are fine-tuned using the gradient descent method to obtain the fine-tuned first legal model.
6. The parameter adjustment method for a legal aid judgment model based on knowledge embedding according to claim 1, characterized in that, The method of using question-and-answer data to train the finely tuned first legal model through reinforcement learning to obtain a legal aid judgment model includes: The fine-tuned first legal model is defined as an agent, and the environment and state of the agent, as well as the agent's actions and reward functions, are defined based on the question-and-answer data. A legal question is randomly selected from the question data of the question-and-answer data, and the legal question is converted into a vector as the state input of the current environment; The agent generates a response text based on the current state input of the environment through forward propagation; The answer text is scored according to the preset reward function to obtain a reward score value, and the reward score value is used as a reward feedback signal. Based on the reward signal, the parameters of the fine-tuned first legal model are iteratively updated using a reinforcement learning algorithm until the preset model convergence condition is met, at which point the reinforcement learning training stops, and the second legal model is obtained.
7. The parameter adjustment method for a legal aid judgment model based on knowledge embedding according to claim 1, characterized in that, The process of acquiring raw legal judgment data and preprocessing it to obtain preprocessed legal judgment data includes: Obtain open-source raw legal judgment data and perform noise cleaning on the raw legal judgment data; The terminology of the original legal judgment data after noise cleaning is standardized, and a category balancing strategy is used to balance the categories of the original legal judgment data to obtain preprocessed legal judgment data.