Legal Document Generation Method, System, Electronic Device and Storage Medium

The use of intelligent agents to structure and execute legal document generation tasks addresses inefficiencies and errors in existing methods, enhancing the speed and accuracy of legal document creation with transparent and reliable results.

CN120087345BActive Publication Date: 2025-07-15SHANGHAI FARILUAN INTELLIGENT TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510527766.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-04-25
Publication Date
2025-07-15
Estimated Expiration
2045-04-25

AI Technical Summary

Technical Problem

The prior art is inefficient, difficult to guarantee quality in the generation of factor-based legal documents, and lacks transparency and interpretability, especially in complex legal cases, which are prone to problems of error and logical incoherence.

Method used

The multi-agent Agent system is adopted to form a task chain through key information extraction, task disassembly and dependency analysis, and multiple agents perform subtasks in parallel or serially to generate factor-based legal documents, and provide task monitoring and exception handling mechanisms.

Benefits of technology

It improves the efficiency and quality of legal documents generation, ensures the interpretability and accuracy of the generated results, reduces manual intervention and errors, and meets legal requirements.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120087345B_ABST
    Figure CN120087345B_ABST
Patent Text Reader

Abstract

This application relates to the field of artificial intelligence technology, and specifically provides a legal document generation method, system, electronic device, and storage medium, aiming to solve the problems of improving the generation efficiency, quality, and interpretability of element-based legal documents. The method provided by this application includes obtaining case information and case demands; using a first intelligent agent to extract key information from the case information; determining demand tasks according to the case demands; decomposing the demand tasks into multiple subtasks, and determining the execution order of the multiple subtasks according to the dependency relationships between the multiple subtasks; forming a task chain by linking the multiple subtasks according to the execution order; using a second intelligent agent and executing the subtasks in the task chain according to the key information and legal information to obtain task results; filling in information in the template of the element-based legal document according to the task results and key information to generate an element-based legal document. Through the above method, the generation efficiency, quality, and interpretability of element-based legal documents can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of artificial intelligence technology, and particularly relates to a method, system, electronic device, and storage medium for generating legal documents. Background Art

[0002] Element-based legal documents (including complaints and responses) are a type of tabular legal documents. When generating or creating element-based legal documents, it is necessary to extract the information required for element-based legal documents from multi-source heterogeneous data (such as documents, images, videos, etc.), and then fill in this information into the template file of the element-based legal document to obtain the element-based legal document.

[0003] Currently, the methods for generating element-based legal documents mainly include manual extraction and filling methods, rule matching methods, and methods of automatically generating based on general large models / fine-tuned large models.

[0004] 1. Regarding the manual extraction and filling method. This method mainly involves the user manually extracting information from multi-source heterogeneous data and manually filling this information into the template file of the legal document. Therefore, this method is time-consuming and laborious, and prone to errors. Especially when the number of legal cases is large and / or complex, it is difficult to ensure the acquisition efficiency and quality of legal documents.

[0005] 2. Regarding the rule matching method. This method mainly involves pre-defining some rules / templates, using these rules / templates to extract information from multi-source heterogeneous data, that is, obtaining information that meets the rules / templates, and then filling in this information into the template file of the element-based legal document. Although this method is relatively simple and intuitive, it is rather mechanical and difficult to apply to the diverse expressions of the same information in different materials. For example, the same information may be expressed differently in different documents, and the corresponding rule / template only covers one of the expressions. Then, when using this rule / template to extract information from each document, it may not be possible to accurately extract this information from each document. In addition, it is difficult for rules / templates to cover all situations, and they need to be updated and maintained frequently.

[0006] 3. Regarding the method of automatically generating based on fine-tuned large models.

[0007] Methods for fine-tuning large language models usually fine-tune (or train the model) a general large language model in the form of question-and-answer pairs with the case details and application conclusions of legal cases. Although this method can improve the performance of general large language models to a certain extent, there are also obvious limitations: (1) The intermediate steps are uncontrollable: Traditional fine-tuning mainly focuses on the direct mapping relationship between the input and output, ignoring the intermediate reasoning steps. This "black box" training method makes the model lack transparency and interpretability when dealing with complex tasks. (2) The quality is uncontrollable: Due to the lack of control over the intermediate steps, the model may produce logically incoherent or unrealistic results when generating outputs. Especially in the field of law where high requirements are placed on logic and accuracy, this uncontrollability may lead to serious problems. (3) Knowing what but not why: Although the model trained by traditional fine-tuning can generate results, it cannot clearly explain its reasoning process. Such a model lacking transparency is difficult to gain the trust of users in practical applications, especially in scenarios where the basis for decision-making needs to be explained.

[0008] Correspondingly, a new technical solution is needed in this field to solve the above problems. Summary of the Invention

[0009] In order to overcome the above defects, this application is proposed to solve or at least partially solve the following technical problems: how to improve the generation efficiency and quality of element-based legal documents and make the generation process of element-based legal documents interpretable.

[0010] In a first aspect, a method for generating legal documents is provided, and the method includes:

[0011] Obtain the case information and case claims of the case to be processed;

[0012] Use a first intelligent agent (Agent) to extract key information from the case information to obtain the key information in the case information;

[0013] Determine the claim task of the case to be processed according to the case claims;

[0014] Decompose the claim task into multiple subtasks, analyze the dependency relationship between the multiple subtasks, and determine the execution order of the multiple subtasks according to the dependency relationship;

[0015] Link the multiple subtasks according to the execution order of the multiple subtasks to form a task chain corresponding to the claim task;

[0016] Use a second intelligent agent (Agent) and execute each subtask in the task chain according to the key information and the preset legal information to obtain the task result of the claim task;

[0017] According to the task results and the key information, fill in the information in the template of the element-based legal document, and generate the element-based legal document of the case to be processed according to the template with the information filled in.

[0018] In a technical solution of the above legal document generation method, the case information includes multiple types of sub-information, there are multiple first intelligent agents Agent, and the multiple first intelligent agents Agent respectively correspond to multiple information types one by one. Using the first intelligent agent Agent to extract key information from the case information to obtain the key information in the case information includes:

[0019] For each type of sub-information in the case information, obtain the first intelligent agent Agent corresponding to the type of the sub-information, and use the first intelligent agent Agent to extract key information from the sub-information to obtain the key information in the sub-information.

[0020] In a technical solution of the above legal document generation method, analyzing the dependency relationship between the multiple subtasks includes: if the input of the first subtask includes the output of the second subtask, then the first subtask depends on the second subtask; otherwise, the first subtask does not depend on the second subtask;

[0021] Wherein, the first subtask and the second subtask are both any one of the multiple subtasks, and the first subtask is different from the second subtask.

[0022] In a technical solution of the above legal document generation method, determining the execution order of the multiple subtasks according to the dependency relationship includes:

[0023] If the first subtask depends on the second subtask, then the execution order of the second subtask takes precedence over the execution order of the first subtask;

[0024] Wherein, the first subtask and the second subtask are both any one of the multiple subtasks, and the first subtask is different from the second subtask.

[0025] In a technical solution of the above legal document generation method, determining the execution order of the multiple subtasks according to the dependency relationship includes:

[0026] Successively take each of the multiple subtasks as the current subtask, and determine the degree of dependence of the current subtask according to the dependence relationship between the current subtask and other subtasks; if the current subtask depends on other subtasks and is also depended on by other subtasks, then the degree of dependence is the highest; if the current subtask depends on other subtasks or is depended on by other subtasks, then the degree of dependence is the second highest; if the current subtask does not depend on other subtasks and is not depended on by other subtasks, then the degree of dependence is the lowest;

[0027] Determine the priority of the current subtask according to the degree of dependence, and the priority is positively correlated with the degree of dependence;

[0028] Arrange the execution order of the multiple subtasks in descending order of the priority; if, when arranging, the priority of the first subtask is higher than or equal to the priority of the second subtask, but the first subtask depends on the second subtask, then make the execution order of the second subtask prior to the execution order of the first subtask;

[0029] Wherein, the first subtask and the second subtask are both any one of the multiple subtasks, and the first subtask is different from the second subtask.

[0030] In a technical solution of the above legal document generation method, there are multiple second intelligent agents Agent. Adopt the second intelligent agent Agent, and execute each subtask in the task chain according to the key information and the preset legal information to obtain the task result of the claim task, including:

[0031] Determine the task type of each subtask in the task chain according to the dependence relationship between the multiple subtasks; if the current subtask in the task chain does not depend on other subtasks, then the task type of the current subtask is a parallel task; otherwise, the task type of the current subtask is a serial task; the current subtask is any one subtask in the task chain, and the other subtasks are the remaining subtasks in the task chain except the current subtask;

[0032] When there are multiple parallel tasks in the task chain, adopt multiple second intelligent agents Agent to respectively and parallelly execute each parallel task in the multiple parallel tasks.

[0033] In a technical solution of the above legal document generation method, the method further includes performing task monitoring in the following manner:

[0034] Monitor the execution status of each subtask in the task chain;

[0035] If it is detected that an exception occurs during the execution of the current subtask in the task chain, obtain an exception handling mechanism corresponding to the type of the exception, use the exception handling mechanism to handle the current subtask, and suspend the execution of the target subtask, where the current subtask is any subtask in the task chain, and the target subtask is other subtasks in the task chain that are executed after the current subtask;

[0036] If it is detected that the execution of the current subtask fails, re-execute the current subtask.

[0037] In a technical solution of the above legal document generation method, the disassembling of the claim task into multiple subtasks includes:

[0038] Based on the claim task and the first to the i-th subtasks, predict multiple (i + 1)-th subtasks, where i ≥ 2, and the first subtask is predicted based on the claim task; wherein the input of the (i + 1)-th subtask includes the output of the i-th subtask.

[0039] In a technical solution of the above legal document generation method, the predicting of multiple (i + 1)-th subtasks based on the claim task and the first to the i-th subtasks includes: obtaining the task characteristics of the claim task and the first to the i-th subtasks; using the function call mechanism of the large language model, and predicting at least one of the multiple (i + 1)-th subtasks according to the task characteristics;

[0040] And / or, the predicting of multiple (i + 1)-th subtasks based on the claim task and the first to the i-th subtasks includes: obtaining the text description information of the claim task and the first to the i-th subtasks; inputting the text description information into the large language model for processing, and predicting at least one of the multiple (i + 1)-th subtasks;

[0041] And / or,

[0042] The predicting of multiple (i + 1)-th subtasks based on the claim task and the first to the i-th subtasks includes: obtaining target legal information related to the claim task from a preset legal knowledge base, where the legal knowledge base is used to store legal information, and the legal information includes legal provisions and cases; based on the target legal information, and according to the claim task and the first to the i-th subtasks, predicting at least one of the multiple (i + 1)-th subtasks.

[0043] In a second aspect, a legal document generation system is provided, and the system includes an information input module, a perception module, a planning module, and a document generation module;

[0044] The information input module is configured to: obtain the case information and case demands of the case to be processed;

[0045] The perception module is configured to: use the first intelligent agent to extract key information from the case information to obtain the key information in the case information;

[0046] The planning module is configured to: determine the demand tasks of the case to be processed according to the case demands; decompose the demand tasks into multiple subtasks, analyze the dependency relationships between the multiple subtasks, and determine the execution order of the multiple subtasks according to the dependency relationships; link the multiple subtasks according to the execution order of the multiple subtasks to form a task chain corresponding to the demand tasks; use the second intelligent agent and execute each subtask in the task chain according to the key information and preset legal information to obtain the task result of the demand tasks;

[0047] The document generation module is configured to: fill in information in the template of the element-based legal document according to the task result and the key information, and generate the element-based legal document of the case to be processed according to the template with the information filled in.

[0048] In a technical solution of the above legal document generation system, the system further includes a memory module and / or a decision module;

[0049] The memory module is configured to: store the key information, the execution results of each subtask in the task chain, and the task result of the demand tasks;

[0050] The decision module is configured to: monitor the execution status of each subtask in the task chain;

[0051] If it is monitored that an exception occurs during the execution of the current subtask in the task chain, obtain an exception handling mechanism corresponding to the type of the exception, use the exception handling mechanism to process the current subtask, and suspend the execution of the target subtask, where the current subtask is any subtask in the task chain, and the target subtask is other subtasks in the task chain that are executed after the current subtask;

[0052] If it is monitored that the current subtask fails to execute, re-execute the current subtask.

[0053] In a third aspect, an electronic device is provided, the electronic device includes at least one processor; and, a memory communicatively connected to the at least one processor; wherein, a computer program is stored in the memory, and when the computer program is executed by the at least one processor, the method described in any one of the technical solutions provided in the first aspect above is implemented.

[0054] In a fourth aspect, a computer-readable storage medium is provided, which stores multiple pieces of program code, and the program code is adapted to be loaded and run by a processor to execute the method described in any of the technical solutions provided in the above first aspect.

[0055] One or more of the above technical solutions of the present application have at least one or more of the following beneficial effects:

[0056] In a technical solution of implementing the legal document generation method provided in the present application, case information and case demands of a case to be processed can be obtained; a first intelligent agent is used to extract key information from the case information to obtain the key information in the case information; according to the case demands, the demand tasks of the case to be processed are determined; the demand tasks are disassembled into multiple subtasks, and the dependency relationships between the multiple subtasks are analyzed, and the execution order of the multiple subtasks is determined according to the dependency relationships; the multiple subtasks are linked according to the execution order of the multiple subtasks to form a task chain corresponding to the demand tasks; a second intelligent agent is used, and each subtask in the task chain is executed according to the key information and the preset legal information to obtain the task result of the demand tasks; according to the task result and the key information, the template of the element-based legal document is filled with information, and the element-based legal document of the case to be processed is generated according to the template after the information filling is completed.

[0057] The above implementation can automatically extract the information required for the element-based legal document from the case information and case demands of the case to be processed, and automatically fill the template of the element-based legal document with this information. Compared with the manual extraction and filling methods in the prior art, the above implementation can greatly improve the acquisition efficiency and quality of legal documents.

[0058] The above implementation uses a first intelligent agent to extract key information from the case information. Even if the expression of the same key information is different in different case information, the key information can be accurately extracted from different case information. Compared with the rule matching method in the prior art, the above implementation is more flexible when extracting key information, can extract key information more accurately and reliably, and at the same time, since there is no need to pre-define rules / templates, there is no need to frequently update and maintain these rules / templates.

[0059] The above implementation solution decomposes a complex claim task into multiple subtasks, and then links the multiple subtasks in their respective execution orders to form a task chain. The execution process of this task chain is equivalent to the process of inferring the claim result from the case information, and a subtask is equivalent to an intermediate step in the above process, and the execution result of the subtask is the result of the intermediate step. Based on the results of each intermediate step, the user can accurately understand how to infer the task result from the case information, so that the task result is interpretable. In addition, when the task result is logically incoherent or does not meet the actual requirements, the subtasks in the task chain can be adjusted (i.e., controlling the intermediate steps) to optimize the task result and ensure the quality of the task result. BRIEF DESCRIPTION OF THE DRAWINGS

[0060] With reference to the accompanying drawings, the disclosure of the present application will become more understandable. It is easy for those skilled in the art to understand that these drawings are only for illustrative purposes and are not intended to limit the scope of protection of the present application. Among them:

[0061] Figure 1 is a schematic flowchart of the main steps of a legal document generation method according to an embodiment of the present application;

[0062] Figure 2 is a schematic diagram of a task chain according to an embodiment of the present application Figure 1 ;

[0063] Figure 3 is a schematic flowchart of the main steps of determining the execution order of multiple subtasks according to an embodiment of the present application;

[0064] Figure 4 is a schematic flowchart of the main steps of executing each subtask in the task chain according to an embodiment of the present application;

[0065] Figure 5 is a schematic diagram of a task chain according to an embodiment of the present application Figure 2 ;

[0066] Figure 6 is a schematic flowchart of the main steps of task monitoring when executing the task chain according to an embodiment of the present application;

[0067] Figure 7 is a main structural block diagram of a legal document generation system according to an embodiment of the present invention;

[0068] Figure 8 is a main structural block diagram of a legal document generation system according to another embodiment of the present invention;

[0069] Figure 9It is a schematic diagram of the main structure of an electronic device according to an embodiment of the present application.

[0070] Reference numerals:

[0071] 11: Information input module; 12: Sensing module; 13: Planning module; 14: Document generation module; 15: Memory module; 16: Decision-making module; 21: Memory; 22: Processor. Detailed implementation manners

[0072] Some implementation manners of the present application will be described below with reference to the accompanying drawings. Those skilled in the art should understand that these implementation manners are only used to explain the technical principle of the present application and are not intended to limit the protection scope of the present application.

[0073] In the description of the present application, "module" and "processor" may include hardware, software, or a combination of both. A module may include a hardware circuit, various suitable sensors, communication ports, a memory, and may also include a software part, such as program code, or may be a combination of software and hardware. The processor may be a central processing unit, a microprocessor, an image processor, a digital signal processor, or any other suitable processor. The processor has data and / or signal processing functions. The processor may be implemented in software, in hardware, or in a combination of both. The computer-readable storage medium includes any suitable medium for storing program code, such as a magnetic disk, a hard disk, an optical disk, a flash memory, a read-only memory, a random access memory, and so on. The term "A and / or B" represents all possible combinations of A and B, such as only A, only B, or A and B.

[0074] An embodiment of the legal document generation method provided by the present application will be described below.

[0075] Refer to the attached Figure 1 , Figure 1 It is a schematic diagram of the main step flow of the legal document generation method according to an embodiment of the present application. As Figure 1 shown, the legal document generation method in the embodiment of the present application mainly includes the following steps S101 to step S107.

[0076] Step S101: Obtain the case information and case demands of the case to be processed.

[0077] The case to be processed may be a civil case to be processed, such as a divorce case, a contract dispute case, an inheritance dispute case, etc.

[0078] Case information can be information related to the case to be processed provided by a user (such as a party to the case or a legal practitioner). The case information should contain as much information as possible related to the case to be processed, avoiding omission of any important details that may affect the outcome of the case. Taking a divorce case as an example, the case information may include, but is not limited to: identification documents of both spouses, marriage certificate, identification documents of children, pre-marital property certificates, post-marital property and debts, etc.

[0079] Case demands refer to litigation requests. Taking a divorce case as an example, the case demands may include: requesting a divorce from the defendant, having the plaintiff raise the daughter, and dividing the couple's common property of X yuan.

[0080] Step S102: Use the first intelligent agent Agent to extract key information from the case information to obtain the key information in the case information.

[0081] The first intelligent agent Agent is a network model constructed using artificial intelligence technology, and the first intelligent agent Agent has the ability to extract information from case information. For example, the first intelligent agent Agent is a large language model (Large Language Model, LLM).

[0082] In some embodiments, the case information may include multiple types of sub-information, and the first intelligent agent Agent may also be multiple, and multiple first intelligent agent Agents correspond to multiple information types one by one, and multiple information types include the types of the above-mentioned sub-information. For each type of sub-information in the case information, a first intelligent agent Agent corresponding to the type of the sub-information can be obtained, and the first intelligent agent Agent is used to extract key information from the sub-information to obtain the key information in the sub-information. Through this embodiment, in the case where the case information has multiple types of sub-information, the intelligent agent Agents corresponding to each type of sub-information can be used to perform information extraction in parallel, effectively improving the extraction efficiency.

[0083] In some embodiments, for each type of sub-information, the type of key information to be extracted from the sub-information can be preset in advance, and then the sub-information is extracted according to the type of key information. Taking a divorce case as an example, Table 1 below exemplarily shows multiple types of sub-information in the case information, the labels (or types) of each type of sub-information, and the types of key information in each type of sub-information.

[0084] Table 1

[0085]

[0086] Step S103: Determine the demand task of the case to be processed according to the case demands. Specifically, the content of the case demands can be used as the demand task.

[0087] Step S104: Decompose the claim task into multiple subtasks, analyze the dependencies between the multiple subtasks, and determine the execution order of the multiple subtasks according to the dependencies.

[0088] When decomposing the claim task, it is possible to first determine the reasoning steps required to infer the task result of the claim task from the input information, and each reasoning step is used as a subtask. When there are multiple claim tasks, each claim task can be decomposed into multiple subtasks, and different claim tasks may have the same subtasks. In this case, only one subtask can be set, and different claim tasks share this subtask. Taking a divorce case as an example, if the claim task is that the woman requests the man to leave the house clean, this claim task can be decomposed into subtasks such as determining whether the relationship between the husband and wife has broken down, whether there is a fault party, the custody of the children, and the division of property.

[0089] The dependency between two subtasks is used to describe whether one subtask (hereinafter described as the first subtask) depends on another subtask (hereinafter described as the second subtask); if the first subtask depends on the second subtask, it means that the execution of the first subtask requires the result of the second subtask, and the second subtask needs to be executed first and then the first subtask, that is, the execution order of the second subtask takes precedence over the execution order of the first subtask; if the first subtask and the second subtask do not depend on each other, then there is no restriction on the execution order between the first and second subtasks, and even the two can be executed in parallel. Among them, the first and second subtasks are any one of the above multiple subtasks, and the first and second subtasks are different.

[0090] In some embodiments, when analyzing the dependency between the first and second subtasks, the input and output of the first and second subtasks can be analyzed; if the input of the first subtask includes the output of the second subtask, it means that the first subtask needs to directly use the result of the second subtask to execute, so the first subtask depends on the second subtask; otherwise, the first subtask does not depend on the second subtask. Taking a divorce case as an example, the first and second subtasks are respectively "determining whether the relationship between the husband and wife has broken down" and "division of property". When dividing the property, the result of whether the relationship between the husband and wife has broken down needs to be used. Therefore, the "division of property" depends on the "determining whether the relationship between the husband and wife has broken down", and the "determining whether the relationship between the husband and wife has broken down" is executed first, and then the "division of property" is executed.

[0091] Step S105: Link the multiple subtasks according to the execution order of the multiple subtasks to form a task chain corresponding to the claim task. Specifically, link each subtask in sequence according to its execution order to form a task chain.

[0092] Step S106: Employ a second Agent and execute each subtask in the task chain according to the key information and the preset legal information to obtain the task result of the claim task.

[0093] The second Agent is a network model constructed using artificial intelligence technology. The second Agent can execute the operations of the subtasks according to the input information of the subtasks to obtain the execution results of the subtasks. The execution result of the subtask arranged last in the execution order in the task chain can be used as the task result of the claim task. Taking a divorce case as an example, the claim task is that the wife requests the husband to leave the marriage with no property. This claim task is disassembled into four subtasks that are executed sequentially from first to last: determining whether the couple's relationship has broken down, whether there is a fault party, the custody of the children, and the division of property. When the subtask of property division is completed, the result of the property division can be used as the task result of the claim task.

[0094] Refer to the appendix Figure 2 , Figure 2 Exemplarily shows the task chains corresponding to three claim tasks, and three second Agents ( Figure 2 Agent 1, Agent 2, and Agent 3 in Figure 2 are respectively used to execute the subtasks in the three task chains. Among them, one task chain includes four subtasks ( Figure 2 Tasks 1 to 4 in Figure 2 that are executed sequentially from first to last), one task chain includes two subtasks (

[0095] Tasks 5 to 6 in Figure 2 that are executed sequentially from first to last), and one task chain only includes one subtask ( Figure 2 Task 7 in Figure 2 ). The task results of the three claim tasks respectively include the execution results w7, w10, and w11 of Tasks 4, 6, and 7.

[0095] In some embodiments, a legal knowledge base can be set up. The legal knowledge base stores legal provisions and cases. The preset legal information can include the legal provisions and cases in the legal knowledge base related to the case type of the case to be processed. Taking a divorce case as an example, the legal provisions related to divorce cases can include the legal provisions recorded in the "Civil Code", the "Marriage Law", etc.

[0096] In some embodiments, when obtaining legal provisions and cases from the legal knowledge base, keywords of the case to be processed can be obtained, and the legal provisions and cases recorded in the legal knowledge base can be matched according to the keywords to obtain the legal provisions and cases that match the case to be processed; alternatively, the similarity between the case to be processed and the cases recorded in the legal knowledge base can also be calculated, and cases similar to the case to be processed can be obtained according to the results of the similarity calculation. For example, if the keywords of the case to be processed contain words related to domestic violence, the relevant provisions in the "Civil Code" regarding divorce caused by domestic violence and cases similar to the case to be processed can be obtained.

[0097] Step S107: Fill in the information in the template of the element-based legal document according to the task result and key information, and generate the element-based legal document of the case to be processed based on the template with the filled-in information. Specifically, the template with the filled-in information can be used as the element-based legal document.

[0098] Taking a divorce case as an example, the element-based legal documents can be a complaint and a defense statement.

[0099] Taking the complaint in a divorce case as an example, the complaint includes information about the parties, litigation requests and bases, agreed jurisdiction and litigation preservation, facts and reasons, etc. Among them, the information about the parties includes the information of the plaintiff (including name, gender, date of birth, etc.) and the information of the defendant (including name, gender, date of birth, etc.), and these information can be filled in according to the key information. The litigation requests and bases include community property of the couple, joint debts of the couple, child support, etc., and these information may come from the key information or the task result, and can be queried from the key information and the task result according to the information to be filled in when filling in. The filling of the content such as agreed jurisdiction and litigation preservation, facts and reasons is similar to the above-mentioned information about the parties, litigation requests and bases, and will not be elaborated here.

[0100] The method described in the above Step S101 to Step S107 has the following technical effects:

[0101] (1) The above method can automatically extract the information required for the element-based legal document from the case information and case demands of the case to be processed, and automatically fill in the information in the template of the element-based legal document according to these information, improving the acquisition efficiency and quality of the legal document.

[0102] (2) The above method uses the first intelligent agent Agent to extract key information from the case information. Even if the expression of the same key information is different in different case information, it can accurately extract the key information from different case information.

[0103] (3) In the above method, the execution process of the task chain is equivalent to the process of inferring the case claim result from the case information. The execution result of the subtask in the task chain is the result of the intermediate step of this process. Based on the results of each intermediate step, the user can accurately understand how to infer the task result from the case information, making the task result interpretable. By means of multi-step reasoning, complex legal problems can be processed more accurately, avoiding legal risks caused by information loss or logical errors. In addition, when the task result is logically incoherent or does not meet the actual requirements, the subtasks in the task chain can be adjusted (i.e., controlling the intermediate steps) to optimize the task result, ensuring the quality of the task result, so that the generated legal document can accurately reflect the actual situation of the case to be processed and meet the legal requirements.

[0104] (4) The above method adopts multiple intelligent agents to work collaboratively, which can efficiently complete the generation of legal documents. For example, the first intelligent agent is used to extract key information (such as extracting the identity information and property status of both parties in a divorce case, etc.), and the task chains corresponding to different claim tasks can be executed by different second intelligent agents (such as matching and applying legal rules to ensure that the generated legal documents meet the requirements of relevant laws and regulations such as the Civil Code). Through the division of labor and cooperation of multiple intelligent agents, the efficiency, stability and reliability of processing are improved.

[0105] Briefly speaking, the above method realizes the efficient and accurate automatic generation of element-based legal documents, provides powerful tool support for users (such as legal practitioners), and also brings higher efficiency and better legal protection to the handling of legal cases (such as civil cases), with broad application prospects and important social value. At the same time, each step and decision-making process in the execution process of the task chain are transparent, and the user can clearly understand how this method gradually derives the case result (Case Result, CR) from the case input (CaseInput set, CI), which provides higher credibility and acceptability for the practical application of this method.

[0106] Next, the embodiments of the legal document generation method provided in this application will be further described, specifically for the above steps S102, S104 and S106.

[0107] First, an explanation of step S102 will be given.

[0108] In some embodiments of the above step S102, after extracting the key information, data cleaning, structuring, and vectorizing processing can be sequentially performed on the key information to obtain the final key information and store the final key information.

[0109] The following describes data cleaning, structuring, and vectorization.

[0110] 1. Describe data cleaning.

[0111] Data cleaning can be used to remove invalid and redundant data in key information, which is beneficial for the intelligent agent to improve the execution efficiency and accuracy when performing subtasks based on the key information.

[0112] In some embodiments, data cleaning may include object unification, duplicate removal, text error correction, irrelevant information removal, format unification, and data integrity check.

[0113] Object unification is used for: when the same party appears in multiple documents (or multiple case information), the ID number of the party is used as the unique identifier of the party. Based on this, when information conflicts occur for the same party in different documents (or case information), according to the ID number of the party, obtain the information in the original ID record of the party and use this information as the standard.

[0114] Duplicate removal is used for: by comparing case information, removing duplicate case information or duplicate key information to avoid interference with subsequent analysis and processing.

[0115] Text error correction is used for: identifying and correcting misspelled words, wrong words, wrong serial numbers, etc. in case information.

[0116] Irrelevant information removal is used for: removing information irrelevant to the case such as headers, footers, advertisements, etc. in the document, as well as some redundant expressions and format contents to make the data more concise and effective.

[0117] Format unification is used for: formatting key information to make it conform to a unified data format standard, facilitating subsequent structuring and analysis. For example, unifying the date to the "YYYY-MM-DD" format and representing the amount in Arabic numerals, etc.

[0118] Data integrity check is used for: checking whether the extracted key information is complete. For missing information, supplement or mark it according to the actual situation to ensure the integrity of the data, so as to more comprehensively reflect the case situation.

[0119] 2. Describe structuring.

[0120] Structured processing can be used to convert the data structures of information of the same type into the same data structure, that is, to unify the data structures of information of the same type, which is also beneficial to improving the task execution efficiency and accuracy of the intelligent agent (Agent) when performing subtasks according to key information. For example, the data structure of property information is the property type and the market value amount. Based on this, the data structure of pre-marital property can be converted into the pre-marital property type and the market value amount, and the data structure of post-marital property can be converted into the post-marital property type and the market value amount.

[0121] 3. Explain the vectorization processing.

[0122] Vectorization processing can be used to convert the key information that has undergone structured processing into vector form. In some embodiments, the RAG (Retrieval-augmented Generation) model can be used to convert the key information into vector form, and then the key information in vector form is stored as the final key information. In addition, when it is necessary to obtain a certain or certain key information, the RAG model can also be used for retrieval or query to quickly obtain the required key information.

[0123] II. Explain step S104.

[0124] In some embodiments of the above step S104, the claim task can be disassembled into multiple subtasks by the following formula:

[0125] Based on the claim task and the 1st to the i-th subtasks, multiple (i + 1)-th subtasks are predicted, where i ≥ 2, and the 1st subtask is predicted based on the claim task; among them, the input of the (i + 1)-th subtask includes the output of the i-th subtask.

[0126] That is to say, aiming at taking the output of the i-th subtask as the input of the (i + 1)-th subtask, and at the same time combining the claim task and all the subtasks that have been predicted before the i-th subtask, to predict the (i + 1)-th subtask. Based on this, each subtask can be gradually predicted, and the predicted order of each subtask is linked in sequence to form a task chain, which can be described as a task prediction chain (Chain of Task Prediction, CoP).

[0127] In some embodiments, the (i + 1)-th subtask can be predicted in the following way:

[0128] Obtain the task characteristics of the claim task and the 1st to the i-th subtasks, adopt the function call mechanism of the large language model (LLM), and predict at least one of the multiple (i + 1)-th subtasks according to the task characteristics.

[0129] Specifically, functions to be adopted by the large language model during function calls can be preset. When predicting the (i + 1)-th subtask, the large language model calls the above functions and processes them with the above task features as function parameters to obtain the (i + 1)-th subtask. It should be noted that the function call mechanism of the large language model is a conventional function call method. The form of the function is not specifically limited in this application, and the content of the task features is also not specifically limited. Those skilled in the art can flexibly set the function form and the content of the task features according to actual needs, as long as the subtask can be predicted by calling the function and based on the task features.

[0130] In some embodiments, the (i + 1)-th subtask can be predicted in the following way:

[0131] Obtain the text description information of the claim task and the first to the i-th subtasks, and input the text description information into the large language model (LLM) for processing to predict at least one of the multiple (i + 1)-th subtasks. Among them, the text description information is the text used to describe the task content.

[0132] The large language model can reason about the above text description information and predict the (i + 1)-th subtask. In the embodiments of this application, a conventional model training method can be used to enable the large language model to have this ability, and the model training method will not be elaborated here.

[0133] In some embodiments, the (i + 1)-th subtask can be predicted in the following way: Obtain the target legal information related to the claim task from a preset legal knowledge base. The legal knowledge base is used to store legal information, and the legal information includes legal provisions and cases; based on the target legal information, and according to the claim task and the first to the i-th subtasks, predict at least one of the multiple (i + 1)-th subtasks. Taking a divorce case as an example, the legal provisions related to the divorce case may include the legal provisions recorded in the "Civil Code", the "Marriage Law", etc.

[0134] The case information of the case to be processed can be understood as internal information, and the legal information can be understood as external information. In some cases, the input of some tasks may include legal information in addition to internal information. At this time, the legal information that may be required can be obtained from the legal knowledge base, and the (i + 1)-th subtask can be determined in combination with the legal information. For example, if the task content of the (i - 1)-th subtask is to select the correct cited legal article, then the content of the predicted (i + 1)-th subtask is to perform property division based on the execution results of other tasks before the (i - 1)-th subtask (such as the result of judging whether the couple's relationship has broken down), and the cited legal article selected by the (i - 1)-th subtask.

[0135] In some embodiments of the above step S104, it can be determined the execution order of multiple subtasks through Figure 3 the following steps S1041 to S1043 shown below.

[0136] Step S1041: Take each subtask in multiple subtasks as the current subtask in turn, and determine the dependency degree of the current subtask according to the dependency relationship between the current subtask and other subtasks; if the current subtask depends on other subtasks and is also depended on by other subtasks, the dependency degree is the highest; if the current subtask depends on other subtasks or is depended on by other subtasks, the dependency degree is the second highest; if the current subtask does not depend on other subtasks and is not depended on by other subtasks, the dependency degree is the lowest. Herein, other subtasks are the remaining subtasks in multiple subtasks except the current subtask.

[0137] Step S1042: Determine the priority of the current subtask according to the dependency degree. Among them, the priority is positively correlated with the dependency degree, that is, the higher the dependency degree, the higher the priority, and the lower the dependency degree, the lower the priority.

[0138] In some embodiments, the corresponding relationship between the priority and the dependency degree can be preset in advance, and the priority corresponding to the dependency degree of the current subtask is obtained according to this corresponding relationship. Through this embodiment, the priority of the current subtask can be obtained quickly and accurately.

[0139] Step S1043: Arrange the execution order of multiple subtasks in descending order of priority; if when arranging, there is a situation where the priority of the first subtask is higher than or equal to the priority of the second subtask, but the first subtask depends on the second subtask, then make the execution order of the second subtask prior to the execution order of the first subtask. Since the first subtask depends on the second subtask, the output of the second subtask will be used as the input of the first subtask. If only considering the priority, then the first subtask will be executed before the second subtask, and the output of the second subtask is missing during execution, which will ultimately lead to the failure of the first subtask to execute. Considering this problem, in this embodiment, when arranging according to the priority, it will be judged whether there is a situation of "the priority of the first subtask is higher than or equal to the priority of the second subtask, but the first subtask depends on the second subtask". If this situation occurs, then make the execution order of the second subtask prior to the execution order of the first subtask to ensure that the subtasks can be executed normally. Herein, the first and second subtasks are both any one subtask in multiple subtasks, and the first and second subtasks are different.

[0140] Take Figure 2Taking the task chain composed of Task 1 to Task 4 as an example, the dependencies of Task 2 and Task 3 are the highest, and the dependencies of Task 1 and Task 4 are the second highest. Based on this, the priorities of Task 2 and Task 3 are the same and both are the highest priority; the priorities of Task 1 and Task 4 are the same and both are the lowest priority. When arranging the execution order, first arrange the tasks with the highest priority, Task 2 and Task 3. Since Task 3 depends on Task 2, the execution order of Task 2 takes precedence over that of Task 3. When arranging, there is a situation where "the priority of Task 2 is higher than that of Task 1, but Task 2 depends on Task 1". Therefore, even though the priority of Task 2 is higher than that of Task 1, the execution order of Task 1 takes precedence over that of Task 2. Finally, the arrangement order is: Task 1, Task 2, Task 3, Task 4.

[0141] In addition, if the priorities of the first and second subtasks are the same and they do not depend on each other, then the execution orders of the first and second subtasks can be the same. For example, Figure 5 the dependencies of Task 2 and Task 3 in are the same, so their priorities are the same, and Task 2 and Task 3 do not depend on each other, then the execution orders of Task 2 and Task 3 are the same.

[0142] Based on the method described in the above steps S1041 to S1043, it is possible to take into account both the priorities and dependencies of subtasks to determine the execution order of subtasks and ensure that each subtask can be executed normally.

[0143] Third, an explanation of step S106 is given.

[0144] In some embodiments of the above step S106, there are multiple second agents Agent, and they can execute each subtask in the task chain through Figure 4 the following steps S1061 to S1062 shown.

[0145] Step S1061: Determine the task types of each subtask in the task chain according to the dependencies between multiple subtasks. The task types include parallel tasks and serial tasks.

[0146] Specifically, if the current subtask in the task chain does not depend on other subtasks, then the task type of the current subtask is a parallel task; otherwise, the task type of the current subtask is a serial task; the current subtask is any one subtask in the task chain, and other subtasks are the remaining subtasks in the task chain except the current subtask.

[0147] Step S1062: When there are multiple parallel tasks in the task chain, use multiple second agents Agent to execute each parallel task in the multiple parallel tasks in parallel.

[0148] Taking a divorce case as an example, "the ownership of child custody" and "property division" are both parallel tasks. At this time, two second intelligent agents Agent can be used to execute these two subtasks in parallel. For another example, before property division, it is necessary to first determine whether the relationship between the husband and wife has broken down and whether there is a fault party. Property division is a serial task. It is necessary to first complete the subtasks of whether the relationship between the husband and wife has broken down and whether there is a fault party, and then execute the subtask of property division.

[0149] For another example, when dealing with a divorce case involving disputes over the custody of multiple children, multiple second intelligent agents Agent can be used simultaneously to analyze and reason about the situation of each child respectively, and finally summarize the results to generate a complete legal document.

[0150] See appendix Figure 5 , Task 2 and Task 3 are parallel tasks and can be executed by two second intelligent agents Agent respectively; Task 1, Task 4, and Task 5 are all serial tasks and can be executed sequentially by one second intelligent agent Agent. This second intelligent agent Agent can be one of the two second intelligent agents Agent used to execute Task 2 and Task 3, or a third second intelligent agent Agent different from these two second intelligent agents Agent.

[0151] Based on the method described in the above steps S1061 to S1062, multiple subtasks can be executed in parallel, improving the execution efficiency of the entire task chain and obtaining the task result as soon as possible.

[0152] Next, the embodiments of the legal document generation method provided by the present application will be further described. See appendix Figure 6 , In some embodiments according to the present application, when executing the task chain, it can be passed through Figure 6 The following steps S201 to S203 shown are used for task monitoring.

[0153] Step S201: Monitor the execution status of each subtask in the task chain.

[0154] The execution status may include: the start time of task execution, the end time of execution, the execution progress, the execution result. The execution result may include whether an exception occurs, whether the execution is successful, and the task result when the execution is successful, etc. If it is monitored that an exception occurs during the execution of the current subtask, go to step S202; if it is monitored that the current subtask fails to execute, go to step S203. Among them, the current subtask is any subtask in the task chain.

[0155] Step S202: Obtain an exception handling mechanism corresponding to the type of exception, use the exception handling mechanism to process the current subtask, and suspend the execution of the target subtask. Here, the target subtask is other subtasks in the task chain that are executed after the current subtask.

[0156] In this embodiment, the correspondence between the type of exception and the exception handling mechanism can be preset in advance. According to this correspondence, obtain the exception handling mechanism corresponding to the type when the current subtask has an exception, and use this exception handling mechanism for processing.

[0157] The types of exceptions can include data loss, logical errors, etc. Data loss means that the input information of the current subtask is missing, and logical error means that the information input to the current subtask is not the input information required by the current subtask, etc.

[0158] The exception handling mechanism corresponding to data loss can be to suspend the execution of the current subtask and give a prompt so that the user can supplement information according to the prompt. For example, if it is found that the property information is incomplete in the "property division" task, the task execution will be suspended, and the user will be prompted to supplement relevant information. The exception handling mechanism corresponding to a logical error can be to suspend the execution of the current subtask and give a prompt so that the user can adjust the input information of the current subtask. Those skilled in the art can flexibly set the types of exceptions and the corresponding exception handling mechanisms according to actual needs, and this embodiment does not make specific limitations in this regard.

[0159] Step S203: Re-execute the current subtask.

[0160] After detecting that the task execution fails, the task can be automatically re-executed, or the current subtask can be re-executed in response to the user's operation. In some embodiments, an electronic device can be used to execute the legal document generation method provided in this application. Controls for user operations can be set on the display interface of the electronic device. The user can perform operations such as clicking, dragging, and swiping on the control, and the electronic device can re-execute the current subtask in response to the user's operation.

[0161] In some embodiments, when it is detected that the task execution fails, the execution failure information can be recorded. The execution failure information can include information such as the failure reason. In this way, the user can quickly take measures according to the execution failure information to ensure that the current subtask can be successfully executed. For example, if the "custody of children" task fails due to incorrect input information, the execution failure information can include the incorrect input information so that the user can correct the information.

[0162] Based on the method described in the above steps S201 to S203, the execution status of each subtask can be monitored during the execution of the task chain to ensure the reliability of task execution.

[0163] It should be noted that although the above embodiments describe the various steps in a specific order, those skilled in the art can understand that in order to achieve the effects of the present application, it is not necessary to execute the different steps in such an order. They can be executed simultaneously (in parallel) or in other orders, and these adjusted solutions are equivalent technical solutions to the technical solutions described in the present application, and thus will also fall within the protection scope of the present application.

[0164] Those skilled in the art can understand that all or part of the processes in the method of the above-mentioned embodiment of the present application can also be completed by instructing relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium. When the computer program is executed by a processor, the steps of the above-mentioned various method embodiments can be implemented. Among them, the computer program includes computer program code, and the computer program code can be in the form of source code, object code, executable file or some intermediate form, etc. The computer-readable storage medium can include: any entity or device, medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory, random access memory, electrical carrier signal, telecommunication signal, and software distribution medium that can carry the computer program code.

[0165] On the other hand, the present application also provides a legal document generation system.

[0166] Refer to the appendix Figure 7 , Figure 7 is the main structural block diagram of the legal document generation system according to an embodiment of the present invention. As Figure 7 shown, the legal document generation system in the embodiment of the present invention mainly includes an information input module 11, a perception module 12, a planning module 13, and a document generation module 14. The information input module 11 can be configured to obtain the case information and case demands of the case to be processed. The perception module 12 can be configured to use a first intelligent agent Agent to extract key information from the case information to obtain the key information in the case information. The planning module 13 can be configured to determine the demand tasks of the case to be processed according to the case demands; disassemble the demand tasks into multiple subtasks, analyze the dependency relationships between the multiple subtasks, and determine the execution order of the multiple subtasks according to the dependency relationships; link the multiple subtasks according to the execution order of the multiple subtasks to form a task chain corresponding to the demand task; use a second intelligent agent Agent, and execute each subtask in the task chain according to the key information and the preset legal information to obtain the task result of the demand task. The document generation module 14 can be configured to fill in information in the template of the element-based legal document according to the task result and the key information, and generate the element-based legal document of the case to be processed according to the template with the information filled in.

[0167] The description of the specific implementation functions of the above modules can be referred to in steps S101 to S107. In some embodiments, one or more of the information input module 11, the perception module 12, the planning module 13, and the document generation module 14 may be combined into one module.

[0168] In some implementation manners, the legal document generation system may further include a memory module 15 and / or a decision-making module 16. The memory module 15 may be configured to store key information, the execution results of each subtask in the task chain, and the task results of the claim task. In some implementation manners, the execution results of the subtasks may not only include the determination of the case facts (such as whether there is pre-marital property, post-marital joint debts, etc.), but also include a preliminary judgment on the application of the law (such as according to the law, pre-marital property shall belong to the individual, etc.). The memory module 15 will perform associated memory on the execution results of all subtasks to provide support for the execution of subsequent subtasks. For example, when calculating post-marital property, the memory module 15 will remember information such as the source and appreciation of the property, so as to be accurately processed in accordance with the law during property division.

[0169] The decision-making module 16 may be configured to: monitor the execution status of each subtask in the task chain; if it is detected that an exception occurs during the execution of the current subtask in the task chain, obtain an exception handling mechanism corresponding to the type of the exception, use the exception handling mechanism to process the current subtask, and suspend the execution of the target subtask, where the current subtask is any subtask in the task chain, and the target subtask is other subtasks in the task chain that are executed after the current subtask; if it is detected that the current subtask fails to execute, re-execute the current subtask. The description of the specific implementation functions of the decision-making module 16 can be referred to in steps S201 to S203.

[0170] The following combines the attached Figure 8 , to illustrate the legal document generation system provided by the present application, Figure 8Exemplarily shown are a perception module 12, a planning module 13, a memory module 15, and a decision-making module 16. The scenario requirement is used to represent the type of case to be processed, and the scenario requirement instruction is used to indicate an instruction for generating an element-based legal document, which is a legal document for the type of case represented by the scenario requirement. The perception module 12 uses a first intelligent agent (Agent) to extract key information from the case information, obtains the key information in the case information, and stores the key information in the memory module 15. The planning module 13 can form a task chain corresponding to the claim task, and uses a second intelligent agent (Agent) to execute each subtask in the task chain according to the key information and the preset legal information, obtains the task result of the claim task, and stores the execution result of the subtask in the memory module 15 during the execution process. The decision-making module 16 can monitor the execution status of each subtask during the execution of the task chain, and dynamically adjust the subtasks according to the monitoring result. For example, suspend the execution of the current subtask, or when the task result shows logical incoherence or does not meet the actual requirements, adjust the subtasks in the task chain (such as adjusting the dependency relationship between subtasks) to optimize the task result and ensure the quality of the task result.

[0171] By integrating the perception module 12, the planning module 13, the memory module 15, and the decision-making module 16, the above system realizes the simulation of the thinking and working logic of the human brain by obtaining the case result (Case Result, CR) from the input (Case Input set, CI) of a specific scenario (or a type of legal case) through multiple intermediate steps or a chain of tasks (Chain of Task, COT). The above system can be understood as a legal document generation system based on a cognitive architecture model, which can efficiently and accurately generate element-based legal documents (such as a statement of claim, a statement of defense, etc.) for the case to be processed.

[0172] The above legal document generation system is used to execute Figures 1 to 6 the legal document generation method embodiment shown. The technical principles, the technical problems solved, and the technical effects produced by the two are similar. Those skilled in the art of this technology can clearly understand that for the convenience and conciseness of description, the specific working process and related descriptions of the legal document generation system can refer to the content described in the embodiment of the legal document generation method, which will not be elaborated here.

[0173] On the other hand, the present application also provides a computer-readable storage medium.

[0174] In an embodiment of a computer-readable storage medium according to the present application, the computer-readable storage medium may be configured to store a program for executing the legal document generation method in the above method embodiment. This program can be loaded and run by a processor to implement the above legal document generation method. For ease of description, only parts related to the embodiments of the present application are shown. For specific technical details not disclosed, please refer to the method part of the embodiments of the present application. The computer-readable storage medium may be a storage device formed by various electronic devices. Optionally, the computer-readable storage medium in the embodiments of the present application is a non-transitory computer-readable storage medium.

[0175] Another aspect of the present application also provides an electronic device.

[0176] In an embodiment of an electronic device according to the present application, the electronic device may include at least one processor; and a memory communicatively connected to the at least one processor; wherein, a computer program is stored in the memory, and when the computer program is executed by the at least one processor, the method described in any of the above embodiments is implemented. Refer to the attached Figure 9 , Figure 9 It is exemplarily shown in the figure that the memory 21 and the processor 22 are communicatively connected via a bus.

[0177] The electronic device described in the present application may be, but is not limited to, a mobile phone, a tablet computer, a desktop computer, a laptop computer, a handheld computer, a notebook computer, a vehicle-mounted device, an ultra-mobile personal computer (UMPC), a netbook, a personal digital assistant (PDA), an augmented reality (AR) / virtual reality (VR) device, etc. The embodiments of the present application do not make any limitations in this regard.

[0178] So far, the technical solutions of the present application have been described in conjunction with an embodiment shown in the accompanying drawings. However, those skilled in the art can easily understand that the protection scope of the present application is obviously not limited to these specific embodiments. Without departing from the principle of the present application, those skilled in the art can make equivalent changes or substitutions to the relevant technical features, and the technical solutions after these changes or substitutions will all fall within the protection scope of the present application.

Claims

1. A method for generating legal documents, characterized in that, The method includes: Obtaining the case information and case demands of the case to be processed; Using a first intelligent agent (Agent) to extract key information from the case information to obtain the key information in the case information; Determining the demand task of the case to be processed according to the case demands; Decomposing the demand task into multiple subtasks, analyzing the dependency relationships between the multiple subtasks, and determining the execution order of the multiple subtasks according to the dependency relationships; Linking the multiple subtasks according to the execution order of the multiple subtasks to form a task chain corresponding to the demand task; Using a second intelligent agent (Agent) and executing each subtask in the task chain according to the key information and preset legal information to obtain the task result of the demand task; Filling in information in the template of the element-based legal document according to the task result and the key information, and generating the element-based legal document of the case to be processed according to the template with the information filled in.

2. The method according to claim 1, wherein The case information includes multiple types of sub-information, there are multiple first intelligent agents (Agents), and the multiple first intelligent agents (Agents) respectively correspond to multiple information types one by one. The step of using a first intelligent agent (Agent) to extract key information from the case information to obtain the key information in the case information includes: For each type of sub-information in the case information, obtaining the first intelligent agent (Agent) corresponding to the type of the sub-information, and using the first intelligent agent (Agent) to extract key information from the sub-information to obtain the key information in the sub-information.

3. The method according to claim 1, wherein The step of analyzing the dependency relationships between the multiple subtasks includes: If the input of a first subtask includes the output of a second subtask, then the first subtask depends on the second subtask; otherwise, the first subtask does not depend on the second subtask; Wherein, The first subtask and the second subtask are both any one of the multiple subtasks, and the first subtask is different from the second subtask.

4. The method according to claim 1 or 3, characterized in that, The step of determining the execution order of the multiple subtasks according to the dependency relationships includes: If a first subtask depends on a second subtask, then the execution order of the second subtask takes precedence over the execution order of the first subtask; Wherein, The first subtask and the second subtask are both any one of the multiple subtasks, and the first subtask is different from the second subtask.

5. The method according to claim 1 or 3, characterized in that, The step of determining the execution order of the multiple subtasks according to the dependency relationships includes: Successively taking each subtask in the multiple subtasks as the current subtask, and determining the dependency degree of the current subtask according to the dependency relationships between the current subtask and other subtasks; if the current subtask depends on other subtasks and is also depended on by other subtasks, then the dependency degree is the highest; if the current subtask depends on other subtasks or is depended on by other subtasks, then the dependency degree is the second highest; if the current subtask does not depend on other subtasks and is not depended on by other subtasks, then the dependency degree is the lowest; Determine the priority of the current subtask according to the degree of dependence, and the priority is positively correlated with the degree of dependence; Arrange the execution order of the multiple subtasks in descending order of the priority; if, when arranging, the priority of the first subtask is higher than or equal to the priority of the second subtask, but the first subtask depends on the second subtask, then make the execution order of the second subtask prior to the execution order of the first subtask; Wherein, both the first subtask and the second subtask are any one of the multiple subtasks, and the first subtask is different from the second subtask.

6. The method according to claim 1, wherein There are multiple second agents, and the second agents are adopted and each subtask in the task chain is executed according to the key information and the preset legal information to obtain the task result of the claim task, including: Determine the task type of each subtask in the task chain according to the dependence relationship between the multiple subtasks; if the current subtask in the task chain does not depend on other subtasks, the task type of the current subtask is a parallel task; otherwise, the task type of the current subtask is a serial task; the current subtask is any one of the subtasks in the task chain, and the other subtasks are the remaining subtasks in the task chain except the current subtask; When there are multiple parallel tasks in the task chain, use multiple second agents to execute each parallel task in the multiple parallel tasks in parallel respectively.

7. The method according to claim 1, wherein The method further includes task monitoring by the following means: Monitor the execution status of each subtask in the task chain; If it is monitored that an exception occurs during the execution of the current subtask in the task chain, obtain an exception handling mechanism corresponding to the type of the exception, use the exception handling mechanism to handle the current subtask, and suspend the execution of the target subtask, wherein the current subtask is any one of the subtasks in the task chain, and the target subtask is other subtasks in the task chain that are executed after the current subtask; If it is monitored that the current subtask fails to execute, re-execute the current subtask.

8. The method according to claim 1, wherein The disassembling the claim task into multiple subtasks includes: Predict multiple (i + 1)-th subtasks according to the claim task and the 1st to the i-th subtasks, i ≥ 2, and the 1st subtask is predicted based on the claim task; Wherein, the input of the (i + 1)-th subtask includes the output of the i-th subtask.

9. The method according to claim 8, wherein the predicting multiple (i + 1)-th subtasks according to the claim task and the 1st to the i-th subtasks includes: Obtain the task features of the claim task and the 1st to the i-th subtasks; Adopt the function call mechanism of the large language model and predict at least one of the multiple (i + 1)-th subtasks according to the task features; and / or, the predicting multiple (i + 1)-th subtasks according to the claim task and the 1st to the i-th subtasks includes: Obtain the text description information of the claim task and the first to the i-th subtasks; Input the text description information into a large language model for processing, and predict at least one of the multiple (i + 1)-th subtasks; And / or Predicting multiple (i + 1)-th subtasks according to the claim task and the first to the i-th subtasks includes: Obtain target legal information related to the claim task from a preset legal knowledge base, where the legal knowledge base is used to store legal information, and the legal information includes legal provisions and cases; Based on the target legal information, and according to the claim task and the first to the i-th subtasks, predict at least one of the multiple (i + 1)-th subtasks.

10. A legal document generation system, characterized in that, The system includes an information input module, a perception module, a planning module, and a document generation module; The information input module is configured to: obtain the case information and case claim of the case to be processed; The perception module is configured to: use a first intelligent agent (Agent) to extract key information from the case information to obtain the key information in the case information; The planning module is configured to: determine the claim task of the case to be processed according to the case claim; Decompose the claim task into multiple subtasks, analyze the dependency relationships between the multiple subtasks, and determine the execution order of the multiple subtasks according to the dependency relationships; link the multiple subtasks according to the execution order of the multiple subtasks to form a task chain corresponding to the claim task; Use a second intelligent agent (Agent), and execute each subtask in the task chain according to the key information and the preset legal information to obtain the task result of the claim task; The document generation module is configured to: fill in information in the template of the element-based legal document according to the task result and the key information, and generate the element-based legal document of the case to be processed according to the template with the information filled in.

11. The system according to claim 10, wherein The system further includes a memory module and / or a decision module; The memory module is configured to: store the key information, the execution results of each subtask in the task chain, and the task result of the claim task; The decision module is configured to: monitor the execution status of each subtask in the task chain; If it is monitored that an exception occurs during the execution of the current subtask in the task chain, obtain an exception handling mechanism corresponding to the type of the exception, use the exception handling mechanism to process the current subtask, and pause the execution of the target subtask, where the current subtask is any subtask in the task chain, and the target subtask is other subtasks in the task chain that are executed after the current subtask; If it is monitored that the current subtask fails to execute, re-execute the current subtask.

12. An electronic device, characterized in that, Includes: At least one processor; And a memory communicatively connected to the at least one processor; Wherein, a computer program is stored in the memory, and when the computer program is executed by the at least one processor, it implements the legal document generation method according to any one of claims 1 to 9.

13. A computer-readable storage medium storing multiple program codes, characterized in that, The program code is adapted to be loaded and run by a processor to execute the legal document generation method according to any one of claims 1 to 9.

Citation Information

Patent Citations

  • Legal decision prediction method based on priori knowledge and subtask dependency relationship

    CN114707701A

  • Method and device for predicting judgment result of legal document and storage medium

    CN115878815A