A case retrieval method based on multiple models

By employing a multi-model approach based on the BERT model, the problems of dataset diversity and semantic gap in multimodal text similarity detection are solved, enabling accurate retrieval and case recommendation of multimodal text data, and improving the accuracy and efficiency of retrieval.

CN117093673BActive Publication Date: 2026-06-09UNIV OF SCI & TECH OF CHINA

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
UNIV OF SCI & TECH OF CHINA
Filing Date
2023-09-04
Publication Date
2026-06-09

Smart Images

  • Figure CN117093673B_ABST
    Figure CN117093673B_ABST
Patent Text Reader

Abstract

The present application relates to the field of artificial intelligence, in particular to a case retrieval method based on multiple models. Various multi-source data are collected and integrated; the semantic dependency relationship between the text fragments of the contradiction is captured by using Bert, and the similarity of the case data is calculated by using the BM25 algorithm; a model is trained by Bert according to twelve types of classifiers, and at the same time, a model is retrained for the overall similarity model training. The similarity model constructed by combining the case classification model in the prior art and the present application completes the accurate case retrieval of diversified and long-length contradiction dispute data. The legal case data of the present application is more specific and perfect, contains sufficient legal knowledge, can cope with the change of legal rules, the unification of diversified legal data, accurate collection, efficient auxiliary analysis of legal cases and resolution work. The present application is more accurate in calculating the similarity, and the relevant category of legal cases is recommended accurately.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of artificial intelligence, and more specifically to a case retrieval method based on multiple models. Background Technology

[0002] In recent years, machine learning has made groundbreaking progress in the field of data retrieval technology, leading to revolutionary changes in information retrieval, search engines, and knowledge management. Traditional data retrieval methods often face the challenges of massive data volumes and increasing diversity, while machine learning technology, with its powerful pattern recognition and feature learning capabilities, has brought new possibilities to data retrieval, greatly improving retrieval efficiency and the accuracy of results.

[0003] Recent research has demonstrated the superior performance of deep learning in data retrieval, with text data retrieval often based on text similarity. Early work on text similarity focused primarily on traditional feature engineering methods such as TF-IDF and Word Embeddings. While these methods performed well in certain scenarios, they struggled to capture the complex semantic and syntactic relationships. Following this, Mikolov et al. proposed the Word2Vec model, representing words as continuous vectors to map word semantics. This provided a better foundation for text similarity calculation, enabling researchers to leverage word vector similarity to calculate the similarity between sentences or documents. The rise of attention mechanisms further enhanced the performance of text similarity calculation. By introducing attention, models can focus more on important parts of the input text, thus better capturing semantic information. Subsequently, Zamani et al. proposed a deep neural network-based retrieval model that accurately models the semantic association between queries and documents, achieving more precise document matching. Furthermore, advancements in natural language processing have also brought new possibilities to data retrieval. The advent of pre-trained language models, such as BERT, led Devlin et al. to improve semantic understanding and query processing in information retrieval based on BERT.

[0004] Despite significant progress in multimodal text similarity detection applications in the field of data retrieval technology, some problems and challenges still need to be addressed:

[0005] Insufficient dataset diversity: Training a multimodal text similarity detection model requires a large amount of multimodal data, including text, images, and audio. However, obtaining rich and diverse cross-modal datasets remains a challenge, as labeling this data requires significant time and expertise.

[0006] Model generalization ability: Multimodal text similarity detection models perform well on the training set, but often struggle to generalize to new data scenarios in real-world applications. The model may produce inaccurate predictions on unseen data, especially when there are significant differences in the distribution of cross-modal data.

[0007] Semantic gap between modalities: Semantic differences between different modalities can make it difficult for models to capture the true similarity between cross-modal data. For example, the semantic representations of text and images can differ greatly, and effectively building semantic bridges between modalities is a complex problem. Summary of the Invention

[0008] To address the above problems, this invention provides a multi-model-based case retrieval method.

[0009] The method includes:

[0010] Step 1: Prepare the training set. The training set consists of conflict texts. Each conflict text includes a baseline case Q and several candidate case d. Each baseline case Q or several candidate case d consists of fields.

[0011] Step 2: Divide the input training data into I segments, each segment having a length not exceeding 512. Input the i-th segment into the BERT model and extract the semantic features q of the i-th segment. i , i∈[1, I];

[0012] Step 3: Based on the semantic features q of each segment i Calculate the similarity score Score(Q,d) between the baseline case Q and the candidate case d;

[0013] Step 4: Input Score(Q, d) into BERT for training to obtain the overall similarity model;

[0014] Step 5: Locate relevant fields for the twelve predefined dispute dimension types, define the relevant field content of the target dispute dimension type of the baseline case as the baseline field Q′, and the relevant field content of the target dispute dimension type of the candidate case as the candidate field d′; calculate the similarity score Score(Q′, d′) between the baseline field Q′ and the candidate field d′.

[0015] Step 6: Input the Score(Q′, d′) of each dispute dimension type into BERT for training to obtain twelve category similarity models;

[0016] Step 7: Based on the case classification model, the overall similarity model, and the twelve-category similarity model, return the case data to the user's input query data. The returned case data is sorted from highest to lowest similarity.

[0017] Furthermore, step one specifically includes:

[0018] The original data consisted of local public security bureaus’ data on mediation of disputes, police reports, and open-source legal judgments from the internet.

[0019] Each piece of raw data is converted into a uniform format composed of predefined fields;

[0020] One case is randomly selected from the converted data as the baseline case, and 100 cases are randomly selected as candidate cases for the baseline case. Each baseline case and its corresponding candidate cases constitute a text of conflict and dispute.

[0021] A training set is composed of several conflicting and disputed texts.

[0022] Furthermore, step three specifically refers to the semantic features q of each segment. i The similarity score Score(Q,d) between the baseline case Q and the candidate case d is calculated using the BM25 algorithm.

[0023] Furthermore, step three specifically includes:

[0024] The similarity score between the baseline case fact Q and the candidate case fact d is Score(Q, d):

[0025]

[0026] Among them, W i The semantic feature q of the i-th segment i The weights, R(q) i d) represents the semantic feature q of the i-th segment. i The relevance score with each candidate case d;

[0027] The semantic features q of the i-th segment i weight W i for:

[0028]

[0029] Where N represents the total number of feature word vectors in candidate case d, n(q i ) represents the feature word vectors in candidate case d and q i The number of similar items;

[0030]

[0031]

[0032] Among them, f i For q i The frequency of occurrence in d, For q i The frequency of occurrence in Q, avg d represents the average number of feature word vectors in all d, k1, k2, and b are all adjustment factors, and K represents the frequency of occurrence of feature word vectors in candidate case d relative to q. i Irrelevant regulatory factors.

[0033] Furthermore, step seven specifically refers to:

[0034] When a user only inputs a case, the system calculates the similarity between the case information in the case database and the user's input case information using an overall similarity model, and then displays the case information in the case database to the user in descending order of similarity. If the user inputs both a case and a question, the system obtains the question category corresponding to the user's input question based on the existing case classification model, calls the corresponding category similarity model based on the question category, calculates the similarity between the case information in the case database and the user's input case information using the category similarity model, and then displays the case information in the case database to the user in descending order of similarity.

[0035] Furthermore, step two specifically includes:

[0036] The input training data is divided into I segments, each segment having a length not exceeding 512. The text of the i-th segment is divided into words, and each word is converted into its corresponding ID in the vocabulary of the word segmenter. These IDs are then combined into an input sequence according to the order of the corresponding words in the text.

[0037] Initialize the words in the input sequence as word embeddings, paragraph embeddings, and position embeddings, and add the three together to form the input embedding vector of the word;

[0038] The input embedding vector is updated through multiple model layers with self-attention mechanisms to obtain an embedding representation of each word with contextual semantic information;

[0039] The embedding representation corresponding to the last layer of the first special word [CLS] is used as the semantic feature q of the i-th segment in the conflict text. i

[0040] One or more technical solutions provided in the embodiments of this application have at least the following technical effects or advantages:

[0041] This invention relates to a specific data analysis method that, in conjunction with actual laws and regulations, corresponding lawyer advice, case judgments, and corresponding module inputs, achieves accurate calculation of similarity and obtains a similarity ranking of bills under the same classification conditions.

[0042] This invention employs a multi-model-specific combination approach and utilizes the BM25 algorithm to achieve accurate similarity calculation of cases, thereby gaining a more accurate understanding of user needs, enabling users to more precisely understand the case details, and obtaining a ranking of similar cases for the input case.

[0043] This invention uses sufficient data to support the data workstation and is constantly updated, which can better ensure that users have full access to data and a more accurate understanding of the case. Attached Figure Description

[0044] Figure 1 The original data format provided in the embodiments of the present invention;

[0045] Figure 2 The format of a conflicting text in the training set provided in the embodiments of the present invention;

[0046] Figure 3 The training flowcharts for the overall similarity model and the category similarity model provided in the embodiments of the present invention are shown below.

[0047] Figure 4 A flowchart for case retrieval provided in an embodiment of the present invention. Detailed Implementation

[0048] The present invention will be described in detail below with reference to the accompanying drawings and specific embodiments. Before describing the technical solutions of each embodiment of the present invention in detail, the terms and terms involved will be explained. In this specification, components with the same name or the same reference numerals represent similar or the same structures and are limited to illustrative purposes.

[0049] This invention collects and integrates various multi-source data; uses a BERT pre-trained language model to model lexical units with contextual semantic information and feature representations with finite text length; captures semantic dependencies between segments of conflicting texts through a self-attention mechanism; and calculates the similarity of case data using the BM25 algorithm. The similarity model is trained using the BM25 algorithm with twelve classifiers, one model for each classifier trained by the BERT pre-trained model, and another model for the overall data, resulting in a total of thirteen models. This completes the training of the similarity model. By merging existing case classification models with the similarity model constructed in this invention, accurate case retrieval of diverse and lengthy conflicting data is achieved.

[0050] I. Data Collection and Integration

[0051] This invention predefines twelve types of dispute dimensions based on twelve types of dispute descriptions provided by our partner, East China University of Political Science and Law.

[0052] The data sources of this invention include local public security bureau's dispute mediation data, police report data, and open-source legal judgment documents from the internet. These raw data vary in their writing format, expression method, and field composition, such as... Figure 1 As shown. Use a tool to convert each piece of data in the original data into a uniform format composed of predetermined fields, such as... Figure 1 In the data, field s11 represents the dispute category, field s23 represents the basic facts of the case, field s25 represents the cause of the case, and fields s26 and s27 represent the proposed handling plan. From the converted data, one case is randomly selected as the baseline case, and 100 cases are randomly selected as candidate cases for that baseline case. Each baseline case and its corresponding candidate cases constitute a dispute text, such as... Figure 2 As shown, the training set consists of multiple conflicting and disputed texts.

[0053] II. Constructing Semantic Features of Conflict and Dispute Texts Based on the BERT Model

[0054] The length of the conflicting texts in the training set is usually greater than the input sequence length limit of 512 for the BERT model. The conflicting texts are segmented into I segments of no more than 512 words each, based on the 512-word sequence length. One segment is used as input data at a time.

[0055] By using the WordPiece encoding method for word segmentation, the text corresponding to the input data is divided into words or subwords. These words or subwords are then converted into corresponding IDs in the vocabulary of the word segmenter. These IDs are then combined into an input sequence according to the order of the corresponding words or subwords in the text.

[0056] Each word in the input sequence is initialized with BERT to obtain three embedding representations: token embedding, paragraph embedding, and positional embedding. These three are added together to form the final embedding representation of the word, i.e., the input embedding vector e. Token embeddings are obtained by searching the vocabulary after word segmentation; paragraph embeddings are used to distinguish between two sentences, each with a fixed vector representation; and positional embeddings represent the position of the word within the sentence. The input embedding vector e is obtained by adding these three embedding representations.

[0057] BERT's model architecture is based on the Transformer Encoder design and is a multi-layered self-attention model. In each layer, the model computes a new embedding representation of the input word. The self-attention mechanism in each Transformer module allows the model to consider the contextual information of all words in the input sequence, capturing global dependencies within the input sequence. The fully connected layers further abstract and represent these dependencies through non-linear transformations of the input hidden states. For the *a*-th lexical in the input sequence, its embedding representation *v* has contextual semantic information. a It can be represented as:

[0058] v a =Attention(Q) a ,K a V a );

[0059] Where Attention represents self-attention mechanism, Q a K is the query vector for the a-th word. a It is the key vector of all words, V a It is the value vector of all lexical units.

[0060] The embedding representation corresponding to the last layer of the first special word "[CLS]" is used as the semantic feature q of the i-th segment in the conflicting text. i , i∈[1, I]. Specifically, the self-attention mechanism uses other words in the text to enhance the semantic representation of the target word, but the semantics of the target word itself still dominates. Therefore, through BERT's multi-layer structure, the embedding representation of each word not only integrates the information of all words, but can also accurately represent the semantics of the current word itself. The [CLS] bit itself has no semantics. After multi-layer calculation, what is obtained is the weighted average of all words after the self-attention mechanism. Compared with other normal words, [CLS] more appropriately represents the semantics of the entire conflicting text.

[0061] III. Modeling of the Overall Similarity Model

[0062] Let Q be the baseline case fact of a conflicting text in the training set, and let d be a candidate case fact of the baseline case fact Q.

[0063] The similarity score Score(Q, d) between the baseline case Q and the candidate case d is calculated using the BM25 algorithm:

[0064]

[0065] Among them, W i The semantic feature q of the i-th segment i The weights, R(q) i d) represents the semantic feature q of the i-th segment. i The relevance score with each candidate case d.

[0066] The semantic features q of the i-th segment i weight W i for:

[0067]

[0068] Where N represents the total number of feature word vectors in candidate case d, n(q i) represents the feature word vectors in candidate case d and q i The number of similar items.

[0069]

[0070]

[0071] Among them, f i For q i The frequency of occurrence in d, For q i The frequency of occurrence in Q, avg d represents the average number of feature word vectors in all d, k1, k2, and b are all adjustment factors, and K represents the frequency of occurrence of feature word vectors in candidate case d relative to q. i The larger the K value, the smaller the correlation score, which is the moderating factor for irrelevance.

[0072] Input Score(Q, d) into Bert for training to obtain the overall similarity model.

[0073] IV. Modeling of Category Similarity Models

[0074] To improve the accuracy and efficiency of case retrieval, while providing greater flexibility and interpretability, enabling users to conduct accurate and efficient searches for specific categories, it is also necessary to build a category similarity model.

[0075] In the training set, each field of a text representing a conflict or dispute corresponds to one or more dispute dimension types, such as... Figure 1 In this context, field s11 represents the dispute category, field s23 represents the basic facts of the case, field s25 represents the cause of the case, and fields s26 and s27 represent the contingency plan. The relevant fields corresponding to the target dispute dimension type are located based on this information.

[0076] Define the relevant field content of the target dispute dimension type of the baseline case of a conflict text in the training set as the baseline field Q′, and the relevant field content of the target dispute dimension type of a candidate case of the baseline case as the candidate field d′.

[0077] The similarity score Score(Q′, d′) between the baseline field Q′ and the candidate field d′ is calculated using the BM25 algorithm. The calculation method is similar to that of the similarity score Score(Q, d) between the baseline case information Q and the candidate case information d, and will not be repeated here. The Score(Q′, d′) is then input into BERT for training to obtain a category similarity model for the target dispute dimension type.

[0078] The training process for the overall similarity model and the category similarity model is as follows: Figure 3 As shown.

[0079] V. Precise Case Retrieval Based on Data

[0080] After obtaining the overall similarity model and the twelve-category similarity models, accurate case retrieval can be achieved based on existing case classification models. Specific user operations are as follows: Figure 4 As shown, when a user only inputs a case, the system calculates the similarity between the case information in the case database and the user's input case information using an overall similarity model, and then displays the case information in the case database to the user in descending order of similarity. If the user inputs both a case and a question, the system obtains the question category corresponding to the user's input question based on the existing case classification model, calls the corresponding category similarity model based on the question category, calculates the similarity between the case information in the case database and the user's input case information using the category similarity model, and then displays the case information in the case database to the user in descending order of similarity.

[0081] The above-described embodiments are merely preferred embodiments of the present invention and are not intended to limit the scope of the present invention. Various modifications and improvements made by those skilled in the art to the technical solutions of the present invention without departing from the spirit of the present invention should fall within the protection scope defined by the claims of the present invention.

Claims

1. A case retrieval method based on multiple models, characterized in that, Includes the following steps: Step 1: Prepare the training set. The training set consists of conflicting texts, each containing a baseline case. and several candidate cases Each benchmark case Or several candidate cases All are composed of fields; Step two, divide the input training data into The number of segments, each with a length not exceeding 512, will be the first segment. Input the nth fragment into the BERT model, and extract the nth fragment. Semantic features of each fragment ; Step 3: Based on the semantic features of each segment Calculate the baseline case facts With candidate cases Similarity score ; Step four, The model is trained using BERT data to obtain an overall similarity model. Step 5: Locate relevant fields for the predefined twelve dispute dimension types, and define the relevant field content of the target dispute dimension type of the baseline case as the baseline field. The relevant fields for the target dispute dimension type of the candidate case are the candidate fields. ; Calculate the baseline field With candidate fields Similarity score ; Step Six: Categorize the various dispute dimensions... The model was trained using BERT data to obtain twelve categories of similarity models. Step 7: Based on the case classification model, the overall similarity model, and the twelve-category similarity model, return the case data to the user's input query data. The returned case data is sorted from highest to lowest similarity. Step seven specifically refers to: when the user only inputs a case, based on the case information input by the user, the overall similarity model is used to calculate the similarity between the case information in the case database and the case information input by the user, and the case information in the case database is displayed to the user in descending order of similarity; When a user inputs a case and a question, the system obtains the question category corresponding to the user's input question based on the existing case classification model. Based on the question category, the system calls the corresponding category similarity model and uses the category similarity model to calculate the similarity between the case information in the case database and the case information input by the user. The system then displays the case information in the case database to the user in descending order of similarity. Step two specifically includes: dividing the input training data into... The number of segments, each with a length not exceeding 512, will be the first segment. The text of each segment is divided into tokens, and each token is converted into its corresponding ID in the vocabulary of the word segmenter. These IDs are then arranged into an input sequence according to the order of the corresponding tokens in the text. The tokens in the input sequence are initialized with token embedding, paragraph embedding, and position embedding. The three are added together to form the input embedding vector of the token. The input embedding vector is updated through multiple model layers with self-attention mechanisms to obtain an embedding representation of each word with contextual semantic information; the embedding representation corresponding to the last layer of the first special word [CLS] is used as the embedding representation of the first word in the conflict text. Semantic features of each fragment .

2. The case retrieval method based on a multi-model according to claim 1, characterized in that, Step one specifically includes: The original data consisted of local public security bureaus’ data on mediation of disputes, police reports, and open-source legal judgments from the internet. Each piece of raw data is converted into a uniform format composed of predefined fields; One case is randomly selected from the converted data as the baseline case, and 100 cases are randomly selected as candidate cases for the baseline case. Each baseline case and its corresponding candidate cases constitute a text of conflict and dispute. A training set is composed of several conflicting and disputed texts.

3. The case retrieval method based on a multi-model according to claim 1, characterized in that, Step three specifically refers to the semantic features of each segment. The baseline case facts were calculated using the BM25 algorithm. With candidate cases Similarity score .

4. The case retrieval method based on a multi-model according to claim 3, characterized in that, Step three specifically includes: Baseline Case Facts With candidate cases Similarity score : ; in, Indicates the first Semantic features of each fragment The weight, Indicates the first Semantic features of each fragment With each candidate case The relevance score; No. Semantic features of each fragment weight for: ; in, Representative candidate case details The total number of feature word vectors in the text. Representative candidate case details Chinese feature word vectors and The number of similar items; ; ; in, for exist Frequency of occurrence in for Frequency of occurrence in Q Representing all Average number of feature word vectors , , All are regulatory factors. To represent the candidate cases Chinese feature word vectors and Irrelevant regulatory factors.