Legal question and answer method based on fusion of large model and multiple knowledge bases
By adopting a legal Q&A method that integrates large models and multiple knowledge bases in the legal field, the problem of hallucination and poor interpretability of large language models in the legal field is solved, and higher accuracy and reliability are achieved, which meets the needs of the Professionalism and interpretability requirements in the field of law.
Patent Information
- Application Number
- CN202411601431.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-11
- Publication Date
- 2025-02-18
AI Technical Summary
The application of existing large language models in the legal field has hallucinations and poor interpretability, which is difficult to meet the requirements of professionalism and accuracy of generated content in legal scenarios.
The legal question-and-answer method is adopted based on the integration of large models and multiple knowledge bases, and the accuracy and reliability of the model in the legal field is improved through user intention identification, multiple knowledge base construction and LangChain+Special Prompt methods.
It improves the accuracy and reliability of the model in the legal field, enhances the understanding and application of legal knowledge, and meets the professionalism and interpretability of the generated content in the legal field.
Smart Images

Figure CN119474312A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of legal question answering, and specifically to a legal question answering method based on the integration of a large model and multiple knowledge bases. Background Art
[0002] In the field of modern information retrieval and intelligent question answering, with the rapid development of big data and artificial intelligence technology, intelligent question answering systems have been widely used. Large language models have shown excellent performance in a variety of NLP (Natural Language Processing) tasks such as question answering, machine translation and text generation. By training large language models with professional legal and policy knowledge corpora, they can understand more complex user questions and provide better answers; but there are also some shortcomings, such as hallucinations and poor interpretability. When large models are applied to fields with high accuracy requirements such as the legal field, they face greater challenges, such as the timeliness of the law, the logic and accuracy of knowledge reasoning.
[0003] Generative models generally have hallucination problems. The generated answer texts usually lack detailed explanations and basis, and may contain fabricated laws or judicial interpretations, making it difficult to meet the requirements for professionalism and accuracy of generated content in legal scenarios.
[0004] In addition, explainability is crucial for trusting and effectively using large models in the legal field. If you cannot explain how the model reached its conclusion, there may be risks in fields such as law that require highly accurate and reliable decisions. This limits its application in the legal field to some extent. Summary of the invention
[0005] The first purpose of the present invention is to provide a legal question-and-answer method based on the integration of a large model and multiple knowledge bases in response to the deficiencies of the prior art. The present invention first identifies the user's intention, extracts feature words from the user's inquiry language, identifies the user's intention scenario, and distinguishes between legal crime judgment, legal question-and-answer, legal text writing and other scenarios. At the same time, we use multiple knowledge bases, and use the collected legal-related knowledge and knowledge graphs to build a modular knowledge base that matches the intent. We use the LangChain+special prompt+large model method to match different prompts and knowledge bases according to different intents, improve the accuracy and reliability of the model in the legal field, and provide intelligent legal services for different groups of people.
[0006] In order to solve the above technical problems, the technical solution of the present invention is: A legal question-answering method based on the integration of a large model and multiple knowledge bases includes the following steps: S1. Obtain user input information and perform intent recognition on the input information; Furthermore, the intention recognition comprises the following steps: S1-1. Construct Prompt: Define the intent recognition goals and possible intent categories in Prompt, and construct the intent recognition task description ; Provide example descriptions as prior knowledge to construct intent recognition examples ; S1-2. Generate contextual prompts: Describe the intent recognition task , Intent Recognition Example Splicing as contextual prompts for the large model ; S1-3. Combine user input and call the large model: After the user enters information, the big model uses the contextual prompts Understand the user's input information and map it to the preset intent category to complete intent recognition.
[0007] Furthermore, the categories of intent recognition include: case judgment prediction, legal document writing, and regular legal question and answer. S2. Collect legal texts and build a knowledge base; the knowledge base includes a crime knowledge graph, a vector knowledge base, and a legal document template knowledge base;
[0008] S2-1. Constructing the crime knowledge graph The crime corpus collected from the official website is annotated, and the annotated crime corpus is cleaned and preprocessed, and the number of existing crimes is compared to prevent omissions. The crime entities and the relationships between crime entities are extracted from the legal text through natural language processing technology, and the triple database is used to store the extracted entities and relationships.
[0009] According to the similarities between the crimes defined on the official website, the stored triplets are sorted to obtain a crime knowledge graph that is convenient for querying easily confused crimes.
[0010] S2-2. Building a vector knowledge base Through the word embedding technology in natural language processing technology, the collected legal texts are converted into vectors for computer use according to their types, including but not limited to word vector methods such as Word2vec. According to the different types of legal texts (legal provisions, legal books, case libraries, etc.), the constructed vectors are stored in a vector knowledge base such as FAISS, stored as vector files, and saved to disk for subsequent retrieval and use.
[0011] In the process of building a knowledge base, data such as laws, legal books, and case libraries are classified, and separate knowledge bases are built according to different types, which can effectively reduce the retrieval time and maintenance costs of the knowledge base.
[0012] In order to enhance the timeliness of the knowledge base, the data in the knowledge base is updated regularly and the vector knowledge base is rebuilt to address the high demand for timeliness in the law.
[0013] S2-3. Build a knowledge base of legal document templates Provide the collected common legal text templates to the big model, use an example as a prompt to guide the big model to extract the document template, simplify the document structure, store it as multiple key points, and avoid excessively long context.
[0014] Construct tips for extracting key points from legal documents. For common legal documents, describe the extraction task. , Examples of documents currently to be extracted Splicing as contextual prompts for the large model S3, matching the available knowledge in the knowledge base according to the intention recognition results; S3-1. Case judgment matching knowledge base Preset the crime and convert the user's long case description into a preset crime to reduce the probability of errors when matching the graph knowledge base, and let the big model output possible crimes. Query the preset crime in the knowledge graph, find the top N crimes most similar to the current crime according to the category to which the current crime belongs, and provide the detailed information of similar crimes and preset crimes as additional knowledge to the big model.
[0015] S3-2. General question-answer matching knowledge base Vectorize the user's question, match the semantic vector of the user's question with the semantic vector of the data in the knowledge base, and calculate the similarity between the knowledge base vector and the question input by the user through the cosine formula. Set the question vector input by the user as w1 and the knowledge vector of a block in the knowledge base as w2. The specific formula is: After calculating the cosine similarity, the TopK similar legal texts are screened out, a threshold of similar results is set, and the results with similarity exceeding the threshold are deleted to obtain the final relevant knowledge base.
[0016] S3-3. Legal Document Matching Knowledge Base Search the user's question to see if there is a type of legal document in the knowledge base, and provide the key points of the document template stored in the knowledge base according to the required document type. Providing wrong or irrelevant knowledge to the big model may affect the output of the model. If no matching document type is found, no knowledge will be provided.
[0017] S4. Combine the available knowledge in the knowledge base, match the prompt input into the large model according to the intent recognition result, and output the question and answer results that meet the user's intention; Match different prompts according to the user's intention, and divide the user input prompts into three types according to the intention. (corresponding to case judgment prediction), (corresponding to writing legal documents), (Corresponding to regular legal questions and answers). Different tasks have different goals and requirements. Customized prompts can improve the pertinence of tasks, improve the accuracy and efficiency of the model in completing tasks, and bring a better experience to users.
[0018] Each prompt is constructed according to the following formula: The optional part of the relevant knowledge is the matching knowledge obtained in step S3, the relevant introduction of the preset crime in the case judgment intent, the legal provisions matched in multiple knowledge bases in the general question and answer intent, and the key points of the relevant documents in the document writing intent. If no relevant knowledge is matched, this part is empty.
[0019] In case judgment prompts, we combine the ancient legal syllogism form to guide the deductive reasoning ability of the large model through thought chain guidance, and guide the large model to output explainable answers, thereby achieving a higher accuracy rate. In the prompts for writing legal documents and regular legal questions and answers, we use simple thought chain guidance to prompt the large model to think step by step.
[0020] The second object of the present invention is to provide a legal question-answering system based on the fusion of a large model and multiple knowledge bases to implement the above method, comprising the following modules: Intent recognition module, used to recognize the intention of user input information; Multi-knowledge base module, used to provide relevant knowledge matching intent to large models; The prompt module is used to provide specific task descriptions and reasoning ideas for the large model; The query module is used to obtain relevant knowledge from multiple knowledge base modules and generate answers corresponding to user input information.
[0021] A third object of the present invention is to provide an electronic device, comprising a processor and a memory, wherein the memory stores machine executable instructions that can be executed by the processor, and the processor executes the machine executable instructions to implement the above method.
[0022] A fourth object of the present invention is to provide a machine-readable storage medium storing machine-executable instructions, which, when called and executed by a processor, prompt the processor to implement the above method.
[0023] Compared with the prior art, the present invention has the following characteristics and beneficial effects: By adopting the above technical solution, the present invention uses prompt words to guide the large model to output the user's intention, matches different knowledge bases and prompt words according to the user's specific intention, thereby improving the model's understanding of specific tasks, adopts the legal theory syllogism, and guides the model to perform step-by-step reasoning through the thinking chain method, thereby improving the interpretability of the model output and meeting the needs of evidence in the legal field. According to the different characteristics of knowledge, a crime knowledge graph, a vector knowledge base and a document knowledge base are constructed. Constructing a crime knowledge graph can enable the large model to better understand the definition of the crime and the difference between the crimes, and increase the accuracy of case judgments. The external knowledge injection method based on the knowledge base provides implicit external support for the large model, improves the accuracy of the model output, and solves the illusion problem of the large model in the professional field. Regularly maintain the knowledge base to solve the problem of the lack of timeliness of the large model in the legal field. According to different legal knowledge, create multiple knowledge bases, and perform synchronous retrieval when searching the knowledge base, which reduces the time required to retrieve relevant knowledge. At the same time, it reduces the cost required for future reconstruction and maintenance of the knowledge base. The present invention is used to solve problems in the legal field of large models. There is no need to go through the training stage, thereby simplifying the process. When solving timeliness problems, the knowledge base can be reconstructed without repeated training, which reduces the cost of using large models in vertical fields. The final model was tested on the cail2018 data set, and the accuracy rate was 92%, which was 9% higher than that of directly using the large model. The present invention has a wide range of practical application value, and can help various users in the legal field to complete questions and answers with various needs, which helps to better solve practical problems. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0025] Figure 1A schematic diagram of the steps of a legal question-answering method based on the integration of a large model and multiple knowledge bases; Figure 2 A flowchart of the principle of a legal question-answering method based on the integration of a large model and multiple knowledge bases Figure 3 This is a schematic diagram of the legal question-answering system module based on the integration of a large model and multiple knowledge bases. DETAILED DESCRIPTION
[0026] It should be noted that, in the absence of conflict, the embodiments of the present invention and the features in the embodiments may be combined with each other.
[0027] In the description of the present invention, it should be understood that the terms "center", "longitudinal", "lateral", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside" and the like indicate positions or positional relationships based on the positions or positional relationships shown in the accompanying drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as limiting the present invention. In addition, the terms "first", "second", and the like are only used for descriptive purposes, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, features defined as "first", "second", and the like may explicitly or implicitly include one or more of the features. In the description of the present invention, unless otherwise specified, "multiple" means two or more.
[0028] In the description of the present invention, it should be noted that, unless otherwise clearly specified and limited, the terms "installed", "connected", and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or it can be indirectly connected through an intermediate medium, or it can be the internal communication of two components. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood by specific circumstances.
[0029] Reference Figure 1 to Figure 2 , is a schematic diagram of the overall implementation steps of the present invention and a principle flow chart, comprising the following steps: S1. Based on the question input by the user, perform intent recognition and map it to the preset intent; The big model + prompt method is used for intent recognition. In this embodiment, Wenxin Yiyan, which has a strong Chinese comprehension ability, is selected as the base big model. The types of intent are clearly listed in the prompt to guide the big model to map the user's question to the preset intent category.
[0030] Construct the prompt for intent recognition and describe the intent recognition task , Intent Recognition Example Splicing as a contextual reminder of the Wenxin Yiyan This embodiment provides the following examples: Constructing the intent recognition task description , part of which is as follows: "You are a legal intent recognizer. You take sentences as input and determine the user's intent based on the input query. Please select the appropriate intent from the following: case judgment prediction, writing legal documents. If you think neither of the above is correct, then the intent is a regular legal question and answer. Please output the intent directly."
[0031] Understandably, through the task description, the domain knowledge of the large model is stimulated, enabling it to understand the context and requirements of the task.
[0032] Constructing an intent recognition example , part of which is as follows: "I am a forest management staff. I did not pay attention to fire prevention during the burning process, causing serious losses to public and private property. The fire started from the farmland on the south side of the scene, covering an area of 9.85 hectares. What crime did I commit?: Case judgment prediction Please help me write a divorce agreement.: Writing legal documents It has been more than four months since I was injured. Can I still do a work injury assessment if I haven't done an assessment?: General legal questions and answers"
[0033] It can be understood that by using example descriptions as prior knowledge, it is possible to capture task-specific knowledge and improve the execution efficiency and accuracy of the model on the task.
[0034] With a word of literary mind As a base model, As The input guides the large model to map the user's question to the preset intent category. This process is recorded as the Recoginze method, and the expression is as follows: S2. Build a corresponding knowledge base for the corresponding intention, including the crime knowledge graph corresponding to the case judgment, the vector knowledge base corresponding to the general question and answer, and the document key points knowledge base corresponding to the document writing; S2-1 builds a knowledge graph for the crime corresponding to the case judgment prediction Before building the crime knowledge graph, the collected crime corpus is annotated, and the crime corpus is annotated using an annotation system to mark out the entities and relationships in the text. The annotated crime corpus is cleaned and preprocessed, including text cleaning and word segmentation, and the number of existing crimes is compared to prevent omissions and ensure the accuracy and consistency of the annotations.
[0035] In this embodiment, the crime information on the official website is used as the crime corpus. Based on the acquired corpus, a crime knowledge graph is constructed, and natural language processing technology is used to extract entities and relationships in the crime description. Extract crime entities (such as dangerous driving, traffic accident, etc.) and the relationships between them (such as identification, defense, etc.) from the text.
[0036] Define the structure and model of the crime knowledge graph, use a database or triple database to store entities and relationships, define attributes and other features for each crime, and sort the database according to the similarity between crimes.
[0037] In this embodiment, a triple database is used to store entities and relationships, and the triple data is sorted according to the similarity of the official crimes, so as to obtain a crime knowledge graph that is easy to query and easily confused. The knowledge graph can make full use of the structured characteristics and accurately search for precise and simple answers.
[0038] The knowledge in the legal field will be gradually updated and improved over time, and the relevant corpus of crimes will also be updated. Therefore, it is necessary to regularly maintain and update the constructed knowledge graph, regularly collect updated crime corpus, provide the latest crime data, and increase the accuracy of the large model's answers.
[0039] S2-2 Building a regular question-answer vector library Data preprocessing: The collected legal knowledge base includes legal provisions, legal books, analysis and answers of subjective questions in the legal examination, case library, and daily legal questions and answers. The collected knowledge base is cleaned and organized into a json file in the key-value pair format.
[0040] Database construction: Through the word embedding technology in natural language processing technology, the text expressed in natural language is converted into vectors used by computers, including but not limited to word vector methods such as Word2vec. Finally, these document vectors are stored in a vector database (such as FAISS) and saved to disk for subsequent vector retrieval.
[0041] In this embodiment, a high-quality database containing a variety of legal knowledge is constructed based on various user needs that may be involved in actual routine legal Q&A, such as law query, case analysis, judicial procedural consultation, risk assessment, legal education and popularization, etc., which improves the big model's ability to understand legal concepts and legal issues and its ability to apply them in complex scenarios, covering a variety of Q&A scenarios.
[0042] In the process of building a knowledge base, data such as laws, legal books, and case libraries are classified, and separate knowledge bases are built according to different types, which can effectively reduce the retrieval time and maintenance costs of the knowledge base.
[0043] In order to enhance the timeliness of the knowledge base, the data in the knowledge base is updated regularly and the vector knowledge base is rebuilt to address the high demand for timeliness in the law.
[0044] S2-3 Build a knowledge base for writing documents Use the big model to extract the key points from common legal document templates, build a knowledge base of legal document key points, select Wenxinyiyan, which has strong Chinese comprehension ability, as the base big model, and guide the big model to output complete key points of legal documents. Extracting key points from legal document templates can simplify the structure of legal documents and avoid excessively long contexts.
[0045] Construct tips for extracting key points from legal documents. For common legal documents, describe the extraction task. , Examples of documents currently to be extracted Splicing as a contextual reminder of the Wenxin Yiyan Choose Wenxinyiyan, which has strong Chinese comprehension ability As the base model, it guides the big model to output the key points of the complete legal document. This process is recorded as the Extract method, and the expression is as follows, where are the key points of the document template, such as plaintiff, defendant, facts and reasons, basic contract information, etc., and k is the number of key points: This embodiment provides the following examples: Constructing the key point extraction task description , part of which is as follows: “You are a highly intelligent and accurate legal document key points extraction system. You take legal documents as input and extract the key points from them.”
[0046] In this embodiment, an example of the document template to be extracted The manifestation is as follows: Here is a reference example: enter: Output: S3. Process the user input according to the user's intention and match the available knowledge from the corresponding knowledge base. The case judgment intends to match the crime knowledge in the crime knowledge graph, and additional similar crime knowledge is added based on similarity;
[0047] S3-1 Case Judgment Matching Knowledge Base: In order to prevent the case description from being too long and resulting in poor matching results, the charges are preset and the user's long case description is converted into preset charges to reduce the probability of errors when matching the graph knowledge base. The large model is used to output possible charges.
[0048] Search the knowledge graph for the preset crime, find the top N crimes that are most similar to the current crime according to the category to which the current crime belongs, and provide the detailed information of similar crimes and preset crimes as additional knowledge to the big model. Sorting the crimes by similarity and providing them to the big model can solve the problem of confusion among similar crimes.
[0049] In this embodiment, the Wenxin Yiyan model is used to preset the crime, guide the model to output the most likely crime, and screen out the top three crimes. If the total number of crimes is less than three, no screening is performed. The crime is searched on the knowledge graph, and the top N crimes that are most similar to the current preset crime are found according to the major categories of the crime. The information of the similar crimes and the preset crimes, such as concepts and features, is input into the big model as knowledge.
[0050] S3-2 General question and answer matching knowledge base: Vectorize the user's question, match the semantic vector of the user's question with the semantic vector of the data in the knowledge base, and calculate the similarity between the knowledge base vector and the question input by the user through the cosine formula. Set the question vector input by the user as w1 and the knowledge vector of a block in the knowledge base as w2. The specific formula is: After calculating the cosine similarity, the TopK similar legal texts are screened out, and a threshold of similar results is set. In this embodiment, the threshold is 0.5; the results with similarity exceeding the threshold are deleted to obtain the final relevant knowledge base.
[0051] Search in different types of knowledge bases, annotate the retrieved text according to the type, and indicate the text type given by the large language model. For example: Laws and regulations: "Article 1 of the Criminal Law: This law is formulated in accordance with the Constitution and in combination with my country's specific experience and actual situation in fighting crime in order to punish crimes and protect the people."
[0052] S3-3 Legal Document Matching Knowledge Base Search the user's question to see if there is a type of legal document in the knowledge base, and provide the key points of the document template stored in the knowledge base according to the required document type. Providing wrong or irrelevant knowledge to the big model may affect the output of the model. If no matching document type is found, no knowledge will be provided.
[0053] S4. Build prompts for users based on their intentions, including task descriptions, task instructions, and possible knowledge bases to match, and get answers to questions entered by users; Match different prompts according to the user's intention, and divide the user input prompts into three types according to the intention. (corresponding to case judgment prediction), (corresponding to writing legal documents), (Corresponding to regular legal questions and answers). Different tasks have different goals and requirements. Customized prompts can improve the pertinence of tasks, improve the accuracy and efficiency of the model in completing tasks, and bring a better experience to users.
[0054] Each prompt is constructed according to the following formula: The optional part of the relevant knowledge is the matching knowledge obtained in step S3, the relevant introduction of the preset crime in the case judgment intention, the matching legal provisions in multiple knowledge bases in the general question and answer intention, and the key points of the relevant documents in the document writing intention. If no relevant knowledge is matched, this part is empty.
[0055] Construct case judgment prediction tips , the content is as follows: “In the judicial syllogism, the major premise is a specific legal norm, the minor premise is the facts of the case, and the conclusion is the judgment.
[0056] Based on the case input, let us think using the judicial syllogism and finally output the crime committed by the defendant.
[0057] The following is information that may be relevant to the case judgment. You may refer to the following information if they are related to the above text content." In case judgments, we combine the ancient legal syllogism form, guide the thinking chain, stimulate the deductive reasoning ability of the big model, and guide the big model to output explainable answers, thereby achieving a higher accuracy rate.
[0058] Tips for constructing essays , the content is as follows: "You are a professional legal document writer. Please help users complete the document writing based on the input. The following are materials that may be relevant to the document. You may refer to the following materials if they are related to the content of the above document.
[0059] Tips for constructing essays , the content is as follows: "You are a legal expert, please answer the questions entered professionally. The following are materials that may be relevant to the conversation. You can refer to the following materials if they are related to the text content above."
[0060] In order to quantitatively evaluate the model output results, this embodiment uses legal objective questions for testing and uses accuracy as the evaluation indicator. 300 data are randomly selected from cail2018, and the output of the model is limited by prompt words. Regular expressions are used to extract the predicted charges, with an accuracy of 92%, which is 9% higher than the direct use of the Wenxin Yiyanda model. At the same time, 300 multiple-choice questions are randomly selected from the legal examination jec-qa, with an accuracy of 76.7%, which is 4.1% higher than the direct use of the Wenxin Yiyanda model.
[0061] The embodiments of the present invention are described in detail above with reference to the accompanying drawings, but the present invention is not limited to the described embodiments. For those skilled in the art, various changes, modifications, substitutions and variations of these embodiments including components are made without departing from the principles and spirit of the present invention, and still fall within the scope of protection of the present invention.
Claims
1. A legal question-answering method based on the integration of a large model and multiple knowledge bases, characterized in that: The legal question-and-answer method comprises the following steps: S1. Obtaining user input information and performing intent recognition on the input information; the results of the intent recognition include: case judgment prediction, legal document writing, and regular legal questions and answers; S2. Collect legal texts and build a knowledge base; the knowledge base includes a crime knowledge graph, a vector knowledge base, and a legal document template knowledge base; S3, matching the available knowledge in the knowledge base according to the results of intent recognition; S4. Combine the available knowledge in the knowledge base, match the prompt according to the results of intent recognition and input it into the big model, and output the question and answer results that meet the user's intention.
2. The legal question answering method based on the fusion of a large model and multiple knowledge bases according to claim 1 is characterized in that: The intention recognition comprises the following steps: S1-1. Construct Prompt: Define the intent recognition goals and possible intent categories in Prompt, and construct the intent recognition task description ; Provide example descriptions as prior knowledge to construct intent recognition examples ; S1-2. Generate contextual prompts: Describe the intent recognition task , Intent Recognition Example Splicing as contextual prompts for the large model ; S1-3. Combine user input and call the large model: After the user enters information, the big model uses the contextual prompts Understand the user's input information and map it to the preset intent category to complete intent recognition.
3. The legal question answering method based on the fusion of a large model and multiple knowledge bases according to claim 1 is characterized in that: Step S2 includes the following steps: S2-1. Constructing the crime knowledge graph Label the crime corpus collected from the official website, and clean and pre-process the labeled crime corpus as the data source of the knowledge graph; Extract crime entities and the relationships between crime entities from legal texts through natural language processing technology, and use a triple database to store the extracted entities and relationships; According to the similarities between crimes defined on the official website, the stored triples are sorted to obtain a crime knowledge graph that is convenient for querying crimes that are easily confused; S2-2. Building a vector knowledge base Through the word embedding technology in natural language processing technology, the collected legal texts are converted into vectors used by computers according to their types, and the constructed vectors are stored in the vector knowledge base according to the different types of legal texts; S2-3. Build a knowledge base of legal document templates Use the big model to extract the key points from common legal document templates, provide the collected common legal text templates to the big model, use an example as a prompt to guide the big model to extract the document template, store it as multiple key points, and build a legal document template knowledge base.
4. The legal question-answering method based on the fusion of a large model and multiple knowledge bases according to claim 3 is characterized in that: In step S2-3, constructing a prompt for extracting the key points of a legal document includes the following steps: for common legal documents, extracting the task description 、Examples of documents currently to be extracted Splicing as contextual prompts for the large model 。 5. The legal question answering method based on the integration of a large model and multiple knowledge bases according to claim 1 is characterized in that: Step S3 includes the following steps: S3-1. Case judgment prediction and matching crime knowledge graph Preset the crime, convert the user's long case description into the preset crime, reduce the probability of error when matching the graph knowledge base, and let the big model output the possible crime; query the preset crime in the crime knowledge graph, find the top N crimes most similar to the current crime according to the category to which the current crime belongs, and provide the detailed information of similar crimes and preset crimes as additional knowledge to the big model; S3-2. Conventional Legal Question-Answer Matching Vector Knowledge Base Vectorize the user's question, perform similarity matching between the user's question semantic vector and the semantic vector of the data in the knowledge base, calculate the similarity between the knowledge base vector and the question entered by the user, filter out the TopK similar legal texts, set a threshold for similar results, delete the results whose similarity exceeds the threshold, and obtain the final relevant knowledge base; S3-3. Write legal documents and match the legal document template knowledge base The user's question is searched to see whether there is a type of legal document in the knowledge base, and the key points of the document template stored in the knowledge base are provided according to the required document type. If no matching document type is found, no knowledge is provided.
6. The legal question answering method based on the fusion of a large model and multiple knowledge bases according to claim 5 is characterized in that: In step S3-2, the method for calculating the similarity between the knowledge base vector and the question input by the user is: Assume that the question vector input by the user is w1, and the knowledge vector of a block in the knowledge base is w2. The specific formula is: 。 7. The legal question answering method based on the integration of a large model and multiple knowledge bases according to claim 1 is characterized in that: Step S4 is specifically as follows: The prompts input by the user are divided into three types according to the intention: , corresponding to the writing of legal documents , corresponding to the regular legal questions and answers ; Each prompt is constructed according to the following formula: The relevant knowledge in the optional part is the knowledge matched in step S3. If no relevant knowledge is matched, this part is empty.
8. A legal question-answering system based on the fusion of a large model and multiple knowledge bases for implementing the method described in any one of claims 1 to 7, characterized in that: Includes the following modules: Intent recognition module, used to recognize the intention of user input information; Multi-knowledge base module, used to provide relevant knowledge matching intent to large models; The prompt module is used to provide specific task descriptions and reasoning ideas for the large model; The query module is used to obtain relevant knowledge from multiple knowledge base modules and generate answers corresponding to user input information.
9. An electronic device, comprising a processor and a memory, wherein the memory stores machine executable instructions that can be executed by the processor, and the processor executes the machine executable instructions to implement the method according to any one of claims 1 to 7.
10. A machine-readable storage medium, characterized in that: The machine-readable storage medium stores machine-executable instructions. When the machine-executable instructions are called and executed by a processor, the machine-executable instructions prompt the processor to implement the method described in any one of claims 1 to 7.
Citation Information
Patent Citations
Information matching method and device based on legal knowledge graph and storage medium
CN111611396A
Law and regulation question-answering system based on generative language model and construction method
CN117271716A
Law question and answer method and device based on large model and knowledge guidance
CN117725169A
Knowledge base question and answer construction method and device based on large model
CN118035405A
Legal consultation method based on knowledge graph enhancement
CN118093829A
Cited By
Intention labeling method, model training method, intention recognition method and electronic equipment
CN120687539A
Intelligent driving medical map construction, labeling and vectorization integration method and device
CN121524368A
Law element hierarchical extraction method and system based on large model and knowledge graph
CN121996801A
Method and system for hierarchical extraction of legal elements based on large models and knowledge graphs
CN121996801B