Self-adaptive mixed retrieval enhanced question and answer method and device based on knowledge base
By introducing an adaptive hybrid search-enhanced question-and-answer method based on knowledge base in natural language processing technology, the search path is dynamically selected, and the problem of single search paths and lack of adaptive adjustment mechanism in the existing technology is solved, and an efficient and accurate question-and-answer system is realized.
Patent Information
- Application Number
- CN202510160474.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-13
- Publication Date
- 2025-06-10
AI Technical Summary
The existing technology lacks flexible search methods when dealing with complex problems, resulting in the use of the same search strategy for simple and complex problems, which affects the system's response efficiency and lacks an adaptive adjustment mechanism, making it impossible to determine when the search results have met the problem needs.
A knowledge base-based adaptive hybrid search enhanced question-and-answer method is proposed to construct a basic data source by extracting entities and relationships in the initial text, building a triple, and converting it into text search information and vector search information. According to the complexity of the problem, the search path is dynamically selected. shallow problems prefer vector and text retrieval, while deep problems introduce knowledge graph retrieval.
It significantly improves the search efficiency, optimizes resource allocation, and can flexibly select search paths based on the complexity of the problem, ensuring that the search content covers problem requirements without wasting computing resources.
Smart Images

Figure CN120123489A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of natural language processing, and particularly to an adaptive hybrid retrieval enhanced question answering method and device based on a knowledge base. Background Art
[0002] Retrieval-Augmented Generation (RAG) technology has developed rapidly in recent years, integrating the capabilities of information retrieval and generation models to improve the accuracy and efficiency of question answering and information generation tasks. The rapid development of RAG technology has spawned a variety of hybrid indexing architectures to meet the needs in different scenarios. Currently, the hybrid indexing framework mainly includes the following two types: the hybrid retrieval method based on vectors and text, and the hybrid retrieval method based on vectors, text, and relationship graphs (knowledge graphs). There are the following problems: The retrieval results of text and vectors lack structured context information, making it difficult to deeply understand the relationships between entities, which limits the accuracy of the system in dealing with complex problems; The retrieval path is single, and it is impossible to flexibly select the retrieval method according to the complexity of the question, resulting in the same retrieval strategy being used for both simple and complex questions, affecting the efficiency of the system response; Moreover, when dealing with shallow questions, there is a lack of lightweight retrieval options, resulting in excessive calculation and resource consumption, affecting the system efficiency. Even for simple questions, the system calls complex graph retrieval, wasting computing resources; There is a lack of an adaptive adjustment mechanism, and it is impossible to determine when the retrieval results have met the question requirements. This leads to the system possibly continuing to retrieve when the information is already sufficient, increasing unnecessary overhead, or failing to continue retrieving when the information is insufficient, affecting the accuracy of the answer.
[0003] In summary, how to design an adaptive hybrid retrieval enhanced question answering method based on a knowledge base with high efficiency and accuracy is an urgent problem to be solved currently. Summary of the Invention
[0004] This application aims to solve at least one of the technical problems in the related art to some extent.
[0005] To this end, the first object of this application is to propose an adaptive hybrid retrieval enhanced question answering method based on a knowledge base to solve the problems that the existing technical means cannot flexibly select the retrieval method according to the complexity of the question, resulting in the same retrieval strategy being used for both simple and complex questions, affecting the efficiency of the system response, etc.
[0006] The second object of this application is to propose a device.
[0007] The third object of this application is to propose an electronic device.
[0008] The fourth object of this application is to propose a computer-readable storage medium.
[0009] To achieve the above object, an embodiment of the first aspect of the present application proposes an adaptive hybrid retrieval enhanced question-answering method based on a knowledge base, including:
[0010] Extract entities in the initial text, identify the relationships between the entities, and form triples;
[0011] Convert the structured information of the triples into text retrieval information and vector retrieval information, and merge the text retrieval information and the vector retrieval information with the initial text to construct a basic data source;
[0012] Preset query question levels, where the query question levels include the first question and the second question. Judge the complexity of the question to be queried. If the question to be queried is the first question, directly obtain the answer using semantic matching; if the question to be queried is the second question, extract the keywords of the question to be queried, and obtain the structured data of entities and relationships in the basic data source based on the keywords to obtain a retrieval result;
[0013] Re-rank based on the retrieval result to generate a question answer.
[0014] Preferably, the extracting entities in the initial text, identifying the relationships between the entities, and forming triples includes:
[0015] Segment and parse the initial text to obtain the semantic structure of the sentences in the initial text;
[0016] Use a named entity recognition model to extract and label the semantic structure of the sentence to obtain entities of labeled categories;
[0017] Identify the relationships between the entities based on a relationship extraction model to construct triples.
[0018] Preferably, the converting the structured information of the triples into text retrieval information and vector retrieval information, and merging the text retrieval information and the vector retrieval information with the initial text to construct a basic data source includes:
[0019] Use the triples to construct a knowledge graph, perform graphic-text conversion on the triples in the knowledge graph, convert the structured relationship graph into text retrieval information and vector retrieval information, and use the text retrieval information and the vector retrieval information to construct a basic data source.
[0020] Preferably, after constructing the basic data source, it further includes:
[0021] Store and index the basic data source. The index includes: inverted index, vector index, and knowledge graph. The inverted index includes cleaning noise, tokenizing, and removing stop words from each document, constructing a dictionary, traversing with each independent word as the key of the dictionary, and constructing an inverted list using each corresponding document ID. The vector index includes converting the basic data source into a numerical vector. The knowledge graph includes constructing a graph structure of entities and relationships, where entities are nodes and relationships are edges to generate a knowledge graph.
[0022] Preferably, for the preset query problem level, the query problem level includes a first problem and a second problem. Judge the complexity of the problem to be queried. If the problem to be queried is the first problem, directly obtaining the answer using semantic matching includes:
[0023] Obtain a set of sample questions marked as completed;
[0024] Perform an expansion process on the set of sample questions and screen question tags to obtain a high-quality training set;
[0025] Use the high-quality training set to train the model to be trained to obtain a trained problem judgment model;
[0026] Use the trained problem judgment model to judge the problem level of the problem to be queried. If the problem to be queried is the first problem, use the vector retrieval to search the text library, obtain text paragraphs similar to the problem to be queried, and use the inverted index to perform an exact match on the text paragraphs to obtain the retrieval result.
[0027] Preferably, if the problem to be queried is the second problem, extract the keywords of the problem to be queried, and obtain the structured data of entities and relationships in the basic data source based on the keywords to obtain the retrieval result, including:
[0028] If the problem to be queried is the second problem, use Graph retrieval to obtain structured data containing entities and relationships from the knowledge graph, judge whether the structured data can answer the problem to be queried. If it can answer the problem to be queried, obtain the retrieval result; if it cannot answer the problem to be queried, increase the hierarchy value to expand the retrieval range to obtain the retrieval result.
[0029] Preferably, judging whether the structured data can answer the problem to be queried includes:
[0030] Obtain content adequacy judgment data and construct a training data set;
[0031] Fine-tune and train the LLaMA model based on the training data set to obtain a trained content adequacy judgment model;
[0032] Use the content sufficiency judgment model to judge whether the structured data can answer the question to be queried.
[0033] To achieve the above object, an embodiment of the second aspect of the present application proposes an adaptive hybrid retrieval enhanced question answering device based on a knowledge base, including:
[0034] A data extraction module extracts entities in the initial text, identifies the relationships between the entities, and forms triples;
[0035] A data set construction module converts the structured information of the triples into text retrieval information and vector retrieval information, and merges the text retrieval information and the vector retrieval information with the initial text to construct a basic data source;
[0036] A retrieval result acquisition module presets query question levels, where the query question levels include a first question and a second question, judges the complexity of the question to be queried. If the question to be queried is the first question, directly obtain the answer using semantic matching; if the question to be queried is the second question, extract the keywords of the question to be queried, and obtain the structured data of entities and relationships in the basic data source based on the keywords to obtain a retrieval result;
[0037] An answer generation module re-ranks based on the retrieval result to generate a question answer.
[0038] To achieve the above object, an embodiment of the third aspect of the present application proposes an electronic device, including: a processor, and a memory communicatively connected to the processor;
[0039] The memory stores computer execution instructions;
[0040] The processor executes the computer execution instructions stored in the memory to implement the method described in any one of the above.
[0041] To achieve the above object, an embodiment of the fourth aspect of the present application proposes a computer-readable storage medium, where the computer-readable storage medium stores computer execution instructions, and the computer execution instructions are used to implement the method described in any one of the above when executed by a processor.
[0042] An adaptive hybrid retrieval enhanced question answering method based on a knowledge base provided by this application generates natural language descriptions by performing graphic-text conversion on entities and relationships in a knowledge graph, thereby constructing a multi-level hybrid index that supports both semantic expansion and precise matching, making full use of structured information to improve the coverage and accuracy of question retrieval. By dynamically analyzing the depth of questions, the system adaptively selects vectors, text, or retrieval paths. Shallow questions preferentially use vector and text retrieval, while deep questions introduce knowledge graph retrieval. This mechanism significantly improves the retrieval efficiency, optimizes resource allocation, and adaptively selects retrieval paths based on the complexity of questions, using faster vector and text retrieval for simple questions and introducing knowledge graph retrieval for complex questions, thus achieving dynamic allocation and flexible selection of resources.
[0043] Additional aspects and advantages of this application will be given in part in the following description, become apparent in part from the following description, or be understood through the practice of this application. Brief Description of the Drawings
[0044] The above-mentioned and / or additional aspects and advantages of this application will become apparent and be readily understood from the following description of the embodiments in conjunction with the drawings, where:
[0045] Figure 1 is a flowchart of the first specific embodiment of an adaptive hybrid retrieval enhanced question answering method based on a knowledge base provided by the present invention;
[0046] Figure 2 is an overall flowchart of an adaptive hybrid retrieval enhanced question answering method based on a knowledge base;
[0047] Figure 3 is a schematic diagram of question complexity classification prompts;
[0048] Figure 4 is a schematic diagram of content sufficiency judgment prompts;
[0049] Figure 5 is an example diagram of a knowledge graph;
[0050] Figure 6 is a flowchart of retrieval enhanced generation;
[0051] Figure 7 is a structural block diagram of an adaptive hybrid retrieval enhanced question answering device provided by an embodiment of the present invention. Detailed Embodiments
[0052] The core of the present invention is to provide an adaptive hybrid retrieval enhanced question answering method and device based on a knowledge base, which adaptively selects retrieval paths according to the depth of questions during the retrieval process, improves the efficiency of simple queries, and provides deeper graph structure support in complex queries.
[0053] To enable those skilled in the art to better understand the solution of the present invention, the present invention will be further described in detail below in conjunction with the accompanying drawings and specific embodiments. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all of the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the scope of protection of the present invention.
[0054] Please refer to Figure 1 , Figure 1 which is a flowchart of the first specific embodiment of an adaptive hybrid retrieval enhanced question answering method based on a knowledge base provided by the present invention; the specific operation steps are as follows:
[0055] Step S101: Extract entities in the initial text and identify the relationships between the entities to form triples.
[0056] Extracting entities in the initial text and identifying the relationships between the entities to form triples includes:
[0057] Segment and parse the initial text to obtain the semantic structure of the sentences in the initial text;
[0058] Use a named entity recognition model to extract and label the semantic structure of the sentences to obtain entities of labeled categories;
[0059] Based on a relationship extraction model, identify the relationships between entities and construct triples.
[0060] Step S102: Convert the structured information of the triples into text retrieval information and vector retrieval information, and merge the text retrieval information and the vector retrieval information with the initial text to construct a basic data source.
[0061] Use the triples to construct a knowledge graph, perform graphic-text conversion on the triples in the knowledge graph, convert the structured relationship graph into text retrieval information and vector retrieval information, and merge the text retrieval information and the vector retrieval information with the information in the initial text to construct a basic data source for text retrieval and vector retrieval.
[0062] Store and index the basic data source. The index includes: an inverted index, a vector index, and a knowledge graph; the inverted index includes cleaning noise, segmenting words, and removing stop words for each document, constructing a dictionary, traversing each independent word as a key of the dictionary, and constructing an inverted list using each corresponding document ID; the vector index includes converting the basic data source into numerical vectors; the knowledge graph includes constructing a graph structure of entities and relationships, where entities are used as nodes and relationships are used as edges to generate a knowledge graph.
[0063] Step S103: Preset the query problem levels. The query problem levels include the first problem and the second problem. Determine the complexity of the problem to be queried. If the problem to be queried is the first problem, directly obtain the answer using semantic matching. If the problem to be queried is the second problem, extract the keywords of the problem to be queried and obtain the structured data of entities and relationships in the basic data source based on the keywords to get the retrieval result.
[0064] Obtain the marked sample problem set;
[0065] Perform an expansion process on the sample problem set and filter the problem tags to obtain a high-quality training set;
[0066] Use the high-quality training set to train the model to be trained to obtain a trained problem judgment model;
[0067] Use the trained problem judgment model to judge the problem level of the problem to be queried. If the problem to be queried is the first problem, perform a search on the text library using vector retrieval to obtain text paragraphs similar to the problem to be queried, and use the inverted index to perform an exact match on the text paragraphs to obtain the retrieval result.
[0068] If the problem to be queried is the second problem, use Graph retrieval to obtain the structured data containing entities and relationships from the knowledge graph, and determine whether the structured data can answer the problem to be queried. If it can answer the problem to be queried, obtain the retrieval result. If it cannot answer the problem to be queried, increase the level value to expand the retrieval range to obtain the retrieval result.
[0069] The determination of whether the structured data can answer the problem to be queried includes:
[0070] Obtain the content adequacy judgment data and construct a training data set;
[0071] Fine-tune and train the LLaMA model based on the training data set to obtain a trained content adequacy judgment model;
[0072] Use the content adequacy judgment model to determine whether the structured data can answer the problem to be queried.
[0073] In one embodiment, the first problem can also be called a shallow problem, and the second problem can also be called a deep problem, which is preset by the model analyzing the depth, difficulty, and ease of the query problem and will not be elaborated here.
[0074] Step S104: Re-rank based on the retrieval result to generate the question answer.
[0075] This embodiment provides an adaptive hybrid retrieval enhanced question answering method based on a knowledge base, which adaptively selects a retrieval path based on the complexity of the question. For simple questions, faster vector and text retrieval are used, while for complex questions, knowledge graph retrieval is introduced, thus realizing dynamic allocation and flexible selection of resources, and significantly improving the system efficiency. By means of content sufficiency judgment and gradually expanding the retrieval depth, it is ensured that the retrieved content can cover the question requirements and does not waste computing resources. Even if the content requirements cannot be met after multiple expansions, the maximum depth limit of the system can avoid unnecessary computing overhead. A multi-level graphic-text fusion index structure is constructed, including an inverted index, a vector index, and a knowledge graph index, supporting broader and more accurate retrieval requirements. Through graphic-text conversion, the system can more comprehensively combine text information with graph relationships, improving the accuracy and coverage of answers, and being able to provide users with more in-depth and context-related answers.
[0076] Based on the above embodiment, this embodiment describes the above-mentioned adaptive hybrid retrieval enhanced question answering method based on a knowledge base, as Figure 2 shown, specifically as follows:
[0077] The shallow question in this embodiment corresponding to the first question mentioned in the above embodiment; the deep question in this embodiment corresponding to the second question.
[0078] Data collection and preprocessing, including:
[0079] The system first performs word segmentation and dependency parsing on the initial text to analyze the basic semantic structure in the sentence. Then, through a named entity recognition (NER) model, the core entities are extracted from the text and their categories (such as person names, locations, organizations, etc.) are annotated. Then, a relationship extraction model is used to further identify the relationships between these entities and express them in the form of "triples", such as "(John, works_at, Google)".
[0080] Then, the triples constituting the knowledge graph are "graphic-text converted", that is, the structured relationship graph information is converted into a form suitable for text retrieval and vector retrieval. The entities in the knowledge graph and the relationships between them contain rich context information, and this information is converted into natural language descriptions through a language model, thus becoming the basic data source for subsequent text retrieval and vector retrieval.
[0081] After data initialization, the system stores and indexes data in the following three ways:
[0082] Inverted index: Each document is preprocessed, noise is cleaned, word segmentation is performed, and stop words are removed. Then, the system constructs a dictionary, taking each independent word as the key of the dictionary. Then, all documents are traversed, and for each word, the ID of the document where it is located is recorded, thus forming an inverted list.
[0083] Vector Indexing: Convert the above-mentioned basic data sources into numerical vector representations. Specifically, use a pre-trained language model to encode the text, converting sentences or paragraphs into high-dimensional semantic vectors. Then, these vectors are input into a vector index library, and an efficient vector index structure is established through Faiss. The Faiss library quickly performs similarity retrieval and finds content semantically similar to the query in the vector space through approximate nearest neighbor search, thus achieving fuzzy matching at the semantic level.
[0084] Knowledge Graph: Use a graph database or graph processing library to construct these entities and relationships into a graph structure, where entities are nodes and relationships are edges, thus generating a knowledge graph. This graph can reflect the key contextual information in the text in a structured form and support efficient information query and analysis.
[0085] Question Retrieval, including:
[0086] Through a dynamic retrieval path selection and content sufficiency judgment mechanism, efficient responses are achieved under different question complexities, ensuring quick feedback for shallow questions and accurate and rich answers for deep questions. Specifically, it includes:
[0087] After the system receives a query, the model first analyzes its depth, that is, determines whether this is a "shallow question" or a "deep question". To achieve this function, first design a batch of example question sets labeled as "shallow" or "deep", such as "Which layers does the OSI architecture of computer networks include?" (shallow) and "How does climate change affect the future of agricultural production?" (deep). Then, use GPT-4 to expand these examples and ensure the accuracy of question labels through manual screening to form a high-quality training set. As Figure 3 shown, when constructing training data, convert the questions into a prompt format with context.
[0088] Load the LLaMA model in the Transformers library of Hugging Face, perform fine-tuning training using the labeled data, and optimize the accuracy of the model in judging complexity by adjusting parameters. Then, test with a new question set to verify the accuracy of the model in judging shallow and deep questions. When going online, the model combines prompt-assisted judgment to let the model fill in "shallow" or "deep" in actual applications.
[0089] Shallow questions can usually be directly answered through simple keyword or semantic matching, while deep questions involve more complex relationships or context associations and require more in-depth analysis. At the same time, the system preprocesses the questions raised by users, and uses the term frequency-inverse document frequency (TF-IDF) method and inverted index for preliminary analysis to extract important key points related to the questions.
[0090] In one embodiment, for the processing of shallow questions, first, vector retrieval is used to quickly search the text library to capture text paragraphs semantically similar to the user's question. Through the embedding model to obtain high-dimensional semantic representations, vector retrieval can quickly locate potential candidate answers highly relevant to the question, greatly improving the retrieval speed in a large-scale text library. Next, the results obtained from vector retrieval are fed back to the text retrieval module, and exact matching of keywords is performed through the inverted index to further improve the accuracy and relevance of the retrieval. Finally, the retrieved content is passed to the content sufficiency judgment model for evaluation to determine whether it is sufficient to answer the user's question. If the evaluation result is "no", the system will convert the question into a deep question for processing to ensure accurate and comprehensive answers are provided.
[0091] In one embodiment, for the processing of deep questions, first, Graph retrieval is used to obtain structured content containing entities and relationships from the knowledge graph to support the answering of complex questions. The content after Graph retrieval is passed to the content sufficiency judgment model for evaluation to determine whether the current content is sufficient to answer the user's question. If the evaluation result of the content sufficiency model is "no", the system will gradually increase the depth of Graph retrieval (by increasing a certain level value, such as the number of relationship hops or the number of connected nodes) to expand the retrieval scope to ensure more relevant information is obtained. However, to avoid infinite expansion, the system sets a maximum retrieval depth value as a limit. Even if the content requirements are not met after multiple expansions, the system will stop the retrieval and return the current optimal result.
[0092] Among them, as Figure 4 shown, the content sufficiency judgment is as follows:
[0093] In the process of implementing content sufficiency judgment, first, for the questions generated by GPT-4 in the "question analysis" stage, relevant documents are manually retrieved and combined to construct new training data. In the training data, the questions are converted into a prompt format with context, and the specific format is as Figure 3As shown below. At the same time, mark the corresponding "Yes" or "No" to help the model clearly understand this judgment task. Then, use the LLaMA model for fine-tuning training as well. Finally, put the model online and use prompts to assist in judgment so that it can automatically fill in the "Yes" or "No" label in actual applications. When the model outputs "Yes", it means that the current content is sufficient, and the system will stop further retrieval and pass the result to the generation module for processing; if the model outputs "No", the system believes that the current content is insufficient and enters a deeper retrieval process to obtain more information.
[0094] The specific generation of question answers is as follows:
[0095] Based on the retrieved results, the system re-ranks them and selects the most relevant result set as the input for answer generation.
[0096] As Figure 5 、 Figure 6 shown, among which, re-ranking includes: The results provided by the retrieval module usually contain multiple candidate answers. To select the most relevant answer, the system prioritizes these results through a re-ranking algorithm. Multiple factors are considered during ranking, including:
[0097] The relationship between the paragraph and the key entities of the question: The system analyzes the relationship between the retrieved paragraph and the entities in the question in the knowledge graph to judge their relevance. The relevance is judged by analyzing the distance and the number of connections between entities. For example, paragraphs directly related to the entities in the question will be given higher priority.
[0098] Optimizing generation by combining knowledge graph relationships
[0099] The system not only considers text and vector information but also further optimizes through the entity reference relationships in the knowledge graph. For example, if entity A has a strong reference relationship with entity B, the content of A may explain or reference the information of B. In this way, the system can generate more coherent and accurate answers, especially suitable for scenarios with complex multi-entity relationships.
[0100] The system generates the final answer based on the user's query, the retrieved candidate paragraphs, and their relationships in the knowledge graph. The generated answer not only has high semantic relevance but also can effectively combine the key entities in the question to ensure the content is accurate and coherent.
[0101] This embodiment provides an adaptive hybrid retrieval enhanced question-answering method based on a knowledge base, which adaptively selects a retrieval path based on the complexity of the question. For simple questions, faster vector and text retrieval are used, while for complex questions, knowledge graph retrieval is introduced, thus realizing dynamic allocation and flexible selection of resources and significantly improving the system efficiency. By means of content sufficiency judgment and gradually expanding the retrieval depth, it is ensured that the retrieved content can cover the question requirements and does not waste computing resources. Even if the content requirements cannot be met after multiple expansions, the maximum depth limit of the system can avoid unnecessary computing overhead. A multi-level graphic-text fusion index structure is constructed, including an inverted index, a vector index, and a knowledge graph index, which supports broader and more accurate retrieval requirements. Through graphic-text conversion, the system can more comprehensively combine text information with graph relationships, improve the accuracy and coverage of answers, and be able to provide users with more in-depth and context-related answers.
[0102] Please refer to Figure 7 , Figure 7 which is a structural block diagram of an adaptive hybrid retrieval enhanced question-answering device provided by an embodiment of the present invention; the specific device may include:
[0103] A data extraction module 100 extracts entities in the initial text and identifies the relationships between the entities to form triples.
[0104] A data set construction module 200 converts the structured information of the triples into text retrieval information and vector retrieval information, and merges the text retrieval information and the vector retrieval information with the initial text to construct a basic data source.
[0105] A retrieval result acquisition module 300 presets query question levels, where the query question levels include a first question and a second question, judges the complexity of the question to be queried. If the question to be queried is the first question, the answer is directly obtained by semantic matching; if the question to be queried is the second question, the keywords of the question to be queried are extracted, and structured data of entities and relationships in the basic data source are obtained based on the keywords to obtain a retrieval result.
[0106] An answer generation module 400 re-ranks based on the retrieval result to generate a question answer.
[0107] An adaptive hybrid retrieval enhanced question answering device according to this embodiment is used to implement the aforementioned adaptive hybrid retrieval enhanced question answering method based on a knowledge base. Therefore, the specific implementation manners in the adaptive hybrid retrieval enhanced question answering device based on a knowledge base can be seen in the embodiment part of the aforementioned adaptive hybrid retrieval enhanced question answering method based on a knowledge base. For example, the data extraction module 100, the data set construction module 200, the retrieval result acquisition module 300, and the answer generation module 400 are respectively used to implement steps S101, S102, S103, and S104 in the aforementioned adaptive hybrid retrieval enhanced question answering method. Therefore, the specific implementation manners can refer to the descriptions of the corresponding various part embodiments and will not be elaborated here.
[0108] To implement the above embodiments, the present application also proposes an electronic device, including: a processor, and a memory communicatively connected to the processor; the memory stores computer-executable instructions; the processor executes the computer-executable instructions stored in the memory to implement the method provided in the foregoing embodiments.
[0109] To implement the above embodiments, the present application also proposes a computer-readable storage medium storing computer-executable instructions, and the computer-executable instructions are used to implement the method provided in the foregoing embodiments when executed by a processor.
[0110] To implement the above embodiments, the present application also proposes a computer program product including a computer program, and the computer program implements the method provided in the foregoing embodiments when executed by a processor.
[0111] The collection, storage, use, processing, transmission, provision, and disclosure of the user's personal information involved in the present application all comply with the provisions of relevant laws and regulations and do not violate public order and good customs.
[0112] It should be noted that personal information from users should be collected for legal and reasonable purposes and not shared or sold outside of these legitimate uses. In addition, such collection / sharing should be carried out after obtaining the informed consent of the user, including but not limited to notifying the user to read the user agreement / user notice and signing an agreement / authorization including authorizing relevant user information before the user uses the function. In addition, any necessary steps should be taken to protect and safeguard access to such personal information data and ensure that others with access to the personal information data comply with their privacy policies and procedures.
[0113] This application is expected to provide an implementation scheme for users to selectively prevent the use or access of personal information data. That is, this disclosure is expected to provide hardware and / or software to prevent or block access to such personal information data. Once the personal information data is no longer needed, the risk can be minimized by restricting data collection and deleting the data. In addition, when applicable, personal identifiers are removed from such personal information to protect the privacy of users.
[0114] In the description of the foregoing embodiments, the descriptions referring to terms such as "one embodiment", "some embodiments", "example", "specific example", or "some examples" mean that the specific features, structures, materials, or characteristics described in connection with the embodiment or example are included in at least one embodiment or example of this application. In this specification, the schematic descriptions of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials, or characteristics described can be combined in a suitable manner in any one or more embodiments or examples. In addition, without contradiction, those skilled in the art can combine and combine the different embodiments or examples described in this specification and the features of different embodiments or examples.
[0115] In addition, the terms "first" and "second" are only used for descriptive purposes and cannot be understood as indicating or implying relative importance or implicitly specifying the quantity of the indicated technical features. Thus, the features defined with "first" and "second" can explicitly or implicitly include at least one of the features. In the description of this application, "a plurality" means at least two, such as two, three, etc., unless otherwise specifically defined.
[0116] Any process or method description shown in the flowchart or described in other ways herein can be understood as representing a module, segment, or part of code including one or more executable instructions for implementing a customized logic function or process, and the scope of the preferred implementation of this application includes additional implementations, where the functions can be executed in a manner that is not in the order shown or discussed, including in a substantially simultaneous manner or in the reverse order according to the functions involved, which should be understood by those skilled in the art to which the embodiments of this application belong.
[0117] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a definite sequence list of executable instructions for implementing logical functions, and can be specifically implemented in any computer-readable medium for use by an instruction execution system, apparatus, or device (such as a computer-based system, a system including a processor, or other systems that can fetch and execute instructions from the instruction execution system, apparatus, or device), or in conjunction with these instruction execution systems, apparatus, or devices. For the purposes of this specification, a "computer-readable medium" can be any device that can contain, store, communicate, propagate, or transport a program for use by or in conjunction with an instruction execution system, apparatus, or device. More specific examples (non-exhaustive list) of computer-readable media include the following: an electrical connection portion with one or more wirings (electronic device), a portable computer diskette (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disc read-only memory (CDROM). Additionally, the computer-readable medium can even be paper or other suitable media on which the program can be printed, because the program can be obtained electronically, for example, by optically scanning the paper or other media, then editing, interpreting, or otherwise processing it as appropriate, and then storing it in a computer memory.
[0118] It should be understood that various parts of the present application can be implemented by hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, any one or a combination of the following techniques well known in the art can be used: discrete logic circuits having logic gate circuits for implementing logical functions on data signals, application specific integrated circuits having appropriate combinational logic gate circuits, programmable gate arrays (PGAs), field programmable gate arrays (FPGAs), etc.
[0119] Those of ordinary skill in the art of this technology can understand that all or part of the steps carried by the method of implementing the above embodiments can be completed by a program instructing relevant hardware, and the program can be stored in a computer-readable storage medium. When the program is executed, it includes one or a combination of the steps of the method embodiments.
[0120] In addition, each functional unit in various embodiments of the present application may be integrated into one processing module, may exist separately as individual physical units, or two or more units may be integrated into one module. The above-mentioned integrated module may be implemented in the form of hardware or in the form of a software functional module. When the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it may also be stored in a computer-readable storage medium.
[0121] The above-mentioned storage medium may be a read-only memory, a magnetic disk or an optical disc, etc. Although the embodiments of the present application have been shown and described above, it can be understood that the above embodiments are exemplary and should not be construed as limiting the present application. Those of ordinary skill in the art can make changes, modifications, substitutions and variations to the above embodiments within the scope of the present application.
Claims
1. A knowledge base-based adaptive hybrid retrieval enhanced question answering method, characterized in that: include: Extracting entities from the initial text and identifying the relationships between the entities to form triples; Converting the structured information of the triples into text retrieval information and vector retrieval information, and merging the text retrieval information and the vector retrieval information with the initial text to construct a basic data source; Preset a query question level, the query question level includes a first question and a second question, determine the complexity of the query question, if the query question is the first question, directly obtain the answer by using semantic matching; if the query question is the second question, extract the keywords of the query question, and obtain the structured data of entities and relationships in the basic data source based on the keywords to obtain the search results; The search results are re-ranked to generate answers to the questions.
2. The knowledge base-based adaptive hybrid retrieval enhanced question answering method according to claim 1, characterized in that: The extracting of entities from the initial text and identifying the relationships between the entities to form triples include: Performing word segmentation and parsing on the initial text to obtain the semantic structure of the sentences in the initial text; Using a named entity recognition model to extract and annotate the semantic structure of the sentence to obtain entities of the annotated category; The relationships between the entities are identified based on the relationship extraction model, and triples are constructed.
3. The knowledge base-based adaptive hybrid retrieval enhanced question answering method according to claim 1, characterized in that: The converting the structured information of the triple into text retrieval information and vector retrieval information, and merging the text retrieval information and the vector retrieval information with the initial text to construct a basic data source includes: The knowledge graph is constructed using the triples, the triples in the knowledge graph are converted into text and image, the structured relationship graph is converted into text retrieval information and vector retrieval information, the text retrieval information and the vector retrieval information are merged with the information in the initial text, and a basic data source for text retrieval and vector retrieval is constructed.
4. The knowledge base-based adaptive hybrid retrieval enhanced question answering method according to claim 3, characterized in that: After constructing the basic data source for text retrieval and vector retrieval, the following steps are also included: The basic data source is stored and indexed, and the index includes: an inverted index, a vector index and a knowledge graph; the inverted index includes cleaning noise, segmenting and removing stop words for each document, building a dictionary, traversing each independent word as a key of the dictionary, and building an inverted list using each corresponding document ID; the vector index includes converting the basic data source into a numerical vector; the knowledge graph includes constructing a graph structure of entities and relationships, wherein entities are used as nodes and relationships are used as edges to generate a knowledge graph.
5. The knowledge base-based adaptive hybrid retrieval enhanced question answering method according to claim 4, characterized in that: The preset query question level, the query question level includes a first question and a second question, and judging the complexity of the query question. If the query question is the first question, directly obtaining the answer by using semantic matching includes: Get the set of sample questions that have been marked complete; Expanding the sample question set and filtering question labels to obtain a high-quality training set; Use high-quality training sets to train the model to be trained, and obtain a trained problem judgment model; The trained question judgment model is used to judge the question level of the question to be queried. If the question to be queried is the first question, the vector retrieval is used to search the text library to obtain text paragraphs similar to the question to be queried, and the inverted index is used to accurately match the text paragraphs to obtain the retrieval result.
6. The knowledge base-based adaptive hybrid retrieval enhanced question answering method according to claim 1, characterized in that: If the question to be queried is the second question, keywords of the question to be queried are extracted, and structured data of entities and relationships in the basic data source are acquired based on the keywords, and the retrieval results obtained include: If the question to be queried is the second question, use Graph search to obtain structured data containing entities and relationships from the knowledge graph, and determine whether the structured data can answer the question to be queried. If it can answer the question to be queried, obtain the search result; if it cannot answer the question to be queried, increase the level value to expand the search scope and obtain the search result.
7. The knowledge base-based adaptive hybrid retrieval enhanced question answering method according to claim 6, characterized in that: The determining whether the structured data can answer the query question includes: Obtain content adequacy judgment data and build a training data set; Fine-tune the LLaMA model based on the training data set to obtain a trained content adequacy judgment model; The content adequacy judgment model is used to judge whether the structured data can answer the query question.
8. An adaptive hybrid retrieval enhanced question-answering device based on a knowledge base, characterized in that: include: A data extraction module extracts entities from the initial text and identifies the relationships between the entities to form triples; A data set construction module converts the structured information of the triples into text retrieval information and vector retrieval information, and merges the text retrieval information and the vector retrieval information with the initial text to construct a basic data source; A search result acquisition module is provided, which presets a query question level, wherein the query question level includes a first question and a second question, and determines the complexity of the query question. If the query question is the first question, the answer is directly obtained by using semantic matching; if the query question is the second question, the keyword of the query question is extracted, and the structured data of entities and relationships in the basic data source are obtained based on the keyword to obtain the search result; The answer generation module re-ranks the search results to generate answers to the questions.
9. An electronic device, characterized in that: include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, which are used to implement the method according to any one of claims 1 to 7 when executed by a processor.
Citation Information
Cited By
Material synthesis data extraction method and system based on knowledge enhancement large model
CN121051250A
Entity link adaptation method, system and equipment for general information extraction model
CN121597815A
Knowledge index and text generation control method and system for retrieval enhancement generation
CN121765029A
Retrieval enhanced generated knowledge index and text generation control method and system
CN121765029B
A computer- implemented method of structuring content for training an artificial intelligence model
US20230214593A1