Intelligent legal document retrieval system based on vector technology
By converting legal documents into vector representations and constructing a vector-based index data structure, the problem that existing legal documents search system is difficult to output accurate results when facing fuzzy or inaccurate queries is solved, and efficient and accurate legal documents search results are achieved.
Patent Information
- Application Number
- CN202411991432.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-31
- Publication Date
- 2025-04-22
AI Technical Summary
When the existing legal document search system faces vague or inaccurate queries from users, it is difficult to output accurate results, and the traditional keyword matching method cannot deeply understand the semantic connotation of legal documents, resulting in inefficient search efficiency and the correlation and accuracy of the results being difficult to reach an ideal level.
The legal documents intelligent search system based on vector technology is adopted, and the legal documents are converted into vector representations through the document vector generation module. The index construction module is used to build a vector-based index data structure. The query vector generation module generates a query vector, and the vector similarity calculation module calculates the vector similarity, and filters out the legal documents that best match the query intention.
It has achieved a deep understanding of the semantics of legal documents, and even in the face of vague or inaccurate queries, it can quickly and accurately locate relevant legal documents, greatly improving the search efficiency, relevance and accuracy, and meeting the legal industry's needs for efficient legal information retrieval.
Smart Images

Figure CN119862287A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of information retrieval technology, and more specifically, to a legal document intelligent retrieval system based on vector technology. Background Art
[0002] The legal document intelligent retrieval system is a tool that uses artificial intelligence technology, especially natural language processing (NLP) and machine learning (ML) technology, to help users quickly and accurately retrieve and analyze legal documents.
[0003] In the existing legal document retrieval, the traditional keyword matching method occupies a dominant position. However, it has obvious limitations. When the keywords entered by the user are biased, such as inaccurate or incomplete, it is difficult for the retrieval system to output accurate legal document results. In addition, traditional retrieval methods cannot deeply understand the semantic connotation of legal documents, and cannot achieve effective matching for situations with similar semantics but different expressions. When faced with a large-scale and massive legal document library, its retrieval efficiency is low, and the relevance and accuracy of the results obtained are difficult to reach the ideal level. In addition, there are obvious deficiencies in understanding the user's query intention, and it is difficult to give accurate legal knowledge responses based on the user's fuzzy query, which cannot meet the needs of modern legal workers and ordinary people for efficient and accurate legal document retrieval. Summary of the invention
[0004] In order to solve the above problems, the present invention provides a legal document intelligent retrieval system based on vector technology.
[0005] The present invention provides a legal document intelligent retrieval system based on vector technology, including a document vector generation module, an index construction module, a query vector generation module, a similarity calculation module and a result optimization module:
[0006] The document vector generation module is used to perform text preprocessing on relevant legal documents, including but not limited to word segmentation and stop word removal operations, and convert the legal documents into vector representations using a pre-trained word vector model to obtain a legal document vector, i.e., the target vector D, and transmit it;
[0007] The index building module is used to build a data structure based on vector indexes and optimize vector indexes;
[0008] The query vector module also performs text preprocessing on the query statement input by the user, and uses the word vector model and vector generation algorithm adapted to the document vector generation module to convert the query statement into a query vector Q, and transmits it;
[0009] The similarity calculation module is used to receive the legal document vector of the document vector generation module and the query vector of the query vector module, and calculate the similarity between the query vector and the legal document vector, sort the legal documents according to the calculated similarity, and screen out the legal document that best matches the query intent;
[0010] The result optimization module is used to further optimize the results obtained from the initial search.
[0011] Preferably, the document vector generation module uses the pre-trained word vector model to convert the legal document into a vector representation in the following specific manner:
[0012] Use large-scale general corpora for word vector pre-training;
[0013] Perform semantic role labeling on sentences in legal documents, identify the agent, patient, and action role information, and encode the labeling results into vectors in a specific way;
[0014] Analyze the sentence structure of legal documents through dependency syntax analysis tools to determine the dependency relationship between words;
[0015] Perform part-of-speech tagging on legal documents to distinguish nouns, verbs, and adjectives, and then construct vectors based on the role of different parts of speech in expressing semantic logic;
[0016] Separately extract the semantic feature vectors and grammatical feature vectors of legal documents, construct a multi-dimensional feature matrix, and arrange and combine feature vectors of different dimensions in the matrix according to certain rules;
[0017] Use neural network framework to construct legal document vectors that integrate multiple dimensions.
[0018] Preferably, the index building module is used to build a data structure based on a vector index and optimize the vector index, specifically:
[0019] Divide the legal document vector according to preset rules;
[0020] In the index building phase, the vector data in each data block is read in parallel, key information is extracted and preliminarily processed, and intermediate key-value pairs are generated.
[0021] Preferably, before calculating the similarity between the query vector and each legal document vector, the step further includes:
[0022] Perform detailed preprocessing on legal document vectors;
[0023] Handling multi-word expressions in vectors;
[0024] A phrase detection algorithm is used to identify these multi-word expressions and vector map them as a whole unit.
[0025] Preferably, the similarity between the query vector and each legal document vector is calculated as follows:
[0026] Divide legal documents into core semantic structures such as title T, key clause K, factual statement F, and judgment result J;
[0027] Construct an independent semantic vector space for each semantic structure part, and construct a vector in each vector space based on the distribution characteristics of the semantic units;
[0028] Map the vectors of different semantic structure parts into a unified high-dimensional semantic space to achieve the integration of semantic vectors:
[0029] Calculate the similarity between the query vector Q and the target vector D in a unified high-dimensional semantic space;
[0030] Calculate the cosine similarity between the sub-vectors corresponding to each semantic structure part respectively;
[0031] The similarity of each sub-vector is integrated through the semantic structure association matrix M;
[0032] Calculate the overall similarity.
[0033] Preferably, the cosine similarity between the sub-vectors corresponding to each semantic structure part is calculated respectively as follows:
[0034] Will Set as title sub-vector similarity; Let be the key term sub-vector similarity, Let be the fact statement sub-vector similarity, Set as the decision result sub-vector similarity, the calculation formula is as follows:
[0035] ;
[0036] ;
[0037] in, , are the i-th semantic unit values of the query vector and the target vector in the title part, respectively, and n is the total number of semantic units in the title part; , are the first i semantic unit values of the query vector and the target vector in the key clause part, respectively, m is the total number of semantic units in the key clause part, and so on. and .
[0038] Preferably, the specific method of calculating the overall similarity is:
[0039] ; get the overall similarity.
[0040] 8. According to the vector technology-based legal document intelligent retrieval system of claim 7, it is characterized in that the integration of the similarities of each sub-vector through the semantic structure association matrix M is specifically:
[0041] Perform word segmentation on a large number of legal documents and extract each semantic structure part;
[0042] Count the co-occurrence frequencies of words in different semantic structure parts;
[0043] The resonant frequency is normalized to obtain the correlation value.
[0044] Preferably, the result optimization module includes multimodal data to assist result optimization, specifically:
[0045] For text data, perform conventional cleaning, word segmentation, and word vector generation operations to convert the text into a computable vector representation;
[0046] For image data, image recognition technology is used for preprocessing;
[0047] For audio data, first perform audio format conversion, noise reduction and other processing, and use audio feature extraction algorithms;
[0048] A fusion layer is pre-set to fuse the feature vectors of text, image, and audio to obtain a fused feature vector;
[0049] The fused feature vector is transmitted to the document vector generation module as a legal document vector.
[0050] Preferably, the result optimization module further includes a result integration module, and the working steps of the integration module are specifically as follows:
[0051] Determine the relationship between the number of user conversation history records and the limit value;
[0052] If the number of user conversation history records is less than the limit, all conversation history records are directly extracted;
[0053] If the number of user conversation history records exceeds the limit, a large model is used to generate a summary of the conversation history records;
[0054] The generated conversation history summary, the current user question, and the reranked source corpus are input into the big model together;
[0055] Understand the user's query intention with the help of pre-set models, perform semantic supplement and correction on fuzzy queries, and participate in the semantic analysis of search results;
[0056] Use multi-source verification technology to remove AI illusions and obtain the same or related legal documents from multiple official legal databases for content comparison;
[0057] Adopting fact-checking technology based on knowledge graph, checking whether the legal relationship and facts in the search results are correct according to the constructed legal knowledge graph;
[0058] The large model ultimately generates intelligent answers based on the legal knowledge base and presents them to users in the form of streaming output.
[0059] Beneficial effects: 1. Through the intelligent retrieval system of legal documents based on vector technology, the semantics of legal documents can be effectively understood. Even in the face of vague or inaccurate query input by users, the relevant legal documents can be quickly and accurately located by similarity calculation in the vector space, which greatly improves the efficiency, relevance and accuracy of legal document retrieval, and meets the urgent needs of the legal industry and related demanders for efficient legal information retrieval.
[0060] 2. By comprehensively considering the degree of association and similarity between the various semantic structure parts, rather than simply comparing them, it can more accurately reflect the overall semantic similarity of legal documents and other texts, and avoid one-sided judgments; the values of the association matrix elements are based on the semantic analysis and statistics of a large number of legal documents, which is in line with the characteristics of the legal field. The results are more in line with the actual situation of the relationship between legal texts, which is beneficial for legal workers to refer to, such as judging whether there is plagiarism in contracts, litigation documents, etc., and the degree of similarity, etc., to assist in legal affairs decision-making; splitting the text into different semantic structure parts to consider the association and similarity separately, which helps to further clarify which parts have high similarity and which parts have large differences, making it convenient to view and study specific content in a targeted manner and deepen the understanding of text characteristics and their relationships. BRIEF DESCRIPTION OF THE DRAWINGS
[0061] Figure 1 It is a flow chart of the management system of the present invention. DETAILED DESCRIPTION
[0062] Application scenarios: In the existing legal document retrieval, the traditional keyword matching method occupies a dominant position. However, it has obvious limitations. When the keywords entered by the user are biased, such as inaccurate or incomplete, it is difficult for the retrieval system to output accurate legal document results. In addition, traditional retrieval methods cannot deeply understand the semantic connotation of legal documents, and cannot achieve effective matching for situations with similar semantics but different expressions. When faced with a large-scale massive legal document library, its retrieval efficiency is low, and the relevance and accuracy of the results obtained are difficult to reach the ideal level. In addition, there are obvious deficiencies in understanding the user's query intent, and it is difficult to give accurate legal knowledge responses based on the user's fuzzy queries. It cannot meet the needs of modern legal workers and ordinary people for efficient and accurate legal document retrieval.
[0063] like Figure 1 As shown: A legal document intelligent retrieval system based on vector technology, including a document vector generation module, an index construction module, a query vector generation module, a similarity calculation module and a result optimization module:
[0064] The document vector generation module is used to perform text preprocessing on relevant legal documents, including but not limited to word segmentation and stop word removal operations, and convert the legal documents into vector representations using a pre-trained word vector model to obtain legal document vectors and transmit them. It should be noted that legal documents are collected from legal databases, official websites and other channels across the country, and their formats are converted into a unified text format to remove noise data, useless symbols, and text; the text is segmented, stop words are removed, stems are extracted, and other operations are performed. Then, vector technology is used to convert the processed legal documents into vector representations and store them in, for example, the Weviates vector database.
[0065] Among them, the pre-trained Chinese word vector model, for example, the word vector model obtained by training based on a large-scale legal text corpus, maps each word after word segmentation into a corresponding word vector. For example, words such as "house", "sale", and "contract" have their own specific vector representations.
[0066] The index building module is used to build a data structure based on vector indexes and optimize the vector indexes. It should be noted that converting the contents of relevant legal documents into vectors and building indexes can quickly perform similarity searches and nearest neighbor queries in large-scale data sets.
[0067] The query vector module also performs text preprocessing on the query statement input by the user, and uses the word vector model and vector generation algorithm adapted to the document vector generation module to convert the query statement into a query vector, and transmits it;
[0068] Ensure that the query vector and document vector are in the same vector space to facilitate similarity calculation;
[0069] It should be noted that when a user enters a query statement in the system interface, the system will pre-process the query statement, including data desensitization, logging, conversation history, etc., including but not limited to converting the query statement into a vector using the open source embedding model in huggingface.
[0070] The similarity calculation module is used to receive the legal document vector of the document vector generation module and the query vector of the query vector module, and calculate the similarity between the query vector and the legal document vector, sort the legal documents according to the calculated similarity, and screen out the legal document that best matches the query intent;
[0071] It should be noted that by calculating the similarity, the legal document with higher similarity is marked as the legal document that best matches the query intent.
[0072] The result optimization module is used to further optimize the results obtained from the initial search. It should be noted that, for example, the ranking results can be adjusted according to factors such as the authority and timeliness of legal documents. At the same time, for some special query needs, such as specific legal fields and specific geographical scopes, the result set can be further screened and adjusted to improve the practicality and pertinence of the search results.
[0073] For example, considering the authority of legal documents, relevant legal documents from the Higher People's Court or the Supreme People's Court are prioritized because these documents have higher authority and guidance in legal interpretation and application.
[0074] Considering the timeliness factor, if there are the latest judicial interpretations or guiding cases on the handling of house sales defaults, they will be ranked higher in the result set to ensure that the search results can reflect current legal practices and trends;
[0075] For user-specific needs, such as if the user only wants to view local legal documents on house sale and purchase breach in Beijing, the result set is further filtered to retain only legal documents involving relevant cases in Shanghai, and the sorting is readjusted to display the legal documents that best meet the user's needs at the forefront, thereby improving the practicality and pertinence of the search results and providing users with efficient and accurate legal document retrieval services.
[0076] It should be noted that the results input the preliminary search results into, for example, a rerank model, which re-ranks the results according to the preset weights and algorithms, obtains data with higher scores and the best accuracy, and generates the source corpus;
[0077] It should be noted that the legal document intelligent retrieval system based on vector technology can effectively understand the semantics of legal documents. Even in the face of vague or inaccurate query input by users, it can quickly and accurately locate relevant legal documents by relying on similarity calculations in the vector space, greatly improving the efficiency, relevance and accuracy of legal document retrieval, and meeting the urgent needs of the legal industry and related demanders for efficient legal information retrieval.
[0078] As a further embodiment, the specific method in which the document vector generation module converts the legal document into a vector representation using the pre-trained word vector model is as follows:
[0079] Use large-scale general corpora for word vector pre-training; It should be noted that models such as Word2Vec and BERT are then fine-tuned on legal professional corpora. For example, they are further trained with massive legal texts, judgments and other texts to allow the model to learn the semantic associations unique to the legal field, such as the accurate meaning of words such as "plaintiff", "defendant" and "infringement" in the legal context, thus converting the words in the legal documents into vector representations containing rich semantics.
[0080] Among them, the large-scale general corpus is a huge collection of text data, which contains a variety of language materials, such as news reports, novels, papers, blogs, etc. These materials come from different fields and styles and are highly diverse;
[0081] The text in the corpus has been preprocessed, such as word segmentation and annotation, to facilitate computer analysis; large-scale general corpora are very important in the field of natural language processing, which can help researchers train and optimize various models, such as machine translation, sentiment analysis, question-answering systems, etc.
[0082] In addition, large-scale general corpora can help us better understand the usage patterns and characteristics of languages and reveal the trends of language evolution;
[0083] Semantic role annotation is performed on sentences in legal documents to identify the information of the agent, the patient, and the action role, and the annotation results are encoded into vectors in a specific way. It should be noted that, for example, in a document related to breach of contract, "Party A's agent failed to deliver the goods on time, the action, the patient" is annotated, and a vector that can reflect this semantic structure is generated based on the annotation situation, which comprehensively reflects the semantic content of the document.
[0084] The sentence structure of legal documents is analyzed through dependency syntax analysis tools to determine the dependency relationship between words. It should be noted that dependency relationships include subject-predicate relationships, verb-object relationships, etc. Then, different words are given weights based on these relationships and encoded into vectors. For example, in "the court ruled that the defendant compensated the plaintiff for losses", the dependency relationship between "rule" and "defendant" and "compensation" is clear. Vector elements are generated according to their grammatical importance, so that the vector reflects the grammatical association characteristics.
[0085] It should be noted that a syntactic analysis tool is a tool used to analyze sentence structure. It can decompose a sentence into different components, such as subject, predicate, object, etc., and determine the relationship between each component. Syntactic analysis tools are widely used in natural language processing, linguistic research, machine translation and other fields. For example, in machine translation, syntactic analysis tools can help determine the structure of source language sentences for better translation. In linguistic research, syntactic analysis tools can be used to analyze the sentence structure characteristics of different languages, so as to gain a deeper understanding of the laws and characteristics of the language.
[0086] Legal documents are tagged with parts of speech to distinguish between nouns, verbs, and adjectives, and then vectors are constructed based on the role of different parts of speech in expressing semantic logic. It should be noted that nouns often carry key legal subject concepts, and verbs embody legal behaviors. The characteristics corresponding to these parts of speech are quantified and integrated into the vector, such as giving nouns a slightly higher weight for the corresponding dimension, so as to better capture the grammatical features and reflect them in the vector.
[0087] Semantic feature vectors and grammatical feature vectors of legal documents are extracted respectively, a multi-dimensional feature matrix is constructed, and feature vectors of different dimensions are arranged and combined in the matrix according to certain rules. It should be noted that this matrix as a comprehensive vector representation of legal documents can take into account multiple aspects of information such as semantics and grammar.
[0088] Use the neural network framework to build a fusion of multi-dimensional legal document vectors. It should be noted that, for example, in a multi-layer perceptron or a middle layer of the Transformer, the extracted semantic vectors and grammatical vectors are used as inputs, and the fused legal document vectors are output through the nonlinear transformation and fusion operation of the network, so that the vector can contain multi-dimensional key information at the same time and accurately capture the semantics and logical structure of the document.
[0089] As a further embodiment, the index building module is used to build a data structure based on a vector index and optimize the vector index, specifically:
[0090] The legal document vectors are divided according to the preset rules. It should be noted that the data division in the current preset rules abandons the more general division by document type and time range, and is replaced by a more professional and systematic division. For example, a dual-dimensional division is performed based on the legal fields involved in the legal documents, such as civil law, criminal law, commercial law, etc., as well as the filing, trial, and judgment of the litigation stage. The divided legal document vectors are stored in different data blocks of the Hadoop distributed file system HDFS, so that the data can be more accurately located and processed during subsequent index construction and retrieval;
[0091] The data block storage strategy in the current preset rules is to set the data block size based on factors such as the memory capacity of the cluster nodes, network bandwidth, and data read and write frequency, and the principle of determining the number of data block copies takes into account the importance of the data, the reliability requirements of the cluster, etc.
[0092] In the index building phase, the vector data in each data block is read in parallel, key information is extracted and preliminarily processed, and intermediate key-value pairs are generated. For example, the MapReduce programming model is used for processing, and the vector data in each data block is read in parallel through the Map task to extract key information such as the vector identifier and the key attributes of the corresponding document; the Reduce task aggregates and integrates the intermediate results with the same key, such as organizing the vectors of the same type of legal documents according to the appropriate index structure rules, and finally constructs a large-scale vector index to achieve rapid construction;
[0093] Moreover, when reading the vector data in each data block, not only the vector identifier and the key attributes of the corresponding document are extracted, but also the semantic and grammatical features in the vector are preliminarily analyzed and encoded to generate intermediate key-value pairs containing more effective information. The key can be designed as a combination of key features of the legal document, such as legal field + litigation stage + information of the main parties, etc., and the value contains the detailed data of the vector and the preliminary processing results;
[0094] The specific index structure rules used in the aggregation and integration process of the Reduce task are, for example, using the B+ tree index structure, inserting the same type of legal document vectors into the B+ tree nodes in the order of the keys according to the key-value pairs generated by the Map task, to ensure the orderliness and efficient retrieval of the index. At the same time, it explains how to handle data conflicts such as the merging rules of different vector data with the same key value and abnormal situations such as missing or incorrect vector data in the index construction process;
[0095] When a new legal document vector is added, the corresponding MapReduce task is triggered by monitoring the file system changes to quickly process the new vector and update it to the existing index structure to ensure timeliness.
[0096] For example, use Hadoop's file system monitoring tools such as inotify or Hadoop's built-in file system event monitoring interface, set the monitored event types such as file creation, modification, deletion, etc., and trigger thresholds such as file size changes exceeding a certain percentage or multiple file operations within a specific time interval.
[0097] It should be noted that by combining data partitioning, MapReduce task allocation and real-time update mechanism, it is specially applied to index construction and update of massive legal document vectors.
[0098] Among them, the above can also be achieved through:
[0099] The index is constructed in layers, and the layers are formed according to the importance and frequency of use of legal documents. For example, the document vectors corresponding to the commonly used core legal provisions are placed in the high-level index to quickly respond to retrieval needs, and the infrequently used ones are placed in the low-level index. In this way, when building the index, resource allocation can be optimized according to the layering strategy to improve the overall construction speed.
[0100] Cache hot index: Identify the frequently retrieved vector index parts and cache them in a high-speed cache area such as the server's memory cache. Update the cache content in real time to adapt to new data changes. When retrieving, give priority to obtaining from the cache, which not only improves timeliness but also reduces the burden of building large-scale indexes and enhances system scalability.
[0101] As a further embodiment, before calculating the similarity between the query vector and each legal document vector, the following steps are further included:
[0102] Preprocess the legal document vectors in detail. Specifically, in addition to conventional word vector representation, the semantic hierarchy of legal terms is deeply explored. For example, the legal knowledge graph technology is used to integrate the relationship between legal concepts, such as the relationship between higher-level laws and lower-level laws, and the relationship between similar legal provisions, into the vector representation. For the vector dimensions involving the same legal concept system, weighted processing is performed to highlight their importance in semantic matching. In this way, when calculating the similarity, the similarity between legal documents based on semantics and legal logic can be captured more accurately.
[0103] Handle multi-word expressions in vectors; for example, legal phrases, fixed collocations, etc.
[0104] The phrase detection algorithm is used to identify these multi-word expressions and map them as a whole unit. For example, phrases such as "contract breach" and "intellectual property infringement" are no longer simply split into vector combinations of individual words, but a unified phrase vector is generated through a specially trained phrase vector model, avoiding the loss of semantic information due to word splitting in similarity calculations and improving retrieval accuracy.
[0105] As a further embodiment, the similarity between the query vector and each legal document vector is calculated as follows:
[0106] The legal document is divided into core semantic structural parts such as title T, key clause K, factual statement F, and judgment result J. It should be noted that different semantic analysis techniques are used for each part. For example, keyword extraction and subject classification are performed on the title; semantic association mining is performed on key clauses based on the legal knowledge graph; semantic role labeling is used to identify subjects, behaviors, and objects for factual statements; and semantic analysis of the result type and degree is performed on the judgment result.
[0107] Construct an independent semantic vector space for each semantic structure part, and construct vectors in each vector space through the distribution characteristics of semantic units; specifically, in the title vector space, take keywords as semantic units, and construct vectors based on the frequency of keywords in the title, position information, and the degree of association with the legal subject thesaurus. For the key clause vector space, take legal concepts as semantic units, and construct vectors based on the hierarchical relationship of concepts, importance in clauses, and logical associations with other clauses;
[0108] Map the vectors of different semantic structure parts into a unified high-dimensional semantic space to achieve the integration of semantic vectors: Specifically, in the mapping process, a conversion method based on semantic rules is adopted. For example, according to legal semantic logic, the mapping relationship between the title vector and the key clause vector in the unified space is determined. If there is a direct correlation between the keywords in the title and the legal concepts in the key clauses, a corresponding vector conversion path is established during the mapping so that the relevant semantic information can be accurately connected in the unified space;
[0109] Calculate the similarity between the query vector Q and the target vector D in a unified high-dimensional semantic space;
[0110] Calculate the cosine similarity between the sub-vectors corresponding to each semantic structure part respectively;
[0111] The similarities of each sub-vector are integrated through the semantic structure relevance matrix M; specifically, the elements in the relevance matrix Indicates the degree of association between the ith semantic structure part and the jth semantic structure part at the legal semantic level, with a value range of 0 to 1, determined through semantic analysis and statistics of a large number of legal documents. For example, the title may have a high degree of association with key clauses, while the association with factual statements may be relatively low.
[0112] Calculate the overall similarity.
[0113] As a further embodiment, the cosine similarity between the sub-vectors corresponding to each semantic structure part is calculated respectively as follows:
[0114] Will Set as title sub-vector similarity; Let be the key term sub-vector similarity, Let be the fact statement sub-vector similarity, Set as the decision result sub-vector similarity, the calculation formula is as follows:
[0115] ;
[0116] ;
[0117] in, , are the i-th semantic unit values of the query vector and the target vector in the title part, respectively, and n is the total number of semantic units in the title part; , are the first i semantic unit values of the query vector and the target vector in the key clause part, respectively, m is the total number of semantic units in the key clause part, and so on. and .
[0118] As a further embodiment, the specific method of calculating the overall similarity is:
[0119] ; get the overall similarity.
[0120] It should be noted that the semantic structure association matrix M is first used to integrate the similarities of each sub-vector. The elements of this matrix can reflect the degree of association between different semantic structure parts at the legal semantic level. On this basis, the overall similarity is calculated through a specific formula;
[0121] By comprehensively considering the degree of association between the various semantic structure parts and their respective similarities, rather than simply comparing them, it can more accurately reflect the overall semantic similarity of legal documents and other texts, and avoid one-sided judgments;
[0122] The values of the correlation matrix elements are analyzed and counted based on a large number of legal documents, which is in line with the characteristics of the legal field. The results are more in line with the actual situation of the relationship between legal texts, which is helpful for legal workers to refer to, such as judging whether there is plagiarism in contracts, litigation documents, etc., and the degree of similarity, etc., to assist in legal affairs decision-making;
[0123] Splitting the text into different semantic structures to consider the relevance and similarity separately will help to further clarify which parts are highly similar and which parts are very different, making it easier to view and study specific content in a targeted manner and deepen the understanding of the text characteristics and interrelationships.
[0124] As a further embodiment, the similarities of each sub-vector are integrated through the semantic structure association matrix M as follows:
[0125] A large number of legal documents are segmented and each semantic structure part is extracted; it should be noted that the above explanation includes words in titles, key clauses, statements of facts, and judgment results.
[0126] Count the co-occurrence frequencies of words between different semantic structure parts; for example, for the words in the title part and the words in the key clause part, count the number of times they appear together in the same legal document.
[0127] The resonant frequency is normalized to obtain the correlation value. It should be noted that the formula It is concluded that, is the co-occurrence frequency of the words in the i-th semantic structure part and the j-th semantic structure part, is the maximum value among all possible co-occurrence frequencies, so we get The value range is between 0 and 1.
[0128] It is worth mentioning again that, for example, it is also possible to apply a topic model:
[0129] For example, LatentDirichletAllocation and LDA perform topic mining on legal documents. Each semantic structure part can be regarded as a combination of topics. The similarity of topic distributions of different semantic structure parts is calculated. For example, Jensen-Shannon divergence can be used to measure the difference between two topic distributions. The similarity is converted to obtain the correlation value. For example, Let Jensen-Shannon divergence of topic distribution of the i-th semantic structure part and the j-th semantic structure part be , thus ensuring that the value range of is between 0 and 1.
[0130] As a further embodiment, the result optimization module includes multimodal data to assist result optimization, specifically:
[0131] For text data, perform routine cleaning, word segmentation, and word vector generation operations to convert the text into a computable vector representation; for example, use a pre-trained legal field word vector model to map each word in the legal case text into a vector of fixed dimension, and then obtain the overall vector representation of the text by summing or averaging.
[0132] For image data, image recognition technology is used for preprocessing; it should be noted that when using image recognition technology to process legal evidence images, the target detection algorithm is used to identify key elements in the image, such as contract signatures, seals, key evidence objects, etc., and the feature vectors of these elements are extracted. The convolutional neural network CNN can be used to extract features from the image, convert the image into a feature map, and then use the fully connected layer to obtain the feature vector of the image for preprocessing.
[0133] For audio data, audio format conversion, noise reduction and other processing are first performed, and then an audio feature extraction algorithm is used; for example, short-time Fourier transform (STFT) is used to extract the spectral features of the audio, and then the spectral feature sequence is modeled through a recurrent neural network (RNN) or its variants such as a long short-term memory (LSTM) network to obtain a feature vector of the audio.
[0134] A fusion layer is pre-set to fuse the feature vectors of text, image, and audio to obtain a fused feature vector; It should be noted that a simple concatenation method can be used, that is, concatenating the three feature vectors in order into a longer vector; or a more complex fusion strategy can be used, such as fusion based on the attention mechanism. The attention mechanism can automatically learn the importance weights of different modal features in the current task, and then perform weighted summation of each modal feature according to the weight to obtain a fused feature vector. For example, in legal case rerank, if the current task focuses more on the text content, the text feature vector will be assigned a higher attention weight.
[0135] The fused feature vector is transmitted to the document vector generation module as the legal document vector. Specifically, the system first collects and preprocesses the legal documents nationwide, including format unification, text cleaning and other operations, and then uses vector technology to persist the legal documents in the Weaviate vector database. In this process, the text information in the legal document is converted into a vector representation through a specific algorithm model for subsequent retrieval operations;
[0136] When a user searches for relevant legal knowledge, the system receives the user's query request and uses RAG technology to perform vector retrieval. RAG technology converts the user query into a vector and searches for the most similar legal document vector in the vector database. The embedding model uses the open source model in huggingface to map the query and the text in the legal document into the vector space.
[0137] The preliminary results obtained by retrieval are then cleaned and re-ranked for a second time through the rerank model. The rerank model further evaluates and ranks the preliminary retrieval results according to certain rules and algorithms to improve the accuracy and relevance of the results. The specific re-ranking method is to transfer the fused feature vector to the calculation layer of the rerank model, which can be a sorting model based on a neural network, such as a multi-layer perceptron MLP. The MLP further performs nonlinear transformation and calculation on the fused features and outputs the rerank score of each case. In the training stage, based on known case relevance labels such as manually labeled high, medium, and low relevance, the model is trained using the cross entropy loss function and the like to optimize the model parameters so that the model can accurately rerank cases based on multimodal fusion features.
[0138] As a further embodiment, the result optimization module further includes a result integration module, and the working steps of the integration module are specifically as follows:
[0139] Determine the relationship between the number of user conversation history records and the limit value; it should be noted that the limit value is the number of historical conversations, which is pre-set in the system.
[0140] If the number of user conversation history records is less than the limit, all conversation history records are directly extracted;
[0141] If the number of user conversation history records exceeds the limit, a large model is used to generate a summary of the conversation history records, where the large model is Tsinghua Zhipu Qianyan GLM-4 model;
[0142] The generated conversation history summary, the current user question, and the reranked source corpus are input into the big model together;
[0143] With the help of a pre-set model, the user's query intention is understood, the fuzzy query is semantically supplemented and corrected, and the semantic analysis of the search results is participated in; it should be noted that the pre-set model can use Tsinghua Zhipu's GLM-4 model to assist in understanding the user's query intention, semantically supplement and correct the fuzzy query, and participate in the semantic analysis of the search results to improve the readability and usability of the results.
[0144] Use multi-source verification technology to remove AI illusions, obtain the same or related legal documents from multiple official legal databases for content comparison; It should be noted that, such as multi-source verification of search results and fact-checking based on knowledge graphs, ensure that the legal knowledge provided to users is accurate and reliable. Specifically, multi-source verification technology will compare and verify the content of retrieved legal documents from multiple authoritative data sources to ensure the consistency and accuracy of information; fact-checking technology based on knowledge graphs uses the constructed legal knowledge graph to verify key facts and relationships in legal documents to avoid content that does not conform to legal logic and facts;
[0145] Adopting fact-checking technology based on knowledge graph, checking whether the legal relationship and facts in the search results are correct according to the constructed legal knowledge graph;
[0146] The large model ultimately generates intelligent answers based on the legal knowledge base and presents them to users in the form of streaming output.
[0147] The specific steps include: in the data collection and preprocessing stage, legal documents are collected from legal databases, official websites and other channels across the country, and the format is converted into a unified text format to remove noise data, useless symbols, and text. The text is segmented and stemmed. Then, the processed legal documents are converted into vector representations using vector technology and stored in the Weviates vector database;
[0148] The user enters a query statement in the system interface, and the system preprocesses the query statement, including data desensitization, logging, conversation history, etc. Then the query statement is converted into a vector using the open source embedding model in huggingface.
[0149] Through RAG technology, the user query vector is compared with the legal document vector in the vector database to calculate the similarity, and several legal document vectors with high similarity are found as preliminary search results;
[0150] The preliminary search results are input into the rerank model, which re-ranks the results according to the preset weights and algorithms, obtains the data with higher scores and the best accuracy, and generates the source corpus;
[0151] Read the user's conversation history. If the number of conversation history records is less than the limit, all conversation history records are directly obtained. If it exceeds the limit, the conversation history records are first submitted to the big model to form a conversation history summary. Then the summary + current user question + reranked source corpus are submitted to the big model together, and finally a relatively accurate intelligent answer based on the legal knowledge base is generated and presented to the user in the form of stream output;
[0152] In this process, Tsinghua Zhipu's GLM-4 model assists in understanding user query intentions, semantically supplements and corrects fuzzy queries, and participates in the semantic analysis of retrieval results to improve the readability and usability of the results. The multi-source verification technology that removes AI illusions will obtain the same or related legal documents from multiple official legal databases for content comparison. The fact-checking technology based on the knowledge graph will check whether the legal relationships and facts in the retrieval results are correct based on the constructed legal knowledge graph.
[0153] It should be noted that the system integrates the big model, GLM-4 model, multi-source verification technology and knowledge graph technology. This way of multi-technology collaboration is relatively new in the field of legal intelligent question answering. For example, the GLM-4 model focuses on query intent understanding and semantic processing, multi-source verification technology ensures information accuracy from the perspective of multiple databases, and knowledge graph technology verifies from the perspective of legal relations. They work together to make up for the limitations that may exist in a single technology, comprehensively improve the accuracy and reliability of answer generation, and better cope with complex and diverse problem scenarios in the legal field.
[0154] It can also flexibly process information based on the number of conversation history records and effectively compress information by generating summaries, which not only retains key information but also avoids the interference of information overload on subsequent processing. This helps the large model understand the context more accurately, thereby generating answers that are more in line with user needs and conversation logic.
[0155] Working principle:
[0156] The legal document intelligent retrieval system based on vector technology can effectively understand the semantics of legal documents. Even when faced with vague or inaccurate query input by users, it can quickly and accurately locate relevant legal documents by similarity calculation in vector space, greatly improving the efficiency, relevance and accuracy of legal document retrieval, and meeting the urgent needs of the legal industry and related users for efficient legal information retrieval.
[0157] By comprehensively considering the degree of association and similarity between various semantic structural parts, rather than simple comparison, it can more accurately reflect the overall semantic similarity of legal documents and other texts, and avoid one-sided judgment; the values of the association matrix elements are based on the semantic analysis and statistics of a large number of legal documents, which conforms to the characteristics of the legal field. The results are more in line with the actual situation of the relationship between legal texts, which is beneficial for legal workers to refer to, such as judging whether there is plagiarism in contracts, litigation documents, etc., and the degree of similarity, etc., to assist in legal affairs decision-making; splitting the text into different semantic structural parts to consider the association and similarity separately, will help to further clarify which parts have high similarity and which parts have large differences, so as to facilitate targeted viewing and research of specific content and deepen the understanding of text characteristics and their relationships.
[0158] The above are only preferred implementations of the present invention. The protection scope of the present invention is not limited to the above embodiments. All technical solutions under the concept of the present invention belong to the protection scope of the present invention. It should be pointed out that for ordinary technical staff in this technical field, some improvements and modifications without departing from the principle of the present invention should also be regarded as the protection scope of this template.
Claims
1. A legal document intelligent retrieval system based on vector technology, characterized in that: It includes document vector generation module, index construction module, query vector generation module, similarity calculation module and result optimization module: The document vector generation module is used to perform text preprocessing on relevant legal documents, including but not limited to word segmentation and stop word removal operations, and convert the legal documents into vector representations using a pre-trained word vector model to obtain a legal document vector, i.e., the target vector D, and transmit it; The index building module is used to build a data structure based on vector indexes and optimize vector indexes; The query vector module also performs text preprocessing on the query statement input by the user, and uses the word vector model and vector generation algorithm adapted to the document vector generation module to convert the query statement into a query vector Q, and transmits it; The similarity calculation module is used to receive the legal document vector of the document vector generation module and the query vector of the query vector module, and calculate the similarity between the query vector and the legal document vector, sort the legal documents according to the calculated similarity, and screen out the legal document that best matches the query intent; The result optimization module is used to further optimize the results obtained from the initial search.
2. According to claim 1, a legal document intelligent retrieval system based on vector technology is characterized in that: The specific method in which the document vector generation module converts the legal document into a vector representation using the pre-trained word vector model is as follows: Use large-scale general corpora for word vector pre-training; Perform semantic role labeling on sentences in legal documents, identify the agent, patient, and action role information, and encode the labeling results into vectors in a specific way; Analyze the sentence structure of legal documents through dependency syntax analysis tools to determine the dependency relationship between words; Perform part-of-speech tagging on legal documents to distinguish nouns, verbs, and adjectives, and then construct vectors based on the role of different parts of speech in expressing semantic logic; Separately extract the semantic feature vectors and grammatical feature vectors of legal documents, construct a multi-dimensional feature matrix, and arrange and combine feature vectors of different dimensions in the matrix according to certain rules; Use neural network framework to construct legal document vectors that integrate multiple dimensions.
3. According to claim 2, a legal document intelligent retrieval system based on vector technology is characterized in that: The index building module is used to build a data structure based on vector indexes and optimize the vector indexes, specifically: Divide the legal document vector according to preset rules; In the index building phase, the vector data in each data block is read in parallel, key information is extracted and preliminarily processed, and intermediate key-value pairs are generated.
4. According to claim 3, a legal document intelligent retrieval system based on vector technology is characterized in that: Before calculating the similarity between the query vector and each legal document vector, the following further includes: Perform detailed preprocessing on legal document vectors; Handling multi-word expressions in vectors; A phrase detection algorithm is used to identify these multi-word expressions and vector map them as a whole unit.
5. According to claim 1, the intelligent retrieval system for legal documents based on vector technology is characterized in that: The calculation of the similarity between the query vector and each legal document vector is specifically as follows: Divide legal documents into core semantic structures such as title T, key clause K, factual statement F, and judgment result J; Construct an independent semantic vector space for each semantic structure part, and construct a vector in each vector space based on the distribution characteristics of the semantic units; Map the vectors of different semantic structure parts into a unified high-dimensional semantic space to achieve the integration of semantic vectors: Calculate the similarity between the query vector Q and the target vector D in a unified high-dimensional semantic space; Calculate the cosine similarity between the sub-vectors corresponding to each semantic structure part respectively; The similarity of each sub-vector is integrated through the semantic structure association matrix M; Calculate the overall similarity.
6. According to claim 5, a legal document intelligent retrieval system based on vector technology is characterized in that: The specific method of calculating the cosine similarity between the sub-vectors corresponding to each semantic structure part is as follows: Will Set as title sub-vector similarity; Let be the key term sub-vector similarity, Let be the fact statement sub-vector similarity, Set as the decision result sub-vector similarity, the calculation formula is as follows: ; ; in, , are the i-th semantic unit values of the query vector and the target vector in the title part, respectively, and n is the total number of semantic units in the title part; , are the first i semantic unit values of the query vector and the target vector in the key clause part, respectively, m is the total number of semantic units in the key clause part, and so on. and .
7. The intelligent retrieval system for legal documents based on vector technology according to claim 6 is characterized in that: The specific method of calculating the overall similarity is: ; get the overall similarity.
8. The intelligent retrieval system for legal documents based on vector technology according to claim 7 is characterized in that: The integration of the similarities of each sub-vector through the semantic structure association matrix M is specifically as follows: Perform word segmentation on a large number of legal documents and extract each semantic structure part; Count the co-occurrence frequencies of words in different semantic structure parts; The resonant frequency is normalized to obtain the correlation value.
9. The intelligent retrieval system for legal documents based on vector technology according to claim 8 is characterized in that: The result optimization module includes multimodal data to assist result optimization, specifically: For text data, perform conventional cleaning, word segmentation, and word vector generation operations to convert the text into a computable vector representation; For image data, image recognition technology is used for preprocessing; For audio data, first perform audio format conversion, noise reduction and other processing, and use audio feature extraction algorithms; A fusion layer is pre-set to fuse the feature vectors of text, image, and audio to obtain a fused feature vector; The fused feature vector is transmitted to the document vector generation module as a legal document vector.
10. The intelligent retrieval system for legal documents based on vector technology according to claim 9 is characterized in that: The result optimization module also includes a result integration module, and the working steps of the integration module are specifically as follows: Determine the relationship between the number of user conversation history records and the limit value; If the number of user conversation history records is less than the limit, all conversation history records are directly extracted; If the number of user conversation history records exceeds the limit, a large model is used to generate a summary of the conversation history records; The generated conversation history summary, the current user question, and the reranked source corpus are input into the big model together; Understand the user's query intention with the help of pre-set models, perform semantic supplement and correction on fuzzy queries, and participate in the semantic analysis of search results; Use multi-source verification technology to remove AI illusions and obtain the same or related legal documents from multiple official legal databases for content comparison; Adopting fact-checking technology based on knowledge graph, checking whether the legal relationship and facts in the search results are correct according to the constructed legal knowledge graph; The large model ultimately generates intelligent answers based on the legal knowledge base and presents them to users in the form of streaming output.
Citation Information
Cited By
Intelligent question answering method and device based on domain knowledge lightweight fine tuning and cross-domain dynamic knowledge base and readable storage medium thereof
CN120296110A
Government affair file intelligent classification and retrieval system
CN120407796A
Nuclear power plant design text-oriented specification introduction information generation method and device and related equipment
CN120873209A
Method and device for generating specification citation information for nuclear power plant design text and related equipment
CN120873209B
Legal document data sharing method based on data analysis
CN121030809A