Legal thinking chain data construction method and device and program product

By constructing a legal thinking chain dataset that includes detailed intermediate reasoning steps and using reasoning models to generate and screen high-quality thinking chain data, the problems of simple form and poor scalability of existing legal datasets are solved, the data form is enriched and in-depth reasoning is achieved, and the application effect of the model in the legal field is improved.

CN120632054AInactive Publication Date: 2025-09-12HUA DATA TECH (SHANGHAI) CO LTD

Patent Information

Application Number
CN202511120333.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-08-11
Publication Date
2025-09-12
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Existing legal datasets are simple in form, lack deep reasoning capabilities, have limited data volume and poor scalability, making it difficult to support models in conducting complex legal logic analysis.

Method used

By constructing a legal thought chain dataset (CoT dataset), which contains questions, standard answers and detailed intermediate reasoning steps, a reasoning model is used to generate thought chains, and through regular matching and large models to classify erroneous thought chains, guiding and rewritten thought chains are generated, and finally high-quality thought chain data is integrated and screened out.

Benefits of technology

It achieves data enrichment and deep reasoning, expands the data volume and improves scalability, integrates specific logical models in the legal field, and improves the application effect of the model in the legal field.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120632054A_ABST
    Figure CN120632054A_ABST
Patent Text Reader

Abstract

The invention provides a legal thinking chain data construction method and device and a program product, and relates to the technical field of natural language processing. The legal thinking chain data construction method comprises the following steps: collecting question and answer data in a legal field; using an inference model to generate question and answer data with a thinking chain, and dividing the question and answer data into a correct thinking chain and a wrong thinking chain; for the wrong thinking chain, regenerating a thinking chain matched with the analysis process to obtain an instructive thinking chain; extracting part of the correct thinking chain, and rewriting according to legal logic to obtain a rewritten thinking chain; and integrating and screening the instructive thinking chain, the correct thinking chain and the rewritten thinking chain to obtain a high-quality thinking chain data set. According to the method, thinking chain data meeting requirements can be automatically generated according to thinking rule constraints in the legal field, and data support with higher quality, depth and expansibility is provided for model training and application in the legal field.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of natural language processing technology, and in particular to a method, device and program product for constructing legal thinking chain data. Background Art

[0002] In recent years, the field of artificial intelligence has made rapid progress, especially in the area of ​​mathematics and code, where large language models have seen significant improvements in their reasoning capabilities. These models, trained on large datasets, are able to learn complex patterns and logical relationships, enabling them to excel in a variety of tasks. However, the model's reasoning capabilities are closely tied to the domain datasets used. Different domains require specific datasets to support model learning and optimization.

[0003] In the legal field, existing datasets mainly come from public data sources such as judicial examinations and case databases. These existing datasets have the following significant shortcomings:

[0004] (1) Simple data format: Most of the data are in the form of simple question-answer pairs, which lack the representation of the logic and reasoning process behind the questions. This cannot effectively support the model's deep reasoning and complex logical analysis, limiting the model's application scope and performance.

[0005] (2) Lack of deep reasoning: It focuses only on simple retrieval and matching of legal knowledge and cannot provide sufficient information to support the model's deep reasoning, as well as the multi-step logical analysis and application of complex legal concepts involved in dealing with complex legal issues.

[0006] (3) Limited data volume and lack of scalability: Due to the limitations of manual data cleaning methods, existing legal data sets are often limited in number, and data containing deep reasoning and complex legal thinking is even scarcer. At the same time, it is difficult to ensure the consistency and accuracy of the data; these data sets are difficult to provide sufficient support when facing complex legal issues, and cannot adapt to the ever-evolving needs of the legal field.

[0007] Therefore, there is an urgent need to build a high-quality dataset specifically for the legal field to support the model's deep reasoning and complex logical analysis. This dataset should contain a rich legal thought process—the series of logical reasoning and knowledge application processes that legal professionals follow when solving legal problems. This will provide the model with more comprehensive and in-depth legal knowledge, enabling it to learn structured reasoning methods consistent with legal logic. Summary of the Invention

[0008] To address the shortcomings of existing technologies, this paper proposes a method, device, and program product for constructing legal thought chain data. These methods focus on constructing and optimizing legal thought chain data through natural language processing technology to improve the accuracy and efficiency of legal problem-solving. By constructing legal thought chain data, this paper enables structured representation and reasoning of legal knowledge, providing a foundation for improving reasoning performance in downstream legal applications.

[0009] In the Chain-of-Thought dataset described in this invention, namely the CoT (Chain-of-Thought) dataset, each sample in the dataset contains not only the question and the final answer, but also detailed intermediate reasoning steps.

[0010] In a first aspect, the present invention provides a method for constructing legal thinking chain data, comprising the following steps:

[0011] Collect question-and-answer data in the legal field, including questions, standard answers, and analysis processes;

[0012] Use the reasoning model to reason based on the question, obtain the corresponding reasoning answer and thought chain, and thus generate question-answer data with thought chain;

[0013] Based on the inference answers and standard answers, regular matching or large models are used to classify question and answer data with thought chains into correct thought chains and incorrect thought chains;

[0014] Processing the erroneous thinking chain to generate a guiding thinking chain, specifically by using a reasoning model to generate a thinking chain that matches the parsing process, and then updating the erroneous thinking chain to generate a guiding thinking chain;

[0015] Rewrite and optimize the correct thinking chain to generate a rewritten thinking chain. The specific method is: extract part of the correct thinking chain, use the instruction-following class model, rewrite it according to the legal logic, and obtain the rewritten thinking chain;

[0016] The guiding thinking chains, correct thinking chains, and rewritten thinking chains are integrated and screened to obtain a high-quality thinking chain data set.

[0017] As a further improvement of the present invention, the source of the question and answer data includes the DISC-Law-SFT database released by the Data Intelligence and Social Computing Laboratory of Fudan University (FudanDISC).

[0018] As a further improvement of the present invention, the reasoning model selects the Deepseek R1 model, and the instruction following model selects the Deepseek V3 model.

[0019] As a further improvement of the present invention, the method for generating a guiding thought chain further includes: discarding a thought chain that directly quotes a standard answer to ensure that the guiding thought chain is natural and reasonable.

[0020] As a further improvement of the present invention, the legal logic includes: element-by-element analysis rules and legal provisions correct citation rules; wherein,

[0021] The rules for correctly citing legal provisions further include: correctly citing the legal name, correctly citing the provision number, and correctly citing the content of the legal provision.

[0022] As a further improvement of the present invention, the question-answer data is specifically multiple-choice question data, and the elements are options of the multiple-choice questions.

[0023] As a further improvement of the present invention, the screening indicators include: logical consistency, whether the analysis is performed element by element, whether the legal provisions are correctly cited, the correlation between the thought chain and the instructions, and the consistency between the thought process and the text.

[0024] As a further improvement of the present invention, the screening method is manual inspection.

[0025] In a second aspect, the present invention provides a computer device comprising a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the steps of the method described in the first aspect.

[0026] In a third aspect, the present invention provides a computer program product, which implements the steps of the method described in the first aspect when the computer program is executed by a processor.

[0027] This invention provides an automated data processing method. This method can automatically generate qualified thought chain data based on the thought rules and constraints of the legal field, integrating specific logical patterns into the thought chain, and providing higher-quality, more in-depth, and more scalable data support for model training and application in the legal field. Specifically, the technical effects of this invention include:

[0028] It achieves data enrichment and deep reasoning: transforming from a simple question-answer format to thought chain data containing complex logic and multi-step reasoning, better simulating the thinking process of legal professionals and enabling the model to learn deep reasoning capabilities.

[0029] Data volume expansion and scalability improvement: Breaking through the limitations of manual data cleaning, a large amount of thought chain data is generated through automated methods to meet the data volume demand in the legal field. It also has good scalability and can continuously update and expand the data set as legal practice develops.

[0030] Integration of domain-specific logical models: Effectively integrate specific thinking rules and logical models in the legal field into the thinking chain data, so that the generated data is not only sufficient in quantity but also high in quality, and can truly reflect the characteristics and requirements of legal reasoning, thereby improving the application effect of the model in the legal field. BRIEF DESCRIPTION OF THE DRAWINGS

[0031] Figure 1 This is a flow chart of a legal thinking chain data construction method disclosed in the present invention. DETAILED DESCRIPTION

[0032] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the present invention will provide a clear and complete description of the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments, wherein steps S1, S2... in the embodiments described in the present invention do not limit the only execution steps of the present invention; the various models, simulation environments, and software described in the present invention are not the only way to limit the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.

[0033] In the present invention, a computer device / equipment / system refers to a computer-related entity, such as hardware, a combination of hardware and software, software, or software in execution. Specifically, for example, software includes, but is not limited to, a process running on a processor, a processor, an object, executable software, an execution thread, a program, and / or a computer. Furthermore, an application or script running on a server, or a server, can also be software. One or more software programs can be in an execution process and / or thread, and software can be localized on a single computer and / or distributed between two or more computers, and can be executed from various computer-readable media.

[0034] It should be noted that, unless there is any conflict, the embodiments and features in the embodiments of this application can be combined with each other.

[0035] In the first aspect, the present invention provides an embodiment of a method for constructing legal thinking chain data, such as Figure 1 As shown, the specific process can be as follows:

[0036] S1: Generate question-answering data with thought chains;

[0037] S11: Collect question-answering data;

[0038] The collected question-and-answer data is from the legal professional field. The data needs to include questions, standard answers, and the analysis process of obtaining standard answers from questions.

[0039] In one embodiment of the present invention, question-answering data is collected from the DISC-Law-SFT database published by the Data Intelligence and Social Computing Laboratory of Fudan University (FudanDISC).

[0040] S12: Use the reasoning model to reason based on the questions in the question-and-answer data to obtain the corresponding reasoning answers and thought chains; thereby generating question-and-answer data with thought chains.

[0041] Preferably, the reasoning model uses the Deepseek R1 model.

[0042] This step is used to enrich the data in the form of simple question and answer and improve the representation of deep reasoning.

[0043] S2: Classify question-answer data with thought chains;

[0044] Regular matching or large models are used to check the question-and-answer data with thought chains generated by the reasoning model, and the data are divided into correct thought chains and incorrect thought chains based on correct and incorrect answers.

[0045] This step is used to ensure that the data processed subsequently has a certain degree of accuracy and reliability, and to improve the quality of the entire data set.

[0046] S3: Process the incorrect thinking chain and generate a guiding thinking chain;

[0047] The specific steps include:

[0048] S31: Using the parsing process in the question-answering data as a reference, the reasoning model is required to generate a thinking process that matches the parsing process, regenerate the thinking chain, and update the incorrect thinking chain;

[0049] S32: Discard the thought chain that directly quotes the standard answer during the thinking process to ensure that the generated thought chain is more natural and reasonable.

[0050] This step is used to convert data that the model answers incorrectly into valuable learning resources, improve data usage, enhance the model's knowledge capabilities, and improve model performance.

[0051] S4: Rewrite and optimize the correct thinking chain to generate a rewritten thinking chain;

[0052] For the correct thinking chain, extract a part of it, use the instruction-following class model, rewrite it according to the specific legal logic, and obtain the rewritten thinking chain;

[0053] Preferably, the instruction compliance class model uses the Deepseek V3 model.

[0054] Preferably, the rewriting rules include: specifying a legal thinking model to rewrite the thought chain according to the element-by-element analysis rules and the correct citation rules of legal provisions. The elements refer to the elements contained in the question content; in the case of multiple-choice questions, the elements refer to the options in the question.

[0055] Preferably, the rules for correctly citing legal provisions include: correctly citing the legal name, correctly citing the provision number, correctly citing the content of the legal provision, and other rules.

[0056] This step is used to further optimize the correct chain of thinking, making it more consistent with the logical model of the legal field, the way of thinking of legal professionals, and improving the model's reasoning ability in the legal field.

[0057] S5: Integrate and filter multiple chains of thought;

[0058] S51: Integrate the correct thinking chain, rewritten thinking chain and guiding thinking chain;

[0059] S52: Screen the integrated thought chain data to obtain a high-quality CoT dataset, i.e., a high-quality thought chain dataset;

[0060] Screening indicators include: logical consistency, whether the analysis is done element by element, whether the legal provisions are correctly quoted, the relevance of the thinking chain and instructions, the consistency of the thinking process and the text, etc.

[0061] Among them, the correlation between thinking chain and instructions refers to the degree of matching between the thinking chain generated in each step and the corresponding instructions in that step, that is, the evaluation of the execution effect of the instructions in that step; the consistency between thinking process and text refers to the consistency between the thinking process in the thinking chain and the question text in the question and answer data, including the consistency between the text quoted in the thinking process and the question text.

[0062] Preferably, the screening method is: using a manual inspection method to retain high-quality data in proportion.

[0063] This step is used to ensure that the thought chain data finally generated is not only sufficient in quantity but also of high quality, and can truly reflect the characteristics and requirements of legal reasoning.

[0064] In a second aspect, the present invention provides an embodiment of a computer device, comprising a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the steps of the method described in the first aspect.

[0065] In a third aspect, the present invention provides an embodiment of a computer program product, which implements the steps of the method described in the first aspect when executed by a processor.

Claims

1. A method for constructing legal thinking chain data, characterized in that: The following steps are involved: Collect question-and-answer data in the legal field, including questions, standard answers, and analysis processes; Use the reasoning model to reason based on the question, obtain the corresponding reasoning answer and thought chain, and thus generate question-answer data with thought chain; Based on the inference answers and standard answers, regular matching or large models are used to classify question and answer data with thought chains into correct thought chains and incorrect thought chains; Processing the erroneous thinking chain to generate a guiding thinking chain, specifically by using a reasoning model to generate a thinking chain that matches the parsing process, and then updating the erroneous thinking chain to generate a guiding thinking chain; Rewrite and optimize the correct thinking chain to generate a rewritten thinking chain. The specific method is: extract part of the correct thinking chain, use the instruction-following class model, rewrite it according to the legal logic, and obtain the rewritten thinking chain; The guiding thinking chains, correct thinking chains, and rewritten thinking chains are integrated and screened to obtain a high-quality thinking chain data set.

2. The method according to claim 1, characterized in that The sources of the question and answer data include the DISC-Law-SFT database released by the Data Intelligence and Social Computing Laboratory of Fudan University.

3. The method according to claim 1, characterized in that The reasoning model uses the Deepseek R1 model, and the instruction-following model uses the Deepseek V3 model.

4. The method according to claim 1, wherein The method for generating a guiding thought chain further includes: discarding a thought chain that directly quotes a standard answer to ensure that the guiding thought chain is natural and reasonable.

5. The method according to claim 1, wherein The legal logic includes: element-by-element analysis rules and correct citation rules of legal provisions; The rules for correctly citing legal provisions further include: correctly citing the legal name, correctly citing the provision number, and correctly citing the content of the legal provision.

6. The method according to claim 5, characterized in that The question-and-answer data is specifically multiple-choice question data, and the elements are options of the multiple-choice questions.

7. The method according to claim 1 or 6, characterized in that The screening indicators include: logical consistency, whether the analysis is performed element by element, whether the legal provisions are correctly cited, the relevance of the thinking chain and instructions, and the consistency of the thinking process and the text.

8. The method according to claim 7, characterized in that The screening method is manual inspection.

9. A computer device comprising a memory, a processor, and a computer program stored in the memory, wherein: The processor executes the computer program to implement the steps of the method according to any one of claims 1 to 8.

10. A computer program product, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 8 are implemented.

Citation Information

Patent Citations

  • Complex problem processing method and device, equipment and medium

    CN116737912A

  • Generation method and device of thinking chain expansion data based on large language model

    CN117217202A

  • Metadata feature and thinking chain-based multi-table associated large language model question and answer method

    CN118245591A

  • Knowledge distillation method, device, equipment, storage medium and computer program product

    CN119005176A

  • Method and device for multi-stage generation of medical image question and answer thinking chain data

    CN120317386A

Cited By

  • Multi-round retrieval reasoning thinking chain data generation method and program product

    CN121094149A

  • Large model thinking chain knowledge distillation method and system based on anti-fact reasoning

    CN121365743A