A method, device, equipment and storage medium for generating legal document cause

Through the pre-trained cause-of-action extraction model and cause-of-action generation model, combined with the comparison and scoring module, the semantic and contextual features in legal documents are extracted, which solves the problems of low quality and low efficiency of cause-of-action generation in the existing technology, and achieves high-quality and efficient Cause of action is generated.

CN118504527BActive Publication Date: 2024-09-20INFORMATION TECH SERVICE CENT OF THE PEOPLES COURT +1
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
CN202410981514.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-22
Publication Date
2024-09-20
Estimated Expiration
2044-07-22

AI Technical Summary

Technical Problem

The quality and efficiency of generating legal documents' cause of action in the existing technology is low, mainly because the keyword extraction method lacks flexibility and sentence coherence, resulting in a high amount of redundant information, which is labor-intensive and has low generation efficiency.

Method used

The pre-trained cause-of-action extraction model and cause-of-action generation model are used to extract the semantic features and contextual features of the text through the semantic vector extraction layer and the context information extraction layer. Combined with the comparison and scoring module, high-quality cause-of-action text is generated and the generation efficiency is improved.

Benefits of technology

By extracting semantic representation vectors and contextual features in the text, filtering redundant information, and generating high-quality cause-of-action text, the quality and efficiency of cause-of-action generation are improved, and the accuracy and efficiency of cause-of-action generation are significantly improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118504527B
    Figure CN118504527B
Patent Text Reader

Abstract

The embodiments of this specification relate to the field of artificial intelligence technology, and provide a method, device, equipment, and storage medium for generating a legal document cause. The method comprises: receiving a legal document and obtaining the text content of the legal document; determining a text vector of the text content, inputting the text vector of the text content into a pre-trained extraction cause model, and generating an initial cause text, wherein the extraction cause model is used to extract semantic features and context features summarized by the text vector; inputting the initial cause text into a pre-trained generation cause model, and generating a final cause text. Through the embodiments of this specification, the quality and efficiency of cause generation can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of this specification relate to the field of artificial intelligence technology, and in particular to a method, device, equipment and storage medium for generating a legal document. Background Art

[0002] With the development of science and technology, various judicial fields are also undergoing intelligent transformation. As a key link in judicial administration, administrative law enforcement can use intelligent auxiliary technology in the process of case filing, investigation and evidence collection, penalty decision and execution to improve the efficiency of administrative law enforcement personnel and simplify the law enforcement process.

[0003] For the task of generating the cause of action of legal documents, the existing automated implementation methods are mainly based on keyword extraction. Specifically, they include: firstly extracting the key units in the text, where the key units can be words, phrases, sentences, etc., and then combining the extracted key units to obtain the cause of action of the legal document; finally, manually reviewing the cause of action of the legal document. This method is relatively simple, lacks flexibility, does not consider the coherence of sentences, has the problem of poor quality of cause of action generation due to high amount of redundant information, and also has the problem of wasting manpower and low efficiency of cause of action generation. Therefore, how to achieve high-quality cause of action generation and improve the efficiency of cause of action generation is an urgent problem to be solved. Summary of the invention

[0004] In view of the above-mentioned problems in the prior art, the purpose of the embodiments of this specification is to provide a method, device, equipment and storage medium for generating a legal document case, so as to solve the problems of low quality and low efficiency of case generation in the prior art.

[0005] In order to solve the above technical problems, the specific technical solutions of the embodiments of this specification are as follows:

[0006] On the one hand, the embodiments of this specification provide a method for generating a legal document cause of action, the method comprising:

[0007] Receiving legal documents and obtaining the text content of said legal documents;

[0008] Determine a text vector of the text content, input the text vector of the text content into a pre-trained case extraction model, and generate an initial case text; wherein the case extraction model is used to extract semantic features and context features summarized by the text vector;

[0009] The initial case text is input into a pre-trained case generation model to generate a final case text; wherein the case generation model includes a generation module and a comparison and scoring module, the generation module is used to generate a number of case texts based on the initial case text, and the comparison and scoring module is used to estimate the scores of the several case texts, and determine the final case text according to the scores of the several case texts.

[0010] Further, the determining the text vector of the text content includes:

[0011] Filtering, correcting errors and removing duplicates on the text content to obtain a processed text;

[0012] Performing sentence processing on the processed text to obtain a clause sequence;

[0013] The clause sequence is encoded to obtain a text vector.

[0014] Furthermore, the case extraction model includes: a semantic vector extraction layer, a context information extraction layer, a fully connected layer and a splicing layer;

[0015] The step of inputting the text vector of the text content into a pre-trained case extraction model to generate an initial case text includes:

[0016] Inputting the text vector of the text content into the semantic vector extraction layer to obtain the semantic representation vector of each sentence in the text content;

[0017] Inputting the semantic representation vector of each sentence in the text content into the context information extraction layer to obtain the context features of the text content;

[0018] Inputting the context features of the text content into a fully connected layer to obtain a classification result for each sentence in the text content;

[0019] The classification result of each sentence in the text content is input into the splicing layer to obtain the initial case text.

[0020] Furthermore, the classification result of each sentence in the text content is input into the concatenation layer to obtain the initial case text, including:

[0021] Obtaining a category label of each sentence vector from the classification result of each sentence in the text content;

[0022] Extract the sentence vectors whose category labels meet the preset category labels, and concatenate them according to the preset sentence arrangement order to obtain an initial sentence vector set;

[0023] The initial sentence vector set is decoded to obtain an initial case text.

[0024] Furthermore, the training process of generating the case cause model includes:

[0025] Inputting the initial case text into the generation module, and generating a pseudo optimal case and several candidate cases through a beam search algorithm;

[0026] Inputting the pseudo optimal case and several candidate cases into the comparison and scoring module for score estimation to obtain scores of the pseudo optimal case and several candidate cases;

[0027] When the score of the pseudo optimal case is less than the scores of the plurality of candidate cases, the loss functions of the generation module and the comparison and scoring module are calculated according to the scores;

[0028] Updating weight parameters of the generation module and the comparison and scoring module through a back propagation algorithm according to the loss functions of the generation module and the comparison and scoring module;

[0029] Repeat the above process until the preset number of training times is met.

[0030] Furthermore, the loss functions of the generation module and the comparison and scoring module are calculated using the following formula:

[0031] ;

[0032] ;

[0033] in, is the loss function of the generation module, gl is the number of tags included in the pseudo-optimal case, s r Indicates r Marks, represents the first r The log-likelihood of the marker predictions, Indicates that the pseudo optimal case is r tags generated before, Z Represents input text; L contrast To compare the loss function of the scoring module, k The number of candidate cases, Indicates i Candidate cases, S pos represents a pseudo optimal case, β gi express and S pos The spacing margin between No. i The score of the candidate case, represents the score of the pseudo-optimal case, Indicates j Candidate cases, β ij Indicates j and i The interval margin between candidate cases.

[0034] Furthermore, before inputting the initial case text into the pre-trained case generation model, the method further includes:

[0035] Input the initial case text into a word segmenter for word segmentation to obtain the word quantity of the initial case text;

[0036] It is determined whether the word count of the initial case text exceeds the preset sequence length. If so, the excess part is truncated; if not, a special mark is used to complete the missing part to obtain an input text sequence.

[0037] On the other hand, an embodiment of the present specification provides a device for generating a legal document cause, the device comprising:

[0038] A receiving module, used to receive a legal document and obtain the text content of the legal document;

[0039] A first generation module is used to determine the text vector of the text content, input the text vector of the text content into a pre-trained case extraction model, and generate an initial case text; wherein the case extraction model is used to extract semantic features and context features summarized by the text vector;

[0040] The second generation module is used to input the initial case text into a pre-trained case generation model to generate a final case text; wherein the case generation model includes a generation module and a comparison and scoring module, the generation module is used to generate a number of case texts based on the initial case text, the comparison and scoring module is used to estimate the scores of the several case texts, and determine the final case text based on the scores of the several case texts.

[0041] On the other hand, an embodiment of the present specification further provides a computer device, including a memory, a processor, and a computer program stored in the memory, wherein when the computer program is executed by the processor, the instructions of any one of the above methods are executed.

[0042] On the other hand, an embodiment of the present specification further provides a computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor of a computer device, the computer program executes instructions of any one of the above-described methods.

[0043] One or more technical solutions provided by some embodiments of this specification have at least the following technical effects:

[0044] This manual extracts the semantic vector extraction layer in the case model to learn the semantic relationship between each word in each sentence in the text content of the legal document, thereby extracting the semantic representation vector of each sentence in the text content, and inputs it into the context information extraction layer to learn the semantic relationship between different sentence vectors to extract the context information of the entire document, and then based on the context information, it can extract sentences with key information from the entire document and splice them into preliminary cases, thereby filtering out some redundant information in the entire document. In order to improve the quality and efficiency of generating cases, the preliminary cases are input into the pre-trained generated case model to generate the final case text, wherein a comparative scoring module is introduced into the generated case model, which draws on the idea of ​​comparative learning, and constructs a comparative loss function by comparing the length-normalized estimated logarithmic probability between the pseudo-optimal case and the candidate case, and between the candidate case, thereby improving the generation ability of the generated case model.

[0045] The above description is only an overview of the technical solutions of some embodiments of this specification. In order to more clearly understand the technical means of some embodiments of this specification, they can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the embodiments of this specification more obvious and easy to understand, the following specifically cites the preferred embodiments and describes them in detail in conjunction with the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0046] In order to more clearly illustrate the embodiments of this specification or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this specification. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0047] Figure 1 A schematic diagram showing a process of a method for generating a legal document cause in some embodiments of this specification;

[0048] Figure 2 The overall model structure diagram of a method for generating a legal document cause in some embodiments of this specification is shown;

[0049] Figure 3 A schematic diagram showing a process of determining a text vector of text content in some embodiments of this specification;

[0050] Figure 4 A schematic diagram of a process of inputting a text vector of the text content into a pre-trained case extraction model to generate an initial case text in some embodiments of this specification is shown;

[0051] Figure 5A schematic diagram of a process of inputting the classification result of each sentence in the text content into the splicing layer to obtain the initial case text in some embodiments of the present specification is shown;

[0052] Figure 6 A schematic diagram of a process before the initial case text is input into a pre-trained case generation model in some embodiments of this specification is shown;

[0053] Figure 7 A schematic diagram of the training process of generating a case cause model in some embodiments of this specification is shown;

[0054] Figure 8 A schematic diagram of the module structure of a legal document cause generating device in some embodiments of this specification is shown;

[0055] Fig. 9 A schematic diagram of the structure of a computer device in this specification is shown.

[0056] Description of the accompanying symbols:

[0057] 801, receiving module;

[0058] 802, a first generating module;

[0059] 803, second generation module;

[0060] 902. Computer equipment;

[0061] 904, processor;

[0062] 906. Memory;

[0063] 908, driving mechanism;

[0064] 910, input / output module;

[0065] 912. Input device;

[0066] 914. Output device;

[0067] 916. Presentation equipment;

[0068] 918. Graphical user interface;

[0069] 920, network interface;

[0070] 922, communication link;

[0071] 924. Communication bus. DETAILED DESCRIPTION

[0072] The following will be combined with the drawings in the embodiments of this specification to clearly and completely describe the technical solutions in the embodiments of this specification. Obviously, the described embodiments are only part of the embodiments of this specification, not all of the embodiments. Based on the embodiments in this specification, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this specification.

[0073] In order to solve the above problems, the embodiments of this specification provide a method for generating a legal document cause. Figure 1 This is a flowchart of a method for generating a legal document cause provided by an embodiment of this specification. This specification provides method operation steps as described in the embodiment or flowchart, but may include more or fewer operation steps based on conventional or non-creative labor. The order of steps listed in the embodiment is only one way of executing the order of many steps and does not represent the only execution order. When the system or device product is executed in practice, it can be executed in the order of the method shown in the embodiment or the accompanying drawings or in parallel.

[0074] It should be noted that the terms "first", "second", etc. in this specification and claims and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of this specification described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, device, product or equipment that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or equipment.

[0075] Reference Figure 1 As shown, the embodiment of this specification provides a method for generating a legal document cause, the method comprising:

[0076] S101: receiving a legal document and obtaining the text content of the legal document;

[0077] S102: Determine a text vector of the text content, input the text vector of the text content into a pre-trained case extraction model, and generate an initial case text; wherein the case extraction model is used to extract semantic features and context features summarized by the text vector;

[0078] S103: Input the initial case text into a pre-trained case generation model to generate a final case text; wherein the case generation model includes a generation module and a comparison and scoring module, the generation module is used to generate a number of case texts according to the initial case text, and the comparison and scoring module is used to estimate the scores of the several case texts, and determine the final case text according to the scores of the several case texts.

[0079] This manual extracts the semantic vector extraction layer in the case model to learn the semantic relationship between each word in each sentence in the text content of the legal document, thereby extracting the semantic representation vector of each sentence in the text content, and inputs it into the context information extraction layer to learn the semantic relationship between different sentence vectors to extract the context information of the entire document, and then based on the context information, it can extract sentences with key information from the entire document and splice them into preliminary cases, thereby filtering out some redundant information in the entire document. In order to improve the quality and efficiency of generating cases, the preliminary cases are input into the pre-trained generated case model to generate the final case text, wherein a comparative scoring module is introduced into the generated case model, which draws on the idea of ​​comparative learning, and constructs a comparative loss function by comparing the length-normalized estimated logarithmic probability between the pseudo-optimal case and the candidate case, and between the candidate case, thereby improving the generation ability of the generated case model.

[0080] Legal documents include administrative law enforcement documents, litigation documents, formal ruling documents, notarized documents, and other documents involving legal content and with legal force. They usually record the facts of the parties' violations, reasons for punishment, basis, and decisions. The cause of action is a summary of the nature and content of the specific litigation case in the legal document. Through the cause of action, we can quickly understand the nature and content of the case and provide support for the understanding of the subsequent case. After receiving the legal document, it is necessary to extract the text content contained in the legal document and pre-process the text content to provide good data support for the subsequent model training. Since the text data faced by natural language processing is often unstructured and disorganized text data, and the data processed by the deep learning model is often fixed-length input and output, the deep learning model cannot directly process the original text data, and the text data must be converted into numbers, such as vectors. Text vectorization is an important way to represent text. Its main purpose is to represent text as a series of vectors that can express the semantics of the text, so that the computer can understand and process the text content.

[0081] In some embodiments of this specification, refer to Figure 3 As shown, the process of determining the text vector of the text content includes the following steps:

[0082] S301: Filter, correct errors and remove duplicates on the text content to obtain a processed text;

[0083] S302:分句-process the processed text to obtain a clause sequence;

[0084] S303:Encode the clause sequence to obtain a text vector.

[0085] Filtering, error correction, and deduplication of the text content can reduce the impact of noise on the model. In some embodiments, filtering mainly includes operations such as removing stop words. Stop words refer to words that appear frequently in the text but are not helpful for semantic analysis of the text, such as "de", "shi", etc. Removing stop words can reduce the noise in the text data and improve the accuracy of the model. Additionally, there may be problems such as spelling mistakes and grammar mistakes in the text content, and these problems need to be corrected. Common error correction methods include spelling correction and grammar correction. Furthermore, there may also be cases of repeated words and repeated characters in the text content, so it is necessary to perform deduplication processing on the repeated sentences and phrases. After the above basic processing is completed, it is necessary to perform clause processing on the processed text. This is because legal documents contain a large number of long and complex sentences. Clause splitting refers to splitting the text content according to certain rules and combining long sentences into multiple short sentences. Clause splitting can make the text data more structured and facilitate subsequent processing. In some embodiments, all long sentences can be split into several short sentences according to punctuation marks to obtain a clause sequence. In order for the deep learning model to better understand and process the text content, it is necessary to perform encoding processing on the clause sequence to map the text content into a feature representation vector. Optional encoding methods include One-hot encoding, Embedding encoding, etc. Thus, the text content of the legal document can be converted into a text vector.

[0086] In some embodiments of this specification, refer to Figure 2 As shown, the case extraction model includes a semantic vector extraction layer, a context information extraction layer, a fully connected layer, and a splicing layer. Among them, the semantic vector extraction layer focuses on learning the semantic relationship between each word within each clause, encodes the clause vector to obtain a semantic feature representation vector, and uses it as the semantic representation information of the whole sentence; the context information extraction layer focuses on the semantic relationship of the whole document, and obtains the context feature representation vector of the whole document by learning the semantic features between different clause vectors. Preferably, the semantic vector extraction layer can select the BERT model, which encodes and learns the input clause vector through a multi-layer bidirectional encoder and can better extract the semantic features contained in the input clause vector; the context information extraction layer can select a multi-layer Transformer, which filters out a small number of important features from a large number of features through the self-attention mechanism and focuses on these important features, ignoring most of the unimportant features, so as to better capture the internal correlation of the features.

[0087] In some embodiments, the training process of extracting the cause of action model includes the following steps:

[0088] Step a: Build a data set; crawl relevant legal documents from websites or judicial systems, extract text content from legal documents, and annotate short texts in the text content;

[0089] Step b: label the original corpus; divide the labeled short text into sentences and rearrange them according to the sentence length, divide all long sentences in the input legal document into short sentences according to punctuation marks, and obtain a sentence list of the input legal document; starting from the longest sentence in the labeled short text, perform similarity calculation in the sentence list of the input legal document, find the sentence that is most similar to the current longest labeled short sentence, and label the sentence as 1 until all sentences in the short text are matched, and label the sentences in the sentence list of the input legal document that do not match the labeled short text as 0.

[0090] Step c: Extract the training of the case cause model; use the sentence vectors similar to the short text extracted from the legal document in step b as labels, and divide the legal document into L Sequence of single clauses S i , then insert special tags "[CLS]" and "[SEP]" at the beginning and end of each sentence, and input the clause sequence into the BERT module for processing once and cache the vector of the "[CLS]" position t i,CLS ,in Freeze the BERT module weights and use the multi-layer Transformer structure as a module to model the contextual relationship between sentences, interacting through the multi-head self-attention mechanism t i,CLS The context feature representation vector is obtained by combining the information between the two layers. The fully connected layer is used to classify the context feature representation vector. The vector with the classification result of "1" indicates that the corresponding input is key information, and "0" indicates useless information. The input corresponding to the key information is concatenated as a preliminary summary. The loss function of the case extraction model adopts the binary cross entropy loss, and the calculation formula is shown in formula (1):

[0091] (1)

[0092] in, L ext_cross represents the loss function of the case extraction model, L is the clause sequence number, For the i The label classification prediction results of the input sentences, y i is the actual label result.

[0093] In some embodiments, the number of attention heads in the multi-layer Transformer layer is set to 8, the initial learning rate of the case extraction model is set to 2e-5, the batch size is set to 32, and a total of 100 rounds of training are performed. When the loss function does not decrease after more than 2000 batches, the training is terminated early.

[0094] Reference Figure 4 As shown, the text vector of the text content is input into the pre-trained case extraction model to generate the initial case text, including:

[0095] S401: Inputting the text vector of the text content into the semantic vector extraction layer to obtain the semantic representation vector of each sentence in the text content;

[0096] S402: inputting the semantic representation vector of each sentence in the text content into the context information extraction layer to obtain the context features of the text content;

[0097] S403: Inputting the context features of the text content into a fully connected layer to obtain a classification result for each sentence in the text content;

[0098] S404: Input the classification result of each sentence in the text content into the concatenation layer to obtain an initial case text.

[0099] In some embodiments, the fully connected layer is used to predict the label type of each sentence in the legal document input into the model, and the calculation formula of the prediction result is shown in formula (2):

[0100] (2)

[0101] in, For the i The label classification prediction result of the input sentence, W0 is the trainable weight matrix, Softmax (·)express Softmax function, Transformer(·) represents the Transformer network layer, t CLS ={ t 1,CLS , t 2,CLS ,…, t L,CLS} represents the "[CLS]" vector collection.

[0102] In some embodiments of this specification, refer to Figure 5 As shown, the classification result of each sentence in the text content is input into the splicing layer to obtain the initial case text, including:

[0103] S501: Obtaining a category label of each sentence vector from the classification result of each sentence in the text content;

[0104] S502: extracting sentence vectors whose category labels satisfy preset category labels, and concatenating them according to a preset sentence arrangement order to obtain an initial sentence vector set;

[0105] S503: Decode the initial sentence vector set to obtain an initial case text.

[0106] When the fully connected layer of the extraction model outputs the label prediction result of each sentence vector, the sentence vector with the sentence vector label "1" is extracted, indicating that the sentence vector contains key information. Then, according to the special marks before and after each sentence vector, namely "[CLS]" and "[SEP]", the arrangement order between the sentence vectors can be obtained. According to the arrangement, the extracted sentence vectors are smoothly spliced ​​to obtain the initial sentence vector set, and then the initial component vector set is decoded to generate the initial case text.

[0107] Since the initial case text is generated by extracting key information from legal documents, it still contains a lot of redundant information. In order to improve the quality of the generated case, the initial case text needs to be further optimized. In some embodiments of this specification, the quality of case generation is further optimized by generating a case model. Figure 2 As shown in the figure, the case generation model is mainly divided into two parts: the first part is the generation module, which uses the fine-tuned T5-PEGASUS of the Seq2Seq architecture; the second part draws on the idea of ​​contrastive learning and proposes a contrastive scoring module. By introducing contrastive loss, the generation ability of the generation module is enhanced, thereby reducing the possibility of the model generating low-quality cases. Specifically, the generation module generates k +1 case, and determine the pseudo-optimal case and candidate case through beam search score, where the one with the highest score is determined as the pseudo-optimal case. Beam search is a heuristic search algorithm used to quickly find the optimal solution in a large-scale search space. It reduces the search space by retaining a certain number of the most promising candidate solutions. Compared with the greedy search algorithm, it consumes less space and has high search efficiency. The pseudo-optimal case generated by the generation module and several candidate cases are input into the comparison scoring module. The comparison loss is constructed by calculating the scores between the pseudo-optimal case and the candidate case, and between the candidate case, and the cross entropy loss in the generation module is used to jointly optimize the module to obtain the final case generation result.

[0108] In some embodiments of this specification, refer to Figure 6 , before inputting the initial case text into the pre-trained case generation model, it also includes:

[0109] S601: Inputting the initial case text into a word segmenter for word segmentation to obtain the word count of the initial case text;

[0110] S602: Determine whether the word count of the initial case text exceeds a preset sequence length. If so, truncate the excess portion. If not, use special markers to complete the missing portion to obtain an input text sequence.

[0111] In some embodiments, the input of the T5-PEGASUS model is a fixed-length sequence. If the input sequence is too long or too short, it will affect the generation effect of the model. Therefore, before the initial case text is input into the generation module, the sequence of the input text needs to be detected. When the input sequence exceeds the preset sequence length, the excess part is truncated. When the input sequence is less than the preset sequence length, a special marker (such as [PAD]) is used to complete the missing part to reach the preset sequence length.

[0112] In some embodiments, the PEGASUS model often generates unsatisfactory cases due to the lack of training with Chinese corpus. After repeated experimental tests, the mT5 is used as the basic architecture and initial weights, and the word segmenter is first improved in combination with the characteristics of Chinese, and then the pre-training task is constructed according to the PEGASUS training process, so as to train a T5-PEGASUS model that is more suitable for Chinese corpus. The word segmenter used by mT5 is sentencepiece, but the generalization and robustness of this word segmenter for Chinese word segmentation are not high. Considering that the BERT model has better performance in processing Chinese corpus, the word segmenter in mT5 is first replaced with the word segmenter of the BERT model, but it is not enough to directly replace the original version of the Chinese BERT word segmenter. In order to make the word segmenter more in line with Chinese grammar, the BERT word segmenter needs to be improved. Specifically, we added the top 200,000 commonly used words based on the Jieba word segmentation to the dictionary of the original Chinese BERT, and then modified the logic of the original word segmenter so that it can perform Chinese word segmentation operations; then, we used the modified word segmenter to traverse and segment the pre-prepared pre-training corpus, counted the frequency of each word segmentation, and finally retained only the 50,000 most frequent words, ultimately obtaining a vocabulary of 50,000 words to construct the final new word segmenter.

[0113] In some embodiments of this specification, refer to Figure 7 As shown in the figure, the training process of generating the case cause model is as follows:

[0114] S701: Input the initial case text into the generation module, and generate a pseudo optimal case and several candidate cases through a beam search algorithm;

[0115] S702: Inputting the pseudo optimal case and several candidate cases into the comparison and scoring module for score estimation to obtain scores of the pseudo optimal case and several candidate cases;

[0116] S703: When the score of the pseudo optimal case is less than the scores of the plurality of candidate cases, a loss function of a generation module and a comparison and scoring module is calculated based on the scores;

[0117] S704: updating weight parameters of the generation module and the comparison and scoring module through a back propagation algorithm according to the loss functions of the generation module and the comparison and scoring module;

[0118] S705: Repeat the above process until the preset number of training times is met.

[0119] In some embodiments, for the training process of the T5-PEGASUS model, it is assumed that a document has n sentences, pick out about n / 4 clauses (which may not be continuous) make this n / 4 sentences together with the remaining 3 n / The longest common subsequence of the text composed of 4 sentences is as long as possible, and then 3 n / The text of 4 sentences is regarded as the original text. n / 4 sentences are concatenated as the case, thus forming a pseudo case data pair of [original text, case], which can be used to train the Seq2Seq model. It should be noted that when there are no repeated sentences in the document, the original text and the case will not have any intersection, so such a generation task is not a simple copy of the original text, but a more concise and refined case through one input.

[0120] In some embodiments, the generation module maintains multiple candidate targets in each processing sequence according to the beam search score, and generates k +1 candidate case, the case with the highest score is considered as the pseudo-optimal case S g , the rest are candidate cases S c , the specific calculation process is as follows:

[0121] (3)

[0122] (4)

[0123] in, Score ( S c | Z ) is a candidate case Sc The length-normalized estimated log probability of , i.e., the beam search score, Z Indicates input of full text. α It is a penalty hyperparameter related to the case length. It is usually set to less than 1 to avoid generating redundant information. cl Is a candidate case S c ={ s 1 , s 2 ,…, s cl}, that is, the number of key information contained. yes S c No. r The log-likelihood of the marker predictions, Indicates in sequence S c Zhongbidi r tokens earlier predicted the generated token, Indicates i Candidate cases.

[0124] In some embodiments, a conventional optimization method is adopted for the generation module, and the loss function adopts negative log-likelihood loss. The loss function represents the negative log-likelihood of all labels in the pseudo-optimal case. The specific calculation formula is as follows:

[0125] (5)

[0126] in, L gen_cross represents the loss function of the generation module, gl yes S g The number of tags included in s r Indicates r Marks, represents the first r The log-likelihood of the marker predictions, express S g In the r tags generated before, Z Represents the full text of the input. Since each token decoded during the module training phase depends on the previous true token, the case generated by the module is most similar to the true case. S truthHowever, in the test phase, there is no supervision at the intermediate tag level. Each tag during decoding depends on the tag predicted in the previous time step, which may lead to deviations in the tags during decoding. Therefore, the optimal case considered in the generation module is not necessarily the most similar to the reference case, so it is called a pseudo-optimal case in this manual.

[0127] In some embodiments, the pseudo-optimal case is used as a false positive sample S pos , the remaining candidate cases are treated as false negative samples S neg Due to the inevitable bias, some candidate cases will perform better than pseudo-optimal cases in the evaluation indicators. This specification selects ROUGE as the evaluation indicator. ROUGE is a set of indicators for evaluating automatic summarization and machine translation. It compares the automatically generated abstracts or translations with a set of reference abstracts (usually manually generated) and counts the basic units of overlap between the two ( n The number of metagrams, word sequences, and word pairs) is used to evaluate the quality of the abstract and obtain a corresponding score to measure the similarity between the automatically generated abstract or translation and the reference abstract. Based on the ROUGE evaluation index, only S pos The score is less than S neg When the score is obtained, the module is penalized, that is, the generated module is optimized if the condition in formula (6) is met.

[0128] Rouge ( S pos ,S truth )< Rouge ( S neg ,S truth ) (6)

[0129] in, Rouge (·) represents the ROUGE score, using length normalization to estimate the log probability Score As a measure of whether to carry out module optimization and the degree of optimization, Score ( S neg | Z )> Score ( S pos | Z ), the comparison scoring module is optimized, and the loss function between the pseudo-optimal case and the candidate case is as follows:

[0130] (7)

[0131] in, L gc represents the contrast loss between the pseudo-optimal case and the candidate case, k Indicates the number of candidate cases. k =0 means that the generation module only generates pseudo optimal cases. Indicates i Candidate cases, β gi =i*β Represents the interval margin, indicating and S pos The allowable error between β represents the margin, No. i The score of the candidate case, Score ( S pos | Z ) represents the score of the pseudo-optimal case, Z In addition, the comparison error between candidate case causes and candidate case causes is also included in the optimization range, and the error calculation of candidate case causes is shown in formula (8):

[0132] (8)

[0133] in, L cc represents the contrast loss between candidate cases, No. i The score of the candidate case, No. j The score of the candidate case, β ij =( j - i )* β Indicates j and i The candidate cases are sorted from large to small according to the ROUGE score. j > i hour, . And the actual evaluation index is taken into account in the process of ranking candidate cases, so the loss function also optimizes the module from the perspective of evaluation index. L contrast The loss function between the pseudo-optimal case and the candidate case, and between the candidate case and the candidate case is constructed. The specific calculation formula is shown in formula (9):

[0134] L contrast = L gc+ L cc (9)

[0135] In order to train the modules more effectively, the cross entropy loss of the generation module in formula (5) is combined with the contrast loss in the contrast scoring module to jointly construct the total loss function of the case generation model. The specific calculation formula is shown in formula (10):

[0136] L gen = L gen_cross + γL contrast (10)

[0137] in, γ It represents the balance parameter between cross entropy loss and contrast loss, and optimizes the module by controlling the two losses. Therefore, by continuously optimizing the loss function of the case generation model, the generation capability is further optimized, thereby improving the quality of the generated case.

[0138] In order to verify the effectiveness of a case generation method in this specification, a traditional summary generation method and a deep learning-based summary generation method were compared with the case generation method in this specification under the same experimental environment. The experimental results are shown in Table 1.

[0139] Table 1

[0140]

[0141] As can be seen from Table 1, the case generation method in this specification has improved the ROUGE-1, ROUGE-2, and ROUGE-L indicators by 3.16%, 6.33%, and 4.00%, respectively, compared with the summary generation method based on deep learning, indicating that the case generation method in this specification can generate higher quality cases.

[0142] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties. And the acquisition, storage, use, and processing of data in the technical solutions described in the embodiments of this application are in compliance with relevant regulations.

[0143] Based on the above-mentioned method for generating a legal document cause, the embodiment of this specification also provides a corresponding device for generating a legal document cause. The device may include a system (including a distributed system), software (application), module, component, server, client, etc. using the method described in the embodiment of this specification and a device combined with necessary implementation hardware. Based on the same innovative concept, the device in one or more embodiments provided in the embodiment of this specification is as described in the following embodiments. Since the implementation scheme and method of the device to solve the problem are similar, the implementation of the specific device in the embodiment of this specification can refer to the implementation of the aforementioned method, and the repetitions will not be repeated. As used below, the term "unit" or "module" can be a combination of software and / or hardware that implements a predetermined function. Although the device described in the following embodiments is preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceived.

[0144] Specifically, Figure 8 This is a schematic diagram of the module structure of an embodiment of a legal document cause generation device provided in the embodiment of this specification, referring to Figure 8 As shown, a legal document cause generation device provided in an embodiment of this specification includes:

[0145] The receiving module 801 is used to receive a legal document and obtain the text content of the legal document;

[0146] The first generation module 802 is used to determine the text vector of the text content, input the text vector of the text content into a pre-trained case extraction model, and generate an initial case text; wherein the case extraction model is used to extract semantic features and context features summarized by the text vector;

[0147] The second generation module 803 is used to input the initial case text into a pre-trained case generation model to generate a final case text; wherein the case generation model includes a generation module and a comparison and scoring module, the generation module is used to generate a number of case texts based on the initial case text, and the comparison and scoring module is used to estimate the scores of the several case texts, and determine the final case text according to the scores of the several case texts.

[0148] The beneficial effects obtained by the device provided in the embodiments of this specification are consistent with the beneficial effects obtained by the above method and will not be repeated here.

[0149] Reference Fig. 9As shown, based on the above-mentioned method for generating a legal document cause, a computer device 902 is also provided in an embodiment of this specification, wherein the above-mentioned method runs on the computer device 902. The computer device 902 may include one or more processors 904, such as one or more central processing units (CPUs), each of which may implement one or more hardware threads. The computer device 902 may also include any memory 906, which is used to store any kind of information such as code, settings, data, etc. Non-limitingly, for example, the memory 906 may include any one or more combinations of the following: any type of RAM, any type of ROM, flash memory device, hard disk, optical disk, etc. More generally, any memory may use any technology to store information. Further, any memory may provide volatile or non-volatile retention of information. Further, any memory may represent a fixed or removable component of the computer device 902. In one case, when the processor 904 executes an associated instruction stored in any memory or a combination of memories, the computer device 902 may perform any operation of the associated instruction. The computer device 902 also includes one or more drive mechanisms 908 for interacting with any storage, such as a hard disk drive mechanism, an optical disk drive mechanism, etc.

[0150] The computer device 902 may also include an input / output module 910 (I / O) for receiving various inputs (via input devices 912) and for providing various outputs (via output devices 914). A specific output mechanism may include a presentation device 916 and an associated graphical user interface (GUI) 918. In other embodiments, the input / output module 910 (I / O), the input device 912, and the output device 914 may not be included, and the computer device 902 may be used as a computer device in a network. The computer device 902 may also include one or more network interfaces 920 for exchanging data with other devices via one or more communication links 922. One or more communication buses 924 couple the components described above together.

[0151] The communication link 922 may be implemented in any manner, for example, through a local area network, a wide area network (e.g., the Internet), a point-to-point connection, etc., or any combination thereof. The communication link 922 may include any combination of hardwired links, wireless links, routers, gateway functions, name servers, etc. governed by any protocol or combination of protocols.

[0152] Corresponding to Figures 1 to 7 In addition to the method shown, an embodiment of the specification also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the above method are executed.

[0153] The embodiment of the present specification also provides a computer-readable instruction, wherein when the processor executes the instruction, the program therein causes the processor to execute the following Figures 1 to 7 The method shown.

[0154] It should be understood that in the various embodiments of this specification, the size of the serial numbers of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this specification.

[0155] It should also be understood that in the embodiments of this specification, the term "and / or" is only a description of the association relationship of the associated objects, indicating that three relationships can exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this specification generally indicates that the associated objects before and after are in an "or" relationship.

[0156] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed in this specification can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this specification.

[0157] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0158] In the several embodiments provided in this specification, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, or it can be an electrical, mechanical or other form of connection.

[0159] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the embodiments of this specification.

[0160] In addition, each functional unit in each embodiment of this specification may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0161] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this specification is essentially or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the method described in each embodiment of this specification. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.

[0162] Specific embodiments are used in this specification to illustrate the principles and implementation methods of this specification. The description of the above embodiments is only used to help understand the methods and core ideas of this specification. At the same time, for those skilled in the art, according to the ideas of this specification, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on this specification.

Claims

1. A method for generating a legal document cause of action, characterized in that: The method comprises: Receiving legal documents and obtaining the text content of said legal documents; Determine a text vector of the text content, input the text vector of the text content into a pre-trained case extraction model, and generate an initial case text; wherein the case extraction model is used to extract semantic features and context features summarized by the text vector; Inputting the initial case text into a pre-trained case generation model to generate a final case text; wherein the case generation model includes a generation module and a comparison and scoring module, the generation module is used to generate a plurality of case texts according to the initial case text, and the comparison and scoring module is used to estimate the scores of the plurality of case texts, and determine the final case text according to the scores of the plurality of case texts; The case extraction model includes: a semantic vector extraction layer, a context information extraction layer, a fully connected layer and a splicing layer; the text vector of the text content is input into the pre-trained case extraction model to generate an initial case text, including: Inputting the text vector of the text content into the semantic vector extraction layer to obtain the semantic representation vector of each sentence in the text content; Inputting the semantic representation vector of each sentence in the text content into the context information extraction layer to obtain the context features of the text content; Inputting the context features of the text content into a fully connected layer to obtain a classification result for each sentence in the text content; Inputting the classification result of each sentence in the text content into the concatenation layer to obtain an initial case text; The step of inputting the classification result of each sentence in the text content into the concatenation layer to obtain the initial case text includes: Obtaining a category label of each sentence vector from the classification result of each sentence in the text content; Extract the sentence vectors whose category labels meet the preset category labels, and concatenate them according to the preset sentence arrangement order to obtain an initial sentence vector set; Decoding the initial sentence vector set to obtain an initial case text; The training process of generating the case cause model includes: Inputting the initial case text into the generation module, and generating a pseudo optimal case and several candidate cases through a beam search algorithm; Inputting the pseudo optimal case and several candidate cases into the comparison and scoring module for score estimation to obtain scores of the pseudo optimal case and several candidate cases; Updating weight parameters of the generation module and the comparison and scoring module through a back propagation algorithm according to the loss functions of the generation module and the comparison and scoring module; Repeat the above process until the preset number of training times is met; Among them, the loss function of the generation module and the comparison scoring module is calculated using the following formula: ; ; in, L gen_cross is the loss function of the generation module, gl is the number of tags included in the pseudo-optimal case, s r Indicates r Marks, Indicates the pseudo optimal case sequence No. r The log-likelihood of the marker predictions, Indicates that the pseudo optimal case is r tags generated before, Z Represents input text; L contrast To compare the loss function of the scoring module, k The number of candidate cases, Indicates i Candidate cases, S pos represents a pseudo optimal case, β gi express and S pos The spacing margin between No. i The score of the candidate case, Score ( S pos | Z ) represents the score of the pseudo-optimal case, Indicates j Candidate cases, β ij Indicates j and i The interval margin between candidate cases.

2. The method according to claim 1, characterized in that The determining of the text vector of the text content comprises: Filtering, correcting errors and removing duplicates on the text content to obtain a processed text; Performing sentence processing on the processed text to obtain a clause sequence; The clause sequence is encoded to obtain a text vector.

3. The method according to claim 1, characterized in that: Before inputting the initial case text into the pre-trained case generation model, the method further includes: Input the initial case text into a word segmenter for word segmentation to obtain the word quantity of the initial case text; It is determined whether the word count of the initial case text exceeds the preset sequence length. If so, the excess part is truncated; if not, a special mark is used to complete the missing part to obtain an input text sequence.

4. A device for generating a legal document, characterized in that: The device comprises: A receiving module, used to receive a legal document and obtain the text content of the legal document; A first generation module is used to determine the text vector of the text content, input the text vector of the text content into a pre-trained case extraction model, and generate an initial case text; wherein the case extraction model is used to extract semantic features and context features summarized by the text vector; A second generation module is used to input the initial case text into a pre-trained case generation model to generate a final case text; wherein the case generation model includes a generation module and a comparison and scoring module, the generation module is used to generate a plurality of case texts according to the initial case text, the comparison and scoring module is used to estimate the scores of the plurality of case texts, and determine the final case text according to the scores of the plurality of case texts; The case extraction model includes: a semantic vector extraction layer, a context information extraction layer, a fully connected layer and a splicing layer; the text vector of the text content is input into the pre-trained case extraction model to generate an initial case text, including: Inputting the text vector of the text content into the semantic vector extraction layer to obtain the semantic representation vector of each sentence in the text content; Inputting the semantic representation vector of each sentence in the text content into the context information extraction layer to obtain the context features of the text content; Inputting the context features of the text content into a fully connected layer to obtain a classification result for each sentence in the text content; Inputting the classification result of each sentence in the text content into the concatenation layer to obtain an initial case text; The step of inputting the classification result of each sentence in the text content into the concatenation layer to obtain the initial case text includes: Obtaining a category label of each sentence vector from the classification result of each sentence in the text content; Extract the sentence vectors whose category labels meet the preset category labels, and concatenate them according to the preset sentence arrangement order to obtain an initial sentence vector set; Decoding the initial sentence vector set to obtain an initial case text; The training process of generating the case cause model includes: Inputting the initial case text into the generation module, and generating a pseudo optimal case and several candidate cases through a beam search algorithm; Inputting the pseudo optimal case and several candidate cases into the comparison and scoring module for score estimation to obtain scores of the pseudo optimal case and several candidate cases; Updating weight parameters of the generation module and the comparison and scoring module through a back propagation algorithm according to the loss functions of the generation module and the comparison and scoring module; Repeat the above process until the preset number of training times is met; Among them, the loss function of the generation module and the comparison scoring module is calculated using the following formula: ; ; in, L gen_cross is the loss function of the generation module, gl is the number of tags included in the pseudo-optimal case, s r Indicates r Marks, Indicates the pseudo optimal case sequence No. r The log-likelihood of the marker predictions, Indicates that the pseudo optimal case is r tags generated before, Z Represents input text; L contrast To compare the loss function of the scoring module, k The number of candidate cases, Indicates i Candidate cases, S pos represents a pseudo optimal case, β gi express and S pos The spacing margin between No. i The score of the candidate case, Score ( S pos | Z ) represents the score of the pseudo-optimal case, Indicates j Candidate cases, β ij Indicates j and i The interval margin between candidate cases.

5. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 3 is implemented.

6. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 3 is implemented.

Citation Information

Patent Citations

  • Method and device for identifying law document causes

    CN110472231A

  • Method and device for recognizing elements in judicial documents

    CN111291570A

  • Document abstract generation method and device, equipment and storage medium

    CN113420143A

  • Intelligent administrative law enforcement case information extraction and cause affirmation method

    CN114547230A

  • Automatic legal instrument generation system

    CN116822477A