Search enhancement generation methods and apparatus, electronic devices, and program products
By constructing a heterogeneous knowledge graph and dynamically managing weights, the problem of historical logs interfering with search results in autonomous intelligent agents was solved, enabling more accurate contextual information filtering and improving the search signal-to-noise ratio and user experience.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- BEIJING ACAD OF ARTIFICIAL INTELLLIGENCE
- Filing Date
- 2026-01-22
- Publication Date
- 2026-06-02
AI Technical Summary
Existing retrieval enhancement generation techniques for autonomous intelligent agents rely on static vector similarity matching. As the system runs longer, historical logs accumulate, and outdated and irrelevant context interferes with the current retrieval results, reducing the retrieval signal-to-noise ratio and causing hallucinations.
A heterogeneous knowledge graph is constructed, and context information is managed through an initial weight and activation mechanism. By combining an energy decay model and trajectory value assessment, the weight and activation of memory nodes are dynamically adjusted. The knowledge graph is used as a vector storage skeleton to realize the structured representation and filtering of context information.
It effectively reduces the interference of historical trivial records on search results, improves the search signal-to-noise ratio, reduces the possibility of autonomous intelligent agents generating illusions, and enhances the user experience.
Smart Images

Figure CN122132443A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of large language model technology, and in particular to a retrieval enhancement generation method and apparatus, electronic device, and program product. Background Technology
[0002] An autonomous agent is an AI (Artificial Intelligence) system capable of independently perceiving its environment, setting goals, planning tasks, executing actions, and continuously learning without real-time human intervention. Currently, retrieval-augmented generation (RAG) technology based on autonomous agents mainly relies on static vector similarity matching. As the system runs longer, historical logs accumulate linearly, and outdated and irrelevant context (such as early trivial records) often interferes with current search results, leading to a decrease in the search signal-to-noise ratio, causing the autonomous agent to experience illusions, and degrading the user experience. Summary of the Invention
[0003] This application provides a retrieval enhancement generation method and apparatus, electronic device, and program product that can reduce the illusion of autonomous intelligent agents, make more objective and realistic responses to the environment or user instructions, and improve user experience.
[0004] In a first aspect, embodiments of this application provide a retrieval enhancement generation method, which includes: acquiring multimodal interaction data corresponding to an autonomous intelligent agent; extracting entities as nodes from the multimodal interaction data; identifying relationships between entities; establishing edges between nodes; and obtaining a heterogeneous knowledge graph; determining initial weights between two adjacent nodes in the heterogeneous knowledge graph; in response to receiving a user's query instruction, acquiring a query vector corresponding to the query instruction; determining the activation degree of each node in the heterogeneous knowledge graph relative to the query vector, at least based on the initial weights, and determining context information from the heterogeneous knowledge graph based on the activation degree; and the autonomous intelligent agent executing the task corresponding to the query instruction in conjunction with the context information.
[0005] In one embodiment, determining the initial weights between two adjacent nodes in a heterogeneous knowledge graph includes: determining the point mutual information between the i-th node and the j-th node; the point mutual information represents the information gain of the entity corresponding to the i-th node combined with the entity corresponding to the j-th node; the i-th node and the j-th node are two adjacent nodes in the heterogeneous knowledge graph; determining the first number of times the i-th node and the j-th node co-occur; determining the second number of times the i-th node co-occurs independently and the third number of times the j-th node co-occurs independently; and obtaining the initial weights between the i-th node and the j-th node in the heterogeneous knowledge graph based at least on the point mutual information, the first number, the second number, and the third number.
[0006] In one embodiment, the activation degree of each node in the heterogeneous knowledge graph relative to the query vector is determined at least based on the initial weights, including: obtaining the system timestamp of the i-th node at the current moment and the first timestamp of the i-th node's most recent access; obtaining a time decay term based on the system timestamp, the first timestamp, and the memory half-life constant; wherein the memory half-life constant is a preset constant used to control the forgetting rate; counting the cumulative number of times the i-th node is retrieved; determining a baseline threshold for the number of retrieval hits and hyperparameters; the hyperparameters are used to adjust the steepness of the memory consolidation curve; and obtaining the activation degree of each node in the heterogeneous knowledge graph relative to the query vector based on the cumulative number of hits, the baseline threshold, and the hyperparameters. The process involves: determining the memory strength consolidation term; identifying the i-th node vector corresponding to the i-th node; calculating the semantic similarity between the query vector and the i-th node vector to obtain the semantic similarity term; determining the activation degree of each neighbor node in the upstream neighbor node set of the i-th node in the heterogeneous knowledge graph; obtaining the activation diffusion term based on the initial weights between the neighbor nodes and the i-th node and the activation degrees of the neighbor nodes; weighted summing of the semantic similarity term and the activation diffusion term to obtain the semantic matching and activation diffusion term; and obtaining the activation degree of the i-th node based on the time decay term, the memory strength consolidation term, the semantic matching and activation diffusion term.
[0007] In one embodiment, the method further includes: periodically scanning the historical task logs of the autonomous intelligent agent and extracting multiple historical action trajectories from the historical task logs; evaluating the utility of each of the multiple historical action trajectories; determining at least one action trajectory as the target trajectory based on the evaluation results; and converting the target trajectory into a function that can be invoked.
[0008] In one embodiment, utility evaluation is performed on multiple historical action trajectories, including: determining the frequency of occurrence of the m-th group of historical action trajectories; calculating the average success rate of the m-th group of historical action trajectories in performing multiple tasks; calculating the number of atomic steps included in the m-th group of historical action trajectories; obtaining the trajectory benefit density based on the frequency of occurrence, average success rate, and number of atomic steps; determining the compilation cost and expected execution cost of converting the m-th group of action trajectories into functions; obtaining a resource consumption penalty term based on the compilation cost and expected execution cost; determining the information entropy of the parameters corresponding to the m-th group of action trajectories as the generalization potential entropy; and obtaining the utility score corresponding to the m-th group of action trajectories based on the trajectory benefit density, resource consumption penalty term, and generalization potential entropy.
[0009] In one embodiment, after converting the target trajectory into a function that supports invocation, the method further includes: obtaining the output result of running the code corresponding to the function in an isolated sandbox; obtaining the real result corresponding to the m-th action trajectory in the historical task log; obtaining a first value of the first indicator function based on the semantic similarity between the output result and the real result; and / or, invoking the security scanning function of the abstract syntax tree to detect whether there is an illegal invocation in the code corresponding to the function, and obtaining a second value of the second indicator function; and obtaining a verification result of whether the sandbox verification passes based on the first value and / or the second value.
[0010] In one embodiment, after executing the task corresponding to the query instruction, the method further includes: obtaining the reward value obtained by the autonomous intelligent agent in executing the task corresponding to the query instruction as a feedback signal; based on the Heb rule, obtaining the weight increment according to the feedback signal, the activation degree corresponding to the i-th node, the activation degree corresponding to the neighboring nodes of the i-th node, and the preset learning rate; summing the current initial weight and the weight increment, and normalizing the sum to obtain the updated weight.
[0011] Secondly, embodiments of this application also provide a retrieval enhancement generation apparatus, which includes: a construction module, used to acquire multimodal interaction data corresponding to an autonomous intelligent agent, extract entities as nodes from the multimodal interaction data, identify relationships between entities, establish edges between nodes, and obtain a heterogeneous knowledge graph; a weight initialization module, used to determine the initial weights between two adjacent nodes in the heterogeneous knowledge graph; an activation module, in response to receiving a user's query instruction, acquiring a query vector corresponding to the query instruction, determining the activation degree of each node in the heterogeneous knowledge graph relative to the query vector, and determining context information from the heterogeneous knowledge graph based on the activation degree; an inference module, used for the autonomous intelligent agent to execute the task corresponding to the query instruction in combination with the context information; and an update module, used to update the initial weights in the heterogeneous knowledge graph based on the feedback signal obtained by the autonomous intelligent agent in executing the task, according to the Heb rule.
[0012] Thirdly, embodiments of this application provide an electronic device, including a processor and a memory storing a computer program, wherein the processor executes the program to implement the retrieval enhancement generation method of the first aspect.
[0013] Fourthly, embodiments of this application provide a non-transitory computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the retrieval enhancement generation method of the first aspect.
[0014] Fifthly, embodiments of this application provide a computer program product, including a computer program that, when executed by a processor, implements the retrieval enhancement generation method of the first aspect.
[0015] The retrieval enhancement generation method, apparatus, electronic device, and program product provided in this application construct a heterogeneous knowledge graph based on multimodal interaction data. Upon receiving a user's query instruction, it determines the activation degree of each node in the heterogeneous knowledge graph relative to the query vector, at least based on the initial weights between adjacent nodes in the heterogeneous knowledge graph. It then determines context information from the heterogeneous knowledge graph based on the activation degree. For example, it can select entity-related information corresponding to several nodes with high activation rankings as context information related to the query vector. In this way, multimodal interaction data is transformed into a heterogeneous knowledge graph. The heterogeneous knowledge graph is constructed with entities as nodes and relationships between entities as edges. The heterogeneous knowledge graph can incorporate historical context... The complex relationships are structurally represented, and the degree of relevance between each node and the content (query instruction) that the current user wants to query is represented by activation. The initial weights between adjacent nodes can capture logical associations that "although semantically dissimilar, often appear together" (such as "umbrella" and "rain"). The knowledge graph is used as the skeleton for storing historical context information vectors. When a node is activated, energy will spread along the edges (directed edges) of the heterogeneous knowledge graph to the associated neighboring nodes. In this way, highly relevant context information can be filtered out from a large amount of context. The filtered context information is provided to LLM, which can reduce the interference of early trivial records on the retrieval results, improve the retrieval signal-to-noise ratio, and reduce the possibility of the autonomous agent generating illusions. Attached Figure Description
[0016] To more clearly illustrate the technical solutions in this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0017] Figure 1This is a flowchart illustrating the retrieval enhancement generation method provided in the embodiments of this application; Figure 2 This is a flowchart illustrating the process of determining node activation in one embodiment of the retrieval enhancement generation method provided in this application. Figure 3 This is a schematic diagram of the software module structure of the retrieval enhancement generation device provided in the embodiments of this application; Figure 4 This is a schematic diagram of the structure of the electronic device provided in the embodiments of this application. Detailed Implementation
[0018] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.
[0019] In the field of Large Language Model (LLM) technology, how autonomous agents can efficiently manage long-term context and achieve automated capability iteration remains a core technical challenge. The main technical problems associated with related technologies are as follows: Semantic Noise & Static Retrieval in Memory Retrieval: Retrieval augmentation (RAG) techniques in related technologies mainly rely on static vector similarity matching. As the system runs longer, historical logs accumulate linearly. Due to the lack of a dynamic weight adjustment mechanism, outdated and irrelevant context (such as early trivial records) often interferes with current retrieval results, leading to a decrease in the retrieval signal-to-noise ratio and causing model illusions.
[0020] Specifically, in related technologies, during retrieval, the RAG system accumulates a massive amount of historical interaction records linearly in its memory (vector database) over long-term operation. This inevitably includes a large amount of outdated, trivial, or irrelevant information. When a static retrieval system performs similarity matching, these old and irrelevant records are retrieved along with the current query because their textual semantics may have some superficial connection (e.g., both contain words like "user" or "question"). The LLM (Local Level Meter) is essentially a probability-based sequence generator, whose output heavily depends on the context of its input. Some RAG technologies indiscriminately concatenate all retrieved relevant text fragments and input them as "context" along with the user's question into the LLM. When this context is mixed with a large amount of noise (irrelevant / outdated information), the LLM is forced to attempt to fuse all the information to generate a coherent answer. For example, a user asks, "What is the company's latest annual leave policy?" When the autonomous agent performs this task, it will search its memory. This memory may contain the following noise: valid memory: the 2025 Employee Handbook states "10 days of annual leave"; outdated noise: a fragment of an old policy document from 2023 stating "7 days of annual leave"; irrelevant noise: a chat log entry saying, "I really hope I have more annual leave to travel." The autonomous agent's static search results might simultaneously recall fragments from the 2025 Employee Handbook, fragments from the old 2023 policy, and even that casual chat entry (because they all contain the word "annual leave"). Therefore, the context input to the LLM might be: "Context 1 (2025 Employee Handbook): 10 days of annual leave. Context 2 (2023 document): 7 days of annual leave. Context 3 (casual chat): I really hope I have more annual leave… Question: What is the company's latest annual leave policy?" Faced with contradictory information, the LLM might "average" an incorrect answer, such as "8-9 days of annual leave." Alternatively, it might incorrectly quote outdated information, answering "7 days." Even more problematic, an LLM might incorporate casual conversational language to generate an answer that could be partially inaccurate (the company is not actually considering adjustments), such as, "Based on employee feedback, annual leave may be increased; the latest policy is 10 days, but the company is considering adjustments."
[0021] Logical Disconnection in Unstructured Data: Simple vector databases (VectorDB) struggle to capture complex topological relationships between entities (such as causal or temporal changes). When environmental conditions change, the system often can only add new records but cannot effectively update the connection weights between nodes, leading to logical conflicts.
[0022] Lack of Procedural Crystallization: When faced with repetitive, high-frequency, and complex tasks, agents need to start from scratch and perform a complete chain-of-thought reasoning each time. This not only consumes a large amount of computing resources (tokens), but also, due to the randomness of the reasoning process, easily leads to unstable execution results and lacks the ability to transform successful experiences into solidified tools.
[0023] Lack of Verification Loop in Generated Code: Related technologies often lack verification mechanisms when automatically generating tool code, which may result in generated code containing logical errors or security vulnerabilities, failing to meet the stability requirements of industrial applications.
[0024] In view of this, embodiments of this application propose a retrieval enhancement generation method and apparatus, electronic device, and program product. This method employs a dual-loop dynamic cognitive architecture, including a memory metabolism loop and a skill crystallization loop. It constructs a data foundation through heterogeneous graphs, manages the information lifecycle using a physical energy decay model, and solidifies capabilities through trajectory value assessment and sandbox verification. The model routing scheme proposed in embodiments of this application includes at least one of the following technical improvements: Memory metabolism based on energy activation diffusion: This approach abandons simple time decay and proposes a hybrid scoring mechanism combining "temporal half-life" and "semantic topological activation." Utilizing a knowledge graph as the skeleton for vector storage, when a memory node is activated, energy diffuses along the graph edges to related nodes. Simultaneously, a "memory reconsolidation" mechanism based on access frequency is introduced to dynamically adjust the forgetting rate.
[0025] Skills Acquisition Based on Trajectory Value Assessment: This paper proposes an automated pipeline to identify high-frequency and successful action trajectories. Through Abstract Syntax Tree (AST) parsing, linear operation sequences are transformed into reusable macro operators.
[0026] Closed-loop verification and feedback update: A sandbox environment is introduced to verify the consistency of the generated code, and the connection weights of the memory graph are updated in reverse based on the feedback signal (Reward) of the task execution results, so as to realize the adaptive evolution of the system.
[0027] Specifically, the enhanced retrieval generation method of this application embodiment includes at least a preprocessing stage and a retrieval stage from the following five stages: This invention constructs a processing pipeline comprising five core stages: Preprocessing stage: Transform multimodal interaction data into a heterogeneous knowledge graph, and complete node vectorization and edge weight initialization.
[0028] Retrieval phase: A nonlinear time-weighted and graph diffusion algorithm is used to calculate the real-time activation of memory items and accurately retrieve the context from massive logs.
[0029] Generation phase: Monitor the execution trajectory, calculate the trajectory utility score, and reconstruct high-value trajectories into function code.
[0030] Verification phase: The generated code is subjected to syntax analysis and input / output consistency verification in an isolated sandbox.
[0031] Feedback phase: Based on the final results of the task, the graph weights are updated using the Hebbian Rule to achieve parameter iteration.
[0032] Specifically, such as Figure 1 As shown in the figure, this application provides a retrieval enhancement generation method, which may include the following process: Step 101: Obtain multimodal interaction data corresponding to the autonomous intelligent agent, extract entities as nodes from the multimodal interaction data, identify the relationships between entities, establish edges between nodes, and obtain a heterogeneous knowledge graph.
[0033] Step 101 is the process of constructing a heterogeneous knowledge graph based on the historical multimodal interaction data of the autonomous intelligent agent.
[0034] Multimodal interaction data refers to the information streams of various types and formats that an autonomous intelligent agent receives, generates, and processes during its interaction with the environment. Specifically, multimodal interaction data includes at least one of the following: input modality, internal processing modality, output and action modality, and feedback modality.
[0035] The input modality may include at least one of the following: text, such as user-inputted instructions, questions, or chat content; voice, such as user voice commands or dialogues; images / videos, including user-uploaded pictures, screenshots, document scans, or videos, such as a user uploading a product fault diagram for an autonomous agent to diagnose; structured data, such as files or data in JSON, XML, or other formats returned from databases or APIs; code / scripts, such as user-provided code snippets or configuration files; and environmental signals, such as status signals from the physical world or virtual systems, like system logs or error messages.
[0036] Internal processing modalities may include at least one of the following: inference chain text, a complete thought process generated internally by the LLM, such as "If a user wants to analyze project data, they need to first obtain the data source and then clean it..."; a list of plans and sub-goals, such as a structured task list formed by an autonomous agent autonomously decomposing tasks; decision logs, such as the evaluation reasons for choosing a tool; and intermediate representations, which may be generated internal data structures or sketches before generating code or complex output.
[0037] Output and action modalities (actions of the autonomous agent to the environment) may include at least one of the following data: tool call instructions, action descriptions and parameters for calling external tools, usually structured commands (such as "action", "python", "code", etc.); generated code, various types of code such as Python and SQL written autonomously by the autonomous agent; generated multimedia content, such as text replies, natural language answers to users; or generated images / charts, such as pictures or data visualization charts generated according to instructions; or structured output, such as generated tables or JSON documents.
[0038] Feedback modalities (environmental responses) can specifically include at least one of the following data: tool execution results, such as printed output of code execution, returned data, and error stack information; API responses, such as structured returns of success or failure; explicit user feedback, such as user likes, dislikes, ratings, and correction text; and implicit user feedback, such as data on subsequent user behavior, such as whether suggestions were adopted or whether follow-up questions were asked.
[0039] For example, the specific construction process of building a heterogeneous knowledge graph based on multimodal interaction data is as follows: First, entities and relationships between them are identified from the multimodal interaction data stream. Entities are treated as nodes (also called memory nodes), and relationships between entities are treated as edges, thus constructing a directed heterogeneous knowledge graph. Nodes and edges can have different types.
[0040] Specifically, named entity recognition models or LLM itself can be used to identify various types of entities from multimodal interaction data. For example, entities can include at least one of the following objects: task objectives (e.g., predicting trends, answering questions, etc.), execution tools (e.g., search_document, python_executor, etc.), key parameters (e.g., 2025-Q2, Project.csv), core concepts (e.g., technical data, technical topics, user feedback), and status results (e.g., success, FileNotFoundError, etc.).
[0041] After identifying entities, a node is created for each entity in the heterogeneous knowledge graph. Each node has an ID, type, name, and a corresponding text vector embedding (i.e., a node vector, used for subsequent semantic retrieval). Simultaneously with entity identification, relationships between entities are identified. Based on the identified relationships, a directed edge is created between the two nodes, with the direction of the edge indicating the direction of the relationship. For example, a directed edge is established between the nodes "rain" and "umbrella," pointing from "rain" to "umbrella." Connection edges can have various types (e.g., use, input, call, etc.). For example, using an umbrella when it rains is one type of edge.
[0042] Step 102: Determine the initial weights between two adjacent nodes in the heterogeneous knowledge graph.
[0043] The initial weight between two nodes refers to the initial weight of the connecting edge (or simply edge) between them. It's important to note that the weights of each edge in the heterogeneous knowledge graph are dynamically updated. Each time a task is executed, the weights are dynamically updated based on the task's result. After constructing the heterogeneous knowledge graph, during system initialization or when new data (at least one of the aforementioned multimodal data modes) is entered, the initial weights of the edges can be determined as follows: Method 1: In some embodiments of this application, statistical co-occurrence relationships are introduced to capture the logical connections between nodes that are "semantically dissimilar but frequently appear together," and these logical connections are quantified as the initial weights of the edges between the nodes. For example, the nodes "umbrella" and "rain" have low semantic similarity, but they are actually two entities that frequently co-occur. In a heterogeneous knowledge graph, while establishing a directed edge between "umbrella" and "rain," an initial weight is assigned to this directed edge.
[0044] Method 2: In other embodiments, other methods can also be used to determine the initial weights. For example, the initial weights of the edges between two nodes can be determined based on the similarity (e.g., cosine similarity) between the two node vectors corresponding to the two nodes.
[0045] The advantage of Method 1 over Method 2 is that Method 1 solves the cold start problem, ensuring that logically related concepts can be connected through the graph in the early stages of system operation, providing a topological foundation for subsequent retrieval steps.
[0046] The initial weights for determining the initial weights between two adjacent nodes can specifically include: when the autonomous agent performs the first round of tasks, it can determine the initial weights according to the above method one; when processing other rounds of tasks that are not the first round of tasks, the weights updated in the previous round of tasks can be used as the initial weights for the current round of tasks.
[0047] Step 103: In response to receiving the user's query command, obtain the query vector corresponding to the query command.
[0048] For example, if the system detects that a user performs a specified operation (such as clicking, double-clicking, or long-pressing) on a control that triggers a query or retrieval on the interactive interface, and receives at least one of the above-mentioned input modalities of the user input, such as receiving one or more of the user input data such as text, image, video, voice, file, code, or script, then it is determined that the user's query instruction has been received.
[0049] Obtain the query vector corresponding to the query command, that is, convert the user input into a numeric vector that can be processed by LLM. For example, the query vector can be obtained by performing operations such as text preprocessing, token segmentation, encoding, pooling, and normalization on the user input.
[0050] Step 104: Determine the activation degree of each node in the heterogeneous knowledge graph relative to the query vector, based at least on the initial weights, and determine the context information from the heterogeneous knowledge graph based on the activation degree.
[0051] This application's embodiments introduce an activation diffusion mechanism, where a node in a heterogeneous knowledge graph (e.g., the i-th node)... The activation level of ) depends not only on With query vector The semantic similarity also depends on the i-th node. neighboring nodes Whether or not an activity is activated, energy flows along the directed edges of the heterogeneous knowledge graph. Specifically, a comprehensive scoring model is used to simulate three characteristics of human memory: the more frequently used information is remembered more firmly (memory strength consolidation item, or consolidation item for short), the more distant the information is, the easier it is to forget (time decay item for short), and the more relevant the information is, the easier it is to associate with it (semantic matching and activation diffusion item for short). Nodes are obtained based on the consolidation item, decay item, and diffusion item. Activation level.
[0052] Activation degree represents the degree of association between the current query vector and the heterogeneous knowledge graph. Context information is determined from the heterogeneous knowledge graph based on the activation degree. Specifically, this can be done by selecting information corresponding to multiple nodes with activation degrees greater than a preset threshold from the heterogeneous knowledge graph, or by selecting information corresponding to the N nodes with the highest activation degrees as the context information for this query task.
[0053] Step 105: The autonomous intelligent agent combines the context information to execute the task corresponding to the query command.
[0054] The context information is input into the LLM, which then executes the query task based on the context information and obtains the task execution result.
[0055] Figure 1 The illustrated embodiment transforms multimodal interaction data into a heterogeneous knowledge graph. This knowledge graph serves as the skeleton for storing historical context information vectors. The initial weights between adjacent nodes capture the relationships between entities with low semantic similarity but logical connections (e.g., rain and umbrella). Node activation characterizes the strength of the association between the node and the query vector. When a node is activated, energy spreads along the edges (directed edges) of the heterogeneous knowledge graph to its associated neighboring nodes. This allows for the filtering of contextual information strongly related to the query vector from a vast amount of context. Providing this filtered contextual information to the LLM reduces interference from fragmented historical records on retrieval results, improves the retrieval signal-to-noise ratio, reduces illusions generated by autonomous agents, and enhances the user experience.
[0056] In one specific embodiment, step 102 determines the initial weights between two adjacent nodes in the heterogeneous knowledge graph, which can be implemented in the following way: For example, the initial weights of edges in a heterogeneous knowledge graph can be calculated using the following edge weight initialization formula (1): (1) Formula (1) is used to calculate the node during system initialization or new data entry. and Initial weights between Initial weights can represent nodes and The strength of the connection between them.
[0057] in, This represents the i-th node in the heterogeneous knowledge graph. This indicates that the j-th node in the heterogeneous knowledge graph is adjacent to the i-th node, meaning that the j-th node is a neighbor (first-order neighbor node) of the i-th node.
[0058] node With nodes The initial weight of the edge, for example, could be a node Pointing to node The initial weights of the directed edges.
[0059] The Sigmoid normalization function restricts the weights to the (0,1) interval.
[0060] , representing a node With nodes Pointwise Mutual Information (PMI) is used to measure the information gain of the combination of two nodes.
[0061] node With nodes The number of times they appear together in a specified history window. The history window is a historical time window, which can be a user-specified historical time period (such as a month or a week) or a preset time period.
[0062] :node The total number of times it appears independently within a specified history window. .
[0063] Adjustment point mutual information The corresponding weights Co-occurrence frequency The corresponding weights The balance coefficient between the two weights.
[0064] Based on the above exemplary description of step 102, it can be seen that, in some embodiments, determining the initial weights between two adjacent nodes in a heterogeneous knowledge graph can be implemented in the following way: Determine the i-th node (e.g.) ) and the j-th node (e.g. Point mutual information between (e.g.) And, determine the first occurrence count of the i-th node and the j-th node together. Here, point mutual information represents the information gain of the entity corresponding to the i-th node combined with the entity corresponding to the j-th node. The i-th node and the j-th node are two adjacent nodes in the heterogeneous knowledge graph.
[0065] Determine the first occurrence count of the i-th node and the j-th node together. Specifically, it can be the first occurrence count of the i-th node and the j-th node together within the history window. For example, determine the number of times the nodes "umbrella" and "rain" co-occur within the user-specified historical time period, and use that as the first occurrence count.
[0066] Next, determine the second number of times the i-th node appears independently and the third number of times the j-th node appears independently; specifically, determine the second number of times the i-th node appears independently within the history window (e.g., ), determine the third time the j-th node appears independently within the history window (e.g. Based on at least the mutual information of the nodes, the first number, the second number, and the third number, the initial weights between the i-th and j-th adjacent nodes in the heterogeneous knowledge graph are obtained. For example, the square root of the product of the second and third numbers can be calculated first, and the ratio of the first number to the square root can be used as the co-occurrence frequency. Preset weights are then applied. Point-to-point mutual information The nodes are obtained by weighted summation of co-occurrence frequencies and then normalized using the sigmoid function. and nodes The initial weights of the edges between them.
[0067] Using the above formula (1) to calculate the initial weights can establish the physical pathway foundation between memory nodes. If the weights are not initialized reasonably, the subsequent activation diffusion steps will not be able to propagate effectively. Formula (1) combines global statistical information (mutual information) and local statistical information (co-occurrence frequency). Compared with using only cosine similarity to determine the initial weights of edges, this method introduces statistical co-occurrence relationships, which can capture logical associations that often appear together even though they are semantically dissimilar (such as "umbrella" and "rain"), solve the cold start problem, and ensure that logically related entities can be connected through heterogeneous knowledge graphs in the early stage of system operation, providing a topological foundation for retrieval in subsequent steps.
[0068] In one specific embodiment, step 104 determines the activation degree of each node in the heterogeneous knowledge graph relative to the query vector based at least on the initial weights. This can be achieved in the following way: This application proposes a context retrieval mechanism based on dynamic energy decay and topological diffusion. Specifically, when a query command submitted by a user is received, the current activation degree of each memory unit (i.e., memory node) is calculated. The activation degree can also be called activation energy, in order to determine which contexts to recall from the historical context.
[0069] The formula (2) for calculating the dynamic activation degree of memory nodes is as follows: (2) in, The current system timestamp; Memory Node The timestamp of the last (most recent) visit. This represents the memory half-life constant, used to control the rate of forgetting. This indicates the cumulative number of times a memory node has been retrieved. The baseline threshold represents the cumulative number of times a memory node has been retrieved. This represents a hyperparameter that adjusts the steepness of the memory consolidation curve. Represents the query vector. Represents a node The corresponding node vector. Represents the query vector The node vector corresponding to the memory node Semantic similarity, for example, could be the cosine similarity between the query vector and the node vector.
[0070] Indicates pointing to in the graph The set of upstream neighbor nodes, for example This is one of the upstream neighbor nodes in the set. Here, "upstream" refers to the node upstream in the direction indicated by the directed edge, such as node [node name missing]. With nodes By node node node For nodes The upstream neighbor node.
[0071] Represents a node To the node The weights of the edges are initially determined according to step 102 above, and can be updated according to subsequent steps.
[0072] Formula (2) is used to calculate at the current time. For query vectors Memory nodes The overall activation score (i.e., activation level) Formula (2) is a comprehensive scoring model that simulates three characteristics of human memory: the more frequently used the information, the more firmly it is remembered (consolidation item); the more distant the information, the easier it is to forget (decay item); and the more relevant the information, the easier it is to associate with it (diffusion item). In the process of obtaining activation, the embodiments of this application introduce an activation diffusion mechanism. The activation degree depends not only on its relationship with the query vector The literal similarity also depends on neighboring nodes Whether it is activated or not, energy will flow along the edges in the heterogeneous knowledge graph.
[0073] In this way, automatic noise reduction can be achieved: old data that has not been accessed for a long time and has no relevance has a score close to 0 and is automatically filtered out. In addition, the above activation calculation method can also achieve implicit recall: even if the historical context record does not match the token in the query vector, if a certain node is closely connected to the current context logic (the activation of neighboring nodes is high), then this node will also be recalled by "following the clues", thus solving the semantic gap problem.
[0074] Among them, in formula (2) It is a configurable, learnable, and adaptively updated baseline access threshold used to characterize the "critical point at which memory transitions from short-term to stable memory." Its core function is to: enhance memory strength consolidation. In the Sigmoid curve, the inflection point determines how many times a memory node is accessed before it transitions from a "forgettable state" to a "stable memory state".
[0075] Specifically, the benchmark threshold in formula (2) The determination can be made using one or more of the following methods, and the embodiments of the present invention do not limit this: Method 1: Based on adaptive computation using statistical distribution, within a preset time window (W), the system statistically analyzes the access frequency distribution of all memory nodes and dynamically determines it according to quantiles or statistics. or in, , These represent the mean and standard deviation of the cumulative number of hits for all memory nodes within the window (W), respectively. Indicates a preset quantile (e.g., 60); This represents the adjustment coefficient. Quantile represents the quantile function, used to proportionally divide a data distribution into multiple parts.
[0076] Method 1 can achieve the following technical effects: as the system scales up, the threshold automatically increases with the overall access intensity; avoids memory imbalance caused by "early cold data" or "hotspot explosion"; and ensures that memory consolidation is triggered by "relatively high frequency" rather than "absolute number of times".
[0077] Method 2: Grouping is configured based on memory type or source (structured and controllable). In a heterogeneous memory map, different types of nodes (such as tool calls, environmental states, user preferences, and planned trajectories) can correspond to different... : For example, tool / API call nodes: have a low threshold (consolidation can be achieved with a small number of successes); one-time logs or intermediate inference nodes: have a high threshold; failure trajectory nodes: do not trigger consolidation even if they occur frequently.
[0078] in, The baseline access threshold for memory nodes of category (c) is used to determine the minimum cumulative number of hits required for that type of memory to enter a stable and consolidated state. This represents a mapping function used to output the corresponding baseline access threshold based on the attribute characteristics of the memory node. Its specific form can be a rule function, statistical function, lookup table function, or learning model, and the embodiments of the present invention are not limited thereto. It indicates the semantic or functional type of a memory node, used to distinguish memory content for different purposes or cognitive levels. Indicates the source type of the memory node, used to characterize which interaction or system module generated the memory. This represents the lifecycle parameter of a memory node, used to indicate the natural decay timescale of this type of memory without further access. This indicates the importance weight of a memory node in the current or historical task, used to measure its contribution to the success of the task.
[0079] Method 2 can achieve the following technical effects: prevent "worthless high-frequency noise" from being mistakenly reinforced; and enhance the distinguishability of different cognitive levels in the graph.
[0080] Method 3: Offline experience initialization + online fine-tuning (engineering-friendly): In the initial stage of system deployment, empirical constants can be used as initial values. Then, based on online performance metrics (such as illusion rate, recall hit rate, and context length), automatic adjustments are made using gradient or rule-based strategies. Method three ensures the feasibility of the project. Among other things, This represents the baseline access threshold parameter at the (t)th update time. This represents the baseline access threshold parameter obtained after the (t+1)th update. This represents the update step size or learning rate, a coefficient used to control the adjustment magnitude of the baseline access threshold. For illusion loss or illusion penalty, it represents the loss function (illusion loss function) used to quantify the degree of illusion or inconsistency in the system's generated results. This indicates the sensitivity of the illusion loss function to changes in the baseline access threshold parameter, and is used to indicate the direction and magnitude of adjustment.
[0081] It should be noted that, unlike the "fixed access threshold" in existing RAG or caching mechanisms, the embodiments of this invention... It is a dynamic reference quantity embedded in the nonlinear memory consolidation function. Its value can adapt to changes in system operating status, memory distribution and task feedback. It is used to adjust the memory life cycle, rather than a simple counting judgment.
[0082] In this embodiment of the invention, the benchmark threshold The critical number of accesses used to characterize the transition of memory from a short-term state to a stable state is not a fixed constant, but can be dynamically set or adaptively updated based on the statistical distribution of memory node access frequency, node type, or historical task feedback during system operation, so that the memory consolidation process is consistent with the overall system load and cognitive structure.
[0083] Based on the above exemplary description, it can be seen that in some embodiments, such as Figure 2 As shown, in step 104, determining the activation degree of each node in the heterogeneous knowledge graph relative to the query vector, based at least on the initial weights, can be achieved in the following way: Step 1041: Obtain the system timestamp of the i-th node at the current moment and the first timestamp of the i-th node's most recent access.
[0084] For example, get nodes and nodes The most recently accessed timestamp .
[0085] Step 1042: Obtain the time decay term based on the system timestamp, the first timestamp, and the memory half-life constant.
[0086] The memory half-life constant is a preset constant used to control the rate of forgetting. For example, the memory half-life constant is... Based on the system timestamp, the first timestamp, and the memory half-life constant, the time decay term is obtained. This can be achieved by first calculating... With nodes The most recently accessed timestamp The difference between them, take the difference and The negative of the ratio, taken as the exponent of the base e of the natural logarithm, yields the time decay term. .
[0087] Step 1043: Count the cumulative number of times the i-th node is retrieved; determine the baseline threshold and hyperparameters for the number of retrieval hits.
[0088] Among them, hyperparameters are used to adjust the steepness of the memory consolidation curve, for example, hyperparameters are... Statistical analysis of the node The cumulative number of times the search was hit was The baseline threshold for determining the number of search hits is: It should be noted that "being retrieved and hit" here refers to the fact that, in a single task, the information corresponding to an entity is recalled as context and input into the LLM. Optionally, for each entity, the count of being hit can be incremented by 1 for each hit.
[0089] Step 1044: Obtain the memory strength consolidation term based on the cumulative number of times, the baseline threshold, and the hyperparameter.
[0090] For example, as shown in formula (2), the cumulative number of times can be calculated first. Compared with the baseline threshold The difference between the two parameters, and the product of the difference and the hyperparameter, is taken as the negative of the product and used as the independent variable of the sigmoid function to obtain the memory strength consolidation term.
[0091] Step 1045: Determine the i-th node vector corresponding to the i-th node; calculate the semantic similarity between the query vector and the i-th node vector to obtain the semantic similarity term.
[0092] For example, determine the vector of the i-th node corresponding to the i-th node as follows: Calculate the semantic similarity between the query vector and the vector of the i-th node as follows: , as a semantic similarity term.
[0093] Step 1046: Determine the activation degree of each neighbor node in the set of upstream neighbor nodes of the i-th node in the heterogeneous knowledge graph.
[0094] Neighbor nodes The calculation method can be referred to formula (2), that is, the node The activation degree of a root node can be determined based on the activation degree of its upstream neighbor nodes. This process is repeated iteratively until the upstream neighbor node becomes the root node (a node without upstream neighbors). It should be noted that in heterogeneous knowledge graphs, the activation degree of a root node without upstream neighbors can be calculated as follows: Step 1047: Obtain the activation diffusion term based on the initial weights between neighboring nodes and the i-th node, as well as the activation degrees corresponding to the neighboring nodes.
[0095] For example, a weighted sum is performed based on the weight and activation of each node in the neighbor node set to obtain the node. The activation level of the node. For nodes The neighboring nodes, based on the neighboring nodes With nodes Initial weights between and neighboring nodes The corresponding activation level is And based on the weights and activations of other neighboring nodes in the neighboring node set, a weighted sum is obtained. The corresponding activation diffusion term.
[0096] It should be noted that in this embodiment of the invention, the activation degree of a memory node is determined by multiple factors, including semantic matching and activation diffusion terms, memory strength consolidation terms, and time decay terms. The semantic matching and activation diffusion terms include a semantic similarity term (or a direct activation term based on query semantics) and an optional activation diffusion term (or a topological activation diffusion term). The activation diffusion term is not a necessary condition for activation, but rather used to enhance the activation effect when an associated structure exists. When a memory node has no upstream neighbor nodes, its topological diffusion term can be set to zero. In this case, the semantic matching and activation diffusion terms in the activation degree calculation formula automatically degenerate into a form that only includes the semantic similarity term to obtain the activation degree. In a specific embodiment, a similarity search can first be performed on all memory nodes based on the query vector to directly generate an initial set of activated nodes, followed by topological diffusion, thereby ensuring that any memory node, including the graph root node, can be normally activated and retrieved.
[0097] Step 1048: Perform a weighted summation of the semantic similarity term and the activation diffusion term to obtain the semantic matching and activation diffusion terms.
[0098] For example, using weights As the weight corresponding to the semantic similarity term, (1- The weights corresponding to the activation diffusion terms are used as weights, and a weighted sum is performed to obtain the semantic matching and activation diffusion terms.
[0099] Step 1049: Based on the time decay term, memory strength consolidation term, semantic matching and activation diffusion term, obtain the activation degree of the i-th node.
[0100] After steps 1041-1048, the time decay term, memory strength consolidation term, semantic matching, and activation diffusion term are obtained. Based on these terms, the activation degree of the i-th node is obtained. Specifically, the product of these terms can be used as the node's value. In one specific embodiment, the retrieval enhancement generation method provided in this application further proposes a skill clustering and screening mechanism based on trajectory utility evaluation. By periodically scanning historical task logs, multiple candidate action trajectories are obtained, the value of the candidate action trajectories is evaluated, and it is decided whether to convert them into function code that can be encapsulated into tools for invocation.
[0101] In the context of autonomous agents, a trace is a complete, ordered sequence of steps that an agent takes to achieve a specific goal, containing detailed internal states and external interactions; it is a complete "background log" for achieving this goal. For example, in the embodiments of this application, a trace typically includes the following key elements: triggering target, the initial input or target description of the task; thought chain sequence: the thinking, reasoning, and decision-making process of the LLM at each step; tool call sequence, which tools / APIs were specifically executed, and the specific parameters at the time of the call; environmental feedback sequence, the results, status, or error information returned by the environment after each tool call; intermediate results and state changes, the internal data or variables updated by the agent based on feedback; final output, the final result delivered by the agent to the user when the task is completed; metadata and utility score: execution time, token consumption, whether the task was successful, user feedback (reward), etc.
[0102] First, the historical task logs of the autonomous intelligent agent are periodically scanned to extract multiple historical action trajectories. Then, the comprehensive utility evaluation formula of the candidate skill trajectory (3) is used to score each historical action trajectory: (3) in, Representing candidate trajectories The frequency of appearance within a sliding window, which can be a preset historical time window. This represents the average success rate of the task corresponding to this trajectory (normalized to 0-1). This indicates the number of atomic steps contained in the trajectory. An atomic step is the smallest indivisible unit of operation with clear semantics and independent function that an autonomous agent performs to complete a task within the action trajectory.
[0103] This represents the compilation cost of generating code (converting historical action trajectories into code), and... This represents the expected execution cost of converting historical action trajectories into code.
[0104] The information entropy of various parameters in a historical action trajectory, or simply trajectory parameter information entropy, represents the richness of the variation in parameter values.
[0105] Indicates the penalty coefficient. Indicates resource consumption penalty items; Represents the generalization coefficient. This represents the entropy of generalization potential. and It can be a preset constant.
[0106] This represents the trajectory gain density. This represents the total resource budget available for skill generation and execution within a given assessment period. Specifically, It is a normalized benchmark quantity used to measure the relative proportion of resource consumption items under the overall system resource constraints; its resource dimension can be a single indicator or a weighted combination, for example, computational resource budget (such as GPU / CPU time, computing power quota), token budget (maximum number of tokens available for model inference), time budget (upper limit of task execution or generation latency). In formula (3), by Divide by This enables comparability between systems of different sizes or at different stages of operation.
[0107] Its role in Formula 3 is to map "code generation and execution cost" as a penalty relative to the overall resource capacity of the system, preventing the selection of high-consumption but limited-return trajectories for skill solidification in resource-constrained scenarios; and to support the system in adaptively adjusting the skill crystallization (function transformation) strategy under different deployment environments (local, cloud, edge).
[0108] Trajectory parameter information entropy This is used to measure the diversity of parameter values across historical executions of the same operation trajectory, in order to assess the generalization potential of the trajectory when it is transformed into a generic function tool. Specifically, in one embodiment, trajectory parameter information entropy... The following steps 10491-10494 can be used to obtain the following: Step 10491, Parameter Extraction: Parse multiple historical execution records corresponding to the candidate historical action trajectories, and extract the set of variable parameters based on the Abstract Syntax Tree (AST) or structured logs: The parameters include, but are not limited to: file path, URL, ID, numerical threshold, configuration items, etc.
[0109] Step 10492, Parameter Distribution Statistics: For each parameter ( ), and statistically analyze the empirical distribution of its different values within the historical window: Represents the k-th parameter Values The empirical probability, Represents the k-th parameter A specific value. This indicates that within the history window, the parameters The value of is equal to The number of times. Indicates parameters Total number of times it appears in the history window.
[0110] Step 10493, Single-parameter information entropy calculation: Calculate the Shannon information entropy for each parameter: Step 10494, Trajectory-level Information Entropy Aggregation: The information entropy of all parameters in the trajectory is weighted or averaged to obtain the trajectory parameter information entropy. Indicates the total number of parameters. This represents the k-th parameter.
[0111] Alternatively, in other embodiments, a weighted approach (such as weighting by the frequency of parameter usage in the trajectory) can be used to obtain the trajectory parameter information entropy.
[0112] Thus, by employing steps 10491-10494 above, when When the parameters remain almost unchanged, the trajectory is closer to a one-off script and is not suitable for skill abstraction (transformation); when When the value is large, it indicates that the trajectory structure is stable but the parameters are diverse, and it has good generalization potential, making it suitable for crystallization (conversion) into a parameterized function.
[0113] Formula (3) above can act as a filter, selecting operation sequences (i.e., historical action trajectories) that are "worth being converted into code". This method introduces generalization potential entropy. It's not just about whether the action trajectory is successful, but also about the diversity of parameters within that trajectory (such as filenames and URLs). This helps avoid overfitting: if the parameters never change, it indicates a relatively fixed script that doesn't require complex function encapsulation. If the structure remains constant but the parameters vary, it's suitable for abstraction into a general function (such as download(url)). Furthermore, through profit density calculations, it prioritizes encapsulating those steps that are cumbersome (…). For high-frequency, high-impact tasks, maximizing token savings can optimize resource utilization. Historical action trajectories are evaluated for utility, and highly effective trajectories are converted into function code, transforming successful experiences into solidified tools. In subsequent tasks, the autonomous agent can directly call these solidified tools, drawing on past experience without needing to start from scratch with complete thought chain reasoning, thus saving computational resources.
[0114] Based on the above exemplary description, it can be seen that in some embodiments, the historical task logs of the autonomous intelligent agent can be scanned periodically, multiple historical action trajectories can be extracted from the historical task logs, and then the utility of each of the multiple historical action trajectories can be evaluated. Based on the evaluation results, at least one action trajectory can be determined from the multiple historical action trajectories as the target trajectory. The target trajectory can then be converted into a function (tool) that can be invoked. Here, the function includes a function name and function code.
[0115] Specifically, the utility assessment of historical action trajectories can be achieved in the following ways: Determine the frequency of occurrence of the m-th group of historical action trajectories (e.g.) ), and calculate the average success rate of performing multiple tasks in the historical action trajectory of the m-th group ( ), count the number of atomic steps included in the historical action trajectory of the m-th group ( Based on the frequency of occurrence, average success rate, and number of atomic steps, the trajectory reward density is obtained, for example, This yields the trajectory revenue density.
[0116] Next, determine the compilation cost of converting the m-th action trajectory into a function (e.g., ) and expected execution costs (e.g. Based on the compilation cost and the expected execution cost, a resource consumption penalty is obtained, for example, calculating... This yields the resource consumption penalty. Then, the information entropy of the parameters corresponding to the m-th group of action trajectories is determined, serving as the generalization potential entropy (e.g., Finally, based on the trajectory gain density, resource consumption penalty, and generalization potential entropy, the utility score corresponding to the m-th action trajectory is obtained. For example, the utility score corresponding to the m-th action trajectory is obtained by summing the trajectory gain density and generalization potential entropy and then subtracting the resource consumption penalty. From multiple historical action trajectories, historical action trajectories with high utility scores (greater than a preset utility score threshold) are selected and converted into encapsulated functions.
[0117] In one specific embodiment, the function code derived from historical action trajectories is also subjected to sandbox verification. Specifically, the code of the selected high-value trajectories is refactored and verified in an isolated environment. For example, the sandbox verification pass criterion is obtained according to the following formula (4): (4) : Represents an indicator function. The value of the indicator function is 1 if the condition is met, and 0 otherwise.
[0118] : indicates the output result of the function code generated by running the above steps (related steps of formula (3)) in the sandbox.
[0119] : Indicates the actual execution result of the task in the historical task log (or historical log).
[0120] : Indicates the semantic similarity of the output results.
[0121] This indicates the preset semantic threshold, for example, the preset semantic threshold is 0.8-0.95.
[0122] : This indicates a security scanning function based on the Abstract Syntax Tree (AST) to detect whether there are illegal calls (such as os.system, rm -rf, etc.) in the function code generated by the above steps (related steps in formula (3)). If no illegal calls are found, then If an illegal call exists, then ≠ .
[0123] AND operation, The value is 1, and In case 1, the verification passed.
[0124] Formula (4) is the quality inspection standard before the function tool (skill) goes online, which can ensure that the generated function can reuse historical experience and is safe. This method combines semantic consistency verification and static security scanning, which can prevent the code generated by the model from having security risks such as infinite loops and unauthorized access to the file system, and ensure the industrial-grade availability of the system.
[0125] Formula (4) above is only an illustrative example. In other embodiments, at least one of semantic consistency verification or static security scanning can be selected for verification. For example, only semantic consistency verification: Or perform a static security scan only: .
[0126] Based on the above exemplary description, it can be seen that in some embodiments, after converting the target trajectory into a function that can be called, the function code included in the function is also verified: Obtain the output of the code corresponding to the function run in the isolated sandbox. ); Obtain the actual result corresponding to the m-th action trajectory in the historical task log ( Based on the semantic similarity between the output and the true result ( ), to obtain the first value (0 or 1) of the first indicator function.
[0127] Call the security scan function of the abstract syntax tree ( ), detect whether there is an illegal call in the code corresponding to the function, and obtain the second value (0 or 1) of the second indicator function.
[0128] Then, based on the first value and / or the second value, the verification result indicating whether the sandbox verification passed is obtained. For example, performing a bitwise AND operation on the first and second values, with an output value of 1, indicates that the function code passed the sandbox verification.
[0129] In one specific embodiment, after step 105, a weighted posterior update based on the execution feedback can also be performed. Specifically, after the task is completed, the graph parameters are updated based on the result feedback to complete the loop closure.
[0130] For example, the weights of edges in a heterogeneous knowledge graph can be updated based on the Heb rule using the following formulas (5) and (6): (5) (6) in, This represents the learning rate, which controls the step size for weight updates. This indicates the current weight (before the update). This represents the weight increment.
[0131] This indicates the final reward value (feedback signal) for this task.
[0132] This represents the node calculated in step 104. Activation level. This represents the neighbor nodes calculated in step 104. Activation level.
[0133] Normalization operation to prevent weights from growing indefinitely.
[0134] The weight update process in formulas (5) and (6) simulates the Hebbian Theory in biological neuroscience, namely, "co-excited neurons are more tightly connected," and introduces task rewards. As a moderating factor, this reinforces the correct logic: only when the task succeeds ( And two nodes (nodes) When all nodes are activated, the node The connections (weights) between them will be strengthened. And an error correction mechanism is provided: if the task fails ( ), related paths (nodes) The weight of the edges between them will be weakened, thereby preventing the intelligent system from repeating the same mistakes and achieving adaptive evolution of the knowledge structure.
[0135] Based on the above exemplary description, it can be seen that in some embodiments, after executing the task corresponding to the query instruction, the initial weights in the heterogeneous knowledge graph can be updated according to the feedback signal obtained by the autonomous agent in executing the task, based on the Heb rule. The specific update method is as follows: obtain the reward value obtained by the autonomous agent in executing the task corresponding to the query instruction, as a feedback signal; based on the Heb rule, obtain the weight increment according to the feedback signal, the activation degree corresponding to the i-th node, the activation degrees corresponding to the neighboring nodes of the i-th node, and the preset learning rate; sum the current initial weights and the weight increments, and normalize the sum to obtain the updated weights.
[0136] The search enhancement generation apparatus provided in the embodiments of this application is described below. The search enhancement generation apparatus described below can be referred to in correspondence with the search enhancement generation method described above.
[0137] This application provides a retrieval enhancement generation device, which can be integrated into an autonomous intelligent agent, specifically integrated into an LLM or integrated into the autonomous intelligent agent but independent of the LLM, such as... Figure 3 As shown, the device may include: The construction module 301 is used to acquire multimodal interaction data corresponding to autonomous intelligent agents, extract entities as nodes from the multimodal interaction data, identify the relationships between entities, establish edges between nodes, and obtain a heterogeneous knowledge graph.
[0138] The weight initialization module 302 is used to determine the initial weights between two adjacent nodes in a heterogeneous knowledge graph.
[0139] The activation module 303 is used to respond to the user's query command, obtain the query vector corresponding to the query command, determine the activation degree of each node in the heterogeneous knowledge graph relative to the query vector, and determine the context information from the heterogeneous knowledge graph based on the activation degree.
[0140] The reasoning module 304 is used by the autonomous intelligent agent to combine context information and execute the task corresponding to the query command.
[0141] The update module 305 is used to update the initial weights in the heterogeneous knowledge graph based on the feedback signals obtained by the autonomous intelligent agent in performing the task and the Heb rule.
[0142] Figure 4 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 4As shown, the electronic device may include: a processor 410, a communication interface 420, a memory 440, and a communication bus 440, wherein the processor 410, the communication interface 420, and the memory 440 communicate with each other via the communication bus 440. The processor 410 can call a computer program stored in the memory 440 to execute steps of the retrieval enhancement generation method, such as including: The process involves acquiring multimodal interaction data corresponding to the autonomous agent, extracting entities as nodes from the multimodal interaction data, identifying relationships between entities, establishing edges between nodes, and obtaining a heterogeneous knowledge graph. It also involves determining the initial weights between adjacent nodes in the heterogeneous knowledge graph, acquiring the query vector corresponding to the received user query command, determining the activation degree of each node in the heterogeneous knowledge graph relative to the query vector (at least based on the initial weights), and determining contextual information from the heterogeneous knowledge graph based on the activation degree, and finally, the autonomous agent executing the task corresponding to the query command by combining the contextual information.
[0143] Furthermore, the logical instructions in the aforementioned memory 440 can be implemented as software functional units and, when sold or used as independent products, 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 a portion 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 several 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 in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0144] On the other hand, embodiments of this application also provide a computer program product, which includes a computer program that can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can perform the steps of the retrieval enhancement generation method provided in the above embodiments, such as including: The process involves acquiring multimodal interaction data corresponding to the autonomous agent, extracting entities as nodes from the multimodal interaction data, identifying relationships between entities, establishing edges between nodes, and obtaining a heterogeneous knowledge graph. It also involves determining the initial weights between adjacent nodes in the heterogeneous knowledge graph, acquiring the query vector corresponding to the received user query command, determining the activation degree of each node in the heterogeneous knowledge graph relative to the query vector (at least based on the initial weights), and determining contextual information from the heterogeneous knowledge graph based on the activation degree, and finally, the autonomous agent executing the task corresponding to the query command by combining the contextual information.
[0145] On the other hand, embodiments of this application also provide a processor-readable storage medium storing a computer program for causing a processor to perform the steps of the methods provided in the above embodiments, such as including: The process involves acquiring multimodal interaction data corresponding to the autonomous agent, extracting entities as nodes from the multimodal interaction data, identifying relationships between entities, establishing edges between nodes, and obtaining a heterogeneous knowledge graph. It also involves determining the initial weights between adjacent nodes in the heterogeneous knowledge graph, acquiring the query vector corresponding to the received user query command, determining the activation degree of each node in the heterogeneous knowledge graph relative to the query vector (at least based on the initial weights), and determining contextual information from the heterogeneous knowledge graph based on the activation degree, and finally, the autonomous agent executing the task corresponding to the query command by combining the contextual information.
[0146] Processor-readable storage media can be any available medium or data storage device that the processor can access, including but not limited to magnetic storage (such as floppy disks, hard disks, magnetic tapes, magneto-optical disks (MOs), etc.), optical storage (such as CDs, DVDs, BDs, HVDs, etc.), and semiconductor storage (such as ROMs, EPROMs, EEPROMs, non-volatile memory (NAND flash), solid-state drives (SSDs)).
[0147] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and 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 modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0148] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., including several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods of various embodiments or some parts of embodiments.
[0149] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application.
Claims
1. A retrieval enhancement generation method, characterized in that, The method includes: Acquire multimodal interaction data corresponding to autonomous intelligent agents, extract entities as nodes from the multimodal interaction data, identify the relationships between entities, establish edges between nodes, and obtain a heterogeneous knowledge graph. Determine the initial weights between two adjacent nodes in the heterogeneous knowledge graph; In response to receiving a user's query command, obtain the query vector corresponding to the query command; At least based on the initial weights, the activation degree of each node in the heterogeneous knowledge graph relative to the query vector is determined, and context information is determined from the heterogeneous knowledge graph based on the activation degree; The autonomous intelligent agent, in conjunction with the context information, executes the task corresponding to the query instruction.
2. The method according to claim 1, characterized in that, Determining the initial weights between two adjacent nodes in the heterogeneous knowledge graph includes: Determine the point mutual information between the i-th node and the j-th node; the point mutual information represents the information gain of the entity corresponding to the i-th node and the entity corresponding to the j-th node; the i-th node and the j-th node are two adjacent nodes in the heterogeneous knowledge graph; Determine the first occurrence of the i-th node and the j-th node together; Determine the second number of times the i-th node appears independently and the third number of times the j-th node appears independently; The initial weights between the i-th node and the j-th node in the heterogeneous knowledge graph are obtained based at least on the point mutual information, the first count, the second count, and the third count.
3. The method according to claim 1, characterized in that, Determining the activation degree of each node in the heterogeneous knowledge graph relative to the query vector, at least based on the initial weights, includes: Obtain the system timestamp of the i-th node at the current moment and the first timestamp of the i-th node's most recent access; A time decay term is obtained based on the system timestamp, the first timestamp, and the memory half-life constant; wherein, the memory half-life constant is a preset constant used to control the forgetting rate; Count the cumulative number of times the i-th node is retrieved; determine the baseline threshold for the number of retrieved hits and the hyperparameters; the hyperparameters are used to adjust the steepness of the memory consolidation curve; The memory strength consolidation term is obtained based on the cumulative number of times, the baseline threshold, and the hyperparameters; Determine the i-th node vector corresponding to the i-th node; calculate the semantic similarity between the query vector and the i-th node vector to obtain the semantic similarity term; Determine the activation degree of each neighbor node in the set of upstream neighbor nodes of the i-th node in the heterogeneous knowledge graph; Based on the initial weights between the neighboring nodes and the i-th node, and the activation degrees corresponding to the neighboring nodes, the activation diffusion term is obtained; The semantic similarity term and the activation diffusion term are weighted and summed to obtain the semantic matching and activation diffusion terms. The activation degree of the i-th node is obtained based on the time decay term, the memory strength consolidation term, and the semantic matching and activation diffusion term.
4. The method according to any one of claims 1-3, characterized in that, The method further includes: The historical task logs of the autonomous intelligent agent are periodically scanned, and multiple historical action trajectories are extracted from the historical task logs. The utility of each of the multiple historical action trajectories is evaluated; based on the evaluation results, at least one action trajectory is selected from the multiple historical action trajectories as the target trajectory. The target trajectory is converted into a function that can be invoked.
5. The method according to claim 4, characterized in that, The utility of each of the aforementioned historical action trajectories was evaluated, including: Determine the frequency of occurrence of the m-th group of historical action trajectories; Calculate the average success rate of performing multiple tasks based on the historical action trajectory of the m-th group; Count the number of atomic steps included in the m-th group of historical action trajectories; The trajectory gain density is obtained based on the occurrence frequency, the average success rate, and the number of atomic steps. Determine the compilation cost and expected execution cost of converting the m-th group of action trajectories into a function; Based on the compilation cost and the expected execution cost, a resource consumption penalty is obtained; The information entropy of the parameters corresponding to the m-th group of action trajectories is determined as the generalization potential entropy. The utility score corresponding to the m-th group of action trajectories is obtained based on the trajectory benefit density, the resource consumption penalty term, and the generalization potential entropy.
6. The method according to claim 4, characterized in that, After converting the target trajectory into a function that can be invoked, the method further includes: Obtain the output of the code corresponding to the function running in an isolated sandbox; Obtain the actual result corresponding to the m-th action trajectory in the historical task log; Based on the semantic similarity between the output result and the real result, the first value of the first indicator function is obtained; And / or, The security scanning function of the abstract syntax tree is invoked to detect whether there are illegal calls in the code corresponding to the function, and the second value of the second indicator function is obtained. Based on the first value and / or the second value, a verification result is obtained indicating whether the sandbox verification has passed.
7. The method according to claim 3, characterized in that, After executing the task corresponding to the query instruction, the method further includes: The reward value obtained by the autonomous intelligent agent in executing the task corresponding to the query instruction is used as the feedback signal; Based on the Heb rule, the weight increment is obtained according to the feedback signal, the activation degree of the i-th node, the activation degree of the neighboring nodes of the i-th node, and the preset learning rate. The current initial weights and the weight increments are summed, and the sum is normalized to obtain the updated weights.
8. A retrieval enhancement generation device, characterized in that, The device includes: The module is used to acquire multimodal interaction data corresponding to autonomous intelligent agents, extract entities as nodes from the multimodal interaction data, identify the relationships between entities, establish edges between nodes, and obtain a heterogeneous knowledge graph. A weight initialization module is used to determine the initial weights between two adjacent nodes in the heterogeneous knowledge graph. The activation module, in response to receiving a user's query command, obtains the query vector corresponding to the query command, determines the activation degree of each node in the heterogeneous knowledge graph relative to the query vector, and determines the context information from the heterogeneous knowledge graph based on the activation degree; The reasoning module is used by the autonomous intelligent agent to execute the task corresponding to the query instruction in combination with the context information; The update module is used to update the initial weights in the heterogeneous knowledge graph based on the feedback signal obtained by the autonomous intelligent agent in performing the task and the Heb rule.
9. An electronic device comprising a processor and a memory storing a computer program, characterized in that, When the processor executes the computer program, it implements the retrieval enhancement generation method according to any one of claims 1 to 7.
10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the retrieval enhancement generation method according to any one of claims 1 to 7.