Data query method and device based on large model agent, equipment and medium
Patent Information
- Application Number
- CN202610968160.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-01
- Publication Date
- 2026-09-15
- Estimated Expiration
- 2046-07-01
AI Technical Summary
然而,在查询涉及复杂推理时,单纯依赖关键词匹配难以定位分散在不同记忆片段中的关键证据,例如查询“为什么用户取消了原本计划的A地的旅行”,通过关键词匹配无法匹配健康检查结果、饮食担忧、行程变更等多个关联的记忆,而只能召回包含“A地”的片段,这种查询方式导致查询结果的相关性和准确性较低
[0015]This application embodiment acquires user query data; through a preset retrieval routing model, based on the user query data and each preset retrieval primitive sequence, outputs the selection probability for each retrieval primitive sequence; wherein, the retrieval primitive sequence includes retrieval primitives of retrieval types of memory primitive retrieval and associated context retrieval; based on the selection probability of each retrieval primitive sequence, a target retrieval primitive sequence is selected from multiple preset retrieval primitive sequences; for each target retrieval primitive in the target retrieval primitive sequence, the user query data is sequentially combined, and a retrieval is performed in the historical memory bank according to the corresponding retrieval type to obtain the historical associated data set corresponding to the target retrieval primitive sequence, the historical associated data set including at least one target historical memory primitive and a primitive relation chain composed of multiple associated historical memory primitives; wherein, the historical memory bank includes multiple historical memory primitives and multiple relation graphs, the relation graphs are used to provide the association relationship between at least two corresponding historical memory primitives during the context retrieval process; through a large language model, corresponding query results are generated based on the user query data and the historical associated data set. This allows for the dynamic selection of the most suitable multi-step retrieval path for the current query, and the execution of sequential primitives guided by the relationship graph enables the cross-node, multi-hop association of scattered evidence, thereby fully capturing the causal relationships, event chains, or multi-step evidence implicit in complex queries. Specifically, compared to the prior art which relies solely on keyword matching and can only recall isolated fragments containing specific terms, the retrieval routing model of this application does not employ a fixed strategy. Instead, it adaptively selects different sequences of retrieval primitives for each query, allowing the retrieval behavior to adjust according to changes in the information requirements of the query. Simultaneously, because multiple relationship graphs are pre-constructed in the historical memory bank, and there is a clear mapping relationship between retrieval primitives and memory primitives, when the target primitive sequence is executed sequentially, it can start from the initial memory primitive and expand along the structured edges of the relationship graph, successively locating multiple memory primitives that are logically related but literally mismatched, thus linking scattered evidence into a complete chain of evidence. In summary, this application can improve the relevance and accuracy of data queries based on large-model intelligent agents.
Smart Images

Figure CN122470645B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data query technology, and in particular to a data query method, apparatus, device and medium based on a large model intelligent agent. Background Technology
[0002] Data querying based on a large model intelligent agent involves receiving a natural language question input by the user, retrieving relevant information from a pre-stored interaction history or knowledge base, and inputting the retrieved memory fragments along with the user question into a large language model, so that the large language model can generate context-sensitive query results based on the memory fragments.
[0003] In related technologies, when a system retrieves relevant information from pre-stored interaction history or a knowledge base, it typically uses keyword matching. Specifically, this method extracts corresponding keywords from user query data and searches the historical interaction knowledge base to obtain the corresponding memory fragments, thus yielding the query results. However, when the query involves complex reasoning, relying solely on keyword matching struggles to locate key evidence scattered across different memory fragments. For example, when querying "Why did the user cancel their planned trip to location A?", keyword matching cannot match multiple related memories such as health check results, dietary concerns, and travel changes; it can only recall fragments containing "location A." This query method results in low relevance and accuracy of the query results. Summary of the Invention
[0004] This application proposes a data query method, apparatus, device, and medium based on large model intelligent agents, which can improve the relevance and accuracy of data queries based on large model intelligent agents.
[0005] To achieve the above objectives, a first aspect of this application proposes a data query method based on a large model intelligent agent, the method comprising: Obtain user query data; Based on the user query data and each preset retrieval primitive sequence, the selection probability for each retrieval primitive sequence is output using a preset retrieval routing model. The retrieval primitive sequence includes retrieval primitives of retrieval types such as memory primitive retrieval and contextual retrieval; Based on the selection probability of each retrieval primitive sequence, the target retrieval primitive sequence is selected from multiple preset retrieval primitive sequences; For each target retrieval primitive in the target retrieval primitive sequence, the user query data is sequentially combined with the corresponding retrieval type to retrieve data from the historical memory bank, thereby obtaining the historical association data set corresponding to the target retrieval primitive sequence. The historical association data set includes at least one target historical memory primitive and a primitive relationship chain composed of multiple associated historical memory primitives. The historical memory bank contains multiple historical memory primitives and multiple relationship graphs, wherein the relationship graphs are used to provide the association between at least two corresponding historical memory primitives during the context retrieval process; Using a large language model, corresponding query results are generated based on the user query data and the historical associated data set.
[0006] Accordingly, a second aspect of this application proposes a data query device based on a large model intelligent agent, the device comprising: The acquisition module is used to retrieve user query data; The output module is used to output the selection probability for each search primitive sequence based on the user query data and each preset search primitive sequence through a preset search routing model. The retrieval primitive sequence includes retrieval primitives of retrieval types such as memory primitive retrieval and contextual retrieval; The selection module is used to select a target retrieval primitive sequence from multiple preset retrieval primitive sequences based on the selection probability of each retrieval primitive sequence; The retrieval module is used to sequentially combine the user query data with each target retrieval primitive in the target retrieval primitive sequence and search in the historical memory bank according to the corresponding retrieval type to obtain the historical associated data set corresponding to the target retrieval primitive sequence. The historical associated data set includes at least one target historical memory primitive and a primitive relationship chain composed of multiple associated historical memory primitives. The historical memory bank contains multiple historical memory primitives and multiple relationship graphs, wherein the relationship graphs are used to provide the association between at least two corresponding historical memory primitives during the context retrieval process; The generation module is used to generate corresponding query results based on the user query data and the historical associated data set using a large language model.
[0007] In some embodiments, the data query device based on large model agents further includes a training module, used for: Obtain sample query data, and input the sample query data and a preset sample retrieval primitive sequence into a preset retrieval routing model to obtain the predicted selection probability corresponding to each sample retrieval primitive sequence; Based on the retrieval primitive sequence of each sample and the sample query data, a retrieval is performed in the historical memory to obtain the predicted association data set corresponding to each sample retrieval primitive sequence; For each sample, the primitive sequence is retrieved, and the sample query data and the corresponding prediction association data set are input into the large language model to obtain the corresponding prediction query result. The predicted query result corresponding to the retrieval primitive sequence for each sample is scored to obtain the corresponding predicted query result score; Based on the predicted query result score corresponding to each sample retrieval primitive sequence, the reference selection probability corresponding to each sample retrieval primitive sequence is mapped to the result. The target loss is calculated based on the difference between the predicted selection probability and the reference selection probability corresponding to each sample retrieval primitive sequence; Based on the target loss, the preset retrieval routing model is trained to obtain the retrieval routing model.
[0008] In some implementations, the retrieval module is further configured to: The first target retrieval primitive contained in the target retrieval primitive sequence is determined, and a retrieval is performed in the historical memory bank in combination with the user query data and the retrieval type corresponding to the first target retrieval primitive to obtain the corresponding initial historical state sub-data. The initial historical state sub-data includes at least one target historical memory primitive corresponding to the first target retrieval primitive. The next intermediate target retrieval primitive in the target retrieval primitive sequence is determined by the first target retrieval primitive. The user query data, the initial historical state sub-data, and the retrieval type corresponding to the next intermediate target retrieval primitive are combined to search the historical memory to obtain the corresponding intermediate historical state sub-data. The intermediate historical state sub-data corresponding to the next intermediate target retrieval primitive is updated according to the user query data and the intermediate historical state sub-data. Repeat the step of updating the intermediate historical state sub-data corresponding to the next intermediate target retrieval primitive based on the user query data and the intermediate historical state sub-data, until the next intermediate target retrieval primitive is the last target retrieval primitive corresponding to the target retrieval primitive sequence, and determine the intermediate historical state sub-data corresponding to the last target retrieval primitive as the historical associated data set corresponding to the target retrieval primitive sequence.
[0009] In some implementations, the retrieval module is further configured to: When the retrieval type corresponding to the next intermediate target retrieval primitive is a positioning primitive, the user query data, the initial historical state sub-data, and the retrieval type corresponding to the next intermediate target retrieval primitive are combined to search the historical memory to obtain the corresponding intermediate historical state sub-data. The positioning primitive types include entity search primitives, word literal search primitives, and semantic search primitives. When the retrieval type corresponding to the next intermediate target retrieval primitive is an extended primitive, the user query data, the initial historical state sub-data, and the retrieval type corresponding to the next intermediate target retrieval primitive are combined to search the historical memory database to obtain the corresponding intermediate historical state sub-data. The extended primitive types include time association extended primitives, semantic similarity extended primitives, entity co-occurrence extended primitives, and causal relationship extended primitives. The intermediate historical state sub-data includes the initial historical state sub-data and a primitive relationship chain composed of multiple associated historical memory primitives.
[0010] In some implementations, the retrieval module is further configured to: When the retrieval type corresponding to the next intermediate target retrieval primitive is an extended class primitive, at least one target relationship graph corresponding to the next intermediate target retrieval primitive in the historical memory bank is determined, and the at least one target historical memory primitive contained in the initial historical state sub-data is searched in the target relationship graph to determine the position information of the at least one target historical memory primitive in the target relationship graph. Obtain a preset number of associated hops, combine the location information and the number of associated hops, extract the primitive relationship chain corresponding to the at least one target historical memory primitive in the target relationship graph, and obtain the corresponding intermediate historical state sub-data based on the primitive relationship chain.
[0011] In some embodiments, the data query device based on large model intelligent agents further includes a determination module, used for: Multiple initial retrieval primitive sequences are obtained, and for each initial retrieval primitive in each initial retrieval primitive sequence, the preset first sample query data is sequentially combined, and the historical memory is searched according to the corresponding query type to obtain the first associated data set corresponding to each initial primitive sequence. Using a large language model, corresponding predicted query results are generated based on the first sample query data and the first associated data set; Obtain the first retrieval score of the predicted query result corresponding to each initial retrieval primitive sequence, and when the first retrieval score is greater than a preset retention threshold, determine the initial retrieval primitive sequence as an intermediate retrieval primitive sequence; For each intermediate retrieval primitive sequence, primitive reconstruction is performed to generate at least one candidate retrieval primitive sequence, wherein each candidate retrieval primitive sequence is different from any historical retrieval primitive sequence; Obtain the second associated data set retrieved by each candidate retrieval primitive sequence for each preset second sample query data, and generate the second retrieval score of each candidate retrieval primitive sequence on each second sample query data based on the second associated data set; When a target candidate retrieval primitive sequence has a second retrieval score on at least one second sample query data that is higher than the score of all capability retrieval primitive sequences on the same second sample query data in the preset capability frontier, the target candidate retrieval primitive sequence is added to the capability frontier. Calculate the first performance score of each capability retrieval primitive sequence in the capability frontier, and when the first performance score of a target capability retrieval primitive sequence in the capability frontier is greater than the second performance score of at least one retrieval primitive sequence in the deployment frontier, add the target capability retrieval primitive sequence as a retrieval primitive sequence to the deployment frontier.
[0012] In some implementations, the determining module is further configured to: Using a pre-defined verification query set, execute each capability retrieval primitive sequence contained in the current capability frontier and each retrieval primitive sequence contained in the deployment frontier. A first performance score is calculated for each capability retrieval primitive sequence based on the difference between each first query result generated on the validation query set and the sample label, and a second performance score is calculated for each capability retrieval primitive sequence based on the difference between each second query result generated on the validation query set and the sample label. Identify the benchmark retrieval primitive sequence with the lowest second performance score in the deployment frontier; When the difference between the first performance score of the target capability retrieval primitive sequence and the second benchmark performance score corresponding to the benchmark retrieval primitive sequence in the capability frontier is greater than or equal to a preset gain threshold, the target capability retrieval primitive sequence is added to the deployment frontier as a retrieval primitive sequence, and the benchmark retrieval primitive sequence is removed from the deployment frontier. Alternatively, when the difference between the first performance score of the target capability retrieval primitive sequence and the second benchmark performance score corresponding to the benchmark retrieval primitive sequence in the capability frontier is less than or equal to the gain threshold, the sequence length difference between the target capability retrieval primitive sequence and the benchmark retrieval primitive sequence is calculated. When the sequence length difference is less than a preset value, the target capability retrieval primitive sequence is added to the deployment frontier as a retrieval primitive sequence, and the benchmark retrieval primitive sequence is removed from the deployment frontier.
[0013] Accordingly, a third aspect of the embodiments of this application proposes a computer device, which includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the data query method based on a large model intelligent agent according to any one of the embodiments of the first aspect of this application.
[0014] Accordingly, a fourth aspect of the embodiments of this application proposes a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the data query method based on a large model intelligent agent according to any one of the embodiments of the first aspect of this application.
[0015] This application embodiment acquires user query data; through a preset retrieval routing model, based on the user query data and each preset retrieval primitive sequence, outputs the selection probability for each retrieval primitive sequence; wherein, the retrieval primitive sequence includes retrieval primitives of retrieval types of memory primitive retrieval and associated context retrieval; based on the selection probability of each retrieval primitive sequence, a target retrieval primitive sequence is selected from multiple preset retrieval primitive sequences; for each target retrieval primitive in the target retrieval primitive sequence, the user query data is sequentially combined, and a retrieval is performed in the historical memory bank according to the corresponding retrieval type to obtain the historical associated data set corresponding to the target retrieval primitive sequence, the historical associated data set including at least one target historical memory primitive and a primitive relation chain composed of multiple associated historical memory primitives; wherein, the historical memory bank includes multiple historical memory primitives and multiple relation graphs, the relation graphs are used to provide the association relationship between at least two corresponding historical memory primitives during the context retrieval process; through a large language model, corresponding query results are generated based on the user query data and the historical associated data set. This allows for the dynamic selection of the most suitable multi-step retrieval path for the current query, and the execution of sequential primitives guided by the relationship graph enables the cross-node, multi-hop association of scattered evidence, thereby fully capturing the causal relationships, event chains, or multi-step evidence implicit in complex queries. Specifically, compared to the prior art which relies solely on keyword matching and can only recall isolated fragments containing specific terms, the retrieval routing model of this application does not employ a fixed strategy. Instead, it adaptively selects different sequences of retrieval primitives for each query, allowing the retrieval behavior to adjust according to changes in the information requirements of the query. Simultaneously, because multiple relationship graphs are pre-constructed in the historical memory bank, and there is a clear mapping relationship between retrieval primitives and memory primitives, when the target primitive sequence is executed sequentially, it can start from the initial memory primitive and expand along the structured edges of the relationship graph, successively locating multiple memory primitives that are logically related but literally mismatched, thus linking scattered evidence into a complete chain of evidence. In summary, this application can improve the relevance and accuracy of data queries based on large-model intelligent agents. Attached Figure Description
[0016] Figure 1 This is a schematic diagram of the architecture of the data query system based on a large model intelligent agent provided in the embodiments of this application; Figure 2 This is a flowchart of a data query method based on a large model intelligent agent provided in an embodiment of this application; Figure 3 This is a flowchart illustrating the overall process of the data query method based on a large model intelligent agent provided in this application embodiment; Figure 4 This is a schematic diagram of the functional modules of the data query device based on a large model intelligent agent provided in the embodiments of this application; Figure 5This is a schematic diagram of the hardware structure of the computer device provided in the embodiments of this application. Detailed Implementation
[0017] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0018] It should be noted that although functional modules are divided in the device schematic diagram and a logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than the module division in the device or the order in the flowchart. The terms "first," "second," etc., in the specification, claims, and the aforementioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence.
[0019] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing embodiments of this application only and is not intended to limit this application.
[0020] Data querying based on a large model intelligent agent involves receiving a natural language question input by the user, retrieving relevant information from a pre-stored interaction history or knowledge base, and inputting the retrieved memory fragments along with the user question into a large language model, so that the large language model can generate context-sensitive query results based on the memory fragments.
[0021] In related technologies, when a system retrieves relevant information from pre-stored interaction history or a knowledge base, it typically uses keyword matching. Specifically, this method extracts corresponding keywords from user query data and searches the historical interaction knowledge base to obtain the corresponding memory fragments, thus yielding the query results. However, when the query involves complex reasoning, relying solely on keyword matching struggles to locate key evidence scattered across different memory fragments. For example, when querying "Why did the user cancel their planned trip to location A?", keyword matching cannot match multiple related memories such as health check results, dietary concerns, and travel changes; it can only recall fragments containing "location A." This query method results in low relevance and accuracy of the query results.
[0022] Based on this, embodiments of this application provide a data query method, apparatus, device, and medium based on large model intelligent agents, which can improve the relevance and accuracy of data queries based on large model intelligent agents.
[0023] The data query method, apparatus, device, and medium based on large model intelligent agents provided in this application are specifically described through the following embodiments. First, the data query system based on large model intelligent agents in this application is described.
[0024] Please refer to Figure 1 In some implementations, embodiments of this application provide a data query system based on a large model intelligent agent, including a terminal 11 and a server 12.
[0025] In some implementations, terminal 11 can be used to receive query data input by the user, display the final generated query results, and conduct interactive dialogue or transmit instructions to the user.
[0026] For example, terminal 11 can be a hardware device with input / output capabilities and network communication functions, such as a smartphone, tablet, personal computer, smart speaker, in-vehicle terminal, or IoT device. Terminal 11 can acquire the user's natural language query through a built-in graphical user interface, voice acquisition module, or text input box, and send the query data to server 12 through a communication network; at the same time, terminal 11 receives the query results returned by server 12 and presents them to the user through screen display, voice broadcast, or action response.
[0027] In some implementations, server 12 can be used to perform the compilation of large-scale historical interaction data, the construction and maintenance of structured memory, the management of retrieval primitives, the storage and evolution of retrieval skills, the training and reasoning of retrieval routing models, the execution of retrieval skills, and the invocation of large language models and the generation of answers.
[0028] For example, server 12 can be a single server, server cluster, cloud server instance, or edge computing node, or other hardware device with computing, storage, and network communication capabilities. Server 12 can use its configured memory compilation module to divide the original interaction history into memory atoms and build indexes and relationship graphs. It can provide various retrieval primitives such as entity_search, dense_search, and relation_expand through the retrieval primitive library module. It can store executable retrieval primitive sequences through the skill repository module. It can dynamically select target retrieval skills according to user queries through the skill router module. It can execute primitives sequentially and generate evidence views through the skill execution module. It can then generate query results through the large language model. Finally, it can periodically maintain the experience Trie, capability frontier, and deployment frontier through the evolution management module to achieve continuous self-evolution of retrieval skills.
[0029] Terminal 11 and server 12 interact via wired or wireless communication networks (e.g., Wi-Fi, 5G, Ethernet). Their collaborative process is as follows: Terminal 11 collects user query data and sends it to server 12; upon receiving the query, server 12 calls the skill router in the deployment frontier to calculate the selection probability of each retrieval skill, selects the target retrieval primitive sequence, and sequentially combines the query data to perform memory primitive retrieval and contextual retrieval in the historical memory bank, generating a historical associated data set containing target memory primitives and primitive relationship chains. The query results are then generated through a large language model; server 12 returns the final query results to terminal 11, which then presents them to the user. Through this division of labor, terminal 11 focuses on lightweight human-computer interaction tasks, while server 12 is responsible for computationally intensive tasks such as memory compilation, retrieval routing, skill execution, and model inference, thereby achieving complex dynamic memory retrieval and self-evolution capabilities while ensuring response speed.
[0030] The data query method based on large model intelligent agents in this application embodiment can be illustrated through the following embodiments.
[0031] It should be noted that in all specific embodiments of this application, when processing data related to user identity or characteristics, such as user information, user behavior data, user historical data, and user location information, user permission or consent will be obtained first. Furthermore, the collection, use, and processing of this data will comply with relevant laws, regulations, and standards. In addition, when embodiments of this application require access to sensitive personal information of users, separate permission or consent from the user will be obtained through pop-ups or redirects to confirmation pages. Only after obtaining the user's separate permission or consent will the necessary user-related data for the normal operation of the embodiments of this application be obtained.
[0032] In some embodiments, the large-model intelligent agent involved in this application is defined and described. The large-model intelligent agent in the embodiments of this application can be an artificial intelligence system with a large language model as its core component, and on this basis, an integrated long-term memory management module, an external tool calling interface, a task planning and reasoning module, and environmental interaction capabilities. The large-model intelligent agent has the ability to store and retrieve interaction history across sessions and across time, can make multi-step decisions based on user query data, call external resources, maintain dialogue state, and reflect and self-evolve based on internal memory, continuously evolving and updating the retrieval primitive sequence for deployment and verification.
[0033] In this application embodiment, the description will focus on a data query device based on a large-scale intelligent agent, which can be integrated into a computer device. See [link to relevant documentation]. Figure 2 , Figure 2 This application provides a flowchart of the steps for a data query method based on a large model intelligent agent, assuming that the data query device based on a large model intelligent agent is specifically integrated into a terminal or server. When the processor on the terminal or server executes the program instructions corresponding to the data query method based on a large model intelligent agent, the specific process is as follows: Step 101: Obtain user query data.
[0034] In some implementations, the raw natural language query or operation command can be received as the trigger signal and parsing object for the entire dynamic retrieval process, so as to transform the user's real-time information needs into a standardized input form that can be recognized by the routing model and processed by the executable retrieval skills. This lays the data foundation for the subsequent implementation of adaptive retrieval skill selection and evidence construction based on query content.
[0035] The user query data can be the raw input information received by the intelligent agent system to trigger memory retrieval and answer generation. For example, it can be a natural language question posed by the user, an instruction with time or entity constraints, or a complex task description that requires multi-step reasoning by the intelligent agent, and can originate from human-computer interaction interfaces, application programming interface calls, or automated task queues.
[0036] For example, query data can be used to trigger subsequent dynamic memory retrieval and answer generation processes. Specifically, the system can receive natural language questions or operation instructions input by the user through a human-computer interaction interface, such as "What gift did someone buy on a certain trip?" or "Why did they no longer plan a certain trip?" entered by the user in a dialog window; it can also receive structured query requests from external systems through an application programming interface, such as JSON format data containing entities, time ranges, or multi-hop inference hints; and it can also pull pending query tasks from message queues or task pipelines.
[0037] Furthermore, after acquiring the query data, the system can optionally preprocess the original input, including but not limited to removing redundant spaces, standardizing character encoding, filtering sensitive information, identifying explicit or implicit time clues (such as converting "last March" into a specific timestamp), and extracting key entities (such as people, locations, and event names) as auxiliary information for subsequent retrieval. For example, when a user enters "Why did that person stop going to that city?", the system can extract the referents of "that person" and "that city" through named entity recognition, and combine the session context to resolve the referents into specific user IDs and city names, forming a structured query semantic representation. In this way, heterogeneous raw inputs can be transformed into a unified standard query data format that can be processed by subsequent routing models and retrieval primitive sequences, laying a data foundation for adaptive skill selection.
[0038] In this way, users' heterogeneous and unstructured information needs can be transformed into a unified data format that can be processed by subsequent routing and execution modules. This provides an accurate data starting point for dynamically selecting the optimal retrieval skills based on query content and adaptively constructing evidence views for different query types.
[0039] Step 102: Using a preset retrieval routing model, based on user query data and each preset retrieval primitive sequence, output the selection probability for each retrieval primitive sequence; The retrieval primitive sequence includes retrieval primitives of retrieval types such as memory primitive retrieval and contextual retrieval.
[0040] In some implementations, in order to overcome the problem that the agent's memory retrieval behavior is static and cannot adaptively select the appropriate retrieval strategy according to the query type, a preset learnable retrieval routing model can be used to calculate the matching degree between the user query and each candidate retrieval primitive sequence and output the probability distribution, so as to dynamically route heterogeneous queries to the most suitable retrieval program, thereby avoiding the lack of evidence or redundant context injection caused by a single fixed strategy.
[0041] The retrieval routing model can be a learnable neural network model based on a dual-tower encoder or a shared encoder structure. It can be used to evaluate the applicability of each preset retrieval primitive sequence based on the input user query data and output the corresponding selection probability distribution.
[0042] The retrieval primitive sequence can be an executable programmatic instruction sequence consisting of multiple retrieval primitives arranged in sequence. For example, a sequence that first executes entity search to locate relevant memories and then executes time-related expansion to supplement the context can be used to define a complete operational flow for locating, expanding, filtering, and organizing memory atoms from the historical memory bank.
[0043] The selection probability can be a value between 0 and 1, representing the degree of matching or applicability confidence of a certain retrieval primitive sequence compared to other candidate sequences under the condition of given user query data. In other words, it is a soft probability value obtained by normalizing the matching score output by the model through a normalized exponential function.
[0044] Among them, retrieval primitives can be the smallest granular, indivisible, callable functional units that encapsulate a single type of memory access operation. For example, entity search primitives can be used to locate relevant memory atoms based on entities in the query, word literal search primitives can be used to perform text matching based on keywords or BM25, and time association extension primitives can be used to supplement the context along time adjacency relationships.
[0045] In some implementations, the retrieval routing model can employ a dual-tower encoder structure. The query tower encodes user query data into query semantic vectors, while the skill tower encodes the textual descriptions of each retrieval primitive sequence (e.g., skill name, applicable scenario descriptions, information preference tags, etc.) into skill semantic vectors. Subsequently, a learnable matching scoring function (e.g., vector dot product, cosine similarity, or concatenation mapping via a multilayer perceptron) is used to calculate the matching score between the query and each skill. Finally, a normalized exponential function is used to convert the score into a probability distribution, ensuring that the sum of the selection probabilities of all candidate retrieval primitive sequences is 1. For example, for the user query "Why did that person stop going to that city later?", the routing model calculates the matching degree with "time-causal tracking skill", "entity anchoring similarity expansion skill", and "literal fact localization skill" respectively, outputting probabilities of 0.7, 0.2, and 0.1, indicating that the current user query data is most suitable for retrieval skills containing time expansion and relational jumps.
[0046] Specifically, the retrieval primitive sequence can be an ordered combination of primitives of various retrieval types, including at least two types: memory primitive retrieval and contextual retrieval. Memory primitive retrieval primitives can be used to directly locate target memory atoms from the historical memory bank, such as entity search primitives (retrieval based on entities like people, places, and events in the query using an entity-atom index), literal retrieval primitives (obtaining literal related memories based on BM25 or keyword matching), and semantic retrieval primitives (obtaining semantically similar memories through vector similarity). Contextual retrieval primitives can be used to expand upon already located memory atoms to form evidence chains containing multi-hop relationships, such as temporal association expansion primitives (supplementing context along temporal adjacency relationships), semantic similarity expansion primitives (obtaining content with similar themes along semantic similarity edges), entity co-occurrence expansion primitives (expanding based on co-occurring entity relationships), and causal relationship expansion primitives (performing multi-hop reasoning along event or causal edges).
[0047] Specifically, a complete retrieval primitive sequence can be anchored by starting with a memory primitive retrieval primitive, then chaining one or more contextual retrieval primitives to expand the evidence chain, and optionally adding a large language model processing primitive at the end for evidence filtering or summarization. For example, the retrieval primitive sequence "entity search primitive → temporal relation expansion primitive → causal relation expansion primitive" means first locating the initial memory corresponding to the target entity, then expanding adjacent memory segments in chronological order, and finally tracing the causal chain leading to the state change along the causal edge, thus making it suitable for causal reasoning queries such as "why it no longer...".
[0048] The above methods enable adaptive routing decisions for heterogeneous information needs, dynamically guiding queries to the most suitable retrieval program. This overcomes the shortcomings of fixed retrieval strategies that cannot adapt to different evidence construction paths, and provides a reliable basis for skill selection for subsequent execution of accurate and interpretable target retrieval primitive sequences.
[0049] In some implementations, to enable the router to learn decision-making capabilities guided by actual retrieval performance, this application sequentially executes a complete retrieval-generation-evaluation process with sample query data and each sample retrieval primitive sequence. The actual skill performance score is used as a supervision signal mapped to a reference selection probability. The routing model is optimized by minimizing the difference between the predicted probability and the reference probability, thereby enabling the router to adaptively select the retrieval skill that performs better in actual operation based on query characteristics. For example, the retrieval routing model can be trained in the following way: (A.1) Obtain sample query data, and input the sample query data and each preset sample retrieval primitive sequence into the preset retrieval routing model to obtain the predicted selection probability corresponding to each sample retrieval primitive sequence; (A.2) Based on the retrieval primitive sequence and sample query data for each sample, a retrieval is performed in the historical memory to obtain the predicted association data set corresponding to the retrieval primitive sequence for each sample; (A.3) For each sample, retrieve the primitive sequence, combine the sample query data and the corresponding prediction association data set, and input them into the large language model to obtain the corresponding prediction query results; (A.4) Score the predicted query results corresponding to each sample's retrieval primitive sequence to obtain the corresponding predicted query result score; (A.5) Based on the predicted query result score corresponding to each sample retrieval primitive sequence, the reference selection probability corresponding to each sample retrieval primitive sequence is mapped to the result. (A.6) Calculate the target loss based on the difference between the predicted selection probability and the reference selection probability corresponding to the retrieval primitive sequence for each sample; (A.7) Based on the target loss, the preset retrieval routing model is trained to obtain the retrieval routing model.
[0050] The sample query data can be query examples obtained from historical interaction logs or labeled datasets, used to train the retrieval routing model, such as "What gifts did the user buy during their trip in March 2026?" or "Why did they no longer plan a certain trip?", which can be used as input to execute the sample retrieval primitive sequence and evaluate its retrieval performance.
[0051] Among them, the sample retrieval primitive sequence can be a candidate retrieval skill preset during the training phase for the routing model to learn and evaluate. For example, a skill sequence consisting of entity search, temporal association expansion and causal relationship expansion is used to input the routing model together with the sample query data to output the predicted selection probability. It is also used to actually execute in the historical memory to obtain the predicted association data set.
[0052] The preset retrieval routing model can be a neural network model with random or pre-trained parameters in the initial training phase, such as a router based on a dual-tower encoder structure.
[0053] The predicted selection probability can be the normalized result of the matching degree calculated by the preset retrieval routing model for the current sample query data and for each sample retrieval primitive sequence, such as the probability distribution obtained after softmax normalization.
[0054] The predicted association dataset can be an evidence view obtained by performing retrieval, expansion, and filtering in the historical memory bank according to the primitive order of a sample retrieval primitive sequence and combining the sample query data.
[0055] The predicted query result can be the answer text generated by a large language model based on sample query data and predicted associated data set, such as "The user bought a box of low-sugar coffee during his trip in March 2026".
[0056] The predicted query result score can be a numerical value obtained by quantitatively evaluating the predicted query result, such as a score obtained by semantic similarity calculation with the standard query result, large language model review, or matching with the standard answer. It can be used to measure the actual performance of the sample retrieval primitive sequence on the sample query data.
[0057] The reference selection probability can be the predicted query result score based on the retrieval primitive sequence of each sample on the same query, and can be obtained by normalization (such as softmax with temperature).
[0058] The target loss can be a quantified function value that measures the difference between the predicted selection probability and the reference selection probability, such as cross-entropy loss or KL divergence, which is used as the basis for gradient descent to optimize the parameters of the preset retrieval routing model.
[0059] The retrieval routing model can be a neural network model optimized through the above training process, used in the online inference stage to output a suitable skill selection probability distribution from the candidate skill set based on user query data.
[0060] Specifically, real queries can be extracted from the historical interaction logs between the agent and the user, such as user questions in multi-turn dialogues like "What gifts did the user buy during their trip in March 2026?" or "Why did they no longer plan a certain trip?", covering different information needs types such as entity localization, time range focusing, and multi-hop causal reasoning. For each sample query data, it can be input into a preset retrieval routing model along with a pre-defined sequence of sample retrieval primitives (such as "entity anchoring similarity expansion skills", "time causal tracking skills", "literal fact localization skills", etc.).
[0061] For example, the pre-defined retrieval routing model can employ a dual-tower encoder structure: the query encoder maps sample query data to query vectors, and the skill encoder maps the text description of each sample retrieval primitive sequence (such as skill name, applicable scenario description, and primitive sequence summary) to skill vectors; then, a learnable scoring function (such as vector dot product) is used to calculate the matching score, and finally, the softmax function is used to normalize the score to a probability distribution, obtaining the predicted selection probability corresponding to each sample retrieval primitive sequence. For example, for the query "Why did you no longer plan a certain trip?", the model might output a predicted probability of 0.6 for "time causal tracking skill", 0.3 for "entity anchoring similarity extension skill", and 0.1 for "literal fact location skill".
[0062] Furthermore, after calculating the predicted selection probability corresponding to each sample retrieval primitive sequence, each sample retrieval primitive sequence can be actually executed to obtain its true performance on the query. Specifically, for each sample retrieval primitive sequence, the primitives in the sequence can be sequentially combined with the sample query data to perform retrieval, expansion, and filtering operations in the historical memory bank. For example, the sequence for "time-causal tracking skill" is entity search primitive → time association expansion primitive → causal relationship expansion primitive. Entity search primitive → time association expansion primitive → causal relationship expansion primitive: First, the initial historical memory primitive related to the event subject in the query is located through the entity search primitive; then, starting from this initial historical memory primitive, it is expanded along the time adjacency edge to the relevant memories within the preceding and following time windows; finally, the cause chain leading to the state change is traced along the causal relationship edge to form a primitive relationship chain containing multiple associated memory primitives, which serves as the predicted association data set. Subsequently, this predicted association data set and the sample query data can be input into a large language model (such as the GPT series model) to generate the predicted query result text, such as "because the user later said they didn't like the climate of the destination."
[0063] Specifically, after obtaining the predicted query results corresponding to each sample retrieval primitive sequence, each predicted query result can be quantitatively scored to obtain a predicted query result score. The scoring method can employ various evaluation metrics: for example, calculating the semantic similarity between the predicted query result and the standard answer (pre-labeled correct answer) (e.g., BERTScore); or using a large language model as a reviewer to score according to dimensions such as accuracy, completeness, and relevance (e.g., 1-5 points); or judging based on task-specific rules (e.g., whether it contains key entities from the correct answer). For example, the predicted query result generated by the "Time Causal Tracing Skill" scores 0.9, the predicted query result generated by the "Entity Anchoring Similarity Expansion Skill" scores 0.5, and the predicted query result generated by the "Word Literal Fact Location Skill" scores 0.2. This score directly reflects the actual retrieval performance of each sample retrieval primitive sequence on the corresponding sample query data.
[0064] In some implementations, the predicted query result score corresponding to each sample retrieval primitive sequence can be converted into a reference selection probability distribution. This conversion can employ a temperature-controlled softmax function, ensuring that sequences with higher scores receive higher reference probabilities while preserving some exploration space. The formula for calculating the reference selection probability can be expressed as: ; in, To predict the score of the query results, Temperature parameters set according to actual conditions (e.g.) =1), Let's consider the set of candidate skills. Using the scores [0.9, 0.5, 0.2] from the previous example, after softmax transformation, the reference probabilities are 0.62, 0.28, and 0.10, respectively. Thus, the skill with the highest score receives the largest reference probability, but other skills also retain non-zero probabilities, reflecting the relative superiority or inferiority of skills rather than absolute superiority.
[0065] In some implementations, the target loss can be calculated based on the difference between the predicted selection probability (from the current output of the routing model) and the reference selection probability (from the actual execution score mapping) corresponding to each sample retrieval primitive sequence. The target loss can be used to measure the deviation between the current decision distribution of the routing model and the performance-oriented ideal distribution.
[0066] For example, the target loss can be a cross-entropy loss function, which can take the form of: ; in, For reference selection probability (soft label) This loss predicts probabilities for the model. Because the reference probabilities are continuous distributions rather than one-hot hard labels, this loss can convey more nuanced information about the relative superiority or inferiority of skills. For example, if the reference probabilities are [0.62, 0.28, 0.10] and the predicted probabilities are [0.60, 0.30, 0.10], the loss value is smaller; if the predicted probabilities are [0.80, 0.15, 0.05], the loss is larger. The system can sum or average all queries in the training batch to obtain the final target loss.
[0067] Furthermore, the pre-defined retrieval routing model can be iteratively trained with a focus on minimizing the target loss. Specifically, mini-batch stochastic gradient descent or its variants (such as the Adam optimizer) can be used to update the parameters of the routing model. During training, the pre-trained text encoder can be frozen (e.g., using fixed BERT or RoBERTa parameters), optimizing only the projection and matching scoring layers to reduce overfitting risk and accelerate convergence; alternatively, the entire model can be fine-tuned end-to-end based on deployment conditions and data scale. After each training round, the system can use the validation set to monitor the router selection accuracy or average retrieval performance. Training stops when the target loss converges or the validation set performance no longer improves, resulting in a fully trained retrieval routing model. For example, after 1000 training batches, the pre-defined retrieval routing model's prediction probability of assigning "time causal tracking skill" to queries related to "time causal reasoning" improved from 0.3 to over 0.8, and its prediction distribution tended to align with the reference distribution based on the actual execution score mapping, indicating that the model has learned to make routing decisions based on retrieval performance.
[0068] In some implementations, the calculation of the predicted query result score can also incorporate retrieval efficiency metrics to guide the router in learning a decision-making strategy that balances quality and speed. For example, the overall score can be designed as follows: ; in, This is the answer quality score, also known as the predicted query result score (e.g., 0-1). The total time taken for the retrieval-generation process (after normalization). The total number of input and output tokens processed by the large language model. This is determined by adjusting the coefficients. , , This allows the pre-defined retrieval routing model to favor skills with high-quality answers and fast execution speed, or high-quality answers and low token consumption, in different deployment scenarios. This multi-objective optimization method better aligns the router's training objectives with the actual constraints of the online environment (such as real-time requirements and cost budgets), enhancing the practicality and flexibility of the technical solution.
[0069] By using the above methods, the actual performance of the sample retrieval primitive sequence in the historical memory (i.e., the predicted query result score) can be used as a supervision signal and mapped to the reference selection probability. The cross-entropy between the predicted probability and the reference probability can be used as the target loss to train the routing model. In this way, the router can automatically learn the performance-oriented mapping relationship of which query is suitable for which retrieval program without relying on manual annotation of skill preferences. This provides a well-trained decision model for achieving adaptive and quantifiable optimal skill selection in the online inference stage.
[0070] Step 103: Select the target retrieval primitive sequence from multiple preset retrieval primitive sequences based on the selection probability of each retrieval primitive sequence.
[0071] In some implementations, in order to transform the probability distribution output by the routing model into an actual executable retrieval decision, the optimal or threshold-satisfied target sequence can be selected from the candidate sequences based on the selection probability to determine the specific retrieval procedure that should be invoked for the current query, thereby providing a clear skill entry point for the subsequent sequential execution of primitive operations.
[0072] The target retrieval primitive sequence can be one or more retrieval procedures with the highest selection probability selected from multiple preset retrieval primitive sequences, based on the relationship between the selection probabilities output by the routing model.
[0073] Specifically, a probability maximization strategy can be adopted, that is, selecting the retrieval primitive sequence with the highest selection probability as the target retrieval primitive sequence; for example, if the retrieval routing model outputs probabilities of 0.7, 0.2 and 0.1 for "time causal tracking skills", "entity anchoring similarity expansion skills" and "literal fact positioning skills", then "time causal tracking skills" is selected as the target retrieval primitive sequence.
[0074] In some implementations, if the system is configured with a confidence threshold (e.g., 0.6), the single skill is selected only when the highest probability is greater than or equal to the confidence threshold. If the highest probability is lower than the confidence threshold, it indicates that the retrieval routing model is not confident in any single skill. In this case, a multi-skill parallel strategy can be triggered: the top K (e.g., K=2) retrieval primitive sequences with the highest probabilities are selected as target retrieval primitive sequences. In subsequent steps, these target retrieval primitive sequences are executed in parallel, and the corresponding multiple historical association data sets are merged.
[0075] The above methods can effectively transform probabilistic decision-making into executable skills, avoiding the blindness of manual presets or fixed strategies, and thus providing clear procedural guidance for the subsequent sequential execution of retrieval primitives and the construction of high-quality historical relational data sets.
[0076] Step 104: For each target retrieval primitive in the target retrieval primitive sequence, combine it sequentially with the user query data and search in the historical memory bank according to the corresponding retrieval type to obtain the historical association data set corresponding to the target retrieval primitive sequence. The historical association data set includes at least one target historical memory primitive and a primitive relationship chain composed of multiple associated historical memory primitives. The historical memory bank contains multiple historical memory primitives and multiple relationship graphs. The relationship graphs are used to provide the association between at least two corresponding historical memory primitives during the contextual retrieval process.
[0077] In some implementations, in order to dynamically construct a complete evidence chain containing multi-hop association evidence according to query requirements, this application executes each retrieval primitive in the target retrieval primitive sequence in sequence, and uses the retrieval result of the previous primitive as the input evidence state of the subsequent primitive, so as to gradually locate, expand, filter and organize memory primitives in a structured historical memory bank containing memory primitives and relationship graphs, thereby constructing a hierarchical evidence view that contains both target memory primitives and primitive relationship chains.
[0078] Among them, the target retrieval primitive can be the smallest granular memory access unit to be executed, which is taken out sequentially from the target retrieval primitive sequence, such as entity search primitive, temporal association extension primitive or large language model processing primitive, and is used to perform a single type of retrieval operation based on the current evidence state.
[0079] The retrieval type can be a functional category of different memory access operations. For example, the location-type primitive type can include entity search, word literal search, and semantic search, while the extension-type primitive type can include time association extension, semantic similarity extension, entity co-occurrence extension, and causal relationship extension, etc., which are used to indicate the operation mode that the retrieval primitive should adopt in the historical memory bank and the expected form of evidence.
[0080] Among them, the historical memory bank can be a structured memory storage system formed by segmenting, extracting, indexing and graph construction of the long-term interaction history between the agent and the user or the external environment. For example, it can be a data organization that includes memory atom sets, dense vector indexes, BM25 word literal indexes, entity-to-atom indexes, temporal adjacency graphs, semantic similarity graphs and relationship graphs.
[0081] The historical associated data set can be the final evidence view formed by collecting, expanding, filtering, and organizing data from the historical memory bank according to the complete execution flow of the target retrieval primitive sequence. For example, it can be a composite data structure containing at least one target historical memory primitive and a primitive relationship chain formed by connecting multiple associated memory primitives according to time, semantics, or causality.
[0082] Among them, the target historical memory primitive can be the core memory atom that is directly hit and obtained from the historical memory bank during the retrieval process, such as a historical record that is directly related to the entity in the query, "the user said in March 2026 that he liked low sugar coffee".
[0083] Among them, the primitive relationship chain can be a serialized evidence path formed by connecting multiple related historical memory primitives in sequence according to specific associations with the target historical memory primitive (such as temporal adjacency, semantic similarity, entity co-occurrence or causal relationship). For example, the chain structure formed by extending from the target historical memory primitive "the user buys low-sugar coffee" to the historical memory primitive "the user subsequently buys coffee beans" through temporal adjacency, and then to the historical memory primitive "the user stops buying instant coffee" through causal relationship, is used to provide contextual evidence required for multi-hop reasoning.
[0084] Among them, the relationship graph can be a graph data structure pre-constructed in the historical memory bank to express the structured association between at least two historical memory primitives. For example, a temporal adjacency graph establishes edges between memory atoms that are temporally adjacent, a semantic similarity graph establishes edges between memory atoms that are semantically similar, and a relationship graph establishes edges with type between memory atoms that have entity relations or causal relations.
[0085] Among them, the historical memory primitive can be an atomic-level information unit that is segmented and extracted from the long-term interaction history of an agent. For example, it can be an indivisible smallest memory fragment containing the text content "the user said he likes low-sugar coffee", metadata (user identifier, session identifier, source round) and timestamp. It can be used as the basic storage unit of the historical memory bank and the smallest granular object for retrieval operations.
[0086] Specifically, each historical memory primitive has a retrieval mapping relationship with multiple retrieval primitives with different memory retrieval dimensions. That is to say, each historical memory primitive can be retrieved by multiple retrieval methods (such as entity search, word literal search, or semantic search) to support multi-dimensional parallel retrieval and improve recall.
[0087] In some implementations, after selecting a target retrieval primitive sequence, each target retrieval primitive can be executed sequentially according to the order of the primitives in the sequence. Each retrieval primitive takes the current evidence state as input, combines it with user query data, performs the corresponding type of operation in the historical memory, and outputs the updated evidence state.
[0088] Specifically, an evidence state variable can be maintained first, initially empty. For the first target retrieval primitive in the target retrieval primitive sequence, it can be retrieved from the historical memory bank according to its retrieval type (such as entity search, literal search, or semantic search) to obtain an initial set of memory primitives, which is then stored in the evidence state.
[0089] Subsequently, for subsequent target retrieval primitives in the sequence, expansion operations can be performed based on the current evidence state (including memory primitives located according to preceding target retrieval primitives). For example, based on temporal association expansion primitives, adjacent memory primitives can be obtained along temporal adjacency edges; based on relation expansion primitives, multi-hop relation primitives can be obtained along causal or entity relation edges; or the evidence can be filtered, deduplicated, or summarized based on large language model processing primitives. The evidence state is iteratively updated after each target retrieval primitive is executed. When all target retrieval primitives in the target retrieval primitive sequence have been executed, the final evidence state is the historical relational data set corresponding to that target retrieval primitive sequence.
[0090] For example, for the target sequence "entity search primitive → time-related extension primitive → causal extension primitive", we can first locate the memory primitive of the user "someone" buying a gift through entity search, then extend the relevant memories within a week before and after the event along the time adjacency edge, and finally trace the cause chain of "no longer planning to travel" along the causal edge, thus forming a complete evidence view (historical association data set).
[0091] For example, the target historical memory primitive can be a core memory fragment directly hit by a location-based primitive, such as a memory atom text: "On March 12, 2026, the user expressed liking for low-sugar coffee and purchased a box." The primitive relationship chain is a serialized evidence path generated by extension-based primitives along a relationship graph, such as a temporal adjacency relationship chain: starting from the above purchase event, the next temporally adjacent memory is "the user tried low-sugar coffee beans on March 15, 2026," and the next one is "the user said on March 20, 2026, that the taste was not as expected"; subsequently, the causal relationship chain further expands to "due to the poor taste, the user stopped purchasing instant coffee from April onwards." This primitive relationship chain can connect multiple scattered memory atoms in temporal and causal order, forming a coherent context that supports multi-hop reasoning. In addition, the historical association data set can also contain metadata (timestamp, source session round, entity label) for each memory primitive and execution logs during the expansion process (such as the number of hops at each step, filtering conditions), facilitating the tracing of evidence sources when generating subsequent answers.
[0092] In some implementations, the history memory bank can be a persistent storage system formed by structuring the long-term interaction history between the agent and the user or external environment. Its establishment process can be as follows: First, the original interaction history D (which may include multi-turn dialogues, system events, tool call results, etc.) is received and segmented into candidate segments according to time, topic, or event boundaries. For each candidate segment, the system uses a rule engine, information extraction model, or large language model to extract key information, forming atomic-level memory records, called history memory primitives. Each memory primitive can at least contain: atomic text (e.g., "The user indicated they prefer low-sugar coffee"), metadata (e.g., user ID, session ID, source round, entity list, event type), and a timestamp (e.g., "2026-03-12 14:32:00").
[0093] In some implementations, deduplication, merging, or updating operations can be performed on memory primitives. For example, similar preferences of the same entity can be merged into a weighted memory. Subsequently, multiple access structures can be constructed for each memory primitive: its dense vector is calculated and stored in a vector index, keywords are extracted and a BM25 inverted index is constructed, and entities are identified and a mapping from entities to primitives is established. Through the above compilation, the original interaction history is transformed into a structured memory library M(D)=(A,I,G), where A is the set of memory primitives, I is the set of indices, and G is the set of graph structures.
[0094] In some implementations, the relationship graph in the historical memory bank can be used to express the structured associations between at least two historical memory primitives, providing multi-hop retrieval paths for extended class primitives. Specifically, various types of relationship graphs can be constructed based on the memory primitive set: First, a temporal adjacency graph, which establishes undirected or directed edges between primitives that are temporally adjacent (such as consecutive rounds within the same session, or a time difference less than a preset window) based on the timestamp or session round of the memory primitives, to support temporally focused extensions; Second, a semantic similarity graph, which establishes edges between primitives that are semantically similar based on the vector similarity of the memory primitives (such as cosine similarity greater than a threshold of 0.8) or topic clustering results, to support similarity extensions; Third, an event relationship graph, which establishes typed edges between memory primitives through entity relationship extraction, event causal relationship extraction, co-occurrence relationship analysis, or manually / model-generated relationship tags (such as causing, following, belonging to, referencing). For example, a causal edge (cause → effect) can be established between the memory primitive "user buys low-sugar coffee" and "user says they prefer bitter taste," and a causal edge can be established between "user says they prefer bitter taste" and "user stops buying this brand." Furthermore, entity co-occurrence graphs can be constructed: if two memory primitives contain the same entity (such as "user A" and "low-sugar coffee"), an association edge is established. All graph structures are stored in the form of adjacency lists or graph databases and support efficient forward / backward traversal operations, providing millisecond-level neighbor retrieval capabilities for extended class primitives.
[0095] By following the above method, each retrieval primitive can be located, expanded, and filtered based on the evidence state output by the previous primitive, according to the order of the target retrieval primitive sequence. In this way, the complex evidence construction task that cannot be completed by a single retrieval operation can be decomposed into multiple combinable and transitive basic steps. Then, the primitive relation chain containing multi-hop associations can be generated by using the relation graph, providing a hierarchical historical relation data set with both accurate positioning and rich context for subsequent answer generation.
[0096] In some implementations, to achieve ordered collaboration among multiple primitives in the retrieval skill and avoid evidence fragmentation caused by independent retrieval of each primitive, the evidence state output by the previous primitive can be used as the input for the next primitive. This allows for sequential execution of operations such as locating, expanding, and filtering in the historical memory bank, thereby gradually aggregating scattered memory atoms into a coherent view of evidence. Step 104 may include: (104.1) Determine the first target retrieval primitive contained in the target retrieval primitive sequence, and perform a retrieval in the historical memory bank in combination with the user query data and the retrieval type corresponding to the first target retrieval primitive to obtain the corresponding initial historical state sub-data, wherein the initial historical state sub-data includes at least one target historical memory primitive corresponding to the first target retrieval primitive; (104.2) Determine the next intermediate target retrieval primitive in the target retrieval primitive sequence of the first target retrieval primitive, and search in the historical memory bank in combination with user query data, initial historical state sub-data and retrieval type corresponding to the next intermediate target retrieval primitive to obtain the corresponding intermediate historical state sub-data. Update the intermediate historical state sub-data corresponding to the next intermediate target retrieval primitive according to user query data and intermediate historical state sub-data. (104.3) Repeat the step of updating the intermediate historical state sub-data corresponding to the next intermediate target retrieval primitive based on the user query data and intermediate historical state sub-data until the next intermediate target retrieval primitive is the last target retrieval primitive corresponding to the target retrieval primitive sequence. Then, determine the intermediate historical state sub-data corresponding to the last target retrieval primitive as the historical associated data set corresponding to the target retrieval primitive sequence.
[0097] The first target retrieval primitive can be the first retrieval primitive in the target retrieval primitive sequence, used to perform the initial retrieval operation in the historical memory.
[0098] The initial historical state sub-data can be the first-level evidence state generated after the execution of the first target retrieval primitive, such as a set containing at least one target historical memory primitive, a list of currently visited nodes, and execution logs, which can be used as the input evidence basis for the next intermediate target retrieval primitive.
[0099] Among them, the target historical memory primitive can be the core memory atom that is directly hit from the historical memory bank through the location primitive during the retrieval process, such as a historical record that is directly related to the entity in the query, "the user said in March 2026 that he liked low sugar coffee".
[0100] The next intermediate target retrieval primitive can be the next target retrieval primitive to be executed in sequence after the currently executed primitive.
[0101] Among them, the intermediate historical state sub-data can be a stage evidence state generated after executing a non-first retrieval primitive, which is used as input for subsequent primitives and is continuously updated iteratively as the target retrieval primitive sequence is executed.
[0102] In some implementations, the first primitive in the target retrieval primitive sequence can be extracted as the first target retrieval primitive. Based on its corresponding retrieval type and combined with user query data, a retrieval is performed in the historical memory database to obtain initial historical state sub-data. This initial historical state sub-data contains at least one or more target historical memory primitives directly hit by the first primitive, and may also include metadata (timestamp, source session, entity tag) and an initial confidence score for each primitive. For example, the target retrieval primitive sequence is entity_search→relation_expand→llm_process, and the first primitive is entity_search (entity search primitive). The entities "someone" and "a city" can be extracted from the user query data "Why did someone later stop going to a certain city?". The memory primitive set containing these entities can be located in the historical memory database using entity-atomic indexes, such as "Someone bought a plane ticket to a certain city on March 10, 2026" or "Someone expressed dissatisfaction with the climate of that city on March 15, 2026". These two primitives constitute the initial historical state sub-data, represented as evidence state s1={primitive list, current depth=1, set of visited nodes}.
[0103] Furthermore, after executing the first target retrieval primitive, the next target retrieval primitive can be determined as the next intermediate target retrieval primitive according to the order of the target retrieval primitive sequence. The primitives in the sequence are executed sequentially, with each target retrieval primitive taking the evidence state output by the previous primitive as input. For example, after `entity_search`, the second primitive in the sequence is `relation_expand` (relation expansion primitive), which `ki` marks as the next intermediate target retrieval primitive. If the sequence length is greater than 2, there will be a third, a fourth, and so on, and the system will iteratively process them sequentially.
[0104] Specifically, the current evidence state (i.e., the initial historical state sub-data s1 output by the previous primitive) and the user query data can be used as input, and the historical memory can be searched according to the retrieval type of the next intermediate target retrieval primitive (relation_expand). The relation_expand primitive expands from each target historical memory primitive in s1 along the relation graph (such as causal relationship edges, event chain edges). For example, from "bought a plane ticket to a certain city" along the causal edge to find "checked into a hotel after arriving in a certain city", and then along the subsequent relation to find "cancelled the subsequent trip due to unsuitable weather"; from "expressed dissatisfaction with the climate of the city" along the causal edge to find "planned to go to another city instead". These expanded new target historical memory primitives are merged with the original target historical memory primitives to form the intermediate historical state sub-data s2 = s1 ∪ the primitive chain obtained by expansion. The system also records the expansion path (such as "primitive A → causal edge → primitive B → causal edge → primitive C") to form the initial primitive relation chain. Based on user query data and intermediate historical state sub-data, the system updates the evidence status: for example, if the relation_expand primitive also supports filtering by relevance, then expansion branches unrelated to "no longer planned" can be removed, making s2 more focused.
[0105] In some implementations, the above process can be repeated: taking the current intermediate historical state subdata as input, the next intermediate target retrieval primitive in the sequence is executed. For example, the third primitive in the sequence is `llm_process` (a large language model processing primitive). User query data and `s2` (containing multiple primitives and relational chains) can be input into the large language model, which is then asked to perform evidence filtering, deduplication, or summarization operations. `llm_process` outputs the updated evidence state `s3`, for example, "Extract the causal chain: purchase flight ticket → check-in → inclement weather → cancel trip; and filter out irrelevant chatter primitives." The update rule can be determined by the implementation of the target retrieval primitive: for filtering primitives, `s_new = filter(s_old); for expansion primitives, `s_new = s_old ∪ expand(s_old)`. After each update, the system checks whether the current target retrieval primitive is the last one in the target retrieval primitive sequence.
[0106] In some implementations, the step of "updating the intermediate historical state sub-data corresponding to the next intermediate target retrieval primitive based on user query data and the current evidence state" can be repeated until the last target retrieval primitive in the target retrieval primitive sequence is processed. When the next intermediate target retrieval primitive is the last target retrieval primitive, the intermediate historical state sub-data obtained after execution can be identified as the historical relational data set corresponding to the target retrieval primitive sequence. For example, after three target retrieval primitives, entity_search, relation_expand, and llm_process, the final evidence state s_final includes: target historical memory primitives (initial flight ticket purchase record, weather dissatisfaction record) and a primitive relationship chain composed of multiple relational primitives (purchase flight ticket → check-in → weather discomfort → cancel trip → plan other destinations). This historical relational data set can then be used for subsequent large language model to generate query results.
[0107] In some implementations, in addition to strictly executing target retrieval primitives in sequence, conditional jumps or loop execution mechanisms can be supported to address dynamically changing retrieval needs. Specifically, after each target retrieval primitive is executed, the system can decide whether to terminate the sequence early or jump to a specified primitive based on the quality assessment of the current evidence state (such as recall and relevance scores). For example, after entity_search, if the confidence level of the initial historical state sub-data is higher than a preset confidence threshold, the system can skip subsequent extended class target retrieval primitives and directly jump to llm_process at the end of the sequence to generate the answer, thereby saving execution time. This makes the execution path of retrieval skills more flexible and efficient.
[0108] In this way, a state transfer chain between primitives can be formed, so that the initial state output by the first target retrieval primitive serves as the input for the next primitive, and so on, to achieve iterative updates of the evidence state. In this way, multi-step retrieval operations are linked into a complete and traceable execution process, avoiding evidence breakage or duplication of work caused by independent retrieval of each primitive, and thus providing a coherent construction path for the final output of a historical association data set containing a complete primitive relationship chain.
[0109] In some implementations, the type of the next intermediate target retrieval primitive can be determined: if it is a locating primitive, the operation of directly hitting the target memory primitive from the memory bank is performed; if it is an expansion primitive, a relational primitive relationship chain is generated from the existing anchor points along the relationship graph, thus forming a hierarchical evidence construction pattern of locating first and then expanding. For example, in (104.2), "combining user query data, initial historical state sub-data, and the retrieval type corresponding to the next intermediate target retrieval primitive to perform a retrieval in the historical memory bank to obtain the corresponding intermediate historical state sub-data" can include: (104.2.1) When the retrieval type corresponding to the next intermediate target retrieval primitive is a positioning primitive, the user query data, the initial historical state sub-data and the retrieval type corresponding to the next intermediate target retrieval primitive are combined to search in the historical memory to obtain the corresponding intermediate historical state sub-data. The positioning primitive types include entity search primitives, word literal search primitives and semantic search primitives. (104.2.2) When the retrieval type corresponding to the next intermediate target retrieval primitive is an extended primitive, the user query data, the initial historical state sub-data and the retrieval type corresponding to the next intermediate target retrieval primitive are combined to search in the historical memory bank to obtain the corresponding intermediate historical state sub-data. Among them, the types of extended primitives include time association extended primitives, semantic similarity extended primitives, entity co-occurrence extended primitives and causal relationship extended primitives. The intermediate historical state sub-data includes the initial historical state sub-data and the primitive relationship chain composed of multiple related historical memory primitives.
[0110] Among them, positioning primitives can be a set of retrieval primitives that aim to directly hit target memory primitives, such as entity search primitives, word literal search primitives, and semantic search primitives, which are used to search for entities, keywords, or semantic vectors in user queries.
[0111] Among them, entity search primitives can be a type of entity-driven positioning primitive, such as identifying key entities like people, places, items, and events from user queries.
[0112] Among them, the literal search primitive can be a positioning primitive based on keyword or phrase matching, such as using the BM25 algorithm or an inverted index.
[0113] Among them, semantic retrieval primitives can be a type of localization primitive based on vector similarity. For example, by using a text embedding model, query and historical memory primitives are encoded into vectors respectively, and historical memory primitives that are semantically related but may be different in wording are retrieved based on vector similarity. This is used to query scenarios where the expression is inconsistent with the original memory text but the semantics are similar.
[0114] Among them, extended primitives can be a set of retrieval primitives that aim to obtain the associated context from existing evidence anchors along specific relationships, such as time association extended primitives, semantic similarity extended primitives, entity co-occurrence extended primitives, and causal relationship extended primitives, which are used to extend single-point memory primitives into a relation chain composed of multiple associated primitives.
[0115] Among them, time-related extension primitives can be extension primitives based on time adjacency relationships. For example, based on the timestamp of the retrieved historical memory primitive, other memory primitives that are temporally continuous or close to the original primitive can be retrieved within a specified time window or adjacent session phase to restore the sequence of events, phase changes, or time context.
[0116] Among them, semantic similarity extension primitives can be a type of extension primitive based on semantic vectors. For example, using retrieved historical memory primitives as seeds, other memory primitives with similar themes or contents to the original primitives can be retrieved along the edges of the semantic similarity graph to supplement supporting context and improve evidence coverage.
[0117] Among them, the entity co-occurrence extension primitive can be an extension class primitive based on the co-occurrence relationship of entities. For example, it can be a memory primitive associated with other entities that co-occur with the entity in the same memory primitive or adjacent sessions, based on the entity contained in the retrieved historical memory primitive, in order to discover implicit associations between entities.
[0118] Among them, the causal relationship extension primitive can be an extension class primitive based on the causal or event relationship graph. For example, based on the events or states involved in the retrieved historical memory primitives, other memory primitives that have a causal relationship with the primitives can be retrieved along the edges of the relationship graph with relationship types such as cause, result, cause, and effect, for multi-hop reasoning and causal analysis.
[0119] Among them, historical memory primitives can be atomic-level information units that are segmented and extracted from the long-term interaction history of an agent. For example, a minimum memory fragment containing the text content "the user indicated in March 2026 that he liked low-sugar coffee", metadata and timestamps can be used as the basic storage unit of the historical memory bank and the smallest granular object for retrieval operations.
[0120] Among them, the primitive relation chain can be a serialized evidence path formed by connecting multiple related historical memory primitives in sequence according to specific extension relationships (such as temporal adjacency, semantic similarity, entity co-occurrence or causal relationship). For example, the chain structure formed by extending from "the user buys low-sugar coffee" through temporal adjacency to "the user then buys coffee beans" and then through causal relationship to "the user stops buying instant coffee" is used to provide the coherent context required for multi-hop reasoning.
[0121] In some implementations, when the retrieval type corresponding to the next intermediate target retrieval primitive is a location-based primitive (such as an entity search primitive, a word literal search primitive, or a semantic search primitive), the user query data and the current evidence state (i.e., the initial historical state sub-data) can be combined to perform a query in multiple memory primitives in the historical memory bank.
[0122] Specifically, location-based primitives do not change the existing set of primitives in the evidence state. Instead, based on the user query data and the intermediate historical state sub-data updated after the execution of the previous target retrieval primitive, they retrieve new candidate memory primitives from the historical memory bank and add them to the evidence state, outputting the updated intermediate historical state sub-data. For example, if the user query data is "what coffee someone has bought", and the next target retrieval primitive is an entity search primitive (entity_search), the entities "someone" and "coffee" can be identified from the user query data and the intermediate historical state sub-data. The memory primitive "the user bought a box of low-sugar coffee on March 12, 2026" can be retrieved through the entity-atomic index and added to the evidence state, resulting in the intermediate historical state sub-data. If the next target retrieval primitive is a lexical search primitive (lexical_search), the keywords "buy" and "coffee" can be matched based on the BM25 inverted index to recall literal-related memory primitives. If it is a semantic retrieval primitive (dense_search), the query can be encoded as a vector, and its similarity with the vectors of each primitive in the memory can be calculated to recall primitives that are semantically similar but may be different in literal meaning (such as "the user selected decaffeinated coffee beans"). Regardless of the type of localization primitive, its output intermediate historical state sub-data contains at least one newly recalled target historical memory primitive, and retains the original intermediate historical state sub-data content.
[0123] In some implementations, when the retrieval type corresponding to the next intermediate target retrieval primitive is an extended primitive (such as a time-related extended primitive, a semantic similarity extended primitive, an entity co-occurrence extended primitive, or a causal relationship extended primitive), the neighborhood can be expanded on the corresponding relationship graph of the historical memory bank based on the target historical memory primitives (initial historical state sub-data or intermediate historical state sub-data, corresponding to the latest retrieved and updated state sub-data) already in the current evidence state, generating a primitive relationship chain composed of multiple associated historical memory primitives, and merging this relationship chain with the original historical state sub-data to obtain intermediate historical state sub-data.
[0124] For example, the current historical state subdata already contains the seed primitive "The user purchased a box of low-sugar coffee on March 12, 2026". If the temporal focus expansion primitive (temporal_focus_expand) is executed, it can expand a specified time window (e.g., ±3 days) forward and backward in the temporal adjacency graph based on the timestamp of this primitive (2026-03-12), recalling primitives such as "The user searched for coffee brands on 2026-03-10" and "The user tried low-sugar coffee and expressed satisfaction on 2026-03-15", forming a time series relationship chain. If the semantic similarity expansion primitive (similarity_expand) is executed, it can find other primitives most similar to the seed primitive vector along the semantic similarity graph, such as "The user purchased a sugar-free latte". If the causal relationship expansion primitive (relation_expand) is executed, it can perform multi-hop expansion along the causal edges in the event relationship graph: from "Purchasing low-sugar coffee" along the "Cause" edge to "Lower blood sugar", and then along the "Further" edge to "Stop buying sugary drinks", forming a causal inference chain. All the expanded primitives are connected in the order of expansion to form a primitive relation chain, which together with the initial historical state sub-data forms a new intermediate historical state sub-data, and the next target retrieval primitive is executed starting from the new intermediate historical state sub-data.
[0125] In some implementations, besides expansion based on a pre-defined single relationship graph, a joint expansion strategy involving multi-graph fusion can also be supported. Specifically, the target retrieval primitive type can also include a ComprehensiveExpansion Primitive, which can simultaneously utilize temporal adjacency graphs, semantic similarity graphs, and causal relationship graphs, merging the three types of expansion results according to weights (e.g., temporal expansion weight 0.3, semantic expansion weight 0.3, causal expansion weight 0.4), and then removing duplicates to obtain the final expansion result. Furthermore, the weights of each graph can be dynamically adjusted according to the type of user query: for "when did it happen" type queries, the weight of the temporal graph is increased; for "why" type queries, the weight of the causal graph is increased. Through joint expansion of multiple graphs, evidence omissions from a single view can be effectively avoided, improving the integrity and robustness of the primitive relationship chain.
[0126] By using the above methods, we can ensure the accurate acquisition of core evidence, supplement multi-hop correlation information through relationship chains, and thus provide hierarchical evidence that is both focused and in-depth for the subsequent construction of a complete set of historical correlation data.
[0127] In some implementations, to achieve controllable and configurable multi-hop evidence expansion during the execution of extended primitives, and to avoid contextual redundancy caused by blindly traversing the entire graph or uncontrollable expansion depth, a target relation graph matching the type of the extended primitive can be determined, the anchor point memory primitive's node position in the graph can be located, and the primitive relation chain within a specified range can be extracted by jumping along the graph edges according to a preset number of association hops. This achieves precise and adjustable expansion operations from a single anchor point to a multi-hop relation chain. For example, (104.2.2) may include: (104.2.2.1) When the retrieval type corresponding to the next intermediate target retrieval primitive is an extended class primitive, determine at least one target relation graph corresponding to the next intermediate target retrieval primitive in the historical memory bank, and perform retrieval in the target relation graph based on at least one target historical memory primitive contained in the initial historical state sub-data to determine the position information of at least one target historical memory primitive in the target relation graph; (104.2.2.2) Obtain the preset number of associated hops, combine the location information and the number of associated hops, extract at least one primitive relation chain corresponding to the target historical memory primitive in the target relation graph, and obtain the corresponding intermediate historical state sub-data based on the primitive relation chain.
[0128] The target relation graph can be a specific graph structure selected from multiple relation graphs contained in the historical memory bank, based on the type of the current extended class primitive. For example, when executing a time association extended primitive, a time adjacency graph is selected, and when executing a causal relation extended primitive, a relation graph is selected.
[0129] The location information can be the unique identifier or coordinate information of the target historical memory primitive as a node in the target relationship graph, such as the node number, index value or its storage location in the adjacency list, used to locate the starting node of the expansion operation and determine the set of adjacent nodes and edge connections that can be accessed from that node.
[0130] The number of associated jumps can be a preset positive integer parameter, representing the maximum number of steps to expand along the edges of the relation graph starting from the initial memory primitive node. For example, when the number of jumps is 1, only directly adjacent memory primitives are extracted, and when the number of jumps is 2, associated primitives within a two-hop range can be extracted. This is used to control the expansion depth of the primitive relation chain and the range of the acquired evidence context.
[0131] In some implementations, when the next intermediate target retrieval primitive is an expansion primitive, at least one target relation graph corresponding to it in the historical memory can be determined first based on the semantics of the primitive. Different expansion primitives can correspond to different graph structures: for example, the temporal focus expansion primitive (temporal_focus_expand) corresponds to a temporal adjacency graph, the similarity expansion primitive (similarity_expand) corresponds to a semantic similarity graph, the causal relationship expansion primitive (relation_expand) corresponds to a relation graph (event / causal edge), and the entity co-occurrence expansion primitive (relation_expand) can also correspond to an entity co-occurrence graph. For example, when executing the causal relationship expansion primitive (relation_expand), the system selects the relation graph that stores causal edges such as cause, trigger, and influence as the target relation graph. If a primitive supports multiple expansion methods (such as a comprehensive expansion primitive), multiple target relation graphs can be selected, and subsequent expansion can be performed according to priority or weight.
[0132] In some implementations, based on at least one target historical memory primitive contained in the initial historical state sub-data, node retrieval can be performed in the determined target relationship graph to determine the location information of each primitive in the graph. This location information can be a unique identifier of the node (such as a node ID), the node's index coordinates in the graph, or a pointer to an adjacency list. Specifically, the system uses the memory primitive's ID as the key to search for the corresponding graph node in the node mapping table of the relationship graph. For example, the initial historical state sub-data contains the seed primitive "The user purchased a box of low-sugar coffee on March 12, 2026," whose memory primitive ID is "mem_12345." This ID can be searched in the causal relationship graph to locate node N_12345, and its outgoing edge list, incoming edge list, and edge type (such as "caused" or "subsequent") can be obtained. If the primitive node does not exist in the relationship graph (e.g., the newly generated memory has not yet been graphed), a dynamic graph building operation can be triggered, inserting a new node after calculating the similarity or relationship between the primitive's content and existing nodes.
[0133] Furthermore, a preset number of hops can be obtained to control the maximum number of steps to expand along the graph edges from the starting node. The number of hops can be globally fixed (e.g., default hop count = 2) or dynamically specified by the expansion primitive during execution (e.g., automatically increasing the hop count when parsing keywords such as multi-hop or deep-rooted causes from a user query). For example, with a hop count of 1, only one-hop neighbor nodes directly adjacent to the seed node are extracted; with a hop count of 2, nodes within a two-hop range can be extracted, forming a longer chain of evidence. The role of the number of hops is to balance the scope of evidence coverage and retrieval efficiency: a smaller hop count (e.g., 1) is suitable for accurately locating directly relevant contexts and avoiding the introduction of noise; a larger hop count (e.g., 3 or 4) is suitable for scenarios requiring deep reasoning or multi-step causal tracing. Different hop counts can be set for different expansion primitives, and a maximum hop count limit (e.g., 15) can also be set to prevent infinite recursion from adding too much irrelevant data.
[0134] Furthermore, by combining the location information of the seed node and the preset number of associated hops, a graph traversal algorithm (such as breadth-first search or depth-first search) can be executed in the target relationship graph to extract all reachable nodes starting from the seed node with a step size not exceeding the number of associated hops, and arrange them in traversal order to form a primitive relationship chain. For example, seed node N_12345 (buy low-sugar coffee) has an outgoing edge pointing to N_12346 (blood sugar decreases) in the causal relationship graph, and N_12346 has an outgoing edge pointing to N_12347 (stop buying sugary drinks). When the number of associated hops is 2, the extracted relationship chain is: N_12345→N_12346→N_12347, and the corresponding memory primitive texts are "buy low-sugar coffee", "blood sugar decreases", and "stop buying sugary drinks" respectively. Afterwards, this primitive relationship chain can be merged with the original primitives in the initial historical state sub-data (after deduplication) to form the updated intermediate historical state sub-data.
[0135] In some implementations, if multiple target relationship graphs are involved (such as using both temporal and causal graphs simultaneously), the relationship chains of each graph can be extracted separately, and then merged according to weights or intersections to form a multi-perspective composite relationship chain. Ultimately, the intermediate historical state sub-data contains both the initial seed memory primitives and the multi-hop association primitive sequences obtained through graph expansion, providing a structured evidence path for subsequent large language model answer generation.
[0136] The above methods enable the precise extraction of the relationship chain from a single memory primitive to a primitive at a specified depth. This avoids the high computational overhead of full-graph retrieval and ensures the flexible configurability of the extended depth. In turn, it provides a well-structured and controllable chain of evidence for intermediate historical state sub-data, supporting subsequent multi-hop reasoning and causal analysis.
[0137] Step 105: Generate corresponding query results based on user query data and historical related data set using a large language model.
[0138] In some implementations, user queries and evidence views can be fed into a large language model to leverage its semantic understanding and text generation capabilities to produce a coherent and accurate final response.
[0139] Among them, large language models can be deep neural network generative models pre-trained on large-scale corpora, such as GPT series models, Llama series models, etc.
[0140] The query results can be natural language response text or structured output generated by the large language model based on user query data and historical related data sets. For example, for the query "What gift did someone buy on a trip?", the output would be "The user bought a box of low-sugar coffee on a trip in March 2026".
[0141] In some implementations, a prompt template containing system instructions and context can be constructed based on historical association datasets and user query data. For example: "Please answer the user's question based on the following historical memory evidence. Evidence: {historical association dataset}. Question: {user query data}. Requirements: The answer should be concise and accurate, prioritizing key information from the evidence." After receiving this prompt, the large language model can output the answer through an autoregressive generation method. For example, if the user query is "Why did someone later stop going to a certain city?", and the historical association dataset contains a primitive relationship chain: "Purchase flight → Check into hotel → Weather discomfort → Cancel trip", the large language model generates: "The reason this user stopped going to a certain city is that they experienced weather discomfort during their trip, leading them to cancel their subsequent trip."
[0142] This application embodiment acquires user query data; through a preset retrieval routing model, based on the user query data and each preset retrieval primitive sequence, outputs the selection probability for each retrieval primitive sequence; wherein, the retrieval primitive sequence includes retrieval primitives of retrieval types of memory primitive retrieval and associated context retrieval; based on the selection probability of each retrieval primitive sequence, a target retrieval primitive sequence is selected from multiple preset retrieval primitive sequences; for each target retrieval primitive in the target retrieval primitive sequence, the user query data is sequentially combined, and a retrieval is performed in the historical memory bank according to the corresponding retrieval type to obtain the historical associated data set corresponding to the target retrieval primitive sequence, the historical associated data set including at least one target historical memory primitive and a primitive relation chain composed of multiple associated historical memory primitives; wherein, the historical memory bank includes multiple historical memory primitives and multiple relation graphs, the relation graphs are used to provide the association relationship between at least two corresponding historical memory primitives during the context retrieval process; through a large language model, corresponding query results are generated based on the user query data and the historical associated data set. This allows for the dynamic selection of the most suitable multi-step retrieval path for the current query, and the execution of sequential primitives guided by the relationship graph enables the cross-node, multi-hop association of scattered evidence, thereby fully capturing the causal relationships, event chains, or multi-step evidence implicit in complex queries. Specifically, compared to the prior art which relies solely on keyword matching and can only recall isolated fragments containing specific terms, the retrieval routing model of this application does not employ a fixed strategy. Instead, it adaptively selects different sequences of retrieval primitives for each query, allowing the retrieval behavior to adjust according to changes in the information requirements of the query. Simultaneously, because multiple relationship graphs are pre-constructed in the historical memory bank, and there is a clear mapping relationship between retrieval primitives and memory primitives, when the target primitive sequence is executed sequentially, it can start from the initial memory primitive and expand along the structured edges of the relationship graph, successively locating multiple memory primitives that are logically related but literally mismatched, thus linking scattered evidence into a complete chain of evidence. In summary, this application can improve the relevance and accuracy of data queries based on large-model intelligent agents.
[0143] In some implementations, to avoid the risk of deployment instability caused by directly deploying new skills, the initial retrieval primitive sequence can be periodically (e.g., every 1 day, every 5 days, etc.) for performance screening and primitive reconstruction to generate candidate sequences. A dual-front mechanism (capability front for retaining non-redundant retrieval capabilities, deployment front for stable online inference) can be used to decouple capability exploration from deployment, thereby achieving automated expansion and controllable evolution of the retrieval skill set, continuously optimizing to obtain the optimal retrieval primitive sequence. For example, a data query method based on a large model agent may also include: (B.1) Obtain multiple initial retrieval primitive sequences, and for each initial retrieval primitive in each initial retrieval primitive sequence, sequentially combine it with the preset first sample query data, and search in the historical memory according to the corresponding query type to obtain the first associated data set corresponding to each initial primitive sequence; (B.2) Using a large language model, generate corresponding predicted query results based on the first sample query data and the first associated data set; (B.3) Obtain the first retrieval score of the predicted query result corresponding to each initial retrieval primitive sequence, and when the first retrieval score is greater than the preset retention threshold, determine the initial retrieval primitive sequence as the intermediate retrieval primitive sequence; (B.4) For each intermediate retrieval primitive sequence, primitive reconstruction is performed to generate at least one candidate retrieval primitive sequence, wherein each candidate retrieval primitive sequence is different from any historical retrieval primitive sequence; (B.5) Obtain the second associated data set retrieved by each candidate retrieval primitive sequence for each preset second sample query data, and generate the second retrieval score of each candidate retrieval primitive sequence on each second sample query data based on the second associated data set; (B.6) When a target candidate retrieval primitive sequence has a second retrieval score on at least one second sample query data that is higher than the scores of all capable retrieval primitive sequences on the same second sample query data in the preset capability frontier, the target candidate retrieval primitive sequence is added to the capability frontier. (B.7) Calculate the first performance score of each capability retrieval primitive sequence in the capability frontier, and add the target capability retrieval primitive sequence as a retrieval primitive sequence to the deployment frontier when the first performance score of the target capability retrieval primitive sequence in the capability frontier is greater than the second performance score of at least one retrieval primitive sequence in the deployment frontier.
[0144] The initial retrieval primitive sequence can be a basic retrieval procedure, such as a sequence containing only a single semantic retrieval primitive, a sequence containing a single entity search primitive, or a sequence containing a single word literal retrieval primitive.
[0145] The predicted query result can be the answer text generated by a large language model based on the first sample query data and the first set of related data.
[0146] The first retrieval score can be a numerical value obtained by quantitatively evaluating the predicted query results, such as a score calculated through rule matching, large language model review, or similarity with the labeled answer.
[0147] The retention threshold can be a preset numerical boundary point, such as 0.6 or 0.7, used to filter out qualified retrieval primitive sequences: when the first retrieval score is greater than the threshold, the corresponding initial retrieval primitive sequence is retained as an intermediate retrieval primitive sequence, otherwise it is discarded.
[0148] Among them, the intermediate retrieval primitive sequence can be a basic skill sequence that meets the performance standards and is retained after the initial retrieval primitive sequence has been filtered by the first retrieval score.
[0149] Among them, the candidate retrieval primitive sequence can be a new skill sequence that is different from all previously explored retrieval primitive sequences, generated by performing primitive reconstruction operations (such as adding primitives, replacing primitives, deleting redundant primitives, or adjusting their order) on the intermediate retrieval primitive sequence.
[0150] The second sample query data can be a query example selected from another query set that is different from the first sample query data, used to evaluate the generalization performance of the candidate retrieval primitive sequence.
[0151] The second associated data set can be a view of historical associated evidence retrieved from the historical memory bank after executing a candidate retrieval primitive sequence on the second sample query data.
[0152] The second retrieval score can be a score obtained by quantitatively evaluating the query results of a candidate retrieval primitive sequence after it has been executed on a certain second sample query data.
[0153] The capability frontier can be a data structure used to store a set of skills that contribute non-redundant retrieval capabilities. The sequence of capability retrieval primitives in the capability frontier collectively guarantees that, for any query, at least one skill in the capability frontier can achieve the best performance currently explored.
[0154] Among them, the capability retrieval primitive sequence can be a retrieval skill contained in the capability frontier that has been verified to have a unique capability contribution.
[0155] The first performance score can be a comprehensive score obtained by evaluating each capability retrieval primitive sequence in the capability frontier on the validation query set, such as the average retrieval score or weighted score on multiple validation queries.
[0156] Among them, the target capability retrieval primitive sequence can be a skill sequence in the capability frontier whose first performance score is greater than the second performance score of at least one retrieval primitive sequence in the deployment frontier.
[0157] The second performance score can be a comprehensive score obtained by evaluating each retrieval primitive sequence in the deployment frontier on the validation query set.
[0158] In this context, the deployment frontier can be a stable, router-verified set of skills for online inference.
[0159] In some implementations, multiple initial search primitive sequences can be obtained, such as three seed skills: a sequence containing only semantic search primitives (dense_search), a sequence containing only entity search primitives (entity_search), and a sequence containing only lexical search primitives (lexical_search). For each initial search primitive sequence, each initial search primitive can be executed sequentially, and combined with preset first sample query data (such as "what coffee did someone buy"), a search can be performed in the historical memory database to obtain a first set of associated data corresponding to each sequence.
[0160] Furthermore, the first sample query data and the first associated data set corresponding to each initial retrieval primitive sequence can be input into the large language model to generate corresponding predicted query results. For example, inputting "What coffee did someone buy?" and "The user selected decaffeinated coffee beans" will result in the large language model outputting "The user bought decaffeinated coffee beans". The predicted query results for each sequence are recorded for subsequent scoring.
[0161] Furthermore, the predicted query results for each initial retrieval primitive sequence can be quantitatively scored to obtain a first retrieval score. The score can be based on semantic similarity to the standard answer or by a large language model review. For example, if the standard answer is "low-sugar coffee," then the score for the entity_search sequence is 0.95, the score for the dense_search sequence is 0.65, and the score for the lexical_search sequence is 0.30. A preset retention threshold of 0.6 is set; sequences with a first retrieval score greater than 0.6 (entity_search and dense_search) are identified as intermediate retrieval primitive sequences. Sequences with scores below the threshold (lexical_search) are discarded. Discarded retrieval primitive sequences can be recorded in the rejection branch of the empirical Trie to avoid subsequent repeated exploration.
[0162] In some implementations, for each intermediate retrieval primitive sequence, at least one candidate retrieval primitive sequence can be generated through primitive reconstruction operations. Reconstruction methods can include: adding primitives (e.g., adding `llm_process` to the end of the sequence), replacing primitives (e.g., replacing `dense_search` with `similarity_expand`), deleting redundant primitives, or adjusting the primitive order. For example, for the `entity_search` sequence, adding `relation_expand` yields the new sequence `[entity_search,relation_expand]`. Before reconstruction, an experience Trie can be queried; if a candidate path has already been explored (whether successfully or unsuccessfully), that candidate is skipped, ensuring that each candidate retrieval primitive sequence is distinct from any historical retrieval primitive sequence.
[0163] In some implementations, multiple pre-defined second sample query data sets (with different distributions than the first sample query data sets, such as those containing time-based causal reasoning questions) can be obtained. For each candidate retrieval primitive sequence, a retrieval is performed to obtain a second set of related data. Then, an answer is generated using a large language model, and a second retrieval score is calculated for each candidate retrieval primitive sequence on each second sample query data set. For example, the candidate retrieval primitive sequence [entity_search,relation_expand] scores 0.85 on the query "Why did you stop planning to travel later?" and 0.70 on the query "When to buy coffee?". All scores are summarized and recorded.
[0164] In some implementations, the system can maintain a capability frontier, which initially may contain intermediate retrieval primitive sequences whose first retrieval score is greater than a retention threshold from the initial retrieval primitive sequence. For each candidate retrieval primitive sequence, if there exists at least one second sample query data such that the second retrieval score of the candidate retrieval primitive sequence on that second sample query data is higher than the scores of all capability retrieval primitive sequences in the current capability frontier on the same second sample query data, then the candidate retrieval primitive sequence is identified as a target candidate retrieval primitive sequence and directly added to the capability frontier. For example, if the candidate [entity_search,relation_expand] scores 0.85 on a causal inference query, while the highest score in the current capability frontier is 0.70, then the candidate is added to the capability frontier. Simultaneously, an experience Trie records the successful path.
[0165] In some implementations, the system can maintain a deployment front, which initially contains one or more sequences with the highest first retrieval scores among the initial retrieval primitive sequences, for online inference. First, a first performance score and a second performance score can be calculated for each capability retrieval primitive sequence in the capability front. Both the first and second performance scores are calculated based on a validation query set: the query results generated after executing each retrieval primitive sequence on the validation query set are compared with sample labels to obtain a comprehensive score for each sequence (e.g., average semantic similarity). The first performance score reflects the ability of the skill to generate original retrieval without routing intervention in the capability front, and the second performance score reflects the corresponding ability of the skill in the deployment front. Subsequently, if a target capability retrieval primitive sequence exists in the capability front, and its first performance score is greater than the second performance score of at least one retrieval primitive sequence in the deployment front, then the target capability retrieval primitive sequence is added to the deployment front as a retrieval primitive sequence. For example, if the deployment frontier already contains skills A (second performance score 0.75) and B (second performance score 0.70), and the capability frontier has a new skill C with a first performance score of 0.80, which is greater than skill B's second performance score of 0.70, then skill C is added to the deployment frontier. Optionally, to maintain the stability of the deployment frontier size, the system can simultaneously remove the retrieval primitive sequence with the lowest second performance score from the deployment frontier. If the first performance score of all skills in the capability frontier is not greater than the second performance score of any skill in the deployment frontier, then the deployment frontier remains unchanged.
[0166] By using the above methods, basic skills that meet the performance standards can be automatically selected from the initial seed skills, and new candidate skills can be continuously generated through primitive reconstruction. In this way, the capability frontier is used as an exploration space to retain diverse skills with non-redundant retrieval capabilities. Then, by directly comparing the first performance score and the second performance score, skills that are superior to the current deployment are selectively added to the deployment frontier, thereby realizing the continuous self-evolution of retrieval skills. At the same time, it avoids the routing instability risk caused by the direct deployment of new skills, and provides a skill management mechanism that is both scalable and reliable for online inference systems.
[0167] In some implementations, to balance performance improvement and skill complexity at the deployment front during skill evolution, and to avoid introducing redundant or inefficient skills in the pursuit of performance gains, the score difference between candidate skills in the capability front and the lowest-performing skill in the deployment front can be compared on the validation query set. A dual judgment is made based on the gain threshold and the sequence length difference: if the performance gain is sufficient, the skill is directly replaced; if the performance gain is insufficient but the skill is more compact, replacement is also allowed. This achieves the goal of maintaining the conciseness and stability of the skill set while ensuring or improving deployment performance. For example, (B.7) may include: (B.7.1) Execute each capability retrieval primitive sequence contained in the current capability frontier and each retrieval primitive sequence contained in the deployment frontier using the preset verification query set; (B.7.2) Calculate the first performance score of each capability retrieval primitive sequence based on the difference between each first query result generated on the validation query set and the sample label for each capability retrieval primitive sequence, and calculate the second performance score of each capability retrieval primitive sequence based on the difference between each second query result generated on the validation query set and the sample label for each retrieval primitive sequence. (B.7.3) Identify the benchmark retrieval primitive sequence with the second lowest performance score in the deployment frontier; (B.7.4) When the difference between the first performance score of the target capability retrieval primitive sequence and the second benchmark performance score of the benchmark retrieval primitive sequence in the capability frontier is greater than or equal to a preset gain threshold, the target capability retrieval primitive sequence is added to the deployment frontier as a retrieval primitive sequence, and the benchmark retrieval primitive sequence is removed from the deployment frontier. Alternatively, when the difference between the first performance score of the target capability retrieval primitive sequence and the second benchmark performance score of the benchmark retrieval primitive sequence in the capability frontier is less than or equal to the gain threshold, the sequence length difference between the target capability retrieval primitive sequence and the benchmark retrieval primitive sequence is calculated. When the sequence length difference is less than a preset value, the target capability retrieval primitive sequence is added to the deployment frontier as a retrieval primitive sequence, and the benchmark retrieval primitive sequence is removed from the deployment frontier.
[0168] The validation query set can be a set of query examples reserved from labeled data or historical query logs for unbiased evaluation of the performance of retrieval primitive sequences.
[0169] The first query result can be the response text generated by a large language model after executing a sequence of primitives for a certain capability in the capability frontier on the validation query set.
[0170] The sample labels can be the standard answer or expected output corresponding to each query in the validation query set, such as manually labeled correct answers or validated benchmark answers.
[0171] The second query result can be the response text generated by a large language model after executing a certain retrieval primitive sequence in the deployment frontier on the validation query set.
[0172] Among them, the benchmark retrieval primitive sequence can be the retrieval skill sequence with the second lowest performance score in the current deployment frontier, such as the deployed skill with the worst overall performance on the validation query set.
[0173] The gain threshold can be a preset performance improvement tolerance parameter, such as 0.05 or 0.1, which represents the minimum performance improvement that the candidate skill needs to achieve compared to the baseline sequence.
[0174] The sequence length difference can be the algebraic difference between the number of primitives in the target capability retrieval primitive sequence and the number of primitives in the benchmark retrieval primitive sequence.
[0175] The preset value can be a fixed integer threshold for comparing the difference in sequence lengths, such as 0 or 1. When the difference in sequence lengths is less than this value (for example, less than 0 means the candidate sequence is shorter, or less than or equal to -1 means it is at least one primitive shorter), the candidate skill is considered to have an advantage in complexity, and thus the more concise skill is preferred when the performance is similar.
[0176] In some implementations, a pre-defined validation query set can be obtained. This set contains multiple query data samples with sample labels (standard answers), covering different types such as entity localization, temporal causal reasoning, and multi-hop relationship tracking. For each query data in the validation query set, each capability retrieval primitive sequence contained in the current capability frontier, as well as each retrieval primitive sequence contained in the current deployment frontier, can be executed. During execution, each retrieval primitive sequence can be retrieved in the historical memory according to its primitive order and generate an evidence view, and then the corresponding query results are output by calling the large language model.
[0177] Specifically, query results generated by skills in the capability frontier are called first query results, and query results generated by skills in the deployment frontier are called second query results. For example, if the validation query set contains the query Q1 "Why does someone no longer go to a certain city?", the capability frontier contains skill C1 (entity_search→relation_expand), and the deployment frontier contains skill D1 (dense_search→temporal_focus_expand). The system runs C1 and D1 respectively, recording the first query result generated by C1 and the second query result generated by D1.
[0178] Furthermore, the first query results generated by each capability retrieval primitive sequence on the validation query set can be compared with the corresponding sample labels to obtain the first performance score for each capability retrieval primitive sequence. The comparison can be performed using methods such as semantic similarity, exact match rate, or large language model evaluation scoring. For example, if the similarity between the first query result of skill C1 and the sample label is 0.85 on Q1, 0.90 on Q2, and 0.75 on Q3, then the average score of 0.83 is calculated as the first performance score for C1. Simultaneously, the second performance score for each retrieval primitive sequence can be calculated based on the differences between the second query results generated by each retrieval primitive sequence on the validation query set in each deployment frontier and the sample labels. For example, if the similarity between skill D1 and the sample labels is 0.70 on Q1, 0.65 on Q2, and 0.80 on Q3, then the average score of 0.72 is calculated as the second performance score for D1. The first and second performance scores reflect the original retrieval generation capability of each skill without routing intervention.
[0179] Furthermore, from all the retrieval primitive sequences contained in the current deployment frontier, the retrieval primitive sequence with the lowest second performance score can be identified and designated as the benchmark retrieval primitive sequence, and its benchmark second performance score can be recorded. For example, if the deployment frontier contains skills D1 (score 0.72), D2 (score 0.68), and D3 (score 0.60), then the one with the lowest second performance score is D3, and its benchmark second performance score is 0.60.
[0180] In some implementations, it can be determined whether there is a target capability retrieval primitive sequence in the capability frontier, such that the difference between the first performance score of the target capability retrieval primitive sequence and the benchmark second performance score satisfies a preset condition.
[0181] For example, in cases where the performance gain reaches or exceeds the threshold: if a target capability retrieval primitive sequence exists (e.g., C1, with a first performance score of 0.83), the difference between it and the baseline second performance score (0.60) is calculated to be 0.23. The preset gain threshold is 0.05. Since 0.23 ≥ 0.05, C1 can be added to the deployment frontier as a retrieval primitive sequence, and the baseline retrieval primitive sequence D3 can be removed from the deployment frontier. The updated deployment frontier includes D1, D2, and C1.
[0182] For example, in the case of insufficient performance gain but shorter sequences, if a target capability retrieval primitive sequence exists (e.g., C2, with a first performance score of 0.62), its difference from the benchmark second performance score (0.60) is 0.02, which is less than or equal to the gain threshold of 0.05. In this case, the system calculates the sequence length difference: sequence length refers to the number of primitives contained in the retrieval primitive sequence. The length of the benchmark sequence D3 is 4 (e.g., entity_search→similarity_expand→relation_expand→llm_process), and the length of the target sequence C2 is 2 (e.g., entity_search→relation_expand), resulting in a sequence length difference of 2. 4= 2. The preset value is 0 (i.e., the target sequence length is required to be less than the reference sequence length). Because... If 2 < 0, the system adds C2 to the deployment front and removes the baseline sequence D3, thus replacing the redundant skill with a more streamlined one. If the sequence length difference is not less than a preset value (e.g., the target sequence is not shorter), no replacement is performed.
[0183] For example, in other cases: if the first performance score of all skills in the capability frontier is lower than or equal to the baseline second performance score, and there are no more streamlined alternative skills, then the deployment frontier remains unchanged.
[0184] The above methods enable unbiased evaluation of skills in the capability frontier and deployment frontier based on the validation query set. Gain thresholds ensure that skills with significant performance improvements can enter the deployment frontier. At the same time, when the performance gain is insufficient, sequence length difference judgment is introduced to allow more concise skills to replace redundant old skills. This achieves the goal of maintaining or improving skill performance while taking into account the simplicity of the skill set and execution efficiency in the deployment frontier.
[0185] Please refer to Figure 3 The following is combined with Figure 3 In some implementation methods, the overall process of the embodiments of this application is described.
[0186] Specifically, the long-term interaction history between an agent and a user or external environment can be compiled into structured memory. More specifically, the original interaction history can be segmented into atomic-level memory records, each containing at least text, metadata, and a timestamp. Based on this, various indexes and graph structures are constructed: including vector embeddings for semantic retrieval, BM25 indexes for word literal matching, entity-memory primitive mappings for entity localization, as well as temporal adjacency graphs, semantic similarity graphs, and relational graphs (event / causal edges). These indexes and graphs collectively constitute the memory access foundation, providing subsequent retrieval primitives with entity search, word literal search, semantic search, and multi-dimensional expansion capabilities including time, semantics, and relationships.
[0187] Furthermore, in the online inference phase, after acquiring the user query data, a pre-trained retrieval routing model can be invoked. This model can select the most suitable retrieval primitive sequence from the set of retrieval primitive sequences (i.e., the set of deployment frontier skills) based on the query requirements. Each retrieval primitive sequence is an executable program composed of multiple retrieval primitives in sequence. For example, first, the entity search primitive is executed to locate relevant memory atoms, then the relation expansion primitive is executed to obtain multi-hop evidence chains along causal edges, and finally, the primitives are processed by the large language model for evidence filtering or summarization. After selecting the target retrieval primitive sequence, each target retrieval primitive in the target retrieval primitive sequence can be executed sequentially. Each execution updates the current evidence state, ultimately obtaining a historical association data set containing target historical memory primitives and primitive relation chains. Subsequently, the user query data and this historical association data set are input into the large language model to generate corresponding query results and return them to the user.
[0188] In some implementations, skill-router co-evolution can be performed in offline or periodic background tasks. Specifically, an experience Trie (prefix tree) can be maintained to record explored primitive paths, success / failure patterns, and execution trajectories; simultaneously, two frontiers can be maintained—a capability frontier to retain a set of skills with non-redundant retrieval capabilities, and a deployment frontier to store a stable set of skills validated by the router (i.e., a set of retrieval primitive sequences used for online inference). During initialization, the capability frontier and deployment frontier can contain seed skills with only a single retrieval primitive, such as semantic retrieval primitives, entity search primitives, or literal search primitives.
[0189] Furthermore, the evolutionary process may include: for each query on the training batch, executing all skills in the capability frontier, recording the execution trajectory (Per-Skill Rollouts on Train Batch) and performance score of each skill; a candidate skill generator, based on the current skill summary, failure examples, successful paths, and statistical information read from the experience Trie, generates candidate retrieval primitive sequences by adding, replacing, or rearranging primitives, and excluding explored duplicate paths. For each candidate retrieval primitive sequence, its second retrieval score can be evaluated on the second sample query data: if there exists at least one query that makes the score of the candidate retrieval primitive sequence higher than the scores of all skills in the current capability frontier on the same query (i.e., the candidate survives on the training batch), then the candidate is added to the capability frontier, and the frontier recalculation operator Phi is executed to prune redundant skills. Subsequently, the first performance score of each skill in the capability frontier and the second performance score of each skill in the deployment frontier can be calculated based on the validation query set, and the post-routing performance can be evaluated by the execution trajectory of the router on the deployment validation set. If a target skill exists in the capability front, and its first performance score is greater than the second performance score of at least one skill in the deployment front, or if the candidate deployment front shows improved or maintained performance after routing relative to the current deployment front and the skill set does not expand, then the candidate skill is accepted to join the deployment front, and the lowest-performing skill in the deployment front may be removed. The acceptance or rejection results are written back to the experience Trie to achieve continuous updates of the dual fronts.
[0190] Through the above mechanism, the system achieves self-evolution of retrieval skills: the capability frontier continuously explores new combinations of retrieval procedures, while the deployment frontier verifies the skills to ensure their stability and reliability. Throughout the process, the experience Trie avoids repeatedly exploring invalid paths, and soft-label cross-entropy is used to train the router to accurately select the appropriate retrieval primitive sequence based on query requirements, thereby continuously improving the adaptability of memory retrieval and the quality of answer generation in long-term interaction scenarios.
[0191] Please see Figure 4 This application also provides a data query device based on a large model intelligent agent, which can implement the above-mentioned data query method based on a large model intelligent agent. The data query device based on a large model intelligent agent includes: Module 41 is used to retrieve user query data; Output module 42 is used to output the selection probability for each search primitive sequence based on user query data and each preset search primitive sequence through a preset search routing model. Among them, the retrieval primitive sequence includes retrieval primitives of retrieval types such as memory primitive retrieval and associated context retrieval; The selection module 43 is used to select a target retrieval primitive sequence from multiple preset retrieval primitive sequences based on the selection probability of each retrieval primitive sequence; The retrieval module 44 is used to sequentially combine user query data with each target retrieval primitive in the target retrieval primitive sequence and search in the historical memory bank according to the corresponding retrieval type to obtain the historical associated data set corresponding to the target retrieval primitive sequence. The historical associated data set includes at least one target historical memory primitive and a primitive relationship chain composed of multiple associated historical memory primitives. The historical memory bank contains multiple historical memory primitives and multiple relationship graphs. The relationship graphs are used to provide the association between at least two corresponding historical memory primitives during the contextual retrieval process. The generation module 45 is used to generate corresponding query results based on user query data and historical related data sets through a large language model.
[0192] The specific implementation of the data query device based on large model intelligent agents is basically the same as the specific embodiment of the data query method based on large model intelligent agents described above, and will not be repeated here. Subject to meeting the requirements of the embodiments of this application, the data query device based on large model intelligent agents may also be equipped with other functional modules to implement the data query method based on large model intelligent agents in the above embodiments.
[0193] This application also provides a computer device, which includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the aforementioned data query method based on a large model intelligent agent. This computer device can be any intelligent terminal, including tablet computers, in-vehicle computers, etc.
[0194] Please see Figure 5 , Figure 5 The hardware structure of a computer device according to another embodiment is illustrated. The computer device includes: The processor 51 can be implemented using a general-purpose CPU (Central Processing Unit), microprocessor, application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of this application. The memory 52 can be implemented as a read-only memory (ROM), static storage device, dynamic storage device, or random access memory (RAM). The memory 52 can store the operating system and other applications. When the technical solutions provided in the embodiments of this specification are implemented through software or firmware, the relevant program code is stored in the memory 52 and called and executed by the processor 51 using the data query method based on a large model intelligent agent according to the embodiments of this application. Input / output interface 53 is used to implement information input and output; The communication interface 54 is used to enable communication and interaction between this device and other devices. Communication can be achieved through wired means (such as USB, network cable, etc.) or wireless means (such as mobile network, WIFI, Bluetooth, etc.). Bus 55 transmits information between various components of the device (e.g., processor 51, memory 52, input / output interface 53, and communication interface 54); The processor 51, memory 52, input / output interface 53, and communication interface 54 are connected to each other within the device via bus 55.
[0195] This application also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the above-described data query method based on a large model intelligent agent.
[0196] Memory, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs and non-transitory computer-executable programs. Furthermore, memory may include high-speed random access memory, and may also include non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid-state storage device. In some embodiments, memory may optionally include memory remotely located relative to the processor, and these remote memories can be connected to the processor via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.
[0197] The embodiments described in this application are for the purpose of more clearly illustrating the technical solutions of the embodiments of this application, and do not constitute a limitation on the technical solutions provided by the embodiments of this application. As those skilled in the art will know, with the evolution of technology and the emergence of new application scenarios, the technical solutions provided by the embodiments of this application are also applicable to similar technical problems.
[0198] Those skilled in the art will understand that the technical solutions shown in the figures do not constitute a limitation on the embodiments of this application, and may include more or fewer steps than shown, or combine certain steps, or different steps.
[0199] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.
[0200] Those skilled in the art will understand that all or some of the steps in the methods disclosed above, as well as the functional modules / units in the systems and devices, can be implemented as software, firmware, hardware, or suitable combinations thereof.
[0201] The terms “first,” “second,” “third,” “fourth,” etc. (if present) in the specification and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms “comprising” and “having,” and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0202] It should be understood that in this application, "at least one" and "several" refer to one or more, and "multiple" refers to two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, "A and / or B" can represent three cases: only A exists, only B exists, and both A and B exist simultaneously, where A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. "At least one of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one of a, b, or c can represent: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, and c can be single or multiple.
[0203] In the embodiments provided in this application, it should be understood that the disclosed systems and methods can be implemented in other ways. For example, the system embodiments described above are merely illustrative; for instance, the division of the units described above is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interfaces, devices, or units, and may be electrical, mechanical, or other forms.
[0204] The units described above as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0205] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0206] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes multiple instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned storage medium includes various media capable of storing programs, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0207] The preferred embodiments of the present application have been described above with reference to the accompanying drawings, but this does not limit the scope of the claims of the present application. Any modifications, equivalent substitutions, and improvements made by those skilled in the art without departing from the scope and substance of the embodiments of the present application shall be within the scope of the claims of the present application.
Claims
1. A data query method based on a large model intelligent agent, characterized in that, The method includes: Obtain user query data; Based on the user query data and each preset retrieval primitive sequence, the selection probability for each retrieval primitive sequence is output using a preset retrieval routing model. The retrieval primitive sequence includes retrieval primitives of retrieval types such as memory primitive retrieval and contextual retrieval; Based on the selection probability of each retrieval primitive sequence, the target retrieval primitive sequence is selected from multiple preset retrieval primitive sequences; For each target retrieval primitive in the target retrieval primitive sequence, the user query data is sequentially combined with the corresponding retrieval type to retrieve data from the historical memory bank, thereby obtaining the historical association data set corresponding to the target retrieval primitive sequence. The historical association data set includes at least one target historical memory primitive and a primitive relationship chain composed of multiple associated historical memory primitives. The historical memory bank contains multiple historical memory primitives and multiple relationship graphs, wherein the relationship graphs are used to provide the association between at least two corresponding historical memory primitives during the context retrieval process; Using a large language model, corresponding query results are generated based on the user query data and the historical associated data set.
2. The data query method based on a large model intelligent agent according to claim 1, characterized in that, The retrieval routing model is trained in the following way: Obtain sample query data, and input the sample query data and a preset sample retrieval primitive sequence into a preset retrieval routing model to obtain the predicted selection probability corresponding to each sample retrieval primitive sequence; Based on the retrieval primitive sequence of each sample and the sample query data, a retrieval is performed in the historical memory to obtain the predicted association data set corresponding to each sample retrieval primitive sequence; For each sample, the primitive sequence is retrieved, and the sample query data and the corresponding prediction association data set are input into the large language model to obtain the corresponding prediction query result. The predicted query result corresponding to the retrieval primitive sequence for each sample is scored to obtain the corresponding predicted query result score; Based on the predicted query result score corresponding to each sample retrieval primitive sequence, the reference selection probability corresponding to each sample retrieval primitive sequence is mapped to the result. The target loss is calculated based on the difference between the predicted selection probability and the reference selection probability corresponding to each sample retrieval primitive sequence; Based on the target loss, the preset retrieval routing model is trained to obtain the retrieval routing model.
3. The data query method based on a large model intelligent agent according to claim 1, characterized in that, For each target retrieval primitive in the target retrieval primitive sequence, the user query data is sequentially combined with the data, and a search is performed in the historical memory database according to the corresponding retrieval type to obtain the historical associated data set corresponding to the target retrieval primitive sequence, including: The first target retrieval primitive contained in the target retrieval primitive sequence is determined, and a retrieval is performed in the historical memory bank in combination with the user query data and the retrieval type corresponding to the first target retrieval primitive to obtain the corresponding initial historical state sub-data. The initial historical state sub-data includes at least one target historical memory primitive corresponding to the first target retrieval primitive. The next intermediate target retrieval primitive in the target retrieval primitive sequence is determined by the first target retrieval primitive. The user query data, the initial historical state sub-data, and the retrieval type corresponding to the next intermediate target retrieval primitive are combined to search the historical memory to obtain the corresponding intermediate historical state sub-data. The intermediate historical state sub-data corresponding to the next intermediate target retrieval primitive is updated according to the user query data and the intermediate historical state sub-data. Repeat the step of updating the intermediate historical state sub-data corresponding to the next intermediate target retrieval primitive based on the user query data and the intermediate historical state sub-data, until the next intermediate target retrieval primitive is the last target retrieval primitive corresponding to the target retrieval primitive sequence, and determine the intermediate historical state sub-data corresponding to the last target retrieval primitive as the historical associated data set corresponding to the target retrieval primitive sequence.
4. The data query method based on a large model intelligent agent according to claim 3, characterized in that, The process involves combining the user query data, the initial historical state sub-data, and the retrieval type corresponding to the next intermediate target retrieval primitive to search the historical memory database, obtaining the corresponding intermediate historical state sub-data, including: When the retrieval type corresponding to the next intermediate target retrieval primitive is a positioning primitive, the user query data, the initial historical state sub-data, and the retrieval type corresponding to the next intermediate target retrieval primitive are combined to search the historical memory to obtain the corresponding intermediate historical state sub-data. The positioning primitive types include entity search primitives, word literal search primitives, and semantic search primitives. When the retrieval type corresponding to the next intermediate target retrieval primitive is an extended primitive, the user query data, the initial historical state sub-data, and the retrieval type corresponding to the next intermediate target retrieval primitive are combined to search the historical memory database to obtain the corresponding intermediate historical state sub-data. The extended primitive types include time association extended primitives, semantic similarity extended primitives, entity co-occurrence extended primitives, and causal relationship extended primitives. The intermediate historical state sub-data includes the initial historical state sub-data and a primitive relationship chain composed of multiple associated historical memory primitives.
5. The data query method based on a large model intelligent agent according to claim 4, characterized in that, When the retrieval type corresponding to the next intermediate target retrieval primitive is an extended class primitive, the user query data, the initial historical state sub-data, and the retrieval type corresponding to the next intermediate target retrieval primitive are combined to perform a retrieval in the historical memory to obtain the corresponding intermediate historical state sub-data, including: When the retrieval type corresponding to the next intermediate target retrieval primitive is an extended class primitive, at least one target relationship graph corresponding to the next intermediate target retrieval primitive in the historical memory bank is determined, and the at least one target historical memory primitive contained in the initial historical state sub-data is searched in the target relationship graph to determine the position information of the at least one target historical memory primitive in the target relationship graph. Obtain a preset number of associated hops, combine the location information and the number of associated hops, extract the primitive relationship chain corresponding to the at least one target historical memory primitive in the target relationship graph, and obtain the corresponding intermediate historical state sub-data based on the primitive relationship chain.
6. The data query method based on a large model intelligent agent according to claim 1, characterized in that, The method further includes: Multiple initial search primitive sequences are obtained, and for each initial search primitive in each initial search primitive sequence, the preset first sample query data is sequentially combined, and the search is performed in the historical memory according to the corresponding search type to obtain the first associated data set corresponding to each initial search primitive sequence. Using a large language model, corresponding predicted query results are generated based on the first sample query data and the first associated data set; Obtain the first retrieval score of the predicted query result corresponding to each initial retrieval primitive sequence, and when the first retrieval score is greater than a preset retention threshold, determine the initial retrieval primitive sequence as an intermediate retrieval primitive sequence; For each intermediate retrieval primitive sequence, primitive reconstruction is performed to generate at least one candidate retrieval primitive sequence, wherein each candidate retrieval primitive sequence is different from any historical retrieval primitive sequence; Obtain the second associated data set retrieved by each candidate retrieval primitive sequence for each preset second sample query data, and generate the second retrieval score of each candidate retrieval primitive sequence on each second sample query data based on the second associated data set; When a target candidate retrieval primitive sequence has a second retrieval score on at least one second sample query data that is higher than the score of all capability retrieval primitive sequences on the same second sample query data in the preset capability frontier, the target candidate retrieval primitive sequence is added to the capability frontier. Calculate the first performance score of each capability retrieval primitive sequence in the capability frontier, and when the first performance score of a target capability retrieval primitive sequence in the capability frontier is greater than the second performance score of at least one retrieval primitive sequence in the deployment frontier, add the target capability retrieval primitive sequence as a retrieval primitive sequence to the deployment frontier.
7. The data query method based on a large model intelligent agent according to claim 6, characterized in that, The calculation of the first performance score of each capability retrieval primitive sequence in the capability frontier, and the addition of the target capability retrieval primitive sequence as a retrieval primitive sequence to the deployment frontier when the first performance score of a target capability retrieval primitive sequence in the capability frontier is greater than the second performance score of at least one retrieval primitive sequence in the deployment frontier, includes: Using a pre-defined verification query set, execute each capability retrieval primitive sequence contained in the current capability frontier and each retrieval primitive sequence contained in the deployment frontier. A first performance score is calculated for each capability retrieval primitive sequence based on the difference between each first query result generated on the validation query set and the sample label, and a second performance score is calculated for each capability retrieval primitive sequence based on the difference between each second query result generated on the validation query set and the sample label. Identify the benchmark retrieval primitive sequence with the lowest second performance score in the deployment frontier; When the difference between the first performance score of the target capability retrieval primitive sequence and the second benchmark performance score corresponding to the benchmark retrieval primitive sequence in the capability frontier is greater than or equal to a preset gain threshold, the target capability retrieval primitive sequence is added to the deployment frontier as a retrieval primitive sequence, and the benchmark retrieval primitive sequence is removed from the deployment frontier. Alternatively, when the difference between the first performance score of the target capability retrieval primitive sequence and the second benchmark performance score corresponding to the benchmark retrieval primitive sequence in the capability frontier is less than or equal to the gain threshold, the sequence length difference between the target capability retrieval primitive sequence and the benchmark retrieval primitive sequence is calculated. When the sequence length difference is less than a preset value, the target capability retrieval primitive sequence is added to the deployment frontier as a retrieval primitive sequence, and the benchmark retrieval primitive sequence is removed from the deployment frontier.
8. A data query device based on a large-scale intelligent agent, characterized in that, The device includes: The acquisition module is used to acquire user query data; The output module is used to output the selection probability for each search primitive sequence based on the user query data and each preset search primitive sequence through a preset search routing model. The retrieval primitive sequence includes retrieval primitives of retrieval types such as memory primitive retrieval and contextual retrieval; The selection module is used to select a target retrieval primitive sequence from multiple preset retrieval primitive sequences based on the selection probability of each retrieval primitive sequence; The retrieval module is used to sequentially combine the user query data with each target retrieval primitive in the target retrieval primitive sequence and search in the historical memory bank according to the corresponding retrieval type to obtain the historical associated data set corresponding to the target retrieval primitive sequence. The historical associated data set includes at least one target historical memory primitive and a primitive relationship chain composed of multiple associated historical memory primitives. The historical memory bank contains multiple historical memory primitives and multiple relationship graphs, wherein the relationship graphs are used to provide the association between at least two corresponding historical memory primitives during the context retrieval process; The generation module is used to generate corresponding query results based on the user query data and the historical associated data set using a large language model.
9. A computer device, characterized in that, The computer device includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the data query method based on a large model intelligent agent as described in any one of claims 1 to 7.
10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the data query method based on a large model intelligent agent as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Retrieval method, device and equipment based on multiple agents and medium
CN122173530A
Encoding and retrieval of synthetic memories for a generative model from a user interaction history including multiple interaction modalities
US20250021474A1