A method, system and device for generating legal texts using artificial intelligence interaction
By embedding the extraction and processing of legal knowledge triplets in the generative pre-trained language model, the problem of difficulty in integrating user-AI interaction information to generate legal texts in the prior art is solved, and high-quality and automated legal text generation is achieved.
Patent Information
- Application Number
- CN202411113030.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-14
- Publication Date
- 2025-02-25
- Estimated Expiration
- 2044-08-14
AI Technical Summary
It is difficult for the prior art to effectively integrate the information obtained by multiple interactions between users and AI to generate applicable and accurate legal texts, especially in complex legal scenarios that cannot handle multi-level legal logical structures.
By introducing a generative pre-trained language model and a legal information extraction model, multiple semantic continuous query statements are processed, legal knowledge triplets are extracted, and legal argument triplets are generated through triple knowledge processing, and legal text is finally generated.
It significantly improves the quality and accuracy of legal text generation, makes the generated text more semantically accurate and the legal logic more rigorous, reduces the problem of inconsistency in context, and realizes the full process automation from query input to final text generation.
Smart Images

Figure CN119090010B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of distributed big data, and specifically relates to a legal text generation method, system and device with artificial intelligence interaction. Background Art
[0002] In modern legal services, timely and effective legal consultation and text generation are crucial for lawyers and clients. However, lawyers are usually not available 24 / 7, which makes traditional legal consulting services limited in dealing with sudden or urgent legal matters. With the advancement of artificial intelligence technology, it has gradually become possible to use artificial intelligence to consult and search for legal issues, and this method can make legal services more streamlined, thereby improving the efficiency and popularity of legal services. However, although AI can play an important role in consulting and answering legal issues, how to effectively integrate the information obtained from multiple interactive questions and answers into legal texts suitable for actual scenarios is still a difficult problem that needs to be solved.
[0003] Since lawyers cannot provide services at all times, the use of artificial intelligence for legal consultation and problem searching can make the legal service process more streamlined. However, how to effectively integrate the information obtained from multiple interactions between users and AI, and ultimately generate applicable and accurate legal texts, remains a key challenge. In the existing technology, some legal text generation tools are often limited to simple template filling or fixed format generation, and cannot flexibly respond to complex and changing legal consulting needs. These tools are usually unable to understand the contextual information generated by multiple interactions between users and AI, resulting in the lack of coherence and accuracy in the generated text, which is difficult to meet the needs of actual legal services.
[0004] In today's legal services industry, the generation and processing of legal documents is a highly manual process. Traditionally, the drafting, revision and review of legal documents mainly rely on the knowledge and experience of professionals such as lawyers and legal personnel. This approach not only consumes a lot of time and energy, but also has a certain risk of human error. At the same time, with the rapid development of the Internet, more and more companies and individuals need to obtain legal services. However, there are problems in the legal services market, such as limited service capabilities, high costs, and slow response speeds. Especially during non-working hours, the supply of legal services is seriously insufficient. This limitation restricts the popularization and promotion of legal services.
[0005] In recent years, generative pre-trained language models (LLMs) have made significant progress in the field of natural language processing, especially in text generation. By pre-training on large-scale legal texts, these models are able to generate legal texts with a certain quality and can perform contextual understanding and reasoning based on natural language queries. The development of this technology provides new possibilities for the automatic generation of legal texts.
[0006] Although the generative pre-trained language model can generate legal texts that conform to grammar and syntax, it still has deficiencies in semantic understanding and reasoning, especially when dealing with multi-level and multi-dimensional legal relationships, it is easy to have misunderstandings or reasoning errors. When generating legal texts, the current generative pre-trained model often finds it difficult to effectively extract and structure legal knowledge. For example, the knowledge graph construction method and system based on legal data described in the patent document with publication number CN107908671B results in the generated text being not rigorous enough in legal logic. Since legal texts have high continuity and consistency requirements, the prior art is prone to context inconsistency when generating long legal texts, which in turn affects the overall quality of the text. In the prior art, although there are already some applications that can use generative language models to generate legal texts, these applications are mainly focused on some simple legal text generation tasks, such as the standardization of contract terms and the interpretation of legal terms. In complex legal scenarios, such as contracts involving multi-party legal relationships, the prior art is difficult to handle multi-level legal logic structures, and the generated legal texts often cannot meet the needs of professional legal services.
[0007] In addition, current technologies rely more on statistical models and pattern matching, which is inadequate when faced with complex legal issues, especially in scenarios where deep reasoning is required, and the generated text may deviate from legal logic. Most existing legal text generation technologies can only cover certain links in the legal text generation process, and cannot achieve full process automation from query input to final text generation. This limitation means that the generated legal text still requires a lot of manual intervention in practical applications. Since the generation of legal texts depends on the performance of pre-trained models, the quality and reliability of the generated results may not be guaranteed in practical applications, especially when dealing with complex and non-standardized legal queries, which are prone to errors or misleading. Summary of the invention
[0008] The purpose of the present invention is to propose an artificial intelligence interactive legal text generation method, system and device to solve one or more technical problems existing in the prior art and at least provide a beneficial choice or create conditions.
[0009] In order to achieve the above object, according to one aspect of the present invention, a method for generating legal texts through artificial intelligence interaction is provided, the method comprising the following steps:
[0010] Multiple query statements are input into the generative pre-trained language model in sequence, and the multiple query statements have a continuous relationship in semantic relationship; the generative pre-trained language model generates each query statement in sequence to obtain each output statement; the legal information extraction model is used to extract triples from each output statement to obtain a set of legal knowledge triples corresponding to each output statement; the connection degree between each entity in the legal knowledge triple set is obtained, and the statistical relationship connectivity between each entity is calculated; each legal knowledge triple set is subjected to triple knowledge processing to obtain a legal argumentation triple, and the legal text is generated using the legal argumentation triple; wherein the legal information extraction model is trained by the legal text and is used to extract knowledge triples from the legal text.
[0011] Furthermore, the generative pre-trained language model may include, but is not limited to, a generative pre-trained language model such as GPT-3, BERT and / or GPT-4.
[0012] Furthermore, for inputting multiple query statements:
[0013] Design multiple query statements with continuous semantic relationships according to the type of legal text to be generated;
[0014] These query statements are input into the generative pre-trained language model in a predetermined order.
[0015] Furthermore, the method of performing triple knowledge processing on each set of legal knowledge triples to obtain legal argument triples is as follows:
[0016] Integrate the legal knowledge triples in each legal knowledge triple set to obtain the relationship connection and expansion vectors corresponding to all legal knowledge triples;
[0017] The statistical relationship connects the average probability distribution of the opening and closing vectors, and selects several legal knowledge triples whose distance exceeds the average probability distribution distance as legal argumentation triples.
[0018] Furthermore, the step of performing triple knowledge processing on each legal knowledge triple set also includes:
[0019] Calculate the statistical relationship connectivity and entity relationship expansion / compression between each pair of entities in each legal knowledge triple;
[0020] The entity relationship stretch amount is calculated based on the hyperplane area and linear direction difference of the entity embedding vector in the semantic space; wherein, the entity relationship stretch amount is calculated based on the area of the hyperplane occupied by the entity embedding vectors in the semantic space and the degree of difference in the linear direction between the entity embedding vectors in the semantic space, and the entity relationship stretch amount is a scalar that can be used to simultaneously measure the area of the hyperplane occupied by the entity embedding vectors in the semantic space and the linear direction of the hyperplane they occupy in the semantic space.
[0021] Furthermore, the connection degree between each entity in the legal knowledge triple set is obtained, and the statistical relationship connectivity between each entity is calculated, specifically:
[0022] Each legal knowledge triple set is composed of several legal knowledge triples, each legal knowledge triple is composed of three entities, and each entity is a string data extracted from a query statement or an output statement;
[0023] Traverse each entity of the legal knowledge triple in each set of legal knowledge triples, and calculate the statistical relationship connectivity between each entity according to the connection degree between each entity, wherein the statistical relationship connectivity between entities is calculated by the connectivity of each relationship between the entities, one connection relationship between entities corresponds to one connection degree, and the relationship connectivity between entities is the sum of the connection degree plus the non-zero bias value divided by the non-zero bias value.
[0024] Furthermore, the legal argument triples are used for text generation: the text generation includes inputting the legal argument triples into a generative pre-trained language model, or filling them into a text template.
[0025] The present invention also provides an artificial intelligence interactive legal text generation system, the artificial intelligence interactive legal text generation system comprises: a processor, a memory, and a computer program stored in the memory and executable on the processor, the processor implements the steps in the artificial intelligence interactive legal text generation method when executing the computer program, the artificial intelligence interactive legal text generation system can be run in computing devices such as desktop computers, laptop computers, PDAs, and cloud data centers, and the executable system may include, but is not limited to, a processor, a memory, and a server cluster, and the processor executes the computer program to run in the following system units:
[0026] A sentence input unit, used to sequentially input a plurality of query sentences into the generative pre-trained language model, wherein the plurality of query sentences have a continuous relationship in terms of semantic relationship;
[0027] A sentence output unit, used to enable the generative pre-trained language model to generate each query sentence in turn to obtain each output sentence;
[0028] A knowledge extraction unit, used to enable the legal information extraction model to perform triple extraction on each output sentence, and obtain a set of legal knowledge triples corresponding to each output sentence;
[0029] An entity calculation unit, used to obtain the connection degree between entities in the legal knowledge triple set and calculate the statistical relationship connectivity between entities;
[0030] The knowledge generation unit is used to perform triple knowledge processing on each set of legal knowledge triples to obtain legal argumentation triples, and use the legal argumentation triples to generate legal texts.
[0031] Correspondingly, the present invention also provides an electronic device, a readable storage medium and a computer program product:
[0032] An electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the artificial intelligence interactive legal text generation method and the methods of each step therein.
[0033] A non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to cause the computer to execute the artificial intelligence interactive legal text generation method and the methods of the various steps therein.
[0034] A computer program product includes a computer program, which, when executed by a processor, implements the artificial intelligence interactive legal text generation method and the methods of the various steps therein.
[0035] The beneficial effects of the present invention are as follows: the present invention provides a method, system and device for generating legal texts interactively by artificial intelligence, which significantly improves the quality and accuracy of generated legal texts by introducing a legal information extraction model and triple knowledge processing. By embedding the extraction and processing of legal knowledge triples in a generative pre-trained language model, the generated text is not only more accurate in semantics, but also more rigorous in legal logic. By calculating the statistical relationship connectivity and entity relationship tension and closure of legal knowledge triples, the understanding and reasoning ability of complex legal scenarios are further enhanced. By performing full-text embedded vectorization processing on the input query statements and output statements, the continuity and consistency of the generated legal text are improved, thereby reducing the problem of context inconsistency. The method of the present invention automatically completes the entire process from query input to extraction of legal knowledge triples and then to the generation of the final legal text, which reduces the need for manual intervention and improves efficiency and reliability. By analyzing and processing the generated legal text with legal argumentation triples, the reliability and legal compliance of the generated results are significantly improved, ensuring the availability and accuracy of the generated legal text in practical applications. The legal text generation method of the present invention can be widely used in the legal service industry to realize the automation and intelligence of legal text generation, reduce the cost of legal services, and improve the response speed and quality of legal services, thus having broad promotion prospects in industrial applications. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] The above and other features of the present invention will become more obvious by describing in detail the embodiments shown in the accompanying drawings. The same reference numerals in the accompanying drawings of the present invention represent the same or similar elements. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other accompanying drawings can be obtained based on these accompanying drawings without creative work. In the accompanying drawings:
[0037] Figure 1 Shown is a flow chart of a method for generating legal texts using artificial intelligence interaction;
[0038] Figure 2 Shown is a system structure diagram of an artificial intelligence interactive legal text generation system. DETAILED DESCRIPTION
[0039] The following will be combined with the embodiments and drawings to clearly and completely describe the concept, specific structure and technical effects of the present invention, so as to fully understand the purpose, scheme and effect of the present invention. It should be noted that the embodiments and features in the embodiments of this application can be combined with each other without conflict.
[0040] In the description of the present invention, "several" means one or more, "more" means more than two, "greater than", "less than", "exceed" etc. are understood as not including the number itself, and "above", "below", "within" etc. are understood as including the number itself. If there is a description of "first" or "second", it is only used for the purpose of distinguishing the technical features, and cannot be understood as indicating or implying the relative importance or implicitly indicating the number of the indicated technical features or implicitly indicating the order of the indicated technical features.
[0041] like Figure 1 The flowchart of the method for generating legal texts through artificial intelligence interaction according to the present invention is shown below. Figure 1 To illustrate an artificial intelligence interactive legal text generation method, system and device according to an embodiment of the present invention.
[0042] The present invention proposes a legal text generation method using artificial intelligence interaction, which specifically includes the following steps:
[0043] Inputting a plurality of query statements into the generative pre-trained language model in sequence, wherein the plurality of query statements have a continuous relationship in terms of semantic relationship;
[0044] The generative pre-trained language model generates each query sentence in turn to obtain each output sentence;
[0045] The legal information extraction model is used to extract triples from each output sentence, and the legal knowledge triple set corresponding to each output sentence is obtained;
[0046] Obtain the connection degree between each entity in the legal knowledge triple set, and calculate the statistical relationship connectivity between each entity;
[0047] Each set of legal knowledge triples is subjected to triple knowledge processing to obtain legal argumentation triples, and the legal text is generated using the legal argumentation triples.
[0048] Among them, the legal information extraction model can be a deep neural network model trained by legal text and used to extract knowledge triples from legal text. The core of this method is to use a generative pre-trained language model (such as GPT-3, BERT) to process multiple semantically continuous query sentences and generate corresponding output sentences. After the initial generation, these output sentences are not directly used as the final text, but legal knowledge triples are extracted from them through the legal information extraction model. This process ensures that each generated sentence is not only grammatically correct, but also contains structured legal knowledge, thereby improving the accuracy and logic of legal text generation. Finally, after triple knowledge processing, each legal knowledge triple is refined, so that the generated text has significant improvements in legal logic and contextual consistency.
[0049] Furthermore, the generative pre-trained language model includes an API interface for a generative pre-trained language model of GPT-3, BERT and / or GPT-4.
[0050] In some embodiments, these models have been pre-trained on large-scale text data and have strong text understanding and generation capabilities. It is also preferred that the selected pre-trained model be fine-tuned in the legal field according to the special needs of the legal field. This can be done by continuing to train the model on a large number of legal texts (such as judgments, regulations, contracts, etc.) to make it more adaptable to legal language style and terminology.
[0051] Further, for inputting multiple query statements:
[0052] Design multiple query statements with continuous semantic relationships based on the type of legal text to be generated:
[0053] For example, if a contract needs to be generated, the query statement can extract character information that appears in sequence in the text document of the contract, such as text extraction information about the contract subject, contract object, contract term, etc.
[0054] These query statements are input into the generative pre-trained language model in a predetermined order:
[0055] For example, ensure that the semantic relationship between each query statement is clear so that the model understands the context.
[0056] In some embodiments, for legal information extraction: a legal information extraction model can be selected, for example, a specially trained legal information extraction model can be used, Lawyer LLaMA can be used, or another dialogue can be directly opened on the client of the generative pre-trained language model to let it recognize the semantic entities of legal terms, such as models based on named entity recognition (NER) and relationship extraction. These models should be able to accurately extract entities and their relationships from legal texts to form legal knowledge triples. During the extraction process, the legal information extraction model can be applied to each generated output sentence to extract the contained legal knowledge triples. Each triple is usually composed of (subject, relationship, object), such as ("buyer", "signing", "contract").
[0057] In the specific implementation of query input and processing, first, the user can input a set of query statements related to legal issues into the generative pre-trained language model in sequence. These query statements should have a continuous relationship in semantics, reflecting the user's gradual and in-depth exploration of a legal issue. For example, the query statement may be:
[0058] “What is a breach of contract?”
[0059] “What legal actions can I take if the other party breaches the contract?”
[0060] “Under what circumstances can compensation for breach of contract be sought?”
[0061] Generative pre-trained language models can be GPT-3, BERT, etc., which will generate corresponding output sentences based on the input query sentences. Each output sentence is based on the model's learning and inference on a large amount of legal text corpus, providing legal interpretations or suggestions related to the query sentence.
[0062] For the extraction of legal information triples, after obtaining the individual sentences output by the generative pre-trained language model, a specially trained legal information extraction model is used to process these output sentences to extract legal knowledge triples.
[0063] The legal information extraction model can be a model trained based on technologies such as NER (named entity recognition) and relationship extraction, which can identify legal entities from legal texts and extract the relationships between entities. Specifically, the legal knowledge triple is composed of three parts:
[0064] Entity 1 (e.g., contract)
[0065] Entity 2 (eg, default)
[0066] Entity 3 (eg, compensation)
[0067] In this process, each output sentence is processed and one or more legal knowledge triples are extracted. For example, if the output sentence is "Contract breach can lead to compensation", the extracted legal knowledge triples may be:
[0068] [Contract, cause, breach of contract]
[0069] [Breach of contract, resulting in, compensation]
[0070] Legal knowledge can be structured through triples composed of strings and can be stored in a database to facilitate data retrieval for further analysis and processing.
[0071] Furthermore, the connection degree between each entity in the legal knowledge triple set is obtained, and the statistical relationship connectivity between each entity is calculated, specifically:
[0072] Each legal knowledge triple set is composed of several legal knowledge triples, each legal knowledge triple is composed of three entities, and each entity is a string data extracted from a query statement or an output statement;
[0073] Traverse each entity of the legal knowledge triple in each set of legal knowledge triples, and calculate the statistical relationship connectivity between each entity according to the connection degree between each entity, wherein the statistical relationship connectivity between entities is calculated by the connectivity of each relationship between the entities, one connection relationship between entities corresponds to one connection degree, and the relationship connectivity between entities is the sum of the connection degree plus the non-zero bias value divided by the non-zero bias value.
[0074] Each legal knowledge triple set is composed of several legal knowledge triples, each legal knowledge triple is composed of three entities, each entity is a string data extracted from a query statement or an output statement, and the connection degree between each entity is obtained.
[0075] In some embodiments, the entities included in each triple in each set of legal knowledge triples are compared, and the number of connections and connection combinations between each entity are counted. In any legal knowledge triple Atriple, Atriple includes three entities [entity1, entity2, entity3], and in any legal knowledge triple Btriple, Btriple includes [entity4, entity5, entity1], each adjacent entity in the legal knowledge triple is connected, and the entities are connected to form a graph. In Atriple, there is a direct connection between the combination of entity1 and entity2, where the connection degree of the direct connection is 0. There is no direct connection between the combination of entity1 and entity3, but there is an indirect connection, where the connection degree corresponding to the indirect connection is the number of entities between the two entities. The connection degrees between the two entities are different in different legal knowledge triples. For example, in the Atriple legal knowledge triple, there is only one entity between the two entities, so the connection degree in Atriple is 1. In Atriple and Btriple, entity4 and entity2 are also indirectly connected, because entity4 and entity1 are separated by entity5, and entity1 is directly connected to entity2, so there are 2 entities between entity4 and entity2 in the two legal knowledge triples, and the connection degree between entity4 and entity2 is 2. Entities that appear in different legal knowledge triples can be repeated, and one entity can appear in multiple different legal knowledge triples. Some entities can appear in more than one legal knowledge triple, which means that these entities have multiple different connection relationships.
[0076] If there are multiple different connection relationships between entities, there are correspondingly multiple connection degrees between the entities.
[0077] Traverse each entity of the legal knowledge triple in each set of legal knowledge triples, and calculate the statistical relationship connectivity between each entity according to the connection degree between each entity, wherein the statistical relationship connectivity between entities is calculated by the connectivity of each relationship between the entities, one connection relationship between entities corresponds to one connection degree, and the relationship connectivity between entities is the sum of the connection degree plus the non-zero bias value divided by the non-zero bias value.
[0078] In some embodiments, for example, there are three different indirect connections between entity6 and entity7, where the connection degrees are 2, 3, and 5 respectively, then the relationship connectivity corresponding to their connection degrees may be b / (2+b), b / (3+b), and b / (4+b), where b represents the non-zero bias value, and preferably, the value of b is a non-zero positive number, and the specific value of b may be 1. The statistical relationship connectivity between entities is obtained by calculating the average value of each relationship connectivity between entities, and the statistical relationship connectivity between entity6 and entity7 is the arithmetic mean of the relationship connectivity corresponding to their connection degrees.
[0079] All query statements and output statements are fully embedded and vectorized, and then the embedding vectors of the entities included therein are obtained as the entity embedding vectors corresponding to each entity.
[0080] In some embodiments, all query statements input by the user and their corresponding output statements are collected, and all the collected query statements and their output statements are used together by using a pre-trained language model, such as BERT, GPT-3, etc., to generate text embeddings, wherein all query statements and their output statements should be embedded and vectorized together. Such embedding and vectorization processing is a semantic embedding of all query statements and their output statements in the whole text, which is conducive to extracting contextual information using the contextual embedding mechanism, and obtaining the embedding vector of the entity included in the contextual embedding. Preferably, the Transformers library introduced by HuggingFace can be run in an environment that supports PyTorch, and the modules of BertTokenizer and BertModel can be called to encode the input text and obtain sentence embeddings, usually taking the vector of the [CLS] tag, and then intercepting the embedding vector of the entity included therein. Alternatively, preferably, the GPT-3 model of OpenAI can also be used to generate embeddings through API calls.
[0081] By calculating and analyzing the degree of connection of entities in each legal knowledge triple, the system can better understand the relationship network between legal entities. Specifically, by analyzing the number and combination of entity connections between different triples, a legal knowledge graph can be constructed. This process not only makes the generated text more logically consistent, but also enhances the system's ability to understand the complex relationships between legal entities, making text generation more in line with actual legal needs and reducing the need for human intervention.
[0082] Furthermore, the step of performing triple knowledge processing on each legal knowledge triple set includes:
[0083] Calculate the statistical relationship connectivity and entity relationship expansion / compression between each pair of entities in each legal knowledge triple;
[0084] The entity relationship stretch amount is calculated based on the hyperplane area and linear direction difference of the entity embedding vector in the semantic space; wherein, the entity relationship stretch amount is calculated based on the area of the hyperplane occupied by the entity embedding vectors in the semantic space and the degree of difference in the linear direction between the entity embedding vectors in the semantic space, and the entity relationship stretch amount is a scalar that can be used to simultaneously measure the area of the hyperplane occupied by the entity embedding vectors in the semantic space and the linear direction of the hyperplane they occupy in the semantic space.
[0085] In some implementation examples, the method of triple knowledge processing may specifically be:
[0086] Calculate the statistical relationship connectivity and entity relationship span between the three entities of each legal knowledge triple, wherein the entity relationship span is calculated by the area of the hyperplane occupied by the entity embedding vectors in the semantic space and the degree of difference between the entity embedding vectors in the linear direction in the semantic space. The entity relationship span is a scalar that can be used to simultaneously measure the area of the hyperplane occupied by the entity embedding vectors in the semantic space and the linear direction of the hyperplane occupied by the entity embedding vectors in the semantic space;
[0087] In some embodiments, calculations are performed between each of the three entities of a legal knowledge triple. For example, among the three entities [entity1, entity2, entity3] included in Atriple, the statistical relationship connectivity and entity relationship tension and closure between entity1 and entity2 are calculated, and the statistical relationship connectivity and entity relationship tension and closure between entity1 and entity3 are calculated, and the statistical relationship connectivity and entity relationship tension and closure between entity3 and entity2 are also calculated.
[0088] In one embodiment, the value of the vector cross product between two entity embedding vectors of a legal knowledge triple can be calculated to represent the value of the area of the hyperplane between the entity embedding vectors in the semantic space. In one embodiment, the value of the cosine similarity between two entity embedding vectors of a legal knowledge triple can be calculated to represent the value of the degree of difference between the entity embedding vectors in the linear direction in the semantic space.
[0089] In some embodiments, the product of the area of the hyperplane occupied by the entity embedding vectors in the semantic space and the degree of difference between the entity embedding vectors in the linear direction in the semantic space can be used as the entity relationship stretching amount. The product of the area of the hyperplane occupied by the entity embedding vectors in the semantic space and the degree of difference between the entity embedding vectors in the linear direction in the semantic space can also be subjected to certain function processing and weighted processing and used as the entity relationship stretching amount.
[0090] In each legal knowledge triple, the statistical relationship connectivity and entity relationship tension and closing amount between each two entities are obtained respectively, and the array consisting of the numerical values of the statistical relationship connectivity and entity relationship tension and closing amount between each two entities in sequence is taken as the relationship connectivity and tension and closing vector corresponding to the legal knowledge triple.
[0091] In some embodiments, in a legal knowledge triple, where every two entities serve as a pair of entities, then three entities are combined in pairs to form three pairs of entities, and the statistical relationship connectivity and entity relationship tension and closing value between each pair of entities are calculated. The values of the statistical relationship connectivity values and entity relationship tension and closing values of the three pairs of entities are arranged in the corresponding order of the three pairs of entities to form a sequence or array as the relationship connectivity tension and closing vector corresponding to the legal knowledge triple.
[0092] Furthermore, the method of performing triple knowledge processing on each set of legal knowledge triples to obtain legal argument triples is as follows:
[0093] Integrate the legal knowledge triples in each legal knowledge triple set, and then calculate the relationship connection and expansion vector corresponding to each legal knowledge triple according to the statistical relationship connectivity and entity relationship expansion and expansion between each pair of entities in each legal knowledge triple;
[0094] The average probability distribution of the relationship connection opening and closing vectors is obtained statistically, and several legal knowledge triples whose distance exceeds the average probability distribution distance are selected as legal argumentation triples.
[0095] In some embodiments, the legal knowledge triples in each legal knowledge triple set are integrated, and the relationship connection tension and closing vectors corresponding to all the legal knowledge triples are obtained, and the average probability distribution of the relationship connection tension and closing vectors corresponding to all the legal knowledge triples is calculated, so as to compare the relationship connection tension and closing vectors corresponding to each legal knowledge triple with the average probability distribution of the relationship connection tension and closing vector, and compare to obtain several legal knowledge triples whose relationship connection tension and closing vectors are far away from the average probability distribution of the relationship connection tension and closing vector as legal argumentation triples.
[0096] In one embodiment, among all the acquired legal knowledge triples corresponding to the relational connection and expansion vectors, the arithmetic mean of the Euclidean distance of the relational connection and expansion vector corresponding to each legal knowledge triple relative to the relational connection and expansion vector corresponding to the remaining legal knowledge triples is calculated as the probability distribution distance corresponding to the legal knowledge triple, and then the median value of the probability distribution distance corresponding to each legal knowledge triple is calculated as the average probability distribution of the relational connection and expansion vector, wherein the legal knowledge triples whose probability distribution distance value is greater than the average probability distribution of the relational connection and expansion vector are called legal argumentation triples. It is also preferred that feature extraction can be performed based on the probability distribution distance corresponding to each legal knowledge triple to obtain a threshold and / or constraint condition, and the obtained threshold and / or constraint condition can be used to select a number of legal knowledge triples from the legal knowledge triples whose probability distribution distance value is greater than the average probability distribution of the relational connection and expansion vector as a number of legal argumentation triples.
[0097] In legal text generation, dealing with complex legal relationships is a major challenge. By calculating the statistical relationship connectivity and entity relationship tension between entities, the system can quantify and analyze the relationship between entities. This quantification not only takes into account the direct connection between entities, but also the potential relationship between entities in the semantic space (such as hyperplane area, directional difference, etc.). This in-depth semantic analysis makes the generated legal text not only reasonable on the surface, but also more rigorous and reliable in terms of underlying legal logic. This process improves the accuracy of text generation and ensures that the generated text is more in line with legal requirements in practical applications.
[0098] By integrating and analyzing legal knowledge triples, relational connection vectors are generated, and by analyzing the probability distribution of these vectors, the triples with the most legal argument value are further identified. This process enables the system to automatically extract and generate content with more legal value and give priority to these key triples in the text generation process. This approach ensures that the generated legal text not only contains all the necessary information, but also gives priority to the most important legal argument points, making the text more legally effective and persuasive.
[0099] In the process of extracting legal information, a key step is to extract legal knowledge triples from the generated legal text. Each triple contains three entities, which usually represent important concepts or elements in legal terminology, such as "contract", "breach of contract", "compensation", etc. Since each triple contains three entities, the name "triplet knowledge processing" directly reflects this feature, emphasizing that in the processing process, the analysis and processing of the relationship between these three entities is one of the core steps. The "triplet" here not only refers to the number of entities, but also implies a multi-level analysis of the relationship between these three entities.
[0100] “Triple knowledge processing” can also refer to the three-level relationship analysis of legal knowledge triples during the processing process. This processing includes:
[0101] Analysis of connection degree: This is the first level, focusing on the frequency of entities in legal knowledge triples appearing in different triples and the connections between them. By calculating the connection degree, common concept combinations or associations in legal terms are identified.
[0102] Calculation of relationship connectivity: This is the second level, which further analyzes the strength of the connection between two entities and quantifies their relationship. This analysis allows us to understand the relevance and importance of legal terms more accurately.
[0103] Generation and analysis of embedding vectors: This is the third level. By embedding the text into vectors and combining them with semantic analysis of the generative language model, we can understand the correlation between legal terms in a higher-dimensional semantic space. This process not only analyzes the direct connection between entities, but also considers their complex interactions in the semantic space.
[0104] “Triple knowledge processing” can also be expressed as the multi-level integration of knowledge in the processing process. The “triple” here refers not only to the relationship between entities, but also to the three different dimensions of knowledge processing:
[0105] Legal entity knowledge: The entities extracted from the text themselves represent the basic units of legal knowledge, which is the most basic level of knowledge.
[0106] Entity relationship knowledge: The connection relationship, connectivity and relationship tension between entities represent the second level of knowledge, which is an analysis of the correlation between legal terms.
[0107] Semantic embedding knowledge: Through the generation and analysis of embedding vectors, we can understand the complex relationships between legal terms in the semantic space, which constitutes the third level of knowledge.
[0108] This multi-level knowledge processing approach not only improves the depth of understanding of legal texts, but also helps generate more accurate and logical legal documents.
[0109] By multi-level and multi-dimensionally processing the three entities in each legal knowledge triple, this method can capture a richer and more complex legal knowledge structure when generating legal texts, thereby generating high-quality legal documents. This algorithm design strategy is innovative in legal text generation because it not only relies on a single text generation technology, but also combines the results of multiple technical fields such as knowledge graphs and semantic analysis to transform the simple text generation process into a complex and logical knowledge processing process.
[0110] Further, wherein the legal argument triples are used for text generation: the text generation includes inputting the legal argument triples into a generative pre-trained language model, or filling them into a text template.
[0111] Based on the extracted legal knowledge triples, legal text can be generated. The generated legal text can be completed in the following two ways:
[0112] The processed legal knowledge triples are input into the generative pre-trained language model again, allowing the model to generate relevant legal texts based on these triples. This generation method is suitable for automatically generating legal documents with specific argumentation logic.
[0113] The extracted legal knowledge triples are filled in according to the pre-set template to generate a standardized legal document. For example, according to a specific legal issue template, the corresponding triples can be filled into the template to generate a legal opinion or complaint in a standardized format.
[0114] In some embodiments, the legal argument triples are input again into the generative pre-trained language model, and the generative pre-trained language model is made to generate text according to the legal argument triples. For each input query sentence, the generative pre-trained language model is used to generate a corresponding output sentence. Specific parameters such as temperature, maximum generated length, etc. can be set during generation to control the diversity and length of the generated text.
[0115] In some embodiments, the legal argument triples are filled into document templates according to rules including but not limited to regular expressions to generate text. The generated output statements are preliminarily automatically reviewed using a rule system to ensure that they are consistent with the meaning of the query statement. Figure 1 and conform to the norms of legal language.
[0116] Finally, the generated legal text can be used as different types of legal documents such as legal opinions, contract clauses, litigation documents, etc. for users or legal professionals, so that the supply of legal text can provide services online 24 hours a day, realizing the streamlined production of the Internet. This text generation method can significantly improve the efficiency and accuracy of legal document generation, reduce the risk of errors in human participation, and provide effective technical support for legal practice. By re-inputting the legal argument triples into the generative pre-trained language model, the system is able to generate text with higher legal value. This process ensures that the generation of legal text is not only logical, but also able to provide accurate and coherent legal arguments in complex legal scenarios. In addition, by generating text using rules and templates, this process can significantly improve the efficiency of legal text generation and ensure that the output legal text is consistent with conventional legal documents in structure, reducing the need for manual review and modification.
[0117] The artificial intelligence interactive legal text generation system runs on any computing device such as a desktop computer, a laptop computer, a PDA or a cloud data center. The computing device includes: a processor, a memory and a computer program stored in the memory and running on the processor. When the processor executes the computer program, the steps in the artificial intelligence interactive legal text generation method are implemented. The executable system may include, but is not limited to, a processor, a memory, and a server cluster.
[0118] An embodiment of the present invention provides an artificial intelligence interactive legal text generation system, such as Figure 2 As shown, an artificial intelligence interactive legal text generation system of this embodiment includes: a processor, a memory, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps in the above-mentioned artificial intelligence interactive legal text generation method embodiment are implemented. The processor executes the computer program to run in the following system units:
[0119] A sentence input unit, used to sequentially input a plurality of query sentences into the generative pre-trained language model, wherein the plurality of query sentences have a continuous relationship in terms of semantic relationship;
[0120] A sentence output unit, used to enable the generative pre-trained language model to generate each query sentence in turn to obtain each output sentence;
[0121] A knowledge extraction unit, used to enable the legal information extraction model to perform triple extraction on each output sentence, and obtain a set of legal knowledge triples corresponding to each output sentence;
[0122] An entity calculation unit, used to obtain the connection degree between entities in the legal knowledge triple set and calculate the statistical relationship connectivity between entities;
[0123] The knowledge generation unit is used to perform triple knowledge processing on each set of legal knowledge triples to obtain legal argumentation triples, and use the legal argumentation triples to generate legal texts.
[0124] Among them, in order to better unify the numerical linear relationship and probabilistic connection between physical quantities of different units of measurement, different physical quantities can be dimensionally processed.
[0125] Among them, preferably, all undefined variables in the present invention, if not clearly defined, can be manually set thresholds.
[0126] The artificial intelligence interactive legal text generation system can be run on computing devices such as desktop computers, laptops, PDAs, and cloud data centers. The artificial intelligence interactive legal text generation system includes, but is not limited to, processors and memories. Those skilled in the art will understand that the example is only an example of an artificial intelligence interactive legal text generation method, system, and device, and does not constitute a limitation on an artificial intelligence interactive legal text generation method, system, and device. It may include more or fewer components than the example, or combine certain components, or different components. For example, the artificial intelligence interactive legal text generation system may also include input and output devices, network access devices, buses, etc.
[0127] The present invention also provides an electronic device, a readable storage medium and a computer program product:
[0128] An electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the artificial intelligence interactive legal text generation method and the methods of each step therein.
[0129] A non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to cause the computer to execute the artificial intelligence interactive legal text generation method and the methods of the various steps therein.
[0130] A computer program product includes a computer program, which, when executed by a processor, implements the artificial intelligence interactive legal text generation method and the methods of the various steps therein.
[0131] Wherein, electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. Electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or claimed herein.
[0132] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0133] The program code for implementing the method of the present invention can be written in any combination of one or more programming languages. These program codes can be provided to a processor or controller of a general-purpose computer, a special-purpose computer or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code can be executed entirely on the machine, partially on the machine, partially on the machine as a stand-alone software package and partially on a remote machine, or entirely on a remote machine or server.
[0134] In the context of the present invention, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0135] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0136] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.
[0137] A computer system may include clients and servers. Clients and servers are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship to each other.
[0138] The processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete component gate circuits or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor, etc. The processor is the control center of the artificial intelligence interactive legal text generation system, and uses various interfaces and lines to connect the various sub-areas of the entire artificial intelligence interactive legal text generation system.
[0139] The memory can be used to store the computer program and / or module, and the processor realizes various functions of the artificial intelligence interactive legal text generation method, system and device by running or executing the computer program and / or module stored in the memory and calling the data stored in the memory. The memory can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.); the data storage area can store data created according to the use of the mobile phone (such as audio data, a phone book, etc.). In addition, the memory can include a high-speed random access memory, and can also include a non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.
[0140] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in the present disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution disclosed in the present invention can be achieved, and this document is not limited here.
[0141] The present invention provides a method, system and device for generating legal texts in an artificial intelligence interactive manner. A plurality of query statements are sequentially input into a generative pre-trained language model, wherein the plurality of query statements have a continuous relationship in semantic relationship; the generative pre-trained language model sequentially generates each query statement respectively to obtain each output statement; a legal information extraction model is used to perform triple extraction on each output statement respectively to obtain a set of legal knowledge triples corresponding to each output statement; the connection degree between each entity in the set of legal knowledge triples is obtained, and the statistical relationship connectivity between each entity is calculated; each set of legal knowledge triples is subjected to triple knowledge processing to obtain a legal argumentation triple, and the legal text is generated using the legal argumentation triple. The efficiency and accuracy of legal document generation can be significantly improved, and artificial intelligence can be summarized and screened in multiple questions and answers, long dialogues and complex legal discussion scenarios of human-computer interaction to provide accurate and coherent natural language output.
[0142] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. An artificial intelligence interactive legal text generation method, characterized in that: The method comprises: Input multiple query statements into the generative pre-trained language model in sequence, wherein the multiple query statements have a continuous relationship in semantic relationship; the generative pre-trained language model generates each query statement in sequence to obtain each output statement; use the legal information extraction model to extract triples from each output statement to obtain a set of legal knowledge triples corresponding to each output statement; obtain the connection degree between each entity in the set of legal knowledge triples, and calculate the statistical relationship connectivity between each entity; perform triple knowledge processing on each set of legal knowledge triples to obtain a legal argumentation triple, and use the legal argumentation triples to generate a legal text; Wherein, the legal information extraction model is trained by legal texts and used to extract knowledge triples from legal texts; Among them, the step of performing triple knowledge processing on each set of legal knowledge triples to obtain legal argumentation triples also includes: calculating the relationship connection and expansion vector corresponding to each legal knowledge triple based on the statistical relationship connectivity and entity relationship expansion and contraction between each pair of entities in each legal knowledge triple, and then calculating the average probability distribution of the relationship connection and expansion and contraction vector, and selecting several legal knowledge triples whose distance exceeds the average probability distribution distance as legal argumentation triples.
2. The method for generating legal texts through artificial intelligence interaction according to claim 1, characterized in that: in, The generative pre-trained language model includes a generative pre-trained language model of GPT-3, BERT and / or GPT-4.
3. The method for generating legal texts through artificial intelligence interaction according to claim 1, characterized in that: in, For entering multiple query statements: Design multiple query statements with continuous semantic relationships according to the type of legal text to be generated; These query statements are input into the generative pre-trained language model in a predetermined order.
4. The method for generating legal texts through artificial intelligence interaction according to claim 1, characterized in that: in, The step of performing triple knowledge processing on each set of legal knowledge triples also includes: Calculate the statistical relationship connectivity and entity relationship stretching amount between each pair of entities in each legal knowledge triple; wherein the entity relationship stretching amount is calculated based on the hyperplane area and linear direction difference of the entity embedding vector in the semantic space; wherein the entity relationship stretching amount is calculated based on the area of the hyperplane occupied by the entity embedding vectors in the semantic space and the degree of difference between the entity embedding vectors in the linear direction in the semantic space, and the entity relationship stretching amount is a scalar that can be used to simultaneously measure the area of the hyperplane occupied by the entity embedding vectors in the semantic space and the linear direction of the hyperplane they occupy in the semantic space.
5. The method for generating legal texts through artificial intelligence interaction according to claim 4, characterized in that: in, Obtain the connection degree between each entity in the legal knowledge triple set, and calculate the statistical relationship connectivity between each entity, specifically: Each legal knowledge triple set is composed of several legal knowledge triples, each legal knowledge triple is composed of three entities, and each entity is a string data extracted from a query statement or an output statement; Traverse each entity of the legal knowledge triple in each set of legal knowledge triples, and calculate the statistical relationship connectivity between each entity according to the connection degree between each entity, wherein the statistical relationship connectivity between entities is calculated by the connectivity of each relationship between the entities, one connection relationship between entities corresponds to one connection degree, and the relationship connectivity between entities is the sum of the connection degree plus the non-zero bias value divided by the non-zero bias value.
6. A method for generating legal texts through artificial intelligence interaction according to any one of claims 1, 4 or 5, characterized in that: in, Generating text using legal argument triples: The text generation includes inputting the legal argument triples into a generative pre-trained language model, or filling them into a text template.
7. An artificial intelligence interactive legal text generation system, characterized in that: The artificial intelligence interactive legal text generation system runs in any computing device such as a desktop computer, a laptop computer or a cloud data center. The computing device includes: a processor, a memory and a computer program stored in the memory and running on the processor. When the processor executes the computer program, the steps in the artificial intelligence interactive legal text generation method as described in any one of claims 1 to 5 are implemented.
8. An electronic device comprising: at least one processor; and a memory communicatively coupled to the at least one processor; The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 5.
Citation Information
Patent Citations
A Method and System for Constructing Knowledge Graphs Based on Legal Data
CN107908671B
Knowledge injection method of pre-training language model and corresponding interaction system
CN114936287A
Knowledge graph link prediction method and system
CN116776973A