Context construction method and device for intelligent agent and storage medium
By employing an agent context management method, which uses intelligent storage and consistency judgment based on semantic relevance and long-term value scores, the problems of information loss and redundant conflicts in agent context management are solved, achieving efficient and accurate context management and response.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- ZHONGKE YUNGU TECH
- Filing Date
- 2025-12-22
- Publication Date
- 2026-04-17
AI Technical Summary
Existing agent context management methods are limited by the model input token window, which restricts the context length, makes information easy to be truncated, and fails to execute tasks correctly. Furthermore, context management based on external storage and retrieval is complex to maintain in terms of real-time performance and consistency.
By acquiring the current input information in the agent's interaction round, the current semantic representation is generated. Based on the semantic relevance and long-term value score, it is stored in the short-term or long-term memory bank, and consistency judgment is performed to avoid redundancy and conflict. Similar memory entries are merged through periodic cluster analysis, and the long-term memory bank is optimized using the Lloyd algorithm.
It breaks through the context length limit, reduces token consumption and computation time, improves the accuracy and consistency of answers, avoids information interference and knowledge conflict, and enhances the response quality of the intelligent agent.
Smart Images

Figure CN121882249A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and specifically to a method, apparatus and storage medium for constructing context for intelligent agents. Background Technology
[0002] Intelligent agents are a crucial research and application area in artificial intelligence, typically referring to intelligent entities capable of perceiving their environment, making autonomous decisions, and executing actions. During execution, the agent's "working memory"—its context—determines its actions. However, when agents perform complex tasks, the context quickly becomes cluttered as tools are invoked and large models accumulate their processing results. This leads to soaring costs, increased response delays, and even performance degradation issues such as context poisoning and context distraction. To address this deficiency, context management is necessary. Context management for agents involves collecting, parsing, and utilizing contextual information during interactions to understand and monitor the agent's state in real time. This allows for the assessment of whether behavior is reasonable or abnormal, timely detection of contextual inconsistencies and their causes, and prediction of the agent's state evolution during task execution.
[0003] However, existing agent context management methods are based on session windows, which are limited by the model input token window, resulting in a restricted context length. Old information is easily truncated, leading to information loss and inability to execute tasks correctly. Furthermore, context management based on external storage and retrieval makes retrieval quality dependent on vectorization and indexing strategies, and real-time performance and consistency maintenance are complex. Therefore, a new method for agent context management is urgently needed. Summary of the Invention
[0004] The purpose of this application is to provide a method, apparatus, and storage medium for constructing context for intelligent agents.
[0005] To achieve the above objectives, the first aspect of this application provides a context construction method for an intelligent agent, comprising: obtaining the current input information of the intelligent agent in an interaction round, and parsing and generating the corresponding current semantic representation based on the current input information; Determine the semantic relevance between the current semantic representation and the current dialogue task context; Calculate the long-term value score of the current semantic representation, where the long-term value score is a function value calculated by a predefined function based on the frequency of the current semantic representation within a preset historical period and its logical consistency with existing knowledge in the long-term memory. If the semantic relevance is greater than a first predetermined threshold, the current semantic representation is stored in short-term memory. If the long-term value score is greater than the second predetermined threshold, the current semantic representation is stored in the long-term memory. When the agent needs to generate a response to the current input information, it retrieves target memory content that is semantically related to the current input information from the short-term memory bank and the long-term memory bank; The target memory content is combined with the current input information to form a prompt message, which is then input into the large language model to generate a response to the current input information.
[0006] In this embodiment of the application, the method further includes: before storing the current semantic representation in the short-term memory or long-term memory, performing a consistency judgment on the current semantic representation with existing memory entries in the short-term memory and long-term memory, the consistency judgment including redundancy judgment and conflict judgment; if the current semantic representation fails the redundancy judgment or conflict judgment, it is determined that the current semantic representation has failed the consistency judgment and the current semantic representation is refused to be stored; if the current semantic representation passes both the redundancy judgment and conflict judgment, it is determined that the current semantic representation has passed the consistency judgment and the current semantic representation is stored in the short-term memory or long-term memory.
[0007] In this embodiment, the consistency judgment between the current semantic representation and existing memory entries in the short-term memory bank and long-term memory bank includes: calculating the vector similarity between the current semantic representation and each existing memory entry; if there are existing memory entries with a vector similarity greater than a preset redundancy threshold, determining that the current semantic representation has failed the redundancy judgment and refusing to store the current semantic representation; using a relation extraction model, extracting triples in subject-verb-object format from the current semantic representation and from each existing memory entry; comparing the triples extracted from the current semantic representation with the triples extracted from each existing memory entry; if there are two triples with the same subject and object, but the predicates are semantically mutually exclusive, determining that the two triples have a logical conflict, determining that the current semantic representation has failed the conflict judgment, and updating or replacing the conflicting knowledge in the existing memory entries with the information in the current semantic representation.
[0008] In this embodiment of the application, the method further includes: updating existing memory entries according to the current semantic representation when the current semantic representation fails the redundancy judgment, and / or performing deduplication operation on the existing memory entries.
[0009] In this embodiment of the application, the method further includes: performing cluster analysis on memory entries in the long-term memory bank periodically based on a preset update cycle, merging multiple semantically similar memory entries into a new knowledge unit; wherein, the new knowledge unit is represented by a centroid vector as its semantic core feature in the vector space, and the centroid vector is calculated by the average of the semantic vectors of multiple memory entries; and replacing the multiple memory entries corresponding to the new knowledge unit with the new knowledge unit to update the long-term memory bank.
[0010] In this embodiment, the cluster analysis is performed using the Lloyd algorithm, which minimizes the sum of squared distances between memory entries within a cluster and centroid vectors through iterative allocation and update steps until convergence.
[0011] In this embodiment, obtaining the current input information of the agent in one interaction round and generating the corresponding current semantic representation based on the current input information includes: obtaining the current input information of the agent in one interaction round, wherein the current input information includes at least one of text, speech, image, and video; if the current input information includes speech data, calling a speech recognition model to convert the speech data into first text; if the current input information includes image data, calling an optical character recognition model to extract text information from the image data to obtain second text; if the current input information includes video data, extracting frame images from the video data at predetermined intervals, and sequentially extracting text information from each frame image through an optical character recognition model, and concatenating them into third text in chronological order; and concatenating and extracting entities from the initial text data, first text, second text, and third text in the current input information to generate the current semantic representation.
[0012] In this embodiment of the application, determining the semantic relevance between the current semantic representation and the current dialogue task context includes: using an embedding model to convert the current semantic representation and the current task dialogue context into corresponding embedding vectors respectively; and determining the cosine similarity between the two embedding vectors as the semantic relevance.
[0013] Among them, semantic relevance .in, .
[0014] In this embodiment, the long-term value score of the current semantic representation is calculated according to the following formula:
[0015] in, This refers to the long-term value score; , All are weighting coefficients;
[0016] This refers to the frequency of the current semantic representation within a preset historical time period. This refers to the logical consistency between the current semantic representation and the existing knowledge in the long-term memory. This refers to the current semantic representation. This refers to the parameters of the model layer.
[0017] In the embodiments of this application, , The values are 0.6 and 0.4, respectively.
[0018] The first predetermined threshold is 0.75, and the second predetermined threshold is 0.75.
[0019] In this embodiment of the application, memory entries in the long-term memory bank are labeled with task scenario tags; When an agent needs to generate a response to the current input information, it retrieves target memory content from the long-term memory that is semantically related to the current input information, including: based on the current task scenario, prioritizing the retrieval of memory entries that match the labels of the current task scenario.
[0020] A second aspect of this application provides a context building apparatus for an intelligent agent, comprising: The memory is configured to store instructions; The processor is configured to retrieve instructions from memory and, when executing instructions, to implement the aforementioned context construction method for intelligent agents.
[0021] A third aspect of this application provides a machine-readable storage medium storing instructions that, when executed by a processor, cause the processor to perform the aforementioned context construction method for an intelligent agent.
[0022] This approach doesn't passively store all historical dialogues. Instead, it actively evaluates the input information, categorizing it and storing it in memory storage systems of different natures and purposes. It then efficiently and accurately recalls the information when needed. Through selective memorization and recall, it theoretically manages and utilizes an infinite amount of historical information, overcoming the limitations of context length. Furthermore, each time the large model is provided with a carefully selected, concise context, significantly reducing token consumption and computation time, and substantially lowering computational costs and latency. Moreover, this approach avoids irrelevant information interference and conflicts between old and new knowledge, making responses more focused, accurate, and consistent, thus improving response quality and consistency.
[0023] Other features and advantages of the embodiments of this application will be described in detail in the following detailed description section. Attached Figure Description
[0024] The accompanying drawings are provided to further illustrate the embodiments of this application and form part of the specification. They are used together with the following detailed description to explain the embodiments of this application, but do not constitute a limitation on the embodiments of this application. In the drawings: Figure 1 The schematic diagram illustrates a flow chart of a context construction method for an intelligent agent according to an embodiment of this application; Figure 2A The schematic diagram illustrates a flow chart of a context construction method for an intelligent agent according to another embodiment of this application; Figure 2B This illustration schematically shows a data preprocessing diagram according to an embodiment of the present application; Figure 3 This schematic diagram illustrates a structural block diagram of a context building apparatus for an intelligent agent according to an embodiment of this application; Figure 4 The diagram illustrates the internal structure of a computer device according to an embodiment of this application. Detailed Implementation
[0025] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. It should be understood that the specific embodiments described herein are only for illustration and explanation of the embodiments of this application and are not intended to limit the embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without creative effort are within the scope of protection of this application.
[0026] Figure 1 The illustration schematically shows a flowchart of a context construction method for an intelligent agent according to an embodiment of this application. For example... Figure 1 As shown in one embodiment of this application, a context construction method for an intelligent agent is provided, including the following steps: Step 101: Obtain the current input information of the agent in one interaction round, and parse and generate the corresponding current semantic representation based on the current input information; Step 102: Determine the semantic relevance between the current semantic representation and the current dialogue task context; Step 103: Calculate the long-term value score of the current semantic representation. The long-term value score is a function value calculated by a predefined function based on the frequency of the current semantic representation within a preset historical period and its logical consistency with existing knowledge in the long-term memory. Step 104: If the semantic relevance is greater than the first predetermined threshold, store the current semantic representation in the short-term memory. Step 105: If the long-term value score is greater than the second predetermined threshold, store the current semantic representation in the long-term memory. Step 106: When the agent needs to generate a response to the current input information, retrieve target memory content that is semantically related to the current input information from the short-term memory bank and the long-term memory bank; Step 107: Combine the target memory content with the current input information to form a prompt message and input it into the large language model to generate a response to the current input information.
[0027] An agent is an artificial intelligence entity capable of perceiving its environment (such as user input), making autonomous decisions, and executing actions (such as generating responses or invoking tools). In this scheme, it specifically refers to a program system based on a large language model, possessing multi-turn dialogue and task execution capabilities. An interaction round refers to a complete "input-output" interaction cycle between the agent and the user. A round begins with the agent receiving new input from the user (current input information) and ends with the agent generating a response to that input. Current input information refers to the original information provided by the user to the agent in the current interaction round. This current input information can be single or any combination of multimodal data such as text, speech, images, or video. Current semantic representation refers to the unified, machine-understandable meaning expression generated after parsing, transforming, and fusing the current input information. Current semantic representation is the result of converting multimodal information, such as speech-to-text and image OCR recognition data, into text, and then performing entity extraction and semantic encoding, serving as the core data unit for all subsequent processing. The processor can acquire the agent's current input information in an interaction round and parse it to generate the corresponding current semantic representation. Furthermore, the processor can determine the semantic relevance between the current semantic representation and the current dialogue task context. The current dialogue task context refers to the current state information of the ongoing task or session that the agent is processing. It consists of the recent dialogue history most relevant to the current task, executed steps, and temporary states; it is a dynamically updated set of information used to maintain the coherence of the session. Semantic relevance is a quantitative metric used to measure the immediate semantic relevance between the current semantic representation and the current dialogue task context. This metric is typically obtained by calculating the cosine similarity between the two in vector space; a higher value indicates a greater relevance to the current task.
[0028] Next, the processor can calculate the long-term value score of the current semantic representation. This score is a function value calculated using a predefined function, based on the frequency of the current semantic representation's occurrence within a preset historical period and its logical consistency with existing knowledge in the long-term memory. The long-term value score is also a quantitative indicator used to assess whether the current semantic representation possesses lasting value beyond the current session. The long-term value score is calculated by combining two factors using a predefined function: the frequency of the current semantic representation's occurrence within the preset historical period and the logical consistency between the current semantic representation and existing knowledge in the long-term memory. Specifically, frequency refers to the number of times the current semantic representation has appeared in all interactions within the preset historical period (e.g., the past week, month). Logical consistency refers to the degree to which the current semantic representation conforms factually and logically to the solid knowledge stored in the long-term memory.
[0029] In one specific embodiment, the long-term value score of the current semantic representation can be calculated according to the following formula:
[0030] in, This refers to the long-term value score; , All are weighting coefficients;
[0031] This refers to the frequency of the current semantic representation within a preset historical time period. This refers to the logical consistency between the current semantic representation and the existing knowledge in the long-term memory. This refers to the current semantic representation. This refers to the parameters of the model layer.
[0032] Specifically, in one embodiment, , The values are 0.6 and 0.4, respectively.
[0033] Next, based on the comparison results between semantic relevance and long-term value score and their corresponding predetermined thresholds, it can be determined whether to store the current semantic representation in short-term memory or long-term memory. Specifically, if the semantic relevance is greater than the first predetermined threshold, the current semantic representation can be stored in short-term memory. If the long-term value score is greater than the second predetermined threshold, the current semantic representation can be stored in long-term memory. Short-term memory is a storage area for storing highly timely and relevant information. It mainly stores context closely related to the ongoing task, with frequent updates and a short lifespan, similar to working memory. Long-term memory is a persistent storage area for storing high-value and highly stable knowledge. It stores experience, facts, and general knowledge extracted from historical interactions; information updates more slowly but is retained for a long time, similar to a knowledge base or experience base. The first and second predetermined thresholds are pre-set numerical judgment thresholds. In a specific embodiment, both the first and second predetermined thresholds can be set to 0.75. The first predetermined threshold is used to determine whether the information is timely and relevant enough to be stored in short-term memory. The second predetermined threshold is used to determine whether the information is stable and valuable enough to be stored in long-term memory.
[0034] Furthermore, when the agent needs to generate a response to the current input information, the processor can retrieve target memory content semantically relevant to the current input information from the short-term and long-term memory banks. This target memory content is then combined with the current input information to form a prompt message, which is input into the large language model to generate a response to the current input information. Here, the target memory content refers to the most useful information fragments dynamically retrieved and selected from the short-term and long-term memory banks based on their semantic relevance to the current input information during response generation. The prompt message refers to the final combination of instructions and context input to the large language model. In this scheme, it refers to the optimized model input text formed by intelligently concatenating the current input information with the retrieved target memory content, used to guide the large model to generate a more accurate and relevant response.
[0035] like Figure 2A As shown, this scheme can filter and fuse high-value information from short-term / long-term memory based on task requirements and context priority to form a concise and efficient contextual input. When the large model determines that the user's current input task cannot be completed directly, it can select memories with high vector similarity from the short-term / long-term memory, concatenate them with the input, and send them to the large model.
[0036] As can be seen, this solution aims to address the core problems of information loss, redundancy, conflict, and low retrieval efficiency caused by the limited context window in traditional large-scale model applications. Its core innovation lies in the fact that this solution does not passively store all historical dialogues, but actively and valuablely evaluates the input information and categorizes it into different types of memory storage for different purposes, then efficiently and accurately recalls it when needed. It can be seen that, through selective memory and recall, this solution can theoretically manage and utilize an infinite amount of historical information, breaking through the context length limitation. Furthermore, each time the large-scale model is provided with a carefully selected, concise context, significantly reducing token consumption and computation time, and greatly lowering computational costs and latency. Moreover, this solution avoids interference from irrelevant information and conflicts between old and new knowledge, making the answers more focused, accurate, and consistent, thus improving the quality and consistency of the responses.
[0037] In one embodiment, the method further includes: before storing the current semantic representation in a short-term memory or a long-term memory, performing a consistency check on the current semantic representation with existing memory entries in the short-term memory and the long-term memory, the consistency check including redundancy check and conflict check; if the current semantic representation fails the redundancy check or conflict check, determining that the current semantic representation has failed the consistency check and refusing to store the current semantic representation; if the current semantic representation passes both the redundancy check and conflict check, determining that the current semantic representation has passed the consistency check and storing the current semantic representation in the short-term memory or the long-term memory.
[0038] In this embodiment, a consistency check is also performed on the current semantic representation. Specifically, the current semantic representation is compared with existing memory entries in the short-term and long-term memory banks to check for redundancy or conflicts. That is, if the current semantic representation is found to be identical to an existing memory entry, it is considered redundant, and there is no need to store it again, avoiding the storage and retrieval of large amounts of duplicate content and saving computational and storage resources. Furthermore, if the current semantic representation conflicts with an existing memory entry, there is no need to store that existing memory entry, otherwise the stored content would be contradictory. This conflict resolution mechanism allows the memory bank to automatically evolve with new evidence and information, enabling the agent to learn and correct its cognition. Specifically, if the vector similarity between the current semantic representation and each existing memory entry is greater than a preset redundancy threshold, the current semantic representation is considered redundant, meaning it has failed the consistency check. In cases where the current semantic representation fails the consistency check, the processor can refuse to store the current semantic representation and / or prioritize updating existing memory entries. If the current semantic representation passes the consistency check, the processor can store it in either short-term memory or long-term memory. In summary, if the vector similarity between the current semantic representation and any existing entry in either short-term or long-term memory is high (e.g., the vector similarity exceeds a preset redundancy threshold), the current semantic representation is considered to have failed the redundancy check. If the current semantic representation conflicts with any existing entry in either short-term or long-term memory (e.g., the knowledge is contradictory or conflicting), the current semantic representation is considered to have failed the conflict check. If the current semantic representation fails the redundancy check or the conflict check, it is considered to have failed the consistency check. Prioritizing updating existing entries means not directly storing the current semantic representation as a new entry, but using it to modify or overwrite conflicting older entries. This reflects the principle of using new information to correct old knowledge.
[0039] Specifically, when performing redundancy checks, the input can be the current dialogue content or newly added knowledge fragments. The system's stored context memory set is: {m1, m2, m3, ..., mi}. Similarly, the Embing model is used to convert all text into semantic vectors. Calculate the cosine similarity between the new input and each memory: If the similarity is greater than 0.95, it indicates that there may be redundant information (i.e., the semantic similarity with existing memory is too high, meaning that this information does not need to be stored in memory again). Conflict judgment can also be performed, and relation extraction can be performed on the semantic content to extract triples.
[0040] in, This refers to (subject / entity 1). It refers to (predicate / relation). : refers to (object / entity 2).
[0041] A logical conflict can be identified if the following conditions exist:
[0042] For inputs with logical conflicts, it is necessary to perform time expiration checks on the memorized information. Indicates the attenuation value. Indicates the attenuation frequency. For the present time, The time when the conflict occurred: like If the value is less than the set threshold, the memory information is marked as "expired" and the new user input (the current input information) is used to replace the memory information.
[0043] Specifically, in one embodiment, the consistency determination of the current semantic representation with existing memory entries in the short-term memory bank and long-term memory bank includes: calculating the vector similarity between the current semantic representation and each existing memory entry; if there are existing memory entries with vector similarity greater than a preset redundancy threshold, determining that the current semantic representation has failed the redundancy judgment and refusing to store the current semantic representation; using a relation extraction model, extracting triples in subject-verb-object format from the current semantic representation and from each existing memory entry; comparing the triples extracted from the current semantic representation with the triples extracted from each existing memory entry; if there are two triples with the same subject and object, but the predicates are semantically mutually exclusive, determining that the two triples have a logical conflict, determining that the current semantic representation has failed the conflict judgment, and updating or replacing the conflicting knowledge in the existing memory entries with the information in the current semantic representation.
[0044] Vector similarity refers to the degree of closeness between two semantic representations in a high-dimensional vector space, usually calculated using cosine similarity. The value range is [-1, 1], with higher values (closer to 1) indicating closer meanings in the mathematical space understood by the model. The preset redundancy threshold is a pre-defined similarity threshold used to determine whether information constitutes redundancy. For example, this value can be set to 0.85 or 0.95, depending on project requirements. When the vector similarity between two data points exceeds this threshold, the system determines that the two pieces of information are semantically highly repetitive, and the new information can be classified as redundant. Therefore, if the vector similarity between the current semantic representation and the vector of any existing memory entry in the short-term and long-term memory banks is greater than the preset redundancy threshold, the current semantic representation is considered to have failed the redundancy check and is thus considered redundant information. In this case, the processor can refuse to store the current semantic representation. In one embodiment, if the current semantic representation fails the redundancy check, the processor can also update existing memory entries or perform deduplication operations on existing memory entries based on the current semantic representation. That is, the processor can choose not to directly store the current semantic representation as a new entry, but instead use the current semantic representation to modify or overwrite existing memory entries that conflict with it. In other words, it can use the latest knowledge (the current semantic representation) to overwrite the old knowledge (existing memory entries), thereby updating the knowledge. Alternatively, it can proactively check whether multiple similar entries already exist in the library and merge or clean them up to further optimize the storage structure.
[0045] The relation extraction model is a natural language processing model used to automatically identify and extract structured relational facts from unstructured text. Its output is typically a triple in the form of subject, predicate, and object. A triple is a basic data structure representing knowledge, formatted as (subject, predicate, object). For example, ("Operator Zhang San", "Execute", "Initiate Check"), its function is to convert natural language descriptions into a standardized form that can be logically compared by machines. Semantic mutual exclusion of predicates refers to two triples where the subject and object are the same, but the predicates are contradictory in meaning or cannot be simultaneously true. For example, for the same subject "valve V1", the predicates "state is open" and "state is closed" are semantically mutually exclusive. This is the core criterion for judging logical conflicts. Conflicting knowledge refers to the specific knowledge or factual statements that exist in existing memory entries and logically directly contradict new input information (such as the current semantic representation). Each existing memory entry in the short-term memory bank and long-term memory bank also has a corresponding triple. For ease of description, the triple extracted from the current semantic representation can be called the first triple, and the triple extracted from each existing memory entry in the short-term and long-term memory banks can be called the second triple. Next, the first triple is compared with each second triple to check if there exists a second triple with the same subject and object, but whose predicates are semantically mutually exclusive. If such a case exists, it indicates a logical conflict between the second triple and the first triple of the current semantic representation. In this case, the current semantic representation can be considered to have failed the conflict judgment. The processor can update or replace conflicting knowledge in existing memory entries with information from the current semantic representation, i.e., perform knowledge correction. Using new information to cover contradictory parts in old memories allows the agent's memory to keep pace with the times, enabling self-correction and learning.
[0046] Assuming the current semantic representation passes both redundancy and conflict checks—meaning it neither duplicates nor conflicts with existing entries in the knowledge base—the processor can determine that the current semantic representation has passed consistency checks and can be stored in either short-term or long-term memory. The choice of which memory to store it in is determined by the semantic relevance and long-term value score.
[0047] This implementation, through specific algorithms and clearly defined rules, achieves automated and precise detection and processing of information redundancy and logical conflicts. This ensures the high quality and purity of the database memory, a fundamental prerequisite for subsequent efficient retrieval and high-quality context generation.
[0048] In one embodiment, the method further includes: performing cluster analysis on memory entries in the long-term memory bank periodically based on a preset update cycle, merging multiple semantically similar memory entries into a new knowledge unit; wherein the new knowledge unit is represented by a centroid vector as its semantic core feature in the vector space, and the centroid vector is calculated by averaging the semantic vectors of multiple memory entries; replacing the multiple memory entries corresponding to the new knowledge unit to update the long-term memory bank.
[0049] The preset update cycle is a time interval parameter pre-set by technicians. For example, it can be set every 24 hours or after processing 1000 interactions. The preset update cycle can serve as a fixed clock or event counter to trigger the current optimization operation, ensuring that the optimization process is executed regularly and automatically without manual intervention. Clustering analysis is an unsupervised machine learning method that aims to divide a set of memory entries into multiple clusters or categories according to the principle of grouping similarities, so that objects within the same cluster have the highest possible similarity, while objects in different clusters have the lowest possible similarity. A knowledge unit refers to a new structured knowledge entity formed after clustering analysis. In this embodiment, a knowledge unit is not a single numerical value, but a data object whose core attribute represents the common semantics abstracted from multiple specific and scattered memory entries. It can contain statistical information, summaries, or association indexes of the original entries. In this embodiment, based on the preset update cycle, clustering analysis can be performed periodically on memory entries in the long-term memory bank, merging multiple semantically similar memory entries into new knowledge units. The processor can run a clustering analysis algorithm on the semantic vector set of all memory entries, automatically dividing these vectors into K clusters. Within the same cluster, all memory entries whose semantic vectors are close to each other in mathematical space mean that they describe the same, similar, or highly related facts, concepts, or experiences. Furthermore, the processor can calculate the centroid vector for each newly discovered cluster. The centroid vector, in cluster analysis of vector space, represents the central location of a cluster (i.e., a knowledge unit). It is typically calculated as the arithmetic mean of all member vectors within the cluster (i.e., the semantic vectors of multiple memory entries). The centroid vector is not the knowledge unit itself, but rather its coordinates or index in the entire semantic space. A semantic vector is a fixed-length, high-dimensional numerical vector obtained by transforming a memory entry (text) through an embedding model. This vector encodes the deep semantics of the text and is the basis for vector similarity calculation and cluster analysis. For each newly created knowledge unit, the processor can perform a crucial write operation: using this knowledge unit to replace multiple memory entries originally belonging to that cluster in the long-term memory, thereby updating the long-term memory. Therefore, all subsequent vector-based retrieval operations will shift their comparison target from a large number of original memory entry vectors to a smaller number of centroid vectors of knowledge units, resulting in a significant improvement in retrieval speed and a reduction in response latency.
[0050] Specifically, in one embodiment, the cluster analysis is performed using the Lloyd algorithm, which minimizes the sum of squared distances between intra-cluster memory entries and centroid vectors through iterative allocation and update steps until convergence.
[0051] The Lloyd algorithm is a classic iterative optimization algorithm for solving clustering problems, often referred to as the standard form of the K-Means algorithm. Its core idea is to gradually find the optimal grouping of data by repeatedly performing two steps (assignment and update). The assignment step is the first step in a single iteration of the Lloyd algorithm. In this step, the algorithm traverses each memory entry (represented by its semantic vector) in the long-term memory, calculates the distance (usually Euclidean distance) between the entry and all current centroid vectors, and reassigns it to the cluster represented by the nearest centroid vector. This step determines which knowledge unit each memory entry belongs to. The update step is the second step in a single iteration of the Lloyd algorithm. After all memory entries have been reassigned, the algorithm recalculates the centroid vector for each cluster. The new centroid vector is the arithmetic mean of the semantic vectors of all current members (memory entries) within that cluster. This step updates the core feature representation of each "knowledge unit" based on the new membership composition. The sum of squared distances is the objective function that the Lloyd algorithm optimizes, also known as the sum of squared errors within the cluster. For the entire clustering result, it is the sum of the squared distances between each memory entry in all clusters and the centroid vector of its respective cluster. Minimizing this sum means that the algorithm strives to make members within the same cluster as tightly clustered around the centroid as possible, thus ensuring the compactness and representativeness of the clustering result. In this scheme, after the assignment step is executed, the clusters to which all memory entries belong no longer change; or, the algorithm is considered to have converged when the distance moved by the new centroid vector calculated in the update step compared to the old centroid vector in the previous round is less than a very small threshold. At this point, the objective function (the sum of squared distances) has approached a local minimum, and the optimization process automatically stops. By pursuing the minimization of the sum of squared distances, the algorithm ensures that each knowledge unit (and its centroid vector) generated in the end can mathematically represent its class of memory in the most compact way, maximizing the preservation of common information and discarding irrelevant details, thus achieving high-quality knowledge abstraction. It can be seen that the Lloyd algorithm, with its clear structure and fast convergence speed, is very suitable as an automated maintenance task that runs periodically in the background. This algorithm makes the optimization process of the long-term memory completely free of human intervention and can process large-scale data within an acceptable time. The Lloyd algorithm is used for long-term memory clustering and reconstruction to prevent fragmentation, form high-level abstract knowledge units, and enhance retrieval and memory efficiency.
[0052] Specifically, to prevent the fragmentation of long-term memory, the entire long-term memory bank can be periodically clustered, merging similar memories into more abstract and representative knowledge units. For a long-term memory vector set {V1, V2, V3, ..., Vi}, K knowledge clusters {C1, C2, C3, ..., Ck} are generated, each cluster represented by its centroid ck. The goal is to minimize the sum of squared distances within the clusters, as shown in the following formula:
[0053] in, It refers to the vector representation (feature vector) of the i-th sample; It refers to the center of the k-th cluster; It is the loss function of the K-means clustering algorithm.
[0054] Next, updates can be performed using the Lloyd algorithm. First, allocation is performed, where... The formula for finding the cluster index that minimizes the distance is as follows: Updated again: Repeat the above two steps until convergence. Wherein, This refers to determining the cluster number of each data point i for all sample data points. .
[0055] In one embodiment, obtaining the agent's current input information in one interaction round and generating a corresponding current semantic representation based on the current input information includes: obtaining the agent's current input information in one interaction round, wherein the current input information includes at least one of text, speech, image, and video; if the current input information includes speech data, calling a speech recognition model to convert the speech data into first text; if the current input information includes image data, calling an optical character recognition model to extract text information from the image data to obtain second text; if the current input information includes video data, extracting frame images from the video data at predetermined intervals, and sequentially extracting text information from each frame image using an optical character recognition model, and concatenating them into third text in chronological order; and concatenating and extracting entities from the initial text data, first text, second text, and third text in the current input information to generate the current semantic representation.
[0056] like Figure 2BAs shown, in this embodiment, the current input information includes at least one of text, speech, image, and video. That is, the current input information can include one or more types of data, meaning it can simultaneously or individually contain any combination of text, speech, image, and video. When the current input information includes speech data, the processor can call a speech recognition model to convert the speech data into first text. The speech recognition model is an artificial intelligence model specifically designed to automatically convert continuous speech audio signals into corresponding text. Specifically, the speech recognition model can employ the Whisper model, an advanced model capable of high-precision, multilingual speech-to-text conversion. Its function is to encode auditory information into semantically identical text information. When the current input information includes image data, the processor can call an optical character recognition model to extract text information from the image data, obtaining second text. The optical character recognition model is an artificial intelligence model or algorithm specifically designed to detect, recognize, and extract printed or handwritten text information contained in image or video frames. Its function is to decode the text content in visual information into a processable text string. When the current input information includes video data, the processor can extract frame images from the video data at predetermined intervals, and sequentially extract text information from each frame image using an optical character recognition model, then concatenate them into a third text in chronological order. A frame image refers to a single static image extracted from the video stream at specific time intervals. The predetermined interval refers to the sampling strategy parameter used when processing video data. For example, "extract 1 frame per second" or "extract 1 frame every 10 frames." This interval determines the balance between the granularity of video analysis and processing overhead. The smaller the interval, the more complete the information is preserved, but the greater the computational load; conversely, the larger the interval, the less information is retained. Next, the processor can concatenate and extract entities from the initial text data, the first text, the second text, and the third text in the current input information to generate the current semantic representation. The initial text data refers to the raw text information directly input by the user in the current interaction round, without requiring modality conversion. This initial text data is an independent input modality, alongside speech, images, and video. Entity extraction is a key technology in natural language processing, referring to the automatic identification and classification of named entities with specific meanings from unstructured text, such as names of people, places, organizations, equipment models, fault codes, times, and values. As can be seen in this embodiment, the processor encapsulates or encodes the entity extraction results into a fixed-format current semantic representation data object. This object not only contains the semantics of the original text but also highlights key information points in a structured manner, providing direct and efficient input for subsequent calculations of semantic relevance and long-term value scores. Therefore, this solution can provide a unified semantic representation for inputs such as speech, images, and video, supporting cross-modal information integration.
[0057] In one embodiment, determining the semantic relevance between the current semantic representation and the current dialogue task context includes: using an embedding model to convert the current semantic representation and the current task dialogue context into corresponding embedding vectors respectively; and determining the cosine similarity between the two embedding vectors as the semantic relevance.
[0058] Embedding models are trained artificial intelligence models whose core function is to take a text as input and output a fixed-length, high-dimensional numerical vector. This vector is not randomly generated, but rather, during the model's training process, it learns to map semantically similar text to positions close to each other in the vector space. Specifically, embedding models can use text-embedding-3-large (large-scale text embedding model) or similar pre-trained models. ,in, This refers to the vector representation obtained after the semantic input is processed by the embedding model. This refers to the embedded model function. This refers to the vector representation of the semantic meaning. An embedding vector, also known as a semantic vector, is the output obtained after processing text through an embedding model. An embedding vector is a point in a high-dimensional space (such as hundreds or thousands of dimensions), represented by a set of numerical values (vectors). The geometric position and orientation of this vector encode the deep semantic information of the input text. It is understandable that semantically similar texts will have highly similar embedding vector orientations in space. In this embodiment, the processor can invoke the embedding model to convert the current semantic representation and the current task dialogue context into corresponding embedding vectors, then determine the cosine similarity between the two embedding vectors, and use this cosine similarity as the semantic correlation between the current semantic representation and the current task dialogue context.
[0059] In one embodiment, memory entries in the long-term memory bank are labeled with task scenario tags; when the agent needs to generate a response to the current input information, retrieving target memory content that is semantically related to the current input information from the long-term memory bank includes: according to the current task scenario, prioritizing the retrieval of memory entries that match the tags of the current task scenario.
[0060] Task scenario tags refer to a set of discrete category identifiers, defined manually or learned automatically, used to label and classify long-term memory entries from a business or domain perspective. For example, in the construction machinery operation and maintenance scenario, tags could include excavator maintenance, hydraulic system failure, engine maintenance, electrical inspection, and periodic inspection. Each memory entry can be attached with one or more such tags to indicate the specific work context or problem type to which the knowledge applies. The current task scenario refers to the business scenario category most likely to belong, identified or inferred in real time by the processor through analysis of user input, dialogue history, and task objectives during the current interaction round. The current task scenario is a dynamic variable that may change as the dialogue progresses. For example, if a user continuously discusses the problem of "hydraulic oil temperature too high," the system can determine the current task scenario as a hydraulic system failure. Tag matching refers to the logical operation of comparing the current task scenario with the task scenario tags attached to long-term memory entries during the retrieval process. Matching can be exact matching, hierarchical matching, or similarity matching. Exact matching occurs when the current scenario and the entry tag are exactly the same. Hierarchical matching refers to matching based on a preset tag hierarchy (e.g., "hydraulic system failure" is a subclass of "fault diagnosis"). Similarity matching refers to calculating the semantic similarity between a scenario description and a label; a match is considered to have a similarity exceeding a threshold. In this solution, the main purpose of matching is to quickly filter out a subset of memories that are highly relevant to the current business.
[0061] Specifically, in this embodiment, whenever a piece of information is determined to have long-term value and stored in the long-term memory, the processor automatically or semi-automatically assigns it an appropriate task scenario label. Automatic labeling can map the text content of the memory entry to a predefined label system using a classification model or keyword matching. Semi-automatic / manual labeling refers to the ability of domain experts to specify labels when the knowledge is stored in the database, or for the processor to recommend labels first, which are then confirmed by the user. When the agent needs to generate a response to the current input information, the processor can retrieve target memory content that is semantically related to the current input information from the long-term memory. For example, based on the current task scenario, memory entries that match the labels of the current task scenario can be retrieved first. This ensures that the recalled memories are consistent with the current problem in terms of business scenario, avoiding common-sense errors such as "recalling engine maintenance records when asking about hydraulic failure," thus improving the usability and accuracy of the results. Furthermore, it significantly reduces the number of entries that need to participate in vector similarity calculation, thereby speeding up the retrieval process, which is especially beneficial for real-time responses in large-scale knowledge bases. In addition, this solution has stronger scenario consistency on the basis of semantic relevance, which helps the model generate more professional and targeted answers.
[0062] In summary, this solution has the following beneficial effects: 1. Context selection and pruning for improved efficiency: A dynamic context priority management mechanism is proposed to intelligently filter and simplify historical context, retaining only the information most valuable to the current task, avoiding the repeated processing of irrelevant or redundant content by large models, and significantly reducing token consumption and response latency.
[0063] 2. Adaptive Memory Decay Model: This model combines memory usage with a "hotness" metric to dynamically decay information in both long-term and short-term memory. Frequently accessed contexts retain higher priority, while information that has not been referenced for a long time is automatically cleared or downgraded, achieving automatic memory adjustment and preventing forgetting.
[0064] 3. Multimodal Unified Context Fusion: A multimodal vector fusion memory unit is designed to map image features, speech transcription, and text semantics to the same context vector space. This enables collaborative memory of cross-modal information, allowing the agent to comprehensively utilize visual, auditory, and textual information for reasoning.
[0065] 4. Construction Machinery Scene Optimization: Introduce task scene tags to cluster long-term memory, marking specific operation scenarios or fault types in context. For example, automatically attach tags such as "excavator maintenance" or "hydraulic fault" based on the current task, and match similar fault patterns in the knowledge base to improve the accuracy and efficiency of recalling relevant historical information.
[0066] In one embodiment, this method can be applied to the mechanical field, enabling context management based on mechanical equipment expertise. By combining multimodal inputs and expert knowledge, it can achieve more efficient and robust intelligent operation and maintenance and diagnostic support, significantly improving decision quality and response speed.
[0067] Figure 1 This is a flowchart illustrating a context construction method for an agent in one embodiment. It should be understood that, although... Figure 1 The steps in the flowchart are shown sequentially as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise explicitly stated herein, there is no strict order in which these steps are executed, and they can be performed in other orders. Figure 1 At least some of the steps in the process may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least some of the sub-steps or stages of other steps.
[0068] In one embodiment, a context building apparatus for an agent (not shown) is provided, the apparatus comprising: The memory is configured to store instructions; The processor is configured to retrieve the instructions from the memory and, when executing the instructions, to implement the context construction method for an agent as described in any of the above embodiments.
[0069] The processor contains a kernel, which retrieves the corresponding program unit from memory. One or more kernels can be configured, and the context construction method for the agent can be implemented by adjusting kernel parameters.
[0070] The memory may include non-permanent memory in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip.
[0071] In one embodiment, such as Figure 3As shown, a context construction device for an intelligent agent is provided. This device includes: a context acquisition module, a semantic parsing module, a memory classification module, a consistency judgment module, an adaptive update module, and a context invocation module. The context acquisition module is the architecture entry point, collecting user input; the context invocation module is the architecture exit point, sending the processed context to the large model. Specifically, the context acquisition module stores the content after the user interacts with the current intelligent agent in a MySQL database. This content includes the interlocutor, dialogue time, model parameters, and dialogue content, and periodically collects raw dialogue data (speech, images, text, etc.). This module automatically collects and structures the context information, providing a data foundation for subsequent semantic understanding, memory management, and long-term task tracking. The semantic parsing module performs semantic analysis and preprocessing on the collected raw dialogue data, identifies key entities, and converts multimodal information into a unified semantic representation, providing data for the subsequent memory-based modules. Specifically, the semantic parsing module preprocesses the original dialogue data. If the original dialogue data contains speech data, it extracts the speech content using the Whisper speech-to-text model. If the original dialogue data contains images of protective gear, it extracts the image information after recognizing the image using OCR. If the original dialogue data contains video content, it averages out the images by frame rate, extracts the information using OCR, and then splices them together in the order of the video frames. After preprocessing, entity extraction is performed together with the user input text data, converting it into unified semantics. The memory classification module classifies and stores the parsed semantic information into short-term memory (context related to the current session or task) and long-term memory (persistent information such as historical experience and engineering knowledge base), and can set a global task context to maintain long-term goals. The consistency judgment module performs logical coherence checks on long-term / short-term memory based on previous dialogue content, detecting whether there are conflicting, redundant, or outdated information (such as user input contradicting short-term memory or conflicting with known knowledge in long-term memory). The adaptive update module updates long-term memory because long-term memory generates a large number of similar or duplicate entries over time, leading to low retrieval efficiency and knowledge duplication. To prevent fragmentation of long-term memory, this module periodically clusters the entire long-term memory bank, merging similar memories into more abstract and representative knowledge units. Context Invocation Module: This module constructs optimized prompts for the large model. Based on task requirements and context priority, this module filters and merges high-value information from short-term / long-term memory to form a concise and efficient contextual input. Specifically, when the large model determines that the user's current input task cannot be directly completed, it selects memories with high vector similarity from short-term / long-term memory, concatenates them with the input, and sends them to the large model.
[0072] This application provides a storage medium storing a program that, when executed by a processor, implements the aforementioned context construction method for intelligent agents.
[0073] This application provides a processor for running a program, wherein the program executes the above-described context construction method for an intelligent agent.
[0074] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 4 As shown, the computer device includes a processor A01, a network interface A02, memory (not shown), and a database (not shown) connected via a system bus. The processor A01 provides computing and control capabilities. The memory includes internal memory A03 and a non-volatile storage medium A04. The non-volatile storage medium A04 stores an operating system B01, a computer program B02, and a database (not shown). The internal memory A03 provides an environment for the operation of the operating system B01 and the computer program B02 stored in the non-volatile storage medium A04. The network interface A02 is used for communication with external terminals via a network connection. When the computer program B02 is executed by the processor A01, it implements a context construction method for intelligent agents.
[0075] Those skilled in the art will understand that Figure 4 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0076] This application provides a computer (electronic) device, which includes a processor, a memory, and a program stored in the memory and executable on the processor. When the processor executes the program, it implements the steps of any of the above-mentioned context construction methods for intelligent agents.
[0077] This application also provides a computer program product that, when executed on a data processing device, is adapted to execute a program that initializes a context construction method step for an intelligent agent.
[0078] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0079] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0080] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0081] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0082] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0083] Memory may include non-persistent memory in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.
[0084] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.
[0085] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0086] The above are merely embodiments of this application and are not intended to limit this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.
Claims
1. A context construction method for an agent, characterized in that, include: Obtain the agent's current input information in one interaction round, and parse and generate the corresponding current semantic representation based on the current input information; Determine the semantic relevance between the current semantic representation and the current dialogue task context; Calculate the long-term value score of the current semantic representation, wherein the long-term value score is a function value calculated by a predefined function based on the frequency of the current semantic representation within a preset historical period and its logical consistency with existing knowledge in the long-term memory. If the semantic relevance is greater than a first predetermined threshold, the current semantic representation is stored in a short-term memory. If the long-term value score is greater than a second predetermined threshold, the current semantic representation is stored in a long-term memory. When the agent needs to generate a response to the current input information, it retrieves target memory content that is semantically related to the current input information from the short-term memory bank and the long-term memory bank; The target memory content is combined with the current input information to form a prompt message, which is then input into a large language model to generate a response to the current input information.
2. The method of claim 1, wherein, The method further includes: Before storing the current semantic representation into the short-term memory or long-term memory, the current semantic representation is compared with the existing memory entries in the short-term memory and long-term memory. The consistency judgment includes redundancy judgment and conflict judgment. If the current semantic representation fails the redundancy check or the conflict check, it is determined that the current semantic representation has failed the consistency check, and the current semantic representation is refused to be stored. If the current semantic representation passes both the redundancy check and the conflict check, and the current semantic representation passes the consistency check, then the current semantic representation is stored in the short-term memory or the long-term memory.
3. The method according to claim 2, characterized in that, The step of determining the consistency between the current semantic representation and existing memory entries in the short-term memory bank and the long-term memory bank includes: Calculate the vector similarity between the current semantic representation and each existing memory entry; If there are existing memory entries whose vector similarity is greater than a preset redundancy threshold, it is determined that the current semantic representation has failed the redundancy judgment, and the current semantic representation is refused to be stored. Using a relation extraction model, triples in subject-verb-object format are extracted from the current semantic representation and from each existing memory entry, respectively. The triples extracted from the current semantic representation are compared with the triples extracted from each existing memory entry; If two triples have the same subject and object, but their predicates are semantically mutually exclusive, then the two triples are determined to have a logical conflict. The current semantic representation fails the conflict judgment, and the conflicting knowledge in the existing memory entry is updated or replaced with the information in the current semantic representation.
4. The method according to claim 2 or 3, characterized in that, The method further includes: If the current semantic representation fails the redundancy check, the existing memory entry is updated according to the current semantic representation, and / or a deduplication operation is performed on the existing memory entry.
5. The method according to claim 1, characterized in that, The method further includes: Based on a preset update cycle, cluster analysis is performed periodically on the memory entries in the long-term memory bank to merge multiple semantically similar memory entries into a new knowledge unit; wherein, the new knowledge unit is represented by a centroid vector as its semantic core feature in the vector space, and the centroid vector is calculated by averaging the semantic vectors of the multiple memory entries; The new knowledge units are used to replace the corresponding multiple memory entries to update the long-term memory bank.
6. The method according to claim 5, characterized in that, The clustering analysis is performed using the Lloyd algorithm, which minimizes the sum of squared distances between memory entries within a cluster and the centroid vector through iterative allocation and update steps until convergence.
7. The method according to claim 1, characterized in that, The step of obtaining the agent's current input information in a single interaction round and generating the corresponding current semantic representation based on the current input information includes: Obtain the current input information of the intelligent agent in one interaction round, wherein the current input information includes at least one of text, voice, image and video; If the current input information includes voice data, a speech recognition model is invoked to convert the voice data into first text. When the current input information includes image data, an optical character recognition model is invoked to extract text information from the image data to obtain the second text. When the current input information includes video data, frame images are extracted from the video data at predetermined intervals, and text information in each frame image is extracted sequentially through the optical character recognition model and concatenated into a third text in chronological order. The initial text data, the first text, the second text, and the third text in the current input information are concatenated and entity extracted to generate the current semantic representation.
8. The method according to claim 1, characterized in that, Determining the semantic relevance between the current semantic representation and the current dialogue task context includes: The current semantic representation and the current task dialogue context are converted into corresponding embedding vectors using an embedding model; The cosine similarity between two embedded vectors is determined as the semantic association.
9. The method according to claim 1, characterized in that, The long-term value score of the current semantic representation is calculated using the following formula: in, This refers to the long-term value score; , All are weighting coefficients; This refers to the frequency of the current semantic representation within a preset historical time period. This refers to the logical consistency between the current semantic representation and the existing knowledge in the long-term memory. This refers to the current semantic representation. This refers to the parameters of the model layer.
10. The method according to claim 9, characterized in that, , The values are 0.6 and 0.4, respectively.
11. The method according to claim 1, characterized in that, The first predetermined threshold is 0.75, and the second predetermined threshold is 0.
75.
12. The method according to claim 1, characterized in that, The memory entries in the long-term memory bank are labeled with task scenario tags; When the agent needs to generate a response to the current input information, retrieving target memory content semantically related to the current input information from the long-term memory bank includes: Based on the current task scenario, memory entries that match the tags of the current task scenario are retrieved first.
13. A context building apparatus for an intelligent agent, characterized in that, include: The memory is configured to store instructions; A processor is configured to retrieve the instructions from the memory and, when executing the instructions, to implement the context construction method for an agent according to any one of claims 1 to 12.
14. A machine-readable storage medium storing instructions thereon, characterized in that, When executed by a processor, this instruction causes the processor to be configured to perform the context construction method for an agent according to any one of claims 1 to 12.
Citation Information
Cited By
Intelligent agent execution context automatic generation method based on structured task description and related device
CN122112050A
Agent execution context automatic generation method based on structured task description and related device
CN122112050B