Multipath fusion-based law and regulation recommendation system and method

By integrating multiple recall strategies and knowledge enhancement methods in the legal and regulatory recommendation system, the problems of insufficient semantic understanding and low accuracy in the existing technology are solved, and the immediacy and accuracy of legal and regulatory recommendations are achieved.

CN119903234AActive Publication Date: 2025-04-29中国司法大数据研究院有限公司

Patent Information

Application Number
CN202411968921.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-30
Publication Date
2025-04-29
Estimated Expiration
2044-12-30

AI Technical Summary

Technical Problem

The existing legal search and recommendation technologies have problems such as insufficient understanding of semantics, low accuracy and inaccurate capture of user intentions, and cannot meet the dual needs of immediacy and accuracy of users in the legal consultation process.

Method used

A legal and regulatory recommendation system based on multiple fusion is proposed. Through various recall strategies such as fusion rule recall, knowledge recall and standard answer recall, RRF technology is used to fusion and rearrange multiple results. Combining knowledge-enhancing methods such as intent understanding and topic dictionary construction, the correlation between problems and laws is strengthened.

Benefits of technology

It significantly improves the accuracy of legal and regulatory recommendations, ensures the immediacy and accuracy of the recommendation process, and meets users' needs for accurate legal recommendations and real-time responses.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119903234A_ABST
    Figure CN119903234A_ABST
Patent Text Reader

Abstract

The invention discloses a law and regulation recommendation system and method based on multi-path fusion. The method comprises the following steps: 1) splitting laws and regulations texts according to law provisions, extracting structured contents, and constructing a laws and regulations set E; 2) constructing a standard answer library, wherein the standard answer library comprises a plurality of QA pairs; (3) vectorizing each law article in E by using the fine-tuned embedding model E '(.), and vectorizing each problem Q by using the pre-trained embedding model E (.); 4) performing entity extraction, semantic understanding and knowledge enhancement on the user question Q to serve as extension information Qe of the user question Q; using E '(.) to carry out vectorization weighted fusion on the user questions Q and Qe to obtain a question vector Qvec representing the user intention; 5) selecting k legal provisions most related to the user question Q from multiple recall results; and 6) calculating a reordering score of each of the k legal provisions and the user question Q, and returning a plurality of legal provisions with the highest reordering score to the user.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of information recall of natural language processing, and relates to the recall recommendation of laws and regulations, and specifically to a law and regulation recommendation system and method based on multi-channel fusion, that is, recommending relevant laws and regulations that can solve the legal problem input by the user. Background Art

[0002] With the popularization of the Internet and the enhancement of public legal awareness, more and more people choose to obtain legal consulting services through the Internet. Existing legal article retrieval technologies mainly include methods based on keyword matching, label classification, and traditional classification models. However, these methods each have certain limitations and are difficult to meet users' needs for accurate legal article recommendations and real-time responses.

[0003] 1. Keyword-based search methods: This type of method relies on matching keywords in user questions to search for legal provisions. Although it can quickly find legal provisions related to keywords, due to the lack of a deep understanding of semantics, keyword matching may cause search results to be inconsistent with the user's true intentions. For example, if the legal questions asked by users contain synonyms or keywords with different expressions, keyword-based searches often fail to accurately capture user needs, resulting in biased results.

[0004] 2. Tag-based retrieval method: This method achieves fast retrieval by adding tags or classification tags to legal provisions. Although tagging helps narrow the search scope, the accuracy and comprehensiveness of the tags are crucial to the effectiveness of the system. Tag classification is usually rough and cannot deal with complex and abstract legal issues. In addition, it is difficult to update and manage tags, which may cause some legal provisions to be misclassified or omitted, affecting the accuracy of recommendations.

[0005] 3. Retrieval method based on classification model: The classification model classifies legal issues into different categories through training data sets, and then returns relevant laws based on the categories. Although this method can provide a certain degree of accuracy in some cases, it lacks flexibility and is highly dependent on training data. If the training data is insufficient or there are deviations in the data annotation, the accuracy of the classification model will drop significantly. In addition, the classification model still lacks a deep semantic understanding of user questions, making it difficult to capture complex legal scenarios and user personalized needs.

[0006] In summary, existing legal retrieval and recommendation technologies generally have problems such as insufficient semantic understanding, low accuracy, and inaccurate capture of user intentions, which cannot meet the dual needs of users for immediacy and accuracy in the legal consultation process. Therefore, there is an urgent need for a system that can accurately predict and recommend relevant legal provisions based on deep semantic understanding to improve the efficiency and quality of legal consultation retrieval services. Summary of the invention

[0007] The present invention aims to solve the problems of low efficiency and poor accuracy in existing methods for recommending laws and regulations, and therefore proposes a system and method for recommending laws and regulations based on multi-channel fusion. This method fuses multiple recall strategies such as rule recall, knowledge recall, and standard answer recall, and uses RRF technology to fuse and rearrange multi-channel results. At the same time, combined with knowledge enhancement methods such as intent understanding and subject dictionary construction, the correlation between questions and laws is strengthened, the accuracy of legal and regulatory recommendations is significantly improved, and the immediacy and accuracy of the recommendation process are ensured.

[0008] The technical solution of the present invention is:

[0009] A method for recommending laws and regulations based on multi-channel fusion, the steps of which include:

[0010] 1) Split the legal texts by article and extract structured content to construct a legal set E = {l i |i=1,2,…,n}; where l i represents the ith legal article;

[0011] 2) constructing a standard answer library, wherein the standard answer library includes a plurality of QA pairs, each of which includes a question Q and an answer text A;

[0012] 3) Fine-tune the pre-trained embedding model E(·) using the question-legal pair dataset G to obtain the fine-tuned embedding model E′(·); vectorize each legal provision in the legal and regulatory set E using the embedding model E′(·) and store it in the legal provision vector library; for each question Q in the standard question-answering library, use the pre-trained embedding model E(·) to vectorize and store it in the legal provision vector library;

[0013] 4) Use the question understanding module to extract entities, understand semantics, and enhance knowledge of the received user question Q as the extended information Q of the user question Q e ; Use the embedding model E′(·) to analyze the user question Q and its extended information Q e After vectorization, the obtained vectors are weighted and fused to obtain a question vector Q representing the user’s intention. vec ;

[0014] 5) Use the BM25 model to recall several relevant laws that are most relevant to the user's question Q from the legal database E; according to the question vector Q vec Calculate the similarity with each legal article vector in the legal article vector library, and recall several legal articles with the highest similarity; and select several question-answer pairs with similar semantics to the user question Q from the standard answer library and extract legal articles from the answer part of each selected question-answer pair to obtain the relevant legal article set LA As the recall result; then comprehensively sort the recall results, and select the top-k laws L={L1,L2,…,L k};

[0015] 6) The top-k laws L={L1,L2,…,L k} and user question Q are input into the rearrangement model to calculate L = {L1, L2, …, L k} and the re-ranking scores of each legal provision and the user's question Q, and return the legal provisions with the highest re-ranking scores to the user.

[0016] Furthermore, in step 1), a multi-stage prompt word is designed, including a prompt word P for generating a topic word. m , Prompt word P used to generate keywords k , Prompt word P used to generate the interpretation of the keyword d , used to generate prompt words P for potential legal issues related to legal provisions q ; For each article i , first use the prompt word P m Guide the large language model to generate topic words and use the prompt word P k Guide the large language model to generate keywords, and use the generated subject words and keywords to search for legal provisions. i Mark it; then for the legal article l i Each keyword k ij , use the prompt word P d Guide the large language model to generate interpretation D(k ij );Then based on this law i The subject words, keywords and definitions of q Generation and Law i Related potential legal issues, predict the legal provisions i Practical application scenarios of Q(T(l i ),k ij ,D(k ij ))={q1,q2,…,q m}, where q m For the law i The corresponding mth potential problem.

[0017] Furthermore, the method for constructing the standard answer library is: first, a fuzzy matching method is used to filter out answer texts that do not mention legal clauses, and then regular extraction is performed on each answer text to obtain the legal provisions and their numbers contained therein, and the legal status of each extracted legal provision is detected. If the answer text contains any invalid, repealed or non-existent legal provisions, the QA pairs in the answer text will be filtered; then a natural language reasoning matching screening method is used to perform preliminary screening on each retained QA pair, and then a multi-model verification method is used to verify each QA pair retained after the preliminary screening, and the QA pairs that pass the verification are stored in the standard answer library.

[0018] Furthermore, the problem-law pair dataset G = {(Q j1 ,Q j2 ,…,Q jm ,L j )|j=1,2,…,N}, where the law L j With m questions Q j1 ,Q j2 ,…,Q jm Related, Q jm Indicates that the large language model is based on the law L j The mth question generated.

[0019] Furthermore, a sparse network layer is introduced at the output end of the pre-trained embedding model E(·) to generate a sparse vector.

[0020] Furthermore, the embedding model E′(·) is used to transform each legal article l in the legal and regulatory set E into a dense vector e l and the sparse vector w l And store it in the legal article vector library, use the embedding model E′(·) to convert the associated knowledge corresponding to each legal article l into dense vectors and sparse vectors and store them in the legal article vector library; for each question Q in the standard question-answering library, use the pre-trained embedding model E(·) to generate the dense vector e of the question Q Q and the sparse vector w l And stored in the legal article vector library; the related knowledge includes subject terms, keywords, interpretations and potential problems.

[0021] Furthermore, Article 1 i ={regulation name, item number, timeliness, legal type, legal content, ...}; each legal article is stored in a tree or table structure.

[0022] A law and regulation recommendation system based on multi-path fusion, characterized by comprising a law and regulation set construction module, a standard answer library construction module, a law article vector library construction module, a question understanding module, a multi-path recall module and a rearrangement model;

[0023] The legal regulations set building module is used to split the legal regulations text according to the legal provisions and extract the structured content to build the legal regulations set E = {l i |i=1,2,…,n}; where l i represents the ith legal article;

[0024] The standard answer library construction module is used to construct a standard answer library, wherein the standard answer library includes a plurality of QA pairs, each QA pair includes a question Q and an answer text A;

[0025] The legal article vector library construction module is used to fine-tune the pre-trained embedding model E(·) using the question-legal article pair dataset G to obtain the fine-tuned embedding model E′(·); then use the embedding model E′(·) to vectorize each legal article in the legal and regulatory set E and store it in the legal article vector library; and for each question Q in the standard question-answering library, use the pre-trained embedding model E(·) to vectorize and store it in the legal article vector library;

[0026] The question understanding module is used to extract entities, understand semantics and enhance knowledge of the received user question Q as the extended information Q of the user question Q. e ; Use the embedding model E′(·) to analyze the user question Q and its extended information Q e After vectorization, the obtained vectors are weighted and fused to obtain a question vector Q representing the user’s intention. vec ;

[0027] The multi-path recall module is used to use the BM25 model to recall several relevant laws that are most relevant to the user's question Q from the legal database E; according to the question vector Q vec Calculate the similarity with each legal article vector in the legal article vector library, and recall several legal articles with the highest similarity; and select several question-answer pairs with similar semantics to the user question Q from the standard answer library and extract legal articles from the answer part of each selected question-answer pair to obtain the relevant legal article set L A As the recall result; then comprehensively sort the recall results, and select the top-k laws L={L1,L2,…,L k};

[0028] The rearrangement model is used to calculate the top-k laws L = {L1, L2, ..., L k} and the re-ranking scores of each legal provision and the user's question Q, and return the legal provisions with the highest re-ranking scores to the user.

[0029] A server, characterized in that it comprises a memory and a processor, wherein the memory stores a computer program, the computer program is configured to be executed by the processor, and the computer program comprises instructions for executing the above method.

[0030] A computer-readable storage medium stores a computer program, wherein the computer program implements the above method when executed by a processor.

[0031] A method for recommending laws and regulations based on multi-channel fusion includes the following steps:

[0032] Step 1: Construction of the legal and regulatory database: (a) Obtain the latest and most complete legal and regulatory texts from multiple sources such as national laws, local regulations, and legislative materials; split the collected laws and regulations by article, and extract structured content to construct a legal and regulatory set E = {l i |i=1,2,…,n}. Among them, l i Indicates the i-th legal article and contains the following text information: i = {regulation name, item number, timeliness, legal type, legal content, ...}. The legal provisions are stored in a tree or table structure to facilitate subsequent recall and related queries. (b) To further improve the accuracy of the recommendation, a multi-stage prompt word (Prompt) is designed to guide the large language model to parse the legal text and generate metadata related to the legal provision, including subject terms, keywords, keyword interpretations, and potential legal issues. The multi-stage prompt word (Prompt) includes the prompt word P used to generate the subject term. m , Prompt word P used to generate keywords k , Prompt word P used to generate the interpretation of the keyword d , used to generate prompt words P for potential legal issues related to legal provisions q First, use the prompt word P m Generate subject words and prompt words P k Generate keywords. These subject words and keywords are used to mark the core content of the law, which is convenient for quick indexing and matching. ij , use the prompt word P d Guide the model to generate detailed explanations and background information: D(k ij )=Interpretation(k ij ), the prompt word P d Input the large language model to directly generate keyword k ij Finally, based on the subject words, keywords and definitions, use the prompt word P q Generate potential legal issues related to the law and predict the actual application scenarios of the law: Q(T(l i ),k ij,D(k ij ))={q1,q2,…,q m}, where the keyword T(l i ), keyword k ij 、Interpretation D(k ij ), prompt word P q Input a large language model and output Q(T(l i ),k ij ,D(k ij ))={q1,q2,…,q m}, q m The mth potential problem corresponding to the i-th legal article. By splitting and structuring the storage of laws and regulations, the system can quickly recall and manage a large number of legal texts.

[0033] Step 2: Construction of a standard answer database: (a) Automatically collect millions of real user legal consultation question and answer pairs (QA pairs) from the Internet and the company's legal and regulatory recommendation systems to ensure that the collection scope is wide and covers various legal and regulatory scenarios. (b) In order to ensure the high quality and consistency of the standard answer database, strict quality screening is required to filter out invalid or unqualified QA pairs. The final standard answer database includes multiple QA pairs, each QA pair includes a question Q and an answer text A, as a standard legal Q and A pair. The following multi-level quality screening method is used:

[0034] 1. Fuzzy matching and rule filtering

[0035] In order to ensure that the answers to the QA pairs in the standard answer library are based on clear legal provisions, we must first exclude those answers that do not cite laws and regulations. Fuzzy matching and rule filtering methods are used to identify and filter these invalid answers. Specifically, fuzzy matching is to filter out answers that do not mention legal provisions by searching for keywords containing legal terms and clause numbers, such as "XX Law", "Article XX", "XX Interpretation", etc. For example, these keywords are matched through regular expressions:

[0036]

[0037] Only answers that satisfy Match(A) = 1 will be retained. Further, rule filtering is to extract legal provisions and their numbers from the answer text A, such as "Labor Law Article 47". These identified legal provisions are temporarily stored as a set L A ={l1,l2…,l n}, where l i Indicates the i-th clause cited in the answer, i = 1 to n. Each identified legal clause l iIt will be matched with the legal database D in the system. Database D contains all currently valid legal clauses and their status (valid, invalid, revoked).

[0038]

[0039] Among them, D valid Indicates the currently valid set of laws. If all laws in the answer pass the check (i.e. Valid Law Check(l i )=1 for all l i ∈L A If true, the answer is retained:

[0040]

[0041] If the answer contains any invalid, repealed or non-existent laws, the QA pair will be filtered.

[0042] 2. Natural language reasoning matching screening

[0043] In order to ensure the semantic relevance of questions and answers, the natural language inference (NLI) matching algorithm is introduced for preliminary screening. The NLI model can judge the relationship between questions and answers (implication, contradiction, neutrality) to ensure that the answer does respond to the intention of the question.

[0044] How the NLI model works: Given a question (Q) and an answer (A), the NLI model determines whether there is one of the following relationships between A and Q:

[0045] Entailment: The answer is a valid response to the question.

[0046] Contradiction: The answer contradicts the question.

[0047] Neutral: The answer is irrelevant to the question and does not directly answer the question.

[0048] Screening rules and decision formula: Use the NLI model trained with RoBERTa, input question Q and answer A into the model, and generate the probability distribution of three types of relationships: P(E)+P(C)+P(N)=1. Among them, P(E) represents the probability of entailment, P(C) represents the probability of contradiction, and P(N) represents the probability of neutrality. The NLI screening rules are as follows:

[0049]

[0050] Among them, θ is the threshold of the implied probability (the recommended value is 0.85). Only when P(E) is higher than θ, the QA pair is retained. Otherwise, the QA pair will be filtered. Through the NLI screening method, it is possible to more accurately determine whether the answer truly responds to the question, thereby reducing the entry of irrelevant or invalid question and answer pairs and improving the overall quality of the standard answer library.

[0051] 3. Multi-model verification

[0052] To further enhance the robustness of quality screening. After preliminary screening, multiple advanced semantic models (such as BERT, SimCSE, and large language models) are used to perform in-depth verification on the screened QA pairs, calculate their comprehensive scores, and ensure the consistency of the question-answer pairs in the multi-model semantic space. Multiple semantic matching models are integrated to calculate the consistency scores and take the average to ensure the robustness of the results:

[0053]

[0054] Among them, Score i is the matching score of the i-th model, and n is the total number of models. Only QA pairs whose final scores exceed a certain threshold can be included in the standard answer library.

[0055] (c) Add high-quality QA pairs that have been screened to the standard answer library in an incremental manner. After each update, the system performs a deduplication operation on the newly added QA pairs to ensure that there is no semantic duplication in the library. Incremental update formula: A t+1 =A t ∪ΔA. Where A t is the standard answer library at time t, and ΔA is the newly screened incremental QA pair.

[0056] (d) Automatically update and build the standard question and answer database A. The system automatically executes the above steps (a), (b) and (c) at set time intervals (such as daily or weekly) to ensure that the content of the standard answer database is always up to date and complete. The automation process can be implemented through a cyclic task scheduling system, for example: T(i+1)=T(i)+Δt, where T(i) is the i-th execution time and Δt is the interval period. The automation process designed in this way ensures that the standard answer database can dynamically adapt to the latest laws and regulations and user needs, providing reliable knowledge support for the system's recommendation performance.

[0057] Step 3: Construction of legal article vector library: In order to realize an efficient legal and regulatory recommendation system based on multi-channel fusion, it is necessary to build sparse and dense vector libraries to achieve semantic matching and efficient recall of legal articles and questions.

[0058] (a) Synthetic fine-tuning data based on LLM

[0059] Due to the lack of sufficient high-quality question-legal pair data, this system uses a large language model to select appropriate question generation strategies for each legal article and randomly generate multiple questions to build a diverse synthetic data set. These questions must be rich and comprehensive in breadth and depth to ensure that each legal article is understood and expressed from multiple perspectives. The following are some question generation strategies:

[0060] 1. Background questions: Generate questions based on the applicable context of the law, simulating the background questions that users may ask in real life. Example: For labor law, generate questions such as "Can a company fire an employee without reason during the probation period?"

[0061] 2. Reverse reasoning questions: Construct opposing or opposite situations to test the boundaries and exceptions of laws. Example: For the clauses in the Consumer Rights Protection Law, generate questions such as "Can I apply for a refund if the return time exceeds 7 days?"

[0062] 3. Detail questions: Focus on the specific details of the law, such as time, amount, procedural provisions, etc. Example: For tax law provisions, generate questions such as "By what date does the annual declaration need to be completed?"

[0063] 4. Fuzzy questions: Generate questions with vague or informal descriptions to simulate the user's daily language expression. Example: Based on the provisions of intellectual property law, generate questions such as "Is it legal to steal someone else's creative pictures?"

[0064] 5. Clause comparison questions: Compare the differences between similar or close clauses to help users understand the nuances. Example: For clauses in contract law and consumer law, generate questions such as "What are the differences between a contract for the sale of goods and a contract for services?"

[0065] 6. Multi-step reasoning questions: Design questions that require reasoning across multiple clauses or regulations to arrive at answers, simulating complex situations. Example: For multiple clauses in the Company Law, generate questions such as "Can a company shareholder transfer shares after a creditor files a lawsuit?"

[0066] 7. Case analysis questions: Generate questions based on actual or hypothetical cases to help the model handle complex situations. Example: For criminal law provisions, generate questions such as "If A spreads rumors in public, does it constitute a crime?"

[0067] Based on the above policy examples (not limited to these types), we randomly select applicable policies for each law and generate multiple questions to form a diverse dataset of question-law pairs G = {(Q j1 ,Q j2 ,…,Q jm ,L j )|j=1,2,…,N}, where the law L jWith m questions Q j1 ,Q j2 ,…,Q jm associated to enhance the diversity and coverage of the dataset, Q jm Indicates that the large language model is based on the law L j The mth question generated.

[0068] (b) Fine-tuning the embedding model based on synthetic datasets

[0069] The pre-trained embedding model E(·) is trained based on general corpus and is more suitable for similarity measurement in general scenarios. However, when applied to the legal field, the model is often insufficient in understanding legal terminology, logical relationships between legal provisions, and domain-specific semantics. To this end, it is necessary to use legal field data for fine-tuning so that the model can better adapt to the semantic association and matching needs in legal scenarios. Therefore, this patent uses the generated dataset G to fine-tune the pre-trained embedding model E(·) so that the model can better capture the semantic association between questions and legal provisions. During the fine-tuning process, the model will simultaneously optimize the representation of dense and sparse vectors to improve the accuracy of recall and matching. Specifically, each pair of data (Q, L) ∈ G will generate a hidden state vector: H Q =E(Q),H L =E(L). Next, use norm(·) to analyze the problem vector H Q and the law vector H L Normalize the first vector of to get their respective dense vectors: e Q =norm(H Q [0]), e L =norm(H L [0]). The core of dense recall is to calculate the inner product between the question and the law to measure their semantic relevance: dense = <e Q ,e L >. Here, the <·> operation represents the inner product between two embedded vectors. The larger the inner product value, the higher the semantic relevance between the problem and the law. Considering the particularity of the legal field, a sparse network layer is introduced at the output end of E(·) to solve the problems of domain adaptability, information density and computational efficiency of the model. The sparse network layer is used to generate sparse vectors. Its input H Q , the output is w Qt, and the results are stored in the Milvus database. Sparse network layers perform well when dealing with specialized terms or rare keywords, and focus on key features rather than capturing all subtle relationships, which makes them more efficient in text search. The main purpose of the sparsification process is to select important terms in questions and laws based on the weight estimation of terms, and use the weights of these terms for vocabulary recall. Here, the hidden state vector H is used Q and H L To estimate the importance of each term. Specifically, for each term in the question, its importance in the question is determined by calculating its weight. The weight calculation formula is: in, is a weight matrix that maps hidden states to scalars. Q [i] represents the hidden state vector of the i-th term in the question. ReLU(·) is the rectified linear unit (ReLU) activation function, which is used to ensure that the weights are non-negative. If a term t appears multiple times in the question, only the maximum weight (i.e., the greatest importance) of the term is retained. This strategy ensures that repeated terms are not overestimated by simple frequency accumulation. Next, the weights of the terms in the law are calculated in the same way: H L [i] represents the hidden state vector of the i-th term in the legal provision. Similarly, for terms that appear repeatedly in the legal provision, only its maximum weight is retained. Further, it is necessary to calculate the relevance score between the question and the legal provision, considering the terms they share (i.e., Q∩L), and calculate the final matching score based on the weights of these terms: s sparse =∑ t∈Q∩L (w Qt ·w Lt ). Among them, w Qt and w Lt The formula is obtained by summing the weights of all common terms to obtain the lexical relevance score s between the question and the law. sparse . Finally, a joint loss function is used to optimize the semantic relevance of sparse and dense vectors. Through the above steps, the fine-tuned embedding model is expressed as: E′(·)=FineTune(E(·),G). The fine-tuned model E′(·) can generate high-quality dense and sparse vectors and better capture the semantic association between questions and laws. This optimization process ensures the semantic matching ability of the model at different levels, enabling the legal and regulatory recommendation system to have higher accuracy and efficiency in complex recall tasks.

[0070] (c) Legal provisions, related knowledge, and standard issues are stored in the database

[0071] In order to achieve efficient recall and matching, candidate laws, related knowledge (such as subject terms, keywords, interpretations, and potential problems), and questions in the standard question-answering database are encoded into dense vectors and sparse vectors, and these vectors are stored in the Milvus vector database for fast query. Specifically, the law L is converted into a dense vector e using the pre-trained and fine-tuned embedding model E′(·). L and the sparse vector w L , and then cached in the Milvus vector database. After storing the vector, the system builds an ANN (approximate nearest neighbor) index for the dense vector table in the Milvus database to improve recall performance. Similarly, the associated knowledge also uses the fine-tuned embedding model E′(·) to complete this vectorization storage process, generating dense vectors and sparse vectors corresponding to each associated knowledge. Furthermore, for each question Q in the standard question-answering database, the unfine-tuned embedding model E(·) is used to generate a dense e Q and the sparse vector w Q Similarly, the generated question vectors are stored in the corresponding table of Milvus.

[0072] Step 4: Understand the user's question Q. After the user enters a question Q, the system's question understanding module will conduct an in-depth analysis of the question, including entity extraction, semantic understanding, and knowledge enhancement. Specifically, it is divided into the following three steps:

[0073] (a) Entity Extraction: Use the UIE (Unified Information Extraction) model to extract key entities from question Q, such as the legal name Q title , Entry No. Q item and query subject Q key The purpose of using the UIE model is its efficiency and accuracy, which can quickly identify and extract relevant legal entities in the text. Q = {Q title :[e1,…,e n ],Q item :[e1,…,e n ],Q key :[e1,…,e n ]}.

[0074] (b) Semantic understanding: guiding the large language model to accurately parse the implicit meaning and complex context in the question. This step guides the model to not only recognize the literal meaning of the question, but also capture the underlying semantic level, such as the specific application of legal terms and context-dependent meaning interpretation, by constructing a specific prompt template.

[0075] (c) Knowledge enhancement: The prompt of the large language model is designed to summarize key information such as legal terms, dispute focus, legal issues, and problem explanations. At this stage, the model uses its extensive legal knowledge base and semantic understanding capabilities acquired in previous training to conduct an in-depth analysis of the problem, thereby providing detailed legal insights and explanations, helping the system to accurately identify and respond to users' legal consulting needs.

[0076] (d) Integrate the information analyzed in (a), (b), and (c) as the extended information Q of the question e , and use the embedding model E′(·) fine-tuned in step 3 to encode Q and Q e , and then weighted fusion is performed to obtain a question vector Q representing the user's intention vec .

[0077] Step 5: Multi-path recall: In order to improve the accuracy and coverage of the legal and regulatory recommendation system, the present invention integrates different information sources and model capabilities through a multi-path recall method. This process includes three recall paths: rule recall, knowledge recall, and standard answer recall. The results of each path are comprehensively ranked using weighted fusion and RRF (Reciprocal Rank Fusion) algorithms, and finally the relevant laws for the next stage (i.e., the re-ranking stage) are obtained.

[0078] (a) The first path (rule recall) uses the BM25 model for recall. This model mainly evaluates the relevance of questions and legal provisions based on word frequency and reverse document frequency. For user question Q, the BM25 model is used to recall the top p relevant legal provisions that are most relevant to question Q from the legal and regulatory database E. The scoring function of BM25 is:

[0079]

[0080] Where M is the total number of laws, m(t) is the number of laws containing word t, f(t,L) is the number of times word t appears in law L, |L| is the length of law L, avgdL is the average length of law, k1 and b are adjustable hyperparameters. The matching score of each law is calculated through BM25, and the top-p laws are returned.

[0081] (b) The second path (knowledge recall) uses the fine-tuned embedding model E′(·) to parse the user question Q and its extended information Q e Encode and generate a vector representation Q vec =αE′(Q)+βE′(Q e), where α and β are adjustable parameters and α+β=1. The semantic similarity between this vector and the legal article vector in the legal article vector library is calculated. The legal articles in the legal article vector library have integrated legal knowledge such as themes and interpretations to enhance semantic matching capabilities. Vector recall uses cosine similarity to calculate the similarity between the question and the legal article:

[0082]

[0083] Among them, Q vec The vector representation of the user's question, L vec is the vector representation of the legal provisions. Finally, the top-p legal provisions are recalled.

[0084] (c) The third path (standard answer recall) recalls the top-n question-answer pairs (Q, A) that are semantically similar to the user’s question Q from the standard answer database. i ). Answer part A i Extract legal provisions and obtain the relevant legal provision set L A ={L A1 ,L A2 ,…,L An}.

[0085] (d) Fusion and sorting of multi-path recall results. The RRF algorithm is used to fuse the recall results of the three paths. i The RRF score is calculated as follows:

[0086]

[0087] Where R is the number of paths, k r is the smoothing parameter of path r, rank r (L i ) is the legal provision L i The ranking in path r. Finally, the laws are sorted according to the RRF score, and the top-k laws are returned as the input of the next stage (i.e., the re-ranking stage).

[0088] Step 6: After obtaining the top-k laws through multi-way recall, the system enters the re-ranking stage to further optimize the recommendation order. In this stage, the preliminary recall results are re-ranked through the re-ranking model to improve the accuracy and relevance of the recommendation results. The re-ranking model is a supervised learning model, and its input is the top-k laws obtained through multi-way recall L = {L1, L2, ..., L k} and user question Q, the output is the re-ranking score S(L i ) and the final ranking. The goal of the rearrangement model is to capture the deep semantic relationship between legal provisions and user questions, and to perform refined ranking by combining contextual information and legal knowledge of legal provisions.

[0089] The advantages of the present invention are as follows:

[0090] Advantage 1: Multi-path fusion: Through parallel retrieval through three paths of rule recall, knowledge recall and standard answer recall, and using RRF for fusion and rearrangement, the advantages of different information sources are efficiently integrated, thereby significantly improving the accuracy and comprehensiveness of legal article recommendations.

[0091] Advantage 2: Knowledge enhancement and multi-dimensional vectorization: Metadata such as subject terms, keywords, interpretations, and potential legal issues are introduced into the construction of the legal and regulatory database, and the legal provisions are deeply analyzed and annotated through multi-stage prompt technology. At the same time, the legal provisions and related knowledge are sparsely and densely vectorized, so that the system can obtain robust results based on the weight of the terms during retrieval, and can also achieve high-relevance matching based on the embedded model of deep semantic understanding, thereby achieving fast, accurate, and deeply intelligent legal and regulatory recommendations.

[0092] Advantage 3: Automatically build a high-quality standard answer library: Through automated collection, strict multi-level quality screening and multi-model verification strategies, a highly reliable standard answer library is built, providing an effective reference for one of the recall paths. This rigorous data governance and optimization process ensures that the system can continuously and stably provide accurate and reliable legal article recommendation results in complex legal consulting scenarios. BRIEF DESCRIPTION OF THE DRAWINGS

[0093] Figure 1 It is a model framework diagram of an embodiment.

[0094] Figure 2 Schematic diagram of automatic incremental update of the standard answer library construction in the embodiment. DETAILED DESCRIPTION

[0095] The present invention is further described in detail below in conjunction with the accompanying drawings. The examples given are only used to explain the present invention but not to limit the scope of the present invention.

[0096] Example:

[0097] Reference Figure 1 , a law and regulation recommendation system and method based on multi-channel fusion, comprising the following steps:

[0098] Step 1: Build a legal and regulatory database.

[0099] Obtain the latest and most complete legal and regulatory texts from multiple sources such as national laws, local regulations, and legislative materials; split the collected laws and regulations by article, and extract structured content to build a legal and regulatory database E = {l i |i=1,2,…,n}. Among them, l i Indicates the i-th legal article and contains the following legal article information: i={regulation name, item number, timeliness, legal type, legal content, ...}. Table 1 is an example of legal provisions in the legal and regulatory database.

[0100] Table 1 Examples of legal provisions

[0101]

[0102]

[0103] As shown in Table 2, a multi-stage prompt is designed to guide the large language model to parse the legal text and generate metadata related to the legal text, including subject terms, keywords, keyword interpretations, and potential legal issues. By splitting and structuring the storage of laws and regulations, the system can quickly recall and manage a large amount of legal text. Table 3 shows the metadata information related to the legal text parsed by the large model.

[0104] Table 2 Multi-stage prompt example (confidential content omitted)

[0105]

[0106]

[0107] Table 3 Metadata examples

[0108]

[0109] Step 2: Construction of standard answer database.

[0110] like Figure 2 The following is a schematic diagram of the automatic incremental update of the standard answer database. (a) Automatically capture and collect millions of real user legal consultation question and answer pairs (QA pairs) from the Internet and the company's legal and regulatory recommendation system to ensure that the collection scope is wide and covers various legal and regulatory scenarios. Table 4 lists some examples of the initial QA pairs collected.

[0111] Table 4 Examples of initial QA pairs

[0112]

[0113]

[0114] (b) Further, the initial QA pairs are strictly screened for quality to filter out invalid or unqualified question-answer pairs. Specifically, a multi-level quality screening method is used:

[0115] 1. Use fuzzy matching to match legal terms in the answer, such as "Labor Law" in A1 and "Civil Code" in A2. Through fuzzy matching, (Q1, A1), (Q2, A2), (Q3, A3), (Q6, A6), and (Q7, A7) all match specific legal terms, so they pass the fuzzy matching screening and are retained. However, (Q4, A4) and (Q5, A5) do not quote legal terms and are filtered out. Further, rule filtering is to perform regular extraction of legal terms and their numbers on the answer text A, such as extracting "Article 10 of the Contract Law of the People's Republic of China" from A3. Each identified legal term will be matched with the legal database in the system. The database contains all currently valid legal terms and their status (valid, invalid, abolished). If the answer contains any invalid, abolished or non-existent legal terms, the QA pair will be filtered. For example, "Article 10 of the Contract Law of the People's Republic of China" in (Q3, A3) is marked as invalid in the database and is filtered out.

[0116] 2. Use the natural language inference (NLI) model to determine the relationship between questions and answers. The screening rules and decision formulas are as follows: Input question Q and answer A into the NLI model trained with RoBERTa as the base to generate the probability distribution of three types of relationships: P(E)+P(C)+P(N)=1. Among them, P(E) represents the probability of implication, P(C) represents the probability of contradiction, and P(N) represents the probability of neutrality. The NLI screening rules are as follows:

[0117]

[0118] Among them, θ is the threshold of the implied probability (the recommended value is 0.85). Only when P(E) is higher than θ, the QA pair is retained. Otherwise, the QA pair will be filtered. Therefore, for the QA pair in the example, the following results are obtained:

[0119] (Q1, A1)-P(E)=0.98 (implied)

[0120] (Q2, A2)-P(E)=0.90 (implied)

[0121] (Q7, A7) — P(E) = 0.20 (contradiction)

[0122] Entailment means that the answer is a valid response to the question. (Q1, A1) and (Q2, A2) meet the requirements and need to be retained. Contradiction or neutrality means that the answer is contradictory or irrelevant to the question. Therefore, (Q7, A7) needs to be filtered out. Through the NLI screening method, it is possible to more accurately determine whether the answer truly responds to the question, thereby reducing the entry of irrelevant or invalid question-answer pairs and improving the overall quality of the standard answer library.

[0123] 3. Further, the retained QA pairs are deeply verified using multi-model verification to calculate the comprehensive score. Specifically, multiple advanced semantic models such as BERT, SimCSE, and large language models are used to calculate the relevance score of each pair of QA and take the average value:

[0124]

[0125] Among them, Score i is the matching score of the i-th model, and n is the total number of models. Only QA pairs whose final scores exceed the set threshold (0.85) can be included in the standard answer library. The input QA pairs and model scores are as follows:

[0126] Score_1(Q1,A1)=0.88, Score_2(Q1,A1)=0.96, Score_2(Q1,A1)=0.92

[0127] Score_1(Q2,A2)=0.87, Score_2(Q2,A2)=0.85, Score_2(Q1,A1)=0.93

[0128] Score_1(Q6,A6)=0.78, Score_2(Q6,A6)=0.80, Score_2(Q6,A6)=0.69

[0129] Calculate the final score:

[0130] (Q1,A1):Final score=(0.88+0.96+0.92) / 3=0.92

[0131] (Q2,A2):Final score=(0.87+0.85+0.93) / 3=0.88

[0132] (Q6,A6):Final score=(0.78+0.80+0.69) / 3=0.75

[0133] Filter results:

[0134] The scores of (Q1, A1) and (Q2, A2) are higher than the threshold and are retained.

[0135] The score of (Q6, A6) does not reach the threshold and is filtered out.

[0136] (c) Add high-quality QA pairs that have been screened to the standard answer library in an incremental manner. After each update, the system performs a deduplication operation on the newly added QA pairs to ensure that there is no semantic duplication in the library. Incremental update formula: A t+1 =A t∪ΔA. Where A t is the standard answer library at time t, and ΔA is the newly screened incremental QA pair.

[0137] (d) Automatically update and build the standard question and answer database A. The system automatically executes the above steps (a), (b) and (c) at set time intervals (such as daily or weekly) to ensure that the content of the standard answer database is always up to date and complete. The automation process can be implemented through a cyclic task scheduling system, for example: T(i+1)=T(i)+Δt, where T(i) is the i-th execution time and Δt is the interval period. The automation process designed in this way ensures that the standard answer database can dynamically adapt to the latest laws and regulations and user needs, providing reliable knowledge support for the system's recommendation performance.

[0138] Step 3: Build sparse and dense vector libraries.

[0139] Using a large language model to synthesize high-quality question-legal pairs as training samples, fine-tuning the BGE-M3 model to obtain a new embedding model E suitable for the legal field model , and use this model to encode legal provisions-related knowledge (such as subject terms, interpretations, etc.) and questions in the standard question-answering database into dense and sparse vectors, respectively expressed as: LK dense ={lk d1 ,lk d2 ,…,lk dn},

[0140] LK sparse ={lk s1 ,lk s2 ,…,lk sn},

[0141] Q dense = {q d1 ,q d2 ,…,q dn},

[0142] Q sparse = {q s1 ,q s2 ,…,q sn}.

[0143] Each legal article vector has integrated legal knowledge such as subject matter and interpretation, and then these vectors are stored in the Milvus vector database. After the vectors are stored, the system builds an ANN (approximate nearest neighbor) index for the dense vector table in the Milvus database for fast query.

[0144] Step 4: Generally, for a user question Q, first Figure 1 The question understanding module performs in-depth analysis of Q. Specifically, it includes the following sub-steps:

[0145] (a) Using the UIE (Unified Information Extraction) model to extract legal-related terms, concepts, entities, etc. from Q for auxiliary query, such as the legal name Q title ={e1,…,e n}, Entry No. Q item ={e1,…,e n} and query subject Q key ={e1,…,e n}wait.

[0146] (b) Guide the large language model to accurately parse the implicit meaning and complex context in the question. This step guides the model to not only recognize the literal meaning of the question, but also capture the potential semantic level S by constructing a specific prompt template. Q , such as the specific application of legal terms and the context-dependent interpretation of meaning.

[0147] (c) Design the prompt of the large language model to summarize the key information such as legal terms, dispute focus, legal issues, and explanation of the problem. At this stage, the model uses its extensive legal knowledge base and the semantic understanding ability acquired in previous training to conduct an in-depth analysis of the problem, thereby providing detailed legal insights and explanations. Q ={key1,key2,key3}, which helps the system to accurately identify and respond to users’ legal consultation needs.

[0148] (d) Integrate the information analyzed in (a), (b), and (c) as the extended information Q of the question e , and use the embedding model E fine-tuned in step 3 model To encode Q and Q e , and then weighted fusion is performed to obtain a question vector Q representing the user's intention vec .

[0149] Step 5: Further, through Figure 1 The multi-path recall module retrieves relevant laws for Q from different aspects. This process includes three paths: rule recall, knowledge recall, and standard answer recall. The RRF (Reciprocal Rank Fusion) algorithm is used to comprehensively sort the results of each path, and finally the relevant laws for the next stage (i.e., the re-ranking stage) are obtained. Specifically, it includes the following sub-paths:

[0150] (a) The first path (rule recall) uses the BM25 model for recall. For the user question Q, the first 20 relevant laws are retrieved from the legal and regulatory database D constructed in step 1 to form a subset

[0151] (b) The second path (knowledge recall) converts the vector representation Q obtained in step 4(d) into vec The legal article-knowledge vector LK in the knowledge vector library constructed in step 3 dense and LK sparse Calculate semantic similarity and finally return the top 20 relevant laws based on similarity to form a subset

[0152] (c) The third path (standard answer recall) recalls the top 20 question-answer pairs (Q, A) that are semantically similar to the user’s question Q from the standard answer vector library constructed in steps 2 and 3. i ). Answer part A i Extract legal provisions and perform frequency statistics to obtain the first 20 relevant legal provision subsets

[0153] (d) Further, the recall results of the three paths are fused using the RRF algorithm, i.e., the subset {S bm25 S vec S q Finally, the laws are sorted according to the RRF scores, and the top 20 relevant laws are returned as input for the next stage (i.e., the re-ranking stage).

[0154] Step 6: After obtaining the top 20 candidate laws related to question Q through multi-channel recall, the system enters the re-ranking stage to further optimize the order of recommendations, such as Figure 1 Generally, the question Q is concatenated with each candidate legal article L and input into the rearrangement model to obtain a similarity score, and the similarity scores are re-ranked based on the scores, and finally the top 5 most relevant legal articles are returned to the user.

[0155] Although the specific embodiments of the present invention are disclosed for the purpose of illustration, the purpose is to help understand the content of the present invention and implement it accordingly, those skilled in the art will understand that various substitutions, changes and modifications are possible without departing from the spirit and scope of the present invention and the appended claims. Therefore, the present invention should not be limited to the content disclosed in the best embodiment, and the scope of the present invention is subject to the scope defined in the claims.

Claims

1. A method for recommending laws and regulations based on multi-channel fusion, the steps of which include: 1) Split the legal texts by article and extract structured content to construct a legal set E = {l i |i=1,2,…,n}; where l i represents the ith legal article; 2) constructing a standard answer library, wherein the standard answer library includes a plurality of QA pairs, each of which includes a question Q and an answer text A; 3) Fine-tune the pre-trained embedding model E(·) using the problem-law pair dataset G to obtain the fine-tuned embedding model E ′ (·); Using the embedding model E ′ (·) Each legal provision in the legal and regulatory set E is vectorized and stored in the legal provision vector library; for each question Q in the standard question-answering library, the pre-trained embedding model E(·) is used to vectorize and store it in the legal provision vector library; 4) Use the question understanding module to extract entities, understand semantics, and enhance knowledge of the received user question Q as the extended information Q of the user question Q e ; Using the embedding model E ′ (·) For the user question Q and its extended information Q e After vectorization, the obtained vectors are weighted and fused to obtain a question vector Q representing the user’s intention. vec ; 5) Use the BM25 model to recall several relevant laws that are most relevant to the user's question Q from the legal database E; according to the question vector Q vec Calculate the similarity with each legal article vector in the legal article vector library, and recall several legal articles with the highest similarity; and select several question-answer pairs with similar semantics to the user question Q from the standard answer library and extract legal articles from the answer part of each selected question-answer pair to obtain the relevant legal article set L A As the recall result; then comprehensively sort the recall results and select the top-k laws that are most relevant to the user's question Q L={L1,L2,…,L k }; 6) The top-k laws L={L1,L2,…,L k } and user question Q are input into the rearrangement model to calculate L = {L1, L2, …, L k } and the re-ranking scores of each legal provision and the user's question Q, and return the legal provisions with the highest re-ranking scores to the user.

2. The method according to claim 1, characterized in that In step 1), a multi-stage prompt word is designed, including a prompt word P for generating a topic word. m , Prompt word P used to generate keywords k , Prompt word P used to generate the interpretation of the keyword d , used to generate prompt words P for potential legal issues related to legal provisions q ; For each article i , first use the prompt word P m Guide the large language model to generate topic words and use the prompt word P k Guide the large language model to generate keywords, and use the generated subject words and keywords to search for legal provisions. i Mark it; then for the legal article l i Each keyword k ij , use the prompt word P d Guide the large language model to generate interpretation D(k ij );Then based on this law i The subject words, keywords and definitions of q Generation and Law i Related potential legal issues, predict the legal provisions i Practical application scenarios of Q(T(l i ),k ij ,D(k ij ))={q1,q2,…,q m }, where q m For the law i The corresponding mth potential problem.

3. The method according to claim 1, characterized in that The method for constructing the standard answer library is as follows: first, a fuzzy matching method is used to filter out answer texts that do not mention legal clauses, and then regular extraction is performed on each answer text to obtain the legal clauses and their numbers contained therein, and the legal status of each extracted legal clause is detected. If the answer text contains any invalid, repealed or non-existent legal clauses, the QA pairs in the answer text will be filtered; then, a natural language inference matching screening method is used to perform preliminary screening on each retained QA pair, and then a multi-model verification method is used to verify each QA pair retained after the preliminary screening, and the QA pairs that pass the verification are stored in the standard answer library.

4. The method according to claim 1, 2 or 3, characterized in that: The problem-law pair dataset G = {(Q j1 ,Q j2 ,…,Q jm ,L j )|j=1,2,…,N}, where the law L j With m questions Q j1 ,Q j2 ,…,Q jm Related, Q jm Indicates that the large language model is based on the law L j The mth question generated.

5. The method according to claim 1, 2 or 3, characterized in that: A sparse network layer is introduced at the output end of the pre-trained embedding model E(·) to generate a sparse vector.

6. The method according to claim 2 or 3, characterized in that: Using the embedding model E ′ (·) Convert each legal article l in the legal and regulatory set E into a dense vector e l and the sparse vector w l And store it in the legal clause vector library, using the embedding model E ′ (·) Convert the associated knowledge corresponding to each legal article l into dense vectors and sparse vectors and store them in the legal article vector library; For each question Q in the standard question-answering library, use the pre-trained embedding model E(·) to generate the dense vector e of the question Q Q and the sparse vector w l And stored in the legal article vector library; the related knowledge includes subject terms, keywords, interpretations and potential problems.

7. The method according to claim 1, characterized in that Article 1 i ={regulation name, item number, timeliness, legal type, legal content, ...}; each legal article is stored in a tree or table structure.

8. A law and regulation recommendation system based on multi-channel fusion, characterized in that: It includes a legal and regulatory set building module, a standard answer library building module, a legal article vector library building module, a question understanding module, a multi-path recall module and a rearrangement model; The legal regulations set building module is used to split the legal regulations text according to the legal provisions and extract the structured content to build the legal regulations set E = {l i |i=1,2,…,n}; where l i represents the ith legal article; The standard answer library construction module is used to construct a standard answer library, wherein the standard answer library includes a plurality of QA pairs, each QA pair includes a question Q and an answer text A; The legal clause vector library building module is used to fine-tune the pre-trained embedding model E(·) using the problem-legal clause pair dataset G to obtain the fine-tuned embedding model E ′ (·); Then use the embedding model E ′ (·) vectorize each legal provision in the legal and regulatory set E and store it in the legal provision vector library; and for each question Q in the standard question-answering library, use the pre-trained embedding model E(·) to vectorize and store it in the legal provision vector library; The question understanding module is used to extract entities, understand semantics and enhance knowledge of the received user question Q as the extended information Q of the user question Q. e ; Using the embedding model E ′ (·) For the user question Q and its extended information Q e After vectorization, the obtained vectors are weighted and fused to obtain a question vector Q representing the user’s intention. vec ; The multi-path recall module is used to use the BM25 model to recall several relevant laws that are most relevant to the user's question Q from the legal database E; according to the question vector Q vec Calculate the similarity with each legal article vector in the legal article vector library, and recall several legal articles with the highest similarity; and select several question-answer pairs with similar semantics to the user question Q from the standard answer library and extract legal articles from the answer part of each selected question-answer pair to obtain the relevant legal article set L A As the recall result; then comprehensively sort the recall results and select the top-k laws that are most relevant to the user's question Q L={L1,L2,…,L k }; The rearrangement model is used to calculate the top-k laws L = {L1, L2, ..., L k } and the re-ranking scores of each legal provision and the user's question Q, and return the legal provisions with the highest re-ranking scores to the user.

9. A server, characterized in that: The invention comprises a memory and a processor, wherein the memory stores a computer program, the computer program is configured to be executed by the processor, and the computer program comprises instructions for executing the method according to any one of claims 1 to 7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.

Citation Information

Patent Citations

  • A legal knowledge intelligent query system oriented to legal consultation service

    CN109726215A

  • Legal consultation system based on legal semantic parts and document big data statistical analysis

    CN110059193A

  • Input prompting method and device for question-answering robot

    CN110765247A

  • Knowledge graph driving type law intelligent consultation system

    CN110765257A

  • Diversified recommendation method for news based on graph neural network and its device

    US20240184838A1

Cited By

  • Retrieval enhancement processing method and system based on large model

    CN120256648A

  • A retrieval enhancement processing method and system based on a large model

    CN120256648B

  • Technical supervision system and data processing method for power equipment

    CN121212367A

  • Technical supervision system of power equipment and data processing method

    CN121212367B