Method, device, and electronic device for obtaining case category

Through the fusion recognition of keyword matching and case classification model, and the generation of case categories are combined with the generative big model, the problems of high error rate and low recall rate in case extraction in the existing technology are solved, and the accuracy of the case categories of legal documents is achieved and Full coverage identification.

CN117874230BActive Publication Date: 2024-12-06HANVON CORP
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311776316.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-12-21
Publication Date
2024-12-06
Estimated Expiration
2043-12-21

AI Technical Summary

Technical Problem

In the prior art, the legal document case extraction method is prone to first-level case marking errors caused by overlapping keywords, and the recall rate is low, so it is impossible to effectively extract the case category corresponding to the keywords that do not cover the keywords.

Method used

By matching legal documents with preset keyword databases, keyword matching results are obtained, and classification processing is performed based on pre-trained case classification model, and the identification results are fused to improve the accuracy of case identification; when the case category cannot be obtained, use Generative mockups generate first-level case categories that match the legal instruments, ensuring full coverage.

Benefits of technology

It effectively improves the accuracy and recall rate of case extraction of legal documents, reduces the error rate of case acquisition in category, and ensures the identification of uncovered types.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117874230B_ABST
    Figure CN117874230B_ABST
Patent Text Reader

Abstract

The present application discloses a method, device, and electronic device for obtaining case cause categories, and belongs to the field of computer technology. The method matches legal documents with keywords in a preset keyword library to obtain keyword matching results; obtains a first case cause recognition result based on the keyword matching results; classifies and processes the legal documents based on a pre-trained case cause classification model to obtain a second case cause recognition result; fuses the first case cause recognition result and the second case cause recognition result to perform case cause recognition to obtain a fusion recognition result, and obtains a first-level case cause category based on the fusion recognition result. If the case cause category cannot be obtained based on the fusion recognition result, a first-level case cause category matching the legal document is generated through a pre-trained generative large model, so as to perform case cause recognition on the types of legal documents not covered by the keyword library, thereby ensuring full coverage of legal documents that need to be identified, and improving the recall rate of the first-level case cause category.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a method, device, electronic device, and computer-readable storage medium for obtaining case category. Background Art

[0002] Extracting the cause of action of legal documents can provide data support for the retrieval and management of legal documents. In the existing technical solutions, the cause of action of legal documents is mainly extracted through statistical learning methods. For example, different types of cause of action keywords are obtained from legal documents, and the legal document keyword library is obtained by batch segmentation. The cause of action of the target legal document is determined by comparing the frequency of co-occurrence of high-frequency keywords and various cause of action keywords in the target legal document and the total word frequency. The cause of action extraction method in the prior art has at least the following defects: the first-level cause of action is easily marked incorrectly due to the overlap of cause of action keywords, the cause of action cannot be extracted for legal documents corresponding to uncovered keywords, and the recall rate is low.

[0003] It can be seen that the method of obtaining case category in the prior art still needs to be improved. Summary of the invention

[0004] The embodiments of the present application provide a method, device, electronic device and storage medium for obtaining case category, which can improve the accuracy of case extraction in legal documents and make the applicable legal documents more comprehensive.

[0005] In a first aspect, an embodiment of the present application provides a method for obtaining a case category, including:

[0006] Match the legal document with the keywords in the preset keyword library to obtain keyword matching results;

[0007] Obtaining a first case cause recognition result according to the keyword matching result;

[0008] Classify the legal document based on a pre-trained case classification model to obtain a second case recognition result;

[0009] fusing the first case cause recognition result and the second case cause recognition result to perform case cause recognition, and obtaining a fusion recognition result, wherein the fusion recognition result is used to indicate: a fusion recognition failure, or a primary case cause category matched by the legal document;

[0010] In response to the fusion recognition result indicating that the legal document matches the primary case category, ending the current case recognition operation;

[0011] In response to the fusion recognition result indicating that the fusion recognition has failed, a primary case category matching the legal document is generated by a pre-trained generative large model.

[0012] In a second aspect, an embodiment of the present application provides a device for obtaining a case category, including:

[0013] A keyword matching module is used to match legal documents with keywords in a preset keyword library to obtain keyword matching results;

[0014] A first case cause recognition result acquisition module, used to acquire a first case cause recognition result according to the keyword matching result;

[0015] A second case cause recognition result acquisition module, used to classify the legal document based on a pre-trained case cause classification model to obtain a second case cause recognition result;

[0016] a fusion recognition result acquisition module, used for fusing the first case cause recognition result and the second case cause recognition result to perform case cause recognition and obtain a fusion recognition result, wherein the fusion recognition result is used to indicate: fusion recognition failure, or the first-level case cause category matched by the legal document;

[0017] A first judgment output module, configured to terminate the current case cause identification operation in response to the fusion recognition result indicating that the legal document matches the first-level case cause category;

[0018] The first judgment output module is also used to generate a first-level case category matching the legal document through a pre-trained generative large model in response to the fusion recognition result indicating that the fusion recognition failed.

[0019] In a third aspect, an embodiment of the present application further discloses an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the case category acquisition method described in the embodiment of the present application when executing the computer program.

[0020] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the steps of the method for obtaining the case category disclosed in the embodiment of the present application are performed.

[0021] The case category acquisition method disclosed in the embodiment of the present application is to obtain a keyword matching result by matching the legal document with the keywords in the preset keyword library; obtain the first case identification result according to the keyword matching result; on the other hand, classify the legal document based on the pre-trained case classification model to obtain the second case identification result; then, fuse the first case identification result and the second case identification result to perform case identification to obtain a fusion identification result, which is used to indicate: fusion identification failure, or the first-level case category matched by the legal document can be matched to a first-level case category with a higher degree of relevance by comprehensively comparing the case identification results obtained by different methods, thereby effectively reducing the error rate of the first-level case category obtained. Further, when the case category cannot be obtained through the keyword identification result and the case classification model, the first-level case category matched by the legal document is generated by the pre-trained generative large model to perform case identification on the types of legal documents not covered by the keyword library, thereby ensuring full coverage of legal documents whose case categories need to be identified, and greatly improving the recall rate of the first-level case category.

[0022] The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are 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.

[0024] Figure 1 This is one of the flow charts of the method for obtaining the case category disclosed in the embodiment of the present application;

[0025] Figure 2 It is a schematic diagram of the structure and content of a preset keyword library in the case category acquisition method disclosed in the embodiment of the present application;

[0026] Figure 3 This is the second flow chart of the method for obtaining the case category disclosed in the embodiment of the present application;

[0027] Figure 4 It is one of the structural schematic diagrams of the case category acquisition device disclosed in the embodiment of the present application;

[0028] Figure 5This is the second structural diagram of the case category acquisition device disclosed in the embodiment of the present application;

[0029] Figure 6 A block diagram schematically shows an electronic device for executing the method according to the present application; and

[0030] Figure 7 A storage unit for holding or carrying a program code for implementing the method according to the present application is schematically shown. DETAILED DESCRIPTION

[0031] 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 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.

[0032] Reference Figure 1 , a method for obtaining case category disclosed in an embodiment of the present application includes: steps 110 to 160.

[0033] The specific implementation methods of each step are described below.

[0034] Step 110, matching the legal document with the keywords in the preset keyword library to obtain keyword matching results.

[0035] Among them, the legal document is a legal document of the case category to be obtained.

[0036] The preset keyword library is pre-constructed and includes a number of keywords. The keywords included in the preset keyword library are keywords extracted by collecting legal document data and according to certain rules.

[0037] In the legal field, the causes of action corresponding to legal documents include primary causes of action and secondary causes of action. Based on the latest laws and regulations, the cause of action categories include 11 primary causes of action and 473 secondary causes of action, ensuring the comprehensive coverage and legal professionalism of the causes of action. Secondary causes of action are further refinements of primary causes of action, and each primary cause of action category includes one or more secondary cause of action categories. For example, the primary cause of action category "Intellectual Property and Competition Disputes" may correspond to secondary cause of action categories such as "Copyright Contract Disputes", "Trade Secret Contract Disputes", "False Advertising Disputes", etc.

[0038] Among them, each keyword included in the preset keyword library is provided with a first-level case category label and a second-level case category label, which are used to indicate the first-level case category and the second-level case category matched by the keyword. It can be understood that the keyword has the highest probability of appearing in the legal documents of the corresponding first-level case category. In the embodiment of the present application, the same keyword has a unique set of first-level case category labels and second-level case category labels, that is, the intersection of the keywords corresponding to different second-level case categories is empty.

[0039] By building a hierarchical preset keyword library, we can cover the first-level case categories more comprehensively, effectively improve the accuracy of obtaining the first-level case categories, and effectively reduce the error rate of obtaining the first-level case categories due to the overlap of the case categories of the hit keywords.

[0040] In an embodiment of the present application, each keyword is also provided with a discrimination weight, and the discrimination weight reflects the confidence of the keyword in judging the primary case category that matches the legal document containing the keyword.

[0041] The method of establishing the preset keyword library is described below and will not be repeated here. Figure 2 shown.

[0042] As mentioned above, the keywords in the preset keyword library are marked with corresponding first-level case categories and second-level case categories, as well as discrimination weights. Accordingly, the matching of legal documents with the keywords in the preset keyword library to obtain keyword matching results includes: keyword matching of the legal documents with the keywords in the preset keyword library respectively, obtaining the keywords that successfully match the legal documents with the preset keyword library, and the number of occurrences of each of the keywords that successfully match; obtaining the keyword matching results based on the successfully matched keywords, the number of occurrences of each of the keywords, and the first-level case categories and discrimination weights corresponding to the keywords.

[0043] For example, the legal document may be first segmented and extracted, and then each extracted segmented word may be matched with a keyword in a preset keyword library, and the successfully matched keywords and the number of occurrences of the successfully matched keywords in the legal document may be recorded. For another example, each keyword in the preset keyword library may be word matched with the legal document, the number of occurrences of each keyword in the legal document may be obtained, and a keyword with a number of occurrences greater than or equal to 1 may be selected as a successfully matched keyword, and the number of occurrences of the successfully matched keyword in the legal document may be recorded.

[0044] In the embodiments of the present application, other methods may be used to perform keyword matching on the legal document and the keywords in the preset keyword library, respectively, to obtain the keywords that the legal document successfully matches with the preset keyword library, and the number of occurrences of each of the keywords that successfully matches, which are not listed one by one in the embodiments of the present application. The embodiments of the present application do not limit the specific implementation method of performing keyword matching on the legal document and the keywords in the preset keyword library, respectively, to obtain the keywords that the legal document successfully matches with the preset keyword library, and the number of occurrences of each of the keywords that successfully matches.

[0045] After keyword matching, for each successfully matched keyword, the keyword, the number of occurrences of the keyword, and the first-level case category and discrimination weight corresponding to the keyword can be used as a keyword matching result corresponding to the keyword. The keyword matching results of all successfully matched keywords constitute the keyword matching results of the legal text and the preset keyword library.

[0046] Next, the first case cause recognition result can be obtained based on the keyword matching result. On the other hand, a pre-trained case cause classification model is used to predict the case cause category of the legal document to obtain a second case cause recognition result. The first case cause recognition result and the second case cause recognition result are comprehensively considered to perform case cause recognition to obtain a fusion recognition result of the case cause category of the legal document.

[0047] Step 120: Obtain the first case cause identification result based on the keyword matching result.

[0048] Optionally, obtaining a first case identification result based on the keyword matching result includes: obtaining a target first-level case category of the keyword distribution included in the legal document and the number of keywords corresponding to each target first-level case category based on the first-level case category corresponding to the keyword and the number of occurrences; obtaining the sum of the discrimination weights of the keywords corresponding to the same target first-level case category based on the discrimination weights of each keyword, the number of occurrences and the corresponding first-level case category as the first weight corresponding to the corresponding target first-level case category; in response to the number of the target first-level case categories being 1, and the number of keywords corresponding to the target first-level case category and the first weight satisfying the first judgment condition , adding the target first-level case category as a candidate first-level case category to the first case recognition result, wherein the first judgment condition is: the number of keywords corresponding to the target first-level case category meets the preset number threshold condition, and the first weight corresponding to the target first-level case category meets the preset weight sum threshold condition; in response to the number of the target first-level case categories being 1, and the number of keywords and the first weight corresponding to the target first-level case category not meeting the first judgment condition, setting the first case recognition result to empty; in response to the number of the target first-level case categories being greater than 1, obtaining the first case recognition result according to the number of keywords corresponding to the target first-level case category and the first weight corresponding to the target first-level case category.

[0049] When obtaining the first case identification result according to the keyword matching result, it is necessary to combine the pre-set judgment factors and judgment conditions to judge whether the case category matching the legal document can be identified according to the keyword matching result, and, if the case category matching the legal document can be identified according to the keyword matching result, identify the case category matching the legal document as a candidate case category. The judgment factors include but are not limited to one or more of the following: the first-level case category of keyword distribution, the number of keywords corresponding to the specified first-level case category (the same keyword appears multiple times in the legal document and is calculated as multiple keywords), the sum of the discrimination weights of the keywords in the specified first-level case category, and the difference between the sum of the discrimination weights of the keywords inside and outside the first-level case category.

[0050] The calculation methods of each judgment factor are explained below.

[0051] (I) The first-level case categories of keyword distribution and the number of keywords corresponding to the first-level case categories

[0052] For example, first, according to the first-level case category corresponding to the keyword in the keyword matching result and the number of occurrences of the keyword in the legal document, each first-level case category whose number of corresponding keywords in the keyword matching result is greater than 0 is obtained as the target first-level case category. Among them, the correspondence between the keyword and the first-level case category can be determined according to the first-level case category label set for the keyword in the preset keyword library.

[0053] Furthermore, for each target first-level case category, the number of occurrences of all keywords corresponding to the target first-level case category in the keyword matching results are accumulated, and the accumulated sum is used as the number of keywords included in the target first-level case category, and the number is used as the number of keywords corresponding to the target first-level case category.

[0054] (II) The sum of the discrimination weights of the keywords in the specified first-level case category

[0055] As mentioned above, each keyword in the preset keyword library is set with a discrimination weight. When adopting the method in the previous article, the keyword corresponding to each target first-level case category is obtained according to the keyword matching results, and the number of occurrences of each corresponding keyword, the discrimination weight of each corresponding keyword is multiplied by the number of occurrences of the keyword to obtain the weight of the keyword. After that, the weights of all corresponding keywords are accumulated, and the accumulated result is used as the first weight corresponding to the target first-level case category.

[0056] (III) The difference between the sum of the discrimination weights of keywords within and outside the first-level case category

[0057] For the target first-level case categories determined in the above steps, one of the target first-level case categories is selected as the first target first-level case category, and the remaining target first-level case categories are determined as the second target first-level case categories. Then, for the currently selected first target first-level case category, the current second target first-level case category is determined, and then the first weights corresponding to each current second target first-level case category are accumulated to obtain the target weight; then, the difference between the first weight corresponding to the currently selected first target first-level case category and the target weight is used as the difference between the sum of the discrimination weights of the keywords inside and outside the first-level case category corresponding to the currently selected first target first-level case category.

[0058] Next, based on the values ​​of the judgment factors obtained by the above calculation, a technical solution for identifying the primary case category based on the keyword matching results is explained.

[0059] First, determine whether the keywords in the legal document are distributed in one target first-level case category or in multiple target first-level case categories. If they are distributed in one target first-level case category, that is, the number of target first-level case categories is 1, then further determine whether the number of keywords corresponding to the target first-level case category and the first weight corresponding to the target first-level case category meet the first judgment condition; if they are distributed in multiple target first-level case categories, that is, the number of target first-level case categories is greater than 1, then further determine whether the difference between the number of keywords corresponding to each target first-level case category, the first weight corresponding to the target first-level case category, and the sum of the discrimination weights of keywords inside and outside the first-level case category meets other preset judgment conditions.

[0060] For example, when the number of target first-level case categories is equal to 1, if the number of keywords corresponding to the target first-level case category meets the preset number threshold condition, and the first weight corresponding to the target first-level case category meets the preset weight sum threshold condition, then the target first-level case category is used as a candidate first-level case category, and the candidate first-level case category is added to the first case recognition result. If the number of target first-level case categories is 1, but the number of keywords corresponding to the target first-level case category does not meet the preset number threshold condition, or the first weight corresponding to the target first-level case category does not meet the preset weight sum threshold condition, then the first case recognition result will not include any first-level case category, that is, the first case recognition result is empty.

[0061] When the number of target first-level case cause categories is greater than 1, one or more of the above-mentioned judgment factors are judged for each target first-level case cause category respectively, so as to identify the case cause category according to the keyword matching results corresponding to each target first-level case cause category.

[0062] Optionally, obtaining the first case cause recognition result according to the number of keywords corresponding to the target first-level case cause category and the first weight corresponding to the target first-level case cause category includes: in response to the number of keywords corresponding to the first target first-level case cause category and the first weight corresponding to the target first-level case cause category satisfying the second judgment condition, adding the first target first-level case cause category as a candidate first-level case cause category to the first case cause recognition result; in response to the number of keywords corresponding to the first target first-level case cause category and the first weight corresponding to the target first-level case cause category not satisfying the second judgment condition, abandoning obtaining the first case cause recognition result corresponding to the first target first-level case cause category; wherein the second judgment condition is: the number of keywords corresponding to the first target first-level case cause category satisfies a preset number threshold condition, and the first weight corresponding to the first target first-level case cause category satisfies a preset weight sum threshold condition, and the difference between the first weight of the first target first-level case cause category and the target weight satisfies a preset weight difference threshold condition, and the target weight is: the cumulative sum of the first weights of the second target first-level case cause category, and the first target first-level case cause category and the second target first-level case cause category are different target first-level case cause categories.

[0063] For example, for each of the target first-level case categories, each of the target first-level case categories can be used as the first target first-level case category, and the target first-level case categories other than the first target first-level case category can be used as the second target first-level case category, and the following judgment operation is performed: if the number of keywords corresponding to the first target first-level case category meets the preset number threshold condition, and the first weight corresponding to the first target first-level case category meets the preset weight sum threshold condition, and the difference between the first weight of the first target first-level case category and the target weight meets the preset weight difference threshold condition, then the first target first-level case category is used as a candidate first-level case category, and the candidate first-level case category is added to the first case recognition result; if the number of keywords corresponding to the first target first-level case category does not meet the preset number threshold condition, or the first weight corresponding to the first target first-level case category does not meet the preset weight sum threshold condition, or the difference between the first weight of the first target first-level case category and the target weight does not meet the preset weight difference threshold condition, then the relevant keyword recognition result according to the first target first-level case category is abandoned, and the first case recognition result is obtained.

[0064] If for each target first-level case category, the relevant keyword recognition results based on the first target first-level case category are abandoned to obtain the first case recognition result, then after the case recognition is performed in this step, the first case recognition result obtained is empty.

[0065] After this step, case category identification is performed based on the keyword matching results, and the first case identification result obtained may be any of the following situations: the first case identification result is empty, and the first case identification result includes one or more candidate case categories.

[0066] Step 130, classify the legal document based on the pre-trained case classification model to obtain a second case recognition result.

[0067] Optionally, the case classification model can be built based on a hierarchical decomposition BERT model.

[0068] The training method of the case classification model is described below and will not be repeated here.

[0069] The case classification model performs hierarchical classification and coding mapping on the words in the input legal document, and finally outputs the probability that the input legal document matches each preset case category. Taking the preset case category including 11 case categories as an example, for the input legal document, the case classification model will output 11 probability values, each probability value represents the probability that the input legal document matches the corresponding case category.

[0070] Furthermore, the probability of the legal document output by the case classification model matching the corresponding case category can be used as the second case identification result.

[0071] Optionally, the classifying process of the legal document based on the pre-trained case classification model to obtain a second case recognition result includes: pre-processing the legal document to obtain a text sequence marked with the beginning of a sentence; inputting the text sequence into the pre-trained case classification model, performing hierarchical decomposition and position coding processing on the text sequence through the case classification model to obtain a coding vector corresponding to the text sequence, and performing classification mapping based on the coding vector to obtain a second case recognition result.

[0072] For example, the legal document may be subjected to word segmentation, stop words removal, and preprocessing operations such as adding a distinction between the start and end positions of sentences to obtain a text sequence marked with the start of sentences.

[0073] The BERT model input vector contains three parts. The first part is the vector of the token, the second part is the vector of the position code, and the third part is the vector of the paragraph code to which the token belongs. The position code provides order information for the sequence. The position code used in the BERT model is a learnable absolute position code. The advantage of this position code is that different codes for different positions can be learned instead of fixed codes. This position code requires setting the maximum length of the training sentence and cannot predict sentences that exceed the length because the dimension of the position code is fixed. For example, the native BERT can only process sentences with a maximum length of 512. The length of legal documents usually exceeds 512. In the prior art, the BERT model is usually used by truncating the input text sequence. In the legal field, truncating the input text sequence may cause key information to be lost, resulting in inaccurate case classification.

[0074] In the embodiments of the present application, by improving the position coding method and performing hierarchical decomposition processing on the position coding corresponding to the input text sequence, the case classification model can process longer input text sequences.

[0075] Optionally, the text sequence is input into a pre-trained case classification model, and the text sequence is subjected to hierarchical decomposition position encoding processing by the case classification model to obtain an encoding vector corresponding to the text sequence, and classification mapping is performed based on the encoding vector to obtain a second case recognition result, including: dividing the text sequence into at least one encoding group according to the length of the text sequence and the maximum input sequence length of the case classification model; obtaining the inter-group position index and intra-group position index of the text in each of the encoding groups; initializing the intra-group encoding weight and the inter-group encoding weight of the first encoding group to a preset weight value; and obtaining the case classification model trained based on the intra-group encoding weight, the inter-group encoding weight, and the case classification model trained based on the intra-group encoding weight, the inter-group encoding weight, and the case classification model trained based on the intra-group encoding weight, the inter-group encoding weight, and the case classification model trained based on the intra-group encoding weight, the inter-group encoding weight, and the case classification model trained based on the intra-group encoding weight, the inter-group encoding weight, and the case classification model trained based on the inter ... text sequence is divided into at least one encoding group; The absolute position encoding weights are obtained to obtain the relative position encoding weights of the model; according to the intra-group position index and inter-group position index of the text, the intra-group position codes and inter-group position codes are extracted from the corresponding positions of the relative position encoding weights; the intra-group position codes and inter-group position codes are weighted summed with specified weights to obtain hierarchical position codes, wherein the specified weights of the intra-group position codes are negatively correlated with the encoding group positions, and the specified weights of the inter-group position codes are positively correlated with the encoding group positions; the absolute position codes of the case classification model are replaced with the hierarchical position codes; based on the replaced absolute position codes, the encoding vectors corresponding to the text sequence are classified and mapped to obtain the second case recognition result.

[0076] First, when the length of the text sequence is greater than the maximum input sequence length of the case classification model, the text sequence is divided into one or more coding groups according to the maximum input sequence length of the case classification model, and the coding groups are numbered starting from 1 according to the position of the text in each coding group. Taking the maximum input sequence length of the case classification model as 512 as an example, the length of the text sequence is divided by the maximum input sequence length of the case classification model (such as 512) to obtain the number of coding groups of the text sequence.

[0077] Furthermore, the index of the text sequence (from 0 to the maximum character length of the text sequence - 1) is divided by the number of encoding groups to calculate the inter-group position index and the intra-group position index, and the formula is as follows: IndexOUT=textIndex%GroupNum;

[0078] in, Indicates rounding down, % indicates remainder, textIndex indicates text sequence index, GroupNum indicates the number of encoding groups, IndexIN indicates the position index within a group, and IndexOUT indicates the position index between groups.

[0079] Set the initial intra-group coding weight to 0.45 and the initial inter-group coding weight to 0.55. The first coding group can use this weight. In each subsequent coding group, the intra-group coding weight decreases and the inter-group coding weight increases until the last coding group, when the intra-group coding weight decreases to 0.35 and the inter-group coding weight increases to 0.65. The initial intra-group coding weight and the initial inter-group coding weight can be set based on experience.

[0080] Optionally, the relative position encoding weights of the model can be calculated using the following formula:

[0081]

[0082] Among them, W RP (i) represents the relative position encoding weight of encoding group i, W AP (i) represents the absolute position encoding weight of encoding group i, W I (i) represents the intra-group coding weight of coding group i, W AP (1) represents the absolute position encoding weight of encoding group 1, W O (i) represents the inter-group coding weight of coding group i.

[0083] Optionally, the hierarchical position encoding of the model corresponding to the encoding group K can be calculated by the following formula:

[0084] LPE(j)=GroupIE(j)×W I (k)+GroupOE(j)×Wo (k);

[0085] Where LPE(j) represents the jth item in the hierarchical position encoding, GroupIE(j) represents the jth item in the group position encoding, and W I (k) represents the intra-group coding weight of coding group K, GroupOE(j) represents the jth item in the inter-group position coding, and W o (k) represents the inter-group coding weight of coding group K, k=j%GroupNum, and GroupNum represents the number of coding groups.

[0086] Finally, the obtained hierarchical position coding is used to replace the absolute position coding in the case classification model for coding processing.

[0087] Afterwards, the decoding layer of the case classification model classifies and maps the encoding vector obtained by the encoding process to obtain the probability value of the legal document matching each first-level case category, that is, the second case recognition result.

[0088] Step 140, fusing the first case cause identification result and the second case cause identification result to perform case cause identification and obtain a fusion identification result, wherein the fusion identification result is used to indicate: failure of fusion identification, or the case cause category matched by the legal document.

[0089] In order to improve the accuracy of case cause identification, the first case cause identification result obtained based on the keyword matching result and the second case cause identification result obtained by classification through the case cause classification model are comprehensively considered to perform case cause identification.

[0090] As described above, the first case cause identification result is empty, or includes a candidate first-level case cause category, and the second case cause identification result includes: the preset probabilities corresponding to each first-level case cause category, and accordingly, the first case cause identification result and the second case cause identification result are integrated to perform case cause identification to obtain a fused identification result, including: in response to the first case cause identification result and the second case cause identification result satisfying the third judgment condition, the first-level case cause category corresponding to the maximum probability in the probabilities is used as the first-level case cause category of the legal document to obtain a fused identification result, wherein the third judgment condition is: the maximum probability satisfies the preset probability threshold condition, and the first-level case cause category corresponding to the maximum probability is the candidate first-level case cause category included in the first case cause identification result; in response to the first case cause identification result and the second case cause identification result not satisfying the third judgment condition, a fused identification result indicating a failure of fusion identification is obtained.

[0091] For example, the first case identification result includes two candidate first-level case categories. At this time, if the maximum probability among the probabilities corresponding to the first-level case categories in the second case identification result meets the preset probability threshold condition (for example, greater than or equal to the preset probability threshold), it is considered that the first-level case category corresponding to the maximum probability in the second case identification result can be used as the case category of the legal document. Further, it is determined whether the first-level case category corresponding to the maximum probability is included in the first case identification result. If included, it is considered that the first-level case category obtained by classification based on the case classification model is consistent with the first-level case category obtained by keyword matching, and the first-level case category corresponding to the maximum probability is used as the first-level case category matched by the legal document. That is, the fusion recognition result is the first-level case category corresponding to the maximum probability; if not included, it is considered that the first-level case category obtained by classification based on the case classification model is inconsistent with the first-level case category obtained by keyword matching. In this case, a fusion recognition result indicating a failure of fusion recognition is obtained, for example, the fusion recognition result is set to an empty or invalid case category.

[0092] If the first case cause recognition result is not empty, it is possible to determine whether the first case cause category corresponding to the maximum probability is included in the first case cause recognition result by comparing the similarities and differences between the name of the first case cause category corresponding to the maximum probability and the name of each candidate first case cause category in the first case cause recognition result. If the first case cause recognition result is empty, it is possible to directly determine that the first case cause category corresponding to the maximum probability is not included in the first case cause recognition result.

[0093] For example, the content of legal document A is "the plaintiff Yang claimed that Yang had two brothers, the eldest brother Yang XX (died of illness in 2006, and was married to Ding). In early 2005, Yang XX was ill and bedridden, unable to take care of himself. Yang XX asked relatives and village cadres to negotiate with Yang and let him take responsibility for Yang XX's birth, upbringing, death, burial and related matters. On January 31, 2005, Yang XX made a will. Yang XX lived with Yang XX and took responsibility for..." After keyword matching with the preset keyword library, the keyword matching results are: there are 14 successfully matched keywords, among which the number of keywords corresponding to the case category of "marriage, family, inheritance disputes" is equal to 13, and the number of keywords corresponding to the case category of "property rights disputes" is equal to 1.

[0094] According to the discrimination weight of each keyword, the sum of the discrimination weights (i.e., the first weight) of the keywords corresponding to the case category "marriage, family, inheritance disputes" is 5.28, and the sum of the discrimination weights (i.e., the first weight) of the keywords corresponding to the case category "property rights disputes" is 0.44. The number of keywords 13 meets the preset number threshold condition, the first weight 5.28 corresponding to the case category "marriage, family, inheritance disputes" meets the preset weight sum threshold condition, and the difference between the first weight 5.28 and 0.44 meets the preset weight difference threshold condition, so the first case identification result can be obtained as the case category "marriage, family, inheritance disputes".

[0095] On the other hand, the above legal document A is classified based on the pre-trained case classification model, and the second case recognition result is: the probability of the corresponding case category "marriage and family, inheritance disputes" is 0.901, the probability of the corresponding case category "property rights disputes" is 0.052, the probability of the corresponding case category "tort liability disputes" is 0.021,... Among the probabilities corresponding to the 11 case categories, the maximum probability of 0.901 meets the preset probability threshold condition, and the case category "marriage and family, inheritance disputes" corresponding to the maximum probability 0.901 in the second case recognition result is included in the first case recognition result, so the fusion recognition result can be obtained: the first-level case category matched by legal document A is "marriage and family, inheritance disputes".

[0096] In another example, the content of legal document B is "Zhong and Jiang are neighbors. Jiang temporarily occupied Zhong's Di Shui area to build a house. It was agreed that the original foundation could be excavated when Zhong built the house. In March 2015, when Zhong built the house and asked for opinions from the neighbors, Jiang did not raise any objection. However, during the construction of the house, Jiang obstructed it many times with various reasons, and the conflict between the two sides intensified. On August 16, 2016, Zhong found that the drainage ditch of the new house was blocked with cement, so he took a crowbar and wanted to pry open the cement to drain the water. Jiang rushed to stop him and told him that it was him who did it, and the reason was to facilitate the passage of vehicles, and the two sides had a dispute. ......", after keyword matching with the preset keyword library, the keyword matching results are: there are 14 successfully matched keywords in total, among which the number of keywords corresponding to the case category of "property rights dispute" is equal to 5, and the number of keywords corresponding to the case category of "personal rights dispute" is equal to 3.

[0097] According to the discrimination weight of each keyword, the sum of the discrimination weights (i.e., the first weight) of the keywords corresponding to the case category of "property rights dispute" is 3.28, and the sum of the discrimination weights (i.e., the first weight) of the keywords corresponding to the case category of "personal rights dispute" is 2.56. The number of keywords 5 meets the preset number threshold condition, and the first weight 3.28 corresponding to the case category of "unauthorized dispute" meets the preset weight sum threshold condition. The difference between the first weight 3.28 and 2.26 does not meet the preset weight difference threshold condition, so it can be obtained that the first case identification result is empty.

[0098] On the other hand, the above legal document B is classified based on the pre-trained case classification model, and the second case recognition result is: the probability of the corresponding case category "property rights dispute" is 0.783, the probability of the corresponding case category "personal rights dispute" is 0.153, the probability of the corresponding case category "tort liability dispute" is 0.094,... Among the probabilities corresponding to the 11 case categories, the maximum probability of 0.783 meets the preset probability threshold condition. However, the case category "property rights dispute" corresponding to the maximum probability of 0.783 in the second case recognition result is not included in the first case recognition result, so the fusion recognition result can be obtained: fusion recognition failed.

[0099] Afterwards, a prompt word is generated based on the above legal document B, triggering the pre-trained generative large model to generate a first-level case category matching the legal document.

[0100] Step 150, in response to the fusion recognition result indicating the case category that matches the legal document, ending the current case recognition operation.

[0101] If the case category that matches the legal document is obtained through fusion identification in the above steps, the obtained case category is output, and the current case category acquisition operation for the legal document is terminated.

[0102] Step 160 , in response to the fusion recognition result indicating that the fusion recognition has failed, generating a primary case category matching the legal document through a pre-trained generative large model.

[0103] If the case category matching the legal document cannot be obtained after the fusion identification in the above steps, it is necessary to further generate the first-level case category matching the legal document through the pre-trained generative large model.

[0104] Optionally, based on the Llama model (Large Language Model Meta AI, an open and efficient descendant model of a large basic language model released by Meta AI) structure, pre-training and instruction fine-tuning can be used to obtain a generative large model with legal expertise and the ability to understand case extraction tasks, as the generative large model for extracting the first-level case category in the embodiment of the present application.

[0105] The structure and training method of the pre-trained generative large model refer to the prior art and will not be repeated in the embodiments of the present application.

[0106] Optionally, the generating of the first-level case category matching the legal document by using a pre-trained generative big model includes: generating a prompt word based on the legal document; triggering the pre-trained generative big model to generate the name of the first-level case category matching the legal document based on the prompt word; and performing name alignment processing on the generated name of the first-level case category based on the real name of the preset first-level case category to obtain the first-level case category matching the legal document.

[0107] When the generative big model is triggered to generate the first-level case category matching the legal document, the prompt words of the generative big model need to be input in the software engineering. Usually, the prompt words need to include prompt information such as generation instructions, input text, and generation content style.

[0108] In some optional embodiments, prompt words may be generated based on the original text of the legal document.

[0109] In some other optional embodiments, key sentences may be extracted from legal documents, and prompt words may be generated based on the extracted key sentences.

[0110] Due to the particularity of legal documents, some legal documents have relatively long texts, and the interference information included therein may cause the content generated by the generative large model to be inconsistent with expectations. In some optional embodiments of the present application, prompt words are generated based on the legal documents, including: in response to the text length of the legal document being greater than a preset length threshold, extracting sentences in the legal document according to the degree of correlation between the sentences in the legal document, and generating prompt words; in response to the text length of the legal document being less than or equal to the preset length threshold, generating prompt words based on the legal document.

[0111] Wherein, according to the degree of association of the sentences in the legal document, extracting the sentences in the legal document and generating prompt words include: calculating the degree of association between the sentences in the legal document based on the word vector; for the first sentence, accumulating the degree of association between the first sentence and each second sentence to obtain the importance value of the first sentence, wherein the second sentence is the sentence in the legal document other than the first sentence; extracting a specified number of first sentences in descending order of the importance value to generate prompt words. Wherein, the degree of association between the two sentences can be calculated based on the word vector similarity between the two sentences. The specified number is dynamically determined based on the preset length threshold and the length of the extracted first sentence.

[0112] For example, the sentence correlation degree calculation method in the prior art can be used to calculate the correlation degree between the sentences in the legal document based on the word vector, and the correlation degree is iteratively summed to obtain the importance value of each sentence. Among them, sentences with lower importance values ​​are sentences that are not closely related to the case. After that, the sentences with lower importance values ​​are eliminated, and the sentences in the legal document that are closely related to the case are retained. In this way, all key information in the legal document can be effectively retained and interference information can be eliminated.

[0113] On the premise of retaining key information, ensuring that the input length of the generative model is not too long can enable the generative model to better understand the key information of the legal document, avoid the legal model making one-sided judgments due to the length of the document content, and improve the accuracy of extracting the cause of action. At the same time, it reduces the text processing time of the generative model and saves computing resources.

[0114] Based on the generated prompt words, the generative model can be asked to output the first-level case category of a certain part of the legal document text in the prompt words in the form of a dialogue. After the generative model fully understands the legal document text in the input prompt words, it outputs the name of the first-level case category corresponding to the legal document text.

[0115] In the embodiments of the present application, in order to avoid the illusion problem that may exist in the name of the first-level case category generated by the large model, that is, the name of the generated first-level case category may be a case name with similar semantics but not completely accurate, it is necessary to align the name of the first-level case category generated by the large model with the real name of the preset first-level case category. If the name of the generated first-level case category is exactly the same as the real name of a first-level case category, the generated name is directly output; if the name of the generated first-level case category is not exactly the same as the real names of all first-level case categories, it is necessary to calculate the similarity between the generated name and each real name, and use the real name with the highest similarity to the generated name as the name of the first-level case category corresponding to the legal document.

[0116] Among them, the actual name of the preset first-level case category is the name of the first-level case category commonly used in the legal field.

[0117] Optionally, based on the real names of preset first-level case categories, the names of the generated first-level case categories are aligned to obtain the first-level case categories that match the legal document, including: respectively calculating the similarities between the real names of each preset first-level case category and the names of the generated first-level case categories; and taking the first-level case category with the real name having the greatest similarity as the first-level case category that matches the legal document.

[0118] Optionally, the similarity may be represented by a normalized Levenshtein distance.

[0119] For example, you can use the following formula to calculate the similarity between two names:

[0120]

[0121] Among them, S 1 With S 2 The Normalized LevenshteinDistance represents the generated name string S 1 and the real name string S 2 The normalized Levenshtein distance between the name string S 1 and the real name string S 2 The minimum edit distance between 1 ),len(S 2 )) represents the name string S 1 and the real name string S 2 The maximum character length of NormalizedLevenshtein Distance. The value range of NormalizedLevenshtein Distance is between 0 and 1, where 0 means that the two strings are exactly the same and 1 means that the two strings are completely different. When the value of Normalized Levenshtein Distance is 0, it can be considered that the generated name is exactly the same as the real name. When the value of Normalized Levenshtein Distance is 1, it can be considered that the generated name is completely different from the real name.

[0122] The following describes the method of constructing a keyword library.

[0123] For example, first collect a large number of legal documents such as civil cases and administrative cases with known first- and second-level case categories. Then, use a large model to batch extract keywords from each legal document, and classify and count the high-frequency keywords extracted from the legal documents of each case category according to the first-level case category of the legal document. Then, according to the principle of non-repetition of keywords between second-level case categories, deduplicate the high-frequency keywords in the legal documents of each second-level case category to obtain the high-frequency keywords corresponding to each second-level case category.

[0124] Furthermore, in order to ensure the integrity of the vocabulary, professional legal professionals can also screen and supplement the high-frequency keywords corresponding to each secondary case category to ensure that the keywords of different case categories are accurate, the keywords between different case categories are not repeated, and the vocabulary is complete and can cover all common keywords.

[0125] Finally, a secondary case category label is set for the keyword according to the secondary case category corresponding to the high-frequency keyword, and a primary case category label is set for the keyword according to the secondary case category label.

[0126] By refining the case categories corresponding to the keywords into secondary case categories in the form of hierarchical labels, the matching accuracy can be improved, the keyword recall rate can be increased, and the keyword library maintenance can be facilitated.

[0127] In some optional embodiments, a discrimination weight can be set for each keyword according to the confidence that the keyword can be determined as the case category. For example, when constructing a keyword library, by counting the frequency of occurrence of each keyword in a large number of legal documents of each case category, the higher the frequency of occurrence of the keyword in a legal document of a certain case category, the higher the confidence of the keyword in discriminating a high case category. That is, the appearance of some keywords can more confidently determine that a legal document is a certain case category, and these keywords are given a larger discrimination weight.

[0128] The contents of the constructed keyword library can be Figure 2 shown.

[0129] The following describes the training method of the case classification model.

[0130] First, construct training samples for training the case classification model.

[0131] Optionally, the full texts of several legal documents and the actual first-level case categories corresponding to the legal documents may be obtained, and the legal documents may be screened to screen out some legal documents whose number of keywords is insufficient or whose sum of the judgment weights of the keywords and / or the difference between the sum of the weights of the keywords inside and outside the first-level case category is not sufficient to determine the first-level case category.

[0132] Then, the full text of each legal document is segmented, stop words are removed, and preprocessing is added to distinguish the start and end positions of sentences to obtain the text sequence corresponding to each legal document. After that, the text sequence is used as sample data, and the real first-level case category corresponding to the legal document generating the text sequence is used as the sample label to generate a training sample corresponding to each legal document, thereby obtaining a plurality of training samples.

[0133] Afterwards, based on the constructed training samples, a BERT-based case classification model is trained. In an embodiment of the present application, the case classification model is a multi-classification model. Taking the example that the first-level case classification of civil legal documents includes eleven major categories, the case classification model trained for civil legal documents can be an eleven-classification model.

[0134] Since the position encoding of the BERT model is randomly initialized and needs to be trained, the standard BERT model has an input length limit of 512, and the content of common legal documents varies in length, and the longest can reach thousands of words. In order to perform case reasoning on legal documents of different lengths, in the embodiment of the present application, during the training of the case classification model, a design idea of ​​hierarchical decomposition position encoding is proposed, and the inter-group encoding index and the intra-group encoding index are calculated based on the absolute position encoding of the pre-trained model, thereby constructing a relative position encoding, so that the case classification model can be used without increasing the video memory occupied during reasoning, but can be applied to longer text lengths.

[0135] During the case classification model training process, hierarchical decomposition position coding is used to encode the text sequence used as sample data in the training sample. The specific method can be found in the description of the reasoning stage in the previous article, which will not be repeated here.

[0136] Furthermore, by classifying and mapping the encoding vectors obtained by hierarchical position encoding, we can obtain the predicted probability that the text sequence in the sample data matches each of the 11 first-level case cause categories.

[0137] Then, referring to the training method of the general BERT model, the classification loss of the case classification model is calculated according to the predicted probability and sample labels, and the case classification model is iteratively trained with the goal of optimizing the loss until the preset convergence conditions are met.

[0138] Optionally, for the trained case classification model, the performance of the trained case classification model can be evaluated through a reserved test set. The accuracy, precision, recall, F1 score and other indicators of the case classification model on the test set are calculated to better optimize the case classification model.

[0139] The iterative training process of the case classification model refers to the existing technology and will not be repeated here.

[0140] The case category acquisition method disclosed in the embodiment of the present application obtains a keyword matching result by matching a legal document with a keyword in a preset keyword library; obtains a first case recognition result based on the keyword matching result; on the other hand, the legal document is classified based on a pre-trained case classification model to obtain a second case recognition result; thereafter, the first case recognition result and the second case recognition result are fused to perform case recognition to obtain a fused recognition result, which is used to indicate: fusion recognition failure, or the first-level case category matched by the legal document can be matched to a more relevant first-level case category by comprehensively comparing the case recognition results obtained by different methods, thereby effectively reducing the error rate of the obtained first-level case category.

[0141] Furthermore, when the case category cannot be obtained through the keyword recognition results and the case classification model, the first-level case category matching the legal document is further generated through the pre-trained generative large model to identify the case of legal document types not covered by the keyword library, thereby ensuring full coverage of legal documents that need to be identified, and greatly improving the recall rate of the first-level case category.

[0142] Furthermore, by aligning the names of the case categories generated by the generative big model based on the real names of the preset first-level case categories, the problem that the case categories generated by the generative big model may produce hallucinations can be effectively solved, thereby improving the accuracy of case category acquisition.

[0143] In some optional embodiments, when the first case cause identification result is empty, a fusion identification result indicating that the fusion identification has failed may be obtained, thereby triggering a subsequent step of extracting the first-level case cause category corresponding to the legal document through a generative big model.

[0144] Reference Figure 3 The case category acquisition method disclosed in the embodiment of the present application includes: step 310 to step 380.

[0145] Step 310, matching the legal document with the keywords in the preset keyword library to obtain keyword matching results.

[0146] Step 320: Obtain the first case cause identification result based on the keyword matching result.

[0147] Step 330 , determine whether the first case cause identification result includes a candidate first-level case cause category. If so, jump to step 340 ; otherwise, jump to step 370 .

[0148] Optionally, after obtaining the first case cause identification result according to the keyword matching result, it also includes: determining whether the first case cause identification result includes a candidate first-level case cause category; in response to not including the candidate first-level case cause category, generating a first-level case cause category matching the legal document through a pre-trained generative large model; in response to including the candidate first-level case cause category, jumping to executing the pre-trained case cause classification model to classify the legal document to obtain a second case cause identification result step.

[0149] Step 340: classify the legal document based on the pre-trained case classification model to obtain a second case recognition result.

[0150] Step 350, integrating the first case cause identification result and the second case cause identification result to perform case cause identification and obtain a fusion identification result, wherein the fusion identification result is used to indicate: fusion identification failure, or the first-level case cause category matched by the legal document.

[0151] Step 360 , determining whether the fusion recognition result indicates that the fusion recognition fails, if so, jump to step 370 , otherwise, jump to step 380 .

[0152] Step 370, generating a first-level case category matching the legal document through a pre-trained generative big model.

[0153] In some embodiments of the present application, in response to the fusion recognition result indicating that the fusion recognition failed, a primary case category matching the legal document is generated by a pre-trained generative large model.

[0154] Thereafter, execute step 380.

[0155] Step 380, end the current case identification operation.

[0156] In some embodiments of the present application, in response to the fusion recognition result indicating a primary case category that matches the legal document, the current case recognition operation is terminated.

[0157] Among them, the specific implementation methods of step 310, step 320, step 340, step 350 and step 370 refer to the relevant description in the previous embodiments, which will not be repeated here.

[0158] In an embodiment of the present application, by determining whether the first case cause recognition result includes a candidate first-level case cause category, and directly generating a first-level case cause category matching the legal document through a pre-trained generative large model when the first case cause recognition result does not include a candidate first-level case cause category, the efficiency of obtaining the case cause category can be improved.

[0159] The present application also discloses a device for obtaining a case category, such as Figure 4 As shown, the device comprises:

[0160] The keyword matching module 410 is used to match the legal document with the keywords in the preset keyword library to obtain the keyword matching results;

[0161] A first case cause recognition result acquisition module 420, configured to acquire a first case cause recognition result according to the keyword matching result;

[0162] A second case cause recognition result acquisition module 430 is used to classify the legal document based on a pre-trained case cause classification model to obtain a second case cause recognition result;

[0163] A fusion recognition result acquisition module 440 is used to fuse the first case cause recognition result and the second case cause recognition result to perform case cause recognition and obtain a fusion recognition result, wherein the fusion recognition result is used to indicate: fusion recognition failure, or the first-level case cause category matched by the legal document;

[0164] A first judgment output module 450 is used to terminate the current case cause identification operation in response to the fusion recognition result indicating that the legal document matches the first-level case cause category;

[0165] The first judgment output module 450 is further used to generate a first-level case category matching the legal document through a pre-trained generative large model in response to the fusion recognition result indicating that the fusion recognition failed.

[0166] Optional, such as Figure 5 As shown, after obtaining the first case cause recognition result according to the keyword matching result, the device further includes:

[0167] A judgment module 425 is used to determine whether the first case cause identification result includes a candidate first-level case cause category;

[0168] The second judgment output module 426 is further used to generate a first-level case category matching the legal document through a pre-trained generative large model in response to not including the candidate first-level case category;

[0169] The judgment module 425 is also used to jump to the step of executing the classification process of the legal document based on the pre-trained case classification model in response to including a candidate first-level case category, and obtain a second case recognition result.

[0170] Optionally, the keyword matching result includes: the keywords included in the legal document, the following information of each keyword: the number of occurrences in the legal document, the corresponding first-level case category, and the discrimination weight. The first case identification result acquisition module 420 is further used to:

[0171] According to the primary case category and the number of occurrences corresponding to the keyword, obtaining the target primary case category of the keyword distribution included in the legal document and the number of keywords corresponding to each target primary case category;

[0172] According to the discrimination weight, the number of occurrences and the corresponding primary case category of each keyword, the sum of the discrimination weights of the keywords corresponding to the same target primary case category is obtained as the first weight corresponding to the corresponding target primary case category;

[0173] In response to the number of the target first-level case category being 1, and the number of keywords and the first weight corresponding to the target first-level case category satisfying a first judgment condition, the target first-level case category is added to the first case identification result as a candidate first-level case category, wherein the first judgment condition is: the number of keywords corresponding to the target first-level case category satisfies a preset number threshold condition, and the first weight corresponding to the target first-level case category satisfies a preset weight sum threshold condition;

[0174] In response to the number of the target first-level case category being 1, and the number of keywords and the first weight corresponding to the target first-level case category not satisfying the first judgment condition, setting the first case identification result to be empty;

[0175] In response to the number of the target first-level case cause categories being greater than 1, a first case cause recognition result is obtained according to the number of keywords corresponding to the target first-level case cause categories and a first weight corresponding to the target first-level case cause categories.

[0176] Optionally, obtaining the first case cause recognition result according to the number of keywords corresponding to the target first-level case cause category and the first weight corresponding to the target first-level case cause category includes:

[0177] In response to the number of keywords corresponding to the first target first-level case category and the first weight corresponding to the target first-level case category satisfying the second judgment condition, adding the first target first-level case category as a candidate first-level case category to the first case recognition result;

[0178] In response to the number of keywords corresponding to the first target first-level case category and the first weight corresponding to the target first-level case category not satisfying the second judgment condition, giving up obtaining the first case identification result corresponding to the first target first-level case category;

[0179] Among them, the second judgment condition is: the number of keywords corresponding to the first target first-level case category meets the preset number threshold condition, and the first weight corresponding to the first target first-level case category meets the preset weight sum threshold condition, and the difference between the first weight of the first target first-level case category and the target weight meets the preset weight difference threshold condition, and the target weight is: the cumulative sum of the first weights of the second target first-level case category, and the first target first-level case category and the second target first-level case category are different target first-level case categories.

[0180] Optionally, the first case cause recognition result includes: candidate first-level case cause categories, and the second case cause recognition result includes: preset probabilities corresponding to each first-level case cause category. The fusion recognition result acquisition module 440 is further used to:

[0181] In response to the first case cause recognition result and the second case cause recognition result satisfying a third judgment condition, the first-level case cause category corresponding to the maximum probability in the probabilities is used as the first-level case cause category of the legal document to obtain a fusion recognition result, wherein the third judgment condition is: the maximum probability satisfies a preset probability threshold condition, and the first-level case cause category corresponding to the maximum probability is a candidate first-level case cause category included in the first case cause recognition result;

[0182] In response to the first case cause recognition result and the second case cause recognition result not satisfying the third judgment condition, a fusion recognition result indicating a fusion recognition failure is obtained.

[0183] Optionally, the first-level case category matching the legal document is generated by the pre-trained generative big model, including:

[0184] Based on the legal document, generating prompt words;

[0185] Based on the prompt word, trigger the pre-trained generative model to generate the name of the first-level case category matching the legal document;

[0186] Based on the real name of the preset first-level case category, the name of the generated first-level case category is aligned to obtain the first-level case category that matches the legal document.

[0187] Optionally, the second case cause recognition result acquisition module 430 is further used to:

[0188] Preprocessing the legal document to obtain a text sequence marked with sentence starts;

[0189] The text sequence is input into a pre-trained case classification model, and the text sequence is subjected to hierarchical decomposition and position encoding processing through the case classification model to obtain an encoding vector corresponding to the text sequence, and classification mapping is performed based on the encoding vector to obtain a second case recognition result.

[0190] The case category acquisition device disclosed in the embodiment of the present application is used to implement the case category acquisition method described in the embodiment of the present application. The specific implementation methods of each module of the device will not be repeated here, and reference can be made to the specific implementation methods of the corresponding steps in the method embodiment.

[0191] The case category acquisition device disclosed in the embodiment of the present application obtains a keyword matching result by matching a legal document with a keyword in a preset keyword library; obtains a first case recognition result based on the keyword matching result; on the other hand, the legal document is classified based on a pre-trained case classification model to obtain a second case recognition result; thereafter, the first case recognition result and the second case recognition result are fused to perform case recognition to obtain a fused recognition result, which is used to indicate: fusion recognition failure, or the first-level case category matched by the legal document can be matched to a more relevant first-level case category by comprehensively comparing the case recognition results obtained by different methods, thereby effectively reducing the error rate of the obtained first-level case category.

[0192] Furthermore, when the case category cannot be obtained through the keyword recognition results and the case classification model, the first-level case category matching the legal document is further generated through the pre-trained generative large model to identify the case of legal document types not covered by the keyword library, thereby ensuring full coverage of legal documents that need to be identified, and greatly improving the recall rate of the first-level case category.

[0193] Furthermore, by aligning the names of the case categories generated by the generative big model based on the real names of the preset first-level case categories, the problem that the case categories generated by the generative big model may produce hallucinations can be effectively solved, thereby improving the accuracy of case category acquisition.

[0194] Each embodiment in this specification is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. 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.

[0195] The above is a detailed introduction to a method and device for obtaining case category provided by the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and a core idea. At the same time, for those skilled in the art, according to the idea of ​​the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.

[0196] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.

[0197] The various component embodiments of the present application can be implemented in hardware, or in software modules running on one or more processors, or in a combination thereof. It should be understood by those skilled in the art that a microprocessor or digital signal processor (DSP) can be used in practice to implement some or all functions of some or all components in the electronic device according to the embodiment of the present application. The present application can also be implemented as a device or apparatus program (e.g., computer program and computer program product) for executing part or all of the methods described herein. Such a program implementing the present application can be stored on a computer-readable medium, or can have the form of one or more signals. Such a signal can be downloaded from an Internet website, or provided on a carrier signal, or provided in any other form.

[0198] For example, Figure 6An electronic device that can implement the method according to the present application is shown. The electronic device can be a PC, a mobile terminal, a personal digital assistant, a tablet computer, etc. The electronic device traditionally includes a processor 610 and a memory 620 and a program code 630 stored on the memory 620 and can be run on the processor 610, and the processor 610 implements the method described in the above embodiment when executing the program code 630. The memory 620 can be a computer program product or a computer-readable medium. The memory 620 can be an electronic memory such as a flash memory, an EEPROM (electrically erasable programmable read-only memory), an EPROM, a hard disk or a ROM. The memory 620 has a storage space 6201 for the program code 630 of a computer program for executing any method step in the above method. For example, the storage space 6201 for the program code 630 can include various computer programs for implementing the various steps in the above method respectively. The program code 630 is a computer-readable code. These computer programs can be read from one or more computer program products or written into the one or more computer program products. These computer program products include program code carriers such as hard disks, compact disks (CDs), memory cards or floppy disks. The computer program includes a computer readable code, and when the computer readable code is executed on an electronic device, the electronic device is caused to execute the method according to the above embodiment.

[0199] The embodiment of the present application also discloses a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the steps of the method for obtaining the case category as described in the embodiment of the present application are implemented.

[0200] Such a computer program product may be a computer-readable storage medium, which may have a computer-readable storage medium having a Figure 6 The memory 620 in the electronic device shown in the figure is similar to the storage segment, storage space, etc. The program code can be compressed and stored in the computer-readable storage medium in an appropriate form. The computer-readable storage medium is generally as shown in the reference Figure 7 The portable or fixed storage unit. Generally, the storage unit includes computer readable code 630', which is a code read by a processor. When the code is executed by the processor, each step in the method described above is implemented.

[0201] The term "one embodiment", "embodiment" or "one or more embodiments" herein means that a particular feature, structure or characteristic described in conjunction with the embodiment is included in at least one embodiment of the present application. In addition, please note that the examples of the term "in one embodiment" here do not necessarily all refer to the same embodiment.

[0202] In the description provided herein, a large number of specific details are described. However, it is understood that the embodiments of the present application can be practiced without these specific details. In some instances, well-known methods, structures and techniques are not shown in detail so as not to obscure the understanding of this description.

[0203] In the claims, any reference signs placed between brackets shall not be construed as limiting the claims. The word "comprising" does not exclude the presence of elements or steps not listed in the claims. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. The present application may be implemented by means of hardware comprising several different elements and by means of a suitably programmed computer. In a unit claim enumerating several means, several of these means may be embodied by the same item of hardware. The use of the words first, second, and third etc. does not indicate any order. These words may be interpreted as names.

[0204] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims

1. A method for obtaining case category, characterized in that: The method comprises: Match the legal document with the keywords in the preset keyword library to obtain keyword matching results; Obtaining a first case cause recognition result according to the keyword matching result; Classify the legal document based on a pre-trained case classification model to obtain a second case recognition result; fusing the first case cause recognition result and the second case cause recognition result to perform case cause recognition, and obtaining a fusion recognition result, wherein the fusion recognition result is used to indicate: a fusion recognition failure, or a primary case cause category matched by the legal document; In response to the fusion recognition result indicating that the legal document matches the primary case category, ending the current case recognition operation; In response to the fusion recognition result indicating that the fusion recognition fails, generating a primary case category matching the legal document through a pre-trained generative large model; The first-level case category for matching the legal document generated by the pre-trained generative big model includes: Based on the legal document, generating prompt words; Based on the prompt word, trigger the pre-trained generative model to generate the name of the first-level case category matching the legal document; Based on the real name of the preset first-level case category, the name of the generated first-level case category is aligned to obtain the first-level case category that matches the legal document.

2. The method according to claim 1, characterized in that After obtaining the first case cause identification result according to the keyword matching result, the method further includes: Determining whether the first case cause identification result includes a candidate first-level case cause category; In response to not including the candidate first-level case category, generating a first-level case category matching the legal document through a pre-trained generative big model; In response to including the candidate first-level case category, the process jumps to the step of executing the classification process of the legal document based on the pre-trained case classification model to obtain the second case recognition result step.

3. The method according to claim 1, characterized in that The keyword matching result includes: the keywords included in the legal document, the following information of each keyword: the number of occurrences in the legal document, the corresponding first-level case category, and the discrimination weight. The first case identification result is obtained according to the keyword matching result, including: According to the primary case category and the number of occurrences corresponding to the keyword, obtaining the target primary case category of the keyword distribution included in the legal document and the number of keywords corresponding to each target primary case category; According to the discrimination weight, the number of occurrences and the corresponding primary case category of each keyword, the sum of the discrimination weights of the keywords corresponding to the same target primary case category is obtained as the first weight corresponding to the corresponding target primary case category; In response to the number of the target first-level case category being 1, and the number of keywords and the first weight corresponding to the target first-level case category satisfying a first judgment condition, the target first-level case category is added to the first case identification result as a candidate first-level case category, wherein the first judgment condition is: the number of keywords corresponding to the target first-level case category satisfies a preset number threshold condition, and the first weight corresponding to the target first-level case category satisfies a preset weight sum threshold condition; In response to the number of the target first-level case category being 1, and the number of keywords and the first weight corresponding to the target first-level case category not satisfying the first judgment condition, setting the first case identification result to be empty; In response to the number of the target first-level case cause categories being greater than 1, a first case cause recognition result is obtained according to the number of keywords corresponding to the target first-level case cause categories and a first weight corresponding to the target first-level case cause categories.

4. The method according to claim 3, characterized in that The obtaining the first case cause recognition result according to the number of keywords corresponding to the target first-level case cause category and the first weight corresponding to the target first-level case cause category includes: In response to the number of keywords corresponding to the first target first-level case category and the first weight corresponding to the target first-level case category satisfying the second judgment condition, adding the first target first-level case category as a candidate first-level case category to the first case recognition result; In response to the number of keywords corresponding to the first target first-level case category and the first weight corresponding to the target first-level case category not satisfying the second judgment condition, giving up obtaining the first case identification result corresponding to the first target first-level case category; Among them, the second judgment condition is: the number of keywords corresponding to the first target first-level case category meets the preset number threshold condition, and the first weight corresponding to the first target first-level case category meets the preset weight sum threshold condition, and the difference between the first weight of the first target first-level case category and the target weight meets the preset weight difference threshold condition, and the target weight is: the cumulative sum of the first weights of the second target first-level case category, and the first target first-level case category and the second target first-level case category are different target first-level case categories.

5. The method according to claim 1, characterized in that The first case cause recognition result includes: candidate first-level case cause categories, and the second case cause recognition result includes: preset probabilities corresponding to each first-level case cause category. The first case cause recognition result and the second case cause recognition result are integrated to perform case cause recognition, and a fusion recognition result is obtained, including: In response to the first case cause recognition result and the second case cause recognition result satisfying a third judgment condition, the first-level case cause category corresponding to the maximum probability in the probabilities is used as the first-level case cause category of the legal document to obtain a fusion recognition result, wherein the third judgment condition is: the maximum probability satisfies a preset probability threshold condition, and the first-level case cause category corresponding to the maximum probability is a candidate first-level case cause category included in the first case cause recognition result; In response to the first case cause recognition result and the second case cause recognition result not satisfying the third judgment condition, a fusion recognition result indicating a fusion recognition failure is obtained.

6. The method according to claim 1, characterized in that The pre-trained case classification model is used to classify the legal document to obtain a second case recognition result, including: Preprocessing the legal document to obtain a text sequence marked with sentence starts; The text sequence is input into a pre-trained case classification model, and the text sequence is subjected to hierarchical decomposition and position encoding processing through the case classification model to obtain an encoding vector corresponding to the text sequence, and classification mapping is performed based on the encoding vector to obtain a second case recognition result.

7. A device for obtaining case category, characterized in that: The device comprises: A keyword matching module is used to match legal documents with keywords in a preset keyword library to obtain keyword matching results; A first case cause recognition result acquisition module, used to acquire a first case cause recognition result according to the keyword matching result; A second case cause recognition result acquisition module, used to classify the legal document based on a pre-trained case cause classification model to obtain a second case cause recognition result; a fusion recognition result acquisition module, used for fusing the first case cause recognition result and the second case cause recognition result to perform case cause recognition and obtain a fusion recognition result, wherein the fusion recognition result is used to indicate: fusion recognition failure, or the first-level case cause category matched by the legal document; A first judgment output module, configured to terminate the current case cause identification operation in response to the fusion recognition result indicating that the legal document matches the first-level case cause category; The first judgment output module is further configured to generate a first-level case category matching the legal document through a pre-trained generative large model in response to the fusion recognition result indicating that the fusion recognition fails; The first-level case category for matching the legal document generated by the pre-trained generative big model includes: Based on the legal document, generating prompt words; Based on the prompt word, trigger the pre-trained generative model to generate the name of the first-level case category matching the legal document; Based on the real name of the preset first-level case category, the name of the generated first-level case category is aligned to obtain the first-level case category that matches the legal document.

8. An electronic device comprising a memory, a processor, and a program code stored in the memory and executable on the processor, wherein: When the processor executes the program code, the method for obtaining the case category described in any one of claims 1 to 6 is implemented.

9. A computer-readable storage medium having program code stored thereon, characterized in that: When the program code is executed by a processor, the steps of the case category acquisition method described in any one of claims 1 to 6 are implemented.