An intelligent legal document automated generation system

The intelligent legal document automated generation system utilizes the BERT-CRF architecture and K-Means++ clustering algorithm to construct a knowledge graph, achieving efficient and accurate legal document generation and solving the problems of low efficiency and high risk in traditional manual processing.

CN120850987BActive Publication Date: 2025-12-02HANGZHOU HANZI INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511353952.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-09-22
Publication Date
2025-12-02
Estimated Expiration
2045-09-22

AI Technical Summary

Technical Problem

Existing technologies rely on manual processing in legal document generation, which suffers from low generation efficiency, template matching errors, high legal risks, and a lack of structured integration and dynamic correlation capabilities.

Method used

An intelligent legal document automated generation system is adopted, including a user interaction module, a legal knowledge graph module, a document generation module, and a verification module. It uses the BERT-CRF architecture to extract entities and intents, combines the K-Means++ clustering algorithm to construct a knowledge graph, matches templates through the longest common subsequence algorithm, and uses a support vector machine to fill slots.

Benefits of technology

It improves the accuracy of template selection and the efficiency of content filling, ensures accurate identification of user intent, enhances the ability to match legal provisions with cases, and reduces legal risks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120850987B_ABST
    Figure CN120850987B_ABST
Patent Text Reader

Abstract

This invention relates to the field of automated document generation, specifically an intelligent automated legal document generation system. The system includes a user interaction module, a legal knowledge graph module, a document generation module, a verification module, and a database. The user interaction module extracts entities and detects input defects using named entity recognition and slot-filling algorithms, outputting the user's initial intent. The legal knowledge graph module classifies legal texts and constructs a knowledge graph using improved clustering and knowledge graph construction algorithms. The document generation module matches templates using the longest common subsequence algorithm and fills the knowledge graph's associated content into slots using a support vector machine. The verification module verifies data logic and slot coverage. This invention achieves automated processing of legal documents from input to generation through multi-module collaboration, improving the efficiency and accuracy of document generation, ensuring content compliance and logical rigor, and is applicable to various automated legal document generation scenarios.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of automated document generation, specifically to an intelligent automated legal document generation system. Background Technology

[0002] In the field of traditional legal document generation, existing technical solutions mainly rely on manual drafting of documents based on fixed templates, which has significant technical bottlenecks and application limitations.

[0003] When manually processing unstructured user input, it is difficult to efficiently extract key entities and intents. Incomplete input information and logical contradictions often lead to repeated document revisions, severely impacting generation efficiency. The template matching process heavily relies on the legal expertise of operators. When user intent is ambiguous, template type misjudgment is highly likely, resulting in document structure and content deviating from actual needs. Existing technologies lack the ability to structure and dynamically correlate legal knowledge, making it impossible to automatically retrieve and verify the legality of document clauses. It is also difficult to perform similarity reasoning based on historical cases, leading to legal risks or unreasonable clauses in the generated documents.

[0004] Therefore, an intelligent legal document automated generation system is needed to solve the above problems. Summary of the Invention

[0005] To address the technical problems raised in the background section, this invention provides an intelligent legal document automated generation system.

[0006] The objective of this invention can be achieved through the following technical solutions:

[0007] This invention provides an intelligent legal document automated generation system, including a user interaction module, a legal knowledge graph module, a document generation module, a verification module, and a database.

[0008] The user interaction module obtains text or voice input from the conversational interface, extracts entity sets using a named entity recognition algorithm, and then detects input defects or contradictory input items using a slot-filling algorithm to generate initial complete text content. Finally, an intent recognition algorithm outputs the user's first intent, specifically:

[0009] It receives text input and voice input, and processes them into text representation through a modality conversion function. Voice input is converted into raw text through an ASR model.

[0010] Named entity recognition is implemented using the BERT-CRF architecture, and slot filling is performed on the original text using a rule engine. The formula is as follows: ,in For the identified set of entities, each entity The slot filling process, which includes the type, is defined as follows: ,in For a predefined set of slot rules, This is the set of filled slots, each slot... It includes slot names and slot values; specifically, the original text is segmented into word sequences, and the BERT encoder outputs a context representation. The entity label value of each word sequence is calculated through the CRF layer. ,in For entity labels, the loss function of the CRF layer is expressed as: Slot filling task output: Calculates each slot using a pointer network. starting position and end position probability distribution Its calculation logic is as follows: This is used to construct a predefined set of slot rules; the entity tag value is matched with the predefined slot set to obtain the slot name and slot value;

[0011] Defect detection function is obtained based on rules and the filled slot set. Its formula is expressed as ,in The set of defect detection rules includes completeness rules, consistency rules, and reasonableness rules. These rules sequentially detect missing required slots, detect logical contradictions between slots, and evaluate the reasonableness of slot values ​​to obtain the initial complete text content.

[0012] Set a core intent category set, which includes drafting contracts, drafting litigation documents, querying legal provisions, uploading evidence materials, and modifying documents; match the initial complete text content with the core intent category set, extract the current text intent set and send it to the preset language model, which is equipped with an intent recognition algorithm, outputs the probability value of each intent category in the text intent set, and sets the intent category with the highest probability value as the user's first intent.

[0013] The legal knowledge graph module divides legal texts into categorized texts based on clustering algorithms, and then uses knowledge graph construction algorithms to construct a knowledge graph from these categorized texts. The specific process is as follows:

[0014] The legal text stored in the database is extracted, cleaned, and standardized. This legal text includes legal provisions, judgments, and legal terminology. The legal text is then integrated into a set of text feature vectors using a hybrid processing method combining TF-IDF and legal domain term vectors. Its calculation logic is as follows: ,in With a fixed weighting factor of 0.6, For traditional text features, the calculation formula is as follows: ,in For words In text, word frequency is represented by NF, where NF is the total number of documents in the corpus. For containing words The number of documents, For legal domain word vectors, the Law2Vec pre-trained word vector model was used, trained by retrieving 100,000 court judgments. Its computational logic is as follows: ,in For the Law2Vec vector of the word, The word count of the document;

[0015] The K-Means++ algorithm automatically classifies the preprocessed text feature vector set. The specific steps are as follows:

[0016] S11: Randomly select a vector from the set of text feature vectors as the first cluster center. ;

[0017] S12: For each remaining vector Calculate its distance to the nearest selected cluster center. distance, The cluster center number is calculated using the following logic: ;

[0018] S13: Obtain the sum of squared distances ST of all vectors, and set the probability of each vector being selected as the next center to be 1. Its calculation logic is as follows: ;

[0019] S14: Randomly sample the points according to probability, and the selected points will be the next cluster centers. Repeat steps S12-S14 until K cluster centers are selected;

[0020] S15: Then for each vector Calculate the cosine similarity from it to all cluster centers, and then... Maximum clustering assigned to cosine similarity ;

[0021] S16: For each cluster... Recalculation Center YR is the mean of all vectors in the cluster, and the cluster centers are updated accordingly. This process is repeated iteratively.

[0022] S17: Stop iterating when the rate of change of the center vector in two consecutive iterations is less than 0.01; the rate of change is calculated by taking the vector difference norm of each cluster center in the current iteration and the previous iteration, dividing the norm by the norm of the center vector in the previous iteration to obtain the change magnitude of a single cluster center, and taking the average of the change magnitudes of all cluster centers as the overall rate of change.

[0023] By dynamically adjusting the attention weights of the entity recognition model using the feature vectors of cluster centers, the accuracy of entity extraction in specific domains can be improved. Specifically, a domain mask is added to the input layer of the BERT model, and the feature vectors of the cluster centers to which the current text belongs are used as additional inputs. The calculation logic is as follows: ,in For word embedding vectors, Embed the vector for the cluster center. For the model input vector, As attention weights, domain-specific entities are extracted from high-frequency feature words of cluster centers to construct a domain entity dictionary;

[0024] Based on the domain semantics of each cluster center, the relationship types between entities are defined. Specifically, each cluster center is mapped to its corresponding relationship type, the entities corresponding to each cluster center are extracted, and the extracted entities are associated with their corresponding cluster centers to form an entity-domain mapping table. A domain subgraph storage method is adopted, with each cluster center corresponding to a knowledge subgraph. The subgraph includes the entity set, relation set, corresponding rule set, and case set of the domain;

[0025] Association rules based on Apriori mining predefine domain inference rules for each cluster center, determine the cluster center to which it belongs through text classification, and perform inference only in that domain subgraph; thus constructing knowledge graph content.

[0026] The document generation module, based on the set legal document template library, uses the Longest Common Subsequence (LCS) algorithm to match the user's first intent with the most suitable template type in the library. Then, it extracts related content from the knowledge graph based on the initial complete text content. The support vector machine automatically places the extracted related content into the corresponding template slots. The specific process is as follows:

[0027] The legal document template library includes templates for several types of legal documents, including general civil contract templates, commercial transaction contract templates, civil litigation templates, criminal litigation templates, administrative litigation templates, and non-litigation templates. A Chinese word segmentation tool is used to convert user intent and template descriptions into a word sequence, obtaining the intent sequence length. and template sequence length And filter stop words; perform the same steps in the template library; the LCS algorithm calculates the length of the longest common subsequence of the intent sequence and the template sequence. ,set up Indicating the intention sequence before Before the word and template sequence Given the length of each word, the logic for calculating its state transition equation is as follows: The lengths of each word in the intent sequence and template sequence are obtained sequentially. Words with the same length in the intent and template sequences are concatenated to form the longest common subsequence (LCS) length. The similarity between the user intent and the template is calculated by the ratio of the LCS length to the lengths of the two sequences. Its calculation logic is as follows: Iterate through all templates and select the template with the highest similarity as the matching template.

[0028] The initial complete text content is converted into a machine-readable set of triples, specifically by segmenting the initial complete text content into words to obtain a word sequence. Where n represents the total number of words, then the set of triples is... The extraction function is: Where g represents the word number, , and These are the entities, attributes, and corresponding values ​​in the text content, where... yes The entity, It is an attribute of the entity. It's an attribute value. For example, if the entity is a deposit, the attribute is the amount, and the corresponding value is 7000 yuan; [This refers to the entity in the user's requirements.] With knowledge graph entities Through semantic similarity The calculation logic for selecting the most matching node is as follows: ,in The cosine similarity of entity descriptions can be calculated using vectors generated by BERT. For contextual similarity, select the node with the highest semantic similarity, where the node includes the matching entity and the matching relationship;

[0029] Then through attribute values Triggering entities in the knowledge graph and text content Related knowledge subgraphs To verify compliance, the current triggering state is obtained through a triggering rule function, and its calculation logic is as follows: RTR is the rule output, which includes the trigger status and prompt information. For trigger function, For legal rules; if the rule output indicates that it has been triggered, then a compliance score is calculated. Its calculation logic is as follows: This is used to obtain matching rules; the set of cases within the knowledge subgraph is calculated based on the entity features of the word sequence, and the most similar cases are matched to determine the case similarity. The calculation logic is as follows: The sum is weighted by entity overlap and semantic similarity. ,in For the entity set of word sequence, For the set of entities in the case, The semantic similarity between word sequences and cases; A fixed weighting coefficient of 0.6 was used; the case with the highest case similarity was selected as the matching case.

[0030] The matching entities, matching relationships, matching rules, and matching cases are input into slots in the matching template via a support vector machine. Specifically, the matching entities, matching relationships, matching rules, and matching cases are converted into a unified vector and concatenated into a standard vector XF. The support vector machine then uses a slot prediction decision function to sequentially match the input standard vector to the corresponding prediction slots. In this context, the slot prediction decision function is: ,in Slot category The inner product of the weight vector and the input features. This is a bias item corresponding to the slot category. To predict the slot category label, the category with the largest output value of the decision function is selected. The slot category is assigned a number, which is used to generate complete legal documents.

[0031] The verification module uses a detection algorithm to logically verify the data and terms, and then verifies the integrity of the slot coverage. The specific process is as follows:

[0032] Set start time and end time Its logical consistency score is The specific judgment logic is as follows: When the value is 0, the document must be rewritten.

[0033] Set the complete set of required slots for legal documents as follows The filled slots are The integrity score is Its calculation logic is as follows: If the value is less than the preset threshold, the code will be rewritten.

[0034] The database contains preset thresholds and predefined information.

[0035] Compared with the prior art, the beneficial effects of the present invention are: the document generation module achieves semantic-level matching of templates through the longest common subsequence algorithm, and completes the automatic filling of slots by combining support vector machines. Compared with the traditional template matching method, it significantly improves the accuracy of template selection and the efficiency of content filling, and can quickly generate legal documents with standardized structure.

[0036] The user interaction module adopts the BERT-CRF architecture and slot filling algorithm, which can automatically extract entities and detect input defects, efficiently converting conversational or voice input into structured text, solving the problems of low information extraction efficiency and easy omission in traditional manual processing, and ensuring accurate recognition of user intent;

[0037] The legal knowledge graph module utilizes the K-Means++ clustering algorithm and domain subgraph construction technology to classify legal texts semantically and dynamically adjust entity recognition weights to form a structured knowledge network. This enables the system to accurately extract domain-specific entities, improve the correlation and matching ability between legal provisions and cases, and avoid the shortcomings of chaotic legal retrieval and inaccurate entity extraction in traditional solutions. Attached Figure Description

[0038] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. The following drawings are not drawn to scale according to the actual size, but are intended to illustrate the main idea of ​​the present invention.

[0039] Figure 1 This is a schematic diagram of the principle of the present invention.

[0040] Figure 2 This is a flowchart of the core algorithm for the document generation module. Detailed Implementation

[0041] The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are also within the scope of protection of the present invention.

[0042] Please refer to Figure 1 As shown, the present invention provides an intelligent legal document automated generation system, including a user interaction module, a legal knowledge graph module, a document generation module, a verification module, and a database.

[0043] The user interaction module obtains text or voice input from the conversational interface, extracts entity sets using a named entity recognition algorithm, and then detects input defects or contradictory input items using a slot-filling algorithm to generate initial complete text content. Finally, an intent recognition algorithm outputs the user's first intent, specifically:

[0044] It receives text input and voice input, and processes them into text representation through a modality conversion function. Voice input is converted into raw text through an ASR model.

[0045] Named entity recognition is implemented using the BERT-CRF architecture, and slot filling is performed on the original text using a rule engine. The formula is as follows: ,in For the identified set of entities, each entity The slot filling process, which includes the type, is defined as follows: ,in For a predefined set of slot rules, This is the set of slots after they have been filled. For precise matching and filling operations between entities and slots, each slot It includes slot names and slot values; specifically, the original text is segmented into word sequences, and the BERT encoder outputs a context representation. The entity label value of each word sequence is calculated through the CRF layer. ,in For entity labels, the loss function of the CRF layer is expressed as: Slot filling task output: Calculates each slot using a pointer network. starting position and end position probability distribution Its calculation logic is as follows: ,in For normalized exponential functions, This involves enhancing the context vector of the input text to serve the global prediction of slot boundaries. The current slot's state vector is augmented with features to facilitate the dynamic association between the slot and the text, thereby constructing a predefined set of slot rules; the entity label value is matched with the predefined set of slots to obtain the slot name and slot value;

[0046] Rule-based and statistical input defect detection function Its formula is expressed as ,in The set of defect detection rules includes completeness rules, consistency rules, and reasonableness rules. These rules sequentially detect missing required slots, detect logical contradictions between slots, and evaluate the reasonableness of slot values ​​to obtain the initial complete text content.

[0047] In legal document generation scenarios, a set of core intent categories is set. Core intents include drafting contracts, drafting litigation documents, querying legal provisions, uploading evidence materials, and modifying documents. It should be noted that drafting contracts is further subdivided into housing rental / sales contracts / service contracts, etc.; drafting litigation documents includes complaints / answers / appeals, etc.; querying legal provisions includes the Civil Code / Criminal Law / Administrative Litigation Law, etc.; and modifying documents includes adjusting clauses / supplementing facts / changing claims, etc. The initial complete text content is matched with the set of core intent categories to extract the current text intent set and send it to a preset language model. The preset language model is equipped with an intent recognition algorithm, which outputs the probability value of each intent category in the text intent set. The intent category with the highest probability value is set as the user's primary intent.

[0048] The legal knowledge graph module divides legal texts into categorized texts based on clustering algorithms, and then uses knowledge graph construction algorithms to construct a knowledge graph from these categorized texts. The specific process is as follows:

[0049] The legal text stored in the database is extracted, cleaned, and standardized. This legal text includes legal provisions, judgments, and legal terminology. The legal text is then integrated into a set of text feature vectors using a hybrid processing method combining TF-IDF and legal domain term vectors. Its calculation logic is as follows: ,in With a fixed weighting factor of 0.6, Traditional text features are used to measure the importance of words in a text, and their calculation formula is as follows: ,in For words In text, word frequency is represented by NF, where NF is the total number of documents in the corpus. For containing words The number of documents, For legal domain word vectors, the Law2Vec pre-trained word vector model was used, trained by retrieving 100,000 court judgments. Its computational logic is as follows: ,in For the Law2Vec vector of the word, The word count of the document;

[0050] It should be noted that the traditional K-Means algorithm, which randomly selects initial centers, is prone to local optima. This invention uses the K-Means++ algorithm to automatically classify the preprocessed text feature vector set. The specific steps are as follows:

[0051] S11: Randomly select a vector from the set of text feature vectors as the first cluster center. ;

[0052] S12: For each remaining vector Calculate its distance to the nearest selected cluster center. distance, The cluster center number is calculated using the following logic: ;

[0053] S13: Obtain the sum of squared distances ST of all vectors, and set the probability of each vector being selected as the next center to be 1. Its calculation logic is as follows: The probability is proportional to the square of the distance from the point to the nearest center; the farther the point is, the higher the probability of it being selected.

[0054] S14: Randomly sample the points according to probability, and the selected points will be the next cluster centers. Repeat steps S12-S14 until K cluster centers are selected. Each cluster center corresponds to a core semantic label in a legal field, such as Civil Law - Contract Law or Criminal Law - Crimes against Property.

[0055] S15: Then for each vector Calculate the cosine similarity from it to all cluster centers, and then... Maximum clustering assigned to cosine similarity ;

[0056] S16: For each cluster... Recalculation Center YR is the mean of all vectors in the cluster, and the cluster centers are updated accordingly. This process is repeated iteratively.

[0057] S17: Stop iterating when the rate of change of the center vector in two consecutive iterations is less than 0.01; the rate of change is calculated by taking the vector difference norm of each cluster center in the current iteration and the previous iteration, dividing the norm by the norm of the center vector in the previous iteration to obtain the change magnitude of a single cluster center, and taking the average of the change magnitudes of all cluster centers as the overall rate of change.

[0058] By dynamically adjusting the attention weights of the entity recognition model using the feature vectors of cluster centers, the accuracy of entity extraction in specific domains can be improved. Specifically, a domain mask is added to the input layer of the BERT model, and the feature vectors of the cluster centers to which the current text belongs are used as additional inputs. The calculation logic is as follows: ,in For word embedding vectors, Embed the vector for the cluster center. The input vector for the model is the final input vector that integrates textual semantics and domain information; As attention weights, domain-specific entities are extracted from high-frequency feature words at cluster centers to construct a domain entity dictionary, assisting the model in recognition; such as Civil Law - Contract Law Dictionary: Lessee, Lessor, Overdue Rent Payment and Penalty;

[0059] Based on the domain semantics of each cluster center, the relationship types between entities are limited to reduce invalid relationship extraction. Specifically, each cluster center is mapped to its corresponding relationship type, the entities corresponding to each cluster center are extracted, and the extracted entities are associated with their corresponding cluster centers to form an entity-domain mapping table. For example, if an entity is overdue on rent payments, then it belongs to... The cluster centers are in the Civil Law - Contract Law section, and the path is Contract Law → Lease Contract → Breach of Contract; a domain subgraph storage method is adopted, with each cluster center corresponding to a knowledge subgraph. The subgraph includes the entity set, relation set, corresponding rule set, and case set of the domain;

[0060] Association rules based on Apriori mining predefine domain inference rules for each cluster center, such as... Reasoning rules in the Contract Law section of Civil Law: Overdue rent payment More than 30 days The lessor has the right to terminate the contract. When a query is entered, such as "Can the contract be terminated if the lessee fails to pay the rent for 45 days?", the cluster center to which the lessee belongs is determined by text classification. Reasoning is only performed in the subgraph of that domain to avoid cross-domain interference; thus, the knowledge graph content is constructed.

[0061] The document generation module, based on the set legal document template library, uses the Longest Common Subsequence (LCS) algorithm to match the user's first intent with the most suitable template type in the library. Then, it extracts related content from the knowledge graph based on the initial complete text content. The support vector machine automatically places the extracted related content into the corresponding template slots. The specific process is as follows:

[0062] The legal document template library includes templates for several types of legal documents, including general civil contract templates, commercial transaction contract templates, civil litigation templates, criminal litigation templates, administrative litigation templates, and non-litigation templates. A Chinese word segmentation tool is used to convert user intent and template descriptions into a word sequence, obtaining the intent sequence length. and template sequence length And filter stop words; for example, if the user's original intent is "I want to generate a house rental contract", the word segmentation result is [I want, generate, a house, rental, contract], after filtering stop words, it is [house, rental, contract]; the same steps are performed in the template library; the LCS algorithm calculates the length of the longest common subsequence of the intent sequence and the template sequence. ,set up Indicating the intention sequence before Before the word and template sequence Given the length of each word, the logic for calculating its state transition equation is as follows: The lengths of each word in the intent sequence and template sequence are obtained sequentially. Words with the same length in the intent and template sequences are concatenated to form the longest common subsequence (LCS) length. The similarity between the user intent and the template is calculated by the ratio of the LCS length to the lengths of the two sequences. Its calculation logic is as follows: Iterate through all templates and select the template with the highest similarity as the matching template.

[0063] The initial complete text content is converted into a machine-readable set of triples, specifically by segmenting the initial complete text content into words to obtain a word sequence. Where n represents the total number of words, then the set of triples is... The extraction function is: Where g represents the word number, , and These are the entities, attributes, and corresponding values ​​in the text content, where... yes The entity, It is an attribute of the entity. It's an attribute value. For example, if the entity is a deposit, the attribute is the amount, and the corresponding value is 7000 yuan; [This refers to the entity in the user's requirements.] With knowledge graph entities Through semantic similarity The calculation logic for selecting the most matching node is as follows: ,in The cosine similarity of entity descriptions can be calculated using vectors generated by BERT. For contextual similarity, select the node with the highest semantic similarity, where the node includes the matching entity and the matching relationship;

[0064] Then through attribute values Triggering entities in the knowledge graph and text content Related knowledge subgraphs To verify compliance, the current triggering state is obtained through a triggering rule function, and its calculation logic is as follows: RTR is the rule output, which includes the trigger status and prompt information. For trigger function, For legal rules; if the rule output indicates that it has been triggered, then a compliance score is calculated. Its calculation logic is as follows: This is used to obtain matching rules; the set of cases within the knowledge subgraph is calculated based on the entity features of the word sequence, and the most similar cases are matched to determine the case similarity. The calculation logic is as follows: The sum is weighted by entity overlap and semantic similarity. ,in For the entity set of word sequence, For the set of entities in the case, The semantic similarity between word sequences and cases; A fixed weighting coefficient of 0.6 was used; the case with the highest case similarity was selected as the matching case.

[0065] The matching entities, matching relationships, matching rules, and matching cases are input into slots in the matching template via a support vector machine. Specifically, the matching entities, matching relationships, matching rules, and matching cases are converted into a unified vector and concatenated into a standard vector XF. The support vector machine then uses a slot prediction decision function to sequentially match the input standard vector to the corresponding prediction slots. In this context, the slot prediction decision function is: ,in Slot category The inner product of the weight vector and the input features has the same dimension as the input standard vector. This is a bias item corresponding to the slot category. To predict the slot category label, select the category with the largest output value from the decision function. The slot category is assigned a number, which is used to generate complete legal documents.

[0066] The verification module uses a detection algorithm to logically verify the data and terms, and then verifies the integrity of the slot coverage. The specific process is as follows:

[0067] Set start time and end time Its logical consistency score is The specific judgment logic is as follows: When the value is 0, the document must be rewritten.

[0068] Set the complete set of required slots for legal documents as follows The filled slots are The integrity score is Its calculation logic is as follows: If it is less than the preset threshold, it will be rewritten.

[0069] The database contains preset thresholds and predefined data information.

[0070] The foregoing description is illustrative of the invention and should not be construed as limiting it. Although several exemplary embodiments of the invention have been described, those skilled in the art will readily understand that many modifications can be made to the exemplary embodiments without departing from the novel teachings and advantages of the invention. Therefore, all such modifications are intended to be included within the scope of the invention as defined in the claims. It should be understood that the foregoing description is illustrative of the invention and should not be construed as limiting it to the specific embodiments disclosed, and modifications to the disclosed embodiments and other embodiments are intended to be included within the scope of the appended claims. The invention is defined by the claims and their equivalents.

Claims

1. An intelligent legal document automated generation system, comprising a user interaction module, a legal knowledge graph module, a document generation module, a verification module, and a database, characterized in that: The user interaction module obtains text or voice input from the conversational interface, extracts entity sets using a named entity recognition algorithm, and then detects input defects or contradictory input items using a slot filling algorithm to generate initial complete text content. Finally, it uses an intent recognition algorithm to output the user's first intent. The legal knowledge graph module divides legal texts into categorized texts using a clustering algorithm, and then constructs a knowledge graph from these categorized texts using a knowledge graph construction algorithm. The specific process of the legal knowledge graph module constructing the knowledge graph is as follows: By leveraging the feature vectors of cluster centers, the attention weights of the entity recognition model are dynamically adjusted to improve the extraction accuracy of entities in specific domains. Specifically, a domain mask is added to the input layer of the BERT model, and the feature vectors of the cluster centers to which the current text belongs are used as additional inputs. Domain-specific entities are extracted from the high-frequency feature words of the cluster centers to construct a domain entity dictionary. Based on the domain entity dictionary of each cluster center, the relationship types between entities are limited. Specifically, each cluster center is mapped to its corresponding relationship type, the entities corresponding to each cluster center are extracted, and the extracted entities are associated with their corresponding cluster centers to form an entity-domain mapping table. The domain subgraph storage method is adopted, with each cluster center corresponding to a knowledge subgraph. The subgraph includes the entity set, relation set, corresponding rule set, and case set of the domain. The association rules based on Apriori mining predefine domain inference rules for each cluster center, determine the cluster center to which it belongs through text classification, and perform inference only in that domain subgraph to construct knowledge graph content; The document generation module uses the Longest Common Subsequence (LCS) algorithm to match the user's first intent with the most suitable template type in the legal document template library based on the set legal document template library. Then, it extracts the related content of the knowledge graph from the initial complete text content. The support vector machine automatically puts the extracted related content into the slot of the most suitable template to generate a complete legal document. The verification module uses a detection algorithm to logically verify the data and terms, and then verifies the integrity of the slot coverage.

2. The intelligent legal document automated generation system according to claim 1, characterized in that, The document generation module, based on the established legal document template library, uses the longest common subsequence algorithm to match the user's first intent with the most suitable template type within the legal document template library. The specific process is as follows: The legal document template library contains templates for several legal document types. A Chinese word segmentation tool is used to convert user intent and template descriptions into word sequences, obtaining the intent sequence length and template sequence length, and filtering stop words. The same steps are performed within the template library. The longest common subsequence algorithm calculates the length of the longest common subsequence between the intent sequence and the template sequence, setting... Indicating the intention sequence before Before the word and template sequence The length of each word is obtained; the length of each word in the intent sequence and template sequence is obtained in turn; words with the same length in the intent sequence and template sequence are concatenated to obtain the longest common subsequence length; the similarity between the user intent and the template is calculated by the ratio of the LCS length to the length of the two sequences; all templates are traversed, and the template with the highest similarity is used as the matching template.

3. The intelligent legal document automated generation system according to claim 1, characterized in that, The document generation module extracts relevant content from the knowledge graph based on the initial complete text content. The support vector machine then automatically places the extracted relevant content into the corresponding template slots. Specifically: After segmenting the initial complete text content into words to obtain a word sequence, the triple set is extracted; the entities in the user's requirements are compared with the entities in the knowledge graph through semantic similarity, and the node with the highest semantic similarity is selected. Then, the knowledge subgraph associated with the entity in the text content is triggered by the attribute value to verify compliance. Specifically, the current triggering status is obtained by triggering the rule function. If the function rule outputs a result indicating that the rule has been triggered, a compliance score is calculated to obtain the matching rule. The set of cases within the knowledge subgraph is calculated using the entity features of the word sequence, and the most similar cases are matched. The matching entities, matching relationships, matching rules, and matching cases are input into slots in the matching template via a support vector machine to generate complete legal documents.

4. The intelligent legal document automated generation system according to claim 1, characterized in that, The specific process of outputting the user's primary intent is as follows: It receives text and voice input, and processes them into text representation using a modality conversion function. Named entity recognition is implemented using the BERT-CRF architecture, and slot filling is performed on the original text. The output of the slot filling task is: the probability distribution of the start and end positions of each slot is calculated through a pointer network to construct a predefined set of slot rules; the entity label values ​​are matched with the predefined set of slots to obtain the slot name and slot value. Based on the defect detection rule set and the filled slot set, a defect detection function is obtained. The function sequentially detects missing required slots, detects logical contradictions between slots, and evaluates the rationality of slot values ​​to obtain the initial complete text content. Set a core intent category set, match the initial complete text content with the core intent category set, extract the current text intent set and send it to the preset language model. The preset language model is equipped with an intent recognition algorithm, which outputs the probability value of each intent category in the text intent set, and sets the intent category with the highest probability value as the user's first intent.

5. The intelligent legal document automated generation system according to claim 1, characterized in that, The legal knowledge graph module divides legal texts into categorized texts based on a clustering algorithm. The specific process is as follows: The legal texts stored in the database are extracted, cleaned, and standardized. The legal texts include legal provisions, judgments, and legal terms. The legal texts are then integrated into a set of text feature vectors using a hybrid processing method combining TF-IDF and legal domain word vectors.

6. The intelligent legal document automated generation system according to claim 5, characterized in that, The legal knowledge graph module automatically classifies the preprocessed text feature vector set using the K-Means++ algorithm. The specific steps are as follows: Step 1: Randomly select a vector from the set of text feature vectors as the first cluster center; Step 2: For each remaining vector, calculate its distance to the nearest selected cluster center; Step 3: Obtain the sum of squared distances of all vectors and calculate the probability that each vector will be selected as the next center; Step 4: Randomly sample the sample points according to the probability. The selected point is the next cluster center. Repeat steps 2-4 until K cluster centers are selected. Step 5: Calculate the cosine similarity of each vector to all cluster centers, and assign the vector to the largest cluster based on the cosine similarity. Step 6: Recalculate the mean of all vectors in each cluster as the center, and update the cluster centers accordingly. Repeat this process iteratively. Step 7: Stop iterating when the rate of change of the center vector is less than 0.01 in two consecutive iterations.

7. The intelligent legal document automated generation system according to claim 1, characterized in that, The verification module uses a detection algorithm to logically verify the data and terms, and then verifies the integrity of the slot coverage. The specific process is as follows: Set start time and end time Its logical consistency score is The specific judgment logic is as follows: When the value is 0, the document must be rewritten. Set the complete set of required slots for legal documents as follows The filled slots are The integrity score is Its calculation logic is as follows: If the value is less than the preset threshold, the code will be rewritten.