Intelligent agent question and answer interaction method based on large model and generative artificial intelligence
By dynamically evaluating the importance of information unit packets and adjusting memory capacity, the problem of information loss and low efficiency in long dialogues and cross-conversation interactions of traditional intelligent agents is solved, achieving efficient question-and-answer interaction and contextual coherence.
Patent Information
- Application Number
- CN202511275764.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-08
- Publication Date
- 2025-12-19
- Estimated Expiration
- 2045-09-08
AI Technical Summary
Traditional intelligent agents lack dynamic information value considerations when processing dialogue history, leading to the accidental deletion of key historical information, increased computational burden, low response efficiency, and difficulty in persistently preserving user preferences and core information in cross-conversation interactions.
An intelligent agent question-answering interaction method based on large models and generative artificial intelligence is adopted. By obtaining the time weight and topic weight of information unit packets, the working memory, short-term memory and long-term memory are dynamically updated. The memory capacity is adjusted in combination with the system load characteristics to achieve intelligent filtering and compressed storage of information.
It enhances the agent's contextual understanding and responsiveness in long dialogues and multi-turn interactions, ensuring interaction coherence and operational stability, and optimizing the balance between resource utilization and information integrity.
Smart Images

Figure CN121168645A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of artificial intelligence question and answer interaction, in particular to an agent question and answer interaction method based on large models and generative artificial intelligence. BACKGROUND
[0002] As an important branch of artificial intelligence, generative artificial intelligence can creatively generate new content based on existing data and is widely used in text, image, audio and video generation fields. With the development of deep learning technology and computing hardware, generative artificial intelligence is particularly prominent in the field of natural language processing. The generative dialogue model represented by ChatGPT has shown excellent dialogue ability and interaction results, laying a technical foundation for agent question and answer interaction.
[0003] However, the traditional agent has significant deficiencies in processing dialogue history. On the one hand, the traditional agent directly truncates the dialogue history into a fixed-length context input model or uses a single storage module to manage information, lacking consideration of the dynamic changes in information value. On the other hand, the traditional agent often repeatedly processes all historical content when generating summaries, failing to establish a hierarchical and incremental memory flow mechanism. This processing method often leads to accidental deletion of key historical information due to model input length limitations in long dialogue scenarios. In cross-session interactions, user preferences and core information are also difficult to persist. Meanwhile, repeated summary processing of full historical content not only increases the computational burden but also reduces the agent's response efficiency. Ultimately, this leads to problems such as context discontinuity, missing key information and low interaction efficiency in question and answer responses. SUMMARY
[0004] To solve the above technical problems, the present application provides an agent question and answer interaction method based on large models and generative artificial intelligence to solve existing problems.
[0005] The agent question and answer interaction method based on large models and generative artificial intelligence of the present application adopts the following technical solutions: During the current user's conversation with the agent of artificial intelligence, the questioning content at the current time and all question and answer content before the current time are obtained, each question and answer content is formed into a plurality of information unit packages, and the embedding vectors of the questioning content and all information unit packages are obtained; The working memory, short-term memory and long-term memory in the agent are dynamically updated based on the information unit packages, wherein the update process of the short-term memory capacity threshold is: determine a time weight of each information unit package based on a time interval between each information unit package and the question content, determine a theme weight of each information unit package based on a similarity of an embedding vector between each information unit package and the question content, and determine an importance score of each information unit package by combining the time weight, so as to screen the information unit package that needs to be stored into the short-term memory from the information unit package eliminated in the working memory within the preset time length before the current time; obtain a delay of the agent at the current time, and determine a load characteristic value of the agent at the current time in combination with a preset target delay, determine a score characteristic value of the short-term memory at the current time based on a distribution of the importance scores of all information unit packages in the short-term memory within the preset time length before the current time, and adjust a capacity threshold of the short-term memory at the current time in combination with the load characteristic value, so as to retain necessary information unit packages; screen the candidate information unit package based on the information unit packages stored in the working memory, the short-term memory and the long-term memory of the agent at the current time, and answer the question content at the current time.
[0006] Preferably, the expression of the time weight of each information unit package is: ; in the formula, denotes the time weight of the i th information unit package; denotes the time interval between the i th information unit package and the question content; denotes a preset time weight factor; denotes a preset time decay coefficient; exp( ) denotes an exponential function with a natural constant as a base number.
[0007] Preferably, the expression of the theme weight of each information unit package is: ; in the formula, denotes the theme weight of the i th information unit package; denotes the similarity of the embedding vector between the i th information unit package and the question content; denotes the maximum value of the similarity of the embedding vector between all information unit packages within the preset time length before the current time and the question content at the current time; denotes a preset theme weight factor.
[0008] Preferably, the importance score of each information unit package is a normalized value of the sum of the time weight and the theme weight of each information unit package.
[0009] Preferably, the screening of the information unit package that needs to be stored into the short-term memory from the information unit package eliminated in the working memory within the preset time length before the current time comprises: In the information unit package eliminated by the working memory in the preset time length before the current time, the information unit package with the importance score greater than the preset threshold is stored into the short-term memory.
[0010] Preferably, the load characteristic value of the intelligent agent at the current time is a ratio of the time delay of the intelligent agent at the current time to the preset target time delay.
[0011] Preferably, the score characteristic value of the short-term memory at the current time is a mean value of the importance scores of all information unit packages in the short-term memory in the preset time length before the current time.
[0012] Preferably, the capacity threshold of the short-term memory at the current time is adjusted, including: The capacity threshold of the short-term memory at the current time is expressed as: ; in the formula, represents the load characteristic value of the intelligent agent at the current time; I represents the score characteristic value of the short-term memory at the current time; represents the preset upper limit of the base capacity; represents the preset adjustment factor; norm[ ] represents a normalization function.
[0013] Preferably, the candidate information unit package is screened, including: The similarity degrees between all information unit packages in the short-term memory and the long-term memory and the embedded vector of the question content at the current time are arranged in descending order, and the information unit packages corresponding to the first preset number of similarity degrees in the arrangement result and all information unit packages in the working memory at the current time are taken as the candidate information unit packages at the current time.
[0014] Preferably, the question content at the current time is answered, including: The product of the importance score of each candidate information unit package at the current time and the preset weight is calculated, which is recorded as the comprehensive score of each candidate content at the current time, and all information unit packages at the current time are arranged in descending order according to the comprehensive score, and multiple information unit packages are selected from the arranged candidate information unit packages to splice into a streaming context and transmit to the large language model of the intelligent agent to answer the question content at the current time.
[0015] An embodiment of the present application provides an intelligent agent question and answer interaction method based on a large model and generative artificial intelligence, which includes the following steps: The present application has at least the following beneficial effects: The application realizes intelligent screening and compressed storage of eliminated content in working memory by dynamically evaluating the importance score of the information unit package by combining time weight and theme weight, retains high-value information, optimizes the utilization efficiency of short-term memory through differential summary and dynamic capacity control, and thus improves the context understanding and response capability of the intelligent agent in long dialogue and multi-round interaction; further, the application realizes intelligent adjustment of the short-term memory capacity by dynamically fusing the system load eigenvalue and the score eigenvalue, can shrink the capacity to guarantee system response efficiency in high load, and can expand the capacity to retain key content in high-value information-intensive, thus achieving dynamic balance between resource consumption and information integrity, and significantly improving the context coherence and running stability of the intelligent agent in complex dialogue scenarios; in summary, the application realizes efficient question and answer interaction of the intelligent agent based on large model and generative artificial intelligence through hierarchical memory and dynamic updating mechanism, allocates multi-modal information to working, short-term and long-term three-layer memory according to importance, dynamically screens and compresses content combining time and theme weight, avoids context redundancy, guarantees key information is not lost, at the same time, adjusts the memory capacity dynamically through load and score eigenvalue, balances between resource utilization and information integrity, and finally significantly improves the interaction coherence, response speed and question and answer interaction stability in long dialogue and cross-session scenarios. BRIEF DESCRIPTION OF DRAWINGS
[0016] In order to more clearly illustrate the technical solutions and advantages of the embodiments of the present application or the prior art, the following will briefly introduce the drawings needed to be used in the embodiments or prior art description. Obviously, the drawings in the following description are only some embodiments of the present application, and those skilled in the art can obtain other drawings according to these drawings without creative labor.
[0017] Figure 1 The step flow chart of the question and answer interaction method of the intelligent agent based on large model and generative artificial intelligence provided by an embodiment of the present application is shown in the figure. Figure 2 The short-term memory capacity threshold updating step flow chart provided by an embodiment of the present application is shown in the figure. DETAILED DESCRIPTION
[0018] In order to further illustrate the technical means and effects adopted by the present application to achieve the predetermined invention purpose, the following will combine the drawings and preferred embodiments to specifically describe the question and answer interaction method of the intelligent agent based on large model and generative artificial intelligence according to the present application, its specific implementation, structure, features and effects in detail. In the following description, different "one embodiment" or "another embodiment" do not necessarily refer to the same embodiment. In addition, the specific features, structures or characteristics in one or more embodiments can be combined in any suitable form.
[0019] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs.
[0020] The specific scheme of the agent question and answer interaction method based on large models and generative artificial intelligence provided by the application will be specifically described below in combination with the drawings.
[0021] The agent question and answer interaction method based on large models and generative artificial intelligence provided by an embodiment of the application, in particular, provides the agent question and answer interaction method based on large models and generative artificial intelligence as follows, please refer to Figure 1 The method comprises the following steps: Step S1: In the process of the current user and the agent of artificial intelligence conversation, the question content at the current time and all information unit packages before the current time are acquired, and the embedding vectors of the question content and all information unit packages are acquired.
[0022] The information input by the user is usually continuous multi-modal content, such as long text, coherent speech or continuous images. If these contents are directly treated as a whole, many problems will occur: for example, the long text may exceed the input length limit of the model, due to compatibility problems, the image and speech contents cannot be directly interpreted by the text model, and multiple topics may be mixed in a single content, which will cause the memory management and retrieval efficiency of artificial intelligence to be not high, so structured processing must be performed first to enable artificial intelligence to adapt to the input requirements of the multi-layer memory system.
[0023] Firstly, it is judged whether the input content is text, image or speech. If the input content is not text, the input content is converted, for example, the speech is converted into text by using automatic speech recognition technology (ASR), the text information in the image is extracted by using picture text recognition technology (OCR), and at the same time, the noise of the input content is filtered out, for example, the invalid symbols in the text, the silent part in the speech and the redundant frames in the image are deleted to ensure that the original input is available.
[0024] Secondly, semantic segmentation is performed to generate information units. In processing the text, the BERT model is used to divide the long text into semantically complete short sentences or paragraphs; in processing the speech and image contents in time sequence, the BERT model is used to cut them into independent units according to the time interval and semantic coherence. Therefore, in the process of the current user and the agent of artificial intelligence conversation, the question content at the current time and all question and answer contents before the current time are acquired, and each question and answer content is cut into multiple independent units.
[0025] Further, the multi-modal vector embedding is generated, and the segmented text units are from different sources, including text, audio, and time-frequency. Therefore, different methods are used to extract the embedding vectors of the independent units. For example, for the text independent unit, the pre-trained Transformer editor is used for segmentation and coding, and the fixed dimension text vector is output as the embedding vector of the text independent unit. For the audio independent unit, the Wav2Vec 2.0 is used to convert the speech spectrum into a speech semantic vector as the embedding vector of the audio independent unit. For the image independent unit, the visual encoder of the CLIP model is used to extract the visual feature vector as the embedding vector of the image independent unit. Thus, the embedding vectors of the independent units are obtained. In order to ensure that the embedding vectors of different types of independent units can be compared with each other, the embedding vectors of all independent units are subjected to L2 standardization processing.
[0026] Among them, the methods of obtaining text vectors by using a pre-trained Transformer editor, converting speech spectrum into a speech semantic vector by using Wav2Vec 2.0, extracting a visual feature vector by using a visual encoder of a CLIP model, and standardizing embedding vectors by using L2 standardization are all known technologies, and their specific processes will not be described again.
[0027] Finally, the independent units are labeled with data, and each independent unit is added with metadata of a timestamp and a modal type, and is bound with the embedding vector to form an information unit package as an input of memory management.
[0028] Among them, the metadata of the modal type means that for the text independent unit, the metadata of the modal type is “text”, for the audio independent unit, the metadata of the modal type is “audio”, and for the image independent unit, the metadata of the modal type is “image”.
[0029] Step S2: dynamically updating the working memory, short-term memory and long-term memory in the agent based on the information unit package.
[0030] The traditional single context window has a problem that it is limited by the input length of the model and cannot simultaneously consider the latest information in the long conversation and the core content across the conversation. Moreover, if all the content is stored, it is easy to occupy resources. If only one layer of memory is used, it is difficult to balance the timeliness and persistence of information, in which the timeliness refers to the latest conversation content, and the persistence refers to the long-term user preference. Therefore, the embodiment uses a hierarchical management method to balance the timeliness and persistence of information, which is specifically as follows: The memory is divided into three layers in the embodiment, which is specifically as follows: The working memory is a window-level memory that stores original information of the last N rounds of conversations, retains original details without compression, has a fixed capacity limit, such as 4 KB, and deletes the oldest content when new information exceeds the capacity, dynamically adjusts the content, focuses on the latest conversation content, provides the most timely and complete context for the current interaction, and is the key to ensuring timely response to the conversation.
[0031] The short-term memory is a transitional memory that stores high-value information selected from the eliminated working memory and the refined abstract, uses incremental differential abstract to abstract the newly eliminated fragment, avoids repeated calculation, dynamically adjusts the capacity, and mainly stores key events, decisions and temporary user needs in recent conversations as an intermediate layer between the working memory and the long-term memory. It compresses redundant information and retains important clues in recent history, provides lightweight support for quick access to historical information, and balances storage efficiency and information integrity.
[0032] The long-term memory is a knowledge base-level persistent memory that stores key information such as core facts across sessions, user stable preferences, and resident knowledge that needs to be retained for a long time. It uses an expandable vector database such as FAISS to store and index, and the content is extracted from the short-term memory through event triggering or regularly. It can be stored across time and sessions, and its core function is to maintain continuity in long-period interactions. When the user asks about historical facts, repeated needs or preference-related content, it can quickly find key information through vector retrieval.
[0033] S201: Based on the time interval between each information unit package and the question content, determine the time weight of each information unit package; based on the similarity of the embedding vectors between each information unit package and the question content, determine the theme weight of each information unit package, and combine the time weight to determine the importance score of each information unit package, to select the information unit package that needs to be stored in the short-term memory from the information unit package eliminated by the working memory within a preset time length before the current time.
[0034] First, the information unit package is stored in the working memory first, and is added in chronological order, while the fixed capacity limit is used to maintain it in real time. If the new information unit exceeds the capacity after being added, the first-in-first-out mechanism is triggered, and the information unit stored earliest is deleted according to the timestamp, and the process is repeated iteratively. The working memory can consistently retain the original details of the last N rounds of conversations, and the value of N is not fixed and depends on the capacity of the working memory.
[0035] The deleted fragments from the working memory will immediately enter the processing flow of the short-term memory. First, the time weight of each information unit package is determined based on the time interval between each information unit package and the question content. Then, the theme weight of each information unit package is determined based on the similarity of the embedding vectors between each information unit package and the question content. The importance score of each information unit package is determined by combining the time weight. The comprehensive value of these information unit packages is calculated using the importance score formula. If the score exceeds the pre-set standard, the differential incremental summary model is called, such as the lightweight pointer generation network, which performs differential compression on the fragments. This compression only generates a concise summary for new content that has not been summarized before, without repeatedly processing all historical content. The generated summary is placed in the short-term memory. At the same time, the storage upper limit of the short-term memory is adjusted in real time through the dynamic capacity threshold formula. If the upper limit is exceeded, the summaries with low scores are deleted in descending order of importance score to ensure that the total capacity of the short-term memory is within a controllable range.
[0036] The specific determination process of the importance score is as follows: First, the time weight of each information unit package is determined based on the time interval between each information unit package and the question content. Specifically: As a specific implementation, in the present embodiment, the time weight of the i-th information unit package is expressed as: ; in the formula, represents the time interval between the i-th information unit package and the question content; represents a pre-set time weight factor; represents a pre-set time decay coefficient; exp() represents an exponential function with a natural constant as the base.
[0037] It should be noted that the values of the pre-set time weight factor and the pre-set time decay coefficient are artificially set. In the present embodiment, the value of the pre-set time weight factor is 0.5, and the value of the pre-set decay coefficient is 0.5. In actual application, as other implementation manners, the implementer can also set them according to specific circumstances, which are not specially limited in the present embodiment.
[0038] According to the time weight, the longer the time interval between the i-th information unit package and the question content, the smaller the information weight of the i-th information unit package, indicating that the timeliness score of the old information is lower. Conversely, the closer the time interval between the i-th information unit package and the question content, the larger the information weight of the information unit package, indicating that its timeliness score is higher, and its influence and contribution to the current context are also greater.
[0039] Further, the theme weight of each information unit package is determined based on the similarity of the embedding vectors between each information unit package and the question content. Specifically, In the present embodiment, the subject weight of the ith information unit package is expressed as: ; in the formula, represents the similarity of the embedding vectors between the ith information unit package and the question content; represents the maximum value of the similarity of the embedding vectors between all information unit packages and the question content at the current time within a preset time length before the current time; represents a preset subject weight factor.
[0040] It should be noted that the value of the preset subject weight factor is artificially set, and the addition result of the preset time weight factor and the preset subject weight factor is 1. In the present embodiment, the value of the preset residential area weight factor is 0.5. In actual application, as an alternative, the implementer can set it according to the specific situation, which is not specially limited in the present embodiment. It should be noted that there are many methods for measuring the similarity between vectors. In the present embodiment, the cosine similarity of the embedding vectors between the ith information unit package and the question content is taken as the similarity of the embedding vectors between the ith information unit package and the question content. In actual application, as an alternative, the implementer can use other methods for measuring the similarity between vectors, such as the inverse of the Euclidean distance. The selection of the method for measuring the similarity between vectors is not specially limited in the present embodiment.
[0041] The calculation method of the cosine similarity is a known technology, and the specific calculation process is not described again.
[0042] According to the subject weight of each information unit package, it can be understood that the subject weight reflects the semantic correlation between the information unit package and the current question content. If the proportion of the similarity of the embedding vectors between the ith information unit package and the question content in the maximum value of the similarity of the embedding vectors between all information unit packages and the question content at the current time within a preset time length before the current time is larger, i.e. , it indicates that the semantic correlation between the ith information unit package and the current question content is stronger, which indicates that the ith information unit package is more helpful for the current question and answer interaction and is the content that needs to be considered first in the context. On the contrary, if the proportion of the similarity of the embedding vectors between the ith information unit package and the question content in the maximum value of the similarity of the embedding vectors between all information unit packages and the question content at the current time within a preset time length before the current time is smaller, i.e. , it indicates that the semantic correlation between the ith information unit package and the current question content is weaker, which indicates that the ith information unit package is less helpful for the current question and answer interaction and is the content that can be considered later or eliminated in the context.
[0043] Further, the embodiment determines the importance score of each information unit package by combining the topic weight of each information unit package with the time weight, so as to screen the information unit package from the information unit packages eliminated by the working memory within the preset time length before the current time and store the information unit package into the short-term memory, specifically: In the embodiment, the normalized value of the sum of the time weight and the topic weight of each information unit package is taken as the importance score of each information unit package.
[0044] According to the importance score of each information unit package, it can be understood that the importance score dynamically evaluates the comprehensive value of the information unit package from the time dimension and the semantic dimension respectively; if the time weight of the current information unit package is greater, it means that the current information unit package has more advantages in the time dimension and is more likely to be preferentially retained or called, and the corresponding importance score is greater; at the same time, if the topic weight of the current information unit package is greater, it means that the topic contribution of the current information unit package is greater, and the current information unit package is more suitable for the demand of the current question content in the semantic dimension, and the possibility of the current information unit package being preferentially considered for generating an answer or context reconstruction is greater, so the importance score of the current information unit package is greater. On the contrary, if the time weight of the current information unit package is smaller, it means that the current information unit package no longer has an advantage in the time dimension and is more likely to be retained or eliminated later, and the corresponding importance score is smaller; at the same time, if the topic weight of the current information unit package is smaller, it means that the topic contribution of the current information unit package is weaker, and the current information unit package is less suitable for the demand of the current question content in the semantic dimension, and the possibility of the current information unit package being preferentially considered for generating an answer or context reconstruction is smaller, so the importance score of the current information unit package is smaller.
[0045] Further, the embodiment stores the information unit package with the importance score greater than the preset threshold value in the information unit packages eliminated by the working memory within the preset time length before the current time into the short-term memory.
[0046] The information unit package eliminated in the working memory refers to the information unit package deleted according to the first-in-first-out mechanism when the capacity of the working memory exceeds the upper limit of the capacity at the time of storing a new information unit package into the working memory.
[0047] It should be noted that the values of the preset time length and the preset threshold value are artificially set, and the value of the preset time length in the embodiment is 10 min, and the value of the preset threshold value is 0.4. In actual application, as other implementation manners, the implementer can also set them according to the specific circumstances, and the embodiment does not make special limitations.
[0048] So far, by combining the time weight and the theme weight to dynamically evaluate the importance score of the information unit package, this embodiment realizes intelligent filtering and compressed storage of the eliminated content in the working memory, retains high-value information, optimizes the utilization efficiency of the short-term memory through differential abstraction and dynamic capacity control, and thus improves the context understanding and response capability of the intelligent agent in long dialogue and multi-round interaction.
[0049] In S202, the time delay of the intelligent agent at the current time is obtained, and a load characteristic value of the intelligent agent at the current time is determined in combination with a preset target time delay. A score characteristic value of the short-term memory at the current time is determined based on the distribution of the importance scores of all the information unit packages in the short-term memory within a preset time length before the current time, and the capacity threshold of the short-term memory at the current time is adjusted in combination with the load characteristic value, so as to retain necessary information unit packages.
[0050] If the upper limit of the short-term memory is fixed, two troublesome situations will be encountered. One is when the system load suddenly becomes large, such as when many people simultaneously have a dialogue or the computing resources are insufficient, the fixed capacity can cause the useless storage to occupy too much memory and computing power during retrieval, slowing down the response speed. The other is when a lot of high-value information appears in the dialogue, such as the core preferences and key decisions of the user, the fixed upper limit can not be able to store important content and thus has to be deleted, affecting the coherence of the subsequent dialogue.
[0051] Therefore, in this embodiment, the time delay of the intelligent agent at the current time is obtained, and a load characteristic value of the intelligent agent at the current time is determined in combination with a preset target time delay. A score characteristic value of the short-term memory at the current time is determined based on the distribution of the importance scores of all the information unit packages in the short-term memory within a preset time length before the current time, and the capacity threshold of the short-term memory at the current time is adjusted in combination with the load characteristic value, using a dynamic adjustment mechanism, which combines the system load index and the average importance of information. When the system load is high, the capacity is automatically reduced to release resources, ensuring that the system can operate efficiently. When high-value information is relatively dense, the capacity is appropriately relaxed to retain key content, so as to find a dynamic balance between controllable resource consumption and important information loss. The short-term memory can effectively support the context coherence of the recent dialogue, and will not slow down the system performance. The specific process is as follows: In this embodiment, the time delay of the intelligent agent at the current time is obtained, and a load characteristic value of the intelligent agent at the current time is determined in combination with a preset target time delay. Specifically: The embodiment takes the ratio of the delay of the agent at the current time to the preset target delay as the load characteristic value of the agent at the current time, which is used to evaluate the busy degree of the current agent, that is, to reflect the resource shortage degree of the current agent, and is the basis for dynamically adjusting the short-term memory capacity. If the load characteristic value is greater than 1, it means that the agent is overloaded, at which time the short-term memory capacity needs to be triggered to shrink. Conversely, if the load characteristic value is less than 1, it means that the load of the agent does not reach the expectation, and the capacity of the short-term memory can be appropriately increased.
[0052] It should be noted that the value of the preset target delay is artificially set. In the embodiment, the value of the preset target delay is artificially set to 200 ms. In actual application, the implementer can also set it by himself according to the specific situation, and the embodiment does not make special limitations.
[0053] Further, the embodiment determines the score characteristic value of the short-term memory at the current time based on the distribution of the importance scores of all information unit packages in the short-term memory within the preset time length before the current time, specifically: In the embodiment, the mean value of the importance scores of all information unit packages in the short-term memory within the preset time length before the current time is taken as the score characteristic value of the short-term memory at the current time, which is used to represent the overall importance of the information in the short-term memory and is another key factor for dynamically adjusting the memory capacity. The score characteristic value can evaluate the overall value of the content in the current short-term memory. The greater the score characteristic value is, the more relaxed the capacity limit can be. The importance of a single information unit package can only reflect its own value, while the score characteristic value can reflect the overall importance of the information in the short-term memory in this period of time. When the score characteristic value is high, it means that the overall value of the information in the current short-term memory is higher. This setting can avoid deleting high-value information too early due to capacity limitation, and is more in line with the needs of actual use scenarios.
[0054] Based on the score characteristic value, the agent can appropriately relax the capacity limit of the short-term memory when high-value information is intensive, so as to avoid important information from being deleted too early.
[0055] Finally, the embodiment adjusts the capacity threshold of the short-term memory at the current time by comprehensively considering the score characteristic value and the load characteristic value of the short-term memory at the current time, so as to retain necessary information unit packages, specifically: As an implementation manner, in the embodiment, the capacity threshold of the short-term memory at the current time is expressed as: ; in the formula, the load characteristic value of the agent at the current time is denoted as I; the score characteristic value of the short-term memory at the current time is denoted as I; the preset upper limit of the reference capacity is denoted as Cmax; and the normalization function is denoted as norm[ ].
[0056] Preferably, the short-term memory capacity threshold updating step flowchart provided by the embodiment is as shown in Figure 2
[0057] It should be noted that the preset upper limit of the reference capacity and the preset adjustment factor are artificially set. In the embodiment, the preset upper limit of the reference capacity is 10 KB, and the preset adjustment factor needs to be greater than 1. In the embodiment, the preset adjustment factor is 2. In actual application, as other implementation manners, the implementer can also set it by himself according to the specific situation, and the embodiment does not make special limitation. Among them, the setting of the preset adjustment factor needs to ensure that it does not exceed the capacity that can be reached by the actual hardware.
[0058] In addition, if a certain information unit package in the short-term memory is called more than M times, it will be selected and stored in the long-term memory for persistent storage. The specific process is: first, generate a global index for this information unit package through the vector database FAISS, which contains embedding vectors and metadata; further, store the information unit package in the distributed vector library; at the same time, the long-term memory performs periodic full-index optimization, that is, by clustering and deduplicating similar entries, the same content is merged, so that in the cross-session scenario, the key information can be quickly found through vector retrieval.
[0059] It should be noted that the value of M in the embodiment is 10. In actual application, as other implementation manners, the implementer can also set it by himself according to the specific situation, and the embodiment does not make special limitation.
[0060] Among them, the vector database FAISS, the distributed vector library and the full-index optimization are all known technologies, and their specific operation principles and processes will not be repeated here.
[0061] So far, by dynamically fusing the system load characteristic value and the score characteristic value, the embodiment realizes the intelligent adjustment of the short-term memory capacity, which can both shrink the capacity to ensure the system response efficiency in high load, and expand the capacity to retain key content in high-value information-intensive, so as to realize dynamic balance between resource consumption controllability and information integrity, and significantly improve the context coherence and running stability of the intelligent agent in complex dialogue scenarios.
[0062] Step S3: Based on the information unit package stored in the working memory, the short-term memory and the long-term memory of the intelligent agent at the current time, the candidate information unit package is screened to answer the question content at the current time.
[0063] Based on step S2, the hierarchical and updating processing of the working memory, short-term memory and long-term memory in the agent is completed. However, since the information unit packages in the multi-layer memory are scattered in the working, short-term and long-term three levels, there are still a lot of contents irrelevant to the current dialogue. If these information is directly transmitted to the large model, it will either make the context redundant or miss the key information. Therefore, it is necessary to first pick out the most relevant fragments to the current dialogue through retrieval, and then reorganize them into a concise and complete context according to the logic, so as to solve the problems of information dispersion and insufficient relevance. The specific process is as follows: First, the embedding vector of the user's current input question content is taken as the query basis, and the vector database is called to do fast KNN retrieval on the information unit packages in the short-term memory and the long-term memory. Specifically, in the embodiment, the similarity between the embedding vectors of all information unit packages in the short-term memory and the long-term memory and the current question content is arranged in descending order, and the top pre-set number of similarity corresponding information unit packages and all information unit packages in the working memory at the current time are taken as the candidate information unit packages at the current time.
[0064] Among them, the calculation process of similarity refers to the process of calculating the theme weight, which will not be repeated here.
[0065] It should be noted that the value of the pre-set number is artificially set. In the embodiment, the value of the pre-set number is 50. In actual application, as other implementation manners, the implementer can also set it according to the specific situation, and the embodiment does not have special restrictions.
[0066] Further, they are assigned basic weights according to the level: working memory 0.6, short-term memory 0.3, long-term memory 0.1. The product of the importance score of each candidate information unit package at the current time and the pre-set weight is calculated, which is recorded as the comprehensive score of each candidate content at the current time. Among them, the pre-set weight is the basic weight of the corresponding level. Further, all information unit packages at the current time are arranged in descending order according to the comprehensive score, and n1 information unit packages are selected in the working memory, n2 information unit packages are selected in the short-term memory, and n3 information unit packages are selected in the long-term memory according to the order of “working memory, short-term memory, long-term memory”. At the same time, the prompt template such as “answer the question based on the following historical information” is added to construct the streaming context Prompt. The construction process of the streaming context is a known technology, which will not be repeated here.
[0067] Among them, the values of n1, n2 and n3 are artificially set. In the embodiment, their values are 5, 3 and 2 respectively. In actual application, the implementer can also set them according to the specific situation, and the embodiment does not have special restrictions.
[0068] Further, the streaming context is transmitted to the large language model of the agent, and with the semantic understanding and generation capability of the large language model, a response to the current moment question content is output, and the memory update is performed according to different levels, the working memory uses the mechanism of first-in first-storage and deleting the earliest content when the storage is full, and the original content of the current round is added, and the old content exceeding the capacity is deleted; the short-term memory makes an incremental summary of the fragments eliminated from the working memory, wherein, only the newly eliminated part is processed to reduce the calculation amount; the long-term memory stores the core information in the short-term memory that needs to be retained across sessions for a long time after the conversation ends, and through real-time generation of answers and hierarchical incremental updating of memory, efficient interaction is realized, and the memory can be continuously extended.
[0069] The process of question and answer interaction using the large language model is a known technology, and details are not described again.
[0070] So far, the embodiment realizes efficient question and answer interaction of the agent based on the large model and generative artificial intelligence through the hierarchical memory and dynamic updating mechanism, allocates the multi-modal information to the working memory, the short-term memory and the long-term memory according to the importance, dynamically filters and compresses the content according to the time and theme weight, avoids context redundancy, guarantees that the key information is not lost, dynamically adjusts the memory capacity according to the load and score feature value, balances the resource utilization and information integrity, and finally significantly improves the interaction continuity, response speed and system stability in the long conversation and cross-session scenario.
[0071] It should be noted that the above-mentioned sequence of the embodiments of the present application is only for description, and does not represent the advantages and disadvantages of the embodiments. The above describes specific embodiments of the present application. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments of the user, multitasking and parallel processing are possible or may be advantageous.
[0072] Each of the embodiments in the present specification is described in a progressive manner, and the same or similar parts of each embodiment can be referred to each other, and each embodiment mainly describes the difference from other embodiments.
[0073] The above-described embodiments are only used to illustrate the technical solutions of the present application, but not limit them; the technical solutions recorded in the above-described embodiments are modified, or some technical features are replaced, and the essence of the corresponding technical solutions does not deviate from the scope of the technical solutions of the embodiments of the present application, which should be included in the protection scope of the present application.
Claims
1. A method for agent question and answer interaction based on large models and generative artificial intelligence, characterized in that, The method comprises the following steps: During the conversation between the current user and the intelligent agent of the artificial intelligence, the questioning content at the current time and all the question and answer content before the current time are obtained, each question and answer content is formed into a plurality of information unit packages, and the embedding vectors of the questioning content and all the information unit packages are obtained; The working memory, short-term memory and long-term memory in the intelligent agent are dynamically updated based on the information unit packages, wherein the updating process of the capacity threshold of the short-term memory is as follows: Based on the time interval between each information unit package and the questioning content, the time weight of each information unit package is determined; based on the similarity of the embedding vectors between each information unit package and the questioning content, the theme weight of each information unit package is determined, and the importance score of each information unit package is determined in combination with the time weight, so as to screen out the information unit packages that need to be stored in the short-term memory from the information unit packages that are eliminated from the working memory within a preset time period before the current time; The time delay of the intelligent agent at the current time is obtained, and the load characteristic value of the intelligent agent at the current time is determined in combination with a preset target time delay; the score characteristic value of the short-term memory at the current time is determined based on the distribution of the importance scores of all the information unit packages in the short-term memory within a preset time period before the current time, and the capacity threshold of the short-term memory at the current time is adjusted in combination with the load characteristic value, so as to retain necessary information unit packages; Based on the information unit packages stored in the working memory, short-term memory and long-term memory of the intelligent agent at the current time, candidate information unit packages are screened out to answer the questioning content at the current time.
2. The large model and generative artificial intelligence-based agent question and answer interaction method of claim 1, wherein, The expression of the time weight of each information unit is: ; wherein, represents the time weight of the i-th information unit package; represents the time interval between the i-th information unit package and the question content; represents a preset time weight factor; represents a preset time decay coefficient; and exp( ) represents an exponential function with a natural constant as the base number.
3. The large model and generative artificial intelligence-based intelligent agent question and answer interaction method of claim 1, wherein, The expression of the theme weight of each information unit package is: ; wherein, represents the theme weight of the i-th information unit package; represents the similarity of the embedding vector between the i-th information unit package and the question content; represents the maximum value of the similarity of the embedding vector between all information unit packages within a preset time length before the current time and the question content at the current time; represents a preset theme weight factor.
4. The large model and generative artificial intelligence-based intelligent agent question and answer interaction method of claim 1, wherein, The importance score of each information unit package is a normalized value of the sum of the time weight and the theme weight of each information unit package.
5. The large model and generative artificial intelligence-based intelligent agent question and answer interaction method of claim 1, wherein, The screening of the information unit packages that need to be stored in the short-term memory from the information unit packages eliminated from the working memory within a preset time period before the current time comprises: Among the information unit packages eliminated from the working memory within a preset time period before the current time, the information unit packages with an importance score greater than a preset threshold are stored in the short-term memory.
6. The large model and generative artificial intelligence-based intelligent agent question and answer interaction method of claim 1, wherein, The load characteristic value of the intelligent agent at the current time is the ratio of the time delay of the intelligent agent at the current time to the preset target time delay.
7. The large model and generative artificial intelligence-based intelligent agent question and answer interaction method of claim 1, wherein, The score characteristic value of the short-term memory at the current time is the average of the importance scores of all the information unit packages in the short-term memory within a preset time period before the current time.
8. The large model and generative artificial intelligence-based intelligent agent question and answer interaction method of claim 1, wherein, The adjustment of the capacity threshold of the short-term memory at the current time comprises: The capacity threshold of short-term memory at the current time The expression is: ; wherein, represents the load eigenvalue of the agent at the current time; I represents the score eigenvalue of the short-term memory at the current time; represents the preset upper limit of the reference capacity; represents the preset adjustment factor; norm[ ] represents a normalization function.
9. The large model and generative artificial intelligence-based intelligent agent question and answer interaction method of claim 1, wherein, The screening of the candidate information unit packages comprises: The similarity of the embedding vectors between all the information unit packages in the short-term memory and the long-term memory and the questioning content at the current time is arranged in descending order, and the information unit packages corresponding to the first preset number of similarities in the arrangement result and all the information unit packages in the working memory at the current time are taken as the candidate information unit packages at the current time.
10. The large model and generative artificial intelligence-based intelligent agent question and answer interaction method of claim 1, wherein, The answering of the questioning content at the current time comprises: The product of the importance score of each candidate information unit package at the current moment and the preset weight is calculated, which is recorded as the comprehensive score of each candidate content at the current moment, and all information unit packages at the current moment are arranged in descending order according to the comprehensive score, and multiple information unit packages are selected from the arranged candidate information unit packages to splice into the stream context and transmit to the large language model of the agent to answer the question content at the current moment.
Citation Information
Patent Citations
Edge computing power deconstruction and intelligent scheduling method based on traffic computing network
CN117408405A
Bionic multi-brain module expert thinking link agent system
CN119106726A
Long text processing method and related device
CN119204234A
Memory-driven question and answer optimization method and device, equipment and storage medium
CN119226436A
Memory retrieval method based on large language model and related device
CN119903125A
Cited By
Intelligent agent interaction method and device, equipment, medium and product
CN121809534A