Similar case recommendation method and related device

By performing module extraction and structured processing of the case text entered by the user, vectorized representation is generated, which solves the shortcomings of traditional text matching technology in case recommendations and achieves more efficient and accurate case recommendations.

CN114398474BActive Publication Date: 2025-02-25IFLYTEK CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111592766.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-23
Publication Date
2025-02-25
Estimated Expiration
2041-12-23

AI Technical Summary

Technical Problem

In the case recommendation scenario of a similar case, the case facts entered by the user are as high as several hundred words, while the average number of words in the historical cases in the case database is over thousands. The traditional text matching technology is not suitable and it is difficult to achieve effective matching.

Method used

By module extraction of the case text entered by the user, structured case text is constructed and converted into vectorized representations, so that similar historical cases are found in the case database.

Benefits of technology

This method does not require users to label the case elements, which reduces the workload and calculation amount, and improves the accuracy of recommended results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114398474B_ABST
    Figure CN114398474B_ABST
Patent Text Reader

Abstract

The present application discloses a method for recommending similar cases and related devices, the method for recommending similar cases comprising: obtaining a case text input by a user, and performing module extraction on the case text to obtain all modules contained in the case text and the module content of each module; determining the association relationship between the modules based on the module content of all the modules in the case text to construct the structured case text; obtaining a vectorized representation of each module in the structured case text, and obtaining historical cases similar to the case text from a case database based on the vectorized representation. In the above manner, the present application can parse the case text input by the user into a unified structured representation to obtain better recommendation results.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of text processing technology, and specifically relates to a similar case recommendation method and related devices. Background Art

[0002] Similar case recommendation means that the user inputs a sentence, a paragraph or even several paragraphs of case facts, and the similar case recommendation system matches it with the massive historical cases in the case database, returns several historical cases with high similarity, and displays them to the user in order of similarity from large to small.

[0003] From a technical perspective, similar case recommendation is essentially a text matching task. The core difficulty lies in the fact that the case facts entered by the user are sometimes as long as several hundred words, while the average number of words in the historical cases in the case database is as high as thousands. Traditional text matching technology solutions are not suitable for similar case recommendation scenarios. Summary of the invention

[0004] The present application provides a similar case recommendation method and related devices, which can parse the case text input by the user into a unified structured representation to obtain better recommendation results.

[0005] In order to solve the above technical problems, a technical solution adopted in the present application is: to provide a similar case recommendation method, including: obtaining a case text input by a user, and performing module extraction on the case text to obtain all modules contained in the case text and the module content of each module; determining the association relationship between the modules based on the module content of all the modules in the case text to construct a structured case text; obtaining a vectorized representation of each module in the structured case text, and obtaining historical cases similar to the case text from a case database based on the vectorized representation.

[0006] In order to solve the above technical problems, another technical solution adopted in the present application is: to provide a similar case recommendation device, including: an extraction module, used to obtain the case text input by the user, and perform module extraction on the case text to obtain all modules contained in the case text and the module content of each module; an association module, connected to the extraction module, used to determine the association relationship between the modules based on the module content of all the modules in the case text to construct the structured case text; a first acquisition module, connected to the association module, used to obtain the vectorized representation of each module in the structured case text; a second acquisition module, connected to the first acquisition module, used to obtain historical cases similar to the case text from the case database based on the vectorized representation.

[0007] In order to solve the above technical problems, another technical solution adopted in the present application is: to provide an electronic device, including a memory and a processor coupled to each other, wherein the memory stores program instructions, and the processor is used to execute the program instructions to implement the similar case recommendation method described in any of the above embodiments.

[0008] In order to solve the above technical problems, another technical solution adopted by the present application is: providing a storage device storing program instructions that can be executed by a processor, wherein the program instructions are used to implement the similar case recommendation method described in any of the above embodiments.

[0009] Different from the prior art, the beneficial effects of the present application are as follows: the case text input by the user is first modularly parsed in the similar case recommendation method provided by the present application to construct a structured case text; after obtaining the structured case text, the vectorized representation of each module is parsed, and based on the vectorized representation of each module, historical cases similar to the case text are obtained from the case database for user reference. This method does not require the user to define the element labels of each case separately, and its workload and calculation amount are relatively small; and in the similarity calculation process, the corresponding vectorized representation is obtained for each module, and its accuracy is higher than that of the entire text matching method. BRIEF DESCRIPTION OF THE DRAWINGS

[0010] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work, among which:

[0011] Figure 1 A flowchart of a method for implementing a similar case to this application;

[0012] Figure 2 for Figure 1 A schematic diagram of a flow chart of an implementation method before step S101;

[0013] Figure 3 This is a schematic diagram of the structure of a case document;

[0014] Figure 4 for Figure 2 A schematic diagram of a flow chart of an implementation method corresponding to step S202;

[0015] Figure 5 It is a structural schematic diagram of an implementation scheme of a module extraction model extraction scheme;

[0016] Figure 6 for Figure 2A schematic diagram of a flow chart of an implementation method corresponding to step S203;

[0017] Figure 7 It is a structural schematic diagram of an implementation scheme of a module association model association scheme;

[0018] Figure 8 for Figure 1 A schematic diagram of a flow chart of an implementation method corresponding to step S105;

[0019] Fig. 9 This is a structural schematic diagram of an implementation method of a device recommended for similar cases of this application;

[0020] Fig.10 This is a schematic diagram of the structure of an embodiment of an electronic device of the present application;

[0021] Fig.11 This is a schematic structural diagram of an implementation of a storage device of the present application. DETAILED DESCRIPTION

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

[0023] See also Figure 1 , Figure 1 This is a flowchart of an implementation method of a similar case recommendation method of the present application. The similar case recommendation method specifically includes:

[0024] S101: Obtain the case text input by the user.

[0025] Specifically, the case text input by the user can be a sentence or a paragraph, and this application does not limit the length of the case text input by the user. The case text input by the user has different fields, and the corresponding case databases are different, and the model parameters used are different. As long as the case text input by the user and the historical cases in the corresponding case database can be parsed into the common structure of the corresponding field, they fall within the coverage of the similar case recommendation method in this application.

[0026] In one embodiment, before the above step S101, a process of building a case database may also be included. For details, please refer to Figure 2 , Figure 2 for Figure 1 The flowchart of an implementation method before step S101 in FIG. 1 is a flowchart of an implementation method before step S101. The specific process of building the case database includes:

[0027] S201: Obtain case documents to be stored.

[0028] Specifically, the field to which the case document to be stored belongs may be the same as the field to which the case text input by the user in step S101 belongs.

[0029] S202: Extract modules from the case documents to be stored in the database to obtain all modules contained in the case documents to be stored in the database and the module content of each module.

[0030] Specifically, case documents to be stored are generally written by writers in the relevant field in accordance with certain logical specifications. The main purpose of steps S202 to subsequent steps S203 of this application is to structure the case documents to be stored, explore the writing ideas of the writers, and convert the internal logic of the case documents to be stored into a form that can be understood by computers.

[0031] For example, Figure 3 As shown, Figure 3 This is a structural diagram of a case document. Figure 3 In the process of structuring the case documents shown in the figure, special consideration was given to their versatility. Figure 3 It can be seen that the logical chain of writing the case document is: through the evidence in hand, it is determined that a person has a certain reward or punishment fact, and if the determined reward or punishment fact meets the circumstances stipulated in certain clauses, then according to the provisions of the clauses, it is determined that a person has committed a certain behavior name and given corresponding reward or punishment measures. A case document may involve multiple reward or punishment persons, and a reward or punishment person may involve multiple behavior names and reward or punishment facts. Figure 3 It only shows two different rewarders and multiple reward and punishment facts and names of behaviors, which can be further expanded according to the actual situation. In addition to this logical chain, the case document will also respond and make decisions on controversial evidence facts or clause application issues. Therefore, in summary, under normal circumstances, the modules in a case document can include name, behavior name, basis clause, reward and punishment facts, evidence, reward and punishment measures, circumstances, dispute focus and ruling results.

[0032] In an application scenario, see Figure 4 , Figure 4 for Figure 2 The flowchart of an implementation method corresponding to step S202 in FIG. 1 is a flowchart of an implementation method corresponding to step S202 in FIG. 1 , and the specific implementation process of the above step S202 may include:

[0033] S301: Obtain all modules related to the field of the case document to be stored.

[0034] For example, Figure 3 As shown, all modules related to the field of the case document to be stored may include name, name of the behavior, basis clause, reward and punishment facts, evidence, reward and punishment measures, circumstances, focus of the dispute and ruling results.

[0035] S302: For each module, the name of the module and the case documents to be stored are input into the trained module extraction model to obtain the module content of each module in the case documents to be stored.

[0036] Specifically, Figure 5 As shown, Figure 5 It is a structural diagram of an implementation scheme of a module extraction model extraction scheme. The module extraction model 10 includes a first pre-trained model 100 and two first fully connected layers 102; wherein, the first pre-trained model 100 can be a common BERT model, etc.; and the output of the first pre-trained model 100 is respectively connected to the input of the two first fully connected layers 102. For example, the name of the module to be extracted (such as the basis clauses, reward and punishment facts and evidence, etc.) and the content of the case document to be stored are first concatenated, and sent to the first pre-trained model 100 to obtain the hidden layer representation, and the hidden layer representation passes through the two first fully connected layers 102 respectively to predict the starting position and the ending position of the module content of the current module to be extracted; wherein, the text content between the adjacent starting position and the ending position is the module content predicted by the module extraction model 10.

[0037] Optionally, when the first pre-trained model 100 is a BERT model, since the input characters of the BERT model must be less than or equal to 512 characters, when the characters of the case documents to be stored exceed this limit, a sliding window technology can be introduced; that is, the case documents to be stored are split to form multiple sub-documents, and adjacent sub-documents may not overlap at all or may have overlapping parts, which is not limited in this application. The module name to be extracted and the multiple sub-documents can be spliced ​​separately, and after splicing, they enter the module extraction model 10 to obtain the corresponding starting position and end position.

[0038] In an application scenario, the process of training the module extraction model 10 includes:

[0039] A. Construct a first training set; wherein the first training set includes multiple first training texts, and the first training texts are in the same field as the case texts, and the first training texts are marked with location labels of various modules.

[0040] Optionally, the first training set may include a large number of manually annotated case documents in a certain field, and the starting position and the ending position of each module in each case document may be manually annotated in advance.

[0041] B. Input the name of any module and the first training text into the first pre-trained model 100 to obtain the hidden layer representation.

[0042] C. Inputting the hidden layer representation into the two first fully connected layers 102 respectively to obtain the predicted starting position and the predicted ending position of the module in the first training text respectively;

[0043] D. Adjust the parameters of module extraction model 10 based on the predicted starting position, predicted ending position and position label associated with the same module.

[0044] Optionally, in this embodiment, the predicted module content can be obtained based on the predicted starting position and the predicted ending position related to the same module, and the actual module content can be obtained based on the position label; the cross-entropy loss is obtained based on the predicted module content and the actual module content; and the parameters in the module extraction model 10 (including the first pre-trained model 100 and the first fully connected layer 102) are adjusted based on the cross-entropy loss.

[0045] S203: Determine the association relationship between modules based on the module contents of all modules of the case documents to be stored, so as to construct a structured case document to be stored.

[0046] Specifically, after extracting the predefined modules in the case documents to be stored, the next step is to associate the different modules. The first step in executing module association is to determine the module pairs that need to be associated. For example, for multiple reward and punishment facts and multiple behavior names that appear in a case document, it is necessary to specifically determine which behavior name each reward and punishment fact belongs to.

[0047] In one embodiment, see Figure 6 , Figure 6 for Figure 2 The flowchart of an implementation method corresponding to step S203 in FIG. 1 is a flowchart of an implementation method corresponding to step S203 in FIG. 1 , wherein step S203 specifically includes:

[0048] S401: Obtain module pairs formed by all modules in the case documents to be stored; wherein each module pair includes two modules.

[0049] Optionally, in this embodiment, the module pairs that need to be associated can be manually determined in advance. Figure 3 In this embodiment, it is not necessary to strictly follow Figure 3 To construct module pairs based on the relationship between modules in the structure tree shown in the figure, we can make equivalent modifications from the perspective of reducing the difficulty of the task. Figure 3 As shown, the reward and punishment facts and the basis clauses need to be associated, but this application actually associates the reward and punishment facts with the behavior name and name, and the basis clauses are also associated with the behavior name and name. In this way, we know that when the reward and punishment facts and the basis clauses are associated with the same behavior name and name, they are also associated. Therefore, in order to construct Figure 3In the structured judgment shown, the applicant has pre-determined the following module pairs that need to be associated: evidence-reward and punishment facts; reward and punishment facts-behavior name; reward and punishment facts-name; basis clause-behavior name; basis clause-name; reward and punishment measures-behavior name; reward and punishment measures-name; behavior name-name; personal information-name; circumstances-name; circumstances-basis clause; dispute focus-name; dispute focus-judgment result. For other module pairs, such as evidence-name, their association relationship is not important, so there is no need to judge the size of their association probability.

[0050] S402: For each module pair, the module contents of the two modules in the module pair are input into the trained module association model to obtain the association probability between the two modules in the current module pair.

[0051] Specifically, see Figure 7 , Figure 7 The schematic diagram of the structure of the first embodiment of the module association model association scheme. The module association model 20 includes a second pre-trained model 200, two second fully connected layers 202 and two self-attention layers 204; and the output of the second pre-trained model 200 is respectively connected to the input of the two second fully connected layers 202, and the output of one second fully connected layer 202 is connected to the input of one self-attention layer 204. Optionally, the second pre-trained model 200 can be a BERT model, etc. The structure of the above module association model 20 is relatively simple.

[0052] In an application scenario, the process of training the module association model 20 includes:

[0053] A. Construct a second training set; wherein the second training set includes multiple second training texts, and the second training texts are in the same field as the case text input by the user, and the second training texts are annotated with actual association probabilities of module contents of each module pair contained therein; wherein the actual association probability is 1 or 0.

[0054] Specifically, the modules in the first training text can be combined according to the artificially predefined module pairs to construct the second training text. For example, taking the evidence-reward and punishment fact module pair as an example, a case document includes two people, Zhang San and Li Si. Zhang San has evidence 1 corresponding to reward and punishment fact 1, evidence 2 corresponding to reward and punishment fact 2, and Li Si has evidence 3 corresponding to reward and punishment fact 3. Then there are 9 combinations of evidence-reward and punishment fact module pairs, but only 3 combinations are correct combinations, and their association probability is 1; the other 6 are wrong combinations, and their association probability is 0. Please note that the 9 association combinations here are the association combinations of the original sentences of the judgment corresponding to the evidence and the original sentences of the judgment corresponding to the reward and punishment facts. That is, the second training sample is the association between the two sentences and their association probability.

[0055] B. Input the module contents of the two modules in the same module pair in the second training text into the second pre-training model 200 to obtain the first hidden layer representation and the second hidden layer representation respectively.

[0056] C. Pass the first hidden layer representation through one of the second fully connected layers 202 and one of the self-attention layers 204 to obtain a first module representation, and pass the second hidden layer representation through another second fully connected layer 202 and another self-attention layer 204 to obtain a second module representation.

[0057] Optionally, the formula of the self-attention layer 204 is: H1 = ∑ i α i *h i ; H2=∑ j α j *h j ; Among them, the self-attention coefficient α i =softmax(FFN(h i )), α j =softmax(FFN(h j )); H1 represents the first module, h i represents each character in one module; H2 represents the second module, j Represents individual characters in another module.

[0058] D. Obtain the predicted association probability based on the first module representation and the second module representation.

[0059] Optionally, the first module representation and the second module representation may be dot-multiplied to obtain the predicted association probability.

[0060] E. Adjusting parameters in the module association model 20 based on the predicted association probability and the actual association probability.

[0061] Optionally, a cross entropy loss between the predicted association probability and the actual association probability can be obtained, and parameters in the module association model 20 (including the second pre-trained model 200, the second fully connected layer 202, and the self-attention layer 204) are adjusted based on the cross entropy loss.

[0062] The above-mentioned method of training module association model 20 is relatively mature and easy to implement.

[0063] In addition, in order to incorporate more information, so that the module association model 20 knows the content that the user is concerned about and improve the model training effect, the setting method of segment_id is introduced in the second pre-trained model 200. Specifically, when the module contents of two modules in the same module pair in the second training text are input into the second pre-trained model 200, the first module element in the module content of one of the modules is marked as 1, and the remaining characters other than the first module element in the module content of one of the modules are marked as 0; and the second module element in the module content of the other module is marked as 0, and the remaining characters other than the second module element in the module content of the other module are marked as 1. For example, Figure 7 As shown in FIG. 1 , when the name of one of the modules is name, and the corresponding module content is “name XX, male…”, the first module element in the module content can be regarded as the name entity content (such as Figure 7 In the example, if "XX" is a reward or punishment fact, then "XX" can be marked as 1, and "name" and "male..." can be marked as 0; when the name of another module is reward or punishment facts, and its corresponding module content is "...XX took out XX...", the second module element in the module content can be regarded as the reward or punishment fact entity content (such as Figure 7 In the above example, if XX is taken out from the box, then “XX is taken out from the box” can be marked as 0, and the remaining “…” can be marked as 1.

[0064] S403: Determine that two modules in a module pair whose association probability exceeds a threshold have an association relationship.

[0065] Optionally, the threshold may be 1 or 0.8, etc., which may be set according to actual conditions.

[0066] At this point, the case documents to be stored can be structured.

[0067] S204: Obtain the vectorized representation of each module in the structured case document to be stored, and store it in the case database.

[0068] Optionally, in order to speed up the subsequent search from massive cases, the above step of storing it in the database also includes: constructing a nearest neighbor search index for each vectorized representation of each module in each case document to be stored.

[0069] Alternatively, the process of obtaining the vectorized representation of each module in the structured case document to be stored can be: obtaining each word vector in the module content of each module in the structured case document to be stored; and performing weighted average on all word vectors to obtain the vectorized representation. Alternatively, the module content of each module in the structured case document to be stored is respectively input into the trained third pre-trained model to obtain the corresponding vectorized representation. In this embodiment, the third pre-trained model can be a BERT model.

[0070] At this point, the case database can be constructed through the above steps. In the subsequent application process, the vectorized representation of each module of the historical case can be directly obtained from the case database to reduce the amount of system calculation during the application process and improve the efficiency of similar case recommendation.

[0071] S102: Perform module extraction on the case text input by the user to obtain all modules contained in the case text and the module content of each module.

[0072] Specifically, the implementation process of the above step S102 may be: A. Obtain all modules related to the field of the case text. For example, all modules related to the field of the case text may include Figure 3 The name, name of the behavior, basis clause, reward and punishment facts, evidence, reward and punishment measures, circumstances, dispute focus and ruling results shown in B. For each module, the name of the module and the case text are input into the trained module extraction model to obtain the module content of the module. The implementation process of step B is similar to that of step S202 above, and will not be described in detail here.

[0073] S103: Determine the association relationship between modules based on the module contents of all modules of the case text to construct a structured case text.

[0074] Specifically, the specific implementation process of the above step S103 includes: A. Obtaining module pairs formed by all modules in the case text; wherein each module pair contains two modules. Figure 3It can be seen from the relevant content that the module pairs that can be formed in the field to which the current case text belongs include: evidence and reward and punishment facts, reward and punishment facts and behavior names, reward and punishment facts and names, basis clauses and behavior names, basis clauses and names, reward and punishment measures and behavior names, reward and punishment measures and names, behavior names and names, personal information and names, circumstances and names, circumstances and basis clauses, focus of disputes and names, and focus of disputes and ruling results. After obtaining the various modules in the current case text through step S102, the various modules in the current case text can be combined according to the preset module pair composition method, and the combined module pairs are sent to the subsequent step B to obtain the association probability of each module pair. B. For each module pair, the module contents of the two modules in the module pair are input into the trained module association model to obtain the association probability between the two modules in the current module pair. Optionally, this step is similar to the above-mentioned step S402 and will not be repeated here. C. The two modules in the module pair whose association probability exceeds the threshold are determined to have an association relationship.

[0075] S104: Obtain vectorized representation of each module in the structured case text.

[0076] Optionally, the specific implementation process of the above step S104 can be: obtaining each word vector in the module content of each module in the structured case text; and performing weighted average on all word vectors to obtain a vectorized representation; or, inputting the module content of each module in the structured case text into the trained third pre-trained model to obtain a corresponding vectorized representation. The above process of obtaining a vectorized representation is relatively mature and easy to implement.

[0077] S105: Obtain historical cases similar to the case text from the case database based on the vectorized representation of each module.

[0078] See also Figure 8 , Figure 8 for Figure 1 The specific implementation process of the above step S105 can be:

[0079] S501: For each historical case in the case database, obtain a first similarity between the vectorized representation of each module in the case text and the vectorized representation of the same module in the historical case.

[0080] Optionally, in this embodiment, the first similarity of two modules is defined as the cosine similarity between their vectorized representations. For example, if the module in the case text includes reward and punishment facts, the first similarity between the vectorized representations of the reward and punishment facts in the case text and the reward and punishment facts in each historical case can be obtained.

[0081] S502: Obtain the overall similarity between the historical case and the case text according to the first sum of the first similarities of each module in the case text.

[0082] Optionally, in this embodiment, the overall similarity is equal to the first sum value.

[0083] Alternatively, as shown in the following embodiment: the case text input by the user includes: Name xxx picked up a wallet on the bus. Historical case A in the case database: Name xx picked up a wallet on the bus. Historical case B in the case database: Name xxx picked up a wallet on bus No. 5; Name xxx picked up a mobile phone on bus No. 31. Through comparison, it is found that historical case A is more worthy of recommendation because it has only one reward and punishment fact, and is similar to the reward and punishment facts input by the user, so it is more likely to have similar judgment results; and the similarity of historical case B should be ranked after historical case A, because although historical case B also has a very similar "picking up a wallet on the bus" behavior, it has another reward and punishment fact of "picking up a mobile phone on the bus", which is inconsistent with the reward and punishment facts input by the user. In order to consider this factor, we can structure the historical cases and the case texts input by the user, and then penalize the similarity of historical cases with different numbers of reward and punishment fact modules input, so as to obtain better sorting results.

[0084] The specific implementation process may be: before the above step S502, including: obtaining the first number of each module in the case text and the second number of each module in the historical case; obtaining the second similarity value according to the first number and the second number of the same module; wherein the greater the difference between the first number and the second number of the same module, the smaller the second similarity value. The above step S502 specifically includes: taking the sum of the first sum of the first similarities of each module in the case text and the second similarity value as the overall similarity.

[0085] S503: Sort all historical cases in the case database from high to low according to the overall similarity, and output some historical cases with higher overall similarity.

[0086] Optionally, in this embodiment, 10 or 50 historical cases with relatively high overall similarity may be output for user reference according to actual needs.

[0087] See also Fig. 9 , Fig. 9This is a structural diagram of an embodiment of a similar case recommendation device of the present application, and the similar case recommendation device includes an extraction module 30, an association module 32, a first acquisition module 34 and a second acquisition module 36. Among them, the extraction module 30 is used to obtain the case text input by the user, and perform module extraction on the case text to obtain all modules contained in the case text and the module content of each module. The association module 32 is connected to the extraction module 30, and is used to determine the association relationship between modules based on the module content of all modules in the case text to construct a structured case text. The first acquisition module 34 is connected to the association module 32, and is used to obtain the vectorized representation of each module in the structured case text. The second acquisition module 36 is connected to the first acquisition module 34, and is used to obtain historical cases similar to the case text from the case database based on the vectorized representation.

[0088] Optionally, the extraction module 30 is specifically used to obtain all modules related to the field of the case text; for each module, the name of the module and the case text are input into the trained module extraction model to obtain the module content of the module.

[0089] Wherein, the module extraction model includes a first pre-trained model and two first fully connected layers; and the output of the first pre-trained model is respectively connected to the input of the two first fully connected layers. The above-mentioned similar case recommendation device also includes a first training module, which is connected to the extraction module 30 and is used to train the module extraction model; wherein, the process of training the module extraction module includes: constructing a first training set; wherein the first training set contains multiple first training texts, and the first training texts are in the same field as the case texts, and the first training texts are marked with the position labels of each module; the name of any module and the first training text are input into the first pre-trained model to obtain the hidden layer representation; after the hidden layer representation is respectively input into the two first fully connected layers, the predicted starting position and predicted ending position of the module in the first training text are respectively obtained; the parameters of the module extraction model are adjusted based on the predicted starting position, predicted ending position and position label related to the same module.

[0090] Optionally, the above-mentioned association module 32 is specifically used to: obtain module pairs formed by all modules in the case text; wherein each module pair contains two modules; for each module pair, input the module contents of the two modules in the module pair into the trained module association model to obtain the association probability between the two modules in the current module pair; and determine the two modules in the module pair whose association probability exceeds a threshold as having an association relationship.

[0091] The module association model includes a second pre-trained model, two second fully connected layers and two self-attention layers; and the output of the second pre-trained model is respectively connected to the input of the two second fully connected layers, and the output of one second fully connected layer is connected to the input of one self-attention layer. The above-mentioned similar case recommendation device also includes a second training module, which is connected to the association module 32 and is used to train the module association model. The specific process of training the module association model includes: constructing a second training set; wherein the second training set contains multiple second training texts, and the second training texts are in the same field as the case texts, and the second training texts are annotated with the actual association probabilities of each module pair contained therein; wherein the actual association probability is 1 or 0; inputting the module contents of the two modules in the same module pair in the second training text into the second pre-trained model to obtain the first hidden layer representation and the second hidden layer representation respectively; passing the first hidden layer representation through one of the second fully connected layers and one of the self-attention layers to obtain the first module representation, and passing the second hidden layer representation through another second fully connected layer and another self-attention layer to obtain the second module representation; obtaining the predicted association probability based on the first module representation and the second module representation; adjusting the parameters in the module association model based on the predicted association probability and the actual association probability.

[0092] Optionally, when the module contents of two modules in the same module pair in the second training text are input into the second pre-trained model, the first module element in the module content of one of the modules is marked as 1, and the remaining characters other than the first module element in the module content of one of the modules are marked as 0; and the second module element in the module content of the other module is marked as 0, and the remaining characters other than the second module element in the module content of the other module are marked as 1.

[0093] Optionally, the first acquisition module 34 is specifically used to obtain each word vector in the module content of each module in the structured case text; and perform weighted averaging of all word vectors to obtain a vectorized representation; or, the module content of each module in the structured case text is respectively input into the trained third pre-trained model to obtain a corresponding vectorized representation.

[0094] Optionally, the second acquisition module 36 is specifically used to obtain, for each historical case in the case database, a first similarity between a vectorized representation of each module in the case text and a vectorized representation of the same module in the historical case; obtain an overall similarity between the historical case and the case text based on a first sum of the first similarities of the modules in the case text; sort all historical cases in the case database from high to low based on the overall similarity, and output some historical cases with higher overall similarity.

[0095] Among them, before the step of obtaining the overall similarity between the historical case and the case text according to the sum of the first similarities of each module in the case text, it includes: obtaining the first number of each module in the case text and the second number of each module in the historical case; obtaining the second similarity value according to the first number and the second number of the same module; wherein, the greater the difference between the first number and the second number of the same module, the smaller the second similarity value; obtaining the overall similarity between the historical case and the case text according to the first sum of the first similarities of each module in the case text includes: taking the sum of the first sum and the second similarity value as the overall similarity.

[0096] In addition, the similar case recommendation device provided by the present application may also include a construction module, which is connected to the second acquisition module 36, and is used to obtain the case documents to be stored, and perform module extraction on the case documents to be stored to obtain all modules contained in the documents to be stored and the module content of each module; determine the association relationship between modules based on the module content of all modules of the case documents to be stored, so as to construct a structured case document to be stored; obtain the vectorized representation of each module in the structured case document to be stored, and store it in the case database. Optionally, before the step of storing it in the database, it also includes: constructing a nearest neighbor search index for each vectorized representation.

[0097] See also Fig.10 , Fig.10 This is a structural diagram of an embodiment of an electronic device of the present application, and the electronic device specifically includes: a memory 40 and a processor 42 coupled to each other, the memory 40 stores program instructions, and the processor 42 is used to execute the program instructions to implement the steps in any of the above-mentioned case recommendation methods. Specifically, the electronic device includes but is not limited to: a desktop computer, a laptop computer, a tablet computer, a server, etc., which are not limited here. In addition, the processor 42 can also be called a CPU (Central Processing Unit). The processor 42 may be an integrated circuit chip with signal processing capabilities. The processor 42 can also be a general-purpose processor, a digital signal processor (Digital Signal Processor, DSP), an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), a field-programmable gate array (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. In addition, the processor 42 can be implemented by an integrated circuit chip.

[0098] See also Fig.11 , Fig.11 This is a schematic diagram of the structure of an embodiment of a storage device of the present application. The storage device 50 stores program instructions 52 that can be executed by a processor. The program instructions 52 are used to implement the steps in any of the above-mentioned case recommendation methods.

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

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

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

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

[0103] The above description is only an embodiment of the present application and does not limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly used in other related technical fields, are also included in the patent protection scope of the present application.

Claims

1. A similar case recommendation method, characterized in that: include: Obtaining a case text input by a user, and performing module extraction on the case text to obtain all modules contained in the case text and the module content of each module; Determining the association relationship between the modules based on the module contents of all the modules of the case text to construct the structured case text; Obtaining vectorized representations of each module in the structured case text, and obtaining historical cases similar to the case text from a case database based on the vectorized representations; Wherein, the determining of the association relationship between the modules based on the module contents of all the modules of the case text comprises: obtaining module pairs formed by all the modules in the case text; wherein each module pair comprises two modules; for each module pair, inputting the module contents of the two modules in the module pair into the trained module association model to obtain the association probability between the two modules in the current module pair; determining the two modules in the module pair whose association probability exceeds a threshold as having an association relationship; The module association model includes a second pre-trained model, two second fully connected layers and two self-attention layers; and the output of the second pre-trained model is respectively connected to the input of the two second fully connected layers, and the output of one second fully connected layer is connected to the input of one self-attention layer; the process of training the module association model includes: constructing a second training set; wherein the second training set contains multiple second training texts, and the second training texts are in the same field as the case texts, and the second training texts are annotated with the actual association probability of the module content of each module pair contained therein; wherein the actual association probability is 1 or 0; inputting the module contents of the two modules in the same module pair in the second training text into the second pre-trained model to obtain a first hidden layer representation and a second hidden layer representation respectively; passing the first hidden layer representation through one of the second fully connected layers and one of the self-attention layers to obtain a first module representation, and passing the second hidden layer representation through another second fully connected layer and another self-attention layer to obtain a second module representation; obtaining a predicted association probability based on the first module representation and the second module representation; and adjusting the parameters in the module association model based on the predicted association probability and the actual association probability.

2. The similar case recommendation method according to claim 1, characterized in that: The step of extracting modules from the case text to obtain all modules contained in the case text and the module content of each module includes: Obtain all modules related to the field of the case text; For each of the modules, the name of the module and the case text are input into the trained module extraction model to obtain the module content of the module.

3. The similar case recommendation method according to claim 2, characterized in that: The module extraction model includes a first pre-trained model and two first fully connected layers; and the output of the first pre-trained model is respectively connected to the input of the two first fully connected layers; The process of training the module extraction model includes: Constructing a first training set; wherein the first training set includes a plurality of first training texts, and the first training texts are in the same field as the case texts, and the first training texts are marked with location labels of various modules; Inputting the name of any module and the first training text into the first pre-trained model to obtain a hidden layer representation; Inputting the hidden layer representation into two first fully connected layers respectively, respectively obtaining the predicted starting position and the predicted ending position of the module in the first training text; The parameters of the module extraction model are adjusted based on the predicted starting position, the predicted ending position and the position label associated with the same module.

4. The similar case recommendation method according to claim 1, characterized in that: When the module contents of two modules in the same module pair in the second training text are input into the second pre-training model, the first module element in the module content of one of the modules is marked as 1, and the remaining characters in the module content of one of the modules other than the first module element are marked as 0; and the second module element in the module content of the other module is marked as 0, and the remaining characters in the module content of the other module other than the second module element are marked as 1.

5. The similar case recommendation method according to claim 1, characterized in that: The step of obtaining the vectorized representation of each module in the structured case text includes: Obtaining each word vector in the module content of each module in the structured case text; and performing weighted averaging on all the word vectors to obtain the vectorized representation; or, The module contents of each module in the structured case text are respectively input into the trained third pre-trained model to obtain the corresponding vectorized representation.

6. The similar case recommendation method according to claim 1, characterized in that: The step of obtaining historical cases similar to the case text from a case database based on the vectorized representation includes: For each historical case in the case database, obtaining a first similarity between a vectorized representation of each module in the case text and a vectorized representation of the same module in the historical case; Obtaining the overall similarity between the historical case and the case text according to the first sum of the first similarities of the modules in the case text; All the historical cases in the case database are sorted from high to low according to the overall similarity, and some of the historical cases with higher overall similarity are output.

7. The similar case recommendation method according to claim 6, characterized in that: Before the step of obtaining the overall similarity between the historical case and the case text according to the sum of the first similarities of the modules in the case text, the method includes: obtaining the first number of each module in the case text and the second number of each module in the historical case; obtaining a second similarity value according to the first number and the second number of the same module; wherein the greater the difference between the first number and the second number of the same module, the smaller the second similarity value; The obtaining of the overall similarity between the historical case and the case text according to the first sum of the first similarities of the modules in the case text comprises: taking the sum of the first sum and the second similarity value as the overall similarity.

8. The recommendation method according to claim 1, characterized in that: Before the step of obtaining the case text input by the user, the method includes: Obtain case documents to be stored, and perform module extraction on the case documents to be stored to obtain all modules contained in the case documents to be stored and the module content of each module; Determine the association relationship between the modules based on the module contents of all the modules of the case document to be stored, so as to construct the structured case document to be stored; Obtain the vectorized representation of each module in the structured case document to be stored, and store it in the case database.

9. The similar case recommendation method according to claim 8, characterized in that: Before the step of storing it in the database, it also includes: A nearest neighbor search index is constructed for each of the vectorized representations.

10. A similar case recommendation device, characterized in that: include: An extraction module, used to obtain a case text input by a user, and perform module extraction on the case text to obtain all modules contained in the case text and the module content of each module; an association module, connected to the extraction module, for determining the association relationship between the modules based on the module contents of all the modules of the case text, so as to construct the structured case text; A first obtaining module, connected to the association module, for obtaining vectorized representations of each module in the structured case text; A second obtaining module, connected to the first obtaining module, for obtaining historical cases similar to the case text from a case database based on the vectorized representation; Wherein, the determining of the association relationship between the modules based on the module contents of all the modules of the case text comprises: obtaining module pairs formed by all the modules in the case text; wherein each module pair comprises two modules; for each module pair, inputting the module contents of the two modules in the module pair into the trained module association model to obtain the association probability between the two modules in the current module pair; determining the two modules in the module pair whose association probability exceeds a threshold as having an association relationship; The module association model includes a second pre-trained model, two second fully connected layers and two self-attention layers; and the output of the second pre-trained model is respectively connected to the input of the two second fully connected layers, and the output of one second fully connected layer is connected to the input of one self-attention layer; the process of training the module association model includes: constructing a second training set; wherein the second training set contains multiple second training texts, and the second training texts are in the same field as the case texts, and the second training texts are annotated with the actual association probability of the module content of each module pair contained therein; wherein the actual association probability is 1 or 0; inputting the module contents of the two modules in the same module pair in the second training text into the second pre-trained model to obtain a first hidden layer representation and a second hidden layer representation respectively; passing the first hidden layer representation through one of the second fully connected layers and one of the self-attention layers to obtain a first module representation, and passing the second hidden layer representation through another second fully connected layer and another self-attention layer to obtain a second module representation; obtaining a predicted association probability based on the first module representation and the second module representation; and adjusting the parameters in the module association model based on the predicted association probability and the actual association probability.

11. An electronic device, characterized in that: It comprises a memory and a processor coupled to each other, wherein the memory stores program instructions, and the processor is used to execute the program instructions to implement the similar case recommendation method according to any one of claims 1 to 9.

12. A storage device, characterized in that: Program instructions that can be executed by a processor are stored, and the program instructions are used to implement the similar case recommendation method described in any one of claims 1 to 9.

Citation Information

Patent Citations

  • A social network short text recommendation method based on a word meaning topic model

    CN109766431A

  • Case text matching method and device, electronic device and storage medium

    CN110727787A