Memory recall method based on large language model and related device

Through the memory recall method based on the large language model, the problem of insufficient memory association ability in the vector index method is solved, and a knowledge graph of deep semantic understanding is constructed, which improves the comprehensiveness and depth of memory recall, and enhances the cognitive ability of the intelligent system. .

CN119202180APending Publication Date: 2024-12-27GUANGZHOU QUYAN NETWORK TECH CO LTD
View PDF 0 Cites 8 Cited by

Patent Information

Application Number
CN202411307907.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-19
Publication Date
2024-12-27

AI Technical Summary

Technical Problem

The existing memory recall method based on vector index has limitations in memory association ability, and it is impossible to effectively associate one entity to another related entity, resulting in fragmentation of memory information, information deviation and context loss, affecting the decision quality of intelligent systems and User experience.

Method used

Using the memory recall method based on the large language model, by obtaining short-term dialogue information between users and agents, performing semantic content analysis, constructing long-term memory maps, entity extraction and inference hierarchy evaluation, generating query languages, querying and generating from long-term memory maps Reply to achieve deep semantic understanding and multi-level reasoning.

Benefits of technology

It significantly improves the comprehensiveness and depth of memory recall, overcomes the limitations of traditional methods in related information retrieval, forms a highly structured knowledge graph, and enhances the cognitive ability and application scope of intelligent systems.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119202180A_ABST
    Figure CN119202180A_ABST
Patent Text Reader

Abstract

The invention discloses a memory recall method based on a large language model and a related device. The method comprises the steps that short-term memories are divided into inactive short-term memories and active short-term memories; performing semantic content analysis on the inactive short-term memory through a large language model, and converting the obtained entity information and entity relationship triad into a long-term memory graph; entity extraction and multi-level reasoning are carried out on the active short-term memory according to entities in the long-term memory map through a large language model, and the extracted entities and reasoning levels are combined to generate a query language; and querying from the long-term memory map through a query language, performing textualization processing on the obtained long-term memory triple information, and generating a reply according to the textualized long-term memory triple information and the short-term memory through a large language model. The technical problems that an existing memory recall mode based on vector indexes has limitation of memory association ability and recalled entity memory information is incomplete are solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of natural language processing technology, and in particular to a memory recall method based on a large language model and related devices. Background Art

[0002] With the rapid development of large language models, they have shown powerful capabilities in natural language understanding and generation. However, how to better utilize these models for deep semantic understanding and multi-level reasoning remains a challenge.

[0003] Traditional memory recall systems mainly rely on vector indexing for similarity matching, but the existing memory recall methods based on vector indexing have limitations in memory association capabilities, and the system cannot effectively associate one entity with another related entity. This is because vector indexing mainly relies on the similarity between pre-calculated embedding vectors and lacks a deep understanding of the semantic relationship between entities. Therefore, it is difficult for the system to perform complex memory reasoning and association, which greatly reduces the cognitive ability and application scope of intelligent systems. In addition, the entity memory information recalled by the existing memory recall methods based on vector indexing is incomplete, and it is difficult to fully recall all memory information related to a specific entity. This problem is mainly manifested in memory information fragmentation, memory information bias, and memory context loss. The reason for this problem is that the vector indexing method mainly focuses on local memory similarity and is difficult to capture the global memory semantic structure; lacks an effective memory organization and association mechanism, and cannot build a complete memory network. This will affect the decision-making quality and user experience of intelligent systems, especially in memory scenarios that require a comprehensive understanding of an entity or concept, such as intelligent customer service, virtual companionship, and other applications. Summary of the invention

[0004] The present application provides a memory recall method based on a large language model and related devices, which are used to improve the technical problems of the existing vector index-based memory recall method, such as the limitation of memory association ability and incomplete recalled entity memory information.

[0005] In view of this, the first aspect of the present application provides a memory recall method based on a large language model, comprising:

[0006] Acquire short-term conversation information between the user and the agent to obtain short-term memory, and divide the short-term memory to obtain inactive short-term memory and active short-term memory;

[0007] Parsing the semantic content of the inactive short-term memory by using a large language model to obtain first entity information and entity relationship triples;

[0008] Converting the first entity information and entity relationship triples into long-term memory to obtain a long-term memory map;

[0009] Extracting entities from the active short-term memory according to the entity information in the long-term memory map through a large language model, evaluating the extracted entities by reasoning levels, and combining the extracted entities and the corresponding reasoning levels to generate a query language;

[0010] Querying the long-term memory map by using the query language to obtain long-term memory triple information, and textualizing the long-term memory triple information to obtain long-term memory text information;

[0011] A response is generated based on the long-term memory text information and the short-term memory through a large language model.

[0012] Optionally, dividing the short-term memory to obtain inactive short-term memory and active short-term memory includes:

[0013] The short-term memories whose dialogue rounds exceed a preset number and whose dialogue information generation time exceeds a preset time are classified as inactive short-term memories, and the remaining short-term memories are classified as active short-term memories.

[0014] Optionally, converting the first entity information and entity relationship triples into long-term memory to obtain a long-term memory map includes:

[0015] Checking whether each entity in the first entity information already exists in a graph database; the graph database is used to store long-term memory graphs;

[0016] If the current entity does not exist in the graph database, a new entity node is created in the graph database, and the attributes of the current entity are added to the new entity node, where the attributes of the entity include name, type and description;

[0017] If the current entity already exists in the graph database, compare the description of the current entity with the entity of the same name in the graph database, merge the duplicate descriptions, and retain the non-duplicate descriptions to update the description of the entity node in the graph database;

[0018] For each entity relationship triplet, determine the location of the source entity and the target entity corresponding to the current entity relationship triplet in the graph database, and check whether there is a current entity relationship between the source entity and the target entity, wherein the entity relationship triplet includes a name, a description, and a sentiment weight;

[0019] If it does not exist, add the current entity relationship to the source entity and target entity corresponding to the current entity relationship triple;

[0020] If it exists, compare the current entity relationship between the source entity and the target entity corresponding to the current entity relationship triplet with the description of the entity relationship between the source entity and the target entity in the graph database, merge duplicate descriptions, retain non-duplicate descriptions, and re-evaluate the sentiment weights of the source entity and the target entity to update the entity relationship between the source entity and the target entity in the graph database;

[0021] Output the updated graph database.

[0022] Optionally, extracting entities from the active short-term memory according to entity information in the long-term memory map through a large language model and performing reasoning level evaluation on the extracted entities include:

[0023] Extracting entities from the active short-term memory according to the entity information in the long-term memory map using a large language model to obtain second entity information;

[0024] Evaluate the relevance between the entities in each of the second entity information and the memory recall question, sort the entities in each of the second entity information in descending order according to the relevance, output the first first number of entities after sorting, and obtain an entity list; the memory recall question is a question initiated by the user to the intelligent agent in the short-term dialogue information;

[0025] The reasoning level of the entities in the entity list corresponding to the memory recall question is evaluated according to the memory recall question and the entity list through a large language model.

[0026] Optionally, the long-term memory triple information is processed into text form to obtain long-term memory text information, and then the method further includes:

[0027] Calculating the total relevance score of each of the long-term memory text information, sorting each of the long-term memory text information in descending order according to the total relevance score, and obtaining the first second number of sorted long-term memory text information;

[0028] The generating a response according to the long-term memory text information and the short-term memory by using a large language model includes:

[0029] A response is generated by a large language model based on the sorted first second number of long-term memory text information and the short-term memory.

[0030] Optionally, the calculating of the total relevance score of each of the long-term memory text information includes:

[0031] Calculating similarity scores between each of the long-term memory text information and the corresponding memory recall question;

[0032] The similarity scores between each long-term memory text information and the corresponding memory recall question, the relevance of the entities in each long-term memory text information, and the sentiment weight of the entity relationship are weighted summed to obtain the total relevance score of each long-term memory text information.

[0033] The second aspect of the present application provides a memory recall system based on a large language model, comprising:

[0034] A partitioning module is used to obtain short-term conversation information between the user and the agent, obtain short-term memory, and partition the short-term memory to obtain inactive short-term memory and active short-term memory;

[0035] A semantic parsing module, used for performing semantic content parsing on the inactive short-term memory through a large language model to obtain first entity information and entity relationship triples;

[0036] A conversion module, used for converting the first entity information and entity relationship triples into long-term memory to obtain a long-term memory map;

[0037] A multi-level reasoning module, for extracting entities from the active short-term memory according to the entity information in the long-term memory map through a large language model, performing reasoning level evaluation on the extracted entities, and combining the extracted entities and the corresponding reasoning levels to generate a query language;

[0038] A query module, used for querying the long-term memory map by using the query language to obtain long-term memory triple information, and performing text processing on the long-term memory triple information to obtain long-term memory text information;

[0039] A reply generation module is used to generate a reply based on the long-term memory text information and the short-term memory through a large language model.

[0040] Optionally, the multi-level reasoning module is specifically used for:

[0041] Extracting entities from the active short-term memory according to the entity information in the long-term memory map using a large language model to obtain second entity information;

[0042] Evaluate the relevance between the entities in each of the second entity information and the memory recall question, sort the entities in each of the second entity information in descending order according to the relevance, output the first first number of entities after sorting, and obtain an entity list; the memory recall question is a question initiated by the user to the intelligent agent in the short-term dialogue information;

[0043] Evaluating, by a large language model, the reasoning level of the entities in the entity list corresponding to the memory recall question according to the memory recall question and the entity list;

[0044] Combine the extracted entities and the corresponding reasoning levels to generate query language.

[0045] A third aspect of the present application provides an electronic device, the device comprising a processor and a memory;

[0046] The memory is used to store program code and transmit the program code to the processor;

[0047] The processor is used to execute the memory recall method based on the large language model described in any one of the first aspects according to the instructions in the program code.

[0048] In a fourth aspect, the present application provides a computer-readable storage medium, which is used to store program code. When the program code is executed by a processor, the memory recall method based on a large language model described in any one of the first aspects is implemented.

[0049] It can be seen from the above technical solutions that this application has the following advantages:

[0050] The memory recall method based on a large language model provided in the present application accurately extracts entities and their relationships from complex short-term memory information based on the deep semantic parsing function of the large language model, and then constructs a sophisticated relationship network. Through the establishment of this network, a highly structured knowledge graph is formed. The knowledge graph has powerful multi-level reasoning capabilities, thereby overcoming the limitations of traditional long-term memory recall methods in related information retrieval, and can significantly improve the comprehensiveness and depth of memory recall. BRIEF DESCRIPTION OF THE DRAWINGS

[0051] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0052] Figure 1 A flowchart of a memory recall method based on a large language model provided in an embodiment of the present application;

[0053] Figure 2 A structural schematic diagram of a memory recall device based on a large language model provided in an embodiment of the present application. DETAILED DESCRIPTION

[0054] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0055] The existing memory recall method based on vector indexing has limitations in memory association ability, and the intelligent system cannot effectively associate one entity with another related entity. This is because the vector index mainly relies on the similarity between pre-calculated embedding vectors and lacks a deep understanding of the semantic relationship between entities. Therefore, it is difficult for the system to perform complex memory reasoning and association, which greatly reduces the cognitive ability and application scope of the intelligent system.

[0056] Another key technical problem is the incomplete recall of entity memory information, which makes it difficult to fully recall all memory information related to a specific entity. This problem is mainly manifested in memory information fragmentation, memory information bias, and memory context loss. Technical reasons include that the vector indexing method mainly focuses on local memory similarities and has difficulty capturing the global memory semantic structure; lacks effective memory organization and association mechanisms, and cannot build a complete memory network. This will affect the decision-making quality and user experience of intelligent systems, especially in memory scenarios that require a comprehensive understanding of an entity or concept, such as intelligent customer service, virtual companionship and other applications.

[0057] To improve your understanding of the above issues, please refer to Figure 1 , the embodiment of the present application provides a memory recall method based on a large language model, comprising:

[0058] Step 110: Obtain short-term conversation information between the user and the agent, obtain short-term memory, and divide the short-term memory to obtain inactive short-term memory and active short-term memory.

[0059] Obtain short-term conversation information between two conversation entities (user and agent) as short-term memory. Short-term memory is the ability of an AI system to temporarily store and process information, similar to human working memory. Short-term memory has the following characteristics:

[0060] 1) Limited capacity: usually only a small amount of information can be stored;

[0061] 2) Short duration: If information is not frequently used or transformed, it will be quickly forgotten;

[0062] 3) Quick access: can be called and processed quickly.

[0063] Long-term memory is the ability of an AI system to store and retrieve information over a long period of time, which is equivalent to human long-term memory. Long-term memory has the following characteristics:

[0064] 1) Large capacity: can store massive amounts of information;

[0065] 2) Persistence: information can be stored for a long time;

[0066] 3) Structured: Information is usually stored in some structured form to facilitate subsequent retrieval.

[0067] Considering that the capacity of short-term memory is limited and it is quickly forgotten, in order to better simulate human memory, the short-term memory that is about to be forgotten is subjected to deep semantic analysis, useful information is extracted, unnecessary details are ignored, and it is converted into long-term memory. Before further processing the short-term memory, it is necessary to first divide the short-term memory to determine which memories are inactive short-term memories and which short-term memories are active short-term memories.

[0068] Specifically, the short-term memory with more than a preset number of rounds and the time for generating the dialogue information exceeding the preset time is classified as inactive short-term memory, and the remaining short-term memory is classified as active short-term memory. Short-term memory is divided into pending short-term memory and active short-term memory based on the time dimension and the number of rounds of dialogue. When the number of rounds of dialogue exceeds a certain number of rounds, and the time for generating the message in the short-term memory exceeds a certain number of rounds, this is used as the dividing line. The part that does not exceed the limit is active short-term memory, and the part that exceeds the limit is inactive short-term memory.

[0069] Step 120: parse the semantic content of the inactive short-term memory through a large language model to obtain first entity information and entity relationship triples.

[0070] The large language model is used to parse the semantic content from the conversation information in the inactive short-term memory to obtain the first entity information and entity relationship triples. The large language model can be trained by matching the entity information and entity relationship training text in the known database. The semantic content includes the subject (agent), the conversation object (user), the conversation sub-object (other entities mentioned, such as places, people, organizations, etc.) and their related relationships (born, liked, owned, etc.).

[0071] After the semantic content is defined, in order to ensure the quality of semantic content parsing of the large language model, the content input to the large language model needs to be comprehensive, including:

[0072] 1. System settings: You need to set clear memory graph extraction task goals for the large language model. For example, if you are a memory graph extractor, please identify all these types of entities and all the relationships between them from the provided dialogue information.

[0073] 2. Context information, which needs to include a list of entities that already exist in the current memory map, to prevent the large language model from generating different names (uppercase, lowercase, alias, synonyms, etc.) for the same real entity, thus ensuring the quality of memory map generation;

[0074] 3. Output format, define the formatted output structure of triples. Each entity should have three pieces of information: name, type, and description. Name must be unique. Entity relationships must include name, description, and sentiment weight. Name must be unique between two entities.

[0075] 4. Input and output examples. More generalized input and output examples can effectively enhance the compliance of large language models and make their output more stable.

[0076] By parsing the semantic content of inactive short-term memory through a large language model, the entity information and entity relationship triples mentioned in the inactive short-term memory can be obtained.

[0077] Step 130: Convert the first entity information and the entity relationship triplet into long-term memory to obtain a long-term memory map.

[0078] Processing of the first entity information:

[0079] Check whether each entity in the first entity information already exists in the graph database; the graph database is used to store the long-term memory graph, that is, the long-term memory graph that has been generated before is stored in the graph database;

[0080] If the current entity does not exist in the graph database (that is, the current entity is a new entity), a new entity node is created in the graph database, and the attributes of the current entity are added to the new entity node. The attributes of the entity include name, type, and description.

[0081] If the current entity already exists in the graph database, the description of the current entity can be compared with the description of the entity with the same name in the graph database through the large language model, and the duplicate descriptions can be merged and the non-duplicate descriptions can be retained to update the description of the entity node in the graph database;

[0082] Add a timestamp to the entity node according to the latest update time of the entity node to record the latest update time;

[0083] Establishing entity relationships:

[0084] For each entity relationship triplet, determine the location of the source entity and target entity corresponding to the current entity relationship triplet in the graph database, and check whether the source entity and the target entity have a current entity relationship. The entity relationship triplet includes name, description and sentiment weight;

[0085] If it does not exist, add the current entity relationship (name, type, importance) to the source entity and target entity corresponding to the current entity relationship triple;

[0086] If it exists, the current entity relationship between the source entity and the target entity corresponding to the current entity relationship triplet can be compared with the description of the entity relationship between the source entity and the target entity in the graph database through the large language model, duplicate descriptions can be merged, non-duplicate descriptions can be retained, and the sentiment weights of the source entity and the target entity can be re-evaluated to update the entity relationship between the source entity and the target entity in the graph database (i.e., update the description and sentiment weight);

[0087] Add a timestamp to the entity relationship based on the latest update time of the entity relationship to record the latest update time;

[0088] Output the updated graph database. The updated graph database output is the latest long-term memory graph.

[0089] It should be noted that when establishing entity relationships, the directionality of entity relationships needs to be considered, and bidirectional relationships may need to be created. The semantic content extracted by the large language model in the inactive short-term memory will contain the information of the entity and the direction between the two entities, for example:

[0090] (Father) - [Care] -> (Son)

[0091] (Son) - [Respect and reluctance] -> (Father)

[0092] The above example requires the creation of a bidirectional relationship between entities (father and son).

[0093] Through the above process, inactive short-term memory is subjected to deep semantic parsing, useful messages are extracted, unnecessary details are ignored, and it is converted into long-term memory.

[0094] Step 140: Use a large language model to extract entities from active short-term memory based on entity information in the long-term memory graph and perform reasoning level evaluation on the extracted entities, and combine the extracted entities and the corresponding reasoning levels to generate a query language.

[0095] Multi-level reasoning refers to a type of reasoning performed in information structures such as knowledge graphs or relational databases, in which the reasoning process needs to go through multiple levels or levels, gradually deducing from one entity to another to answer complex queries or questions.

[0096] The problems with the reasoning process of memory map recall are: 1. The entities extracted by traditional NER and other technologies do not exist in the memory map, or there are similar or synonymous entities, making it difficult to recall related memories; 2. It is impossible to dynamically formulate a suitable reasoning level. When the level is small, incomplete memory extraction will occur. When it is large, the extracted memory is too redundant, making it difficult to extract effective memory.

[0097] For the first problem, a large language model is introduced to extract entities from active short-term memory. The large language model extracts entities from active short-term memory based on the entity information in the long-term memory map to obtain second entity information. This application provides the large language model with the existing entity information in the long-term memory map to extract entities from active short-term memory, so that the large language model has a basis for entity extraction. Relying on the generalization ability of the large language model, the extracted entities are all valid, thereby solving the problem of inconsistency between the extracted entities and the map entities.

[0098] For the second question, we first need to evaluate the relevance between the extracted entities and the actual memory recall problem (the memory recall problem is a question asked by the user to the intelligent agent in the short-term dialogue information). By limiting the relevance range (such as 0-10), the large language model sorts the entities in the second entity information according to the relevance, outputs the first number of entities after sorting (i.e., Top K entities), and obtains the Top K entity list. Among them, the relevance will be evaluated based on the ability of the large language model based on semantic understanding. Then, in order to select the appropriate memory reasoning level, the logical reasoning ability of the large language model is used to dynamically evaluate the reasoning level of the Top K entities in the entity list for the current memory recall problem. It is understandable that the prompt for evaluating the reasoning level can be set to the large language model through the prompt engineering, and the context (memory recall problem + Top K entity list) can be provided to the large language model, so that the large language model outputs the reasoning level of each entity in the Top K entity list for the corresponding memory recall problem.

[0099] Through the above process, the Top K entity list and reasoning level ranked by relevance can be obtained, and the query language is generated by combining the entities in the Top K entity list and the reasoning level.

[0100] The query is mainly done through the library query language (such as cypher), which can be generated through a large language model or directly through a preset strategy. Take a preset strategy as an example. For example, given the source entity e1 and reasoning level 3, the query language match (e1:Entity) -[r:relation is generated by combining the source entity e1 and reasoning level 3. ..3]->(e2:Entity), through this query language, all the three-level relationships r and entity e2 of the source entity e1 can be found from the long-term memory map. This will query one or more long-term memory triples. In order to avoid too many long-term memory triples, secondary sorting can be performed later to filter out the triplets with low relevance.

[0101] Step 150: query the long-term memory map through a query language to obtain long-term memory triple information, and perform text processing on the long-term memory triple information to obtain long-term memory text information.

[0102] The corresponding long-term memory triple information (subject, relationship, object) can be queried from the long-term memory map through the query language, that is, the long-term memory triple includes the subject, the object and the relationship between the subject and the object. The query result is in the form of a subgraph, and the subgraph obtained by the query is textualized. The textualization logic is: take the triple as a unit, splice each unit of the subgraph into a sentence through the name field, and attach a detailed description to obtain the long-term memory text information.

[0103] Step 160: Generate a response based on the long-term memory text information and short-term memory through the large language model.

[0104] In one embodiment, long-term memory text information and short-term memory can be directly input into a large language model to generate a response.

[0105] In another embodiment, in order to further reduce the amount of information recalled from memory, the memory text information is sorted again to filter out the long-term memory text information with low relevance, and then a reply is generated based on the filtered long-term memory text information and short-term memory. Specifically:

[0106] S161, calculating the total relevance score of each long-term memory text information;

[0107] Calculate the similarity score rerank_score between each long-term memory text information and the corresponding memory recall question; the similarity score between the long-term memory text information and the memory recall question can be evaluated through the rerank model;

[0108] The similarity score rerank_score between each long-term memory text information and the corresponding memory recall question, the relevance of the entity in each long-term memory text information entity_relavance_score, and the sentiment weight importance of the entity relationship are weighted summed to obtain the total relevance score of each long-term memory text information, that is:

[0109]

[0110] In the formula, α, β, and γ are the entity relevance, the sentiment weight of the entity relationship, and the weight coefficient of the similarity score, respectively. Their values ​​can be fine-tuned according to the actual usage scenario. The entity relevance of each long-term memory text information inherits the relevance of the starting entity. For example, entity e1 is the Top K starting entity, and the entity relevance of entity e1 and the memory recall question is 8, then the entity relevance of all entities associated with e1 is 8.

[0111] S162, sorting the long-term memory text information in descending order according to the total relevance score, and obtaining the first second number of long-term memory text information after sorting;

[0112] S163. Generate a response based on the sorted first second number of long-term memory text information and short-term memory through a large language model.

[0113] The sorted first second amount of long-term memory text information and short-term memory are input into the large language model to generate the final response.

[0114] This application divides the acquired short-term memory, performs deep semantic analysis on the inactive short-term memory, extracts useful information, ignores unnecessary details, and converts it into a long-term memory map for long-term storage, so that more complete entity memory information can be recalled during subsequent memory recall; extracts entities from active short-term memory through a large language model and dynamically evaluates the reasoning level, and provides the large language model with existing entity information in the long-term memory map, so that the entities extracted by the large language model are relevant and valid, avoiding the problem of inconsistency between the extracted entities and the map entities; selects the appropriate memory reasoning level by evaluating the correlation between the extracted entities and the actual memory recall problem, avoiding the problem of incomplete memory extraction when the level is small, and the problem of too redundant extracted memory and difficulty in refining effective memory when the level is large. This application can significantly improve the memory association ability and the integrity of memory recall by introducing a large language model for semantic analysis and multi-level reasoning, and combining short-term memory and long-term memory for memory recall.

[0115] The above is an embodiment of a memory recall method based on a large language model provided by the present application. The following is an embodiment of a memory recall system based on a large language model provided by the present application.

[0116] Please refer to Figure 2 , a memory recall system based on a large language model provided in an embodiment of the present application includes:

[0117] The partitioning module is used to obtain the short-term dialogue information between the user and the agent, obtain the short-term memory, and partition the short-term memory to obtain the inactive short-term memory and the active short-term memory;

[0118] A semantic parsing module, used to parse the semantic content of the inactive short-term memory through a large language model to obtain the first entity information and entity relationship triples;

[0119] A conversion module, used for converting the first entity information and the entity relationship triplet into long-term memory to obtain a long-term memory map;

[0120] The multi-level reasoning module is used to extract entities from active short-term memory based on entity information in the long-term memory graph through a large language model, evaluate the reasoning level of the extracted entities, and combine the extracted entities and the corresponding reasoning levels to generate query language;

[0121] A query module is used to query the long-term memory map through a query language to obtain long-term memory triple information, and to textually process the long-term memory triple information to obtain long-term memory text information;

[0122] The response generation module is used to generate responses based on long-term memory text information and short-term memory through a large language model.

[0123] As a further improvement, modules are divided, specifically for:

[0124] Obtain short-term conversation information between the user and the agent to obtain short-term memory;

[0125] The short-term memories whose dialogue rounds exceed a preset number and whose dialogue information generation time exceeds a preset time are classified as inactive short-term memories, and the remaining short-term memories are classified as active short-term memories.

[0126] As a further improvement, the conversion module is specifically used for:

[0127] Check whether each entity in the first entity information already exists in a graph database; the graph database is used to store long-term memory graphs;

[0128] If the current entity does not exist in the graph database, a new entity node is created in the graph database, and the attributes of the current entity are added to the new entity node. The attributes of the entity include name, type, and description.

[0129] If the current entity already exists in the graph database, compare the description of the current entity with the entity of the same name in the graph database, merge the duplicate descriptions, and retain the non-duplicate descriptions to update the description of the entity node in the graph database;

[0130] For each entity relationship triplet, determine the location of the source entity and target entity corresponding to the current entity relationship triplet in the graph database, and check whether the source entity and the target entity have a current entity relationship. The entity relationship triplet includes name, description and sentiment weight;

[0131] If it does not exist, add the current entity relationship to the source entity and target entity corresponding to the current entity relationship triple;

[0132] If it exists, compare the current entity relationship between the source entity and the target entity corresponding to the current entity relationship triplet with the description of the entity relationship between the source entity and the target entity in the graph database, merge duplicate descriptions, retain non-duplicate descriptions, and re-evaluate the sentiment weights of the source entity and the target entity to update the entity relationship between the source entity and the target entity in the graph database;

[0133] Output the updated graph database.

[0134] As a further improvement, the multi-level reasoning module is specifically used to:

[0135] The large language model extracts entities from active short-term memory based on the entity information in the long-term memory map to obtain the second entity information.

[0136] Evaluate the relevance between the entities in each second entity information and the memory recall question, sort the entities in each second entity information in descending order according to the relevance, output the first first number of entities after sorting, and obtain an entity list; the memory recall question is a question initiated by the user to the intelligent agent in the short-term dialogue information;

[0137] Using a large language model, we evaluate the reasoning level of the entity pairs in the entity list corresponding to the memory recall question based on the memory recall question and the entity list.

[0138] Combine the extracted entities and the corresponding reasoning levels to generate query language.

[0139] As a further improvement, the method further comprises: a sorting module, which is used to:

[0140] Calculate the total relevance score of each long-term memory text information;

[0141] Sort the long-term memory text information in descending order according to the total relevance score, and obtain the first second number of long-term memory text information after sorting;

[0142] The reply generation module is specifically used to generate a reply based on the sorted first second number of long-term memory text information and short-term memory through a large language model.

[0143] The memory recall system based on a large language model provided in the present application accurately extracts entities and their relationships from complex short-term memory information based on the deep semantic parsing function of the large language model, and then constructs a sophisticated relationship network. Through the establishment of this network, a highly structured knowledge graph is formed. The knowledge graph has powerful multi-level reasoning capabilities, thereby overcoming the limitations of traditional long-term memory recall methods in related information retrieval, and can significantly improve the comprehensiveness and depth of memory recall.

[0144] The embodiment of the present application also provides an electronic device, the device comprising a processor and a memory;

[0145] The memory is used to store the program code and transmit the program code to the processor;

[0146] The processor is used to execute the memory recall method based on the large language model in the aforementioned method embodiment according to the instructions in the program code.

[0147] An embodiment of the present application also provides a computer-readable storage medium, which is used to store program code. When the program code is executed by a processor, the memory recall method based on the large language model in the aforementioned method embodiment is implemented.

[0148] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the system described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.

[0149] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of this application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0150] It should be understood that in this application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.

[0151] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0152] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0153] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0154] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium, including a number of instructions for executing all or part of the steps of the method described in each embodiment of the present application through a computer device (which can be a personal computer, server, or network device, etc.). The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (full name in English: Read-Only Memory, English abbreviation: ROM), random access memory (full name in English: Random Access Memory, English abbreviation: RAM), disk or optical disk and other media that can store program codes.

[0155] As described above, the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims

1. A memory recall method based on a large language model, characterized in that: include: Acquire short-term conversation information between the user and the agent to obtain short-term memory, and divide the short-term memory to obtain inactive short-term memory and active short-term memory; Parsing the semantic content of the inactive short-term memory by using a large language model to obtain first entity information and entity relationship triples; Converting the first entity information and entity relationship triples into long-term memory to obtain a long-term memory map; Extracting entities from the active short-term memory according to the entity information in the long-term memory map through a large language model, evaluating the extracted entities by reasoning levels, and combining the extracted entities and the corresponding reasoning levels to generate a query language; Querying the long-term memory map by using the query language to obtain long-term memory triple information, and textualizing the long-term memory triple information to obtain long-term memory text information; A response is generated based on the long-term memory text information and the short-term memory through a large language model.

2. The memory recall method based on a large language model according to claim 1, characterized in that: The dividing the short-term memory to obtain inactive short-term memory and active short-term memory includes: The short-term memories whose dialogue rounds exceed a preset number and whose dialogue information generation time exceeds a preset time are classified as inactive short-term memories, and the remaining short-term memories are classified as active short-term memories.

3. The memory recall method based on a large language model according to claim 1, characterized in that: The converting the first entity information and entity relationship triples into long-term memory to obtain a long-term memory map includes: Checking whether each entity in the first entity information already exists in a graph database; the graph database is used to store long-term memory graphs; If the current entity does not exist in the graph database, a new entity node is created in the graph database, and the attributes of the current entity are added to the new entity node, where the attributes of the entity include name, type and description; If the current entity already exists in the graph database, compare the description of the current entity with the entity of the same name in the graph database, merge the duplicate descriptions, and retain the non-duplicate descriptions to update the description of the entity node in the graph database; For each entity relationship triplet, determine the location of the source entity and the target entity corresponding to the current entity relationship triplet in the graph database, and check whether there is a current entity relationship between the source entity and the target entity, wherein the entity relationship triplet includes a name, a description, and a sentiment weight; If it does not exist, add the current entity relationship to the source entity and target entity corresponding to the current entity relationship triple; If it exists, compare the current entity relationship between the source entity and the target entity corresponding to the current entity relationship triplet with the description of the entity relationship between the source entity and the target entity in the graph database, merge duplicate descriptions, retain non-duplicate descriptions, and re-evaluate the sentiment weights of the source entity and the target entity to update the entity relationship between the source entity and the target entity in the graph database; Output the updated graph database.

4. The memory recall method based on a large language model according to claim 1, characterized in that: The extracting entities from the active short-term memory according to the entity information in the long-term memory map by using the large language model and performing reasoning level evaluation on the extracted entities include: Extracting entities from the active short-term memory according to the entity information in the long-term memory map using a large language model to obtain second entity information; Evaluate the relevance between the entities in each of the second entity information and the memory recall question, sort the entities in each of the second entity information in descending order according to the relevance, output the first first number of entities after sorting, and obtain an entity list; the memory recall question is a question initiated by the user to the intelligent agent in the short-term dialogue information; The reasoning level of the entities in the entity list corresponding to the memory recall question is evaluated according to the memory recall question and the entity list through a large language model.

5. The memory recall method based on a large language model according to claim 1, characterized in that: The long-term memory triple information is processed into text form to obtain long-term memory text information, and then the following steps are further included: Calculating the total relevance score of each of the long-term memory text information, sorting each of the long-term memory text information in descending order according to the total relevance score, and obtaining the first second number of sorted long-term memory text information; The generating a response according to the long-term memory text information and the short-term memory by using a large language model includes: A response is generated by a large language model based on the sorted first second number of long-term memory text information and the short-term memory.

6. The memory recall method based on a large language model according to claim 5, characterized in that: The calculating of the total relevance score of each of the long-term memory text information comprises: Calculating similarity scores between each of the long-term memory text information and the corresponding memory recall question; The similarity scores between each long-term memory text information and the corresponding memory recall question, the relevance of the entities in each long-term memory text information, and the sentiment weight of the entity relationship are weighted summed to obtain the total relevance score of each long-term memory text information.

7. A memory recall system based on a large language model, characterized in that: include: A partitioning module is used to obtain short-term conversation information between the user and the agent, obtain short-term memory, and partition the short-term memory to obtain inactive short-term memory and active short-term memory; A semantic parsing module, used for performing semantic content parsing on the inactive short-term memory through a large language model to obtain first entity information and entity relationship triples; A conversion module, used for converting the first entity information and entity relationship triples into long-term memory to obtain a long-term memory map; A multi-level reasoning module, for extracting entities from the active short-term memory according to the entity information in the long-term memory map through a large language model, performing reasoning level evaluation on the extracted entities, and combining the extracted entities and the corresponding reasoning levels to generate a query language; A query module, used for querying the long-term memory map by using the query language to obtain long-term memory triple information, and performing text processing on the long-term memory triple information to obtain long-term memory text information; A reply generation module is used to generate a reply based on the long-term memory text information and the short-term memory through a large language model.

8. The memory recall system based on a large language model according to claim 7, characterized in that: The multi-level reasoning module is specifically used for: Extracting entities from the active short-term memory according to the entity information in the long-term memory map using a large language model to obtain second entity information; Evaluate the relevance between the entities in each of the second entity information and the memory recall question, sort the entities in each of the second entity information in descending order according to the relevance, output the first first number of entities after sorting, and obtain an entity list; the memory recall question is a question initiated by the user to the intelligent agent in the short-term dialogue information; Evaluating, by a large language model, the reasoning level of the entities in the entity list corresponding to the memory recall question according to the memory recall question and the entity list; Combine the extracted entities and the corresponding reasoning levels to generate query language.

9. An electronic device, characterized in that: The device comprises a processor and a memory; The memory is used to store program codes and transmit the program codes to the processor; The processor is used to execute the memory recall method based on a large language model according to any one of claims 1 to 6 according to the instructions in the program code.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium is used to store program code, and when the program code is executed by the processor, the memory recall method based on the large language model according to any one of claims 1 to 6 is implemented.

Citation Information

Cited By

  • Text generation model evaluation method and device

    CN119692351A

  • Text generation model evaluation method and apparatus

    CN119692351B

  • Intelligent agent dialogue generation method and storage medium

    CN120448511A

  • Memory information determination method and device based on large model, and task processing method and device based on large model

    CN121581201A

  • Hybrid memory management method and system for large model agent

    CN121599075A