Knowledge question and answer method based on multiple agents and heterogeneous data sources
By constructing a knowledge question-answering system with multiple agents and heterogeneous data sources, the system solves the problems of flexibility and efficiency in the face of diverse user questions, and achieves efficient and accurate knowledge question-answering services.
Patent Information
- Application Number
- CN202511648089.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-12
- Publication Date
- 2025-12-09
AI Technical Summary
Existing knowledge-based question-answering systems lack flexibility when faced with diverse user questioning scenarios and cannot effectively integrate information from different types of databases, resulting in low response efficiency and an inability to meet users' immediate needs.
We employ a multi-agent and heterogeneous data source approach to construct a vector database and a graph database. We utilize a knowledge graph to generate a basic question pool and use a routing agent to dynamically invoke a retrieval agent for efficient retrieval and answer generation.
It enables efficient and accurate responses to diverse user queries, reduces the waste of computing resources caused by repeated searches, and improves the system's flexibility and response efficiency.
Smart Images

Figure CN121092679A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of natural language processing technology, specifically relating to a knowledge question answering method based on multiple agents and heterogeneous data sources. Background Technology
[0002] In recent years, internet data has exploded, and knowledge-based question-answering systems aim to help users quickly obtain the information they need from massive amounts of data. Traditional knowledge-based question-answering systems are mostly based on fixed workflows. Their typical operating mode is: users ask questions, the system retrieves information from a single data source according to preset rules and processes, and then provides an answer. While these systems can provide some question-answering services, they have significant limitations: First, the fixed workflow model lacks flexibility. When encountering questions beyond the scope of preset rules, the system often cannot effectively respond and cannot adjust and optimize itself based on user feedback and complex real-world situations. Secondly, these systems based on a single data source can only answer a limited number of question types and cannot cope with diverse user questioning scenarios.
[0003] With the development of information technology, some knowledge-based question-answering systems have begun to integrate multiple data sources. However, due to the different data formats, storage structures, and semantic representations of these data sources, selecting appropriate data sources based on question type and achieving fast and efficient retrieval remain challenges. For example, the literature [Sarmah B, Mehta D, Hall B, et al. Hybridrag: Integrating Knowledge Graphs and Vector Retrieval Enhanced Generation Techniques for Efficient Information Extraction. Proceedings of the 5th ACM International Conference on Financial Artificial Intelligence. 2024: pp. 608-616] uses a simple concatenation of information from vector retrieval and graph retrieval to form a more comprehensive context, which is then input into a large language model to generate the answer. However, this fixed approach lacks flexibility and may lead to information interference when reasoning about complex problems. For example, the paper [Lee MC, Zhu Q, Mavromatis C et al. Agent-G: An intelligent agent framework for enhanced generation of graph retrieval. Journal of Artificial Intelligence Research, 2025: Vol. 73, pp. 1-15] constructs a source object pool to uniformly manage heterogeneous data and introduces intelligent agent technology to dynamically select data sources and perform complex retrieval actions, thereby improving the quality of the context ultimately provided to the large language model. However, this method requires all original text content to be pre-mapped to the vector space, which leads to significant performance overhead when processing large-scale, dynamic data. At the same time, the intelligent agent is highly dependent on the underlying reasoning ability of the large language model, making it difficult to guarantee the accuracy and timeliness of the generated retrieval strategy.
[0004] When faced with a large number of user questions, the response efficiency of the knowledge question answering system becomes another prominent issue. According to the system workflow definition, every time a user enters a question, even if it is a question similar to a historical question, the system needs to re-analyze the question and perform complex and time-consuming real-time retrieval and processing from the knowledge base. Obviously, this mode will lead to a large waste of computing resources and will also fail to meet users' needs for immediacy.
[0005] In certain specific fields such as medicine and economics, there is a vast amount of relevant data, requiring both experts and ordinary users to spend considerable time and effort searching and filtering. While the emergence of knowledge-based question-and-answer systems has improved information retrieval efficiency to some extent, the challenge remains in linking and integrating information from different types of databases. Furthermore, existing question-and-answer systems lack flexibility in handling diverse user question scenarios and cannot achieve intelligent analysis, resulting in low system efficiency and an inability to meet the ever-growing needs of users. Summary of the Invention
[0006] To address the shortcomings of existing technologies and to meet the diverse question-and-answer scenarios required by users, this invention provides a knowledge question-and-answer method based on multiple agents and heterogeneous data sources. This method can effectively link and integrate information between different types of databases, support personalized questions from users, and provide efficient and accurate knowledge question-and-answer services.
[0007] A knowledge question answering method based on multi-agent and heterogeneous data sources includes the following steps: (1) Collect original documents, identify entities in the documents and process their formats to build a heterogeneous data layer, which includes a vector database and a graph database; (2) Obtain the standard question-answering dataset and use a portion of the knowledge graph to generate extended questions to build a basic question pool for caching high-frequency question-answer pairs; (3) Obtain user questions and perform preliminary retrieval of them in the basic question pool; for user questions that require in-depth retrieval, use a pre-trained classification model to determine the type of user question, and then use the routing agent to flexibly call the required tools and assign the task to different retrieval agents for retrieval. (4) Use the search results obtained by the answering agent to generate the final answer.
[0008] Furthermore, the specific implementation process of step (1) is as follows: S21: Define the document types and scope, and develop a collection plan; S22: Acquire paper documents and online electronic documents; for paper documents, use OCR (Optical Character Recognition) technology to convert the text in the scanned images into editable text, and perform necessary manual corrections; S23: Remove noise information from the text, including headers, footers, and page numbers; perform text encoding conversion; and standardize punctuation and font formats. S24: Divide the processed text into multiple text blocks of appropriate length according to punctuation marks using natural language processing tools, ensuring that the semantics of each text block are independent and complete; S25: Identify the key entity types in the relevant field based on research needs, and define the types of relationships related to these entities; S26: Formulate grammatical rules, identify entities in the text based on features including keywords and syntactic structure, and determine the relationship type between entities based on features including context information and keywords; S27: For cases where rule-based methods cannot identify entities, use a trained named entity recognition model to automatically identify key entities in the text; S28: Manually review and correct the results obtained in steps S26 to S27 to ensure the accuracy of entity recognition and relationship extraction; S29: Based on entity type and relation type, define the labels and related attributes of nodes and edges in the graph database, import the converted text data into the graph database, and complete the construction of the graph database; S210: Use a text vectorization model to map the segmented text blocks to a vector space, select a suitable vector database to store the generated text vectors according to the data scale and characteristics, and complete the construction of the vector database.
[0009] Furthermore, the specific implementation process of step (2) is as follows: S31: Obtain publicly available question-and-answer datasets or relevant question-and-answer datasets authorized for use by research institutions; S32: Identify and remove semantically duplicated question-answer pairs in the dataset to avoid data redundancy; S33: Use graph mining algorithms to automatically extract valuable subgraphs from knowledge graphs, and manually review and screen the extraction results; S34: Convert the subgraph into a natural language description, input the demonstration sample and the subgraph description into the question generation model, and obtain a series of extended questions and answers related to the subgraph; S35: Evaluate the reasonableness of the generated extended questions by manual means or by designing basic rules, and filter out questions with confused logic and unclear semantics; S36: Using a text vectorization model, convert the question text from the dataset and the question text obtained by knowledge graph expansion into vector representations respectively. Store the vectorized questions in the basic question pool, and associate each question with the corresponding answer and other meta-information to complete the initial construction of the basic question pool. S37: Regularly maintain the basic question pool, promptly add high-frequency question and answer data to the basic question pool, and update the corresponding vector information; when the number of stored questions reaches the set threshold, use a reasonable elimination strategy to delete some question and answer data.
[0010] Furthermore, in step (3), the user's question is initially retrieved from the basic question pool. The specific implementation process is as follows: S41: Obtain the input user question, record information including the question time and user ID, and set a reasonable range for the question length; S42: Load the text vectorization model and the pre-built pool of basic questions; S43: Use a text vectorization model to convert user questions into vectorized representations; S44: Calculate the similarity between the user's question vector and each question vector in the base question pool; S45: Set a similarity threshold. If the similarity exceeds the threshold, it is determined that the user's question has a matching question-answer pair in the basic question pool, and the answer corresponding to the question is directly obtained from the basic question pool. If the similarity does not exceed the threshold, it is determined that the user's question has no cached answer and needs to be passed to the routing agent for in-depth retrieval.
[0011] Furthermore, in step (3), the type of user question is determined using a pre-trained classification model. The specific implementation process is as follows: S51: Obtain multiple publicly available single-hop and multi-hop question-answering datasets, determine the question type labels, and after data augmentation, divide the datasets into training and testing sets; The question type tags are divided into three categories: the first category is "simple" questions that can be directly retrieved, corresponding to single-hop questions; the second category is "complex" questions that require additional question decomposition, corresponding to multi-hop questions; the third category is "ambiguous" questions that take into account the unclear user query intent. These questions need to be obtained and labeled by data augmentation, i.e., randomly selecting some questions, shuffling the question sentence structure or randomly deleting some key entities from the questions. S52: Pre-train the selected classifier model using the training set; S53: Convert the user question text into a feature vector and input it into the trained classifier model to identify the type of user question output; S54: If the user's question type is "ambiguous", the question needs to be rewritten. If necessary, user feedback should be introduced, and step S53 should be repeated until the user's question is clear.
[0012] Furthermore, in step (3), the routing agent calls the necessary tools and assigns the task to different retrieval agents for retrieval. The specific implementation process is as follows: S61: Based on the characteristics of different databases, construct corresponding retrieval agents, describe in detail the roles of the retrieval agents and the required tools, and ensure that the routing agents understand the tasks and the applicable scenarios of each tool; S62: Initialize the retrieval agent, including establishing a connection with the corresponding database and loading the necessary configuration files to ensure that the retrieval agent can operate normally; S63: Obtain the user's question content and classification results. If it is a "complex" question, the routing agent needs to call the question decomposition tool to break it down into multiple sub-questions. S64: Perform basic text processing on user questions or their sub-questions to extract key information and core content of the questions; S65: The routing agent evaluates the matching degree between the current question and the tasks applicable to each retrieval agent, selects the most suitable retrieval agent to answer the current question, and transmits the specific question and key information; S66: The selected retrieval agent preprocesses the problem based on key information about the problem and the database used: if a vector database is used, the problem is mapped to a vector space; if a graph database is used, a graph query statement is generated based on the problem. S67: The retrieval agent performs a query operation. If the execution is correct, the result is transmitted back to the routing agent, which waits for the next instruction from the routing agent. If the execution fails, the retrieval agent corrects the error internally or sends the error back to the routing agent for processing, depending on the specific error type.
[0013] Furthermore, the specific implementation process of step (4) is as follows: S71: Retrieve search results and related cached answers; S72: Convert search results in different formats into a unified internal representation and check whether the results cover all the key points of the question; if the information is incomplete, it is necessary to request supplementary information from the search agent again; S73: Reassess the relevance of each search result to the question based on the question content, and filter out results with low relevance; S74: Integrate all the search results and sort and organize the results information according to a certain logical order (such as time order, causal relationship, etc.) to facilitate the generation of subsequent answers; S75: The answering agent generates a preliminary answer using the question content and search results, and checks whether the information in the answer is consistent with each other and whether it answers all aspects of the question; S76: Optimize the language style of the generated answers according to user needs, improve the readability and fluency of the answers, and convert the generated answers into a format suitable for users to view; S77: Add supplementary information to the answer, including references, relevant links, and charts, to help users further understand the relevant content; S78: Finally, return the final answer to the original question to the user.
[0014] A computer device includes a memory and a processor, wherein the memory stores a computer program and the processor executes the computer program to implement the above-described knowledge question answering method based on multiple agents and heterogeneous data sources.
[0015] A computer-readable storage medium storing a computer program, which, when executed by a processor, implements the above-described knowledge question-answering method based on multiple agents and heterogeneous data sources.
[0016] This invention designs a heterogeneous data layer, including a vector database storing the semantic information of the original text and a graph database storing the complex relationships between entities. This design fully leverages the advantages of different types of databases to meet diverse user retrieval needs. Simultaneously, this invention designs and constructs a basic question pool, significantly improving retrieval efficiency by pre-building and caching high-frequency question-answer pairs, avoiding the waste of computational resources caused by numerous repeated searches. Furthermore, this invention utilizes multi-agent collaboration technology, dynamically combining different agents to provide services based on the characteristics of different questions, thus improving upon the lack of intelligent analysis and reasoning capabilities in existing question-answering systems. Attached Figure Description
[0017] Figure 1 This is a schematic diagram of the knowledge question answering method based on multiple agents and heterogeneous data sources of the present invention. Detailed Implementation
[0018] To describe the present invention in more detail, the technical solution of the present invention will be described in detail below with reference to the accompanying drawings and specific embodiments.
[0019] This implementation provides a knowledge question answering method based on multiple agents and heterogeneous data sources, the specific implementation process of which is as follows: Figure 1 As shown: Step S11: Collect the original documents, identify the data and process its format, and construct the vector database and graph database respectively.
[0020] This embodiment constructs a heterogeneous data layer based on existing data, specifically including a vector database and a graph database. For different types of query needs, the heterogeneous data layer can allocate query requests to the most suitable database. For example, when handling queries with high real-time requirements in the text domain, the vector database can quickly locate and return results using its efficient vector similarity calculation method. Meanwhile, the graph database, when handling queries involving complex relationships, can accurately complete the query task through graph traversal and search algorithms. Therefore, the heterogeneous data layer can handle more complex user query scenarios and improve the overall query efficiency of the system. This step divides the original document into multiple semantically complete and independent text blocks and extracts key entities and relationship information from them, respectively completing the construction of the vector database and graph database, and encapsulating them into a heterogeneous data layer. The specific implementation steps are as follows: S21: Define the document types and scope, and develop a collection plan.
[0021] S22: Obtain paper documents or online electronic documents; for paper documents, use OCR technology to convert the text in the scanned image into editable text, and perform necessary manual corrections on the recognition results.
[0022] Specifically, the necessary paper documents can be obtained from libraries, archives, and cooperating research institutions. Professional scanning equipment can be used to convert the paper documents into image files, ensuring that the scanning resolution meets the requirements of subsequent text recognition. Then, OCR technology can be used to convert the text in the scanned image into editable text. At the same time, electronic documents can be collected from online resources such as digital libraries and publicly available datasets. The collected texts are manually reviewed, and obvious content or formatting errors are corrected.
[0023] S23: Remove noise information such as headers, footers, and page numbers from the document, perform text encoding conversion, and standardize punctuation marks, fonts, and other formats.
[0024] S24: Divide the processed long text into multiple text blocks of appropriate length according to punctuation marks and using natural language processing tools to ensure that the semantics of each text block are independent and complete.
[0025] Specifically, the long text is first divided into multiple paragraphs using common punctuation marks (such as periods, question marks, and line breaks) and a set length. Each paragraph usually has relatively independent semantics. Natural language processing tools, such as SpaCy and Sentence-Transformers, are used to detect semantic boundaries in the paragraphs. These tools can identify semantic breakpoints by analyzing the text's grammatical structure, word vectors, and other information, thus enabling further subdivision of the paragraphs.
[0026] S25: Based on research needs, identify key entity types and define the types of relationships related to those entities.
[0027] Specifically, depending on the different fields of research, the entities and relationships that the system focuses on are determined. Taking the medical field as an example, the main entities include medical institutions, drug products, and disease types, as well as relationships such as which drugs are used for different diseases and which diseases different medical institutions focus on.
[0028] S26: Formulate grammatical rules to identify entities based on features such as keywords and syntactic structures in the text; at the same time, determine the relationship type based on contextual information and keywords between entities.
[0029] Specifically, by observing the sentence structure features in the text, we can design regular expressions for matching and extract key information. Taking the medical field as an example, in the sentence structure "[drug name], also known as [drug alias], is often used in clinical trials to treat [disease]", we can identify entities such as drug name and disease, and also extract the treatment relationship between the two entities.
[0030] S27: For cases where some rule-based methods cannot identify entities, use well-trained named entity recognition models, such as deep learning-based models like BiLSTM-CRF (Bidirectional Long Short-Term Memory Network-Conditional Random Field) and BERT-CRF (BERT-based Bidirectional Encoder Representation-Conditional Random Field), to automatically identify key entities in the text.
[0031] Specifically, after constructing the text dataset, a certain proportion of the data is selected as the training set. Key entities need to be manually labeled using the BIO (Start-Inner-Outer Labeling) format. The training data is then input into the selected deep learning model for training, and the model training results are saved. For unlabeled data, the trained model is loaded, and this model is used to automatically identify the key entities contained in the text.
[0032] S28: Manually review and correct the results described in steps S26 to S27 to ensure the accuracy of entity recognition and relationship extraction.
[0033] S29: Based on entity and relation types, define the labels and related attributes of nodes and edges in the graph database, import the converted data into the graph database, and complete the construction of the graph database.
[0034] S210: Determine the text vectorization model and map the segmented text blocks to the vector space; select a suitable vector database to store the generated text vectors according to the data scale and characteristics, and complete the construction of the vector database.
[0035] Step S12: Obtain the standard question-answering dataset and use partial subgraphs of the knowledge graph to generate expanded questions, thus completing the construction of the basic question pool.
[0036] In real-world question-answering scenarios, there may be some frequently occurring questions. If a large number of repeated questions are asked in a short period of time, the system will need to re-analyze and reason, leading to a waste of computing resources. In this embodiment, standard question-answer pairs for reference are introduced, and extended questions are generated for some subgraphs of the knowledge graph. A basic question pool for caching high-frequency question-answer pairs is initially constructed. The specific implementation steps are as follows: S31: Obtain publicly available question-and-answer datasets or relevant question-and-answer datasets authorized for use by research institutions.
[0037] S32: Identify and remove semantically duplicated question-answer pairs in the dataset to avoid data redundancy.
[0038] S33: Use graph mining algorithms to automatically extract valuable subgraphs from the generated knowledge graph, and manually review and screen the extraction results.
[0039] Specifically, common path search algorithms can be used to start from a given entity node and search along the edges using breadth-first or depth-first search to find all possible paths and obtain the relevant subgraph. More complex frequent subgraph mining algorithms and community detection algorithms can also be introduced to obtain subgraph information. Subgraphs with obvious errors are initially filtered out, and then the information of the subgraphs is further reviewed manually to ensure that the information is completely accurate and the relationships are reasonable. Finally, based on research experience, subgraphs with novelty and research value are retained.
[0040] S34: Convert the subgraph into a natural language description, select an appropriate question generation model, input the demonstration sample and the subgraph description into the question generation model, and obtain a series of extended questions and answers related to the subgraph.
[0041] Specifically, a series of natural language description templates are predefined. Entity and relation information is extracted from the subgraph and filled in according to the template requirements to generate the natural language description corresponding to the subgraph. A suitable large language model is selected as the question generation model. At the same time, to avoid fine-tuning, context learning is introduced, that is, some demonstration samples are provided for the model to learn from, specifically question-answer pair information generated from certain descriptive texts. The demonstration samples and the natural language descriptions generated from the subgraph are used as relevant context inputs into the model to guide the model to complete the task of generating expanded question-answer pairs.
[0042] S35: The basic rules of manual or design are used to evaluate the reasonableness of the generated questions and filter out questions with confused logic and unclear semantics.
[0043] S36: Using the same text vectorization model as in step S210, convert the text questions obtained in steps S32 and S34 into vector representations respectively, store the vectorized questions in the basic question pool, and associate the answers and other meta-information corresponding to each question to complete the initial construction of the basic question pool.
[0044] S37: The background maintains the basic question pool regularly, adds high-frequency question and answer data to the basic question pool in a timely manner, and updates the corresponding vector information; when the number of stored questions reaches the set threshold, a reasonable elimination strategy is adopted to delete some question and answer data.
[0045] Specifically, the system needs to record user question-and-answer interaction logs, including questions, answers, and timestamps. These logs can be stored in a database table. The backend periodically performs statistical analysis on the log data, calculating the frequency of similar question-and-answer pairs. Based on a set frequency threshold, high-frequency question-and-answer data is filtered out. For each high-frequency question-and-answer data entry, it first checks if a similar question already exists in the basic question pool; if not, it adds the question. When adding a new question-and-answer pair, the new question is vectorized using the text vectorization model selected when building the basic question pool, and then the question vector representation and the corresponding answer are stored in the basic question pool. When the number of questions in the basic question pool reaches a set threshold, an elimination strategy is triggered, which can delete a certain number of question-and-answer pairs based on time or access frequency.
[0046] Step S13: Obtain user questions and perform a preliminary search in the basic question pool; for questions that require in-depth search, the routing agent flexibly calls the necessary tools or assigns the task to different search agents according to the question type and characteristics.
[0047] The specific steps for performing a preliminary search in the basic question pool are as follows: S41: Obtain user input questions, record information such as the question time and user ID, and set a reasonable range for question length.
[0048] S42: Load the text vectorization model and the pre-built pool of basic questions.
[0049] S43: Use the model to transform the problem into a vectorized representation.
[0050] S44: Calculate the semantic similarity between the problem vector and each problem vector in the base problem pool; specifically, calculate the cosine similarity between the vectors and sort them from high to low similarity values.
[0051] S45: Set a similarity threshold to determine if there are cached answers to the current question in the basic question pool.
[0052] Specifically, a similarity threshold between vectors is preset; when the similarity of a pair of vectors exceeds the threshold, it is determined that the current question has a matching question-answer pair in the basic question pool, and the answer corresponding to the question is directly obtained from the basic question pool; if all calculated similarities are below the threshold, it is determined that the current question has no cached answer and needs to be passed to the routing agent for in-depth retrieval.
[0053] The specific steps for the routing agent to determine the type of user problem are as follows: S51: Obtain multiple publicly available single-hop and multi-hop question-answering datasets, determine question type labels, and perform data augmentation and partitioning of the datasets to construct training and validation test sets for the question classifier.
[0054] Specifically, the question types are mainly divided into three categories: the first category is "simple" questions that can be directly retrieved; the second category is "complex" questions that require additional question decomposition; and the third category is "ambiguous" questions that take into account the unclear user query intent. The proportions of training, testing, and validation sets are reasonably divided, and multiple datasets are randomly selected. When constructing the classifier training dataset, single-hop questions are labeled as "simple" questions, and multi-hop questions are labeled as "complex" questions. At the same time, data augmentation operations are performed, and some questions are randomly selected, the question sentence structure is shuffled, or some key entities in the questions are randomly deleted, and labeled as "ambiguous" questions.
[0055] S52: Use the labeled training set to pre-train the selected classifier model; specifically, select a suitable deep learning model as the classifier, convert the labeled training set into an input format that the model can accept, train it, and save the training results.
[0056] S53: Convert the user question text into a feature vector that the model can process, and input it into the trained question classifier to obtain the category of the user question.
[0057] S54: If the problem category is ambiguous, the problem needs to be rewritten, and user feedback should be introduced if necessary; repeat step S53 until the classification result is clear.
[0058] Specifically, the system checks whether user input contains illegal characters or garbled text. If so, it cleans up the input or prompts the user to re-enter the information. It also combines information such as the user's historical question records and interaction context, and formulates language optimization rules, such as converting colloquial expressions into written expressions and adjusting sentence structure, to rewrite the original question in order to clarify the user's questioning intent.
[0059] The routing agent can flexibly call upon the necessary tools or assign tasks to different retrieval agents. The specific implementation steps are as follows: S61: Based on the characteristics of different databases, construct corresponding retrieval agents. The roles of the agents and the available tools need to be described in detail to ensure that the agents understand the tasks and the applicable scenarios of each tool.
[0060] Specifically, for different types of databases, intelligent agents with different roles are built for management. For example, an intelligent agent proficient in vector database retrieval can identify key information points in user questions and perform efficient searches based on vector semantic similarity. Meanwhile, an intelligent agent responsible for graph database retrieval can understand users' query needs regarding graph data relationships and has the ability to connect to graph databases, generate corresponding graph query languages, and visualize graphs.
[0061] S62: Initialize each retrieval agent, including establishing connections with the corresponding databases and loading necessary configuration files, to ensure that the retrieval agents can operate normally.
[0062] S63: Obtain the user's question content and classification results. If it is a complex question, the routing agent needs to call the question decomposition tool to break it down into multiple sub-questions.
[0063] S64: Perform basic text processing on the current problem to extract key information and core content.
[0064] S65: The routing agent evaluates the matching degree between the question and the task applicable to each retrieval agent, selects the retrieval agent that is most suitable to answer the current question, and transmits the question and key information.
[0065] Specifically, the routing agent pre-records the applicable task scope and capability characteristics of each retrieval agent; based on the core content of the current problem, the routing agent needs to analyze and deduce the most suitable retrieval agent to handle the problem; the routing agent encapsulates the current problem and the extracted key information into a data packet containing information such as problem description and key entities, and transmits the encapsulated data packet to the selected retrieval agent through a defined interface or communication protocol.
[0066] S66: The target retrieval agent takes the next action based on the key information of the question and the corresponding query operation of the database used; if a vector database is used, the user question is mapped to a vector space; if a graph database is used, a graph query statement is generated.
[0067] S67: The retrieval agent performs a query operation; if the execution is correct, the result is passed back to the routing agent, waiting for the next action of the routing agent; if the execution fails, the retrieval agent corrects the error internally or sends it back to the routing agent for processing, depending on the specific error type.
[0068] Step S14: The agent integrates the search results and generates the final answer. The specific implementation steps are as follows: S71: Retrieve all relevant cached answers and search results.
[0069] S72: Convert results in different formats into a unified internal representation and check whether the results cover all the key points of the problem; if the information is incomplete, request supplementary information from the retrieval module again.
[0070] Specifically, during the system's problem analysis process, cached text answers or search results from different types of data sources may be involved. It is necessary to convert results in different formats according to a defined unified internal representation. For example, all results can be converted to JSON (JavaScript Object Notation) format and organized according to a unified field structure. The original problem should be reviewed to clarify its core points. For example, for the question "What are the possible causes of headaches, and what medications can be used to treat them?", the key points include "headache," "causes," and "medications." The unified representation results should be compared with the key points of the original problem to check if all key points are covered. If any missing key points are found in the results, they should be treated as new search requests and a new request should be sent to the search module to supplement the relevant information.
[0071] S73: Based on the question content, use a reordering tool to re-evaluate the relevance of each search result to the question and filter out results with low relevance.
[0072] Specifically, deep learning models are used to perform more complex semantic analysis, capturing the deep semantic relationships between each search result and the question. The question and the initial search results are input into the reorderer, which re-evaluates the relevance of each search result to the question based on its internal algorithm and model, and gives a new score. The search results are reordered based on the new scores, and then a relevance threshold is set to filter out results with scores below the threshold, retaining the results with higher relevance as the final output of the search module.
[0073] S74: Integrate all search results after processing; sort and organize the information according to a certain logical order (such as time order, causal relationship, etc.) to facilitate subsequent answer generation.
[0074] S75: The responding agent generates a preliminary answer using the question content and search results, and checks whether the information in the answer is consistent with each other and whether it answers all aspects of the question.
[0075] Specifically, in addition to generating answers, the answering agent can also invoke checking tools to determine whether the current answer meets the requirements; it inputs the question and relevant search results as context into a selected large language model, and the generated coherent text serves as the initial answer; the agent needs to check whether the information in the answer is logically contradictory, whether it conforms to known facts, and whether the answer covers all the key points of the question; if the answer contains errors or is incomplete, it determines whether the problem occurred during the information integration stage or during the answer generation process based on the checking results; if the answer contains logical contradictions, it may be because contradictory information was pieced together during information integration; and if the answer is incomplete, it may be because the search results were not fully utilized during answer generation.
[0076] S76: Based on user needs, the generated answers can be optimized in terms of language style to improve readability and fluency, and the generated answers can be converted into a format suitable for user viewing.
[0077] S77: Add supplementary information to the answer, such as references and related links, to help users further understand the relevant content.
[0078] S78: Return the final answer to the original question to the user.
[0079] The above description of the embodiments is provided to enable those skilled in the art to understand and apply the present invention. Those skilled in the art can readily make various modifications to the above embodiments and apply the general principles described herein to other embodiments without creative effort. Therefore, the present invention is not limited to the above embodiments, and any improvements and modifications made to the present invention by those skilled in the art based on the disclosure thereof should be within the scope of protection of the present invention.
Claims
1. A knowledge question answering method based on multi-agent and heterogeneous data sources, characterized in that, Includes the following steps: (1) Collect original documents, identify entities in the documents and process their formats to build a heterogeneous data layer, which includes a vector database and a graph database; (2) Obtain the standard question-answering dataset and use a portion of the knowledge graph to generate extended questions to build a basic question pool for caching high-frequency question-answer pairs; (3) Obtain user questions and perform preliminary retrieval of them in the basic question pool; for user questions that require in-depth retrieval, use a pre-trained classification model to determine the type of user question, and then use the routing agent to flexibly call the required tools and assign the task to different retrieval agents for retrieval. (4) Use the search results obtained by the answering agent to generate the final answer.
2. The knowledge question answering method based on multi-agent and heterogeneous data sources according to claim 1, characterized in that, The specific implementation process of step (1) is as follows: S21: Define the document types and scope, and develop a collection plan; S22: Acquire paper documents and online electronic documents; for paper documents, use OCR technology to convert the text in the scanned images into editable text and perform necessary manual corrections; S23: Remove noise information from the text, including headers, footers, and page numbers; perform text encoding conversion; and standardize punctuation and font formats. S24: Divide the processed text into multiple text blocks of appropriate length according to punctuation marks using natural language processing tools, ensuring that the semantics of each text block are independent and complete; S25: Identify the key entity types in the relevant field based on research needs, and define the types of relationships related to these entities; S26: Formulate grammatical rules, identify entities in the text based on features including keywords and syntactic structure, and determine the relationship type between entities based on features including context information and keywords; S27: For cases where rule-based methods cannot identify entities, use a trained named entity recognition model to automatically identify key entities in the text; S28: Manually review and correct the results obtained in steps S26 to S27 to ensure the accuracy of entity recognition and relationship extraction; S29: Based on entity type and relation type, define the labels and related attributes of nodes and edges in the graph database, import the converted text data into the graph database, and complete the construction of the graph database; S210: Use a text vectorization model to map the segmented text blocks to a vector space, select a suitable vector database to store the generated text vectors according to the data scale and characteristics, and complete the construction of the vector database.
3. The knowledge question answering method based on multi-agent and heterogeneous data sources according to claim 1, characterized in that, The specific implementation process of step (2) is as follows: S31: Obtain publicly available question-and-answer datasets or relevant question-and-answer datasets authorized for use by research institutions; S32: Identify and remove semantically duplicated question-answer pairs in the dataset to avoid data redundancy; S33: Use graph mining algorithms to automatically extract valuable subgraphs from knowledge graphs, and then manually review and screen the extraction results; S34: Convert the subgraph into a natural language description, input the demonstration sample and the subgraph description into the question generation model, and obtain a series of extended questions and answers related to the subgraph; S35: Evaluate the reasonableness of the generated extended questions by manual means or by designing basic rules, and filter out questions with confused logic and unclear semantics; S36: Using a text vectorization model, convert the question text from the dataset and the question text obtained by knowledge graph expansion into vector representations respectively. Store the vectorized questions in the basic question pool, and associate each question with the corresponding answer and other meta-information to complete the initial construction of the basic question pool. S37: Regularly maintain the basic question pool, promptly add high-frequency question and answer data to the basic question pool, and update the corresponding vector information; when the number of stored questions reaches the set threshold, use a reasonable elimination strategy to delete some question and answer data.
4. The knowledge question answering method based on multi-agent and heterogeneous data sources according to claim 1, characterized in that, In step (3), the user's question is initially retrieved from the basic question pool. The specific implementation process is as follows: S41: Obtain the input user question, record information including the question time and user ID, and set a reasonable range for the question length; S42: Load the text vectorization model and the pre-built pool of basic questions; S43: Use a text vectorization model to convert user questions into vectorized representations; S44: Calculate the similarity between the user's question vector and each question vector in the base question pool; S45: Set a similarity threshold. If the similarity exceeds the threshold, it is determined that the user's question has a matching question-answer pair in the basic question pool, and the answer corresponding to the question is directly obtained from the basic question pool. If the similarity does not exceed the threshold, it is determined that the user's question has no cached answer and needs to be passed to the routing agent for in-depth retrieval.
5. The knowledge question answering method based on multi-agent and heterogeneous data sources according to claim 1, characterized in that, In step (3), the type of user question is determined using a pre-trained classification model. The specific implementation process is as follows: S51: Obtain multiple publicly available single-hop and multi-hop question-answering datasets, determine the question type labels, and after data augmentation, divide the datasets into training and testing sets; The question type tags are divided into three categories: the first category is "simple" questions that can be directly retrieved, corresponding to single-hop questions; the second category is "complex" questions that require additional question decomposition, corresponding to multi-hop questions; the third category is "ambiguous" questions that take into account the unclear user query intent. These questions need to be obtained and labeled by data augmentation, i.e., randomly selecting some questions, shuffling the question sentence structure or randomly deleting some key entities from the questions. S52: Pre-train the selected classifier model using the training set; S53: Convert the user question text into a feature vector and input it into the trained classifier model to identify the type of user question output; S54: If the user's question type is "ambiguous", the question needs to be rewritten. If necessary, user feedback should be introduced, and step S53 should be repeated until the user's question is clear.
6. The knowledge question answering method based on multi-agent and heterogeneous data sources according to claim 1, characterized in that, In step (3), the routing agent calls the necessary tools and assigns the task to different retrieval agents for retrieval. The specific implementation process is as follows: S61: Based on the characteristics of different databases, construct corresponding retrieval agents, describe in detail the roles of the retrieval agents and the required tools, and ensure that the routing agents understand the tasks and the applicable scenarios of each tool; S62: Initialize the retrieval agent, including establishing a connection with the corresponding database and loading the necessary configuration files to ensure that the retrieval agent can operate normally; S63: Obtain the user's question content and classification results. If it is a "complex" question, the routing agent needs to call the question decomposition tool to break it down into multiple sub-questions. S64: Perform basic text processing on user questions or their sub-questions to extract key information and core content of the questions; S65: The routing agent evaluates the matching degree between the current question and the tasks applicable to each retrieval agent, selects the most suitable retrieval agent to answer the current question, and transmits the specific question and key information; S66: The selected retrieval agent preprocesses the problem based on key information about the problem and the database used: if a vector database is used, the problem is mapped to a vector space. If a graph database is used, a graph query statement is generated based on the question; S67: The retrieval agent performs a query operation. If the operation is successful, the result is passed back to the routing agent, which then waits for the next instruction from the routing agent. If an error occurs, the retrieval agent corrects the error internally or sends the error back to the routing agent for processing, depending on the specific error type.
7. The knowledge question answering method based on multi-agent and heterogeneous data sources according to claim 1, characterized in that, The specific implementation process of step (4) is as follows: S71: Retrieve search results and related cached answers; S72: Convert search results in different formats into a unified internal representation and check whether the results cover all the key points of the question; if the information is incomplete, it is necessary to request supplementary information from the search agent again; S73: Reassess the relevance of each search result to the question based on the question content, and filter out results with low relevance; S74: Integrate all the search results and sort and organize the results information according to a certain logical order to facilitate subsequent answer generation; S75: The answering agent generates a preliminary answer using the question content and search results, and checks whether the information in the answer is consistent with each other and whether it answers all aspects of the question; S76: Optimize the language style of the generated answers according to user needs, improve the readability and fluency of the answers, and convert the generated answers into a format suitable for users to view; S77: Add supplementary information to the answer, including references, relevant links, and charts, to help users further understand the relevant content; S78: Finally, return the final answer to the original question to the user.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that: The processor is used to execute the computer program to implement the knowledge question answering method based on multiple agents and heterogeneous data sources as described in any one of claims 1 to 7.
9. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by the processor, it implements the knowledge question answering method based on multiple agents and heterogeneous data sources as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Clinical test questionnaire generation method and device, equipment and storage medium
CN119007900A
Large-model multi-agent collaborative machine manufacturing knowledge question-answering method
CN119227817A
Question and answer method and system fusing multi-granularity knowledge graph and self-adaptive agent
CN119961418A
Intelligent question and answer method and system, electronic equipment and intelligent question and answer big model
CN119988573A
Multi-intelligent-agent physical examination enhancement generation method and device, equipment and storage medium
CN120256588A
Cited By
Medical insurance knowledge base automatic construction method based on multi-agent collaboration
CN121434369A
Task execution method and device based on model scheduling and storage medium
CN121579178A
Medical subject knowledge service-oriented data processing method and electronic equipment
CN121615743A
