Large law model fine tuning data screening method, equipment and medium

By constructing preference data sets and dependency tree analysis, high-quality legal fine-tuning data sets are screened, which solves the problems of low efficiency and high cost of data screening in the existing technology, and realizes efficient and low-cost legal big model training.

CN120408192APending Publication Date: 2025-08-01CHINA UNIV OF MINING & TECH

Patent Information

Application Number
CN202510475633.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-16
Publication Date
2025-08-01

AI Technical Summary

Technical Problem

During the training process, the data quality of existing legal models has a significant impact on the model's answer effect. How to efficiently screen out high-quality data has become an urgent problem to be solved. The existing methods are costly, have high computing power requirements, and the training process is uncontrollable.

Method used

By generating high-quality and low-quality Q&A datasets, building preference datasets and introducing balanced focus loss functions, using the legal quality scoring model to score and complexity analysis of candidate data, building dependency trees and performing cluster analysis, and filtering out the final fine-tuned dataset.

Benefits of technology

It significantly improves the analysis accuracy and efficiency of legal fine-tuning data sets, reduces training costs, and improves the generalization ability and instruction tracking ability of the model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120408192A_ABST
    Figure CN120408192A_ABST
Patent Text Reader

Abstract

The invention relates to a large law model fine tuning data screening method and device and a medium, and belongs to the technical field of artificial intelligence. Generating and forming a preference data set, training a legal quality scoring model by using the preference data set, and dynamically adjusting weights of a simple compliance sample and a complex dispute sample by using a balance focus loss function; performing quality scoring on the candidate law fine tuning data set, calculating a complexity score of the candidate law fine tuning data set, and generating a quality-complexity scoring data set of the candidate law fine tuning data set; and constructing a dependency tree of a grammar dependency relationship, performing clustering analysis on vectorized dependency tree features, and performing cluster division and sorting on candidate law fine adjustment data sets so as to merge the candidate law fine adjustment data sets into final fine adjustment sub-data sets and complete screening. The problems of semantic distortion and training deviation caused by a traditional screening method are effectively solved, and a systematic solution is provided for efficient training of a large model in the legal vertical field.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to a method, device and medium for screening fine-tuning data of a legal large model, belonging to the technical field of artificial intelligence. Background Art

[0002] Currently, the work of LegalAI in the field of law mainly focuses on completing specific tasks by constructing datasets and presenting machine learning algorithms. Although they have shown some impressive results, this method limits the wider application of intelligent legal systems. The latest progress in large language models (LLMs) has demonstrated extraordinary instruction-following capabilities in different fields, offering great potential for the legal sector. Some preliminary progress has been made in using legal knowledge to answer simple questions by fine-tuning general large models. However, the problems involved in the legal field are much more complex, and the quality of data is crucial for the answering effect of the model. How to screen high-quality data has become an urgent problem to be solved.

[0003] The prior art with the publication number CN1168,225,91A discloses a method for answering legal consultations and a method for training a generative large model in the legal field, belonging to the technical field of natural language processing. The method includes: pre-training a preset generative large model based on unstructured legal text data and general Chinese data to obtain a first fine-tuned large model; performing low-rank matrix incremental weight training on the first fine-tuned large model based on an instruction dataset pre-constructed for each legal sub-field to obtain a second fine-tuned large model corresponding to the legal sub-field; constructing a reward model according to a pre-constructed scoring and ranking dataset and the second fine-tuned large model; using the second fine-tuned large model as an agent and the reward model as an environment to perform reinforcement learning training on the second fine-tuned large model to obtain a generative large model in the legal field. However, the training cost of this large model is high, the computing power requirement is high, and the training fitting process is uncontrollable.

[0004] The prior art with the publication number CN1171,311,73A discloses a phased training method for a legal dialogue large model, including the following steps: determining the training data used in different stages and performing data preprocessing; using a phased training method to improve the corpus quality and professionalism of the model's answers; introducing a legal article retrieval module to generate evidence-supported answers; however, its reply results are relatively rigid, can only make simple adaptive adjustments according to legal articles and case precedents, cannot match the diversity of human language, and there are many problems in understanding legal issues. Summary of the Invention

[0005] Objective of the Invention: Aiming at the deficiencies of the prior art, a method, device and medium for screening fine-tuning data of a legal large model are provided, which can efficiently screen out a data subset helpful for training from a large number of candidate legal fine-tuning data sets. Through this method, the accuracy and efficiency of legal fine-tuning data set analysis can be significantly improved, while ensuring the model output effect, greatly reducing the computing power overhead brought by training.

[0006] To achieve the above technical objectives, a method for screening fine-tuning data of a legal large model according to the present invention is as follows:

[0007] Generate a high-quality Q&A data set and a low-quality Q&A data set respectively using the same legal question set;

[0008] Combine the low-quality Q&A data set and the high-quality Q&A data set to form a preference data set, and use the preference data set to train a legal quality scoring model. During the training process, introduce a balanced focal loss function to dynamically adjust the weights of simple compliance samples and complex dispute samples;

[0009] Use the legal quality scoring model to score the quality of the candidate legal fine-tuning data set, calculate the complexity score of the candidate legal fine-tuning data set, and generate a quality-complexity scoring data set of the candidate legal fine-tuning data set;

[0010] Concatenate the question and answer of each sample instance in the candidate legal fine-tuning data set into a complete sentence, and construct a dependency tree of the syntactic dependency relationship for the concatenated sentence;

[0011] Extract the lexical units in the sample instance as the nodes of the dependency tree, and label the part-of-speech tags, connecting the relational words with the subjects they dominate;

[0012] Extract features from the dependency tree to generate a feature representation of the dependency tree, and map the dependency tree to a high-dimensional vector space for vectorization;

[0013] Perform clustering analysis on the vectorized dependency tree features. By clustering and sorting the candidate legal fine-tuning data set, it is merged into a final fine-tuning sub-data set to complete the screening.

[0014] Furthermore, the high-quality Q&A data set is generated by obtaining high-quality Q&A of different legal consultation categories from the network and the judgment document database, and each Q&A data is arranged in the form of (x i , y i + ), where x i represents the prompt, and y i + represents the high-quality reply; the low-quality Q&A data set is obtained by inputting the questions into GPT trained with legal knowledge, and each Q&A data is in the form of (x i , yi - ) in the form of , where y i - Indicates low-quality responses.

[0015] Furthermore, let the GPT model trained with legal knowledge be LawGPT, and use LawGPT to train a high-quality question-answering dataset (x i ,y i + ) in the prompt x i Generate low-quality response y i - Afterwards, a preference dataset in the form of triples is formed N represents the total number of preference datasets; the preference dataset is used for reward training to obtain the legal quality scoring model Law-reward, and the balanced focus loss function L used in the reward training process is BFL It is expressed as follows:

[0016] L BFL =(1-β|2P i -1| η )log(P i )

[0017] Where β and η are hyperparameters, set to 0.5 and 2 respectively; P i =σ(r θ (x i ,y i + )-r θ (x i ,y i - )), r θ (x i ,y i - ) indicates that x will be prompted i and low-quality responses i - The quality score obtained by sending it to Law-reward, σ is the sigmoid function.

[0018] Furthermore, let the candidate legal fine-tuning dataset to be screened be T = {T1, T2, ..., T N}, where the sample instance is represented by T i ; Use the legal quality scoring model Law-reward to score the sample instances in the candidate legal fine-tuning data to obtain the quality score Each sample instance T i Contains question Q i and the corresponding answer A i, normalize the quality scores of each sample instance in T:

[0019]

[0020] S min is the minimum quality score in the legal fine-tuning dataset T, S max for the highest quality score in the legal fine-tuning dataset T, Represents the sample instance T i Normalized quality score;

[0021] Calculate each sample instance in question Q i The perplexity PPL(A i |Q i ) is used to measure the complexity of the sample instance:

[0022]

[0023] Where M is the answer A i The length of A i,j Indicates answer A i The jth character of ;

[0024] PPL(A i |Q i ) divided by the sample instance in the absence of question Q i The perplexity PPL(A i ), and get the complexity score Complexity(A i |Q i ):

[0025]

[0026] Among them, PPL(A i |Q i ) and PPL(A i ) represent the presence and absence of instruction Q i the degree of confusion in existence;

[0027] Each sample instance T in the final candidate legal fine-tuning dataset T i Quality-complexity score The calculation formula is as follows:

[0028]

[0029] Furthermore, the instruction Q of each sample instance Ti in the candidate legal fine-tuning dataset T is i and reply A i After splicing, the sentence format is "Q i ,Ai ”; perform dependency syntactic analysis on the concatenated sentence to generate a dependency tree Z i ;

[0030] Convert the dependency tree Z i into a graph structure G i =(V i , E i ), where the node v i ∈V i represents the lexical unit in the sample instance, and the initial vector representation of the node is the initial part-of-speech of the legal term. The edge (v i , v k )∈E i represents the relationship between nodes. The generated graph set is represented as {G1, G2,..., G n};

[0031] Extract features from the generated graph set. By iteratively calculating the local structure information of the nodes, the vector representation of the nodes will be continuously updated according to the information of their neighbor nodes; iterate 2 times, and update the vector representation of the node according to its neighbor node set N(v i ):

[0032]

[0033] where represents the label of the node v i in the t-th round of iteration, and N(v i ) is the neighbor node set of the node v i . || means to concatenate the vector representation i of the node v itself with the vector representations j of all neighbor nodes v ∈N(v). Among them, hash is a hash function used to map the concatenated vector to a fixed-length space;

[0034] After iteration, each node has a high-dimensional vector representation Finally, the vector representation of the graph structure G i of the sample instance is obtained by summarizing the vector representations of all nodes:

[0035]

[0036] Use clustering to maintain the syntactic structure diversity of the filtered subset for the vector representation of each sample instance. Given the number of clusters k, where n is the total amount of data in T; Let C j represent the j-th cluster, and calculate the cluster center c j :

[0037]

[0038] Ψ i is the vector representation of the i-th sample instance in the j-th cluster, |C j | is the number of sample instances in cluster C j .

[0039] Objective function of clustering:

[0040]

[0041] where ||Ψ i - c j || 2 is the square of the Euclidean distance between the i-th sample instance vector and the cluster center point. Finally, within each cluster, using the LQC score, the legal fine-tuning data is sorted, and the top n1 texts with the highest LQC scores are selected and merged into the final fine-tuning sub-dataset, with the number being kn1.

[0042] A computer device, including a processor and a memory, the processor is electrically connected to the memory, the memory is used to store instructions and data, and the processor is used to execute the legal large model fine-tuning data screening method.

[0043] A computer-readable storage medium, in which a computer program is stored, and this computer program is adapted to be loaded and executed by a processor to execute the legal large model fine-tuning data screening method.

[0044] Beneficial effects: The present invention focuses on solving the problem of instruction selection in the supervised fine-tuning stage of the legal large model, and proposes an innovative legal fine-tuning data screening method. A fine-tuning data scoring index is proposed, which combines the IFD score with the score obtained by the reward model, and this index evaluates the data more precisely. In addition, by constructing a dependency tree of syntactic dependencies and performing clustering analysis on the vectorized dependency tree features, we ensure that the diversity of the data is effectively maintained. A significant advantage of this method is that even when using a small amount of data for training, it can achieve or even exceed the performance of the model trained using the complete dataset. This not only significantly improves the generalization ability of the model, but also greatly reduces the training cost, achieving a dual optimization of efficiency and effect. Description of the Drawings

[0045] Figure 1 is a schematic flow chart of the legal large model fine-tuning data screening method of the present invention;

[0046] Figure 2 is a schematic diagram of the performance comparison between the present method and the prior art in the embodiments of the present invention. Detailed Embodiments

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

[0048] As Figure 1 shown, the present invention discloses a method for screening fine-tuning data of a legal large model. First, legal experts carefully select at least 8,000 high-quality question-and-answer pairs from multiple legal consultation categories. Then, the open-source large language model LAWGPT in the legal field is selected to generate low-quality responses to the selected prompts as comparison samples. After data filtering, a clear and training-beneficial preference data set is screened out, and a reward scoring model is obtained through training. The reward scoring model is used to score the candidate legal fine-tuning data set, and the data with a score below 0 is screened out to obtain a preliminarily filtered legal fine-tuning data set. After normalizing the reward score, the final legal evaluation score LES is obtained by multiplying it with the instruction-following difficulty index. The sentence-transformers model is used to map the legal fine-tuning data after obtaining the LES score to a high-dimensional dense vector space, the PCA technology is used to reduce the dimension of the high-dimensional vector, and finally K-means is used for clustering to obtain the final fine-tuning sub-data set.

[0049] Specifically, it includes the following steps:

[0050] Step 1: Generate a high-quality question-and-answer data set and a low-quality question-and-answer data set respectively using the same legal question set; the high-quality question-and-answer data set is generated by obtaining high-quality question-and-answer pairs of different legal consultation categories from the network and the judgment document database, and each question-and-answer data is arranged in the form of (x i , y i + ), where x i represents the prompt, and y i + represents the high-quality response; the low-quality question-and-answer data set is obtained by inputting the questions into GPT trained with legal knowledge, and each question-and-answer data is arranged in the form of (x i , y i - ), where y i - represents the low-quality response.

[0051] Step 2: Combine the low-quality question-and-answer data set and the high-quality question-and-answer data set to form a preference data set, and use the preference data set to train a legal quality scoring model. During the training process, a balanced focal loss function is introduced to dynamically adjust the weights of simple compliance samples and complex dispute samples; let the GPT model trained with legal knowledge be LawGPT, and use LawGPT to process the prompts x i in the high-quality question-and-answer data set (x i + ), y iGenerate low-quality response y i - After that, a preference dataset in the form of triple expressions is formed N represents the total number of preference datasets; the legal quality scoring model Law-reward is obtained by using the preference dataset for reward training, and the balanced focal loss function L used in the reward training process BFL is expressed as follows:

[0052] L BFL =(1 - β|2P i - 1| η )log(P i )

[0053] In the formula, β and η are hyperparameters, set to 0.5 and 2; P i =σ(r θ (x i , y i + ) - r θ (x i , y i - ))), r θ (x i , y i - ) represents the quality score obtained by feeding the prompt x i and the low-quality response y i - into Law-reward, and σ is the sigmoid function.

[0054] The number of preference datasets is 5674. Finally, the general dataset is mixed in a ratio of 1:7, and the reward model comprehensive training data is composed as shown in Table 1:

[0055] Table 1 Comprehensive preference dataset distribution

[0056]

[0057]

[0058] Step 3: Use the legal quality scoring model to score the quality of the candidate legal fine-tuning dataset, calculate the complexity score of the candidate legal fine-tuning dataset, and generate the quality-complexity scoring dataset of the candidate legal fine-tuning dataset; let the candidate legal fine-tuning dataset T to be screened = {T1, T2,..., T N}), where the sample instance is represented as T i ; use the legal quality scoring model Law-reward to score the sample instances in the candidate legal fine-tuning data to obtain the quality score Among them, each sample instance T i contains the question Q i and the corresponding answer A i , and the quality scores of each sample instance in T are normalized as follows:

[0059]

[0060] S min is the lowest quality score in the legal fine-tuning dataset T, and S max is the highest quality score in the legal fine-tuning dataset T. represents the normalized quality score of the sample instance T i ;

[0061] Calculate the perplexity PPL(A i |Q i |Q i ) of each sample instance in the presence of the question Q to measure the complexity of the sample instance:

[0062]

[0063] where M is the length of the answer A i , and A i,j represents the j-th character of the answer A i ;

[0064] Divide PPL(A i |Q i ) by the perplexity PPL(A i ) of the sample instance in the absence of the question Q to obtain the complexity score Complexity(A i |Q i |Q i ) of the final sample instance:

[0065]

[0066] where PPL(A i |Q i ) and PPL(A i ) represent the perplexities in the presence and absence of the instruction Q i respectively;

[0067] The quality-complexity scores of each sample instance T i in the final candidate legal fine-tuning dataset T are calculated as follows:

[0068]

[0069] Step 4: Concatenate the question and answer of each sample instance in the candidate legal fine-tuning dataset into a complete sentence, and construct a dependency tree of the grammatical dependencies for the concatenated sentence; for each sample instance T in the candidate legal fine-tuning dataset T i 's instruction Q i and the reply A i are concatenated, and the format of the concatenated sentence is "Q i ,A i "; perform dependency syntactic analysis on the concatenated sentence to generate a dependency tree Z i .

[0070] Step 5: Extract the lexical units in the sample instance as the nodes of the dependency tree, annotate the part-of-speech tags, and connect the relational words with their governed subjects; convert the dependency tree Z i into a graph structure G i =(V i ,E i ), where the node v i ∈V i represents the lexical units in the sample instance, and the initial vector representation of the node is the initial part-of-speech of the legal term. The edge (v i ,v k )∈E i represents the relationship between the nodes. The generated set of graphs is represented as {G1,G2,...,G n}.

[0071] Step 6: Extract features from the dependency tree to generate a feature representation of the dependency tree, and map the dependency tree to a high-dimensional vector space for vectorization; extract features from the generated set of graphs, and through iterative calculation of the local structure information of the nodes, the vector representation of the nodes will be continuously updated according to the information of its neighbor nodes; iterate 2 times, and update the vector representation of the nodes according to its neighbor node set N(v i ):

[0072]

[0073] where represents the label of the node v i in the t-th iteration, and N(v i ) is the neighbor node set of the node v i . || represents concatenating the vector representation i of the node v with the vector representations j of all neighbor nodes v ∈N(v). Among them, hash is a hash function used to map the concatenated vector to a fixed-length space;

[0074] After iteration, each node has a high-dimensional vector representation The graph structure G of the final sample instance i The vector representation of is obtained by aggregating the vector representations of all nodes:

[0075]

[0076] Step 7: Perform clustering analysis on the vectorized dependency tree features. By performing cluster partitioning and sorting on the candidate legal fine-tuning data set, it is merged into the final fine-tuning sub-data set to complete the screening. The vector representation of each sample instance is clustered to maintain the syntactic structure diversity of the screening subset. Given the number of clusters k, where n is the total amount of data in T; Let C j represent the j-th cluster, and calculate the cluster center c j :

[0077]

[0078] Ψ i is the vector representation of the i-th sample instance in the j-th cluster, and |C j | is the number of sample instances in the cluster C j .

[0079] The objective function of clustering:

[0080]

[0081] where ||Ψ i -c j || 2 is the square of the Euclidean distance between the i-th sample instance vector and the cluster center point. Finally, within each cluster, using the LQC score, the legal fine-tuning data is sorted, and the top n1 texts with the highest LQC score are selected and merged into the final fine-tuning sub-data set, with a quantity of kn1.

[0082] A computer device, including a processor and a memory, the processor is electrically connected to the memory, the memory is used to store instructions and data, and the processor is used to execute the legal large model fine-tuning data screening method.

[0083] A computer-readable storage medium, in which a computer program is stored, and this computer program is suitable for being loaded and executed by a processor to execute the legal large model fine-tuning data screening method.

[0084] To evaluate the performance of this method, four different test datasets were utilized, including DISC-Law-EvalBenchmark, LAIW, LawBench, and the self-built test set Self-built. These datasets contain 173, 179, 250, and 220 legal consultation questions respectively. In terms of training details, this method uses Qwen2.5 with 7B parameters as the original LLM for fine-tuning. A learning rate of 2e-5, a warm-up ratio of 0.03, a weight decay of 0.0, and 3 training epochs were maintained in different fine-tuning data. During the evaluation process, gpt-3.5-turbo was called to score the responses of the two compared models, with the scoring range from 1 to 10. At the same time, to eliminate the influence of position bias on judgment, the order of the responses of the two models was changed. The winning criteria are as follows:

[0085] Win: The model scores higher in both comparisons, or wins once and ties in the other comparison.

[0086] Tie: If the model has the same score in both comparisons or has a higher score in one comparison and a lower score in the other comparison.

[0087] Lose: If the model scores lower in both comparisons, or scores lower in one comparison and ties in the other comparison.

[0088] As Figure 2 shown, it compares the response effects of the model trained using 7% of the dataset screened by this method with the dataset obtained from training on the complete dataset. In the four test datasets, this method achieved better results than training on the complete data. The performance of this method was particularly prominent in the LawBench test set. Considering that the complexity of the test questions in LawBench may be relatively high, and this method takes into account the logical responses of the data during data screening, thus performing well in such questions. The results show that the legal fine-tuning data screening method proposed in this paper is effective, and a small amount of high-quality legal fine-tuning data can also enable large models to have a more powerful instruction following ability.

[0089] At the same time, to compare the performance differences between this method and existing methods, three types of win rates mentioned in the CAR method were used here: WS, WR, QS. All other methods involved in the comparative experiment were compared with the model trained on the complete data, and the three types of win rate indicators were calculated respectively on the above four test sets. The calculation methods of the three win rate indicators are as follows:

[0090]

[0091] Where # represents the quantity.

[0092] The experimental results are shown in the following table:

[0093] Table 2 Comparison of Experimental Results between the Proposed Method and Comparative Methods

[0094]

[0095] The data subsets selected by each method in the table are all 7% of the entire dataset. The various comparative methods in the table are introduced as follows:

[0096] random: Randomly select a 7% subset of the candidate dataset.

[0097] CAR: A method for screening instruction data through expert model ranking and diversity clustering.

[0098] Internlm2-reward: Replace the legal reward scoring module in the proposed method with a general reward model, and keep other steps unchanged.

[0099] Superfiltering: Use a small model to screen the instruction following ability index and introduce diversity preservation.

[0100] According to the experimental results, the proposed method can show superiority in the three key indicators of WS, WR, and QS, mainly due to the full consideration of the particularity and complexity of legal responses in its design. By constructing a legal preference dataset, the proposed method can effectively train a reward model that can accurately evaluate the quality of legal responses, enabling the proposed method to more precisely capture the core value of the data when screening legal fine-tuning data. At the same time, construct a dependency tree of syntactic dependencies, perform clustering analysis on the vectorized dependency tree features, and maintain the diversity of the dataset, thereby improving the efficiency and effectiveness of legal fine-tuning data screening.

Claims

1. A method for screening fine-tuning data of a legal large model, characterized in that The steps are as follows Generate a high-quality Q&A dataset and a low-quality Q&A dataset respectively using the same legal question set; Combine the low-quality Q&A dataset and the high-quality Q&A dataset to form a preference dataset, and use the preference dataset to train a legal quality scoring model. During the training process, introduce a balanced focal loss function to dynamically adjust the weights of simple compliance samples and complex dispute samples; Use the legal quality scoring model to score the quality of the candidate legal fine-tuning dataset, calculate the complexity score of the candidate legal fine-tuning dataset, and generate a quality-complexity scoring dataset for the candidate legal fine-tuning dataset; Concatenate the questions and answers of each sample instance in the candidate legal fine-tuning dataset into a complete sentence, and construct a dependency tree of the syntactic dependency relationship for the concatenated sentence; Extract the lexical units in the sample instance as the nodes of the dependency tree, and label the part-of-speech tags, connecting the relational words with their dominated subjects; Extract features from the dependency tree to generate a feature representation of the dependency tree, and map the dependency tree to a high-dimensional vector space for vectorization; Perform clustering analysis on the vectorized dependency tree features. By clustering and sorting the candidate legal fine-tuning dataset, it is merged into a final fine-tuning sub-dataset to complete the screening.

2. The method for screening fine-tuning data of a legal large model according to claim 1, wherein The high-quality Q&A dataset is generated by obtaining high-quality Q&As for different legal consultation categories from the network and the judgment document repository. Each Q&A data is arranged in the form of (x i , y i + ), where x i represents the prompt, and y i + represents the high-quality response; the low-quality Q&A dataset is obtained by inputting the questions into GPT trained with legal knowledge. Each Q&A data is arranged in the form of (x i , y i - ), where y i - represents the low-quality response.

3. The method for screening fine-tuning data of a legal large model according to claim 2, wherein Let the GPT model trained with legal knowledge be LawGPT. Use LawGPT to generate low-quality responses y i for the prompts x i + in the high-quality Q&A dataset (x i , y i - ). After that, form a preference dataset in the form of triple expressions N represents the total number of the preference dataset; use the preference dataset for reward training to obtain the legal quality scoring model Law-reward. The balanced focal loss function L BFL used in the reward training process is expressed as follows: L BFL = (1 - β|2P i - 1| η )log(P i ) where β and η are hyperparameters, set to 0.5 and 2; P i = σ(r θ (x i , y i + ) - r θ (x i , y i - ))), r θ (x i , y i - ) represents the quality score obtained by feeding the prompt x i and the low-quality response y i - into Law-reward, and σ is the sigmoid function.

4. The method for screening fine-tuning data of a legal large model according to claim 3, wherein: Let the candidate legal fine-tuning dataset T to be screened be T = {T1, T2,..., T N}, where the sample instance is represented as T i ; Use the legal quality scoring model Law-reward to score the sample instances in the candidate legal fine-tuning data to obtain the quality scores Among them, each sample instance T i contains the question Q i and the corresponding answer A i , and normalize the quality scores of each sample instance in T: S min is the lowest quality score in the legal fine-tuning dataset T, S max is the highest quality score in the legal fine-tuning dataset T, represents the sample instance T i The quality score after normalization; Calculate the perplexity PPL(A of each sample instance in the presence of question Q i |Q i to measure the complexity of the sample instance: i ) where M is the length of answer A i , A i,j represents the j-th character of answer A i ; Divide the perplexity PPL(A i |Q i ) by the perplexity PPL(A i ) of the sample instance in the absence of problem Q i ) to obtain the complexity score Complexity(A i |Q i ) of the final sample instance: where PPL(A i |Q i ) and PPL(A i ) represent the perplexity with and without the presence of the instruction Q i respectively; Each sample instance T in the final candidate legal fine-tuning dataset T i quality-complexity score The calculation formula is as follows:

5. The method for screening legal large model fine-tuning data according to claim 1, characterized in that For each sample instance T in the candidate legal fine-tuning dataset T i 's instruction Q i and response A i are concatenated, and the format of the concatenated sentence is "Q i ,A i "; Dependency syntactic analysis is performed on the concatenated sentence to generate a dependency tree Z i ; Convert the dependency tree Z i into a graph structure G i =(V i , E i ), where the node v i ∈V i represents the lexical unit in the sample instance, and the initial vector representation of the node is the initial part of speech of the legal term. The edge (v i , v k ) ∈ E i represents the relationship between nodes; the generated set of graphs is represented as {G1, G2,..., G n}; Feature extraction is performed on the generated graph set. By iteratively calculating the local structural information of nodes, the vector representation of a node is continuously updated according to the information of its neighbor nodes. Iterate 2 times, and update the vector representation of the node according to its neighbor node set N(v i ) in Represents node v i The label of the tth iteration, N(v i ) is the node v i The set of neighbor nodes of node v; || means to set node v i Self-vector representation With all neighbor nodes v j Vector representation of ∈N(v) Connect; hash is a hash function used to map the connected vectors to a fixed length space; After iteration, each node has a high-dimensional vector representation The graph structure G of the final sample instance i The vector representation is obtained by aggregating the vector representations of all nodes: The vector representation of each sample instance is clustered to maintain the syntactic structure diversity of the filtered subset. Given the number of clusters k, where n is the total amount of data in T; Let C j represent the j-th cluster, and calculate the cluster center c j : Ψ i is the vector representation of the i-th sample instance of the j-th cluster, and |C j | is the number of sample instances in the cluster C j ; The objective function of clustering: where ||Ψ i -c j || 2 is the square of the Euclidean distance between the i-th sample instance vector and the cluster center point; finally, within each cluster, using the LQC score, the legal fine-tuning data is sorted, and the top n1 texts with the highest LQC scores are selected and merged into the final fine-tuning sub-dataset, with a quantity of kn1.

6. A computer device, characterized in that, It includes a processor and a memory. The processor is electrically connected to the memory. The memory is used to store instructions and data, and the processor is used to execute the method for screening legal large model fine-tuning data according to any one of claims 1-5.

7. A computer-readable storage medium, characterized in that, A computer program is stored in the computer-readable storage medium, and this computer program is suitable for being loaded and executed by the processor to execute the method for screening legal large model fine-tuning data according to any one of claims 1-5.

Citation Information

Patent Citations

  • Legal consultation reply method and legal field generative large model training method

    CN116822591A

  • Staged training method for large legal dialogue model

    CN117131173A

Cited By

  • Progressive training method for field large model in combination with data difficulty and ratio

    CN121303256A

  • Multi-dimensional preference alignment method and system based on clustering and adaptive quantile

    CN121683937A

  • Metal mine dispatching large model fine-tuning data screening method and device and storage medium

    CN122432657A