A similarity calculation method for long legal texts based on information extraction and graph model

Through the method based on information extraction and graph model, the problem that traditional methods are difficult to calculate the similarity of legal long texts is solved, and higher calculation accuracy and case judgment efficiency are achieved, providing an effective algorithm foundation for case retrieval.

CN115034229BActive Publication Date: 2025-03-14UNIV OF ELECTRONICS SCI & TECH OF CHINA
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210779228.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-07-01
Publication Date
2025-03-14
Estimated Expiration
2042-07-01

AI Technical Summary

Technical Problem

Traditional methods are difficult to effectively calculate the similarity between long legal texts, and cannot grasp the key points of the case, which affects the speed and accuracy of similar case searches and judgments.

Method used

Using the method based on information extraction and graph model, entities and behaviors are extracted through LTP semantic dependency analysis, RoBERTa-wwm-ext-large is used for text classification, and graph models of entities and behaviors are constructed, and similarity is calculated in combination with Sentence-BERT and graph models.

Benefits of technology

The accuracy of long text similarity calculations can be improved, the similarity between legal cases can be better solved, the algorithmic basis for similar case searches, and the speed and accuracy of judges' judgments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115034229B_ABST
    Figure CN115034229B_ABST
Patent Text Reader

Abstract

The present invention proposes a method for calculating the similarity of long legal texts based on information extraction and graph models, the method comprising the following steps: extracting entities and behaviors from legal texts; filtering out fault behaviors from behaviors using text classification; constructing a graph model with entities and fault behaviors extracted from two long texts; and calculating the similarity of the two long texts based on the structure and semantic information in the graph model. The purpose of similar cases and similar judgments is to find similar or even identical cases to the cases currently being handled by judges, so as to improve the speed and accuracy of case judgments. The present invention aims to better solve the similarity between legal cases, solve the problem that traditional methods cannot grasp the key points of the case, and provide an algorithmic basis for realizing similar case retrieval.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to a method for calculating similarity of long legal texts based on information extraction and a graph model, and belongs to the field of natural language processing. Background Art

[0002] Semantic Dependency Parsing (SDP) is to analyze the semantic associations between the various language units of a sentence and present the semantic associations in a dependency structure. The advantage of using semantic dependencies to describe the semantics of a sentence is that there is no need to abstract the vocabulary itself, but to describe the vocabulary through the semantic framework that the vocabulary bears, and the number of arguments is always much smaller than that of vocabulary. The goal of semantic dependency analysis is to transcend the constraints of the surface syntactic structure of the sentence and directly obtain deep semantic information. At the same time, semantic dependency analysis is not affected by the syntactic structure, and directly connects language units with direct semantic associations to dependency arcs and marks them with corresponding semantic relationships.

[0003] BERT (Bidirectional Encoder Representations from Transformers) has been proven to be a very powerful method that can significantly improve the performance of various natural language processing tasks, especially in natural language understanding tasks. Text classification is essentially a natural language understanding task. The present invention uses a variant of BERT, RoBERTa-wwm-ext-large, for text classification.

[0004] Sentence-BERT (SBERT) uses twin networks and triplet network structures to generate sentence embedding vectors with semantic meaning. The embedding vectors of sentences with similar semantics are relatively close, so they can be used for similarity calculations (cosine similarity, Manhattan distance, Euclidean distance). This network structure significantly reduces the time it takes to find the most similar sentence pairs from the above 65 hours to 5 seconds (calculating cosine similarity is about 0.01s), and the accuracy can still remain unchanged. When comparing the similarity of sentences A and B, they are respectively input into the SBERT network, and the output is two sets of vectors representing the sentences, and then the similarity between the two is calculated. Summary of the invention

[0005] The present invention proposes a method for calculating the similarity of long legal texts based on information extraction and graph models. The purpose of the present invention is to better solve the similarity between legal cases, solve the problem that the traditional method cannot grasp the key points of the case, and provide an algorithmic basis for realizing similar case retrieval. The purpose of similar cases and similar judgments is to find similar or even identical cases to the cases currently being handled by judges, so as to improve the speed and accuracy of case judgments.

[0006] The overall block diagram of the algorithm of the present invention is shown in Figure 1 , the technical solution is as follows:

[0007] First, entities and behaviors are extracted. For entity extraction, the subject role and object role in the LTP semantic dependency analysis, as well as the tools and materials in the situational roles are used to implement it, including agents, parties, patients, guests, involved events, related events, tools, and materials. For behavior extraction, the present invention innovatively proposes to implement it with the structure of "subject role + action + object role", and the subject role relationship and object role relationship obtained by the LTP semantic dependency analysis are formed into several subtrees with actions as the core, and behaviors are extracted according to the structure of "subject role + action + object role".

[0008] Then, for the extracted behaviors, it is necessary to filter out the fault behaviors from the behaviors through text classification. The present invention fine-tunes the pre-trained model RoBERTa-wwm-ext-large to complete the binary classification task of the text and filter out the fault behaviors from the behaviors.

[0009] After extracting entities and behaviors in the first two steps and filtering behaviors to obtain faulty behaviors, it is necessary to construct a graph model. First, it is necessary to construct a graph model between the entities of long text A and the entities of long text B. The entities between the two long texts are connected according to the degree of semantic similarity. Then, a graph model is constructed between the behaviors of long text A and the behaviors of long text B. The behaviors between the same texts are connected according to the temporal relationship, and the behaviors between the two long texts are connected according to the degree of semantic similarity.

[0010] Finally, after completing the construction of the graph model, it is necessary to calculate the graph similarity. The similarity calculation method includes two levels of calculation, one is the similarity between entities and entities, or between behaviors and behaviors, and the other is to calculate the similarity between two long texts based on the graph model constructed in the previous step. For the first level of calculation, the present invention uses Sentence-BERT (SBERT) for calculation. For the second level of calculation, since the behavior is temporal, the present invention innovatively proposes a similarity calculation method based on a graph model, which fully combines both structural and semantic information, and performs calculations on the behavior graph model established in step three. Entities are not temporal, and are only calculated on the entity graph model established in step three in combination with semantic information.

[0011] The beneficial effects of the present invention are: improving the accuracy of long text similarity calculation to better solve the similarity between legal cases, providing an algorithmic basis for realizing similar case retrieval, and finding similar or even identical cases for judges to refer to the cases they are handling, thereby improving the speed and accuracy of case judgment. BRIEF DESCRIPTION OF THE DRAWINGS

[0012] Figure 1 It is the overall block diagram of the algorithm of the present invention;

[0013] Figure 2 Label for LTP semantic dependency analysis;

[0014] Figure 3 This is an example diagram of the LTP semantic dependency analysis tree;

[0015] Figure 4 This is the structure diagram of the Bert input layer;

[0016] Figure 5 This is the Bert middle layer structure diagram;

[0017] Figure 6 This is the Bert output layer structure diagram;

[0018] Figure 7 This is an example of inputting the full word Mask for wwm;

[0019] Figure 8 It is a structural diagram of the entity graph model;

[0020] Fig. 9 It is the structural diagram of the graph model;

[0021] Fig.10 This is a similarity calculation flow chart based on Sentence-BERT (SBERT); DETAILED DESCRIPTION

[0022] The idea of ​​the algorithm will be described below, and the specific steps of the algorithm will be given.

[0023] Step 1: Entity and behavior extraction

[0024] Entities and behaviors represent static information and dynamic information respectively, and are key information in the text. Entity extraction and behavior extraction are completed based on the semantic dependency analysis tree of LTP. Semantic dependency parsing (SDP) analyzes the semantic associations between the various language units of a sentence and presents the semantic associations in a dependency structure. The goal of semantic dependency analysis is to transcend the constraints of the surface syntactic structure of the sentence and directly obtain deep semantic information. Chinese is semantically coherent and has disadvantages in formal analysis. Therefore, compared with syntactic analysis, semantic dependency analysis can better represent the structure and semantic information of a sentence.

[0025] The model of LTP's semantic dependency analysis is Electra Small+BiAffine, which has an accuracy of 76.62% on the CCL2020 dataset, and has a very leading effect among similar algorithms. In the labels of LTP semantic dependency analysis, the subject roles include agent AGT, party EXP, the object roles include patient PAT, guest CONT, involved DATV, and related LINK, and the situation roles include tool TOOL, material MATL, method MANN, scope SCO, etc. The labels of LTP semantic dependency analysis are as follows: Figure 2 shown.

[0026] For entity extraction, the present invention innovatively uses the subject role, object role in the LTP semantic dependency analysis tree, and tools and materials in the situational role to achieve it, including agent AGT, party EXP, patient PAT, guest CONT, involved DATV, link LINK, tool TOOL, and material MATL. The agent refers to the subject that issues a specific action or the conscious subject that continues the action and expresses psychological activities, and has subjective initiative; the party refers to the issuer of non-behavioral actions, and does not have subjective initiative, including the subject of unconscious movement, the subject of uncontrollable movement, and the subject of various relationships; the patient refers to the direct object changed by the subject's behavior, generally corresponding to the agent, and is the object whose position, nature, result, etc. are changed by the agent, and the most obvious semantic feature is passivity; the object refers to the object involved in the event but not changed, as well as the new thing or result produced by the action; the involved thing is also called the with thing, which is a non-active participant in the action. It can also be said that the involved role is a third-party participant in the semantic event. Semantically speaking, it is the recipient, accompaniment, source, and basis of comparison of the event, etc. Syntactically speaking, it often appears in the indirect object position in double-object sentences; the related event is an object related to the participant of the event. The subject and object are generally connected by verbs that indicate a certain connection, expressing a certain concrete or abstract relationship between the subject and object; tools are tools used in the event. The typical tool role is mainly introduced by the preposition "use", and is usually played by objects, but some living or abstract things can also be used as tools for the event; materials are materials used in the event.

[0027] For behavior extraction, the present invention innovatively proposes to implement it with the structure of "subject role + action + object role". The subject role relationship and object role relationship obtained by the LTP semantic dependency analysis tree are used to form several subtrees with actions as the core, and behaviors are extracted according to the structure of "subject role + action + object role". An example of LTP semantic dependency analysis tree is as follows: Figure 3As shown in Figure 1. The agent AGT and the party EXP describe the subject role and its action; the patient PAT, the guest CONT, the involved DATV, and the link LINK describe the action and its object role. Obviously, the action is the bridge between the subject role and the object role. Figure 3 In the example, "command" points to "person in charge", and the relationship is agent AGT, "command" points to "rescue", and the relationship is object CONT. According to the structure of "subject role + action + object role", the behavior "person in charge commands rescue" is extracted. Similarly, the LTP semantic dependency analysis tree can be used to obtain several subtrees with actions as the core, thereby extracting behaviors.

[0028] Step 2: Text Binary Classification

[0029] For the extracted behaviors, not all of them are key information, and some behaviors do not need to participate in the similarity calculation, otherwise the accuracy of the similarity calculation will be reduced. For example, in legal cases, the importance of the parties' fault behavior is far greater than the importance of non-fault behavior, and it is necessary to filter out the fault behavior from the behavior through text classification methods. Different advances may filter out different behaviors, and we call the behaviors that need to participate in the similarity calculation as fault behaviors. The present invention uses RoBERTa-wwm-ext-large, a variant of BERT, for text classification.

[0030] 1. BERT

[0031] BERT (Bidirectional Encoder Representations from Transformers) has been proven to be a very powerful method that can significantly improve the performance of various natural language processing tasks, especially in natural language understanding tasks, and text classification is essentially a natural language understanding task.

[0032] (1) Bert input layer

[0033] The input of Bert can be a single sentence or a sentence pair. The actual input value is the sum of segment embedding and position embedding. In order to adapt the Bert model to downstream tasks (such as classification tasks and sentence relationship QA tasks), the input will be transformed into [CLS] + sentence A (+ [SEP] + sentence B + [SEP]), where:

[0034] [CLS]: The first character of the input is [CLS], where [CLS] means classification. It represents a special token for the classification task, and its output is the pooler output of the model.

[0035] [SEP]: separator

[0036] ● Sentence A and Sentence B are the input text of the model, where Sentence B can be empty, then the input becomes [CLS] + Sentence A

[0037] Bert uses the same encoding method as Transformer. It takes a fixed-length string as input, and the data is passed from bottom to top for calculation. Each layer uses self-attention and passes the result through a feedforward neural network to the next encoder. At the same time, because the transformer cannot obtain the position information of the word, Bert also adds absolute position encoding like the transformer. However, unlike the transformer, Bert does not use the functional encoding method corresponding to the transformer, but directly uses a method similar to word embedding to directly obtain the position embedding. The Bert input layer is as follows: Figure 4 .

[0038] (2) Bert middle layer

[0039] The middle layer of the model is the same as the encoder of the transformer, which is composed of self-attention layer + ADD&BatchNorm layer + FFN layer. The middle layer of Bert can be expressed as Figure 5 .

[0040] (3) Bert output layer

[0041] Each input of the model corresponds to this output. We can choose different outputs according to different tasks. There are mainly two types of outputs:

[0042] ●pooler output: corresponds to the output of [CLS].

[0043] ·Sequence output: corresponds to the final output of all other input words.

[0044] The output returned at each position is a vector of the size of the hidden layer (768 for the Bert-base version). The output layer of Bert can be represented as follows Figure 6.

[0045] 2.wwm

[0046] Whole Word Masking (wwm) is an upgraded version of BERT released by Google on May 31, 2019. It mainly changes the training sample generation strategy in the original pre-training stage. Because Chinese is segmented at the granularity of characters in the BERT-Base, Chinese model released by Google, the Masked Language Model (MLM) task based on masks in the BERT pre-training process also performs mask operations at the granularity of characters. BERT-wwm performs a series of Chinese-style transformations to address this problem, taking full account of the Chinese word segmentation operation in traditional NLP, and performing mask operations at the granularity of characters, that is, Whole Word Masking (wwm) operations.

[0047] In simple terms, the original WordPiece-based word segmentation method will split a complete word into several subwords. When generating training samples, these separated subwords will be randomly masked. In the whole word mask, if some WordPiece subwords of a complete word are masked, then other parts of the word will also be masked, that is, the whole word mask, such as Figure 7 It should be noted that the mask here refers to the general mask (replace with [MASK]; keep the original vocabulary; randomly replace with another word), not limited to the case where the word is replaced with the [MASK] label.

[0048] 3.RoBERTa

[0049] RoBERTa (Robustly optimized BERT approach) was jointly completed by Facebook AI and the research team of the University of Washington. Because the authors of RoBERTa believe that the native BERT training is insufficient, a complex study was conducted, including a careful evaluation of the impact of hyperparameters and training set size on the BERT pre-trained model. Compared with the native BERT, the RoBERTa pre-trained model has been optimized in six aspects, including dynamic mask, cancellation of NSP tasks, setting larger batch size training, using more data and training longer, adjusting optimizer Adam parameters, and using Byte level to build vocabulary.

[0050] (1) Dynamic Mask Operation

[0051] The native BERT model uses a static Mask operation, while the RoBERTa model uses a dynamic Mask operation. The static Mask operation is actually to perform a Mask operation on the sentence during data processing, and then directly provide these Masked sentences to the model for training. The Mask data has been processed before the model is trained, so no matter how many rounds of training, the Mask operation of this sentence in the subsequent training is fixed. The dynamic Mask operation is to dynamically mask the sentence during model training. The model will continuously change the Mask position during training, so that the Mask position of each round of training samples may be different. The dynamic Mask operation can make the Mask position of a sample different in each round of training, which improves the randomness of the model input data and ultimately improves the learning ability of the model.

[0052] (2) Cancel the NSP task

[0053] BERT's training task includes NSP training, which is to splice two paragraphs and provide them to the model for training. The positive sample is two consecutive paragraphs in the same article, and the negative sample is one paragraph from each of the two articles. The RoBERTa model conducted the following experiments to prove the effect of the NSP task on the BERT model: First, canceling the NSP task can bring a good improvement to the BERT model. The experiment proves that the NSP task has almost no effect on the training effect; then, when the NSP task is used, the sample contains more characters, which has a better effect; finally, when the NSP task is canceled, it is better to obtain data from one article than from multiple articles.

[0054] (3) Set a larger batch size for training

[0055] Using a larger batch size during model training is beneficial to improving the model's performance. The batch size used in the native BERT model training is 256, and 1M steps are trained, while the RoBERTa model uses a larger batch size. From the results, we can see that as the batch size increases, ppl (Perplexity on held-outtraining data) continues to decrease, while the accuracy of downstream tasks continues to improve.

[0056] (4) Use more datasets and train longer

[0057] Using more training data can effectively improve the performance of downstream tasks. The native BERT only used 16G of training text, but the RoBERTa model used 160G of training text, including the original BERT training set BOOKCORPUS and English Wikipedia (16G), 63 million English news dataset CC-NEWS (76G), web content on Reddit (38G), and STORIES (31G), a subset of the CommonCrawl dataset. There is no doubt about the role of data in pre-training models. Both the GPT series models that are more popular now and XLNet have well demonstrated the importance of data. Not only can using more data sets improve the model, but longer training time can also effectively improve the performance of the model.

[0058] (5) Adjust the optimizer Adam parameters

[0059] The RoBERTa model adjusts two parameters in the optimizer Adam:

[0060] m t =β 1 m t-1 +(1-β 1 ) t

[0061] v t =β 2 v t-1 +(1-β 2 ) t 2

[0062]

[0063] The first adjustment is to the second-order moment estimate β in Adam 2 . β 2 The parameter is generally used to solve the problem of gradient sparseness. It is usually recommended to set it close to 1 in NLP or CV tasks, so it is generally set to 0.999. 2 The parameter is set to 0.98; the second adjustment is the ∈ parameter in Adam. The original purpose of the ∈ parameter is to prevent division by 0. Adjusting this parameter here can improve the stability of model training. (6) Use Bytelevel to build a vocabulary

[0064] The main purpose of using a larger Byte level BPE vocabulary in this invention is to reduce the problem of unknown words in NLP tasks. The native BERT model uses the wordpiece method based on BPE (Byte Pair Encoding) when segmenting English words. The core of this method is to break up words into characters and then perform word piece segmentation on the words according to the combination frequency of the fragments. Compared with the original word segmentation, wordpiece can effectively reduce the OOV (out of vocab) situation.

[0065] In summary, compared with BERT, RoBERTa-wwm-ext-large has the following improvements: the training corpus, model parameters and batch size are greatly increased, and a more complex 24-layer Transformer model (BERT uses 12 layers) is used; the next sentence prediction (NSP) task is removed; dynamic masking is used, and a new masking pattern is generated each time a sequence is input to the model; the whole word masking (wwm) technology is used, that is, if some subwords of a word are masked, the entire word will be masked; and the maximum length of 512 is used for training. Based on the above improvements, RoBERTa-wwm-ext-large has achieved SOTA in multiple tasks.

[0066] Based on the pre-trained model RoBERTa-wwm-ext-large, fine-tuning is performed to complete the binary classification task of text and filter out faulty behaviors from behaviors.

[0067] Step 3: Build a graph model

[0068] In the first two steps, entities and behaviors are extracted, and the behaviors are screened to obtain fault behaviors. For the convenience of description, all fault behaviors are referred to as behaviors in the following. In order to solve the similarity between two long texts (assuming A and B), the present invention innovatively proposes a method for constructing a graph model. First, a graph model between the entity of A and the entity of B needs to be constructed, and the entity similarity Sim between A and B is calculated. entity Then, we construct a graph model between A’s behavior and B’s behavior, and find the similarity between A and B’s behavior Sim action .

[0069] For the entity graph model, if the number of entities in A is no more than the number of entities in B, the semantic similarity between each entity in A and each entity in B is calculated, and the entity with the highest semantic similarity in B is selected for connection (if its similarity is greater than or equal to the threshold 0.7). If the semantic similarity between an entity in A and any entity in B is lower than the threshold 0.7, it is regarded as an isolated point in the graph. Finally, the information on the edge is the semantic similarity between the two entities. If the number of entities in B is greater, the opposite is true. The structure of the entity graph model is shown in Figure 8 .

[0070] For the behavior graph model, it is necessary to arrange the behaviors in order when extracting them, because the order between behaviors is also key information. If the behaviors of A and B are the same, but the order is different, the behavior similarity is not 100%. A's behaviors form a directed time sequence graph in order, and the same applies to B's behaviors. If the number of A's behaviors is not more than the number of B's ​​behaviors, then the semantic similarity of each behavior of A and each behavior of B is calculated, and the behavior with the highest semantic similarity in B is selected for connection (if its similarity is greater than or equal to the threshold of 0.7). If B has more entities, then vice versa. The final edge information contains two types. The edges in the same chapter represent the order of time, and the edges in different chapters represent semantic similarity. See the structure of the behavior graph model. Fig. 9 .

[0071] Step 4: Calculate similarity based on the graph model

[0072] The similarity calculation method includes two levels of calculation: one is the similarity between entities or between behaviors; the other is to calculate the similarity between two long texts based on the graph model constructed in the previous step.

[0073] For the calculation of the first level, the present invention uses Sentence-BERT (SBERT) for calculation. BERT and RoBERTa have achieved SOTA results in the regression tasks of sentence pairs such as text semantic similarity, but both require two sentences to be input into the network at the same time, resulting in huge computational overhead. Sentence-BERT (SBERT) uses twin networks and triplet network structures to generate sentence embedding vectors with semantic meaning. The embedding vector distance of sentences with similar semantics is relatively close, so it can be used for similarity calculation (cosine similarity, Manhattan distance, Euclidean distance). The network structure significantly reduces the time it takes to find the most similar sentence pairs from the above 65 hours to 5 seconds (calculating cosine similarity is about 0.01s), and the accuracy can still remain unchanged.

[0074] SBERT adds a Pooling operation to the output results of BERT / RoBERTa to generate a sentence embedding of fixed dimension. Three Pooling strategies were adopted for comparison in the experiment: directly using the output vector of the CLS position as the entire sentence vector; calculating the average value of all Token output vectors as the entire sentence vector; taking the maximum value of each dimension of all Token output vectors as the entire sentence vector. After experimental verification, the second method has the best effect. In order to fine-tune BERT / RoBERTa, SBERT uses twin networks and triplet networks to update parameters so that the generated sentence vectors are more semantically informative. The cosine similarity calculation structure of two sentence embedding vectors u and v is as follows Fig.10 As shown in Figure 2, the loss function is the mean squared error (MSE).

[0075] For the second level of calculation, the present invention innovatively proposes a similarity calculation method based on a graph model, which fully combines both structural and semantic information.

[0076] Entities do not have a temporal relationship. entity When the entity graph model is connected to N entity For entities, the semantic similarity between two entities is S 1 , the number of entities in text A is N a1 , the number of entities in text B is N b1 , then the solution formula is:

[0077]

[0078] Behavior has temporal characteristics. action When action For actions, the semantic similarity between two actions is S 2 , the number of actions in text A is N a2 、N number of actions in text B a2 If the line x in A is connected to the line y in B, and the positions of the two in the behavior sequence are id 1 and id 2 (Ignoring the location of unconnected behaviors), the calculation method for the offset distance between the two is:

[0079] dist=min{|id 2 -id 1 |,|id 2 +N action -id 1 |}

[0080] Then the behavioral similarity between text A and B is:

[0081]

[0082] Finally, the similarity calculation formula between two long texts is:

[0083] Sim=β·Sim entity +(1-β)·Sim action

[0084] It is worth noting that the present invention innovatively proposes to extract the entities and behaviors from all cases first, and embed their Sentence-BERT (SBERT) and store them in a json file, so that when calculating the similarity, you only need to find the corresponding vector from the json file, and then calculate the cosine distance. The reason for this is that there are many behaviors and entities extracted. The entities of the two cases must be calculated one by one for similarity, and the behaviors must also be calculated one by one. Each case must be calculated with all the cases in the case library, so the total amount of calculation is very large. If the extracted entities and behaviors are stored directly in the form of text, they need to be encoded repeatedly during calculation. This process consumes a huge amount of time and is difficult to apply in actual scenarios. After experimental verification, the speed of calculating similarity by embedding and storing SBERT can be increased by 10 to 20 times.

[0085] Matters not covered by the present invention are known technologies.

[0086] The above embodiments are only for illustrating the technical concept and features of the present invention, and their purpose is to enable people familiar with the technology to understand the content of the present invention and implement it accordingly, and they cannot be used to limit the protection scope of the present invention. Any equivalent changes or modifications made according to the spirit of the present invention should be included in the protection scope of the present invention.

Claims

1. A method for calculating similarity of long legal texts based on information extraction and graph model, characterized in that: The method comprises the following steps: Step 1: Entity and behavior extraction, using LTP semantic dependency analysis tree for entity extraction and behavior extraction, where the model of LTP semantic dependency analysis tree is Electra Small+BiAffine, which analyzes the semantic association of each language unit of the sentence and presents it in a dependency structure. Specifically, it uses the tools and materials in the subject, object, and situation roles when extracting entities, including agents, parties, patients, guests, involved, related, tools, and materials; behavior extraction is to construct a subtree with the "subject role + action + object role" structure, and the subject role relationship and object role relationship obtained by the LTP semantic dependency analysis tree are used to form several subtrees with actions as the core, and behaviors are extracted according to the "subject role + action + object role" structure; Step 2: Text binary classification. For the extracted behaviors, fine-tune the pre-trained model RoBERTa-wwm-ext-large to complete the text binary classification task and filter out the fault behaviors from the behaviors. The training corpus, model parameters and batch size of the RoBERTa-wwm-ext-large pre-trained model are greatly increased compared to BERT. A 24-layer Transformer model is used, the next sentence prediction task is removed, and dynamic masking is used to generate a new masking pattern for each input sequence. The full-word masking technology is used, that is, if part of the subwords of a word are masked, the entire word will be masked. The maximum length of 512 is used for training. Step 3: Construct a graph model. First, construct a graph model between the entities of A and B. The construction method is to calculate the semantic similarity between each entity of A and each entity of B, select the entity with the highest semantic similarity in B to connect, otherwise it is an isolated point, and the side information is the semantic similarity between entities; then construct a graph model between the behavior of A and the behavior of B. The behaviors of A and B form a directed time sequence graph in sequence, calculate the semantic similarity between each behavior of A and each behavior of B, select the behavior with the highest semantic similarity in B to connect, and the side information includes the time sequence of the same chapter and the semantic similarity of different chapters; Step 4: Calculate similarity based on the graph model. The similarity calculation method includes two levels of calculation. One is to solve the similarity between entities and between behaviors, and the other is to calculate the similarity between two long texts based on the graph model constructed in the previous step. For the first level of calculation, Sentence-BERT, or SBERT, is used for calculation. Specifically, Pooling operation is added to the output result of SBERT, and the average value of all Token output vectors is calculated as the sentence vector. The sentence embedding vector with semantic meaning is generated by using the twin network and triplet network structure, and the cosine similarity is calculated. For the second level of calculation, a similarity calculation method based on the graph model is used, which fully combines the structural and semantic information. Entities do not have a temporal relationship. When solving the entity similarity Sim entity When the entity graph model is connected to N entity For entities, the semantic similarity between two entities is S1, and the number of entities in text A is N a1 , the number of entities in text B is N b1 , then the solution formula is: Behavior has temporal characteristics. action When the behavior graph model is connected to N action For actions, the semantic similarity of two actions is S2, and the number of actions in text A is N a2 、N is the number of actions in text B a2 ; If the behavior x in A is connected to the behavior y in B, and if their positions in the behavior sequence are id1 and id2 respectively, where id1 and id2 do not take into account the positions of unconnected behaviors, then the calculation method for the offset distance between the two is: dist=min{|id2-id1|,|id2+N action -id1|} Then the behavioral similarity between text A and B is: Finally, the similarity calculation formula between two long texts is: Yes=β·Yes entity +(1-β) Yes action 。 2. The method according to claim 1, characterized in that: Before calculating the similarity, we first extract the entities and behaviors from all cases, and store their Sentence-BERT (SBERT) embeddings in a json file. When calculating the similarity, we find the corresponding vectors from the json file and then calculate the cosine distance.