Similar text determination method and class case retrieval model training method and device
Through a multi-level neural network model, feature extraction and deep matching of questioning texts and preset texts in the legal consultation system is solved, and the accuracy of similarity matching of similar legal cases in the prior art is achieved, achieving more efficient legal consultation and case search.
Patent Information
- Application Number
- CN202510013687.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-03
- Publication Date
- 2025-04-18
AI Technical Summary
It is difficult to effectively match similarity between similar legal cases in legal consulting systems, especially when dealing with complex legal cases, traditional similarity matching algorithms cannot accurately identify core semantic features and label information between cases.
A multi-level neural network model is used to extract the question text and preset text input by the user, including overall semantic features, core sentence meaning features and label information. The accuracy of similarity matching is improved through deep matching algorithms, and the similarity calculation is further optimized by identifying and excluding idiomatic statements.
It improves the accuracy of similarity matching of similar legal cases in the legal consultation system, can provide users with legal advice more effectively, and enhances the accuracy and efficiency of similar case searches.
Smart Images

Figure CN119848233A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method for determining similar texts, and a method and device for training a similar case retrieval model. Background Art
[0002] In the legal consultation scenario, users can consult information related to legal cases through the legal consultation system. When the legal consultation system generates a corresponding reply based on the consultation information input by the user, it can search for similar legal cases and corresponding judgment results in existing legal cases based on the consultation information, and generate reply information to the user's consultation information based on the search results, that is, it can provide legal consultation opinions to users based on similar legal cases. Summary of the invention
[0003] The embodiment of the present application provides a method for determining similar texts, a method and device for training a similar case retrieval model, which can determine a target preset text similar to a first question text input by a user and improve the accuracy of text similarity matching. Specifically, the embodiment of the present application discloses the following technical solutions:
[0004] A first aspect of an embodiment of the present application provides a method for determining similar texts, the method comprising: obtaining multiple preset texts and a first question text input by a user; determining feature information corresponding to each of the multiple preset texts, and determining feature information corresponding to the first question text; wherein the feature information comprises overall semantic features, core sentence features and label information; based on the feature information corresponding to each of the preset texts and the first question text, determining the similarity between the first question text and each of the preset texts; based on the similarity between the first question text and each of the preset texts, determining and outputting a target preset text from the multiple preset texts.
[0005] In some embodiments, the above-mentioned determination of the feature information corresponding to each of the above-mentioned multiple preset texts includes: determining the overall semantic features and word semantic features corresponding to each of the above-mentioned preset texts; based on the overall semantic features corresponding to each of the above-mentioned preset texts, determining the core sentence meaning features corresponding to each of the above-mentioned preset texts; based on the word semantic features corresponding to each of the above-mentioned preset texts, determining the label information corresponding to each of the above-mentioned preset texts.
[0006] In some embodiments, the above-mentioned determination of the overall semantic features and word semantic features corresponding to each of the above-mentioned preset texts includes: performing feature extraction on each of the above-mentioned preset texts through a first neural network model, and obtaining a first feature extraction result corresponding to each of the above-mentioned preset texts obtained by a first coding layer in the above-mentioned first neural network model, and a second feature extraction result corresponding to each of the above-mentioned preset texts obtained by a second coding layer in the above-mentioned first neural network model; wherein the above-mentioned first neural network model includes a plurality of coding layers, the plurality of coding layers include the above-mentioned first coding layer and the above-mentioned second coding layer, the above-mentioned first coding layer and the above-mentioned second coding layer are different coding layers, and the number of layers of the above-mentioned first coding layer is less than the number of layers of the above-mentioned second coding layer; the first feature extraction result corresponding to each of the above-mentioned preset texts is determined as the word semantic feature corresponding to each of the above-mentioned preset texts, and the second feature extraction result corresponding to each of the above-mentioned preset texts is determined as the overall semantic feature corresponding to each of the above-mentioned preset texts.
[0007] In some embodiments, the above-mentioned determining the core sentence meaning features corresponding to each of the above-mentioned preset texts based on the overall semantic features corresponding to each of the above-mentioned preset texts includes: dividing the overall semantic features corresponding to each of the above-mentioned preset texts according to sentences through the second neural network model to obtain multiple sentences corresponding to each of the above-mentioned preset texts; determining the non-core words in the multiple sentences corresponding to each of the above-mentioned preset texts through the second neural network model, and adjusting the weights of the non-core words corresponding to each of the above-mentioned preset texts to obtain the core sentence meaning features corresponding to each of the multiple sentences corresponding to each of the above-mentioned preset texts.
[0008] In some embodiments, the above-mentioned determining the label information corresponding to each of the above-mentioned preset texts based on the semantic features of the words corresponding to each of the above-mentioned preset texts includes: determining, through a third neural network model based on the semantic features of the words corresponding to each of the above-mentioned preset texts, the label information corresponding to each of the above-mentioned sentences in the multiple sentences corresponding to each of the above-mentioned preset texts from multiple preset label information; wherein the label information corresponding to each of the above-mentioned sentences is used to represent the key information corresponding to each of the above-mentioned sentences.
[0009] In some embodiments, the method further includes: identifying idiomatic sentences in each of the above-mentioned preset texts through a fourth neural network model, and determining a processed preset text based on the idiomatic sentences in each of the above-mentioned preset texts; determining the similarity between the above-mentioned first question text and each of the above-mentioned preset texts based on the feature information corresponding to each of the above-mentioned preset texts and the above-mentioned first question text, including: determining the similarity between the above-mentioned first question text and the above-mentioned processed preset text based on the overall semantic features, core sentence meaning features and label information corresponding to the above-mentioned processed preset text and the above-mentioned first question text.
[0010] In some embodiments, the above-mentioned method of determining and outputting a target preset text from the above-mentioned multiple preset texts based on the similarity between the above-mentioned first question text and each of the above-mentioned preset texts includes: sorting the above-mentioned multiple preset texts in descending order and obtaining a sorting result according to the similarity between the above-mentioned first question text and each of the above-mentioned preset texts; determining the first N preset texts in the above-mentioned sorting result as the above-mentioned target preset text, and outputting the above-mentioned target preset text; wherein N is a positive integer.
[0011] In some embodiments, the method further includes: in the absence of necessary information for calculating similarity in the first question text, determining the text features corresponding to the first question text and the core information corresponding to the first question text through a fifth neural network model, and determining the first event information corresponding to the first question text based on the text features and the core information corresponding to the first question text; determining event determination information based on the first event information through a sixth neural network model, and determining and outputting the second question text based on the event determination information and the first question text; obtaining a reply text input by the user to the second question text, and determining a target question text based on the first question text and the reply text; the determination of the feature information corresponding to the first question text includes: determining the feature information corresponding to the target question text.
[0012] A second aspect of an embodiment of the present application provides a training method for a similar case retrieval model, wherein the similar case retrieval model includes a first neural network model, a second neural network model and a third neural network model, and the method includes: obtaining multiple training texts, and determining target similarities corresponding to the multiple training texts and target label sequences corresponding to the multiple training texts; determining a first loss function corresponding to the first neural network model to be trained based on the multiple training texts and the target similarities corresponding to the multiple training texts, and determining a second loss function corresponding to the second neural network model to be trained; determining a third loss function corresponding to the third neural network model to be trained based on the multiple training texts and the target label sequences corresponding to the multiple training texts; determining a target loss function based on the first loss function, the second loss function and the third loss function; optimizing parameters in the first loss function, the second loss function, the third loss function and the target loss function to determine the trained first neural network model, the trained second neural network model and the trained third neural network model.
[0013] In some embodiments, the first loss function corresponding to the first neural network model to be trained is determined based on the multiple training texts and the target similarities corresponding to the multiple training texts, including: determining the overall semantic features and word semantic features corresponding to each of the multiple training texts through the first neural network model to be trained; determining the first similarities corresponding to the multiple training texts based on the overall semantic features corresponding to each of the training texts through the first neural network model to be trained; determining the first loss function based on the first similarities corresponding to the multiple training texts and the target similarities through the first neural network model to be trained.
[0014] In some embodiments, based on the above-mentioned multiple training texts and the target similarities corresponding to the above-mentioned multiple training texts, determining the second loss function corresponding to the second neural network model to be trained includes: determining the core sentence meaning features corresponding to each of the above-mentioned training texts based on the overall semantic features corresponding to each of the above-mentioned training texts by the above-mentioned second neural network model to be trained; determining the second similarity corresponding to each sentence in each of the above-mentioned training texts based on the core sentence meaning features corresponding to each of the above-mentioned training texts by the above-mentioned second neural network model to be trained; determining the second loss function based on the second similarity corresponding to each of the above-mentioned sentences and the target similarities corresponding to the above-mentioned multiple training texts by the above-mentioned second neural network model to be trained.
[0015] In some embodiments, the third loss function corresponding to the third neural network model to be trained is determined based on the multiple training texts and the target label sequences corresponding to the multiple training texts, including: determining the predicted label sequence corresponding to each of the training texts based on the word semantic features corresponding to each of the training texts through the third neural network model to be trained; determining the third loss function based on the predicted label sequence and the target label sequence corresponding to the multiple training texts through the third neural network model to be trained.
[0016] In some embodiments, the target loss function is determined based on the first loss function, the second loss function and the third loss function, including: determining a plurality of weight items according to the product of the first loss function, the second loss function and the third loss function and each of the first preset weights in a plurality of first preset weights; determining a plurality of interaction items between the first loss function, the second loss function and the third loss function based on a plurality of second preset weights; performing exponential calculations on the first loss function, the second loss function and the third loss function, respectively, to obtain a plurality of exponential items; wherein the plurality of exponential items include the exponential items corresponding to the first loss function, the second loss function and the third loss function, respectively; determining the target loss function based on the plurality of weight items, the plurality of interaction items and the plurality of exponential items.
[0017] In some embodiments, the method further includes: obtaining a plurality of words corresponding to each of the preset windows in the training text according to each of the preset windows in the plurality of preset windows through the fourth neural network model to be trained; wherein the number of characters corresponding to each of the preset windows is different; determining the idiomatic sentences in the training text from the plurality of words corresponding to each of the preset windows through the fourth neural network model to be trained, and determining the prior feature parameters according to the idiomatic sentences in the training text; the plurality of weight items are determined according to the product of the first loss function, the second loss function and the third loss function respectively with each of the first preset weights in the plurality of first preset weights, including: determining the plurality of weight items according to the product of the first loss function, the second loss function, the third loss function and the prior feature parameters respectively with each of the first preset weights in the plurality of first preset weights.
[0018] A third aspect of an embodiment of the present application provides a device for determining similar texts, the device comprising: a first acquisition module, configured to acquire multiple preset texts and a first question text input by a user; a first determination module, configured to determine feature information corresponding to each of the multiple preset texts, and determine feature information corresponding to the first question text; wherein the feature information includes overall semantic features, core sentence features and label information; a second determination module, configured to determine the similarity between the first question text and each of the preset texts based on the feature information corresponding to each of the preset texts and the first question text; and a third determination module, configured to determine and output a target preset text from the multiple preset texts based on the similarity between the first question text and each of the preset texts.
[0019] According to a fourth aspect of an embodiment of the present application, there is provided a training device for a similar case retrieval model, wherein the similar case retrieval model comprises a first neural network model, a second neural network model and a third neural network model, and the device comprises: a second acquisition module, configured to acquire a plurality of training texts, and determine target similarities corresponding to the plurality of training texts and target label sequences corresponding to the plurality of training texts; a fourth determination module, configured to determine a first loss function corresponding to the first neural network model to be trained, and a second loss function corresponding to the second neural network model to be trained, based on the plurality of training texts and the target similarities corresponding to the plurality of training texts; a fifth determination module, configured to determine a third loss function corresponding to the third neural network model to be trained, based on the plurality of training texts and the target label sequences corresponding to the plurality of training texts; a sixth determination module, configured to determine a target loss function based on the first loss function, the second loss function and the third loss function; and an optimization module, configured to optimize parameters in the first loss function, the second loss function, the third loss function and the target loss function, so as to determine the trained first neural network model, the trained second neural network model and the trained third neural network model.
[0020] A fifth aspect of an embodiment of the present application provides an electronic device, comprising: one or more processors and a memory, the memory being configured to: store one or more programs; wherein, when the one or more programs are executed by one or more processors, the one or more processors implement the method for determining similar texts described in the first aspect above, or implement the method for training a similar case retrieval model described in the second aspect above.
[0021] A sixth aspect of an embodiment of the present application provides a computer-readable storage medium, which stores computer program instructions. When a computer reads the instructions, it executes the method for determining similar texts described in the first aspect, or implements the method for training a similar case retrieval model described in the second aspect.
[0022] A seventh aspect of an embodiment of the present application provides a computer program product, which includes a computer program stored on a non-transitory computer-readable storage medium, and the computer program includes program instructions. When the program instructions are executed by a computer, the computer executes the method for determining similar texts described in the first aspect, or implements the method for training a similar case retrieval model described in the second aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0024] Figure 1 A schematic diagram of a similar case retrieval model provided for some embodiments of the present application;
[0025] Figure 2 A schematic diagram of another similar case retrieval model provided for some embodiments of the present application;
[0026] Figure 3 A flowchart of a method for determining similar texts provided in some embodiments of the present application;
[0027] Figure 4 A flowchart of another method for determining similar texts provided in some embodiments of the present application;
[0028] Figure 5 A flowchart of another method for determining similar texts provided in some embodiments of the present application;
[0029] Figure 6 A flowchart of another method for determining similar texts provided in some embodiments of the present application;
[0030] Figure 7 A flowchart of another method for determining similar texts provided in some embodiments of the present application;
[0031] Figure 8 A scene graph for similar case retrieval provided in some embodiments of the present application;
[0032] Fig. 9 A flowchart of a method for training a similar case retrieval model provided in some embodiments of the present application;
[0033] Fig.10 A flowchart of another method for training a similar case retrieval model provided in some embodiments of the present application;
[0034] Fig.11 A flowchart of another method for training a similar case retrieval model provided in some embodiments of the present application;
[0035] Fig.12 A flowchart of another method for training a similar case retrieval model provided in some embodiments of the present application;
[0036] Fig.13 A flowchart of another method for training a similar case retrieval model provided in some embodiments of the present application;
[0037] Fig.14 A schematic diagram of a similar text determination device provided in some embodiments of the present application;
[0038] Fig.15 A schematic diagram of a training device for a similar case retrieval model provided in some embodiments of the present application;
[0039] Fig.16 A schematic diagram of an electronic device according to some embodiments of the present application. DETAILED DESCRIPTION
[0040] In order to enable those skilled in the art to better understand the technical solutions in the embodiments of the present invention and to make the above-mentioned purposes, features and advantages of the embodiments of the present invention more obvious and understandable, the technical solutions in the embodiments of the present invention are further described in detail below with reference to the accompanying drawings.
[0041] In existing legal consulting systems, traditional similarity matching algorithms are usually used to determine the similarity between the query content input by the user and the existing case judgments to achieve similar case retrieval. However, traditional similarity matching algorithms are not suitable for similar case retrieval scenarios for the following reasons:
[0042] 1. Case judgments are often composed of multiple complex sentences, and different sentences have different importance for the similarity matching process. Therefore, it is difficult to achieve a good matching effect by using only a single sentence similarity matching algorithm to perform similarity matching on case judgments;
[0043] 2. A considerable portion of the case judgment contains common phrases that are part of legal documents, such as "The above evidence has been cross-examined in court in accordance with the law and confirmed by this court", "If you are dissatisfied with this judgment, you may file a complaint with this court within ten days from the second day after receiving the judgment...", etc. However, when performing similarity matching on case judgments, the importance of common phrases is very low, but they usually appear repeatedly in judgments, so common phrases have a greater negative impact on case similarity matching;
[0044] 3. Some legal cases involve multiple crimes, or different circumstances of the same crime; and there are some specific penalty provisions in different legal fields, such as aggravated circumstances, imaginary competition, implicated crimes, or multiple punishments, which will further complicate the case judgment. Therefore, this situation will make the case similarity matching process more difficult than the conventional sentence similarity matching.
[0045] Based on the above technical problems, the present application provides a method for determining similar texts, a method and device for training a similar case retrieval model, which can perform multi-level deep matching of the first question text input by the user and the preset text based on the overall semantic features, core semantic features and label information of the preset text in the preset data, thereby realizing similarity matching of complex legal cases in legal consultation scenarios and improving the accuracy of similar case retrieval.
[0046] It should be noted that the training samples used in the training process of the neural network model involved in this application are all from authorized legal documents, judgments, case descriptions, etc., and the conclusions obtained by the method for determining similar texts and the similar case retrieval model provided in this application are only used to form consulting opinions for users for reference.
[0047] Figure 1 A schematic diagram of a similar case retrieval model provided in some embodiments of the present application. Figure 1 As shown, the similar case retrieval model 100 may include a first neural network model 110 , a second neural network model 120 and a third neural network model 130 .
[0048] Exemplarily, the first neural network model 110 may be a BERT model, the second neural network model 120 may be a convolutional neural network (CNN) model, and the third neural network model 130 may include a multi-layer bidirectional long short-term memory network (Bi-directional Long Short-Term Memory, Bi-LSTM) model and a conditional random field (Conditional Random Fields, CRF) layer.
[0049] In some embodiments, the similar case retrieval model 100 can obtain a first question text input by a user, and obtain multiple preset texts in a preset database. For example, the first question text input by the user can be legal consultation information, such as "I had a car accident, how should I protect my rights?", "My neighbor's wall repair affected the lighting of my house, I want to know similar cases", etc. The preset text in the preset database can be a judgment of an existing legal case.
[0050] In some embodiments, the first neural network model 110 can obtain the first question text and multiple preset texts input by the user, and perform feature extraction on each preset text and the first question text in the multiple preset texts to obtain the overall semantic features and word semantic features corresponding to each preset text and the first question text. Among them, the overall semantic features corresponding to each preset text and the first question text represent the chapter-level semantic features (i.e., the semantic features of the entire preset text) corresponding to each preset text and the first question text, and the word semantic features corresponding to each preset text and the first question text represent the semantic features corresponding to each word in each preset text and the first question text.
[0051] The second neural network model 120 can obtain the overall semantic features corresponding to each preset text and the first question text determined by the first neural network model 110, and determine the core sentence features corresponding to each preset text and the first question text based on the overall semantic features corresponding to each preset text and the first question text. The core sentence features corresponding to each preset text and the first question text represent the core semantic features corresponding to each sentence in each preset text and the first question text.
[0052] The third neural network model 130 can obtain the word semantic features corresponding to each preset text and the first question text determined by the first neural network model 110, and based on the word semantic features corresponding to each preset text and the first question text, respectively perform sequence annotation on the sentences in each preset text and the first question text to determine the label information corresponding to each sentence in each preset text and the first question text, and the label information represents the legal meaning of each sentence.
[0053] Next, the similar case retrieval model 100 can determine the similarity between each preset text and the first question text based on the feature information (i.e., overall semantic features, core semantic features, and label information) corresponding to each preset text and the first question text. The similar case retrieval model 100 can determine and output one or more target preset texts from the multiple preset texts based on the similarities corresponding to the multiple preset texts, so as to provide the user with legal advice based on the legal case judgments similar to the first question text.
[0054] By applying the above technical solution, a multi-level deep matching algorithm based on paragraph-sentence-sequence annotation can be constructed through a three-layer network structure, thereby improving the accuracy of calculating the similarity between the first question text and each preset text, that is, improving the accuracy of similar case retrieval.
[0055] Figure 2 A schematic diagram of another similar case retrieval model provided in some embodiments of the present application. Figure 2 As shown, the similar case retrieval model 100 may further include a fourth neural network model 140 .
[0056] In some embodiments, the fourth neural network model 140 can identify idiomatic sentences in each preset text. It can be understood that idiomatic sentences are not important for the similarity matching process, and idiomatic sentences also appear frequently in the judgment. Therefore, a large number of idiomatic sentences in the judgment that are not related to similarity matching will increase the calculation amount of similarity matching, and have a greater negative impact on similarity matching. Therefore, in addition to determining the feature information corresponding to each preset text and the first question text through the above-mentioned first neural network model 110, the second neural network model 120 and the third neural network model 130, the similar case retrieval model 100 can also identify the idiomatic sentences in each preset text through the fourth neural network model 140, and do not use the idiomatic sentences in each preset text for similarity calculation. That is to say, the similar case retrieval model 100 can determine the similarity between each preset text and the first question text based on the non-idiomatic sentences in each preset text and the feature information corresponding to the first question text.
[0057] By applying the above technical solution, while calculating the similarity between the first question text and each preset text based on a multi-level deep matching algorithm of paragraph-sentence-sequence annotation, some contents in the preset text that may have a negative impact on the similarity matching (i.e., idiomatic sentences in the preset text) are excluded, thereby further improving the accuracy of the similarity calculation.
[0058] The following is a detailed description of the method for determining similar texts provided in this application.
[0059] Figure 3 A flowchart of a method for determining similar texts provided in some embodiments of the present application, wherein: Figure 3 The method for determining similar texts shown can be done by Figure 1 or Figure 2 The similar case retrieval model 100 shown is implemented as shown. Figure 3 As shown, the method for determining similar texts may include steps 310 to 340.
[0060] Step 310: Acquire multiple preset texts and a first question text input by the user.
[0061] In some embodiments, a user may input legal consulting information (hereinafter referred to as the first question text) in a user interface provided by a legal consulting system (hereinafter referred to as the central control system). The central control system may call a corresponding legal tool in response to the first question text input by the user to process the first question text to obtain a processing result, thereby summarizing the processing results obtained by each legal tool, obtaining a final consulting opinion and outputting it to the user. Among them, the legal tool may include a similar case retrieval model, which may retrieve case judgments similar to the first question text input by the user in a preset database, so that the similar case judgments may be used as the basis for the legal consulting opinion, or the case judgments may be directly output for user reference.
[0062] For example, after the similar case retrieval model is called by the central control system, the first question text input by the user can be obtained, and multiple preset texts can be obtained from the preset database. The preset texts in the preset database can be judgment documents of existing legal cases.
[0063] Step 320, determining feature information corresponding to each of the plurality of preset texts, and determining feature information corresponding to the first question text.
[0064] In some embodiments, after obtaining the first question text and multiple preset texts, the feature information corresponding to each preset text and the feature information corresponding to the first question text can be determined through a similar case retrieval model, wherein the feature information includes overall semantic features, core sentence features and label information.
[0065] Exemplarily, the overall semantic features corresponding to each preset text or the first question text represent the chapter-level semantic features corresponding to each preset text or the first question text (i.e., the semantic features corresponding to the entire preset text or the entire first question text). The core sentence features corresponding to each preset text or the first question text represent the core semantic features corresponding to each sentence in each preset text or the first question text. The label information corresponding to each preset text or the first question text represents the legal meaning corresponding to each sentence in each preset text or the first question text.
[0066] Step 330: Determine the similarity between the first question text and each preset text based on the feature information corresponding to each preset text and the first question text.
[0067] In some embodiments, after determining the feature information corresponding to each preset text and the first question text, the similar case retrieval model can fuse the feature information corresponding to each preset text (such as vector concatenation or weighted fusion, etc.) to obtain the fused feature information corresponding to each preset text; and fuse the feature information corresponding to the first question text to obtain the fused feature information corresponding to the first question text. Then, based on the fused feature information corresponding to each preset text and the fused feature information corresponding to the first question text, the similarity between each preset text and the first question text is determined.
[0068] Step 340: Based on the similarity between the first question text and each preset text, determine and output a target preset text from a plurality of preset texts.
[0069] In some embodiments, the similar case retrieval model may then determine and output a target preset text from a plurality of preset texts based on the similarity between the first question text and each preset text.
[0070] Exemplarily, the similar case retrieval model can determine the preset text with a similarity greater than a preset similarity threshold as the target preset text among multiple preset texts based on the similarity corresponding to the above preset texts and output it; or, it can also sort the multiple preset texts in descending order based on the similarity corresponding to the above preset texts, and select the first N (N is a positive integer) preset texts from the sorted multiple preset texts as the target preset texts and output them. It should be noted that the above method of determining the target preset text among multiple preset texts based on similarity is only an example and is not limited to this in this embodiment.
[0071] Through the above scheme, the similar case retrieval model can extract features from the legal consulting information input by the user (i.e., the first question text) and the judgment in the database (i.e., the preset text) to obtain different levels of feature information corresponding to each preset text and the first question text (including overall semantic features, core sentence meaning features and label information), and determine the similarity between each preset text and the first question text based on the different levels of feature information corresponding to each preset text and the first question text, thereby improving the effect of similarity matching and improving the accuracy of similar case retrieval.
[0072] Figure 4 A flowchart of another method for determining similar texts provided in some embodiments of the present application, such as Figure 4 As shown, the above step 320 may include steps 410 to 430.
[0073] Step 410, determining the overall semantic features and word semantic features corresponding to each preset text.
[0074] In some embodiments, the similar case retrieval model can first perform feature extraction processing on each preset text to obtain the overall semantic features and word semantic features corresponding to each preset text; and perform feature extraction processing on the first question text to obtain the overall semantic features and word semantic features corresponding to the first question text.
[0075] Exemplarily, the overall semantic features and word semantic features corresponding to each preset text and the first question text can be extracted by the first neural network model in the similar case retrieval model. Among them, the first neural network model can be a BERT model. It can be understood that the feature extraction of the text by the BERT model will become more and more abstract as the number of model layers increases, that is, the higher the number of model layers, the more the extracted text features can represent the semantics of the entire chapter of the text, and the lower the number of model layers, the more the extracted text features can represent the semantic features of each word in the text. Therefore, the word semantic features corresponding to each preset text and the first question text output by the first few layers (such as the second layer) of the BERT model can be obtained, and the overall semantic features corresponding to each preset text and the first question text output by the last layer of the BERT model can be obtained.
[0076] Step 420 , based on the overall semantic features corresponding to each preset text, determine the core sentence features corresponding to each preset text.
[0077] In some embodiments, the similar case retrieval model can then determine the core sentence meaning features corresponding to each sentence in each preset text based on the overall semantic features corresponding to each preset text; and determine the core sentence meaning features corresponding to each sentence in the first question text based on the overall semantic features corresponding to the first question text.
[0078] Exemplarily, the core sentence features corresponding to each preset text and the first question text can be determined by the second neural network model in the similar case retrieval model, wherein the second neural network model can be a CNN model.
[0079] Step 430, based on the semantic features of the words corresponding to each preset text, determine the label information corresponding to each preset text.
[0080] In some embodiments, the similar case retrieval model can then perform sequence annotation on the sentences in each preset text based on the word semantic features corresponding to each preset text to determine the label information corresponding to each sentence in each preset text; and perform sequence annotation on the sentences in the first question text based on the word semantic features corresponding to the first question text to determine the label information corresponding to each sentence in the first question text.
[0081] Exemplarily, the semantic features of words corresponding to each preset text and the first question text can be determined by a third neural network model in the similar case retrieval model. The third neural network model can be a neural network model including a Bi-LSTM model and a CRF layer.
[0082] Through the above scheme, the overall semantic features, word semantic features, core sentence features and label information corresponding to each preset text and the first question text can be determined through a similar case retrieval model, that is, different levels of feature information corresponding to each preset text and the first question text are obtained, and the similarity between each preset text and the first question text is determined based on the different levels of feature information corresponding to each preset text and the first question text, thereby improving the effect of similarity matching and improving the accuracy of similar case retrieval.
[0083] Figure 5 A flowchart of another method for determining similar texts provided in some embodiments of the present application, such as Figure 5 As shown, the above step 410 may include steps 510 to 520.
[0084] Step 510, perform feature extraction on each preset text through the first neural network model, and obtain the first feature extraction result corresponding to each preset text obtained by the first encoding layer in the first neural network model, and the second feature extraction result corresponding to each preset text obtained by the second encoding layer in the first neural network model.
[0085] In some embodiments, the first neural network model in the similar case retrieval model can be used to extract features from each preset text, and feature extraction can be performed on the first question text input by the user.
[0086] Exemplarily, the first neural network model can be a BERT model. The BERT model includes multiple encoding layers, and each encoding layer outputs the features of the text (i.e., feature extraction results). Among them, the last few encoding layers in the BERT model can capture the deeper global semantic features corresponding to the text, and the first few encoding layers can capture the shallower local semantic features corresponding to the text (such as the semantic features of each word in the text). That is, the lower the number of layers of the BERT model, the more the text features extracted by the BERT model can represent the semantic features of each word in the text; the higher the number of layers of the BERT model, the more the text features extracted by the BERT model can represent the chapter-level semantic features of the text. Therefore, in order to obtain different levels of semantic features corresponding to each preset text and the first question text, the second encoding layer in the BERT model can be a different encoding layer from the first encoding layer.
[0087] Exemplarily, the number of layers of the first coding layer may be less than the number of layers of the second coding layer. For example, the first coding layer may be a relatively early coding layer in the BERT model, such as the second coding layer in the BERT model; the second coding layer in the BERT model may be a relatively late coding layer in the BERT model, such as the second coding layer may be the last coding layer in the BERT model.
[0088] Step 520, determining the first feature extraction result corresponding to each preset text as the word semantic feature corresponding to each preset text, and determining the second feature extraction result corresponding to each preset text as the overall semantic feature corresponding to each preset text.
[0089] In some embodiments, after obtaining the first feature extraction results corresponding to each preset text and the first question text respectively through the first encoding layer in the BERT model, the first feature extraction results corresponding to each preset text can be determined as the word semantic features corresponding to each preset text, and the first feature extraction results corresponding to the first question text can be determined as the word semantic features corresponding to the first question text. After obtaining the second feature extraction results corresponding to each preset text and the first question text respectively through the second encoding layer in the BERT model, the second feature extraction results corresponding to each preset text can be determined as the overall semantic features corresponding to each preset text, and the second feature extraction results corresponding to the first question text can be determined as the overall semantic features corresponding to the first question text.
[0090] Through the above scheme, the first neural network model can perform feature extraction processing on each preset text and the first question text through different encoding layers, so as to provide semantic features at the word level and semantic features at the overall level for the similarity matching process, thereby improving the accuracy of similarity matching.
[0091] Figure 6 A flowchart of another method for determining similar texts provided in some embodiments of the present application, such as Figure 6 As shown, the above step 420 may include steps 610 to 620.
[0092] Step 610: divide the overall semantic features corresponding to each preset text into sentences through a second neural network model to obtain a plurality of sentences corresponding to each preset text.
[0093] In some embodiments, the core semantic features of each preset text and the first question text can be determined by a second neural network model in a similar case retrieval model based on the overall semantic features corresponding to each preset text and the first question text output by the first neural network model.
[0094] Exemplarily, the second neural network model may be a CNN model. First, the CNN model may divide the sentences in each preset text and the first question text based on the overall semantic features corresponding to each preset text and the first question text. For example, the multiple sentences in each preset text and the first question text may be split according to "。".
[0095] Step 620: Determine the non-core words in the multiple sentences corresponding to each preset text through the second neural network model, and adjust the weights of the non-core words corresponding to each preset text to obtain the core semantic features corresponding to each sentence in the multiple sentences corresponding to each preset text.
[0096] In some embodiments, after determining the multiple sentences in each preset text and the first question text, the CNN model may perform semantic analysis on each sentence in each preset text and the first question text to determine the core semantic features of each sentence.
[0097] Exemplarily, during the process of the CNN model performing semantic analysis on each of the above sentences, the weights of non-core words (such as words like "的", "本院", "依据", etc.) may be reduced, so that the semantic features of each obtained sentence can represent the core meaning of each sentence.
[0098] Through the above solution, the second neural network model can process the overall semantic features corresponding to each preset text and the first question text, can provide semantic features at the sentence level for the similarity matching process, and can further improve the accuracy of similarity matching in combination with the above semantic features at the word level and the overall level.
[0099] In some embodiments, the above step 430 may include: determining the label information corresponding to each sentence in the multiple sentences corresponding to each preset text from multiple preset label information through the third neural network model based on the word semantic features corresponding to each preset text; wherein, the label information corresponding to each sentence is used to represent the key information corresponding to each sentence.
[0100] Exemplarily, the third neural network model may determine one or more label information corresponding to each sentence in each preset text and the first question text based on the word semantic features corresponding to each preset text and the first question text output by the first neural network model.
[0101] Exemplarily, the third neural network model may include a multi-layer Bi-LSTM model and a CRF layer. The third neural network model may perform sequence annotation on different parts of each sentence in each preset text and the first question text in units of words to extract key information in the sentence. In some examples, the third neural network model may annotate each sentence according to preset label information to determine the legal meaning of each part of each sentence, that is, to determine the key information of each sentence. Among them, the preset label information may include elements of a crime, a crime, a legal basis, etc., which are not limited in this embodiment.
[0102] For example, in the sentence "Wang accidentally stepped on the accelerator, causing three people to be seriously injured, and Wang was fully responsible for the accident. According to Article 133 of the Criminal Law and Article 2 of the Interpretation of the Supreme People's Court on Several Issues Concerning the Specific Application of Laws in the Trial of Criminal Cases of Traffic Accidents, Wang's behavior constituted the crime of traffic accident", the label information of "Wang accidentally stepped on the accelerator, causing three people to be seriously injured, and Wang was fully responsible for the accident" can be "elements of the crime"; the label information of "according to Article 133 of the Criminal Law and Article 2 of the Interpretation of the Supreme People's Court on Several Issues Concerning the Specific Application of Laws in the Trial of Criminal Cases of Traffic Accidents" can be "legal basis"; the label information of "Wang's behavior constitutes the crime of traffic accident" can be "crime".
[0103] Through the above scheme, the third neural network model can process the semantic features of words corresponding to each preset text and the first question text, and can provide label-level semantic features for the similarity matching process. In combination with the above-mentioned sentence-level semantic features and the overall-level semantic features, the accuracy of similarity matching can be further improved.
[0104] In some embodiments, after the above step 320, the above method further includes: identifying idiomatic sentences in each preset text through a fourth neural network model, and determining a processed preset text according to the idiomatic sentences in each preset text.
[0105] Exemplarily, after the overall semantic features, core sentence features and label information corresponding to each preset text and the first question text are determined by the first neural network model, the second neural network model and the third neural network model, the idiomatic sentences in each preset text can also be identified by the fourth neural network model in the similar case retrieval model, such as "The above evidence has been cross-examined in court in accordance with the law, and this court confirms it", "If you are dissatisfied with this judgment, you can go through this court within ten days from the second day of receiving the judgment..." and other idiomatic sentences to eliminate the influence of idiomatic sentences on the similarity matching between each preset text and the first question text. Among them, the fourth neural network model can be a TFIDF model.
[0106] Exemplarily, after determining the idiomatic sentences in each preset text, the idiomatic sentences in each preset text may be deleted from each preset text, or the weight of the idiomatic sentences in each preset text may be reduced, thereby obtaining a processed preset text.
[0107] In some embodiments, the above step 330 includes: determining the similarity between the first question text and the processed preset text based on the overall semantic features, core sentence features and label information corresponding to the processed preset text and the first question text.
[0108] Exemplarily, after determining the processed preset text, the similarity between the first question text and the processed preset text can be determined through a similar case retrieval model based on the overall semantic features, core sentence features and label information corresponding to the processed preset text and the first question text.
[0109] Through the above scheme, the fourth neural network model can identify idiomatic sentences in the preset text that are likely to have a negative impact on similarity matching, so as not to use the idiomatic sentences for similarity calculation, thereby further improving the accuracy of similarity matching.
[0110] Figure 7 A flowchart of another method for determining similar texts provided in some embodiments of the present application, such as Figure 7 As shown, the above step 340 may include steps 710 to 720.
[0111] Step 710: sort the plurality of preset texts in descending order according to the similarity between the first question text and each preset text, and obtain a sorting result.
[0112] In some embodiments, after determining the similarity between the first question text and each preset text, the similar case retrieval model can sort each preset text according to the degree of similarity and obtain a sorting result. For example, each preset text can be sorted in descending order according to the degree of similarity, that is, sorting each preset text from high to low; or, each preset text can be sorted in ascending order according to the degree of similarity, that is, sorting each preset text from low to high.
[0113] Step 720: determine the first N preset texts in the sorting result as target preset texts, and output the target preset texts.
[0114] In some embodiments, after obtaining the ranking results, the similar case retrieval model can determine one or more target preset texts to be output from multiple preset texts based on the ranking results.
[0115] For example, when a plurality of preset texts are sorted in descending order, the first N preset texts in the sorting result can be determined as target preset texts, where N is a positive integer. The first N target preset texts are the preset texts that are most similar to the first question text.
[0116] In some embodiments, after determining the target preset text, the similar case retrieval model can output the target preset text through the user interface of the central control system to provide consulting results to the user.
[0117] In some embodiments, after the above step 310, the above method further includes: in the case where the first question text lacks the necessary information for calculating the similarity, determining the question information features corresponding to the first question text and the core information corresponding to the first question text through the fifth neural network model, and determining the first event information corresponding to the first question text based on the question information features and the core information corresponding to the first question text; determining the event determination information based on the first event information through the sixth neural network model, and determining and outputting the second question text based on the event determination information and the first question text; obtaining the reply text input by the user to the second question text, and determining the target question text based on the first question text and the reply text. "Determining the feature information corresponding to the first question text" in the above step 320 includes: determining the feature information corresponding to the target question text.
[0118] Exemplarily, when the first question text currently input by the user lacks necessary information, after the similar case retrieval model matches the first question text with multiple preset texts in the preset database for similarity, the legal judgment results involving the multiple target preset texts that are relatively similar to the first question text may be based on different case situations. Therefore, if the corresponding multiple target preset texts are directly obtained based on the first question text that lacks necessary information and output to the user, it will not be possible to provide the user with a good consulting result, and it will cause the user to distinguish and choose between different judgment results, thereby reducing the user experience. Therefore, the central control system can call other legal tools to obtain event judgment information for determining the necessary information missing in the first question text.
[0119] Exemplarily, the central control system can call legal tools such as the legal event detection model (i.e., the fifth neural network model) and the legal event establishment condition determination model (i.e., the sixth neural network model). The legal event detection model can obtain text features after vectorizing the first question text through the BERT model therein, and determine the core information corresponding to each entity in the first question text and the core relationship between each entity through the graph convolutional network (GCN) model therein; then the legal event detection model can preliminarily determine the legal event (i.e., the first event information) corresponding to the first question text through the classification model therein based on the text features and core information corresponding to the first question text. Then, the legal event establishment condition determination model determines the event determination information based on the first event information. The central control system generates a corresponding second question text (or information slot) based on the event determination information to ask the user questions, so that the user can reply based on the second question text. The similar case retrieval model can supplement and improve the original first question text based on the user's reply text to obtain the target question text; then the target question text is matched with multiple preset texts for similarity, so as to provide users with better consulting results.
[0120] refer to Figure 8 A scenario diagram of similar case retrieval is shown in FIG. Figure 8As shown, the first question text 801 input by the user in the user interface 80 of the central control system is "I was hit by a car, can I defend my rights?" In the scenario involved in the first question text 801, there may be criminal liability and civil liability in traffic accidents, and whether the user can defend his rights also involves information such as the allocation of accident responsibilities between the parties. Therefore, the central control system can determine the lack of necessary information such as the allocation of accident responsibilities (such as whether the user is at fault, whether the responsibility is clear), the degree of injury (minor or serious injury), whether the driver is suspected of drunk driving, drug driving or hit-and-run (whether criminal liability is involved), whether the police have been called and the accident identification certificate has been obtained in the first question text 801 through legal tools such as legal event detection tools, legal information extraction tools, and legal event establishment condition determination tools; and generate corresponding one or more second question texts 802 based on the above one or more necessary information, such as "Who is responsible for the accident between you and the other party?", "Is the other party suspected of drunk driving, drug driving or hit-and-run?", "Is your injury level minor or serious?", etc. Thus, the user can reply to the second question text 802 of the necessary information output by the central control system, such as "the other party bears the responsibility for the accident", "the other party did not flee, but was suspected of drunk driving", "the degree of injury is minor", etc. Further, the similar case retrieval model can obtain the user's reply text 803, and supplement and improve the first question text 801 based on the reply text 803 to obtain the target question text; then the target question text is matched with multiple preset texts for similarity, so as to output the final legal consultation result 804 for the user.
[0121] Through the above scheme, when the consulting information input by the user lacks necessary information, the central control system can interact with the user by asking questions, so that the user can provide some necessary information that can make the similar case retrieval results more accurate based on the question information output by the central control system. In this way, the similar case retrieval model can perform similarity matching with the existing preset text based on the consulting information input by the user and the supplementary necessary information, so as to achieve more accurate similar case retrieval, and then provide users with better similar case retrieval results.
[0122] Fig. 9 A flowchart of a method for training a similar case retrieval model provided in some embodiments of the present application, such as Fig. 9 As shown, the method may include steps 910 to 950.
[0123] Step 910: Acquire multiple training texts, and determine target similarities corresponding to the multiple training texts and target tag sequences corresponding to the multiple training texts.
[0124] In some embodiments, when training a similar case retrieval model to be trained, multiple judgments (hereinafter referred to as training texts) can be selected from an existing legal database as training samples.
[0125] In some examples, in order to improve the training effect, multiple training groups can be set according to multiple training texts. The same training group can include the verdict of a certain crime, as well as the verdicts of other crimes related to or easily confused with the crime. For example, the verdict of the crime of traffic accident can be selected, and the verdicts of different statutory circumstances such as hit-and-run as the condition for the establishment of the crime of traffic accident, hit-and-run as the statutory upgrading condition, and hit-and-run resulting in death can be appropriately covered; on this basis, the verdicts of related crimes such as dangerous driving, obstructing safe driving, and endangering public safety by dangerous means that are easily confused with the crime of traffic accident in practice can be further selected, and the above-mentioned verdicts can be set as the same training group. At the same time, as a reference, one or more verdicts of unrelated cases can be added to the training group.
[0126] In some embodiments, during the training process, two different judgments (i.e., training texts) in the same training group may be input into the similar case retrieval model to be trained each time. In addition, the target similarity between the two training texts may be determined in advance using a supervised method (such as manual annotation) or an unsupervised method (such as annotation using an existing similarity calculation model). The target similarity between the two training texts may include the overall semantic similarity between the two training texts and the semantic similarity between the sentences in the two training texts.
[0127] Next, the corresponding similarity label can be determined according to the target similarity, and the similarity labels corresponding to the two training texts can be input into the similar case retrieval model to be trained. Exemplarily, the similarity label between the two training texts can be determined based on a preset assignment rule. For example, if the target similarity between the two training texts reaches more than 80%, the similarity label is set to 1; if the target similarity between the two training texts is 60% to 80%, the similarity label is set to 0.8; if the target similarity between the two training texts is 40% to 60%, the similarity label is set to 0.6. It should be noted that the above-mentioned setting method of the similarity label is only an example and is not limited to this in this embodiment.
[0128] Exemplarily, the target similarity between different training texts in the same training group will be inevitable based on the facts of the case. For example, the similarity between training texts with basically the same elements of crime is necessarily high, and the target similarity between training texts with different elements of crime is necessarily low. Therefore, the above-mentioned assignment rules can be further refined based on the contents such as the elements of crime in the training group. In addition, the guiding cases and the like will be accompanied by a summary or explanation of the key points for different training texts or similar training texts, so they can also be used as the basis for similarity judgment to further refine the above-mentioned assignment rules.
[0129] In some embodiments, during the training process, each part of each sentence in each training text can be sequence-labeled in advance to determine the target label sequence corresponding to each training text, and the target label sequence corresponding to each training text is input into the similar case retrieval model to be trained.
[0130] Step 920, based on the multiple training texts and the target similarities corresponding to the multiple training texts, determine a first loss function corresponding to the first neural network model to be trained, and determine a second loss function corresponding to the second neural network model to be trained.
[0131] In some embodiments, after the above-mentioned multiple training texts and the target label sequences corresponding to the multiple training texts are input into the similar case retrieval model to be trained, the first neural network model to be trained and the second neural network model to be trained in the similar case retrieval model to be trained can respectively determine the first loss function and the second loss function based on the above-mentioned input.
[0132] Exemplarily, the first neural network model to be trained can perform feature extraction processing on multiple training texts to obtain overall semantic features and word semantic features corresponding to each training text; and determine the first similarity between each training text based on the overall semantic features corresponding to each training text; and then determine the first loss function corresponding to the first neural network model to be trained based on the first similarity and target similarity between each training text.
[0133] Exemplarily, the second neural network model to be trained can determine the core semantic features corresponding to each sentence in each training text based on the overall semantic features corresponding to the above-mentioned training texts (i.e., determine the core sentence meaning features corresponding to each training text); and determine the second similarity between each training text based on the core sentence meaning features corresponding to each training text; and then determine the second loss function corresponding to the second neural network model to be trained based on the second similarity between each training text and the target similarity.
[0134] Step 930: Determine a third loss function corresponding to a third neural network model to be trained based on multiple training texts and target label sequences corresponding to the multiple training texts.
[0135] In some embodiments, the third neural network model to be trained can perform sequence annotation on each sentence in each training text based on the word semantic features corresponding to the above-mentioned training texts to obtain a predicted label sequence corresponding to each training text; and determine the third loss function corresponding to the third neural network model to be trained based on the predicted label sequence and target label sequence corresponding to each training text.
[0136] Step 940: determine a target loss function based on the first loss function, the second loss function, and the third loss function.
[0137] In some embodiments, after determining the first loss function, the second loss function, and the third loss function, the overall loss function (ie, the target loss function) of the similar case retrieval model may be further determined.
[0138] Exemplarily, corresponding weights can be set for the first loss function, the second loss function, and the third loss function, respectively, and multiple weight items can be determined based on the product of the above loss functions and the weights; and multiple interaction items between the first loss function, the second loss function, and the third loss function can also be determined based on the interaction item weights; in addition, the first loss function, the second loss function, and the third loss function can also be respectively subjected to exponential operations to obtain the exponential items corresponding to the above loss functions. Finally, the above multiple weight items, multiple interaction items, and multiple exponential items are added together to obtain the target loss function corresponding to the similar case retrieval model.
[0139] Step 950, optimizing the parameters in the first loss function, the second loss function, the third loss function and the target loss function to determine the trained first neural network model, the trained second neural network model and the trained third neural network model.
[0140] In some embodiments, after obtaining the above-mentioned loss function, the parameters in the first loss function, the second loss function, the third loss function and the target loss function can be optimized respectively to determine the trained first neural network model, the trained second neural network model and the trained third neural network model.
[0141] Fig.10 A flowchart of another method for training a similar case retrieval model provided in some embodiments of the present application, such as Fig.10 As shown, the above step 920 of "determining a first loss function corresponding to a first neural network model to be trained based on multiple training texts and target similarities corresponding to the multiple training texts" may include steps 1010 to 1030.
[0142] Step 1010: determine the overall semantic features and word semantic features corresponding to each training text in a plurality of training texts through the first neural network model to be trained.
[0143] In some embodiments, the first neural network model to be trained may be a BERT model to be trained. The BERT model to be trained may perform feature extraction processing on each training text in a plurality of training texts to obtain overall semantic features and word semantic features corresponding to each training text.
[0144] It can be understood that the manner in which the first neural network model to be trained determines the overall semantic features and word semantic features corresponding to each training text can be referred to the description of steps 510 to 520, which will not be repeated here.
[0145] Step 1020: Determine first similarities corresponding to the plurality of training texts based on overall semantic features corresponding to the training texts using a first neural network model to be trained.
[0146] In some embodiments, the first neural network model to be trained can determine the similarity (ie, the first similarity) between the training texts based on the overall semantic features corresponding to the training texts.
[0147] Exemplarily, the first neural network model to be trained can calculate the cosine similarity between each training text, and the cosine similarity is determined as the first similarity. It should be noted that the above method of determining the first similarity between each training text by the first neural network model to be trained is only an example and is not limited to this in this embodiment.
[0148] Step 1030: Determine a first loss function based on the first similarities corresponding to the plurality of training texts and the target similarities through the first neural network model to be trained.
[0149] In some embodiments, after determining the first similarities between the training texts, the first neural network model to be trained may determine a first loss function based on the first similarities between the training texts and the target similarity.
[0150] Exemplarily, the first loss function can be determined based on the cross-entropy loss between the first similarity and the target similarity to measure the difference between the probability distribution predicted by the first neural network model and the true distribution. In some examples, the first loss function can be determined according to formula (1):
[0151]
[0152] Among them, L1 is the first loss function; y i is the target similarity between each training text, The first similarity between the training texts predicted by the first neural network model to be trained.
[0153] Fig.11 A flowchart of another method for training a similar case retrieval model provided in some embodiments of the present application, such as Fig.11 As shown, the above step 920 of "determining a second loss function corresponding to a second neural network model to be trained based on multiple training texts and target similarities corresponding to the multiple training texts" may include steps 1110 to 1130.
[0154] Step 1110, determining the core sentence features corresponding to each training text based on the overall semantic features corresponding to each training text through the second neural network model to be trained.
[0155] In some embodiments, the second neural network model to be trained may be a CNN model to be trained. The CNN model to be trained may obtain the overall semantic features corresponding to each training text determined by the first neural network model to be trained, and perform feature extraction processing on the overall semantic features corresponding to each training text to obtain the core sentence meaning features corresponding to each sentence in each training text.
[0156] It can be understood that the manner in which the second neural network model to be trained determines the core sentence meaning features corresponding to each training text can be referred to the description of steps 610 to 620, which will not be repeated here.
[0157] Step 1120, determining the second similarity corresponding to each sentence in each training text based on the core sentence meaning features corresponding to each training text by using the second neural network model to be trained.
[0158] In some embodiments, the second neural network model to be trained can determine the second similarity between each sentence corresponding to each training text based on the core sentence meaning features corresponding to each sentence in each training text.
[0159] Taking two training texts S1 and S2 as examples, the core feature corresponding to the i-th sentence in training text S1 is s 1,i ={s 1,1 ,s 1,2 ,s 1,3 ……s 1,n}, the core feature corresponding to the jth sentence in the training text S2 is s 2,i ={s 2,1 ,s 2,2 ,s 2,3 ……s 2,m}, the second neural network model to be trained can determine the second similarity (such as cosine similarity) between the i-th sentence in the training text S1 and the j-th sentence in the training text S2 based on the core sentence meaning features corresponding to the above sentences.
[0160] Step 1130: Determine a second loss function based on the second similarity corresponding to each sentence and the target similarity corresponding to the plurality of training texts through the second neural network model to be trained.
[0161] In some embodiments, after determining the second similarities between the sentences in the training texts, the second neural network to be trained may determine a second loss function based on the second similarities between the sentences and the target similarity.
[0162] Exemplarily, the second loss function may be determined based on the square of the difference between the second similarity between the sentences and the target similarity between the sentences. In some examples, the second loss function may be determined according to formula (2):
[0163]
[0164] Among them, s 1,i is the i-th sentence in the training text S1, s 2,j is the jth sentence in the training text S2; sim(s 1,i ,s 2,i ) is the target similarity between the i-th sentence in training text S1 and the j-th sentence in training text S2; The second similarity between the i-th sentence in the training text S1 and the j-th sentence in the training text S2 predicted by the second neural network.
[0165] Fig.12 A flowchart of another method for training a similar case retrieval model provided in some embodiments of the present application, such as Fig.12 As shown, the above step 930 may include steps 1210 to 1220.
[0166] Step 1210, determining a predicted label sequence corresponding to each training text based on the semantic features of the words corresponding to each training text through the third neural network model to be trained.
[0167] In some embodiments, the third neural network model to be trained may include a multi-layer Bi-LSTM model and a CRF layer. The third neural network model to be trained may obtain the word semantic features corresponding to each training text determined by the first neural network model to be trained, and perform sequence annotation on different parts of each sentence in each training text based on the word semantic features corresponding to each training text to determine the prediction label sequence corresponding to each training text.
[0168] It can be understood that the manner in which the third neural network model to be trained determines the label information corresponding to each training text can refer to the description of step 430, which will not be repeated here.
[0169] Step 1220: Determine a third loss function through the third neural network model to be trained based on the predicted label sequences and the target label sequences corresponding to the multiple training texts.
[0170] In some embodiments, the third loss function corresponding to the third neural network model to be trained can be determined based on the predicted label sequence and the target label sequence corresponding to the plurality of training texts. In some examples, the third loss function can be determined according to formula (3):
[0171]
[0172] Wherein, L3 is the third loss function corresponding to the CRF layer in the third neural network model to be trained; x is the input training text; y is the target label sequence corresponding to the multiple training texts; is the predicted label sequence corresponding to multiple training texts; t is the label information at position t in the target label sequence, y t+1 is the label information at position t+1 in the target label sequence; To predict the label information at position t in the label sequence, is the label information at position t+1 in the predicted label sequence; T(y t ,y t+1 ) is y t With y t+1 Transfer score between for and Transfer score between .
[0173] Fig.13 A flowchart of another method for training a similar case retrieval model provided in some embodiments of the present application, such as Fig.13 As shown, the above step 940 may include steps 1310 to 1340.
[0174] Step 1310: Determine a plurality of weight items according to the product of the first loss function, the second loss function, and the third loss function, respectively, with each of the plurality of first preset weights.
[0175] In some embodiments, corresponding weights (i.e., first preset weights) may be set for the first loss function, the second loss function, and the third loss function to determine the weights of the overall semantic features, the core sentence features, and the tag sequence in the similarity calculation process. Multiple weight items may be determined based on the product of the first loss function, the second loss function, and the third loss function and the corresponding first preset weights.
[0176] For example, the first preset weight of the first loss function L1 is 1.0, the first preset weight of the second loss function L2 is 0.5, and the first preset weight of the third loss function L3 is 0.3. Then the multiple weight items are: 1.0×L1, 0.5×L2, 0.3×L3.
[0177] Step 1320: Determine multiple interaction terms between the first loss function, the second loss function, and the third loss function based on multiple second preset weights.
[0178] In some embodiments, the above loss functions can also be interactively calculated according to the corresponding weights (i.e., the second preset weights), that is, the first loss function, the second loss function, and the third loss function are interactively calculated according to the corresponding second preset weights to obtain multiple interactive terms. Among them, the above interactive terms can be in various forms, such as multiplying two loss functions, weighted averaging, regularization processing, etc., which is not limited in this embodiment.
[0179] For example, the second preset weight lambda1 of the first loss function L1 is 0.1, the second preset weight lambda2 of the second loss function L2 is 0.05, and the first preset weight lambda3 of the third loss function L3 is 0.01. Then, the multiple interaction terms obtained by multiplying the above loss functions in pairs can be: 0.1×(L1×L2), 0.05×(L1×L3), 0.01×(L2×L3).
[0180] Step 1330, exponentially calculate the first loss function, the second loss function, and the third loss function to obtain a plurality of exponential terms, wherein the plurality of exponential terms include exponential terms corresponding to the first loss function, the second loss function, and the third loss function, respectively.
[0181] In some embodiments, the first loss function, the second loss function and the third loss function may be respectively exponentially calculated to obtain a plurality of exponential terms, wherein the exponential terms are used to introduce penalty terms to enhance the training effect of the similar case retrieval model when the loss is relatively small.
[0182] Exemplarily, the exponential terms corresponding to the first loss function, the second loss function, and the third loss function may be:
[0183]
[0184] Step 1340, determining a target loss function based on multiple weight terms, multiple interaction terms, and multiple exponential terms.
[0185] In some embodiments, after determining the above-mentioned multiple weight terms, multiple interaction terms, and multiple exponential terms, the multiple weight terms, multiple interaction terms, and multiple exponential terms may be added together to determine a final target loss function.
[0186] Exemplarily, the target loss function L can be determined according to formula (4):
[0187]
[0188] In some embodiments, the above method also includes: obtaining multiple words corresponding to each preset window in the training text according to each preset window in multiple preset windows through the fourth neural network model to be trained; wherein the number of characters corresponding to each preset window is different; determining idiomatic sentences in the training text from the multiple words corresponding to each preset window through the fourth neural network model to be trained, and determining prior feature parameters based on the idiomatic sentences in the training text.
[0189] Exemplarily, in addition to determining the target loss function based on the first loss function, the second loss function and the third loss function, the prior feature parameters corresponding to the prior features determined by the fourth neural network model (such as the TFIDF model) after training can also be added. The prior features are the prior features corresponding to the idiomatic sentences, which are used to characterize the semantic features of each idiomatic sentence.
[0190] Exemplarily, when training the fourth neural network model, the fourth neural network model can be allowed to judge and learn prior knowledge through multiple sliding windows. Sliding windows of different sizes correspond to different numbers of characters. The fourth neural network model can determine whether the words in the training text are idiomatic sentences in turn according to the text order and the preset sliding windows.
[0191] For example, the number of characters corresponding to sliding windows of different sizes can be set to 2, 3, 4...10, etc., and the entire training text is screened with a sliding window of 2 characters to determine the idiomatic sentences in the training text; then the entire training text is screened with a sliding window of 3 characters to determine the idiomatic sentences in the training text; and so on, gradually increasing the number of characters until all sliding windows are used to complete the screening of the training text. Thus, the fourth neural network model can complete the judgment and learning of prior knowledge of idiomatic sentences in the training text, that is, obtain the prior features corresponding to the idiomatic sentences. The trained fourth neural network model can identify idiomatic sentences in the preset text based on the prior features corresponding to the idiomatic sentences.
[0192] In some embodiments, the above step 1330 includes: determining multiple weight items according to the product of the first loss function, the second loss function, the third loss function and the prior feature parameter and each of the first preset weights in the multiple first preset weights.
[0193] Exemplarily, when determining the target loss function, the prior features obtained by the fourth neural network model can be used as parameters (i.e., prior feature parameters), and the prior feature parameters are assigned corresponding first preset weights to obtain corresponding weight items. Then, the weight items corresponding to the prior feature parameters are added to the weight items, interaction items, and exponential items corresponding to the above-mentioned loss function to obtain the target loss function.
[0194] For example, taking the first preset weight corresponding to the prior feature parameter C as 0.2 as an example, the target loss function L can be determined according to formula (5):
[0195]
[0196] By applying the technical solution provided by the present application, the characteristic information of each level corresponding to the first question text of the user and the multiple preset texts in the database is determined through multiple neural network models in the similar case retrieval model, including overall semantic features, core semantic features and label information. Based on the characteristic information of each level corresponding to the first question text and the preset texts, the first question text is deeply matched with the preset texts at multiple levels, which can achieve the similarity matching between the user's consulting information and complex legal cases in the legal consulting scenario, and can improve the accuracy of similar case retrieval. In addition, the present application can also identify idiomatic sentences in the preset text through the TFIDF model in the similar case retrieval model, so as to eliminate the influence of idiomatic sentences on similarity matching, so as to further improve the accuracy of similar case retrieval.
[0197] In addition, in the process of training multiple neural network models in the similar case retrieval model, the present application not only optimizes and trains each neural network model individually through the loss function corresponding to each neural network model, but also performs interactive calculations and exponential calculations on the loss functions corresponding to each neural network model, thereby further enhancing the training effect of the similar case retrieval model.
[0198] Fig.14 A schematic diagram of a similar text determination device provided in some embodiments of the present application. Fig.14 As shown, the similar text determination device 1400 can be applied to Figure 1 or Figure 2 The similar case retrieval model shown in FIG. 1400 includes an acquisition module 1410 , a first determination module 1420 , a second determination module 1430 and a third determination module 1440 .
[0199] The acquisition module 1410 is configured to acquire a plurality of preset texts and a first question text input by a user.
[0200] The first determination module 1420 is configured to determine feature information corresponding to each of the plurality of preset texts, and determine feature information corresponding to the first question text.
[0201] Among them, feature information includes overall semantic features, core sentence features and label information.
[0202] The second determination module 1430 is configured to determine the similarity between the first question text and each preset text based on feature information corresponding to each preset text and the first question text.
[0203] The third determination module 1440 is configured to determine and output a target preset text from a plurality of preset texts based on the similarity between the first question text and each preset text.
[0204] In some embodiments, the first determination module 1420 is specifically configured to: determine the overall semantic features and word semantic features corresponding to each preset text; determine the core sentence features corresponding to each preset text based on the overall semantic features corresponding to each preset text; determine the label information corresponding to each preset text based on the word semantic features corresponding to each preset text.
[0205] In some embodiments, the first determination module 1420 is specifically configured to: perform feature extraction on each preset text through the first neural network model, and obtain the first feature extraction result corresponding to each preset text obtained by the first coding layer in the first neural network model, and the second feature extraction result corresponding to each preset text obtained by the second coding layer in the first neural network model; wherein the first neural network model includes multiple coding layers, the multiple coding layers include a first coding layer and a second coding layer, the first coding layer and the second coding layer are different coding layers, and the number of layers of the first coding layer is less than the number of layers of the second coding layer; the first feature extraction result corresponding to each preset text is determined as the word semantic feature corresponding to each preset text, and the second feature extraction result corresponding to each preset text is determined as the overall semantic feature corresponding to each preset text.
[0206] In some embodiments, the first determination module 1420 is specifically configured as follows: dividing the overall semantic features corresponding to each preset text according to sentences through the second neural network model to obtain multiple sentences corresponding to each preset text; determining the non-core words in the multiple sentences corresponding to each preset text through the second neural network model, and adjusting the weights of the non-core words corresponding to each preset text to obtain the core sentence meaning features corresponding to each sentence in the multiple sentences corresponding to each preset text.
[0207] In some embodiments, the first determination module 1420 is specifically configured to: determine the label information corresponding to each sentence in the multiple sentences corresponding to each preset text from multiple preset label information based on the semantic features of the words corresponding to each preset text through a third neural network model; wherein the label information corresponding to each sentence is used to represent the key information corresponding to each sentence.
[0208] like Fig.14 As shown, the similar text determination device 1400 also includes a seventh determination module 1450 .
[0209] In some embodiments, the fourth determination module 1450 is configured to: identify idiomatic sentences in each preset text through a fourth neural network model, and determine the processed preset text according to the idiomatic sentences in each preset text.
[0210] In some embodiments, the second determination module 1430 is specifically configured to determine the similarity between the first question text and the processed preset text based on the overall semantic features, core sentence features and label information corresponding to the processed preset text and the first question text.
[0211] In some embodiments, the third determination module 1440 is specifically configured to: sort multiple preset texts in descending order and obtain a sorting result based on the similarity between the first question text and each preset text; determine the first N preset texts in the sorting result as target preset texts, and output the target preset texts; wherein N is a positive integer.
[0212] like Fig.14 As shown, the similar text determination device 1400 also includes an eighth determination module 1460 .
[0213] In some embodiments, the fifth determination module 1460 is configured to: in the absence of necessary information for calculating similarity in the first question text, determine the text features corresponding to the first question text and the core information corresponding to the first question text through the fifth neural network model, and determine the first event information corresponding to the first question text based on the text features and core information corresponding to the first question text; determine the event determination information based on the first event information through the sixth neural network model, and determine and output the second question text based on the event determination information and the first question text; obtain the reply text input by the user to the second question text, and determine the target question text based on the first question text and the reply text; the first determination module 1420 is specifically configured to: determine the feature information corresponding to the target question text.
[0214] Fig.15 A schematic diagram of a training device for a similar case retrieval model provided in some embodiments of the present application. Fig.15As shown, the training device 1500 of the similar case retrieval model can be applied to Figure 1 or Figure 2 The similar case retrieval model training device 1500 includes a second acquisition module 1510 , a fourth determination module 1520 , a fifth determination module 1530 , a sixth determination module 1540 and an optimization module 1550 .
[0215] The second acquisition module 1510 is configured to acquire a plurality of training texts, and determine target similarities corresponding to the plurality of training texts and target tag sequences corresponding to the plurality of training texts.
[0216] The fourth determination module 1520 is configured to determine a first loss function corresponding to the first neural network model to be trained, and determine a second loss function corresponding to the second neural network model to be trained based on multiple training texts and target similarities corresponding to the multiple training texts.
[0217] The fifth determination module 1530 is configured to determine a third loss function corresponding to a third neural network model to be trained based on multiple training texts and target label sequences corresponding to the multiple training texts.
[0218] The sixth determination module 1540 is configured to determine a target loss function based on the first loss function, the second loss function and the third loss function.
[0219] The optimization module 1550 is configured to optimize the parameters in the first loss function, the second loss function, the third loss function and the target loss function to determine the trained first neural network model, the trained second neural network model and the trained third neural network model.
[0220] In some embodiments, the fourth determination module 1520 is specifically configured to: determine the overall semantic features and word semantic features corresponding to each training text in a plurality of training texts through the first neural network model to be trained; determine the first similarities corresponding to a plurality of training texts based on the overall semantic features corresponding to each training text through the first neural network model to be trained; determine the first loss function based on the first similarities corresponding to a plurality of training texts and the target similarities through the first neural network model to be trained.
[0221] In some embodiments, the fourth determination module 1520 is specifically configured to: determine the core sentence meaning features corresponding to each training text based on the overall semantic features corresponding to each training text through the second neural network model to be trained; determine the second similarity corresponding to each sentence in each training text based on the core sentence meaning features corresponding to each training text through the second neural network model to be trained; determine the second loss function based on the second similarity corresponding to each sentence and the target similarities corresponding to multiple training texts through the second neural network model to be trained.
[0222] In some embodiments, the fourth determination module 1520 is specifically configured to: determine the predicted label sequence corresponding to each training text based on the word semantic features corresponding to each training text through the third neural network model to be trained; determine the third loss function based on the predicted label sequence and target label sequence corresponding to multiple training texts through the third neural network model to be trained.
[0223] In some embodiments, the sixth determination module 1540 is specifically configured to: determine multiple weight items based on the product of the first loss function, the second loss function and the third loss function, respectively, and each of the first preset weights in a plurality of first preset weights; determine multiple interaction items between the first loss function, the second loss function and the third loss function based on the plurality of second preset weights; perform exponential calculations on the first loss function, the second loss function and the third loss function, respectively, to obtain multiple exponential items; wherein the multiple exponential items include exponential items corresponding to the first loss function, the second loss function and the third loss function, respectively; determine the target loss function based on the multiple weight items, the multiple interaction items and the multiple exponential items.
[0224] like Fig.15 As shown, the training device 1500 for the similar case retrieval model also includes a ninth determination module 1560 .
[0225] In some embodiments, the second acquisition module 1510 is further configured to: acquire multiple words corresponding to each preset window in the training text according to each preset window in multiple preset windows through the fourth neural network model to be trained; wherein the number of characters corresponding to each preset window is different; the ninth determination module 1560 is configured to: determine the idiomatic sentences in the training text from the multiple words corresponding to each preset window through the fourth neural network model to be trained, and determine the prior feature parameters based on the idiomatic sentences in the training text; the sixth determination module 1540 is specifically configured to: determine multiple weight items according to the product of the first loss function, the second loss function, the third loss function and the prior feature parameters and each first preset weight in multiple first preset weights.
[0226] Fig.16 A schematic diagram of an electronic device provided for some embodiments of the present application. In some embodiments, the electronic device includes one or more processors and a memory. The memory is configured to store one or more programs. Wherein, when the one or more programs are executed by the one or more processors, the one or more processors implement the method for determining similar texts or the method for training a similar case retrieval model in the above-mentioned embodiments.
[0227] like Fig.16As shown, the electronic device 1600 includes: a processor (processor) 1601 and a memory 1602. Exemplarily, the electronic device 1600 may also include: a communication interface (Communications Interface) 1603 and a communication bus 1604.
[0228] The processor 1601, the memory 1602 and the communication interface 1603 communicate with each other via the communication bus 1604. The communication interface 1603 is used to communicate with other devices such as client or other server network elements.
[0229] In some embodiments, the processor 1601 is used to execute the program 1605, and specifically can execute the relevant steps in the above-mentioned similar text determination method or similar case retrieval model training method embodiment. Specifically, the program 1605 can include program code, and the program code includes computer executable instructions.
[0230] Exemplarily, the processor 1601 may be a central processing unit (CPU), or an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement some embodiments of the present application. The electronic device 1600 may include one or more processors, which may be processors of the same type, such as one or more CPUs; or processors of different types, such as one or more CPUs and one or more ASICs.
[0231] In some embodiments, the memory 1602 is used to store the program 1605. The memory 1602 may include a high-speed RAM memory, and may also include a non-volatile memory (NVM), such as at least one disk memory.
[0232] Program 1605 can be specifically called by processor 1601 to enable electronic device 1600 to execute a method for determining similar texts or a method for training a similar case retrieval model.
[0233] Some embodiments of the present application provide a computer-readable storage medium storing at least one executable instruction. When the executable instruction is executed on the electronic device 1600, the electronic device 1600 executes the method for determining similar texts or the method for training a similar case retrieval model in the above-mentioned embodiments.
[0234] The executable instructions may be specifically used to enable the electronic device 1600 to execute a method for determining similar texts or a method for training a similar case retrieval model.
[0235] For example, the computer readable storage medium may be a read-only memory (ROM), a random access memory (RAM), a compact disc (CD-ROM), a magnetic tape, a floppy disk, an optical data storage device, and the like.
[0236] The beneficial effects that can be achieved by the computer-readable storage medium provided in some embodiments of the present application can be referred to the beneficial effects of the corresponding similar text determination method or the similar case retrieval model training method provided above, and will not be repeated here.
[0237] It should be noted that, in the application, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including 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, the elements defined by the sentence "including a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0238] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0239] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as an ordered list of executable instructions for implementing logical functions, which can be embodied in any computer-readable medium for use by an instruction execution system, apparatus or device (such as a computer-based system, a system including a processor or other system that can fetch instructions from an instruction execution system, apparatus or device and execute instructions), or used in combination with these instruction execution systems, apparatuses or devices.
[0240] For the purposes of this specification, a "computer-readable medium" can be any apparatus that can contain, store, communicate, propagate, or transport the program for use by an instruction execution system, apparatus, or device or in conjunction with such instruction execution system, apparatus, or device.
[0241] More specific examples (a non-exhaustive list) of computer-readable media include the following: an electrical connection having one or more wires (electronic device), a portable computer disk case (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), a fiber optic device, and a portable compact disk read-only memory (CDROM).
[0242] In addition, the computer readable medium can even be a paper or other suitable medium on which the program can be printed, because the program can be obtained electronically, for example, by optically scanning the paper or other medium, and then editing, interpreting or processing in other suitable ways as necessary, and then storing it in the computer memory. It should be understood that various parts of the present application can be implemented in hardware, software, firmware or a combination thereof.
[0243] In the above embodiments, multiple steps or methods may be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it may be implemented by any one of the following technologies known in the art or a combination thereof: a discrete logic circuit having a logic gate circuit for implementing a logic function on a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0244] The above-described embodiments of the present application do not constitute a limitation on the protection scope of the present application.
Claims
1. A method for determining similar texts, characterized in that: include: Acquire multiple preset texts and a first question text input by a user; Determine feature information corresponding to each of the plurality of preset texts, and determine feature information corresponding to the first question text; wherein the feature information includes overall semantic features, core sentence features, and label information; Determining the similarity between the first question text and each of the preset texts based on feature information corresponding to each of the preset texts and the first question text; Based on the similarity between the first question text and each of the preset texts, a target preset text is determined and output from the plurality of preset texts.
2. The method according to claim 1, characterized in that The determining of the characteristic information corresponding to each of the plurality of preset texts includes: Determine the overall semantic features and word semantic features corresponding to each of the preset texts; Determining the core sentence features corresponding to each of the preset texts based on the overall semantic features corresponding to each of the preset texts; Based on the semantic features of the words corresponding to each of the preset texts, the label information corresponding to each of the preset texts is determined.
3. The method according to claim 2, characterized in that The determining of the overall semantic features and word semantic features corresponding to each of the preset texts includes: Performing feature extraction on each of the preset texts through a first neural network model, and obtaining a first feature extraction result corresponding to each of the preset texts obtained by a first coding layer in the first neural network model, and a second feature extraction result corresponding to each of the preset texts obtained by a second coding layer in the first neural network model; wherein the first neural network model includes a plurality of coding layers, the plurality of coding layers include the first coding layer and the second coding layer, the first coding layer and the second coding layer are different coding layers, and the number of layers of the first coding layer is less than the number of layers of the second coding layer; The first feature extraction result corresponding to each of the preset texts is determined as the word semantic feature corresponding to each of the preset texts, and the second feature extraction result corresponding to each of the preset texts is determined as the overall semantic feature corresponding to each of the preset texts.
4. The method according to claim 2, characterized in that: The determining of the core sentence features corresponding to each of the preset texts based on the overall semantic features corresponding to each of the preset texts includes: The overall semantic features corresponding to each of the preset texts are divided into sentences by a second neural network model to obtain a plurality of sentences corresponding to each of the preset texts; The non-core words in the multiple sentences corresponding to each of the preset texts are determined by the second neural network model, and the weights of the non-core words corresponding to each of the preset texts are adjusted to obtain the core sentence meaning features corresponding to each of the multiple sentences corresponding to each of the preset texts.
5. The method according to claim 2, characterized in that: The step of determining the label information corresponding to each of the preset texts based on the semantic features of the words corresponding to each of the preset texts includes: Based on the semantic features of the words corresponding to each of the preset texts, the third neural network model determines the label information corresponding to each of the multiple sentences corresponding to each of the preset texts from multiple preset label information; wherein the label information corresponding to each of the sentences is used to represent the key information corresponding to each of the sentences.
6. The method according to any one of claims 1 to 5, characterized in that The method further comprises: Identifying idiomatic sentences in each of the preset texts by using a fourth neural network model, and determining processed preset texts according to the idiomatic sentences in each of the preset texts; The determining the similarity between the first question text and each of the preset texts based on the feature information corresponding to each of the preset texts and the first question text includes: Based on the overall semantic features, core sentence meaning features and label information corresponding to the processed preset text and the first question text, the similarity between the first question text and the processed preset text is determined.
7. The method according to any one of claims 1 to 5, characterized in that The determining and outputting a target preset text from the plurality of preset texts based on the similarity between the first question text and each of the preset texts includes: According to the similarity between the first question text and each of the preset texts, the plurality of preset texts are sorted in descending order to obtain a sorting result; The first N preset texts in the sorting result are determined as the target preset texts, and the target preset texts are output; wherein N is a positive integer.
8. The method according to any one of claims 1 to 5, characterized in that The method further comprises: In the case where the first question text lacks necessary information for calculating the similarity, determining text features corresponding to the first question text and core information corresponding to the first question text through a fifth neural network model, and determining first event information corresponding to the first question text based on the text features and core information corresponding to the first question text; Determine event determination information based on the first event information through a sixth neural network model, and determine and output a second question text based on the event determination information and the first question text; Acquire a reply text input by the user to the second question text, and determine a target question text based on the first question text and the reply text; The determining of feature information corresponding to the first question text includes: Determine feature information corresponding to the target question text.
9. A method for training a similar case retrieval model, characterized in that: The similar case retrieval model includes a first neural network model, a second neural network model and a third neural network model, and the method includes: Acquire multiple training texts, and determine target similarities corresponding to the multiple training texts and target label sequences corresponding to the multiple training texts; Based on the multiple training texts and the target similarities corresponding to the multiple training texts, determining a first loss function corresponding to the first neural network model to be trained, and determining a second loss function corresponding to the second neural network model to be trained; Determining a third loss function corresponding to a third neural network model to be trained based on the multiple training texts and target label sequences corresponding to the multiple training texts; Determine a target loss function based on the first loss function, the second loss function and the third loss function; Optimize the parameters in the first loss function, the second loss function, the third loss function and the target loss function to determine a trained first neural network model, a trained second neural network model and a trained third neural network model.
10. The method according to claim 9, characterized in that The determining, based on the plurality of training texts and the target similarities corresponding to the plurality of training texts, a first loss function corresponding to the first neural network model to be trained comprises: Determine the overall semantic features and word semantic features corresponding to each of the plurality of training texts by using the first neural network model to be trained; Determining, by means of the first neural network model to be trained, a first similarity corresponding to the plurality of training texts based on the overall semantic features corresponding to each of the training texts; The first loss function is determined by the first neural network model to be trained based on the first similarities corresponding to the multiple training texts and the target similarities.
11. The method according to claim 10, characterized in that Determining a second loss function corresponding to a second neural network model to be trained based on the plurality of training texts and target similarities corresponding to the plurality of training texts includes: Determining the core sentence features corresponding to each of the training texts based on the overall semantic features corresponding to each of the training texts by using the second neural network model to be trained; Determining, by the second neural network model to be trained, a second similarity corresponding to each sentence in each of the training texts based on the core sentence meaning features corresponding to each of the training texts; The second loss function is determined by the second neural network model to be trained based on the second similarities corresponding to the sentences and the target similarities corresponding to the multiple training texts.
12. The method according to claim 10, characterized in that The determining, based on the plurality of training texts and the target label sequences corresponding to the plurality of training texts, a third loss function corresponding to the third neural network model to be trained comprises: Determine, by means of the third neural network model to be trained, a prediction label sequence corresponding to each of the training texts based on the semantic features of the words corresponding to each of the training texts; The third loss function is determined by the third neural network model to be trained based on the predicted label sequence and the target label sequence corresponding to the multiple training texts.
13. The method according to claim 9, characterized in that The determining of a target loss function based on the first loss function, the second loss function, and the third loss function comprises: Determine a plurality of weight items according to the product of each of the first preset weights and the first loss function, the second loss function and the third loss function; Determining a plurality of interaction terms between the first loss function, the second loss function, and the third loss function based on a plurality of second preset weights; Performing exponential calculations on the first loss function, the second loss function, and the third loss function, respectively, to obtain a plurality of exponential terms; wherein the plurality of exponential terms include exponential terms corresponding to the first loss function, the second loss function, and the third loss function, respectively; A target loss function is determined based on the multiple weight terms, the multiple interaction terms, and the multiple exponential terms.
14. The method according to claim 13, characterized in that The method further comprises: Acquire, by a fourth neural network model to be trained, a plurality of words corresponding to each of the plurality of preset windows in the training text according to each of the plurality of preset windows; wherein the number of characters corresponding to each of the preset windows is different; Determining idiomatic sentences in the training text from a plurality of words corresponding to each of the preset windows by using the fourth neural network model to be trained, and determining prior feature parameters according to the idiomatic sentences in the training text; The determining of a plurality of weight items according to the product of each of the first preset weights in a plurality of first preset weights by the first loss function, the second loss function and the third loss function respectively comprises: The multiple weight items are determined according to the products of the first loss function, the second loss function, the third loss function and the priori feature parameter and each of the first preset weights in the multiple first preset weights.
15. A device for determining similar texts, characterized in that: include: A first acquisition module is configured to acquire a plurality of preset texts and a first question text input by a user; A first determination module is configured to determine feature information corresponding to each of the plurality of preset texts, and determine feature information corresponding to the first question text; wherein the feature information includes overall semantic features, core sentence features and label information; A second determination module is configured to determine the similarity between the first question text and each of the preset texts based on feature information corresponding to each of the preset texts and the first question text; The third determination module is configured to determine and output a target preset text from the plurality of preset texts based on the similarity between the first question text and each of the preset texts.
16. A training device for a similar case retrieval model, characterized in that: The similar case retrieval model includes a first neural network model, a second neural network model and a third neural network model, and the device includes: A second acquisition module is configured to acquire a plurality of training texts and determine target similarities corresponding to the plurality of training texts and target tag sequences corresponding to the plurality of training texts; A fourth determination module is configured to determine a first loss function corresponding to the first neural network model to be trained, and determine a second loss function corresponding to the second neural network model to be trained based on the multiple training texts and the target similarities corresponding to the multiple training texts; A fifth determination module is configured to determine a third loss function corresponding to a third neural network model to be trained based on the multiple training texts and target label sequences corresponding to the multiple training texts; a sixth determination module, configured to determine a target loss function based on the first loss function, the second loss function and the third loss function; An optimization module is configured to optimize the parameters in the first loss function, the second loss function, the third loss function and the target loss function to determine the trained first neural network model, the trained second neural network model and the trained third neural network model.
17. An electronic device, characterized in that: include: one or more processors; and A memory configured to: store one or more programs; Wherein, when the one or more programs are executed by the one or more processors, the one or more processors implement the method for determining similar text according to any one of claims 1-8, or implement the training method for a similar case retrieval model according to any one of claims 9-14.
18. A computer-readable storage medium, characterized in that: A computer program is stored thereon, and when the computer program is executed by a processor, the method for determining similar text according to any one of claims 1-8 is implemented, or the method for training a similar case retrieval model according to any one of claims 9-14 is implemented.
Citation Information
Patent Citations
Sentence meaning mathematical space representation method and system, medium and equipment
CN110688446A
Class case recommendation method based on semantic similarity
CN113688635A
Class case retrieval method, system and equipment based on Xlnet model
CN114490946A
Class case semantic retrieval method and system, electronic equipment and storage medium
CN116361414A