A method and system for analyzing elements of legal documents

By pre-training language models for sentence processing and element analysis of legal documents, the problem of high element extraction cost and low accuracy in legal judgments is solved, automatic element extraction is realized, and the efficiency and accuracy of judgments are improved.

CN112329436BActive Publication Date: 2024-08-23BEIJING GRIDSUM TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN201910695870.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-07-30
Publication Date
2024-08-23
Estimated Expiration
2039-07-30

AI Technical Summary

Technical Problem

In the existing technology, element extraction in legal judgments has the problems of high labor cost, high time cost, low accuracy and low efficiency. In particular, the diversity of descriptions of the conviction elements due to language diversity affects the accuracy and efficiency of the judgment.

Method used

The element parsing model is obtained by pre-training the language model, and the legal documents are segmented into sentences. The sentences to be parsed are input into the element parsing model one by one for element analysis. The BERT model is used for text replacement and sentence splicing. The model is trained until convergence, and the result is obtained. Analyzed model parameters to achieve automated feature extraction.

Benefits of technology

It saves labor and time costs, improves the accuracy and efficiency of legal judgments, reduces the reliance on manual extraction of elements, and improves the accuracy and efficiency of judgments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112329436B
    Figure CN112329436B
Patent Text Reader

Abstract

The present invention provides a method and system for parsing elements of a legal document, the method comprising: obtaining a legal document to be parsed. Sentence processing is performed on the legal document to obtain a plurality of sentences to be parsed. The sentences to be parsed are input into a pre-established element parsing model one by one to perform element parsing, and the elements contained in each sentence to be parsed in the legal document are obtained, wherein the element parsing model is obtained by training a language model based on sample data. In this scheme, an element parsing model is obtained by pre-training a language model with a massive amount of legal documents, the legal document to be parsed is sentence processed to obtain a plurality of sentences to be parsed, and each sentence to be parsed is used as an input to the element parsing model to obtain the elements in each sentence to be parsed, thereby saving labor costs and time costs and improving the accuracy and efficiency of judgments.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of legal document processing, and in particular to a method and system for analyzing elements of a legal document. Background Art

[0002] When making legal judgments, the more common method is currently the element-based trial. That is, based on the case information, the elements in the case are extracted one by one, and finally the legal judgment is made based on the extracted case elements. However, on the one hand, since the case information contains a variety of information, it usually takes a lot of time and manpower to manually extract the elements required for judgment from a variety of information. On the other hand, due to the diversity of languages, there are usually multiple different descriptions and expressions for the same conviction element, which will affect the accuracy and efficiency of the judgment. Summary of the invention

[0003] In view of this, an embodiment of the present invention provides a method and system for analyzing elements of a legal document to solve the problems of high labor cost, high time cost, low accuracy and low efficiency in the existing manual element extraction.

[0004] To achieve the above objectives, the embodiments of the present invention provide the following technical solutions:

[0005] A first aspect of an embodiment of the present invention discloses a method for analyzing elements of a legal document, the method comprising:

[0006] Obtain legal documents to be parsed;

[0007] The legal document is processed into sentences to obtain a plurality of sentences to be parsed;

[0008] The sentences to be parsed are input one by one into a pre-established element parsing model for element parsing, so as to obtain the elements contained in each sentence to be parsed in the legal document, wherein the element parsing model is obtained by training a language model based on sample data, and the language model is used to perform pre-training based on a preset number of legal texts to determine the initialization model parameters of the element parsing model.

[0009] Preferably, when the language model is a BERT model, the process of obtaining a factor parsing model by training the language model based on sample data includes:

[0010] Performing word replacement and sentence concatenation processing on the sample data to obtain first training data, wherein the sample data is obtained by performing sentence segmentation processing on public legal documents;

[0011] Using the first training data as an input of a first BERT model, and training the first BERT model in combination with a preset first loss function and the sample data until the first BERT model converges;

[0012] Using the converged model parameters of the first BERT model as the initialization model parameters of the second BERT model;

[0013] The second training data is used as the input of the second BERT model, and the second BERT model is trained in combination with a preset second loss function until the second BERT model converges to obtain the element parsing model, wherein the second training data is obtained by selecting a preset number of legal documents from the sample data for element annotation.

[0014] Preferably, the using the first training data as the input of the first BERT model, and training the first BERT model in combination with a preset first loss function and the sample data until the first BERT model converges, includes:

[0015] Using the first training data as input of the first BERT model, obtaining a character prediction result corresponding to a character replacement position, and obtaining a sentence prediction result corresponding to a sentence concatenation position;

[0016] Using a first sub-loss function to calculate a text error between an actual text at the text replacement position and a text prediction result, and using a second sub-loss function to calculate a sentence error between an actual sentence at the sentence concatenation position and a sentence prediction result;

[0017] Based on the word error and the sentence error, training the first BERT model in combination with the first training data until the first BERT model converges;

[0018] The actual text and actual sentences are derived from the sample data.

[0019] Preferably, the step of performing word replacement and sentence concatenation processing on the sample data to obtain the first training data includes:

[0020] The text in the sample data is randomly replaced with preset characters, and a second sentence is randomly concatenated with the first sentence in the sample data, wherein the second sentence is the next sentence corresponding to the first sentence or is not the next sentence corresponding to the first sentence.

[0021] Preferably, the step of taking the sentences to be parsed one by one as inputs of a pre-established element parsing model to perform element parsing, and obtaining the elements contained in each sentence to be parsed in the legal document, further comprises:

[0022] The elements contained in each of the sentences to be parsed are merged.

[0023] A second aspect of an embodiment of the present invention discloses a legal document element parsing system, the system comprising:

[0024] An acquisition unit, used for acquiring the legal document to be parsed;

[0025] A processing unit, used for performing sentence processing on the legal document to obtain a plurality of sentences to be parsed;

[0026] A prediction unit is used to input the sentences to be parsed one by one into a pre-established element parsing model for element parsing, so as to obtain elements contained in each of the sentences to be parsed in the legal document, wherein the element parsing model is obtained by training a language model based on sample data, and the language model is used to perform pre-training based on a preset number of legal texts to determine the initialization model parameters of the element parsing model.

[0027] Preferably, when the language model is a BERT model, the prediction unit includes:

[0028] A processing module, configured to perform text replacement and sentence concatenation processing on the sample data to obtain first training data, wherein the sample data is obtained by performing sentence segmentation processing on a public legal document;

[0029] A first training module, configured to use the first training data as an input of a first BERT model, and train the first BERT model in combination with a preset first loss function and the sample data until the first BERT model converges;

[0030] A setting module, configured to use the converged model parameters of the first BERT model as initialization model parameters of the second BERT model;

[0031] The second training module is used to use the second training data as the input of the second BERT model, and train the second BERT model in combination with a preset second loss function until the second BERT model converges to obtain the element parsing model, wherein the second training data is obtained by selecting a preset number of legal documents from the sample data for element annotation.

[0032] Preferably, the first training module includes:

[0033] A prediction submodule, configured to use the first training data as an input of the first BERT model to obtain a text prediction result corresponding to a text replacement position, and obtain a sentence prediction result corresponding to a sentence concatenation position;

[0034] an error submodule, configured to calculate a text error between an actual text at the text replacement position and the text prediction result using a first sub-loss function, and to calculate a sentence error between an actual sentence at the sentence concatenation position and the sentence prediction result using a second sub-loss function;

[0035] A training submodule, configured to train the first BERT model based on the word error and the sentence error in combination with the first training data until the first BERT model converges;

[0036] The actual text and actual sentences are derived from the sample data.

[0037] A third aspect of an embodiment of the present invention discloses a storage medium, which includes a stored program, wherein when the program is running, the device where the storage medium is located is controlled to execute the legal document element parsing method disclosed in the first aspect of the embodiment of the present invention.

[0038] The fourth aspect of an embodiment of the present invention discloses a legal document element parsing device, including a storage medium and a processor, wherein the storage medium stores a program, and the processor is used to run the program, wherein when the program is running, the legal document element parsing method disclosed in the first aspect of the embodiment of the present invention is executed.

[0039] Based on the above-mentioned embodiment of the present invention, a method and system for parsing elements of a legal document are provided. The method is as follows: obtain a legal document to be parsed. Process the legal document into sentences to obtain a plurality of sentences to be parsed. Input the sentences to be parsed into a pre-established element parsing model one by one to perform element parsing, and obtain the elements contained in each sentence to be parsed in the legal document, wherein the element parsing model is obtained by training a language model based on sample data. In this scheme, an element parsing model is obtained by pre-training a language model with a massive amount of legal documents, and the legal document to be parsed is processed into sentences to obtain a plurality of sentences to be parsed. Each sentence to be parsed is used as an input to the element parsing model to obtain the elements in each sentence to be parsed. Analysis and judgment operations are performed based on the extracted case elements, and there is no need to manually extract the elements in the case one by one, thereby saving labor costs and time costs and improving the accuracy and efficiency of judgments. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] In order to more clearly illustrate the embodiments of the present invention 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 embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.

[0041] Figure 1A schematic diagram of the Transformer structure provided by an embodiment of the present invention;

[0042] Figure 2 A flowchart of a method for parsing elements of a legal document provided by an embodiment of the present invention;

[0043] Figure 3 A flowchart of obtaining a factor parsing model provided by an embodiment of the present invention;

[0044] Figure 4 A flowchart of training a first BERT model provided by an embodiment of the present invention;

[0045] Figure 5 A schematic diagram of the structure of a legal document element parsing system provided by an embodiment of the present invention;

[0046] Figure 6 A schematic diagram of the structure of a crime legal document element parsing system provided by an embodiment of the present invention;

[0047] Figure 7 A schematic diagram of the structure of a legal document element parsing system provided by an embodiment of the present invention;

[0048] Figure 8 A structural diagram of a legal document element parsing system provided in an embodiment of the present invention. DETAILED DESCRIPTION

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

[0050] In this application, the terms "comprises", "comprising" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprising a ..." does not exclude the presence of other identical elements in the process, method, article or device comprising the element.

[0051] As can be seen from the background technology, the current method for extracting case elements is to manually extract the elements in the case one by one based on the case information, and finally make a legal judgment based on the extracted case elements. However, on the one hand, since case information contains a variety of information, it usually takes a lot of time and manpower to manually extract the elements required for judgment from a variety of information. On the other hand, due to the diversity of languages, there are usually multiple different descriptions and expressions for the same conviction element, which will affect the accuracy and efficiency of the judgment.

[0052] Therefore, an embodiment of the present invention provides a method and system for parsing elements of legal documents, which pre-trains a language model with a large number of legal documents to obtain an element parsing model, divides the legal document to be parsed into sentences to obtain multiple sentences to be parsed, and uses each sentence to be parsed as an input to the element parsing model to obtain the elements in each sentence to be parsed, so as to save manpower and time costs, and improve the accuracy and efficiency of judgments.

[0053] It should be noted that the Bidirectional Encoder Representation from Transformers (BERT) model involved in the embodiments of the present invention is a language model proposed by Google, which has a strong abstract ability for text in the field of natural language processing. The BERT model has a 12-layer Transformer structure. The specific structure of the BERT model is: the text input into the embedding layer is segmented according to the word, the word is mapped to a 768-dimensional vector based on the word vector mapping weight provided by Google, and then the encoding vector Enc is obtained through a 12-layer Transformer structure.

[0054] refer to Figure 1 , shows the schematic diagram of the Transformer structure. Figure 1 In the embodiment of the present invention, the Transformer includes multi-head attention, residual unit, layer normalization and two layers of full connection (FFN).

[0055] It should be noted that the factor parsing model involved in the embodiments of the present invention is constructed for different legal fields, that is, for a type of legal field, the sample data corresponding to the legal field is used to train the BERT model to obtain the factor parsing model corresponding to the legal field. For example, for the field of marriage and family affairs, the legal documents related to the field of marriage and family affairs in the legal documents network are used as sample data to train the BERT model to obtain the factor parsing model corresponding to the field of marriage and family affairs.

[0056] refer to Figure 2, shows a flow chart of a method for parsing elements of a legal document provided by an embodiment of the present invention, the method for parsing elements of a legal document comprising the following steps:

[0057] Step S201: Obtain the legal document to be parsed.

[0058] Step S202: Segment the legal document to obtain a plurality of sentences to be parsed.

[0059] In the specific implementation of step S202, a language technology platform (LTP) is used to perform sentence processing on the legal document to obtain a sentence set including multiple sentences to be parsed.

[0060] Step S203: Input the sentences to be parsed one by one into the pre-established element parsing model for element parsing, and obtain the elements contained in each sentence to be parsed in the legal document.

[0061] In the process of implementing step S203, the legal documents required for training the factor parsing model are screened out from the data disclosed by the legal document network, and the legal documents are processed by using LTP to obtain sample data, and the language model is trained based on the sample data to obtain the factor parsing model. For example, assuming that the legal field corresponding to the factor parsing model is the field of marriage and family affairs, the legal documents in the field of marriage and family affairs are screened out from the legal document network, and the legal documents in the field of marriage and family affairs are processed by using LTP to obtain sample data, and the language model is trained based on the sample data to obtain the factor parsing model corresponding to the field of marriage and family affairs. When it is necessary to perform factor parsing on the legal documents in the field of marriage and family affairs, the legal documents are processed by sentence parsing and then input into the factor parsing model corresponding to the field of marriage and family affairs for factor parsing, so as to obtain the elements contained in each sentence in the legal documents in the field of marriage and family affairs.

[0062] It should be noted that the language model is used to perform pre-training based on a preset number of legal texts to determine the initialization model parameters of the factor parsing model. The types of the language model include but are not limited to: ELMo model, GPT model and BERT model.

[0063] It should be noted that by inputting each of the sentences to be parsed into a pre-established element parsing model for element parsing, 0 elements or more than 1 element contained in each of the sentences to be parsed can be obtained.

[0064] Preferably, after executing step S203, the elements contained in each of the sentences to be parsed are merged.

[0065] It should be noted that there are two requirements for the analysis results of the elements of the legal document. One is to obtain only the elements contained in each sentence in the legal document, and the other is to merge the elements contained in each sentence in the legal document to obtain the element set of the legal document.

[0066] In the embodiment of the present invention, a language model is pre-trained with a large number of legal documents to obtain an element parsing model, the legal document to be parsed is processed into sentences to obtain multiple sentences to be parsed, each sentence to be parsed is used as an input of the element parsing model to obtain the elements in each sentence to be parsed, and a legal judgment is made based on the extracted case elements. There is no need to manually extract the elements in the case one by one, and then make a legal judgment based on the manually extracted elements, which saves labor costs and time costs and improves the accuracy and efficiency of the judgment.

[0067] The above embodiments of the present invention Figure 2 The process of obtaining a factor parsing model by training a language model based on sample data in step S203 disclosed herein, when the language model is a BERT model, can be referred to Figure 3 , which shows a flowchart of obtaining a factor parsing model provided by an embodiment of the present invention, including the following steps:

[0068] Step S301: Perform text replacement and sentence concatenation processing on the sample data to obtain first training data.

[0069] In the specific implementation of step S301, the sample data is obtained by sentence processing of the public legal document. For the specific processing process, see the above embodiment of the present invention. Figure 2 The corresponding contents in the disclosed step S203 will not be repeated here.

[0070] When performing text replacement and sentence concatenation, randomly select text from the sample data, replace the text with preset characters, and randomly concatenate a second sentence with the first sentence in the sample data, wherein the second sentence is the next sentence corresponding to the first sentence or is not the next sentence corresponding to the first sentence. For example: randomly replace the text in the sample with "[MASK]". Select the sentence that needs to be concatenated, with a 50% probability of being the next sentence corresponding to the sentence, and a 50% probability of being concatenated with other sentences.

[0071] It should be noted that the random replacement of words and splicing of sentences mentioned above are only for illustrative purposes, and the technicians may also specifically select which words need to be replaced with characters and which sentences need to be spliced. Similarly, some words may be replaced with characters every preset number of words, and some sentences may be spliced ​​every preset number of sentences, which is not specifically limited in the embodiments of the present invention.

[0072] Step S302: Using the first training data as input of a first BERT model, combining a preset first loss function and the sample data, and training the first BERT model until the first BERT model converges.

[0073] It should be noted that in the specific implementation of step S302, the first training data is used as the input of the first BERT model to predict the text at the text replacement site and the sentence at the sentence splicing site, and the first BERT model is trained to judge the text and sentence based on the error between the predicted result and the actual result. For example: for a complete sentence, randomly replace a word in the sentence with a preset character, and train the first BERT model to judge what the actual text is at the preset character site of the sentence. For a whole paragraph of content consisting of multiple sentences, perform sentence splicing on a certain sentence, and train the first BERT model to judge what the actual sentence corresponding to the splicing site of the sentence is.

[0074] Step S303: Using the converged model parameters of the first BERT model as initialization model parameters of the second BERT model.

[0075] In the specific implementation process of step S303, the parameters of the embedding layer and the 12-layer transformer structure in the first BERT model after convergence are used as initialization parameters of the embedding layer and the 12-layer transformer structure in the second BERT model.

[0076] Step S304: using the second training data as the input of the second BERT model, and training the second BERT model in combination with a preset second loss function until the second BERT model converges, thereby obtaining the factor parsing model.

[0077] In the process of implementing step S304, a 768-dimensional vector is selected after the encoding vector Enc in the second BERT model, and the 768-dimensional vector is connected to the number of categories required for element parsing through a 768-dimensional fully connected layer, and the weighted cross entropy loss function (sigmoid cross entropy loss) is used as the second loss function to train the second BERT model. The specific training process is as shown in processes A1-A3. It should be noted that the dimensions of the vectors and fully connected layers involved above include but are not limited to 768 dimensions. The second training data is obtained by selecting a preset number of legal documents from the sample data for element annotation. For example: 800-1000 legal documents are selected from the sample data for sentence segmentation and element annotation to obtain the second training data.

[0078] A1: For each training sentence in the second training data, input each training sentence into the second BERT model for prediction to obtain prediction elements contained in each training sentence.

[0079] A2: Using the second loss function to calculate the error between the predicted element and the actual element contained in each of the training sentences.

[0080] A3: If the error is less than a threshold, the factor parsing model is constructed based on the current model parameters of the second BERT model. If the error is greater than a threshold, the model parameters of the second BERT model are adjusted based on the error, the second BERT model is trained based on the second training data until the error is less than the threshold, and the trained second BERT model is determined to be the factor parsing model.

[0081] It should be noted that the contents involved in the above processes A1-A3 are only used for illustration.

[0082] It should be noted that training a neural network model requires one or a series of initial parameters. The initial parameters of a traditional neural network model usually use a random parameter of a normal distribution with a mean of 0 and a small variance. The initial parameter determination method of a traditional neural network model has a poor prediction effect on text elements. In an embodiment of the present invention, by pre-training the first BERT model until convergence, when training the second BERT model, the parameters of the second BERT model are initialized using the parameter structure of the trained first BERT model, providing the second BERT model with sufficient prior information in the legal field, and effectively improving the accuracy of element prediction of the element parsing model.

[0083] In an embodiment of the present invention, a first BERT model is trained by first training data until convergence, the model parameters of the converged first BERT model are used as the initialization model parameters of the second BERT model, and the second BERT model is trained by second training data until convergence to obtain an element parsing model. The element parsing model is used to perform element parsing on the legal document after sentence processing to obtain the elements contained in each sentence in the legal document, and a legal judgment is made based on the extracted case elements. There is no need to manually extract the elements in the case one by one, and then make a legal judgment based on the manually extracted elements, which can effectively reduce labor costs and time costs, and provide judgment accuracy and efficiency.

[0084] The above embodiments of the present invention Figure 3 The disclosed step S302 involves the process of training the first BERT model, see Figure 4, shows a flowchart of training a first BERT model provided by an embodiment of the present invention, including the following steps:

[0085] Step S401: using the first training data as input of the first BERT model to obtain a text prediction result corresponding to a text replacement position, and to obtain a sentence prediction result corresponding to a sentence concatenation position.

[0086] It should be noted that the process of obtaining the first training data is as described in the above embodiment of the present invention. Figure 3 The contents corresponding to the disclosed step S301 will not be repeated here.

[0087] Step S402: using the first sub-loss function to calculate the text error between the actual text at the text replacement position and the text prediction result, and using the second sub-loss function to calculate the sentence error between the actual sentence at the sentence concatenation position and the sentence prediction result.

[0088] In the specific implementation of step S402, a first 768-dimensional vector is selected from the encoding vector Enc, and the 768-dimensional vector is respectively connected to the first sub-loss function and the second sub-loss function through a 768-dimensional fully connected layer. It should be noted that the dimensions of the vectors and fully connected layers involved above include but are not limited to 768 dimensions.

[0089] It should be noted that the first sub-loss function includes but is not limited to: a multi-classification softmax cross entropy loss function, and the second sub-loss function includes but is not limited to: a binary classification softmax cross entropy loss function.

[0090] Step S403: Based on the text error and the sentence error, the first BERT model is trained in combination with the first training data until the first BERT model converges.

[0091] In the specific implementation of step S403, the actual text and the actual sentence are derived from the sample data, that is, the actual text at the text replacement position and the actual sentence at the sentence splicing position can be obtained through the sample data. If the text error and the sentence error are both less than the threshold, the first BERT is converged. If the text error and the sentence error are both greater than the threshold, the model parameters of the first BERT model are adjusted based on the text error and the sentence error, and the first BERT model is continuously trained using the first training data until the text error and the sentence error are both less than the threshold.

[0092] In an embodiment of the present invention, before obtaining the factor parsing model, a first BERT model is trained with first training data based on a first sub-loss function and a second sub-loss function until convergence, and the model parameters of the converged first BERT model are used as initialization model parameters of the second BERT model. The second BERT model is then trained based on the training data until convergence to obtain the factor parsing model, which can improve the accuracy of factor parsing.

[0093] Corresponding to the method for analyzing legal document elements disclosed in the above embodiment of the present invention, reference is made to Figure 5 The embodiment of the present invention further provides a legal document element parsing system, and the legal document element parsing system includes: an acquisition unit 501, a processing unit 502 and a prediction unit 503.

[0094] The acquisition unit 501 is used to acquire the legal document to be parsed.

[0095] The processing unit 502 is used to process the legal document by sentence division to obtain multiple sentences to be parsed. For the specific processing process of the legal document, please refer to the above embodiment of the present invention. Figure 2 The content corresponding to step S202 is disclosed.

[0096] The prediction unit 503 is used to input the sentences to be parsed into the pre-established factor parsing model one by one for factor parsing, and obtain the factors contained in each sentence to be parsed in the legal document, wherein the factor parsing model is obtained by training a language model based on sample data, and the language model is used to perform pre-training based on a preset number of legal texts to determine the initialization model parameters of the factor parsing model. The process of obtaining the sample data can be found in the above-mentioned embodiment of the present invention. Figure 2 The content corresponding to step S203 is disclosed.

[0097] In the embodiment of the present invention, a language model is pre-trained with a large number of legal documents to obtain an element parsing model, the legal document to be parsed is processed into sentences to obtain multiple sentences to be parsed, each sentence to be parsed is used as an input of the element parsing model to obtain the elements in each sentence to be parsed, and a legal judgment is made based on the extracted case elements. There is no need to manually extract the elements in the case one by one, and then make a legal judgment based on the manually extracted elements, which saves labor costs and time costs and improves the accuracy and efficiency of the judgment.

[0098] refer to Figure 6 , showing a structural block diagram of a legal document element parsing system provided by an embodiment of the present invention, when the language model is a BERT model, the prediction unit 503 includes: a processing module 5031, a first training module 5032, a setting module 5033 and a second training module 5034.

[0099] The processing module 5031 is used to perform text replacement and sentence concatenation processing on the sample data to obtain first training data, wherein the sample data is obtained based on sentence segmentation processing of public legal documents.

[0100] In a specific implementation, the processing module 5031 is specifically used to randomly replace the text in the sample data with preset characters, and randomly concatenate a second sentence with the first sentence in the sample data, wherein the second sentence is the next sentence corresponding to the first sentence or is not the next sentence corresponding to the first sentence. For details, please refer to the above-mentioned embodiment of the present invention. Figure 3 The content corresponding to step S301 is disclosed.

[0101] The first training module 5032 is used to use the first training data as the input of the first BERT model, and train the first BERT model in combination with a preset first loss function and the sample data until the first BERT model converges.

[0102] The setting module 5033 is used to use the model parameters of the first BERT model after convergence as the initialization model parameters of the second BERT model.

[0103] The second training module 5034 is used to use the second training data as the input of the second BERT model, and train the second BERT model in combination with a preset second loss function until the second BERT model converges to obtain the element parsing model, wherein the second training data is obtained by selecting a preset number of legal documents from the sample data for element annotation. For the specific process of training the second BERT model, please refer to the above-mentioned embodiment of the present invention. Figure 3 The content corresponding to step S304 is disclosed.

[0104] In an embodiment of the present invention, the first BERT model is trained by the first training data until convergence, the model parameters of the converged first BERT model are used as the initialization model parameters of the second BERT model, and the second BERT model is trained by the second training data until convergence to obtain an element parsing model. The element parsing model is used to perform element parsing on the legal document after sentence processing to obtain the elements contained in each sentence in the legal document, and the case elements extracted are analyzed and legal judgments are performed, without the need to manually extract the elements in the case one by one, thereby effectively reducing labor costs and time costs, and improving judgment accuracy and efficiency.

[0105] refer to Figure 7, showing a structural block diagram of a legal document element parsing system provided by an embodiment of the present invention, wherein the first training module 5032 includes: a prediction submodule 50321, an error submodule 50322 and a training submodule 50323.

[0106] The prediction submodule 50321 is used to use the first training data as the input of the first BERT model to obtain the text prediction results corresponding to the text replacement positions, and to obtain the sentence prediction results corresponding to the sentence concatenation positions.

[0107] The error submodule 50322 is used to calculate the text error between the actual text at the text replacement position and the text prediction result using the first sub-loss function, and to calculate the sentence error between the actual sentence at the sentence splicing position and the sentence prediction result using the second sub-loss function.

[0108] The training submodule 50323 is used to train the first BERT model based on the character error and the sentence error in combination with the first training data until the first BERT model converges. The process of training the first BERT model is described in the above embodiment of the present invention. Figure 4 The content corresponding to step S403 is disclosed.

[0109] The actual text and actual sentences are derived from the sample data.

[0110] In an embodiment of the present invention, before obtaining the factor parsing model, a first BERT model is trained with first training data based on a first sub-loss function and a second sub-loss function until convergence, and the model parameters of the converged first BERT model are used as initialization model parameters of the second BERT model. The second BERT model is then trained based on the training data until convergence to obtain the factor parsing model, which can improve the accuracy of factor parsing.

[0111] Preferably, combined Figure 5 ,refer to Figure 8 , shows a structural block diagram of a legal document element parsing system provided by an embodiment of the present invention, the legal document element parsing system also includes:

[0112] The merging unit 504 is used to merge the elements contained in each of the sentences to be parsed.

[0113] It should be noted that there are two requirements for the analysis results of the elements of the legal document. One is to obtain only the elements contained in each sentence in the legal document, and the other is to merge the elements contained in each sentence in the legal document to obtain the element set of the legal document.

[0114] In an embodiment of the present invention, according to actual needs, the elements contained in each sentence to be parsed can be merged to obtain an element set of the legal document to be parsed to meet different legal needs.

[0115] Based on the legal document element parsing system disclosed in the above embodiment of the present invention, each of the above modules can be implemented by a hardware device composed of a processor and a memory. Specifically, each of the above modules is stored in the memory as a program unit, and the processor executes the program unit stored in the memory to implement the legal document element parsing.

[0116] The processor includes a kernel, which retrieves the corresponding program unit from the memory. One or more kernels can be set, and the analysis of legal document elements can be achieved by adjusting kernel parameters.

[0117] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip.

[0118] Furthermore, an embodiment of the present invention provides a processor, which is used to run a program, wherein the legal document element parsing method is executed when the program is running.

[0119] Furthermore, an embodiment of the present invention provides a device for parsing elements of a legal document, the device comprising a processor, a memory, and a program stored in the memory and executable on the processor, wherein the processor implements the following steps when executing the program: obtaining the legal document to be parsed; performing sentence processing on the legal document to obtain a plurality of sentences to be parsed; inputting the sentences to be parsed one by one into a pre-established element parsing model for element parsing to obtain elements contained in each of the sentences to be parsed in the legal document, wherein the element parsing model is obtained by training a language model based on sample data, and the language model is used to perform pre-training based on a preset number of legal texts to determine the initialization model parameters of the element parsing model.

[0120] Wherein, when the language model is a BERT model, the process of obtaining an element parsing model by training the language model based on sample data includes: performing text replacement and sentence concatenation processing on the sample data to obtain first training data, wherein the sample data is obtained based on sentence segmentation processing of public legal documents; using the first training data as the input of the first BERT model, combining a preset first loss function and the sample data, training the first BERT model until the first BERT model converges; using the model parameters of the converged first BERT model as the initialization model parameters of the second BERT model; using the second training data as the input of the second BERT model, combining a preset second loss function to train the second BERT model until the second BERT model converges, to obtain the element parsing model, wherein the second training data is obtained by selecting a preset number of legal documents from the sample data for element annotation.

[0121] Among them, the taking of the first training data as the input of the first BERT model, combining a preset first loss function and the sample data to train the first BERT model until the first BERT model converges, includes: taking the first training data as the input of the first BERT model, obtaining a text prediction result corresponding to the text replacement position, and obtaining a sentence prediction result corresponding to the sentence splicing position; using a first sub-loss function to calculate a text error between the actual text at the text replacement position and the text prediction result, and using a second sub-loss function to calculate a sentence error between the actual sentence at the sentence splicing position and the sentence prediction result; based on the text error and sentence error, training the first BERT model in combination with the first training data until the first BERT model converges; wherein the actual text and actual sentence are derived from the sample data.

[0122] The step of performing text replacement and sentence concatenation on the sample data to obtain the first training data includes: randomly replacing the text in the sample data with preset characters, and randomly concatenating a second sentence with the first sentence in the sample data, wherein the second sentence is the next sentence corresponding to the first sentence or is not the next sentence corresponding to the first sentence.

[0123] Among them, the step of taking the sentences to be parsed one by one as input of a pre-established element parsing model to perform element parsing, and obtaining the elements contained in each sentence to be parsed in the legal document, further includes: merging the elements contained in each sentence to be parsed.

[0124] Furthermore, an embodiment of the present invention also provides a storage medium on which a program is stored, and when the program is executed by a processor, it implements the analysis of legal document elements.

[0125] The present application also provides a computer program product, which, when executed on a data processing device, is suitable for executing an initialization program having the following method steps: obtaining a legal document to be parsed; performing sentence processing on the legal document to obtain a plurality of sentences to be parsed; inputting the sentences to be parsed one by one into a pre-established element parsing model for element parsing, and obtaining the elements contained in each of the sentences to be parsed in the legal document, wherein the element parsing model is obtained by training a language model based on sample data, and the language model is used to perform pre-training based on a preset number of legal texts to determine the initialization model parameters of the element parsing model.

[0126] Wherein, when the language model is a BERT model, the process of obtaining an element parsing model by training the language model based on sample data includes: performing text replacement and sentence concatenation processing on the sample data to obtain first training data, wherein the sample data is obtained based on sentence segmentation processing of public legal documents; using the first training data as the input of the first BERT model, combining a preset first loss function and the sample data, training the first BERT model until the first BERT model converges; using the model parameters of the converged first BERT model as the initialization model parameters of the second BERT model; using the second training data as the input of the second BERT model, combining a preset second loss function to train the second BERT model until the second BERT model converges, to obtain the element parsing model, wherein the second training data is obtained by selecting a preset number of legal documents from the sample data for element annotation.

[0127] Among them, the taking of the first training data as the input of the first BERT model, combining a preset first loss function and the sample data to train the first BERT model until the first BERT model converges, includes: taking the first training data as the input of the first BERT model, obtaining a text prediction result corresponding to the text replacement position, and obtaining a sentence prediction result corresponding to the sentence splicing position; using a first sub-loss function to calculate a text error between the actual text at the text replacement position and the text prediction result, and using a second sub-loss function to calculate a sentence error between the actual sentence at the sentence splicing position and the sentence prediction result; based on the text error and sentence error, training the first BERT model in combination with the first training data until the first BERT model converges; wherein the actual text and actual sentence are derived from the sample data.

[0128] The step of performing text replacement and sentence concatenation on the sample data to obtain the first training data includes: randomly replacing the text in the sample data with preset characters, and randomly concatenating a second sentence with the first sentence in the sample data, wherein the second sentence is the next sentence corresponding to the first sentence or is not the next sentence corresponding to the first sentence.

[0129] Among them, the step of taking the sentences to be parsed one by one as input of a pre-established element parsing model to perform element parsing, and obtaining the elements contained in each sentence to be parsed in the legal document, further includes: merging the elements contained in each sentence to be parsed.

[0130] In summary, an embodiment of the present invention provides a method and system for parsing elements of a legal document, the method comprising: obtaining a legal document to be parsed. Processing the legal document into sentences to obtain a plurality of sentences to be parsed. Inputting the sentences to be parsed into a pre-established element parsing model one by one to perform element parsing, and obtaining the elements contained in each sentence to be parsed in the legal document, wherein the element parsing model is obtained by training a language model based on sample data. In this scheme, an element parsing model is obtained by pre-training a language model with a massive amount of legal documents, and the legal document to be parsed is processed into sentences to obtain a plurality of sentences to be parsed. Each sentence to be parsed is used as an input to the element parsing model to obtain the elements in each sentence to be parsed, and a legal judgment is made based on the extracted case elements. There is no need to manually extract the elements in the case one by one, and then perform analysis and legal judgment based on the manually extracted elements, thereby saving manpower and time costs and improving the accuracy and efficiency of the judgment.

[0131] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, devices, clients, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0132] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0133] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0134] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0135] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0136] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.

[0137] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.

[0138] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can refer to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system or system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can refer to the partial description of the method embodiment. The system and system embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without creative work.

[0139] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein 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 the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may 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 the present invention.

[0140] The above description of the disclosed embodiments enables one skilled in the art to implement or use the present invention. Various modifications to these embodiments will be apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A method for analyzing elements of a legal document, characterized in that: The method comprises: Obtain legal documents to be parsed; The legal document is processed into sentences to obtain a plurality of sentences to be parsed; Input the sentences to be parsed into a pre-established element parsing model one by one for element parsing, and obtain the elements contained in each sentence to be parsed in the legal document, wherein the element parsing model is obtained by training a language model based on sample data, and the language model is used to perform pre-training based on a preset number of legal texts to determine the initialization model parameters of the element parsing model; Wherein, when the language model is a BERT model, the process of training the language model based on sample data to obtain a factor parsing model includes: Performing word replacement and sentence concatenation processing on the sample data to obtain first training data, wherein the sample data is obtained by performing sentence segmentation processing on public legal documents; Using the first training data as an input of a first BERT model, and training the first BERT model in combination with a preset first loss function and the sample data until the first BERT model converges; Using the converged model parameters of the first BERT model as the initialization model parameters of the second BERT model; The second training data is used as the input of the second BERT model, and the second BERT model is trained in combination with a preset second loss function until the second BERT model converges to obtain the element parsing model, wherein the second training data is obtained by selecting a preset number of legal documents from the sample data for element annotation.

2. The method according to claim 1, characterized in that The step of using the first training data as an input of a first BERT model, and training the first BERT model in combination with a preset first loss function and the sample data until the first BERT model converges includes: Using the first training data as input of the first BERT model, obtaining a character prediction result corresponding to a character replacement position, and obtaining a sentence prediction result corresponding to a sentence concatenation position; Using a first sub-loss function to calculate a text error between an actual text at the text replacement position and a text prediction result, and using a second sub-loss function to calculate a sentence error between an actual sentence at the sentence concatenation position and a sentence prediction result; Based on the word error and the sentence error, training the first BERT model in combination with the first training data until the first BERT model converges; The actual text and actual sentences are derived from the sample data.

3. The method according to claim 1, characterized in that: The step of performing word replacement and sentence concatenation processing on the sample data to obtain first training data includes: The text in the sample data is randomly replaced with preset characters, and a second sentence is randomly concatenated with the first sentence in the sample data, wherein the second sentence is the next sentence corresponding to the first sentence or is not the next sentence corresponding to the first sentence.

4. The method according to claim 1, characterized in that: After inputting the sentences to be parsed one by one into a pre-established element parsing model for element parsing and obtaining the elements contained in each sentence to be parsed in the legal document, the method further includes: The elements contained in each of the sentences to be parsed are merged.

5. A legal document element analysis system, characterized in that: The system comprises: An acquisition unit, used for acquiring the legal document to be parsed; A processing unit, used for performing sentence processing on the legal document to obtain a plurality of sentences to be parsed; A prediction unit, used for inputting the sentences to be parsed one by one into a pre-established element parsing model for element parsing, and obtaining the elements contained in each sentence to be parsed in the legal document, wherein the element parsing model is obtained by training a language model based on sample data, and the language model is used for pre-training according to a preset number of legal texts to determine the initialization model parameters of the element parsing model; Wherein, when the language model is a BERT model, the prediction unit includes: A processing module, configured to perform text replacement and sentence concatenation processing on the sample data to obtain first training data, wherein the sample data is obtained by performing sentence segmentation processing on a public legal document; A first training module, configured to use the first training data as an input of a first BERT model, and train the first BERT model in combination with a preset first loss function and the sample data until the first BERT model converges; A setting module, configured to use the converged model parameters of the first BERT model as initialization model parameters of the second BERT model; The second training module is used to use the second training data as the input of the second BERT model, and train the second BERT model in combination with a preset second loss function until the second BERT model converges to obtain the element parsing model, wherein the second training data is obtained by selecting a preset number of legal documents from the sample data for element annotation.

6. The system according to claim 5, characterized in that The first training module includes: A prediction submodule, configured to use the first training data as an input of the first BERT model to obtain a text prediction result corresponding to a text replacement position, and obtain a sentence prediction result corresponding to a sentence concatenation position; an error submodule, configured to calculate a text error between an actual text at the text replacement position and the text prediction result using a first sub-loss function, and to calculate a sentence error between an actual sentence at the sentence concatenation position and the sentence prediction result using a second sub-loss function; A training submodule, configured to train the first BERT model based on the word error and the sentence error in combination with the first training data until the first BERT model converges; The actual text and actual sentences are derived from the sample data.

7. A storage medium, characterized in that: The storage medium includes a stored program, wherein when the program is running, the device where the storage medium is located is controlled to execute the legal document element parsing method as described in any one of claims 1-4.

8. A legal document element analysis device, characterized in that: It includes a storage medium and a processor, the storage medium stores a program, and the processor is used to run the program, wherein when the program is running, the legal document element parsing method as described in any one of claims 1-4 is executed.