Structured legal document generation method and system based on large model and knowledge base enhancement
By employing a method based on large models and knowledge base enhancement, combined with legal and regulatory knowledge bases and official document template knowledge bases, the problem of insufficient legality and accuracy in the generation of legal documents is solved. This enables the efficient generation and personalized customization of structured legal documents, improving the flexibility and accuracy of the generation process.
Patent Information
- Application Number
- CN202411925971.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-25
- Publication Date
- 2025-11-07
- Estimated Expiration
- 2044-12-25
AI Technical Summary
Existing technologies struggle to handle complex legal scenarios in legal document generation, lack robust knowledge base support, resulting in generated documents that ignore relevant legal provisions and document templates, lacking legality and accuracy, and unable to retrieve the latest information in real time.
A method based on large models and knowledge base enhancement is adopted. By retrieving legal and regulatory knowledge bases and official document template knowledge bases, and combining them with web search, structured legal documents are generated. The accuracy and compliance of the generated content are ensured by using an intent understanding module and a multi-path supplementation strategy.
It improves the flexibility and accuracy of legal document generation, ensures rich content and clear structure, provides an intuitive reading experience, and adapts to various complex scenarios and needs.
Smart Images

Figure CN120031008B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of structured legal document generation, specifically to a method and system for generating structured legal documents based on large models and knowledge base enhancement. Background Technology
[0002] With the continuous development of artificial intelligence, automated document generation technology has made certain progress, and this technology is gradually becoming an important means to improve work efficiency, reduce labor costs, and improve document quality. However, there are still some difficulties and challenges in the field of legal document generation. As a highly professional and structured document, legal documents usually need to follow strict format and element specifications.
[0003] Traditional AI-powered legal document generation technologies rely on template matching or simple rule deduction, making it difficult to handle complex legal scenarios and in-depth legal reasoning. These methods lack robust knowledge base support, especially when dealing with complex cases. The lack of background knowledge often causes the generated documents to overlook relevant legal provisions and document templates, resulting in insufficient legality and accuracy. Furthermore, existing knowledge bases are often static, unable to retrieve and utilize the latest legal information in real time during the generation process. Therefore, achieving efficient generation and personalized customization of legal documents is a pressing issue that needs to be addressed. Summary of the Invention
[0004] In view of the shortcomings of the existing technology, the purpose of this invention is to provide a structured legal document generation method and system based on large model and knowledge base enhancement, which can improve the readability of legal documents and provide users with a more intuitive reading experience.
[0005] To achieve the above objectives, the technical solution of the present invention includes the following:
[0006] A method for generating structured legal documents based on large models and knowledge base enhancement, the method comprising:
[0007] Based on user input, obtain the case description and document type;
[0008] Based on the case description, a legal knowledge base is retrieved to obtain a set of related legal provisions.
[0009] Based on the document type, a legal document template knowledge base is retrieved to obtain a set of legal document templates related to the document type;
[0010] Determine whether there exists a legal document template in the set of legal document templates that is suitable for the case description and is consistent with the document type;
[0011] In the case that there is a legal document template in the legal document template set that is suitable for the case description and consistent with the type of the document type, generating the legal document input by the user based on the user input, the set of associated legal provisions, and the legal document template.
[0012] Further, the case description and the document type are obtained according to the user input, including:
[0013] determining whether the text length of the user input is greater than a set threshold, and summarizing the user input whose text length is greater than the set threshold;
[0014] embedding the user input or the user input summary whose text length is less than the set threshold into an intent understanding prompt template, and generating the case description and the document type based on a large model; wherein the content of the intent understanding prompt template further includes: a first prompt.
[0015] Further, after retrieving the legal regulations knowledge base based on the case description to obtain a set of associated legal provisions related to the case description, further including:
[0016] embedding the case description, the document type, and any associated legal provision into a legal provision semantic analysis template, and generating a semantic analysis result of the associated legal provision based on a large model; wherein the content of the legal provision semantic analysis template further includes: a second prompt;
[0017] combining the semantic analysis result with the legal regulations application rules previously sorted by legal experts to construct a condition rule;
[0018] judging whether the associated legal provision is suitable for generating the legal document input by the user in combination with the condition rule;
[0019] in the case that the associated legal provision is not suitable for generating the legal document input by the user, deleting the associated legal provision from the set of associated legal provisions.
[0020] Further, retrieving a legal document template knowledge base based on the document type to obtain a set of legal document templates related to the document type, including:
[0021] generating a sparse vector and a dense vector of the document type;
[0022] performing hybrid vector retrieval on the legal document template knowledge base based on the sparse vector and the dense vector to obtain a set of legal document templates related to the document type.
[0023] Further, judging whether there is a legal document template in the legal document template set that is suitable for the case description and consistent with the type of the document type, including:
[0024] The case description, the type of document, and the legal document template set are embedded into a legal document template screening template, and it is judged based on a large model whether there is a legal document template in the legal document template set that is suitable for the case description and consistent with the type of document; wherein the content of the legal document template screening template further includes a third prompt.
[0025] Further, based on the user input, the associated law article set, and the legal document template, the legal document input by the user is generated, including:
[0026] The user input, the associated law article set, and the legal document template are embedded into a legal document generation template, and the legal document input by the user is generated based on a large model; wherein the content of the legal document generation template further includes a fourth prompt.
[0027] Further, the method further includes:
[0028] In the case where there is no legal document template in the legal document template set that is suitable for the case description and consistent with the type of document, network search is performed based on the type of document to obtain the latest document knowledge in the legal field;
[0029] The user input, the associated law article set, and the latest document knowledge in the legal field are embedded into a legal document generation template, and the legal document input by the user is generated based on a large model; wherein the content of the legal document generation template further includes a fourth prompt.
[0030] A structured legal document generation system based on a large model and knowledge base enhancement, the system comprising:
[0031] An intent understanding module for obtaining a case description and a document type according to user input;
[0032] A knowledge base retrieval module for retrieving a legal regulations knowledge base based on the case description to obtain an associated law article set related to the case description, and retrieving a legal document template knowledge base based on the type of document to obtain a legal document template set related to the type of document;
[0033] A document generation module for judging whether there is a legal document template in the legal document template set that is suitable for the case description and consistent with the type of document; in the case where there is a legal document template in the legal document template set that is suitable for the case description and consistent with the type of document, generating the legal document input by the user based on the user input, the associated law article set, and the legal document template.
[0034] An electronic device, comprising a processor and a memory storing computer program instructions; the processor implements the large model and knowledge base enhanced structured legal document generation method of any one of the above when executing the computer program instructions.
[0035] A computer readable storage medium, characterized in that the computer readable storage medium stores computer program instructions, and the computer program instructions are executed by a processor to implement the large model and knowledge base enhanced structured legal document generation method of any one of the above.
[0036] Compared with the prior art, the beneficial effects of the present application are that:
[0037] 1. The present application provides a structured legal document generation method based on large model and knowledge base retrieval, which provides rich document templates and legal knowledge for the large model through the strategy of combining knowledge base retrieval and network retrieval, effectively avoids excessive unintended associations of the large model in the generation process, and ensures the accuracy and legal compliance of the generated content.
[0038] 2. The present application provides a complete legal document generation method with a multi-path supplement strategy, which can flexibly cope with various different complex scenarios and needs. Compared with the single vector retrieval method, this method is supplemented by network retrieval and knowledge base retrieval, which improves the flexibility of the large model in generating legal documents and the ability to cope with complex case needs.
[0039] 3. The present application adopts the structured output of HTML language. The generated legal document not only has rich content and clear structure, but also includes elements such as title, paragraph, clause, etc. according to the predetermined structure, which is convenient for further processing and display in the later stage. BRIEF DESCRIPTION OF DRAWINGS
[0040] Figure 1 is the overall step flowchart of the method of the present application.
[0041] Figure 2 is the structural block diagram of the present application. DETAILED DESCRIPTION
[0042] The present application will be further described in detail below in conjunction with the accompanying drawings, and the examples are only used to explain the present application and are not used to limit the scope of the present application.
[0043] The application mainly responds to the user's demand for legal documents in a thinking chain manner, and significantly improves the quality and accuracy of legal document creation by comprehensively using document template knowledge base, legal regulation knowledge base, legal document knowledge base, network search, OCR technology and multi-task large model means to obtain external knowledge, and adjusting the style of the document by outputting structured legal documents in HTML language to improve the readability of legal documents and provide users with a more intuitive reading experience.
[0044] The structured legal document generation method based on large model and knowledge base enhancement of the application comprises the following steps 1 to 6. Figure 1
[0045] Step 1: According to the user input, the case description and the type of document are obtained.
[0046] According to the user input (including the user's description of the case and the user's instruction) and the first prompt, the case description, the user's instruction and the type of document are obtained by the intention understanding module.
[0047] Among them, the intention understanding is to determine the case description, the user's instruction and the specific type of document with detailed use according to the input first prompt by using the thinking chain reasoning. The main task of this step is to accurately identify the type of document that the user expects to generate, especially when the user's Query expression is not clear or the requirement is complex, the thinking chain reasoning can effectively improve the accuracy of answering complex questions, and ensure the correct identification of the type of document. When the length of the user input text is greater than the set threshold, the user input will be summarized to obtain the user's instruction and the specific type of document, so as to ensure the accuracy and efficiency of the subsequent processing.
[0048] In one embodiment, taking the user input as an example: "I am a landlord, tenant Xiao Wang owes me three months of rent, a total of 9000 yuan, I have urged him to pay many times, but he always delays, now I decide to sue him. Please help me write a complaint." According to the user input, the text length is first identified and judged. Since the text length is less than the threshold, the first prompt is input: "You are a professional legal assistant who analyzes and organizes
user input
case description
user instruction
public document type
user instruction
[0049] Step 2: Retrieve the relevant law article set based on the case description.
[0050] According to the case description, the application retrieves the legal regulations knowledge base through the knowledge base retrieval module, obtains the topk relevant law articles related to the case, and filters out the relevant law article set suitable for generating legal documents based on the semantic matching results of the large model and the legal regulations application rules pre-arranged by legal experts.
[0051] Specifically, the application retrieves the current effective legal regulations library according to the case description, recalls the topk relevant law articles related to the case, wherein the retrieval method includes keyword retrieval based on the case description or vector matching using the vector representation of the case description, and the application does not limit the retrieval method. Then, combined with the condition rules, judge whether the recalled law articles are suitable for the current document generation task. First, input the case description, target document type and recalled relevant law articles into the large language model, analyze the semantic content of the law articles, evaluate the matching degree of the case description and the recalled law articles from the dimensions of key facts, dispute points and user demands, and output the semantic matching results between the recalled law articles and the case description. Combined with the semantic matching results based on the large model and the legal regulations application rules pre-arranged by legal experts, construct the condition rules. The condition rules are determined by the semantic judgment of the large language model and the legal regulations application rules pre-arranged by legal experts. For example, when generating a civil judgment on the case of overdue repayment of the principal of a loan, the relevant law articles of the type of departmental rules cannot be cited for judgment and reasoning; when the user does not seek interest, the relevant law articles about the interest of overdue loans cannot be cited to guide the large model to generate legal documents.
[0052] In one embodiment, the application first retrieves the topk associated articles related to the user's description from the legal regulations library according to the user's case description, combines the large language model assisted judgment (second prompt) and the legal regulations application rules to filter out the associated article set suitable for generating legal documents, and splices according to the article name and specific item content. The associated article example is: Article 752 of the Civil Code of the People's Republic of China “The lessee shall pay the rent as agreed. If the lessee still does not pay the rent within a reasonable period of time after being urged, the lessor may request payment of the entire rent; also may terminate the contract and take back the lease.” Article 9 of the Supreme People's Court's Interpretation on the Application of Laws in the Trial of Financing Lease Contract Dispute Cases (2020 Amendment) “The lessee shall pay the rent as agreed. If the lessee still does not pay the rent within a reasonable period of time after being urged, the lessor may request payment of the entire rent; also may terminate the contract and take back the lease.”.
[0053] Step 3: Retrieving the legal document template knowledge base based on the document type to obtain a set of legal document templates related to the document type.
[0054] According to the obtained document type, the application generates its sparse vector and dense vector, and adopts a hybrid vector retrieval method to retrieve the topk legal document template candidate set most relevant to the document type from the legal document template knowledge base.
[0055] Specifically, the application uses a model based on Transformer (optional models such as BERT, BCE, BGE model, etc.) to convert it into sparse vector and dense vector representation respectively. The dense vector (dense embedding) pays more attention to the overall semantic information and captures the global features of the document type; while the sparse vector (sparse embedding) focuses on the local features and keywords of the document type, and can efficiently process detailed information. By storing the information of sparse vector and dense vector in the same collection, the richness and comprehensiveness of information dimension are ensured, which helps more accurate and efficient retrieval in the subsequent steps. Finally, combining the accuracy of the traditional sparse vector corresponding to the specific document type and the rich semantics of the dense vector, through the hybrid vector retrieval method, the topk most relevant document templates to the user's demand are obtained from the legal document template library, providing high-quality reference templates for subsequent generation.
[0056] In one embodiment, the present application employs a Transformer-based model to convert the user's desired type of official document "civil complaint (dispute over rental contract)" into a sparse vector and a dense vector representation, respectively, and then employs a hybrid vector retrieval method to filter out a topk set of official document templates highly related to the user's desired type of official document "civil complaint (dispute over rental contract)" from a legal official document template knowledge base, for example: Template 1: {'title': 'Civil Complaint (for civil litigation by citizens)', 'intro': 'This template is a complaint for civil litigation by citizens.'}; Template 2: {'title': 'Civil Complaint (for civil litigation by legal persons or other organizations)', 'intro': 'This template is a civil complaint for civil litigation by legal persons or other organizations.'}.
[0057] Among them, the construction of the legal official document template library is first to collect a large amount of legal official document template data from authoritative sources such as government open websites, and then to preprocess the data by combining professional legal personnel verification and automated means to ensure the high quality and consistency of the data. The specific steps of the data preprocessing process include:
[0058] 1) Check the legal official document template. For official documents containing pictures and tables in the format, use OCR technology to correctly parse them into editable text data and preserve the original style and layout of the text;
[0059] 2) For official documents containing multiple attachments, they will be split and each attachment will be stored in association with the main official document template to ensure the integrity and relevance of the attachment content, facilitating subsequent use and retrieval;
[0060] 3) All official document templates will be converted into HTML format for structured storage and subsequent display. The conversion of HTML format not only supports the diversified display of official document content, but also improves the understanding and parsing ability of the document generation system for the structure of official documents;
[0061] 4) Use text embedding technology based on Transformer model (optional models such as BERT, BCE, BGE model, etc.) to convert the specific type of legal official document into sparse vector and dense vector representation;
[0062] 5) Through the analysis of official document templates and their types, generate a brief introduction of each official document template. This introduction will clearly indicate which legal subjects (such as courts, lawyers, enterprises, etc.), case types (such as civil, criminal, administrative, etc.) and other important dimension information that the template is applicable to, in order to better match the user's needs.
[0063] 6) Store the fields of the official document template, the converted HTML format official document template, the official document brief and the vectorized official document type in the vector retrieval database (optional databases such as Elasticsearch, Milvus database, etc.).
[0064] 7) The legal official document template library will be updated continuously to adapt to the changing needs of users. On the one hand, by recording the queries and generating cases interacted with the user, the relevant information is regularly cleaned and stored in the official document template library, ensuring the timely updating and optimization of the template library. On the other hand, new legal official document templates will be collected regularly to further expand the template library and improve its coverage and applicability.
[0065] Step 4: Determine whether there is a legal official document template in the legal official document template set that is suitable for the case description and consistent with the type of the official document type.
[0066] The application further screens the topk legal official document templates retrieved, and according to the obtained official document type and the third prompt, uses the semantic matching method of case subject, case type and other characteristic dimensions to perform semantic matching between the case description input by the user and the specific official document type and the official document template recalled from the legal official document knowledge base (including its brief and official document type), attempts to screen out strongly related official document templates from the legal official document template candidate set, and finally outputs "template x" or "no". If the output is "template x", jump to step 5; if the output is "no", jump to step 6.
[0067] Step 5: In the case where there is a legal official document template in the legal official document template set that is suitable for the case description and consistent with the type of the official document type, generate the legal official document input by the user based on the user input, the associated law article set and the legal official document template.
[0068] The application will combine the user input, the strongly related legal official document template (HTML language), the fourth prompt ("generate the legal official document closely related to the input information, with accurate content and standardized format, according to
user input
official document template
associated law articles
[0069] Step 6: In the case where there is no legal official document template in the legal official document template set that is suitable for the case description and consistent with the type of the official document type, perform network according to the official document type to generate structured legal official documents.
[0070] According to the specific official document type input by the user, the present invention uses network search technology to recall top-k relevant official document knowledge, and uses a large language model to assist in judging whether the recalled official document knowledge is applicable to the current official document generation task. If it is applicable, it combines the relevant official document knowledge and associated legal articles to guide the large language model to generate structured legal official documents. The style decorations of the title, body text, and official document ending of the legal official document are as follows: The title is <div style="text-align:center;font-family:'微软雅黑';font-weight:bold;font-size:24px;">Civil complaint (dispute over a lease contract) ; The content of the body text is <div style="font-family:'微软雅黑';font-size:14px;"> <strong>Plaintiff:< / strong> Born on xx, xx, xxxx, of xx nationality, resident ID No. xxxxxxxxxxxxxx <div style="font-family:'微软雅黑';font-size:14px;"> <strong>Defendant:< / strong> Xiao Wang, born on xx month xx day, xx, of the xx nationality, resident ID number xxxxxxxxxxxxxx <div style="font-family:'微软雅黑';font-size:14px;"> <strong>Claims:< / strong> 1. Request the defendant to pay the total amount of RMB 9000 yuan of arrears of rent; 2. Request the defendant to pay the liquidated damages of RMB xxx yuan due to the delay in paying the rent; 3. The litigation costs of this case shall be borne by the defendant. <strong>Facts and reasons:< / strong> The plaintiff and the defendant signed a "House Lease Contract" on xx month xx, xxxx, stipulating that the defendant leases the house located at xxx of the plaintiff, with the lease term from xx month xx, xxxx to xx month xx, xxxx, and the monthly rent is 3,000 yuan. After the contract was signed, the plaintiff delivered the house to the defendant for use as agreed. However, since xx month, xxxx, the defendant has started to拖欠房租. The plaintiff has urged the defendant to pay the arrears of rent many times, but the defendant has delayed until now on various grounds. As of the date of filing the lawsuit, the defendant has累计拖欠原告 three months' rent totaling 9,000 yuan. ; The ending is <div style="text-align:right;font-family:'微软雅黑';font-size:14px;">Plaintiff: xxx\n Date: xxxx xx xx .
[0071] Based on the same concept, the present invention also provides a structured legal official document generation system based on a large model and knowledge base enhancement, as Figure 2 shown. The system includes: an intention understanding module, a knowledge base retrieval module, and an official document generation module.
[0072] The intention understanding module is used to obtain the case description and official document type according to the user input;
[0073] The knowledge base retrieval module is used to retrieve the laws and regulations knowledge base based on the case description to obtain a set of associated legal articles related to the case description; retrieve the legal official document template knowledge base based on the official document type to obtain a set of legal official document templates related to the official document type;
[0074] The official document generation module is used to judge whether there is a legal official document template in the set of legal official document templates that is suitable for the case description and is consistent with the official document type; in the case where there is a legal official document template in the set of legal official document templates that is suitable for the case description and is consistent with the official document type, generate the legal official document of the user input based on the user input, the set of associated legal articles, and the legal official document template.
[0075] The exemplary system is a device embodiment corresponding to the above exemplary method. The specific operations of each module can be understood by referring to the description of the method embodiment, and will not be elaborated here.
[0076] The above is only the embodiment of the present application, and the common knowledge of the specific structure and characteristics in the scheme is not described too much. It should be pointed out that for those skilled in the art, without departing from the structure of the present application, a number of modifications and improvements can also be made, which should also be considered as the protection scope of the present application, which will not affect the effect and practicality of the patent. The protection scope claimed in the present application should be subject to the content of its claims, and the specific implementation mode and the like recorded in the specification can be used to explain the content of the claims.
Claims
1. A structured legal document generation method based on large model and knowledge base enhancement, characterized in that, The method comprises: According to the user input, the case description and the type of official document are obtained; wherein, the user input, the case description and the type of official document are obtained according to the user input, comprising: Determine whether the text length of the user input is greater than a set threshold, and summarize the user input with a text length greater than a set threshold; Embed the user input with a text length less than a set threshold or the user input summary into an intent understanding prompt template, so that the large model analyzes and organizes the user input, extracts and summarizes the case description and the user instruction with the user expected type of official document, and then identifies and determines the required type of official document according to the user instruction; Based on the case description, retrieve the legal regulation knowledge base to obtain a set of related legal articles related to the case description; wherein, after retrieving the legal regulation knowledge base based on the case description to obtain a set of related legal articles related to the case description, it further comprises: Embed the case description, the type of official document and any related legal article into a legal article semantic analysis template, and generate the semantic analysis result of the related legal article based on the large model; wherein, the content of the legal article semantic analysis template further comprises: a second prompt; Combine the semantic analysis result with the legal regulation application rules previously organized by legal experts to construct a conditional rule; Determine whether the related legal article is suitable for generating the legal official document of the user input in combination with the conditional rule; In the case where the related legal article is not suitable for generating the legal official document of the user input, delete the related legal article from the set of related legal articles; Based on the type of official document, retrieve the legal official document template knowledge base to obtain a set of legal official document templates related to the type of official document; wherein, the construction process of the legal official document template knowledge base comprises: Collect legal official document templates; For official document templates containing pictures and tables in the format, use OCR technology to parse the pictures and tables into editable text data and preserve the original style and layout of the official document template; For official document templates containing multiple attachments, split the official document template and store each attachment in association with the official document template; Convert all official document templates into HTML format; Based on text embedding technology, convert the type of official document template into sparse vector representation and dense vector representation; Through analysis of the official document template and its type, generate a brief introduction of the official document corresponding to each official document template, which clearly indicates the legal subject and case type to which the official document template is applicable; Store the official document template, the converted HTML format official document template, the brief introduction of the official document and the sparse vector representation and dense vector representation in the vector retrieval database to obtain the legal official document template knowledge base; Determine whether there is a legal official document template in the set of legal official document templates that is suitable for the case description and consistent with the type of official document; In the case where there is a legal official document template in the set of legal official document templates that is suitable for the case description and consistent with the type of official document, generate the legal official document of the user input based on the user input, the set of related legal articles and the legal official document template. In the case where there is no legal document template suitable for the case description and consistent with the type of the document type in the legal document template set, a network search is performed based on the document type to obtain the latest document knowledge in the legal field; the user input, the set of associated legal articles, and the latest document knowledge in the legal field are embedded into a legal document generation template, and a legal document of the user input is generated based on a large model; wherein the content of the legal document generation template further includes a fourth prompt.
2. The method of claim 1, wherein, Retrieving a legal document template knowledge base based on the document type obtains a set of legal document templates related to the document type, including: Generating a sparse vector and a dense vector of the document type; Performing hybrid vector retrieval on the legal document template knowledge base based on the sparse vector and the dense vector to obtain a set of legal document templates related to the document type.
3. The method of claim 1, wherein, Determine whether there is a legal document template suitable for the case description and consistent with the type of the document type in the legal document template set, including: Embedding the case description, the document type, and the set of legal document templates into a legal document template screening template, and determining whether there is a legal document template suitable for the case description and consistent with the type of the document type in the legal document template set based on a large model; wherein the content of the legal document template screening template further includes a third prompt.
4. The method of claim 1, wherein, Generating a legal document of the user input based on the user input, the set of associated legal articles, and the legal document template, including: Embedding the user input, the set of associated legal articles, and the legal document template into a legal document generation template, and generating a legal document of the user input based on a large model; wherein the content of the legal document generation template further includes a fourth prompt.
5. A structured legal document generation system based on large model and knowledge base enhancement, characterized in that, The system includes: an intent understanding module for obtaining a case description and a document type according to a user input; A knowledge base retrieval module for retrieving a legal and regulatory knowledge base based on the case description to obtain a set of associated legal articles related to the case description; retrieving a legal document template knowledge base based on the document type to obtain a set of legal document templates related to the document type; The official document generation module is configured to determine whether a legal official document template suitable for the case description and consistent with the type of the official document exists in the set of legal official document templates; in the case where a legal official document template suitable for the case description and consistent with the type of the official document exists in the set of legal official document templates, generate the legal official document input by the user based on the user input, the set of associated legal provisions, and the legal official document template; in the case where a legal official document template suitable for the case description and consistent with the type of the official document does not exist in the set of legal official document templates, perform a network search based on the type of the official document to obtain the latest official document knowledge in the legal field; embed the user input, the set of associated legal provisions, and the latest official document knowledge in the legal field into a legal official document generation template, and generate the legal official document input by the user based on a large model; wherein the content of the legal official document generation template further includes a fourth prompt; The method further includes: determining whether the length of the text input by the user is greater than a set threshold, and summarizing the user input whose length of the text is greater than the set threshold; embedding the user input whose length of the text is less than the set threshold or the summary of the user input into an intent understanding prompt template, so that the large model analyzes and organizes the user input, extracts and summarizes the case description and the user instruction with the user's desired document type, and then identifies and determines the required type of official document according to the user instruction; after retrieving the legal regulation knowledge base based on the case description to obtain a set of associated legal provisions related to the case description, the method further includes: embedding the case description, the type of official document, and any associated legal provision into a legal provision semantic analysis template, and generating a semantic analysis result of the associated legal provision based on a large model; wherein the content of the legal provision semantic analysis template further includes a second prompt; combining the semantic analysis result with the legal regulation application rules pre-organized by legal experts to construct a conditional rule; determining whether the associated legal provision is suitable for generating the legal official document input by the user in combination with the conditional rule; in the case where the associated legal provision is not suitable for generating the legal official document input by the user, deleting the associated legal provision from the set of associated legal provisions; The method further includes: collecting legal official document templates; for official document templates containing pictures and tables in the format, using OCR technology to analyze the pictures and tables into editable text data and preserving the original style and layout of the official document template; for official document templates containing multiple attachments, splitting the official document template and storing each attachment in association with the official document template; unifying all official document templates into HTML format; based on text embedding technology, converting the type of the official document template into sparse vector representation and dense vector representation; by analyzing the official document template and its type, generating a brief introduction of the official document corresponding to each official document template, which clearly indicates the legal subject and case type to which the official document template is applicable. The official document template, the converted HTML format official document template, the official document brief, and the sparse vector representation and the dense vector representation are stored in a vector retrieval database, to obtain the legal official document template knowledge base.
6. An electronic device, comprising: The electronic device comprises a processor and a memory storing computer program instructions; the processor executes the computer program instructions to implement the structured legal official document generation method based on a large model and a knowledge base enhancement according to any one of claims 1-4.
7. A computer-readable storage medium, characterized in that, The computer readable storage medium stores computer program instructions, and the computer program instructions are executed by the processor to implement the structured legal official document generation method based on a large model and a knowledge base enhancement according to any one of claims 1-4.
Citation Information
Patent Citations
Medical document generation method and device, electronic equipment and storage medium
CN117393099A
Structured data question and answer method and device and medium
CN118349654A