A knowledge question-answering method and system for water-related laws and regulations

By building a professional knowledge base and a regulatory knowledge base, using text and vector retrieval technology, and combining the weight scores of entity concepts, the problem of semantic gaps and lack of knowledge in Q&A on water-related laws and regulations has been solved, and the accuracy of Q&A and retrieval accuracy have been improved. .

CN118349660BActive Publication Date: 2024-08-27长江水利委员会网络与信息中心
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202410767039.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-14
Publication Date
2024-08-27
Estimated Expiration
2044-06-14

AI Technical Summary

Technical Problem

There is a semantic gap and lack of knowledge in the existing technology's question and answer method for water-related laws and regulations, which makes it difficult to accurately combine user questions and legal and regulatory texts, and the output answers are not ideal.

Method used

By building a professional knowledge base and a regulatory knowledge base, we use the word segmentation results and entity concepts of the question content to construct text enhancement information and semantic enhancement information, combine the weight scores of the entity concepts for text and vector retrieval, obtain Topk retrieval results, and use the question and answer model Generate answers.

Benefits of technology

It significantly improves the accuracy of retrieval and answers, narrows the semantic distance between user questions and text expressions of laws and regulations, and makes the answer results closer to users' expectations.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118349660B
    Figure CN118349660B
Patent Text Reader

Abstract

The present invention provides a knowledge question-answering method and system for water-related laws and regulations, the method comprising: matching synonyms, entity descriptions and weight scores corresponding to the entity concepts in a pre-constructed professional knowledge base according to at least one entity concept extracted from the user's question content; constructing text enhancement information using the word segmentation results of the question content, all entity concepts and all synonyms; and constructing semantic enhancement information using all entity concepts and corresponding entity descriptions; using the text enhancement information and semantic enhancement information to perform comprehensive retrieval in multiple ways, and determining the final retrieval result from the comprehensive retrieval results. The present invention reduces the semantic distance between the user's question and the legal and regulatory text expression, greatly improves the subsequent retrieval accuracy, and then uses the retrieved legal and regulatory text to generate the answer content, so that the answer result is closer to the user's question content.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of large language models, and in particular to a knowledge question-answering method and system for water-related laws and regulations. Background Art

[0002] Establishing knowledge question-and-answer technology on water-related laws and regulations can effectively help people acquire knowledge on water-related laws and regulations more conveniently, solve water-related problems in actual production and life, and improve society's understanding and application of water resources, water environment, water ecology and water shoreline space management.

[0003] In the user question-and-answer process, in addition to the knowledge in laws and regulations, a large amount of knowledge related to the water industry is also involved. This knowledge will not be given in detail in user questions and legal and regulatory documents, and existing knowledge retrieval methods cannot directly obtain it, which is not conducive to knowledge question-and-answering.

[0004] For example, when users ask questions, they often give simple and direct descriptions of entities (such as "small-sized reservoirs"). This creates a certain semantic gap and knowledge gap between the user's questions and the text of laws and regulations. Since the training corpus of the question-answering model may also have knowledge gaps in the water-related professional field (i.e., the range of the capacity of small-sized reservoirs is unknown, so it is unknown whether the question is applicable to the clause "reservoirs with a capacity of more than 100 cubic meters should..."), the user's questions and search results may not be accurately combined and understood, resulting in unsatisfactory output answers. Summary of the invention

[0005] The present invention provides a knowledge question-and-answer method and system for water-related laws and regulations, so as to solve the defect that the question-and-answer method for water-related laws and regulations in the prior art performs poorly.

[0006] In a first aspect, the present invention provides a knowledge question-and-answer method for water-related laws and regulations, comprising: matching synonyms, entity descriptions and weight scores corresponding to the entity concepts in a pre-constructed professional knowledge base according to at least one entity concept extracted from a user's question content; constructing text enhancement information using the word segmentation results of the question content, all entity concepts and all synonyms; and constructing semantic enhancement information using all entity concepts and corresponding entity descriptions; performing text retrieval in a legal knowledge base using the text enhancement information in combination with the weight scores of the entity concepts to obtain corresponding Topk retrieval results, and performing vector retrieval in the legal knowledge base using the semantic enhancement information to obtain corresponding Topk retrieval results; and performing network retrieval using the text enhancement information to obtain corresponding Topk retrieval results; wherein the legal knowledge base includes multiple knowledge blocks, each knowledge block includes a knowledge block identity, a knowledge block retrieval text for retrieval, and an identity of an associated legal and regulatory text; the Topk retrieval result includes multiple most relevant knowledge blocks retrieved; reordering the knowledge blocks in all Topk retrieval results to obtain a final Topk retrieval result, so as to generate answer information using a question-and-answer model.

[0007] According to a knowledge question-and-answer method for water-related laws and regulations provided by the present invention, text enhancement information is constructed using the word segmentation results of the question content, all entity concepts and all synonyms, including: constructing a Boolean logic retrieval formula in the form of a Boolean expression as the text enhancement information; wherein each entity concept and each synonym of the entity concept are connected by a Boolean logic operator or, and different entity concepts and word segmentation results are connected by a Boolean logic operator and.

[0008] According to a knowledge question-and-answer method for water-related laws and regulations provided by the present invention, text enhancement information is combined with the weight score of the entity concept to perform text search in the legal knowledge base to obtain the corresponding Topk search results, including: performing keyword matching with the knowledge block search text of the knowledge block through the text enhancement information to obtain the matching knowledge block; counting the target entity concepts appearing in the knowledge block search text of each matching knowledge block; scoring each matching knowledge block according to the weight score of the target entity concept in each matching knowledge block; and determining multiple matching knowledge blocks with the highest scoring scores according to the scoring score of each matching knowledge block as the Topk search results corresponding to the text search.

[0009] According to a knowledge question-answering method for water-related laws and regulations provided by the present invention, each matching knowledge block is scored according to the weight score of the target entity concept in each matching knowledge block, specifically:

[0010]

[0011] in, is the scoring value of the matching knowledge block, D represents the knowledge block index text, represents the target entity concept set in the knowledge block index text D, Represents the target entity concept The inverse document frequency of It is represented as an indicator function. When the expression in the brackets is true, the indicator function value is 1, and when the expression in the brackets is false, the indicator function value is 0; Represents the target entity concept It belongs to the entity concepts pre-defined in the professional knowledge base; Target Entity Concept The weight score of , k is the adjustment factor.

[0012] According to a knowledge question-and-answer method for water-related laws and regulations provided by the present invention, semantically enhanced information is used to perform vector search in a legal knowledge base to obtain corresponding Topk search results, including: inputting the semantically enhanced information into a pre-trained target vector model; the target vector model is a model for performing vector search based on the similarity between the semantically enhanced information and the knowledge block search text; and using the target vector model to obtain the Topk search results output by the target vector model.

[0013] According to a knowledge question-and-answer method for water-related laws and regulations provided by the present invention, the training method of the target vector model includes: constructing positive samples and negative samples; wherein the positive samples include semantic enhancement information samples and corresponding correct knowledge blocks; the negative samples include simple negative samples and difficult negative samples, the simple negative samples include semantic enhancement information samples and corresponding erroneous knowledge blocks, and the difficult negative samples are constructed based on the erroneous knowledge blocks of the semantic enhancement information samples output by the initial vector model; the initial vector model is trained using the positive samples and the negative samples to obtain the target vector model.

[0014] According to a knowledge question-and-answer method for water-related laws and regulations provided by the present invention, the knowledge blocks in all Topk search results are reordered to obtain the final Topk search results, so as to generate answer information using a question-and-answer model, including: using the knowledge blocks contained in the final Topk search results to determine the corresponding legal and regulatory texts; inputting the legal and regulatory texts and the user's question content into a pre-built question-and-answer model to obtain corresponding answer information.

[0015] In a second aspect, the present invention further provides a knowledge question-answering system for water-related laws and regulations, comprising:

[0016] A first processing module is used to match synonyms, entity descriptions and weight scores corresponding to the entity concepts in a pre-built professional knowledge base according to at least one entity concept extracted from the user's question content;

[0017] The second processing module is used to construct text enhancement information using the word segmentation results of the question content, all entity concepts and all synonyms; and to construct semantic enhancement information using all entity concepts and corresponding entity descriptions;

[0018] The third processing module is used to use the text enhancement information combined with the weight score of the entity concept to perform text search in the legal knowledge base to obtain the corresponding Topk search results, and use the semantic enhancement information to perform vector search in the legal knowledge base to obtain the corresponding Topk search results; and use the text enhancement information to perform network search to obtain the corresponding Topk search results; wherein the legal knowledge base includes multiple knowledge blocks, each knowledge block includes a knowledge block identity, a knowledge block search text for retrieval, and an identity of the associated legal and regulatory text; the Topk search results include the most relevant multiple knowledge blocks retrieved;

[0019] The fourth processing module is used to reorder the knowledge blocks in all Topk search results to obtain the final Topk search results so as to generate answer information using the question-answering model.

[0020] In a third aspect, the present invention provides an electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps of the knowledge question and answer method regarding water-related laws and regulations as described in any one of the above are implemented.

[0021] In a fourth aspect, the present invention further provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the knowledge question-and-answer method regarding water-related laws and regulations as described in any one of the above-mentioned methods.

[0022] The knowledge question-and-answer method and system for water-related laws and regulations provided by the present invention establish a professional knowledge base and a regulatory knowledge base for water-related laws and regulations, use the professional knowledge base to enhance the question content of (original query) to form text-enhanced query and semantic-enhanced query, and use the text-enhanced query and semantic-enhanced query as the basis for subsequent retrieval, explicitly introduce relevant knowledge of professional entity concepts in the water-related industry as a knowledge supplement to the entity concepts involved in the user's question, narrow the semantic distance between the user's question and the text expression of the laws and regulations, greatly improve the subsequent retrieval accuracy, and then use the retrieved legal and regulatory text to generate answer content, so that the answer result is closer to the user's question content and the accuracy of the answer is improved.

[0023] The present invention compares three methods of knowledge retrieval: using text retrieval alone, using vector retrieval alone, and using text, vector and network comprehensive retrieval at the same time. The comprehensive retrieval method has a significant improvement in the effect.

[0024] By setting corresponding weight scores for different entity concepts in the professional knowledge base, the present invention can make the pre-set professional vocabulary (i.e., entity concepts) more targeted in the text retrieval process, make the retrieval results more focused, and make the retrieval results closer to the user's expected results.

[0025] Although the fine-tuning method of the vector model in the present invention directly affects vector retrieval, since the sample is constructed through text-based knowledge extraction and the addition of entity description text that is closer to the semantics of laws and regulations, it is equivalent to taking advantage of the accuracy of text matching and introducing this advantage into vector retrieval. When fine-tuning the vector model and constructing samples, the semantic gap between user questions and retrieval results in the sample is narrowed in advance, so that each training sample can play a greater role in the fine-tuning process. The text and vector are deeply "combined", and additional professional knowledge is introduced to maximize the significance of joint retrieval. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0027] Figure 1 This is one of the flow charts of the knowledge question-answering method for water-related laws and regulations provided by the present invention;

[0028] Figure 2 This is the second flow chart of the knowledge question-and-answer method for water-related laws and regulations provided by the present invention;

[0029] Figure 3 It is a flowchart of text retrieval based on weight score provided by the present invention;

[0030] Figure 4 It is a schematic diagram of the process of constructing positive and negative samples provided by the present invention;

[0031] Figure 5 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION

[0032] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0033] It should be noted that, in the description of the embodiments of the present invention, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "include one..." do not exclude the existence of other identical elements in the process, method, article or device including the elements. For those of ordinary skill in the art, the specific meanings of the above terms in the present invention can be understood according to the specific circumstances.

[0034] The terms "first", "second", etc. in this application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are generally of one type, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" represents at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.

[0035] Combine the following Figure 1-Figure 5 The present invention describes a method and system for answering questions about water-related laws and regulations provided in an embodiment of the present invention.

[0036] Figure 1 This is one of the flow charts of the knowledge question-answering method for water-related laws and regulations provided by the present invention. Figure 2 This is the second flow chart of the knowledge question and answer method for water-related laws and regulations provided by the present invention. Figure 1 and Figure 2 The technical solution of the present invention is described. The present invention includes but is not limited to the following steps:

[0037] Step 101: Based on at least one entity concept extracted from the user's question content, synonyms, entity descriptions and weight scores that correspond one to one with the entity concept are matched in a pre-built professional knowledge base.

[0038] The professional knowledge base in the present invention is pre-built, and the professional knowledge base contains the basic knowledge concepts related to the water conservancy profession. Each knowledge block in the professional knowledge base contains the fields: entity concept, entity description, synonyms and weight score. Among them, the entity concept can be a professional term involving water, and the entity description source is the conceptual explanation of the professional name in the authoritative bibliography of the water industry (such as "Water Conservancy Dictionary" and "Concise Water Conservancy and Hydropower Dictionary", etc.). The source of synonyms is to perform n-gram segmentation on relevant corpora such as user questions and legal and regulatory texts, and then mine words with high semantic relevance through word embedding models (such as: Dmeta-embedding-zh, etc.); the entity concepts in the present invention are assigned different weight scores, and these weights reflect the importance of entity concepts in the retrieval process. The distribution of weight scores can be based on a variety of factors, such as the frequency of the entity, its importance in a specific field, and its relevance to the query. For example, the weight score can be a score obtained by statistics on the corpus and according to the term frequency-inverse document frequency (TF-IDF) algorithm.

[0039] Here is an example of a knowledge block:

[0040] {

[0041] Physical concept: Small-sized reservoir

[0042] Synonyms: small type 2 reservoir, small type II reservoir, small type (II) reservoir

[0043] Entity Description: Reservoir with a storage capacity greater than or equal to 100,000 cubic meters and less than 1 million cubic meters

[0044] Weight score: 0.8

[0045] }.

[0046] The present invention can segment the question content (i.e., original query) input by the user through a word segmenter enhanced by a professional knowledge base (i.e., capable of recognizing professional vocabulary), and extract professional entities therein, i.e., entity concept fields in the professional knowledge base.

[0047] Step 102: construct text enhancement information using the word segmentation results of the question content, all entity concepts and all synonyms; and construct semantic enhancement information using all entity concepts and corresponding entity descriptions.

[0048] Through the extracted entity concepts, the corresponding synonym fields are found and concatenated with the original query segmentation results to obtain a text-enhanced query (i.e., text-enhanced information).

[0049] Optionally, a Boolean logic search formula is constructed by means of a Boolean expression as the text enhancement information; wherein each entity concept and each synonym of the entity concept are connected by a Boolean logic operator or, and different entity concepts and word segmentation results are connected by a Boolean logic operator and. The following is an example:

[0050] Original query: Yangtze River Commission river channel review scope

[0051] Among them, the extracted entity concept is "Yangtze River Committee", its synonym is "Yangtze River Water Conservancy Committee", and the word segmentation results include "river channel", "review" and "scope".

[0052] Text enhancement query: (Yangtze River Commission or Yangtze River Water Conservancy Commission) and river channel and review and scope.

[0053] Furthermore, by extracting all entity concepts, we find all corresponding entity description fields and obtain a semantically enhanced query (i.e., semantically enhanced information).

[0054] Optionally, the present invention can implement the representation of text enhancement information and semantic enhancement information of different entity concepts by constructing a query knowledge body, as shown below:

[0055] {

[0056] Original query: the user's original query statement, that is, the question content

[0057] Entity list: the extracted entity concept set

[0058] Entity description list: the entity description set corresponding to the extracted entity concept set

[0059] Text enhancement query: Use the word segmentation results of the question content, all entity concepts and all synonyms to construct text enhancement information

[0060] Semantic enhancement query: all entity concepts and all corresponding entity descriptions construct semantic enhancement information

[0061] }

[0062] The query knowledge body is constructed through the professional knowledge base in the present invention. The main purpose is to standardize the water conservancy industry-related concepts input by users to reduce the knowledge differences between the query side and the retrieval side, thereby improving the recall quality of the regulatory knowledge base.

[0063] Step 103: Use the text enhancement information combined with the weight score of the entity concept to perform text search in the legal knowledge base to obtain the corresponding Topk search results, use the semantic enhancement information to perform vector search in the legal knowledge base to obtain the corresponding Topk search results; and use the text enhancement information to perform network search to obtain the corresponding Topk search results.

[0064] The legal knowledge base in the present invention includes multiple knowledge blocks, each of which includes a knowledge block identity, a knowledge block search text for retrieval, and an identity of the associated legal and regulatory text (used to find the legal and regulatory text). During the retrieval process, the present invention can return the most relevant k results, which are called Topk search results. Here, k can be a predefined number, indicating the number of search results that the user wants to obtain; the Topk search results include the most relevant multiple knowledge blocks retrieved.

[0065] The following is a brief description of the construction process of the regulatory knowledge base. This part of the construction includes text segmentation, vector index construction, and text index construction.

[0066] First, the process of text cutting is briefly described. The main object of text cutting is the text of water-related laws and regulations. Most of this type of text consists of several independent clauses with a length of no more than 500 characters. The remaining small part will contain long texts of more than 500 characters, clauses related to the context, etc. Therefore, in the text cutting process, the present invention adopts different construction methods for texts in different situations and stores them in json format. The construction format is as follows:

[0067] {

[0068] Knowledge block id: the unique identifier of each knowledge block, i.e. the knowledge block identity

[0069] Knowledge block index text: can be manually constructed, the knowledge block is used to retrieve the text content

[0070] Related original text id list: related legal and regulatory original text id list, that is, the identity of the related legal and regulatory text

[0071] }.

[0072] The specific construction method is as follows:

[0073] Cut by legal clauses and set an id for each cut original text. The original text format is "legal name + item number + item text". The following is a cutting example:

[0074] "Article 3 of the River Classification Method: The classification of river classes is mainly based on..." Original text (legal and regulatory text) id=23

[0075] "Article 4 of the River Classification Method states that rivers are divided into five classes, namely..." Original text id=24

[0076] For each segmented original text, if its length is less than or equal to 500 characters and the text semantics has no obvious correlation with the context, an independent knowledge block is constructed as follows:

[0077] {

[0078] Knowledge block id: create a new knowledge block id

[0079] Knowledge block index text: the original text of this paragraph

[0080] List of associated original text ids: the original text id of this paragraph

[0081] }

[0082] If the length of a paragraph of original text is > 500 characters and is in the form of a list of sub-items, each sub-item is constructed into a knowledge block. The following is an example:

[0083] Original text:

[0084] “The main contents of budget supervision and inspection include: (i) whether the internal control system of project budget management is sound, whether the documents and materials of each link are complete and intact, etc. (ii) whether the project budget is compiled and submitted in accordance with the prescribed procedures and requirements. (iii) whether the relevant approval procedures for budget adjustments are carried out in accordance with the prescribed procedures... (xvi) other issues that need to be focused on.”

[0085] In this paragraph, "The main contents of budget supervision and inspection include:" is the general description of the paragraph, and the sub-items are followed by sub-titles (I), (II), (III), etc., so the original text of this paragraph can be constructed into 16 texts:

[0086] {

[0087] Knowledge block id: create a new id

[0088] Knowledge block index text: Overview + sub-entry content

[0089] List of associated original text ids: the original text id of this paragraph

[0090] }

[0091] If there is an obvious connection between a paragraph and the context, then introduce the original content corresponding to the context:

[0092] {

[0093] Knowledge block id: create a new id

[0094] Knowledge block index text: the original text of the paragraph, the original text of the context

[0095] List of associated source text ids: source text id of this paragraph, source text id of the context

[0096] }

[0097] Furthermore, the process of constructing a vector index is briefly described. The process of constructing a vector index refers to converting the "knowledge block index text" in the segmented knowledge block into a vector form and storing it in the vector index.

[0098] First, an embedded model is used to map the segmented text block data into a vector form. The embedded model maps the text into a low-dimensional dense vector through large-scale text pair training, which can better represent the semantic features of the text. The embedded model used in this invention is Dmeta-embedding-zh. After obtaining the knowledge block vector, the FAISS (Facebook AI Similarity Search) tool is used to build a vector index for the subsequent retrieval process.

[0099] Finally, the process of building a text index is briefly described. For the "knowledge block index text" in the segmented knowledge block, a word segmenter is used to segment the text knowledge block, and an inverted index in the form of a "word-text list" is established.

[0100] The present invention uses the ik word segmenter to segment the knowledge block text and establish an inverted index to ensure the recall rate during retrieval. After the index is established, a "word-word frequency-inverse document frequency" dictionary is generated for calculating the matching score in the retrieval stage. The present invention uses ES as a text indexing tool.

[0101] Vector index and text index constructed as above can realize vector retrieval and text retrieval. Specifically, the present invention can use BM25 algorithm to use text enhancement information and weight scores of entity concepts to search in the regulatory knowledge base.

[0102] Web search is to use the Internet search engine to search for answers to user questions to supplement the insufficient content in the knowledge base. Specifically, firstly, the query is enhanced according to the text in the query knowledge body, and the search query is optimized using Boolean logic operators and search engine-specific advanced query syntax to generate a standard search query. Subsequently, the interface of the Internet search engine is called to submit the constructed query to the search engine and obtain the search results. The web search API used in the present invention is serpapi, and the search engine is bing search.

[0103] Step 104: Re-rank the knowledge chunks in all the Topk retrieval results to obtain the final Topk retrieval results, so as to generate answer information using the question-answering model.

[0104] Optionally, the present invention uses the bge-reranker model to score the knowledge chunks for re-ranking. Specifically, using the knowledge chunks included in the final Topk retrieval results, the corresponding laws and regulations texts are determined; the laws and regulations texts and the user's question content are input into a pre-constructed question-answering model (i.e., a large model) to obtain the corresponding answer information. The question-answering model in the present invention can be a commonly used question-answering large model in the prior art, and the present invention does not make specific limitations on its type.

[0105] As an optional embodiment, the question-answer generation of the present invention mainly relies on the dialogue generation ability of the large model. The user's question and the laws and regulations texts obtained during the knowledge retrieval process are used to guide the large model to output natural and fluent question-answer texts through certain prompt words. Generating question-answer texts includes the following steps.

[0106] (1) Query: That is, the content of the user's question

[0107] (2) Knowledge retrieval results: Take out all the original text IDs from the "associated original text ID list" field of all the retrieved knowledge chunks, remove duplicates, and find each original text according to the ID.

[0108] (3) Entity description set in the query knowledge body

[0109] (4) Prompt words: The following is an example of the prompt word template adopted by the present invention:

[0110] "<Instruction> Please use the known information to answer the question truthfully, professionally, and concisely. < / Instruction>

[0111] <Requirements> 1. Select the content related to the question from the known information to answer. 2. If no answer can be obtained therefrom, say 'The question cannot be answered based on the known information'. 3. When answering the question, please indicate which known information is relied on. 4. It is not allowed to fabricate answers on your own. < / Requirements>

[0112] <Known information> {context} < / Known information>

[0113] <Question> {question} < / Question> "

[0114] The knowledge question-and-answer method for water-related laws and regulations provided by the present invention establishes a professional knowledge base and a regulatory knowledge base for water-related laws and regulations, uses the professional knowledge base to enhance the question content of (original query) to form text-enhanced query and semantic-enhanced query, and uses the text-enhanced query and semantic-enhanced query as the basis for subsequent retrieval, explicitly introduces relevant knowledge of professional entity concepts in the water-related industry as a knowledge supplement to the entity concepts involved in the user's question, narrows the semantic distance between the user's question and the text expression of the law and regulations, greatly improves the subsequent retrieval accuracy, and then uses the retrieved law and regulations text to generate answer content, so that the answer result is closer to the user's question content and improves the accuracy of the answer.

[0115] Figure 3 is a flowchart of text retrieval based on weight scores provided by the present invention, such as Figure 3 As shown, including but not limited to the following steps:

[0116] Step 301: Perform keyword matching with the knowledge block search text of the knowledge block through the text enhancement information to obtain the matching knowledge block.

[0117] Among them, keyword matching is to use the previously constructed text enhancement information (including the word segmentation results of the question content, entity concepts and their synonyms) to match the knowledge block search text in the legal knowledge base. For example, the present invention can extract keywords from the text enhancement information and search for these keywords in the text index of the legal knowledge base to find the knowledge block search text containing these keywords to determine the corresponding matching knowledge block.

[0118] Step 302: Count the target entity concepts that appear in the knowledge block retrieval text of each matching knowledge block.

[0119] By matching and comparing with the entity concepts in the professional knowledge base, the target entity concepts appearing in the knowledge block retrieval text are determined.

[0120] Step 303: Score each matching knowledge block according to the weight score of the target entity concept in each matching knowledge block.

[0121] Optionally, the scoring formula for the corresponding matching knowledge block is:

[0122]

[0123] in, is the scoring value of the matching knowledge block, D represents the knowledge block index text, represents the target entity concept set in the knowledge block index text D, Represents the target entity concept The inverse document frequency of It is represented as an indicator function. When the expression in the brackets is true, the indicator function value is 1, and when the expression in the brackets is false, the indicator function value is 0; Represents the target entity concept It belongs to the entity concepts pre-defined in the professional knowledge base; Target Entity Concept The weight score is , k is the adjustment factor, and k can be 1.5.

[0124] in, , N represents the number of all documents (knowledge block index text), Indicates that it contains The number of documents.

[0125] Step 304: According to the scoring value of each matching knowledge block, multiple matching knowledge blocks with the highest scoring values ​​are determined as the Topk search results corresponding to the text search.

[0126] It is understandable that in the text of laws and regulations, the importance of the word itself is not only reflected by statistical data. Whether the word has industry attributes and the frequency of the word in user questions should also be important factors affecting its weight score. The traditional BM25 algorithm is based on statistics of the words in the corpus. Generally speaking, it can be considered that the higher the frequency in the same document and the fewer documents it appears in, the higher the weight score of the word. In other words, the traditional BM25 algorithm cannot achieve weight setting for professional vocabulary.

[0127] The text retrieval method based on weight scores proposed in the present invention not only inherits the advantages of the BM25 algorithm, but also takes into account the importance of professional vocabulary (entity concepts) to weight setting, so that the more important the vocabulary is in the retrieved knowledge block (including the knowledge block index text) and the more important it is in the professional field involved, the higher its weight score will be, which is more targeted and can make the question and answer output results more accurate.

[0128] Based on the contents of the above embodiments, as an optional embodiment, the knowledge question and answer method of water-related laws and regulations provided by the present invention uses semantic enhancement information to perform vector search in the legal knowledge base to obtain corresponding Topk search results, including: inputting the semantic enhancement information into a pre-trained target vector model; the target vector model is a model for vector search based on the similarity between the semantic enhancement information and the knowledge block search text; using the target vector model, obtaining the Topk search results output by the target vector model.

[0129] The main purpose of vector retrieval is to use vector indexes to find a certain number of text knowledge blocks that are most relevant to the query statement entered by the user.

[0130] The present invention can use the Dmeta-embedding-zh model to map the original query and semantically enhanced query in the query knowledge body into vector forms respectively, and use the retrieval function of the Faiss index to find and query the k results with the closest cosine similarity of the vector. That is, find the top k "knowledge block index texts" with similarity to the user's question in the vector semantic space, and record the "knowledge block id" corresponding to the text.

[0131] Based on the contents of the above embodiments, as an optional embodiment, the knowledge question-answering method of water-related laws and regulations provided by the present invention, the training method of the target vector model includes: constructing positive samples and negative samples; wherein the positive samples include semantic enhancement information samples and corresponding correct knowledge blocks; the negative samples include simple negative samples and difficult negative samples, the simple negative samples include semantic enhancement information samples and corresponding erroneous knowledge blocks, and the difficult negative samples are constructed based on the erroneous knowledge blocks of the semantic enhancement information samples output by the initial vector model; the initial vector model is trained using the positive samples and negative samples to obtain the target vector model.

[0132] Figure 4 is a schematic diagram of the process of constructing positive and negative samples provided by the present invention, and the following reference Figure 4 An embodiment is described.

[0133] Step 1: Use the professional knowledge base to segment and extract entities from users’ online questions, and obtain entity descriptions of corresponding entity concepts in the professional knowledge base;

[0134] Step 2: Based on the online answer content (the answers to questions about laws and regulations generally cite specific clauses, and note that the answers here are manual answers) and the entity description obtained in the first step, locate the knowledge block ID corresponding to the clause cited in the online answer;

[0135] Step 3: construct positive samples. Add entity descriptions to all entity concepts to form semantically enhanced information samples. Then, construct a positive sample for each knowledge block (correct knowledge block) in the answer.

[0136] Step 4: Construct a simple negative sample corresponding to the positive sample in a ratio of 1:2. The knowledge blocks in the simple negative sample come from random sampling of all knowledge blocks except the correct knowledge block (determined in the third step).

[0137] In a 1:3 ratio, we construct difficult negative samples corresponding to positive samples. The way to obtain knowledge blocks in difficult negative samples is different from that in simple negative samples. Specifically, we use an untuned vector model to retrieve semantically enhanced information samples, and remove the correct knowledge blocks from the topk retrieval results. We then randomly sample the remaining incorrect knowledge blocks to construct difficult negative samples.

[0138] After obtaining the positive and negative samples, the present invention can fine-tune the vector model to form a target vector model.

[0139] Although the fine-tuning method of the vector model in the present invention directly affects vector retrieval, since the sample is constructed through text-based knowledge extraction and the addition of entity description text that is closer to the semantics of laws and regulations, it is equivalent to taking advantage of the accuracy of text matching and introducing this advantage into vector retrieval. When fine-tuning the vector model and constructing samples, the semantic gap between user questions and retrieval results in the sample is narrowed in advance, so that each training sample can play a greater role in the fine-tuning process. The text and vector are deeply "combined", and additional professional knowledge is introduced to maximize the significance of joint retrieval.

[0140] Furthermore, the present invention also establishes a set of manual evaluation indicators to characterize the effect of the answer model from the following four dimensions:

[0141] Authenticity: used to measure the authenticity of the output information; Accuracy: used to measure the accuracy of the output information; Relevance: used to measure the relevance of the output information to the user's problem; Effectiveness: used to measure the effectiveness of the output information in helping users solve problems.

[0142] Each indicator is set to 5 points from high to low, and the final score is the average of the four indicator scores. The evaluation uses the results of public consultation and manual response from authoritative institutions such as special websites.

[0143] In another aspect, the present invention further provides a knowledge question-answering system for water-related laws and regulations, the system comprising: a first processing module, a second processing module, a third processing module and a fourth processing module;

[0144] The first processing module is used to match synonyms, entity descriptions and weight scores corresponding to the entity concepts in a pre-built professional knowledge base according to at least one entity concept extracted from the user's question content;

[0145] The second processing module is used to construct text enhancement information using the word segmentation results of the question content, all entity concepts and all synonyms; and to construct semantic enhancement information using all entity concepts and corresponding entity descriptions;

[0146] The third processing module is used to use the text enhancement information combined with the weight score of the entity concept to perform text search in the legal knowledge base to obtain the corresponding Topk search results, and use the semantic enhancement information to perform vector search in the legal knowledge base to obtain the corresponding Topk search results; and use the text enhancement information to perform network search to obtain the corresponding Topk search results; wherein the legal knowledge base includes multiple knowledge blocks, each knowledge block includes a knowledge block identity, a knowledge block search text for retrieval, and an identity of the associated legal and regulatory text; the Topk search results include the most relevant multiple knowledge blocks retrieved;

[0147] The fourth processing module is used to reorder the knowledge blocks in all Topk search results to obtain the final Topk search results so as to generate answer information using the question-answering model.

[0148] It should be noted that the knowledge question and answer system for water-related laws and regulations provided in the embodiment of the present invention can execute the knowledge question and answer method for water-related laws and regulations described in any of the above embodiments during specific operation, which will not be elaborated in this embodiment.

[0149] Figure 5 is a schematic diagram of the structure of the electronic device provided by the present invention, such as Figure 5 As shown, the electronic device may include: a processor 510, a communication interface 520, a memory 530 and a communication bus 540, wherein the processor 510, the communication interface 520 and the memory 530 communicate with each other via the communication bus 540. The processor 510 may call the logic instructions in the memory 530 to execute the knowledge question-answering method of water-related laws and regulations.

[0150] In addition, the logic instructions in the above-mentioned memory 530 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.

[0151] On the other hand, the present invention also provides a computer program product, which includes a computer program stored on a non-transitory computer-readable storage medium, and the computer program includes program instructions. When the program instructions are executed by a computer, the computer can execute the knowledge question and answer method of water-related laws and regulations provided in the above-mentioned embodiments.

[0152] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to execute the knowledge question-and-answer method of water-related laws and regulations provided in the above-mentioned embodiments.

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

Claims

1. A knowledge question-and-answer method for water-related laws and regulations. It is characterized in that include: According to at least one entity concept extracted from the user's question content, matching synonyms, entity descriptions and weight scores corresponding to the entity concept in a pre-built professional knowledge base; Using the word segmentation results of the question content, all entity concepts and all synonyms to construct text enhancement information; and using all entity concepts and corresponding entity descriptions to construct semantic enhancement information; Using text enhancement information combined with the weight score of the entity concept to perform text search in the legal knowledge base to obtain the corresponding Topk search results, using semantic enhancement information to perform vector search in the legal knowledge base to obtain the corresponding Topk search results; and using text enhancement information to perform network search to obtain the corresponding Topk search results; wherein the legal knowledge base includes multiple knowledge blocks, each knowledge block includes a knowledge block identity, a knowledge block search text for retrieval, and an identity of the associated legal and regulatory text; the Topk search results include the most relevant multiple knowledge blocks retrieved; Reorder all knowledge blocks in the Topk search results to obtain the final Topk search results, so as to generate answer information using the question-answering model; Reorder all knowledge blocks in the Topk search results to obtain the final Topk search results, and use the question-answering model to generate answer information, including: Use the knowledge blocks contained in the final Topk search results to determine the corresponding legal and regulatory texts; Input the legal and regulatory text and the user's question content into the pre-built question-answering model to obtain the corresponding answer information.

2. The knowledge question-and-answer method of water-related laws and regulations according to claim 1, It is characterized in that Use the word segmentation results of the question content, all entity concepts, and all synonyms to construct text enhancement information, including: Constructing a Boolean logic search formula by means of a Boolean expression as the text enhancement information; Among them, each entity concept and each synonym of each entity concept are connected by the Boolean logic operator or, and different entity concepts and word segmentation results are connected by the Boolean logic operator and.

3. The knowledge question and answer method of water-related laws and regulations according to claim 1, It is characterized in that Use text enhancement information combined with the weight score of entity concepts to perform text retrieval in the regulatory knowledge base to obtain the corresponding Topk retrieval results, including: Perform keyword matching with the knowledge block retrieval text of the knowledge block through the text enhancement information to obtain the matching knowledge block; Count the target entity concepts that appear in the knowledge block retrieval text of each matching knowledge block; Scoring each matching knowledge block according to the weight score of the target entity concept in each matching knowledge block; According to the scoring value of each matching knowledge block, multiple matching knowledge blocks with the highest scoring values ​​are determined as the Topk search results corresponding to the text search.

4. The method for questioning and answering knowledge about water-related laws and regulations according to claim 3, It is characterized in that According to the weight score of the target entity concept in each matching knowledge block, each matching knowledge block is scored as follows: in, is the scoring value of the matching knowledge block, D represents the knowledge block index text, represents the target entity concept set in the knowledge block index text D, Represents the target entity concept The inverse document frequency of It is represented as an indicator function. When the expression in the brackets is true, the indicator function value is 1, and when the expression in the brackets is false, the indicator function value is 0; Represents the target entity concept It belongs to the entity concepts pre-defined in the professional knowledge base; Target Entity Concept The weight score of , k is the adjustment factor.

5. The knowledge question-and-answer method of water-related laws and regulations according to claim 1, It is characterized in that Use semantic enhancement information to perform vector search in the regulatory knowledge base to obtain the corresponding Topk search results, including: Inputting the semantic enhancement information into a pre-trained target vector model; the target vector model is a model for vector retrieval based on the similarity between the semantic enhancement information and the knowledge block retrieval text; The target vector model is used to obtain a Topk search result output by the target vector model.

6. The method for questioning and answering knowledge about water-related laws and regulations according to claim 5, It is characterized in that The training method of the target vector model includes: Construct positive samples and negative samples; wherein the positive samples include semantic enhancement information samples and corresponding correct knowledge blocks; negative samples include simple negative samples and difficult negative samples, the simple negative samples include semantic enhancement information samples and corresponding erroneous knowledge blocks, and the difficult negative samples are constructed based on the erroneous knowledge blocks of the semantic enhancement information samples output by the initial vector model; The initial vector model is trained using positive samples and negative samples to obtain the target vector model.

7. A knowledge question-answering system for water-related laws and regulations, It is characterized in that include: A first processing module is used to match synonyms, entity descriptions and weight scores corresponding to the entity concepts in a pre-built professional knowledge base according to at least one entity concept extracted from the user's question content; The second processing module is used to construct text enhancement information using the word segmentation results of the question content, all entity concepts and all synonyms; And, construct semantic enhancement information using all entity concepts and corresponding entity descriptions; The third processing module is used to use the text enhancement information combined with the weight score of the entity concept to perform text search in the legal knowledge base to obtain the corresponding Topk search results, and use the semantic enhancement information to perform vector search in the legal knowledge base to obtain the corresponding Topk search results; and use the text enhancement information to perform network search to obtain the corresponding Topk search results; wherein the legal knowledge base includes multiple knowledge blocks, each knowledge block includes a knowledge block identity, a knowledge block search text for retrieval, and an identity of the associated legal and regulatory text; the Topk search results include the most relevant multiple knowledge blocks retrieved; The fourth processing module is used to reorder the knowledge blocks in all the Topk search results to obtain the final Topk search results so as to generate answer information using the question-answering model; Reorder all knowledge blocks in the Topk search results to obtain the final Topk search results, and use the question-answering model to generate answer information, including: Use the knowledge blocks contained in the final Topk search results to determine the corresponding legal and regulatory texts; Input the legal and regulatory text and the user's question content into the pre-built question-answering model to obtain the corresponding answer information.

8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, It is characterized in that When the processor executes the computer program, the steps of the knowledge question and answer method related to water laws and regulations as described in any one of claims 1 to 6 are implemented.

9. A non-transitory computer-readable storage medium having a computer program stored thereon, It is characterized in that When the computer program is executed by a processor, the steps of the knowledge question and answer method involving water laws and regulations as described in any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • Military knowledge graph construction and question-answering method based on encyclopedia data

    CN112667821A

  • Knowledge graph question-answering method for sub-graph retrieval optimization

    CN117149974A

  • Knowledge retrieval enhancement-based large language model question and answer method and device

    CN118113836A

  • Information processing system, server, terminal device, information processing method and program

    JP2017182457A

  • Knowledge graph question-answer method and apparatus based on deep learning technology, and device

    WO2021139283A1