A method for intelligent drafting of legal documents based on a large language model

By using structured parsing and normalization of a large language model, combined with content fingerprint deduplication and relevance judgment, the problems of inaccurate legal citation and insufficient document type adaptability in existing technologies are solved, thus achieving high-quality automated drafting of legal documents.

CN123115372APending Publication Date: 2026-11-17SHANGHAI ZHIHE NETWORK TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611057259.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-16
Publication Date
2026-11-17

AI Technical Summary

Technical Problem

Existing automated legal document drafting methods are insufficient in terms of the accuracy of legal citations and the differentiation of document generation for various types, making it difficult to adapt to the complex and ever-changing needs of actual cases, resulting in a lack of professionalism and rigor in the generated documents.

Method used

The system employs a large language model for structured parsing and standardization of legal citations, combined with content fingerprint deduplication and relevance assessment, to improve the accuracy of legal citations and generate differentiated citations based on document category.

Benefits of technology

The accuracy of legal citations has been improved, duplicate citations have been eliminated, and the generated legal documents have been improved in terms of content accuracy and type suitability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123115372A_ABST
    Figure CN123115372A_ABST
Patent Text Reader

Abstract

This invention discloses an intelligent legal document drafting method based on a large language model, belonging to the field of artificial intelligence technology. The main steps include: receiving instructions containing document fragments and document categories; merging the fragmented text and then calling a legal retrieval large language model for structured parsing; generating a retrieval task list through abbreviation restoration, batch article splitting, and old law replacement; performing vector retrieval for each task to obtain candidate legal entries; excluding similarity scores, using a frozen set generated from an attribute dictionary as a content fingerprint for cross-batch deduplication, retaining the first-appearing legal entry; inputting the deduplication results into a relevance judgment large language model for Boolean filtering to filter irrelevant entries; and finally generating and returning legal documents based on document category routing. This invention improves the accuracy and relevance of legal citations in legal documents, avoids duplicate citations, and generates more adaptable legal documents by combining document category routing.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of artificial intelligence technology, specifically to a method for intelligent drafting of legal documents based on a large language model. Background Technology

[0002] Currently, the drafting of legal documents mainly relies on manual writing by lawyers or legal professionals, with the support of some auxiliary tools. Existing automated methods typically combine rule engines with template filling; after users input case information according to a preset document structure, the system fills the information into a fixed template to generate a preliminary document. However, this method based on fixed rules and templates lacks flexibility and struggles to adapt to the complex and ever-changing needs of actual cases, especially when a case involves multiple unstructured materials (such as party statements, scanned evidence, chat logs, etc.). Template filling methods cannot automatically extract and understand legal citation information from these materials. In recent years, some researchers have attempted to apply large language models to legal document generation, directly generating the full text of the document by inputting a case description into the model. However, general-purpose large language models have significant shortcomings in the legal field: on the one hand, they often fail to accurately identify and standardize abbreviations of regulations, batch citations of articles, and old laws absorbed by the Civil Code when processing materials, leading to errors in the generated regulatory retrieval tasks; on the other hand, regulation retrieval based on vector similarity easily recalls semantically similar but substantively unrelated articles, and when multiple retrieval tasks exist, different tasks may recall the same regulatory entries, resulting in duplicate regulatory citations in documents and affecting the professionalism and rigor of the documents. Furthermore, existing systems tend to use similar generation methods for different types of legal documents (such as complaints, answers, and cross-examination opinions), failing to specifically design for the unique drafting specifications of each type of document (such as the need for prior identification of the holding party in cross-examination opinions), resulting in a low degree of fit between the generated content and the document type requirements. Therefore, how to improve the accuracy of regulatory citations in the automatic drafting of legal documents, eliminate redundancy in retrieval results, and achieve differentiated and specialized generation for multiple types of documents are urgent technical problems to be solved in this field. Summary of the Invention

[0003] To improve the accuracy of legal citations in automatic legal document drafting, eliminate redundancy in search results, and achieve differentiated generation of various document types, this invention proposes an intelligent legal document drafting method based on a large language model, comprising the following steps:

[0004] S1: Receive document drafting instruction data sent by the terminal device, wherein the instruction data includes a list of file fragment identifiers and a document category identifier;

[0005] S2: Retrieve the text of each file segment corresponding to the file segment identifier list and merge them into a unified context text;

[0006] S3: Call the legal retrieval big language model to perform structured parsing of legal citations in the unified context text, extract legal name retrieval vectors and article numbers, standardize and restore commonly used abbreviations, split batch article citations, uniformly replace old laws absorbed by the Civil Code, and output a structured legal retrieval task list.

[0007] S4: Perform vector retrieval for each task in the list of regulatory retrieval tasks to obtain candidate regulatory entries with embedded similarity scores;

[0008] S5: After excluding the similarity score of each candidate regulation entry, construct an attribute dictionary and convert it into a frozen set as a content fingerprint. Iterate through all candidate regulation entries, retain the regulation entry corresponding to the first occurrence of the content fingerprint, and discard subsequent regulation entries with the same fingerprint.

[0009] S6: Input the deduplicated and retained regulatory entries into the relevance judgment large language model in batches, obtain the Boolean judgment result of whether each regulatory entry is related to the unified context text, and filter out the regulatory entries judged as irrelevant.

[0010] S7: Based on the document category identifier, route to the corresponding specialized document generation branch, generate legal document text, and return it to the terminal device.

[0011] This invention improves the accuracy and relevance of legal citations in drafting legal documents by using structured parsing and standardized processing of legal citations, cross-batch deduplication based on content fingerprints, and secondary screening based on relevance judgment. It also enables differentiated automatic generation based on document category.

[0012] Furthermore, in step S1, the terminal device also sends a query instruction input by the user, which is natural language text describing the user's content requirements, drafting requirements, and specific issues for the required legal documents.

[0013] Furthermore, in step S2, when the number of file fragments corresponding to the file fragment identifier list exceeds a preset threshold, a file fragment retrieval step is also included:

[0014] The system calls a large language model to perform semantic analysis on the user's input query command, generates search keywords, performs vector similarity retrieval on file fragments based on the search keywords, retrieves a preset number of file fragments with the highest similarity, and integrates the search results into the unified context text.

[0015] Furthermore, in step S2, an asynchronous multi-threaded concurrent call mechanism is used when obtaining the text fragments of each file.

[0016] Furthermore, in step S3, the legal retrieval language model is set to output in JSON format, and when the article number is detected to be in Arabic numeral format, the article number is converted to Chinese numeral format.

[0017] Furthermore, in step S5, constructing the attribute dictionary and converting it into a frozen set as a content fingerprint specifically involves:

[0018] For each candidate regulation entry, remove the similarity score key-value pairs from the candidate regulation entry, and convert the remaining key-value pairs into frozensets as content fingerprints.

[0019] Furthermore, in step S6, the relevance judgment large language model is set to output in Boolean format.

[0020] Furthermore, in step S7, the document category identifiers include complaints, answers, appeals, agency statements, lawyer's letters, applications for retrial, applications for enforcement, cross-examination opinions, and general documents. When the document category identifier is cross-examination opinions, the holder is inferred based on the holder's statement or unified context text input by the user before generating the legal document text, and the holder's conclusion is passed as an implicit parameter to the subsequent generation process.

[0021] Compared with the prior art, the present invention has at least the following beneficial effects:

[0022] (1) The present invention proposes a legal document intelligent drafting method based on a large language model. Through structured parsing and standardized processing of legal citations, it can more accurately extract executable legal retrieval tasks from unstructured texts and reduce retrieval errors caused by diversity of expression and non-standard format.

[0023] (2) By constructing a content fingerprint after excluding similarity scores from the vector retrieval results, cross-batch deduplication is performed, which effectively eliminates duplicate citations caused by recalling the same regulations in different retrieval tasks;

[0024] (3) The relevance judgment big language model is used to perform a second screening of the deduplicated legal entries, and only the entries that match the specific case background are retained, thereby improving the case relevance of the cited legal provisions;

[0025] (4) Routing to the corresponding special generation branch according to the document category identifier, and identifying and anchoring the pre-requisite holders of specific documents such as cross-examination opinions, so that the generated legal documents are improved in terms of content accuracy and type adaptability. Attached Figure Description

[0026] Figure 1 This is a flowchart illustrating the steps of an intelligent legal document drafting method based on a large language model. Detailed Implementation

[0027] The following are specific embodiments of the present invention, which are described in conjunction with the accompanying drawings. However, the present invention is not limited to these embodiments.

[0028] In the field of legal document drafting, traditional automated tools mainly rely on fixed template filling or keyword-based legal retrieval. Template filling can only generate documents with a fixed format, unable to flexibly adjust the content according to the specific circumstances of the case, and the legal citations still require manual searching and input. Keyword-based legal retrieval suffers from insufficient semantic understanding capabilities; different expressions of the same legal concept often lead to incomplete or inaccurate search results, requiring users to manually select applicable legal provisions from multiple search results. In recent years, some solutions have attempted to introduce large language models for legal document generation, but these solutions usually treat legal retrieval as an auxiliary step in document generation, lacking systematic verification and deduplication of search results, resulting in generated documents prone to problems such as duplicate legal citations and irrelevant citations. Furthermore, existing solutions often adopt a uniform generation strategy for different types of legal documents, making it difficult to meet the differentiated requirements of complaint, answer, and cross-examination opinions in terms of argumentation logic and format specifications. To address the aforementioned technical problems, this invention proposes an intelligent legal document drafting method based on a large language model. This method achieves high-quality automated drafting of legal documents through a technical path that includes structured parsing of legal citations, concurrent vector retrieval, content fingerprint deduplication, relevance verification, and categorized multi-stage generation. Figure 1 As shown, the method mainly includes the following steps:

[0029] S1: Receive document drafting instruction data sent by the terminal device, wherein the instruction data includes a list of file fragment identifiers and a document category identifier;

[0030] S2: Retrieve the text of each file segment corresponding to the file segment identifier list and merge them into a unified context text;

[0031] S3: Call the legal retrieval big language model to perform structured parsing of legal citations in the unified context text, extract legal name retrieval vectors and article numbers, standardize and restore commonly used abbreviations, split batch article citations, uniformly replace old laws absorbed by the Civil Code, and output a structured legal retrieval task list.

[0032] S4: Perform vector retrieval for each task in the list of regulatory retrieval tasks to obtain candidate regulatory entries with embedded similarity scores;

[0033] S5: After excluding the similarity score of each candidate regulation entry, construct an attribute dictionary and convert it into a frozen set as a content fingerprint. Iterate through all candidate regulation entries, retain the regulation entry corresponding to the first occurrence of the content fingerprint, and discard subsequent regulation entries with the same fingerprint.

[0034] S6: Input the deduplicated and retained regulatory entries into the relevance judgment large language model in batches, obtain the Boolean judgment result of whether each regulatory entry is related to the unified context text, and filter out the regulatory entries judged as irrelevant.

[0035] S7: Based on the document category identifier, route to the corresponding specialized document generation branch, generate legal document text, and return it to the terminal device.

[0036] In practical applications, the intelligent legal document drafting method proposed in this invention can be deployed on a server-side system with data processing capabilities, communicating with terminal devices via application programming interfaces (APIs) or web servers. The terminal devices can be personal computers, tablets, or smartphones used by lawyers or legal professionals. Users access the document drafting services provided by the system through client applications or browsers running on their terminal devices.

[0037] When a user needs to draft a legal document, they first perform necessary operations on the terminal device's interface, including selecting the document type to be drafted, uploading case-related documents, and entering a query command text describing their specific needs. The terminal device generates structured document drafting command data based on the user's actions and sends this data to the server's data processing engine via the network. This command data includes at least a document category identifier field, a user identity identifier, the query command text, a list of file fragment identifiers, a collection of related files, and dialogue history round identifiers. The file fragment identifier list points to the various file fragments uploaded by the user. Each file fragment typically corresponds to a part of a document or a smaller, complete document. This fragmentation design facilitates batch processing and concurrent operations on large-scale files. The document category identifier clarifies the target document type the user expects to generate, such as a complaint, answer, appeal, attorney's letter, lawyer's letter, application for retrial, application for enforcement, or cross-examination opinion.

[0038] After receiving the drafting instruction data, the server first parses and verifies each field in the instruction data to ensure that necessary fields are complete and correctly formatted. Then, it enters the file content preprocessing stage. The data processing engine sends requests to the file repository service sequentially based on the file segment identifier list to obtain the full-text content and corresponding metadata of each segment. Considering that user-uploaded documents in legal practice are often numerous and large in volume, the system adopts an asynchronous multi-threaded concurrent call mechanism to perform file retrieval operations to improve processing efficiency. Specifically, the system processes the identifiers in the file segment identifier list in batches, with a maximum of one hundred segment identifiers processed per batch, and a maximum of ten concurrent threads. This design fully utilizes the server's network input / output resources while avoiding overloading the file repository service or triggering frequency limits due to excessive concurrency. After retrieving the text content of each file segment, the system also calls a large language model to extract core information from that segment, generating a structured contextual summary so that subsequent processing can more efficiently focus on key legal information. For fields in the file metadata that may contain related content, the system will identify their existence through conditional judgment nodes and trigger a supplementary retrieval process upon detection to ensure that no supporting materials related to the case are overlooked. After all the text content of all segments has been acquired and processed, the system will merge the text of each segment into a complete unified context text through variable aggregation nodes. This text contains all the valid information from the user-uploaded file materials, providing a complete background material foundation for subsequent legal retrieval and document generation.

[0039] To address situations where the number of files exceeds the standard processing threshold, the system also incorporates a file fragment retrieval mechanism as an enhancement. When the system detects that the number of fragments in the file fragment identifier list exceeds a preset threshold, it automatically triggers a fragment retrieval sub-process. In this sub-process, the large language model first analyzes the user's input query text to understand the content the user needs to focus on, determining the scope of files to be retrieved and the key elements to be searched. Subsequently, the batch processing slice node performs JSON serialization on each file fragment and calls the fragment vector retrieval plugin to retrieve the most relevant file segments from the file fragments based on the analyzed key elements. The code processing node integrates these fragment retrieval results into a unified context text, enabling the system to accurately focus on the most relevant information paragraphs even if the original uploaded file contains a large amount of material with low relevance to the core requirements, avoiding the dilution of the weight of key information due to excessively long context.

[0040] After obtaining the complete unified context text, the system enters the structured parsing phase of legal citations. The core of this phase involves invoking a specially configured large-scale legal retrieval language model. This model is configured for legal retrieval and analysis, extracting key functions for standardized legal retrieval tasks from unstructured text. The data processing engine inputs the merged unified context text and the user's original query command text into this large-scale language model, requiring the model to output results according to a preset structured format.

[0041] The legal retrieval big language model performs several normalization operations during processing. Specifically, for various legal citations appearing in the context, the model extracts a retrieval vector for each legal name, with the character length of this vector typically limited to thirty characters to ensure retrieval efficiency. Article numbers are processed according to a mandatory standardized format, represented in Chinese numerals; for example, "Article 115" is standardized to "Article 115". For the document number field, the model only extracts it if the citation only contains the document number and not the legal name or issuing authority information; otherwise, the field is left empty to avoid information redundancy. The model also extracts the geographical limitations of the applicable laws and their level of validity codes. When processing batches of article citations, the model automatically performs a splitting operation, decomposing complex citations into multiple independent retrieval tasks, each corresponding to a specific article. For commonly used abbreviations in legal practice, the model has built-in normalization rules to restore simplified names to their full forms. Considering that the original Marriage Law, Contract Law, Guarantee Law, Property Law, and other separate laws have been absorbed after the promulgation of the Civil Code, the model automatically replaces the retrieval vectors of these old laws with those of the Civil Code of the People's Republic of China, ensuring that the search results reflect the currently effective legal system. The model ultimately outputs a structured list of legal retrieval tasks in JSON array format. Each element in the array contains five fields: legal name retrieval vector, article number, document number, geographical limitation, and validity level code, for use in subsequent vector retrieval stages. Simultaneously, the model's output is forcibly set to structured JSON format, prohibiting empty strings in the output content. The maximum number of output tokens is set to 32,768, and the reasoning strategy disables the thought chain mode to ensure the simplicity and determinism of the output results. The data processing engine also verifies the completeness of the model's output. When Arabic numerals are detected in the article number field, format correction processing is triggered to convert them to Chinese numerals.

[0042] After constructing the list of legal retrieval tasks, the system enters the concurrent vector retrieval and cross-batch deduplication phase. For each retrieval task in the list, the data processing engine employs an asynchronous multi-threaded concurrent call mechanism similar to the file acquisition phase, with a batch size limit of one hundred and a concurrent execution limit of ten, sending retrieval requests to a pre-deployed legal vector search plugin. This plugin is specifically optimized for vectorization of legal text, enabling rapid matching based on the semantic similarity of the legal title or body text. A minimum similarity threshold is set in the retrieval request, for example, 0.8, meaning that only legal entries with a similarity score of 0.8 or higher will be included in the result set. Each retrieval task returns a maximum of two results, selecting the two legal entries with the highest similarity. This ensures that potentially relevant legal entries are retrieved while avoiding a large number of low-quality results that burden subsequent processing.

[0043] After aggregating the search results from each batch, the system obtains a set of candidate legal entries returned by multiple search tasks. A significant problem at this point is that different search tasks may have retrieved the same clause from the same legal document. Simply retaining all these entries would lead to duplicate citations of the same clause in the final document, affecting its quality. To address this issue, the system employs a content fingerprint deduplication mechanism. Specifically, for each candidate legal entry, the system first copies its content dictionary and then excludes the similarity score key-value pair. This is because the similarity score can vary depending on the matching calculations of different search tasks, but the substantive content and other attributes of the legal entry are unique. After excluding the score, the remaining key-value pair set is converted into a frozen set type as the content fingerprint of that entry. The system maintains a container for seen fingerprints. It iterates through all candidate legal entries, calculating the content fingerprint for each entry. If the fingerprint does not yet exist in the seen set, the entry is added to the final retention list, and its fingerprint is added to the seen set; otherwise, the entry is discarded. This deduplication method is independent of the specific value of the similarity score. It can accurately identify legal entries with completely identical content. Regardless of which search task they were retrieved from or how many similarity scores they were retrieved from, they will only be retained once, thereby eliminating the duplication phenomenon in cross-batch search results.

[0044] While the deduplicated list of regulations after fingerprinting eliminates content repetition, a problem remains: vector retrieval is based on semantic similarity. Retrieved regulations may be semantically similar to the user's background materials, but not necessarily substantially relevant to the specific case. For example, a document discussing housing sales contract disputes might retrieve general provisions on sales contracts, but also provisions on housing rentals. While the latter is related to housing and semantically close, it's not directly applicable to specific sales contract disputes. To address this, the system incorporates a multi-round regulation relevance verification phase. In this phase, the data processing engine inputs each item from the deduplicated merged list of regulations into a large relevance judgment language model using a concurrent batch processing mechanism. This model is configured to determine the matching degree between each regulation item and the specific case based on all background materials provided by the user. The model is configured to force JSON output, with a fixed output structure of key-value pairs containing Boolean relevance conclusions, prohibiting any explanations or other content to ensure conciseness and parsability. After receiving the model output, the data processing engine appends the relevance labeling field back to the original entry object via the code processing node. The system then runs a filtering node, retaining only entries with a true relevance label and removing those deemed irrelevant from the list. Considering potential timeouts or temporary errors in online service calls, the system also incorporates a fault-tolerance mechanism. When a timeout or error occurs during the relevance judgment's large language model call, a backup model is automatically activated for retrying. The maximum number of retries is set to one. The backup model uses a lightweight configuration with the lowest inference effort setting to ensure the system can still complete the relevance judgment task even under abnormal circumstances.

[0045] After the aforementioned legal retrieval, deduplication, and relevance verification processes, the system obtains a rigorously selected list of valid legal entries that highly match the user's case. At this point, the system enters the document category routing and multi-stage specialized generation phase. The data processing engine reads the document category identifier field from the user's instruction data and routes the execution flow to the corresponding specialized document generation branch through multi-level conditional judgment nodes. The system supports at least nine branches: complaint, answer, appeal, attorney's letter, retrial application, enforcement application, cross-examination opinion, and general documents. For instructions that do not match any specific category, the system automatically routes to the general document generation node, which determines whether to use the first-round generation mode or the follow-up question mode based on the value of the dialogue history round identifier field. For the complaint branch, the system executes a multi-stage pipeline: First, it performs fact-finding, extracting basic factual elements of the case from background materials; then, it generates the points of contention and search elements, clarifying the core issues in dispute and keywords requiring further retrieval; next, it performs concurrent vector retrieval to obtain relevant legal basis; then, it performs legal compatibility verification to ensure that the recalled regulations match the case facts and points of contention; finally, it enters the document text generation stage, outputting a complete complaint. The response branch adds a pre-stage of respondent identification before fact-finding, because the response needs to first identify the respondent, and this identification result will be used throughout the entire generation process. Branches such as appeals, attorney's statements, lawyer's letters, applications for retrial, and applications for enforcement each have their own specialized generation logic, customized to the format requirements and content characteristics of different documents.

[0046] Taking the cross-examination opinion branch as an example, this branch performs the party identification and anchoring steps before document generation. Cross-examination opinions differ from other legal documents; their argumentation angle depends entirely on whether the writer is the plaintiff or the defendant in the litigation process. The same piece of evidence, examined from different parties' perspectives, may have significantly different argumentation logic and expression. The system first determines whether the user instruction explicitly includes statements such as "on behalf of a certain party" or "representing a certain party." If the party is clearly identified, that party's identity is locked as the party for full-text argumentation. If the party is not clearly identified, the system automatically infers the party based on litigation identity clues in the background materials, such as identifying the litigation status of the parties from the complaint or answer draft. The inference conclusion is marked at the beginning of the document. The party anchoring conclusion, as an implicit parameter, runs through the entire process of subsequent application of evidence rules, selection of cross-examination angles, and construction of argumentation strategies, ensuring that the generated cross-examination opinions maintain consistency in their argumentation direction from beginning to end.

[0047] In all specialized document generation branches, the system fully utilizes previously verified lists of valid legal entries, integrating them as legal basis into the relevant sections of the document to ensure that the generated document is both accurate and relevant in terms of legal citation. During document generation, the system also comprehensively considers the user's input query text and dialogue history information, enabling it to ask follow-up questions and supplement information based on the context of multiple rounds of dialogue, further improving the alignment of the generated document with the user's expectations. The final generated legal document text data is returned to the terminal device via the network, presenting the complete document content on the user interface for the user to review, edit, and confirm.

[0048] In summary, this invention, through structured parsing and standardized processing of legal citations (including restoration of commonly used abbreviations, batch splitting of articles, and unified replacement of old laws), can more accurately extract executable legal citation tasks from unstructured text, reducing retrieval errors caused by diverse expressions and non-standard formats. By constructing content fingerprints from vector retrieval results after excluding similarity scores for cross-batch deduplication, it effectively eliminates duplicate citations caused by different retrieval tasks recalling the same regulations. On this basis, a large language model for relevance judgment is used to further filter the deduplicated legal entries, retaining only those that match the specific case background, thereby improving the case relevance of the cited regulations. At the same time, routing to the corresponding specialized generation branch based on document category identifiers and identifying and anchoring the pre-holding parties of specific documents such as cross-examination opinions improves the accuracy and type suitability of the generated legal documents.

[0049] It should be noted that all directional indications (such as up, down, left, right, front, back, etc.) in the embodiments of the present invention are only used to explain the relative positional relationship and movement of each component in a certain specific posture (as shown in the figure). If the specific posture changes, the directional indication will also change accordingly.

[0050] Furthermore, in this invention, descriptions involving terms such as "first," "second," and "a" are for descriptive purposes only and should not be construed as indicating or implying their relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of that feature. In the description of this invention, "a plurality of" means at least two, such as two, three, etc., unless otherwise explicitly specified.

[0051] In this invention, unless otherwise explicitly specified and limited, the terms "connection," "fixed," etc., should be interpreted broadly. For example, "fixed" can mean a fixed connection, a detachable connection, or an integral part; it can mean a mechanical connection or an electrical connection; it can mean a direct connection or an indirect connection through an intermediate medium; it can mean the internal communication of two components or the interaction between two components, unless otherwise explicitly limited. Those skilled in the art can understand the specific meaning of the above terms in this invention according to the specific circumstances.

[0052] Furthermore, the technical solutions of the various embodiments of the present invention can be combined with each other, but only if they are feasible for those skilled in the art. If the combination of technical solutions is contradictory or cannot be implemented, it should be considered that such combination of technical solutions does not exist and is not within the scope of protection claimed by the present invention.

Claims

1. A large language model-based legal document intelligent drafting method, characterized in that, Including the following steps: S1: Receive document drafting instruction data sent by the terminal device, wherein the instruction data includes a file fragment identifier list and a document category identifier; S2: Retrieve the text of each file segment corresponding to the file segment identifier list and merge them into a unified context text; S3: Call the legal retrieval big language model to perform structured parsing of legal citations in the unified context text, extract legal name retrieval vectors and article numbers, standardize and restore commonly used abbreviations, split batch article citations, uniformly replace old laws absorbed by the Civil Code, and output a structured legal retrieval task list. S4: Perform vector retrieval for each task in the list of regulatory retrieval tasks to obtain candidate regulatory entries with embedded similarity scores; S5: After excluding the similarity score of each candidate regulation entry, construct an attribute dictionary and convert it into a frozen set as a content fingerprint. Iterate through all candidate regulation entries, retain the regulation entry corresponding to the first occurrence of the content fingerprint, and discard subsequent regulation entries with the same fingerprint. S6: Input the deduplicated and retained regulatory entries into the relevance judgment large language model in batches, obtain the Boolean judgment result of whether each regulatory entry is related to the unified context text, and filter out the regulatory entries judged as irrelevant. S7: Based on the document category identifier, route to the corresponding specialized document generation branch, generate legal document text, and return it to the terminal device.

2. The legal document intelligent drafting method based on a large language model according to claim 1, characterized in that, In step S1, the terminal device also sends a query instruction input by the user. The query instruction is natural language text describing the user's content requirements, drafting requirements, and specific issues for the required legal documents.

3. The intelligent drafting method for legal documents based on a large language model as described in claim 2, characterized in that, In step S2, when the number of file fragments corresponding to the file fragment identifier list exceeds a preset threshold, a file fragment retrieval step is also included: The system calls a large language model to perform semantic analysis on the user's input query command, generates search keywords, performs vector similarity retrieval on file fragments based on the search keywords, retrieves a preset number of file fragments with the highest similarity, and integrates the search results into the unified context text.

4. The intelligent drafting method for legal documents based on a large language model as described in claim 1, characterized in that, In step S2, an asynchronous multi-threaded concurrent call mechanism is used to obtain the text fragments of each file.

5. The intelligent drafting method for legal documents based on a large language model as described in claim 1, characterized in that, In step S3, the legal retrieval language model is set to output in JSON format. When the article number is detected to be in Arabic numeral format, it is converted to Chinese numeral format.

6. The intelligent drafting method for legal documents based on a large language model as described in claim 1, characterized in that, In step S5, constructing the attribute dictionary and converting it into a frozenset as a content fingerprint specifically involves: For each candidate regulation entry, remove the similarity score key-value pairs from the candidate regulation entry, and convert the remaining key-value pairs into frozensets as content fingerprints.

7. The intelligent drafting method for legal documents based on a large language model as described in claim 1, characterized in that, In step S6, the relevance judgment large language model is set to output in Boolean format.

8. The intelligent drafting method for legal documents based on a large language model as described in claim 1, characterized in that, In step S7, the document category identifiers include complaint, answer, appeal, agency statement, lawyer's letter, application for retrial, application for enforcement, cross-examination opinion, and general document; when the document category identifier is cross-examination opinion, the holder is inferred based on the holder's statement or unified context text entered by the user before generating the legal document text, and the holder's conclusion is passed as an implicit parameter to the subsequent generation process.