A multi-agent retrieval enhancement generation method and system based on diverse data sources
By employing a multi-agent architecture and adaptability matching technology, this technology addresses the issues of low efficiency, poor accuracy, and insufficient privacy protection in processing diverse data sources. It enables efficient and accurate multi-data source querying and generation, making it suitable for complex multi-source data environments.
Patent Information
- Application Number
- CN202510822367.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-19
- Publication Date
- 2025-12-12
- Estimated Expiration
- 2045-06-19
AI Technical Summary
Existing retrieval enhancement generation techniques suffer from problems such as slow query speed, high lexical overhead, high error rate, inaccurate query results, insufficient data privacy protection, and poor model applicability when dealing with diverse data sources. They are particularly difficult to effectively extend and integrate under a single agent architecture.
A multi-agent architecture is adopted, which constructs relational, graph, document, and text agents. The most suitable professional query agent is matched by the fitness formula. The optimal query information is generated by combining the database pattern and a few sample examples and executed in the query execution environment. Finally, the generated agent synthesizes the response.
It enables efficient and accurate multi-data source queries, reduces lexical overhead, improves query speed and accuracy, ensures data privacy protection, and supports seamless integration and scalability in multilingual data environments.
Smart Images

Figure CN120632171B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of intelligent retrieval generation, and in particular to a multi-agent retrieval augmented generation method and system based on multiple data sources. BACKGROUND
[0002] Existing retrieval augmented generation (RAG) technology mainly relies on a single-agent architecture, which expands the capabilities of large language models by incorporating external or private data into the answer generation process. When dealing with private or proprietary data that cannot be accessed during large language model training, RAG systems retrieve relevant domain-specific data from external sources to provide accurate outputs. In the design and implementation of RAG systems, the selection of large language models is crucial. There are generally two types of models: local models and API-based models. Each type has its unique advantages and challenges, and the selection depends on factors such as data sensitivity, computing resources, and scalability requirements.
[0003] The single-agent architecture has several drawbacks. First, when dealing with multiple types of data, the single agent needs to have comprehensive patterns, examples, and extensive knowledge of diverse data structures. This results in slow query generation, high token overhead, and high error rates, leading to low efficiency. Second, the single agent is prone to misinterpretation when processing heterogeneous data, which can result in inaccurate or suboptimal query results, hindering the scalability and performance of the system in diverse data environments. Third, the selection of large language models also presents challenges. Local models can ensure data privacy but require significant computing resources, resulting in high deployment costs and complexity. API-based models are easy to integrate and have strong scalability, but they pose a risk to data privacy. Both types of models have limitations in terms of the amount of data that can be processed per query, necessitating efficient data partitioning and retrieval techniques. In summary, existing technologies have significant shortcomings in terms of multi-data source processing efficiency, query accuracy, data privacy protection, and model applicability, which need to be addressed.
[0004] To address these issues, the present application employs a multi-agent architecture, which delegates information processing tasks to specialized agents. Each agent is tailored to handle specific types of databases, generating accurate and efficient queries while reducing workload and complexity. The addition of new agents allows for seamless scalability, effectively addressing the shortcomings of existing technologies in terms of multi-data source processing efficiency, query accuracy, and data privacy protection. SUMMARY
[0005] To address the shortcomings of existing technologies, the present application provides a multi-agent retrieval augmented generation method and system based on multiple data sources.
[0006] In order to achieve the above object, in a first aspect, the application provides a multi-agent retrieval enhancement generation method based on multiple data sources, comprising the following steps: obtaining target query information and constructing prompt information of the target query information; constructing a multi-agent, determining a professional query agent of the target query information based on the prompt information; obtaining optimal query information of the target query information according to the professional query agent and combining the prompt information; obtaining query return results according to the optimal query information, constructing key return information combining the query return results and the target query information; constructing retrieval enhancement generation results of the target query information based on the key return information and generating agents. The application obtains target query information and constructs prompt information, which lays a foundation for subsequent accurate processing; constructs a multi-agent and determines a professional query agent, matches the most suitable agent for different queries, improves the query professionalism, obtains optimal query information according to the professional agent and the prompt information, which is conducive to optimizing the query effect, obtains results according to the optimal query, constructs key return information, accurately extracts core content, constructs retrieval enhancement generation results based on the key return information and the generating agent, generates more accurate, comprehensive and demand-oriented replies, and improves the information retrieval and generation quality.
[0007] Optionally, the method comprises the following steps: obtaining natural language query information, which is used as the target query information; and constructing the prompt information based on the target query information, combining a database mode and a few sample examples. The application obtains natural language query information as target query information, which directly matches the user's daily expression habits and reduces the use threshold; constructs the prompt information based on the target query information, combining a database mode and a few sample examples, which on the one hand ensures the standardization and accuracy of information construction by using the database mode, and on the other hand provides a reference by means of the few sample examples, so that the prompt information is more guiding and the subsequent information processing effect is improved.
[0008] Optionally, the constructing the multi-agent, determining the professional query agent of the target query information based on the prompt information, comprises: taking a relational agent, a graph agent, a document agent and a text agent as the professional query agent, and constructing the multi-agent according to the professional query agent; and in the multi-agent, determining the professional query agent that is most suitable for the target query information according to the various data source types of the prompt information. The multi-agent containing the relational agent, the graph agent, the document agent and the text agent is constructed, a professional and comprehensive agent information processing system is formed, different types and complex degrees of query requirements can be coped with, the professional query agent that is most suitable is determined according to the various data source types of the prompt information, the advantages of each agent are fully played, blind processing is avoided, the query efficiency and the accuracy are greatly improved, the query result is more in line with the actual demand, more high-quality and efficient services are provided for users, and the overall information retrieval and processing capability is improved.
[0009] Optionally, the determining the professional query agent that is most suitable for the target query information according to the various data source types of the prompt information comprises:
[0010]
[0011] wherein, is an adaptation degree value, is an adaptation function, is a various data source type, is a type of the professional query agent. The various data source types and the type of the professional query agent are quantitatively matched by setting the adaptation degree formula, the adaptation degrees of different agents to the query of a specific data source type are objectively and accurately calculated, the deviation of subjective judgment is avoided, the professional query agent that is most suitable can be quickly and accurately determined through the adaptation degree, and the query efficiency and the result accuracy are improved.
[0012] Optionally, the professional query agent is combined with the prompt information to obtain the optimal query information of the target query information, comprising: obtaining the data structure of the target query information according to the various data source types; establishing a data relationship graph of the data structure according to the database mode; performing syntax adaptation on the target query information to obtain a data-specific syntax of the database mode; and based on the professional query agent, combining the data relationship graph and the data-specific syntax to establish the optimal query information. According to the various data source types, the data structure is obtained, the data form can be accurately grasped, the data relationship graph is established according to the database mode, the relationship between the data is clearly presented, the target query information is adapted to the data-specific syntax, the compatibility of the query and the database is ensured, the optimal query information is established based on the professional query agent, the graph and the syntax, the advantages of the agent are fully utilized, the required data is accurately and efficiently obtained, the query quality is improved, and reliable and accurate data support is provided for subsequent information processing.
[0013] Optionally, the professional query agent is combined with the prompt information to obtain the optimal query information of the target query information, comprising:
[0014]
[0015] Wherein, is the optimal query information, is the professional query agent, is the target query information, is the database mode. The present application clearly shows the way of generating the optimal query information by the professional query agent, the target query information and the database mode through mathematical expressions, presents in quantitative form, has clear logic and strong operability, accurately combines various elements, quickly generates the optimal query information meeting the requirements, improves the query efficiency, ensures the accuracy and effectiveness of the query results, and improves the overall retrieval efficiency.
[0016] Optionally, the query return result is obtained according to the optimal query information, the key return information is constructed by combining the query return result and the target query information, and the method comprises the following steps: the optimal return result is obtained according to the optimal query information in combination with an execution environment of the target query information; the execution environment connects the optimal query information and the corresponding database mode; and the optimal return result is combined with a context of the target query information, so that the key return information is constructed. According to the optimal query information, the optimal return result is obtained in combination with the execution environment, the execution environment connects the query and the database mode, the result is accurately matched with the query requirement, the key return information is constructed by combining the optimal return result and the context of the target query information, the query background and the result are comprehensively considered, the core key content is reserved, the accuracy of information acquisition is improved, the integrity and the availability of information are enhanced, and high-quality and targeted key return information is provided for subsequent processing.
[0017] Optionally, the key return information comprises:
[0018]
[0019] wherein, the key return information is, the execution function is, the optimal query information is, the database mode is. The acquisition method of the key return information is determined, the key return information is presented in the form of a mathematical function, the logic is clear and simple, the execution function is combined with the optimal query information and the database mode, the key information can be efficiently and accurately extracted from the database, the information extraction process is standardized, the information acquisition efficiency is improved, and the accuracy and the reliability of the key return information are ensured.
[0020] Optionally, the retrieval enhancement generation result of the target query information is constructed based on the key return information according to a generated agent, and the method comprises the following steps: the key return information is processed according to the generated agent to obtain the retrieval enhancement generation result, and the following relationship is met:
[0021]
[0022] wherein, the retrieval enhancement generation result is, the conversion function is, the target query information is, The key return information is returned. According to the key return information processing of the generated agent, the retrieval enhancement generation result is obtained, the powerful retrieval capability of the agent is fully utilized, the mathematical expression clearly shows the relationship between various elements, the logic is rigorous, the target query information is combined with the key return information through the conversion function, so that the generation result is more in line with the user demand, the accuracy, integrity and pertinence of the information generation are improved, and the user experience is enhanced.
[0023] In a second aspect, the application provides a multi-agent retrieval enhancement generation system based on a plurality of data sources, which executes the multi-agent retrieval enhancement generation method based on a plurality of data sources provided by the application. The system comprises an input device, an output device, a processor and a memory, and the gain is that the hardware facilities integrated by the application have excellent performance, the input device, the output device, the processor and the memory are connected with each other, the information transmission between each component is smooth, and a high-efficiency information processing system is constructed through the interaction of multiple hardware facilities. The system provided by the application can quickly and accurately process a plurality of data sources, realize multi-agent cooperation, improve retrieval enhancement generation efficiency and quality, provide users with better, more efficient and more accurate information services, and meet complex and diverse information needs. BRIEF DESCRIPTION OF DRAWINGS
[0024] Figure 1 A multi-agent retrieval enhancement generation method based on a plurality of data sources is provided for an embodiment of the application.
[0025] Figure 2 A multi-agent retrieval enhancement generation system based on a plurality of data sources is provided for an embodiment of the application.
[0026] Figure 3 An execution flowchart of the multi-agent retrieval enhancement generation system based on a plurality of data sources is provided for an embodiment of the application. DETAILED DESCRIPTION
[0027] The specific embodiments of the application will be described in detail below. It should be noted that the embodiments described herein are only used for illustration and do not limit the application. In the following description, a large number of specific details are set forth in order to provide a thorough understanding of the application. However, it is obvious to those skilled in the art that the specific details are not necessarily used to implement the application. In other examples, in order to avoid obscuring the application, well-known circuits, software or methods are not specifically described.
[0028] Reference throughout this specification to "one embodiment", "an embodiment", "one example", or "an example" means that a particular feature, structure, or characteristic described in connection with the embodiment or example is included in at least one embodiment of the application. The appearances of the phrases "in one embodiment" or "in an embodiment" or "one example" or "an example" in various places in the specification are not necessarily all referring to the same embodiment or example. Furthermore, the particular features, structures, or characteristics can be combined in any suitable
[0029] Referring to Figure 1 One embodiment of the present application provides a multi-agent retrieval enhanced generation method based on multiple data sources, which comprises the following steps:
[0030] S1, obtaining target query information, and constructing prompt information of the target query information.
[0031] In this embodiment, natural language query information is obtained as the target query information; based on the target query information, database schema and few-shot examples are combined to construct prompt information.
[0032] Specifically, the method flow starts from the natural language query information submitted by the user, which is the input of the system and the basis for a series of subsequent information processing operations; the natural language query information is usually expressed in natural language and summarizes the user's demand, which is the starting point of the retrieval and reply generation process. After the natural language query information is submitted, the user's natural language query information is combined with the related database schema and a set of few-shot examples to generate prompt information; the few-shot examples show the expected query format and output, helping the system better understand and process user queries in the context of the target database; the generation of prompt information ensures that the query can be accurately customized according to the structure and requirements of the database.
[0033] S2, constructing a multi-agent, and determining a professional query agent of the target query information based on the prompt information.
[0034] In this embodiment, relational agents, graph agents, document agents and text agents are used as professional query agents, and a multi-agent is constructed according to the professional query agents; in the multi-agent, the most suitable professional query agent for the target query information is determined according to the type of the multiple data sources of the prompt information.
[0035] Specifically, after prompting the preparation is ready, the system will determine the most appropriate query generation agent according to the data source type that the user wants to query, these agents are specially designed for different types of databases (such as relational, document or graph database), the selected agent generates an optimized query that conforms to the database schema and meets the user's needs, Ensuring that the generated query is both syntactically and semantically compatible with the data source.
[0036] The present application introduces specialized multi-agent, which deals with different types of data by decentralized task management; For example, relational agent is responsible for processing relational data source query, graph agent manages graph data, document agent processes document type storage data, and text agent is responsible for text-based data source; These professional agents work together in a centralized query execution environment to ensure seamless compatibility between multiple data types.
[0037] In this embodiment, professional query agents are responsible for generating executable queries customized for specific data sources; These agents run independently and are good at handling specific types of databases; For example, relational agents generate optimized queries for relational databases to ensure that the structure and relationship between tables can be correctly represented; Document agents formulate queries for document-based databases, focusing on nested and hierarchical data; Graph agents are specially designed to generate queries for graph databases to facilitate efficient querying of entity relationships.
[0038] Further, the agent is specialized, each agent is specially designed for a specific type of data or database, this specialized design enables the system to efficiently process queries with high accuracy and performance. For example, relational agents focus on relational data processing and are suitable for handling queries involving complex relational structured databases; Graph agents are good at processing graph data and can efficiently manage the relationships between entities in graph databases; Document agents optimize for document-oriented data and are suitable for handling common flexible and hierarchical data structures; The modular architecture proposed by the present application allows the addition or update of agents without affecting the overall function. As new data types or data sources emerge, the present application can integrate new agents to adapt to these technological changes. This flexibility is the key to ensuring the long-term scalability and adaptability of the system.
[0039] Specifically, according to the diverse data source type of the prompt information, determine the professional query agent that the target query information is most suitable for, meet the following relationship:
[0040]
[0041] Among them, is the adaptation value, is the adaptation function, is the diverse data source type, To query the type of the professional agent.
[0042] The above manner can ensure that each agent can accurately adapt to the specific needs of processing data, so that the system can provide accurate and optimized query results in various data environments.
[0043] In an optional embodiment, the adaptation function is used to quantify the matching degree of the diverse data source types and the professional query agent in the multi-agent, and returns an adaptation value for selecting the most suitable professional query agent.
[0044] Specifically, first, the diverse data source types and the professional query agent are coded into feature vectors; second, the type matching degree and the ability matching degree of the diverse data source types and the professional query agent are constructed according to the feature vectors; and finally, the adaptation function is constructed based on the type matching degree and the ability matching degree combined with the weight coefficient and the adaptation parameter.
[0045] Further, if the type of the professional query agent is consistent with the diverse data source types (such as a relational agent processing relational data), the type matching degree is 1, otherwise it is 0; the ability matching degree is determined according to the efficiency or optimization degree of the professional query agent in processing a specific data structure, and the value range is [0, 1].
[0046] The adaptation function satisfies the following relationship:
[0047]
[0048] wherein, is the adaptation function, is a traversal count flag, is a total amount of traversal, is an adaptation parameter, is a weight coefficient, is a type matching degree, is an ability matching degree, is a feature vector of the diverse data source types, is a feature vector of the professional query agent.
[0049] In addition, by adding new feature vectors or adjusting the weight, the adaptation function can be extended to support new data source types and agent types, and at the same time, the weight is dynamically adjusted according to the system load or query complexity to improve flexibility.
[0050] In an optional embodiment, the target query information is "in the logistics system, among all the transportation routes between two places, the route with a cost lower than 5000 yuan and a time efficiency less than 24 hours, sorted by cost", the data sources include a relational database (transportation cost table) and a graph database (route network graph); the initial weight coefficient is set to When detecting that the query involves multi-source data types, automatically trigger weight dynamic adjustment. If the graph database query complexity is higher (such as involving multi-path search), focus on the ability matching degree of the professional query agent, and adjust the weight coefficient to , to update the adaptive function; to realize dynamic adjustment.
[0051] S3, according to the professional query agent, combining the prompt information to obtain the optimal query information of the target query information.
[0052] In this embodiment, the data structure of the target query information is obtained according to the multi-source data type; the data relationship graph of the data structure is established according to the database mode; the data special syntax of the database mode is obtained by performing syntax adaptation on the target query information; and the optimal query information is established based on the professional query agent, in combination with the data relationship graph and the data special syntax.
[0053] Specifically, the selected agent generates an optimized query that conforms to the database mode and meets the user's needs, ensuring that the generated query is matched with the data source in terms of syntax and semantics.
[0054] Each professional query agent creates an optimal query for a specific data source based on the user's natural language query information and the database mode. This process is guided by a set of few-shot prompts, which provide relevant examples for the agent, ensuring that the query is accurate in terms of syntax and semantics. This modular query generation method enables the system to adapt to various data environments and is suitable for complex real-world application scenarios.
[0055] Further, based on the professional query agent, the optimal query information is established in combination with the data relationship graph and the data special syntax, satisfying the following relationship:
[0056]
[0057] Wherein, is the optimal query information, is the professional query agent, is the target query information, is the database mode.
[0058] The above process ensures that the generated query is highly matched with the target database and can retrieve the correct data according to the user's needs.
[0059] In an optional embodiment, the process of constructing the professional query agent to construct the optimal query information is abstracted as a multi-modal conditional generation process; first, the database schema is parsed and a data relationship graph is constructed; second, the target query information is semantically analyzed and intention mapped to obtain a candidate operation set; finally, based on a few-shot example, the optimal query information is generated through semantic verification combined with context information.
[0060] Specifically, the metadata of the database schema is parsed, including but not limited to the fields of the table, the edge attributes of the graph database, and the nested levels of the document database, to construct a data relationship graph that satisfies the following relationship:
[0061]
[0062] wherein, is the data relationship graph, is the entity node, is the relationship edge.
[0063] Specifically, the target query information is semantically analyzed and intention mapped to obtain a candidate operation set; the target query information is encoded by an encoder to obtain a feature vector of the target query information; thereby the intention of the target query information is mapped to the entities and relationships in the database schema to construct the candidate operation set, including the selected fields, the connected conditions, and the graph traversal path.
[0064] The feature vector of the target query information satisfies the following relationship:
[0065]
[0066] wherein, is the feature vector of the target query information, is the encoder, is the target query information.
[0067] Specifically, based on a few-shot example, the optimal query information is generated through semantic verification combined with context information; the data relationship graph is encoded by a graph attention network to obtain a schema feature matrix, the generation process of the optimal query information is guided by the few-shot example, and the semantic verification is performed by a parser of the target database combined with the context to ensure the compatibility of the operator and the schema.
[0068] In an optional embodiment, a syntax adaptation probability model is constructed to implement the syntax adaptation of the target query information to obtain the data-specific syntax of the database schema, the syntax adaptation probability model satisfies the following relationship:
[0069]
[0070] wherein, is the probability, is the optimal query information, is the target query information, is the total number of syntax states, is the traversal count flag, is the syntax state of the first step, is the syntax state of the first step, is the syntax state of the first step, is the syntax state of the first step, is the feature vector of the target query information.
[0071] The pattern feature matrix satisfies the following relationship:
[0072]
[0073] wherein, is the pattern feature matrix, is the graph attention network, is the data relationship graph.
[0074] Further, the professional query agent satisfies the following relationship:
[0075]
[0076] wherein, is the professional query agent, is the traversal count flag, is the total number of tokens, is the probability, is the token of the target query information, is the feature vector of the target query information, is the pattern feature matrix.
[0077] In an optional embodiment, in a financial analysis scenario, if the target query information is "comparison analysis of stock price trend and net profit growth rate of a certain company in the past five years"; first, data retrieval is performed, and the document agent extracts net profit data from annual reports, and the document agent extracts time series information of the stock price of the company; the net profit data and the time series information are encoded into a feature vector, and the time dimension is aligned through a cross-attention mechanism to generate fused features; then a generation agent is used to obtain multi-format outputs, including a text summary (such as an average annual growth rate of net profit of 12% in the past five years, and a cumulative stock price increase of 150%), a line chart (a two-axis chart showing the stock price and net profit trend), and a table (annual comparison data).
[0078] S4, obtaining a query return result according to the optimal query information, and constructing key return information in combination with the query return result and the target query information.
[0079] In this embodiment, according to the optimal query information, the optimal return result is obtained in combination with the execution environment of the target query information; the execution environment connects the optimal query information and the corresponding database mode; the optimal return result and the context of the target query information are merged to construct the key return information.
[0080] Specifically, the generated optimal query information is then run in the query execution environment; the execution environment is responsible for interacting with the corresponding database, ensuring seamless compatibility with various database systems, and the execution environment retrieves relevant data according to the query, ensuring that the returned results are accurate and consistent with the context. After data retrieval is complete, the system merges it with the original query context to prepare for subsequent processing. This integration step is crucial because it provides the intelligent agent with the key return information needed to generate accurate and coherent replies. The retrieved data and the original query context together constitute the input for the generation phase.
[0081] Further, after the query generation intelligent agent generates the query, the query is passed to the query execution environment, which serves as the core platform to connect the generated query with the corresponding database to obtain the required data; the query execution environment plays a key role in ensuring accurate and efficient query execution, responsible for communication between the designed system and various databases; the query execution environment is equipped with various database drivers to ensure compatibility with different types of databases. For example, relational databases are accessed through drivers to handle structured data in tables; document databases use specialized drivers to handle document-type data, which has a more flexible and hierarchical structure; graph databases require drivers specifically designed for querying relationships between nodes in graph structures; the system selects the appropriate driver based on the type of database being queried to ensure smooth communication and efficient data retrieval; the query execution environment is responsible for managing database connections, executing queries generated by intelligent agents, and obtaining results.
[0082] Specifically, the optimal return result and the context of the target query information are merged to construct the key return information, satisfying the following relationship:
[0083]
[0084] wherein, is the key return information, is the execution function, is the optimal query information, is the database mode.
[0085] The execution function is used to process the optimal query information and interact with the database schema of the target to obtain key return information, and then transmit the key return information back to the system for subsequent processing. In this way, the query execution is managed, and the execution environment ensures that the system can efficiently retrieve data from various databases while ensuring data consistency and accuracy between different data sources.
[0086] In an optional embodiment, the optimal query information and the database schema are input into the execution function; a corresponding driver is selected according to the database type of the database schema, and the optimal query information is sent to the database schema through the driver to obtain the optimal return result; the optimal return result is merged with the context of the target query information through the execution function; the execution function satisfies the following relationship:
[0087]
[0088] Wherein, is the execution function, represents the merging operation, is the optimal return result, is the context of the target query information.
[0089] S5, based on the key return information, constructing a retrieval enhancement generation result of the target query information according to the generated agent.
[0090] In this embodiment, the key return information is processed according to the generated agent to obtain the retrieval enhancement generation result, which satisfies the following relationship:
[0091]
[0092] Wherein, is the retrieval enhancement generation result, is the conversion function, is the target query information, is the key return information.
[0093] In an optional embodiment, the conversion function includes the following steps: first, different encoding methods are selected according to different data types to structure and encode the key return information to obtain encoded feature information; then, cross-attention mechanism is used to cross-modal fusion of the encoded feature information to obtain fusion features; finally, based on the fusion features, the retrieval generation result is obtained, and the output format includes but is not limited to text, table and chart.
[0094] The fusion features of the key return information satisfy the following relationship:
[0095]
[0096] Wherein, for the total amount of features, for the traversal count flag, for the total amount of features, for the learnable weight matrix, for the feature vector of the target query information, denotes the transpose, for the encoded feature information of the key return information.
[0097] Specifically, the generation agent is responsible for synthesizing the final reply to the user query according to the retrieved data. After the query execution and the completion of the relevant data retrieval, the generation agent processes these information to generate a coherent and context-compliant reply. The generation agent converts the original data into a format that is easy for the user to understand and use. The generation agent combines the original user's target query information and the retrieved key return information to generate the final output of the retrieval-enhanced generation result. The reply form is diverse and depends on the user's specific needs, including but not limited to structured text, tables, or charts, etc. It ensures that the reply is not only accurate but also closely matches the context, meeting the user's needs based on data obtained from different sources.
[0098] In this embodiment, the generation agent synthesizes the final reply using the retrieved data and the user query. The generation agent generates structured and context-rich output. The reply format is adjusted according to user needs, which may include text summaries, charts, tables, or detailed reports, etc. The generated output is presented to the user in an easy-to-understand format, thus completing the entire method flow.
[0099] In an optional embodiment, if the electronic medical record system of a certain medical institution uses a relational database to store patient information, including but not limited to medical record tables, test report tables, and medication record tables; the user's natural language query information is "2024 year diabetes patients who take a certain drug and whose blood sugar level drops more than 20% after taking the drug, and their latest test results", as the target query information; combine the database schema (table structure, field relationship) and the few-sample example to generate the prompt information, which explicitly associates the patient table, the medication table, and the test table; use the adaptation function to calculate the matching degree of the data source type and the agent type, and select the relational agent; use the relational agent to analyze the database schema, construct the data relationship graph, including but not limited to patient information, medication records, and test results, adapt the natural language to the database type of specialized syntax, and generate the optimal query information; the execution environment connects the database based on the optimal query information to obtain the key return information, including the patient list and the latest test results, and merges it with the context of the original query, extracts the key fields, including patient information and blood sugar value; finally, use the generation agent to obtain the retrieval-enhanced generation result, output as a table form and attach a statistical summary.
[0100] Please refer toFigure 2 In an optional embodiment, the present application provides a multi-agent retrieval enhancement generation system based on diverse data sources, comprising an input device, an output device, a processor and a memory, which are connected to each other, wherein the memory is used to store a computer program comprising program instructions, and the processor is configured to invoke the program instructions to perform the specific steps of the related embodiments of the present application. The multi-agent retrieval enhancement generation system based on diverse data sources provided by the present application has a complete structure and objective stability, and can efficiently perform the multi-agent retrieval enhancement generation method based on diverse data sources described in the present application, thereby improving the overall applicability and practical application ability of the present application.
[0101] Please refer to Figure 3 , which is an execution flow chart of the multi-agent retrieval enhancement generation system based on diverse data sources. The workflow starts with a natural language query submitted by a user as the system input, which is the basis for a series of subsequent operations. The query, usually expressed in natural language, summarizes the user's requirements and is the starting point of the retrieval and reply generation process. After the query is submitted, the system combines the user query with the relevant database schema and a set of few-shot examples to generate prompt information. After the prompt is ready, the system determines the most suitable professional query agent according to the type of data source the user wants to query. These agents are specifically designed for different types of databases (such as relational, document, or graph databases). Each type of agent serves as a large model agent, and the selected agent generates an optimized query that conforms to the database schema and meets the user's requirements, ensuring that the generated query is grammatically and semantically compatible with the data source. The generated query is then run in a query execution environment, which is responsible for interacting with the corresponding database to ensure seamless compatibility with various database systems. The execution environment retrieves relevant data according to the query and ensures that the returned results are accurate and contextually consistent. After data retrieval is complete, context retrieval is performed, and the system combines it with the original query context to provide the generation agent with the key information needed to generate an accurate and coherent reply. The retrieved data and the original query context together constitute the input for the generation phase. Finally, the generation agent synthesizes the final reply. Using the retrieved data and the user query, the generation agent generates structured and contextually rich output, and the reply format is adjusted according to user needs, which may include text summaries, charts, tables, or detailed reports, etc. The generated output is presented to the user in an easily understandable format, thus completing the entire workflow.
[0102] The present invention proposes a multi-agent retrieval augmentation generation system based on diverse data sources. Unlike traditional methods, this system delegates query generation tasks to specialized agents, each of which performs retrieval and generation for specific types of data. These agents generate optimized, database-specific queries, but do not directly execute or retrieve data. Queries are executed in separate execution environments to ensure compatibility with various data storage systems. The retrieved context is then combined with the user's original query and processed by the generation agent, which synthesizes a coherent and contextually relevant response.
[0103] The present invention introduces a modular design, improving scalability, enhancing retrieval accuracy, and supporting seamless integration with multilingual data environments. By delegating specific tasks to specialized agents and adopting a centralized execution mechanism, the system addresses the inefficiency of traditional single-agent RAG implementations. It provides a powerful solution for integrating specific domains and heterogeneous data into generative artificial intelligence workflows, making it highly suitable for a wide range of practical applications.
[0104] The key point of the present invention is to adopt a modular and scalable architecture, which disperses task management through the introduction of multiple specialized agents. These agents are responsible for query generation, data retrieval, and response synthesis for various heterogeneous data sources such as relational databases, document databases, and graph databases. Query generation agents generate customized queries based on user queries and database schemas, query execution environments interact with databases and obtain data, and generation agents synthesize the retrieved data into coherent and contextually relevant responses. This architecture not only improves query efficiency and reduces token overhead but also enhances output accuracy, ensuring seamless integration and processing of different data types and sources. Its modular design allows for the flexible addition or update of agents to accommodate new data types or sources, ensuring long-term scalability and adaptability of the system. The entire workflow starts with user submission of natural language queries, proceeds through query generation, data retrieval, and finally generates a response, providing accurate, efficient, and easy-to-understand results for users, suitable for complex real-world application scenarios.
[0105] The present invention proposes a modular and efficient architecture that leverages specialized agents to handle data retrieval and response generation tasks. This architecture ensures seamless integration and processing of various data types and sources while considering scalability and adaptability. Key components of the architecture include query generation agents, query execution environments, generation agents, and agent specialization modules. These components work together to achieve efficient query generation, execution, and accurate response synthesis.
[0106] In summary, the method provided by the application has many advantages compared with the prior art. First, it adopts a modular and expandable architecture, which can integrate various data sources and generative artificial intelligence capabilities, effectively solving the problems of low efficiency, performance bottleneck and insufficient accuracy of traditional single-agent RAG systems in processing complex multi-source data queries. By introducing a special multi-agent, it processes different types of data sources such as relational databases, document databases and graph databases, achieving seamless compatibility and efficient retrieval of different types of data, significantly improving overall query efficiency, reducing token overhead, and improving the accuracy of the final output, making it widely applicable to practical application scenarios involving complex multi-source data environments. Second, the query generation agent can generate the optimal query for a specific data source based on user queries and database patterns, and ensure the accuracy of the query in syntax and semantics through few-shot prompting guidance. This modular query generation method greatly enhances the system's adaptability to various data environments. The query execution environment is equipped with various database drivers to ensure compatibility with various databases, efficiently manage database connections, execute queries and obtain results, and ensure data consistency and accuracy between different data sources. The generation agent integrates the retrieved data into a coherent and contextually appropriate response, which has various forms and can be flexibly adjusted according to user needs to meet different use scenarios. In addition, the specialization of the agent is one of the core features of the application, each agent is designed specifically for a particular type of data or database, and can efficiently process queries with high accuracy and performance. As new data types or data sources appear, the application can flexibly integrate new agents to adapt to these technological changes, ensuring the long-term scalability and adaptability of the system. In summary, the application introduces specialized agents for different database types, centralized query execution environments, and generation agents for synthesizing responses. This framework solves the key limitations of traditional single-agent RAG systems, improves query accuracy, optimizes token usage, and ensures scalability in heterogeneous data sources. The architecture implemented by the application is suitable for various industries such as healthcare and logistics, and focuses on error handling, efficient resource utilization and reducing computational overhead, making the proposed solution robust and reliable in practical applications. The method is easy to understand, simple to calculate, and has less workload, which is convenient for practical application, and provides a theoretical basis and technical support for the further development of intelligent retrieval generation technology.
[0107] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, and are not intended to limit the present application; although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that the technical solutions recorded in the foregoing embodiments can still be modified, or some or all of the technical features can be replaced by equivalents; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the scope of the technical solutions of the embodiments of the present application, and they should be covered in the scope of the claims and the description of the present application.
Claims
1. A multi-agent retrieval enhancement generation method based on diverse data sources, characterized in that, The method comprises the following steps: obtaining target query information and constructing prompt information of the target query information; constructing multiple agents, determining professional query agents of the target query information based on the prompt information; obtaining optimal query information of the target query information according to the professional query agents and the prompt information; obtaining query return results according to the optimal query information, and constructing key return information by combining the query return results and the target query information; constructing retrieval enhancement generation results of the target query information based on the key return information and according to generated agents; the step of constructing multiple agents and determining professional query agents of the target query information based on the prompt information comprises: taking relational agents, graph agents, document agents and text agents as the professional query agents, and constructing the multiple agents according to the professional query agents; in the multiple agents, determining the professional query agents that are most suitable for the target query information according to the diverse data source types of the prompt information; the step of obtaining optimal query information of the target query information according to the professional query agents and the prompt information comprises: obtaining a data structure of the target query information according to the diverse data source types; establishing a data relationship graph of the data structure according to a database mode; performing syntax adaptation on the target query information to obtain a data-specific syntax of the database mode; establishing the optimal query information based on the professional query agents, the data relationship graph and the data-specific syntax.
2. The method of claim 1, wherein, the step of obtaining target query information and constructing prompt information of the target query information comprises: obtaining natural language query information, which is taken as the target query information; constructing the prompt information based on the target query information, a database mode and a few sample examples.
3. The method of claim 1, wherein, the step of determining the professional query agents that are most suitable for the target query information according to the diverse data source types of the prompt information comprises: wherein, is a fitness value, is a fitness function, is a diverse data source type, is a type of professional query agent.
4. The method of claim 1, wherein, the step of establishing the optimal query information based on the professional query agents, the data relationship graph and the data-specific syntax comprises: wherein, is the optimal query information, is the professional query agent, is the target query information, is the database schema.
5. The method of claim 2, wherein, the step of obtaining query return results according to the optimal query information, and constructing key return information by combining the query return results and the target query information comprises: obtaining the query return results according to the optimal query information and an execution environment of the target query information; the execution environment connects the optimal query information and a corresponding database mode; merging the query return results and a context of the target query information, thereby constructing the key return information.
6. The method of claim 5, wherein, the key return information comprises: wherein, is the key return information, is the execute function, is the optimal query information, is the database schema.
7. The method of claim 1, wherein, the step of constructing retrieval enhancement generation results of the target query information based on the key return information and according to generated agents comprises: processing the key return information according to the generated agents to obtain the retrieval enhancement generation results, which satisfy the following relationship: wherein, to retrieve augmentation generation results, to transform functions, to target query information, to key return information.
8. A multi-agent retrieval augmentation generation system based on diverse data sources, the system comprising: The system comprises an input device, an output device, a processor and a memory, which are connected with each other, wherein the memory is configured to store a computer program, the computer program comprises program instructions, and the processor is configured to invoke the program instructions to execute the method for generating multi-agent retrieval enhancement based on multiple data sources according to any one of claims 1-7.
Citation Information
Patent Citations
Multi-agent intelligent retrieval engine and man-machine interaction system and method
CN118132762A
Reinforced learning modeling method and device fusing multi-source heterogeneous data
CN119442144A