Knowledge graph construction method and device, equipment and computer readable storage medium
By constructing and updating the knowledge graph, the problem of insufficient long-term memory maintenance in traditional solutions is solved, and the ability to store user context in long-term memory and enhance long-term conversation capabilities is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- BEIJING JIZHI DIGITAL TECH CO LTD
- Filing Date
- 2026-02-03
- Publication Date
- 2026-06-19
AI Technical Summary
Traditional solutions lack long-term memory maintenance, resulting in insufficient long-term conversation capabilities and problems such as context breaks, repeated questioning, and lack of personalization.
By acquiring user information from the current dialogue record, the dialogue topic, factual concepts, and user preference information are extracted. It is then determined whether the target knowledge graph is stored in the data storage system. If not, the knowledge graph is constructed and stored. If it is, the target knowledge graph is updated, including constructing or updating topic nodes, factual concept nodes, and preference information nodes, and establishing relationships.
It implements long-term memory storage of user context modules, avoiding context breakage, repeated questions, and loss of personalization, thereby improving long-term conversation capabilities.
Smart Images

Figure CN122242672A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of knowledge graph construction technology, and in particular to a knowledge graph construction method, apparatus, device and computer-readable storage medium. Background Technology
[0002] For intelligent agents, memory is a key ability that enables them to store and recall past experiences or relevant knowledge. It allows agents to accumulate experience, thereby promoting wiser and more appropriate actions.
[0003] Traditional solutions lack long-term memory maintenance, resulting in insufficient long-term conversation capabilities.
[0004] In conclusion, how to maintain long-term memory in order to improve long-term conversation capabilities is a technical problem that urgently needs to be solved by those skilled in the art. Summary of the Invention
[0005] In view of this, the purpose of this application is to provide a knowledge graph construction method, apparatus, device and computer-readable storage medium for long-term memory maintenance in order to improve long-term conversation capabilities.
[0006] To achieve the above objectives, this application provides the following technical solution: A knowledge graph construction method includes: obtaining user information corresponding to a current dialogue record, and extracting dialogue topic, factual concepts, and user preference information from the current dialogue record; determining whether a target knowledge graph corresponding to the user information is stored in a data storage system; if not, constructing a knowledge graph based on the user information, the dialogue topic, the factual concepts, and the user preference information, and storing the knowledge graph in the data storage system; if yes, updating the target knowledge graph in the data storage system based on the dialogue topic, the factual concepts, and the user preference information.
[0007] Optionally, after extracting the dialogue topic, factual concepts, and user preference information from the current dialogue record, the method further includes: associating the factual concepts and user preference information with the dialogue topic; updating the target knowledge graph in the data storage system according to the dialogue topic, the factual concepts, and the user preference information, including: determining whether the target knowledge graph stores a topic node corresponding to the dialogue topic; if not, constructing a topic node corresponding to the dialogue topic on the target knowledge graph, and constructing factual concept nodes and preference information nodes associated with the topic node according to the factual concepts and user preference information associated with the dialogue topic; if yes, updating the factual concept nodes and preference information nodes associated with the topic node in the target knowledge graph according to the factual concepts and user preference information associated with the dialogue topic.
[0008] Optionally, updating the fact concept nodes in the target knowledge graph associated with the topic node based on the fact concept associated with the dialogue topic includes: if it is determined that the corresponding fact concept node in the target knowledge graph is invalid based on the fact concept, then deleting the corresponding fact concept node in the target knowledge graph; if it is determined that a corresponding fact concept node needs to be newly created in the target knowledge graph based on the fact concept, then creating the corresponding fact concept node in the target knowledge graph based on the fact concept; if it is determined that the corresponding fact concept node in the target knowledge graph can be overwritten based on the fact concept, then deleting the corresponding fact concept node in the target knowledge graph and creating the corresponding fact concept node in the target knowledge graph based on the fact concept.
[0009] Optionally, updating the preference information nodes associated with the topic node in the target knowledge graph based on the user preference information associated with the dialogue topic includes: if it is determined that the corresponding preference information node in the target knowledge graph is invalid based on the user preference information, then deleting the corresponding preference information node in the target knowledge graph; if it is determined that a corresponding preference information node needs to be newly created in the target knowledge graph based on the user preference information, then creating the corresponding preference information node in the target knowledge graph based on the user preference information; if it is determined that the corresponding preference information node in the target knowledge graph can be overwritten based on the user preference information, then deleting the corresponding preference information node in the target knowledge graph and creating the corresponding preference information node in the target knowledge graph based on the user preference information.
[0010] Optionally, it further includes: determining the relationships between fact concept nodes and preference information nodes, the relationships between fact concept nodes, and the relationships between preference information nodes in the target knowledge graph; and storing the relationships between fact concept nodes and preference information nodes, the relationships between fact concept nodes, and the relationships between preference information nodes in the target knowledge graph.
[0011] Optionally, it further includes: extracting from the current dialogue record the association between the user information and the dialogue topic, the association between the dialogue topic and the factual concepts and the user preference information, the association between the factual concepts and the user preference information, the association between the factual concepts, and the association between the user preference information; constructing a knowledge graph based on the user information, the dialogue topic, the factual concepts, and the user preference information, including: constructing the knowledge graph based on the user information, the dialogue topic, the factual concepts, the user preference information, the association between the user information and the dialogue topic, the association between the dialogue topic and the factual concepts and the user preference information, the association between the factual concepts and the user preference information, and the association between the factual concepts and the user preference information.
[0012] Optionally, determining whether a target knowledge graph corresponding to the user information is stored in the data storage system includes: determining whether the target knowledge graph is stored in the graph database; storing the knowledge graph in the data storage system includes: storing the knowledge graph in the graph database.
[0013] A knowledge graph construction apparatus includes: an acquisition module, configured to acquire user information corresponding to a current dialogue record, and extract dialogue topic, factual concepts, and user preference information from the current dialogue record; a judgment module, configured to determine whether a target knowledge graph corresponding to the user information is stored in a data storage system; a construction module, configured to construct a knowledge graph based on the user information, the dialogue topic, the factual concepts, and the user preference information if the target knowledge graph corresponding to the user information is not stored in the data storage system, and store the knowledge graph in the data storage system; and an update module, configured to update the target knowledge graph in the data storage system based on the dialogue topic, the factual concepts, and the user preference information if the target knowledge graph corresponding to the user information is stored in the data storage system.
[0014] An electronic device includes: a memory for storing a computer program; and a processor for executing the computer program to implement the steps of the knowledge graph construction method as described in any of the preceding claims.
[0015] A computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the knowledge graph construction method as described in any of the preceding claims.
[0016] This application provides a method, apparatus, device, and computer-readable storage medium for constructing a knowledge graph. The method includes: obtaining user information corresponding to the current dialogue record, and extracting dialogue topic, factual concepts, and user preference information from the current dialogue record; determining whether a target knowledge graph corresponding to the user information is stored in the data storage system; if not, constructing a knowledge graph based on the user information, dialogue topic, factual concepts, and user preference information, and storing the knowledge graph in the data storage system; if yes, updating the target knowledge graph in the data storage system based on the dialogue topic, factual concepts, and user preference information.
[0017] The technical solution disclosed in this application obtains user information corresponding to the current dialogue record and extracts dialogue topics, factual concepts, and user preference information from the current dialogue record. If the data storage system does not store a target knowledge graph corresponding to the user information, it constructs a corresponding knowledge graph based on the user information, dialogue topics, factual concepts, and user preference information, and stores the constructed knowledge graph in the data storage system. If the data storage system stores a target knowledge graph corresponding to the user information, it updates the target knowledge graph stored in the data storage system based on the dialogue topics, factual concepts, and user preference information. This enables the construction and storage of a knowledge graph based on dialogue topics, factual concepts, and user preference information extracted from the dialogue record, thereby achieving long-term memory storage of the user context module and maintaining long-term memory. Subsequently, during long-term conversations, the corresponding information contained in the knowledge graph can be queried and retrieved from the data storage system, and long-term conversations can be conducted based on the queried and retrieved information, thereby improving long-term conversation capabilities.
[0018] Additional aspects and advantages of this application will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of this application. Attached Figure Description
[0019] Figure 1 A flowchart illustrating a knowledge graph construction method provided in some embodiments of this application; Figure 2 A schematic diagram illustrating the constructed knowledge graph provided in some embodiments of this application; Figure 3 A schematic diagram of the structure of a knowledge graph construction apparatus provided in some embodiments of this application; Figure 4This is a schematic diagram of the structure of an electronic device provided for some embodiments of this application. Detailed Implementation
[0020] The client-side intelligent agent provides information consulting services to users through an external knowledge base, which is an information-intensive application. For the intelligent agent, memory is a key capability, enabling it to store and recall past experiences or relevant knowledge. This allows the agent to accumulate experience, thereby promoting wiser and more appropriate actions.
[0021] The memory is divided into modules such as short-term memory and long-term memory. Short-term memory is transient and limited because it is constrained by the finite context window length of the Transformer. Short-term memory is typically used to store and process information in the current task or session. Its characteristics are limited capacity and short information retention time. That is, short-term memory uses a fixed-length "context window". As the number of dialogue rounds increases, new dialogue content will displace the earliest dialogue content.
[0022] Traditional solutions rely solely on short-term memory and lack long-term memory maintenance, resulting in insufficient long-term conversation capabilities, such as context breaks, repetitive questioning, and lack of personalization.
[0023] To this end, this application provides a knowledge graph construction method, apparatus, device, and computer-readable storage medium. It obtains user information corresponding to the current dialogue record and extracts dialogue topics, factual concepts, and user preference information from the current dialogue record. If the data storage system does not store a target knowledge graph corresponding to the user information, it constructs a corresponding knowledge graph based on the user information, dialogue topics, factual concepts, and user preference information, and stores the constructed knowledge graph in the data storage system. If the data storage system stores a target knowledge graph corresponding to the user information, it updates the target knowledge graph stored in the data storage system based on the dialogue topics, factual concepts, and user preference information extracted from the current dialogue record. This enables the construction and storage of a knowledge graph based on dialogue topics, factual concepts, and user preference information extracted from the dialogue record, achieving long-term memory storage of the user's context module and thus maintaining long-term memory. Subsequently, during long-distance conversations, the relevant information contained in the knowledge graph can be queried and retrieved from the data storage system based on the information extracted from the conversation. Long-distance conversations can then be conducted based on the queried and retrieved information combined with an external knowledge base, avoiding context breaks, repeated questions, breaks in intent coherence, and lack of personalization, thereby improving long-distance conversation capabilities.
[0024] The embodiments of this application are described in detail below. Examples of these embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and intended to explain this application, and should not be construed as limiting this application.
[0025] See Figure 1 This is a flowchart illustrating a knowledge graph construction method provided in some embodiments of this application. The knowledge graph construction method provided in some embodiments of this application may include: S11: Obtain user information corresponding to the current dialogue record, and extract the dialogue topic, factual concepts, and user preference information from the current dialogue record.
[0026] It should be noted that the execution subject of the knowledge graph construction method provided in some embodiments of this application can be an intelligent agent driven by a large language model. That is, an intelligent agent that extracts and constructs knowledge graph information using a large language model can be selected to construct the knowledge graph.
[0027] In some embodiments of this application, when a user engages in dialogue with an intelligent agent, the agent can obtain user information corresponding to the current dialogue record. Furthermore, the agent can extract the dialogue topic from the current dialogue record, and inspired by human learning and reasoning, it can also extract factual concepts and user preference information from the current dialogue record.
[0028] In this context, the dialogue topic refers to the core issue or area of discussion around which the dialogue revolves. Factual concepts are objective, verifiable, and unbiased specific information units within the dialogue; the extracted factual concepts enhance the agent's ability to recognize knowledge connections. User preference information refers to the methods, forms, or emphases users prefer when acquiring information and learning knowledge; these are subjective behavioral tendencies that can be extracted from the needs expressed in the dialogue. The extracted user preference information is structured and recorded to enrich the knowledge base, ultimately improving the agent's long-term performance in dynamic environments.
[0029] By extracting the above information, a knowledge graph can be constructed based on this information to achieve long-term memory storage of the intelligent agent at the user level, thereby improving conversational capabilities.
[0030] S12: Determine whether the data storage system stores the target knowledge graph corresponding to the user information; if not, proceed to step S13; if yes, proceed to step S14.
[0031] In some embodiments of this application, knowledge graphs can be divided and constructed using user information as units, and the constructed knowledge graphs can be stored in a data storage system to achieve persistent storage of the constructed knowledge graphs.
[0032] Based on the user information corresponding to the current dialogue record, it can be determined whether the data storage system stores a target knowledge graph corresponding to the user information. The target knowledge graph is constructed and updated based on the historical dialogue records between the user and the intelligent agent corresponding to the user information.
[0033] The data storage system can be a graph database. For example, the data storage system can be the graph database Neo4j. In this case, data interaction (i.e., querying, creating, updating, etc.) can be performed with the graph database Neo4j through the Cypher language. That is, the workflow of knowledge graph construction is driven by a large language model, and the entity and relation results extracted from the dialogue records are stored in the graph database Neo4j.
[0034] Of course, data storage systems can also be databases, file systems, experience pools / replay buffers / experience buffers corresponding to experience replay in reinforcement learning, vector databases, etc. Databases can use relational or non-relational databases to store and retrieve long-term information; this method is suitable for data requiring persistent storage. File systems store information in files for long-term preservation and access. Experience pools / replay buffers / experience buffers in reinforcement learning refer to the storage of past experiences for repeated use during training. Vector databases can store and retrieve high-dimensional vector data, suitable for handling embeddings and similarity searches.
[0035] S13: Construct a knowledge graph based on user information, dialogue topics, factual concepts, and user preference information, and store the knowledge graph in the data storage system.
[0036] When determining whether a target knowledge graph corresponding to user information is stored in the data storage system, if it is determined that no target knowledge graph corresponding to user information is stored in the data storage system, a knowledge graph can be constructed based on the user information corresponding to the current dialogue record, the dialogue topic extracted from the current dialogue record, factual concepts, and user preference information, and the constructed knowledge graph is stored in the data storage system. Therefore, some embodiments of this application extract user preference information, factual concepts, dialogue topics, etc., from dialogue records to construct a knowledge graph to achieve long-term memory storage of the intelligent agent's user dimension, thereby improving conversational capabilities.
[0037] Specifically, each user's information can correspond to an independent knowledge graph. The nodes in the knowledge graph include: __User__ (user), __Topic__ (topic), __Fact__ (factual concepts), and __Preference__ (preference information). The __User__ node is the user node, storing user information. The __Topic__ node is the topic node, storing detailed dialogue information related to the topic in the current dialogue record. The __Fact__ node is the factual concept node, storing factual concepts extracted from the current dialogue record. The __Preference__ node is the preference information node, storing user preference information extracted from the current dialogue record.
[0038] Taking Neo4j, a graph database used for data storage, as an example, the design of a long-term dialogue knowledge graph can be divided into independent subgraphs based on users. Nodes include: __User__, __Topic__, __Fact__, and __Preference__. __Fact__ and __Preference__ can be associated with __Topic__, and different __Fact__ and __Preference__ can be associated with each other through logical relationships between entities. For example, see [link to example]. Figure 2 This is a schematic diagram of the knowledge graph constructed according to some embodiments of this application. Figure 2 It contains three _Topic__ nodes, three _Fact__ nodes, and two _Preference__ nodes.
[0039] S14: Update the target knowledge graph in the data storage system based on the dialogue topic, factual concepts, and user preference information.
[0040] When determining whether a target knowledge graph corresponding to user information is stored in the data storage system, if it is determined that the target knowledge graph is stored in the data storage system, the target knowledge graph in the data storage system can be updated based on the dialogue topic, factual concepts, and user preference information extracted from the current dialogue record corresponding to the user information. This ensures that the target knowledge graph contains reliable and effective key information from the dialogue record, enabling long-term memory storage of the agent's user dimension, thereby improving conversation capabilities. Furthermore, updating the target knowledge graph reduces the time cost of knowledge graph construction, reduces the complexity of the knowledge graph, and reduces the knowledge graph's occupation of storage resources, while ensuring the continuity and dynamic adaptability of the knowledge graph.
[0041] By constructing a knowledge graph based on the user information corresponding to the current dialogue record, as well as the dialogue topic, factual concepts, and user preference information extracted from the current dialogue record, and storing it in the data storage system, or by updating the corresponding target knowledge graph already stored in the data storage system, long-term memory storage and maintenance can be achieved. Subsequently, when the intelligent agent conducts long-term conversations, it can quickly retrieve, query, and access the knowledge graph from the data storage system based on the dialogue with the user to obtain at least one key piece of information from the corresponding dialogue topic, factual concepts, and user preference information. Then, it can conduct a dialogue with the user based on the key information, or it can retrieve the dialogue response from the knowledge base attached to the intelligent agent based on the key information and reply to the user with the dialogue response. This avoids situations such as context breaks, repeated questions, breaks in intent coherence, and lack of personalization, thereby improving long-term conversation capabilities.
[0042] The technical solutions disclosed in some embodiments of this application obtain user information corresponding to the current dialogue record and extract dialogue topics, factual concepts, and user preference information from the current dialogue record. If the data storage system does not store a target knowledge graph corresponding to the user information, a corresponding knowledge graph is constructed based on the user information, dialogue topics, factual concepts, and user preference information, and the constructed knowledge graph is stored in the data storage system. If the data storage system stores a target knowledge graph corresponding to the user information, the target knowledge graph stored in the data storage system is updated based on the dialogue topics, factual concepts, and user preference information. This enables the construction of a knowledge graph based on dialogue topics, factual concepts, and user preference information extracted from the dialogue record and its storage in the data storage system, thereby achieving long-term memory storage of the user context module and maintaining long-term memory. Subsequently, during long-term conversations, the corresponding information contained in the knowledge graph can be queried and retrieved from the data storage system, and long-term conversations can be conducted based on the queried and retrieved information, thereby improving long-term conversation capabilities.
[0043] This application provides a knowledge graph construction method in some embodiments, which, after extracting dialogue topics, factual concepts, and user preference information from the current dialogue record, may further include: Associate factual concepts, user preference information, and conversation topics; Updating the target knowledge graph in the data storage system based on dialogue topics, factual concepts, and user preference information can include: Determine whether the target knowledge graph stores a topic node corresponding to the dialogue topic; If not, construct topic nodes corresponding to the dialogue topic on the target knowledge graph, and construct fact concept nodes and preference information nodes associated with the topic nodes based on fact concepts and user preference information associated with the dialogue topic. If so, the fact concept nodes and preference information nodes associated with the topic nodes in the target knowledge graph are updated based on the fact concepts and user preference information related to the dialogue topic.
[0044] In some embodiments of this application, after extracting the dialogue topic, factual concepts, and user preference information from the current dialogue record, the extracted factual concepts and user preference information can be associated with the dialogue topic to improve the accuracy of information acquisition, avoid redundant invalid information, strengthen the logic of the knowledge system, facilitate in-depth understanding and reuse, support the continuous satisfaction of personalized needs, and adapt to long-term knowledge accumulation.
[0045] Based on the above, the constructed knowledge graph can specifically connect user nodes with topic nodes, and topic nodes with fact concept nodes and preference information nodes.
[0046] Furthermore, based on the above, when updating the target knowledge graph in the data storage system according to the dialogue topic, factual concepts, and user preference information, it can first be determined whether the target knowledge graph in the data storage system stores a topic node corresponding to the dialogue topic. In some embodiments of this application, the agent can define a tool: `read_history_concept_about_given_topic`. This tool's function is to read historically stored dialogue information extracted from non-current dialogues based on a given topic. That is, the agent can use the `read_history_concept_about_given_topic` tool to query and determine whether the target knowledge graph stores a topic node corresponding to the dialogue topic.
[0047] If it is determined that the target knowledge graph does not store a topic node corresponding to the dialogue topic, then a topic node corresponding to the dialogue topic can be constructed on the target knowledge graph. Based on the factual concepts and user preference information associated with the dialogue topic, factual concept nodes and preference information nodes associated with the topic node can be constructed. This allows the target knowledge graph to contain the dialogue topic, factual concepts, and user preference information from the current dialogue record, thereby enabling long-term memory maintenance based on the latest and most effective dialogue topic, factual concepts, and user preference information, and improving long-term conversation capabilities.
[0048] In some embodiments of this application, the agent may also define tools: `save_topic`, `save_fact_concept_user_concerned`, and `save_preference_concept_user_mentioned`. The `save_topic` tool saves a topic discussed by the user in the current dialogue. That is, the agent can call `save_topic` to construct a topic node corresponding to the dialogue topic on the target knowledge graph. This tool can be called multiple times. The `save_fact_concept_user_concerned` tool extracts factual concepts of interest to the user from the dialogue record around the dialogue topic and saves them. That is, the agent can call `save_fact_concept_user_concerned` to construct factual concept nodes associated with the topic node based on the factual concepts extracted from the current dialogue record and related to the dialogue topic. This tool can be called multiple times. The `save_preference_concept_user_mentioned` tool extracts user-related preference information from the dialogue record around the dialogue topic and saves it. In other words, the agent can construct preference information nodes associated with the topic node based on user preference information extracted from the current dialogue record and related to the dialogue topic by calling the `save_preference_concept_user_mentioned` tool. This tool can be called multiple times. As described above, in some embodiments of this application, the workflow for the agent to construct the knowledge graph can be self-planned by the large model based on a customized workflow and some tools in the prompt words.
[0049] If it is determined that the target knowledge graph stores topic nodes corresponding to the dialogue topic, then the fact concept nodes and preference information nodes associated with the topic nodes of the dialogue topic in the target knowledge graph can be updated according to the fact concepts and user preference information associated with the dialogue topic. This allows the target knowledge graph to contain the dialogue topic, fact concepts, and user preference information from the current dialogue record, thereby enabling long-term memory maintenance based on the latest and most effective dialogue topic, fact concepts, and user preference information, and improving long-term conversation capabilities.
[0050] This application provides a knowledge graph construction method in some embodiments, which updates fact concept nodes associated with topic nodes in a target knowledge graph based on fact concepts related to a dialogue topic. This method may include: If the corresponding fact concept node in the target knowledge graph is determined to be invalid based on the fact concept, then the corresponding fact concept node in the target knowledge graph is deleted. If it is determined that a corresponding fact concept node needs to be created in the target knowledge graph based on the fact concept, then a corresponding fact concept node is created in the target knowledge graph based on the fact concept. If it is determined that the corresponding fact concept node in the target knowledge graph can be covered based on the fact concept, then the corresponding fact concept node in the target knowledge graph is deleted, and a corresponding fact concept node is created in the target knowledge graph based on the fact concept.
[0051] In some embodiments of this application, the process of updating the fact concept nodes associated with the topic nodes in the target knowledge graph based on the fact concepts associated with the dialogue topic can specifically be as follows: (11) If the factual concept node in the target knowledge graph is determined to be invalid based on the factual concept extracted from the current dialogue record (but no new factual concept corresponding to the factual concept extracted from the current dialogue record is required), where the factual concept node in the target knowledge graph is constructed based on historical dialogue records. For example: the factual concept extracted from the current dialogue record can prove that the corresponding factual concept node in the target knowledge graph is wrong, no longer valid, or invalid, but the factual concept extracted from the current dialogue record cannot fully encompass the domain involved by the corresponding factual concept node in the target knowledge graph, etc., and the factual concept extracted from the current dialogue record cannot completely replace the corresponding factual concept node in the target knowledge graph, but only negates the validity of the corresponding factual concept node in the target knowledge graph, then the corresponding factual concept node in the target knowledge graph can be determined to be invalid. In this case, the corresponding factual concept node in the target knowledge graph can be deleted. It should be noted that in some embodiments of this application, the agent may also define a tool: delete_history_fact_concept. The function of this tool is to invalidate historical fact concepts. That is, the agent can call the delete_history_fact_concept tool to delete the corresponding fact concept node in the target knowledge graph when it is determined that the corresponding fact concept node in the target knowledge graph is invalid.
[0052] (12) If it is determined that a corresponding fact concept node needs to be newly created in the target knowledge graph based on the fact concept extracted from the current dialogue record, for example, the target knowledge graph does not contain a fact concept node corresponding to the fact concept extracted from the current dialogue record, and this fact concept is mentioned for the first time by the corresponding user. In this case, a corresponding fact concept node can be newly created in the target knowledge graph based on the fact concept extracted from the current dialogue record. Specifically, the agent can use the save_fact_concept_user_concerned tool to create a corresponding fact concept node in the target knowledge graph based on the fact concept extracted from the current dialogue record. In particular, the agent can use the above tool to create a fact concept node associated with the corresponding topic node in the target knowledge graph based on the fact concept extracted from the current dialogue record and associated with the dialogue topic.
[0053] (13) If it is determined that the corresponding fact concept node in the target knowledge graph can be covered based on the fact concept extracted from the current dialogue record. For example: the fact concept extracted from the current dialogue record not only renders the corresponding fact concept node in the target knowledge graph ineffective, but also completely includes or replaces the corresponding fact concept node in the target knowledge graph in terms of scope, content, and dimension. The fact concept extracted from the current dialogue record has more comprehensive and accurate characteristics and can replace the corresponding fact concept node in the target knowledge graph to describe the relevant situation. In this case, it can be determined that the corresponding fact concept node in the target knowledge graph can be covered. At this time, the corresponding fact concept node in the target knowledge graph can be deleted, and a new corresponding fact concept node can be created in the target knowledge graph based on the fact concept extracted from the current dialogue record. Specifically, the agent can delete the corresponding fact concept node in the target knowledge graph by calling the delete_history_fact_concept tool. Then, the agent can create a new fact concept node in the target knowledge graph based on the fact concept extracted from the current dialogue record by calling the save_fact_concept_user_concerned tool. (Specifically, the agent can create a new fact concept node in the target knowledge graph based on the fact concept extracted from the current dialogue record that is related to the dialogue topic, and based on the aforementioned tool.)
[0054] The above process can improve the effectiveness, reliability, and accuracy of the target knowledge graph, thereby facilitating the enhancement of the agent's long-range conversational capabilities.
[0055] This application provides a knowledge graph construction method in some embodiments, which updates preference information nodes associated with topic nodes in a target knowledge graph based on user preference information associated with a dialogue topic. This method may include: If the corresponding preference information node in the target knowledge graph is determined to be invalid based on user preference information, then the corresponding preference information node in the target knowledge graph is deleted. If it is determined based on user preference information that a corresponding preference information node needs to be created in the target knowledge graph, then the corresponding preference information node is created in the target knowledge graph based on the user preference information. If it is determined based on user preference information that the corresponding preference information node in the target knowledge graph can be covered, then the corresponding preference information node in the target knowledge graph is deleted, and a new corresponding preference information node is created in the target knowledge graph based on user preference information.
[0056] In some embodiments of this application, the process of updating preference information nodes associated with topic nodes in the target knowledge graph based on user preference information associated with the dialogue topic can specifically be as follows: (21) If the user preference information extracted from the current dialogue record determines that the corresponding preference information node in the target knowledge graph is invalid (but there is no need to create a new preference information node corresponding to the user preference information extracted from the current dialogue record), wherein the preference information node in the target knowledge graph is constructed based on historical dialogue records. For example: if the user preference information extracted from the current dialogue record can prove that the corresponding preference information node in the target knowledge graph is no longer applicable or meets the user's current needs, but the user preference information extracted from the current dialogue record does not have the ability to replace the corresponding preference information node in the target knowledge graph, then the corresponding preference information node in the target knowledge graph can be determined to be invalid. At this time, the corresponding preference information node in the target knowledge graph can be deleted. It should be noted that in some embodiments of this application, the agent can also define a tool: delete_history_preference_concept, the function of which is to invalidate historical preference information, that is: the agent can delete the corresponding preference information node in the target knowledge graph when the corresponding preference information node in the target knowledge graph is invalid by calling the delete_history_preference_concept tool.
[0057] (22) If it is determined that a corresponding preference information node needs to be created in the target knowledge graph based on the user preference information extracted from the current dialogue record, for example, if the target knowledge graph does not contain a preference information node corresponding to the user preference information extracted from the current dialogue record, and this user preference information is mentioned for the first time by the corresponding user, then a relevant preference information node can be created in the target knowledge graph based on the user preference information extracted from the current dialogue record. Specifically, the agent can create a corresponding preference information node in the target knowledge graph based on the user preference information extracted from the current dialogue record by calling the save_preference_concept_user_mentioned tool. In particular, the agent can create a preference information node associated with the relevant topic node in the target knowledge graph based on the user preference information extracted from the current dialogue record and associated with the dialogue topic.
[0058] (23) If it is determined from the user preference information extracted from the current dialogue record that the corresponding preference information node in the target knowledge graph can be covered. For example: if the user preference information extracted from the current dialogue record can not only prove that the corresponding preference information node in the target knowledge graph is no longer applicable, but can also completely replace the corresponding preference information node in the target knowledge graph, then it can be determined that the corresponding preference information node in the target knowledge graph can be covered. At this time, the corresponding preference information node in the target knowledge graph can be deleted, and the corresponding preference information node can be newly created in the target knowledge graph based on the user preference information extracted from the current dialogue record. Specifically, the agent can delete the corresponding preference information node in the target knowledge graph by calling the delete_history_preference_concept tool, and then the agent can create the corresponding preference information node in the target knowledge graph based on the user preference information extracted from the current dialogue record based on the user preference information related to the dialogue topic extracted from the current dialogue record. (Specifically, the agent can create the preference information node associated with the relevant topic node in the target knowledge graph based on the user preference information related to the dialogue topic extracted from the current dialogue record by calling the above tool.)
[0059] The above process can improve the effectiveness, reliability, and accuracy of the target knowledge graph, thereby facilitating the enhancement of the agent's long-range conversational capabilities.
[0060] A knowledge graph construction method provided in some embodiments of this application may further include: Determine the relationships between fact concept nodes and preference information nodes, the relationships between fact concept nodes, and the relationships between preference information nodes in the target knowledge graph; The relationships between fact concept nodes and preference information nodes, as well as the relationships between fact concept nodes and preference information nodes, are stored in the target knowledge graph.
[0061] In some embodiments of this application, the relationships between fact concept nodes and preference information nodes, the relationships between fact concept nodes, and the relationships between preference information nodes in the target knowledge graph can also be determined. Then, the determined relationships between fact concept nodes and preference information nodes, the relationships between fact concept nodes, and the relationships between preference information nodes can be stored in the target knowledge graph to enrich the information content of the knowledge graph, improve the reliability and accuracy of the target knowledge graph, and thus enhance long-range conversation capabilities.
[0062] It should be noted that in some embodiments, the agent may also define a tool: `save_concept_relation`. This tool is used to identify the inherent relationships between saved factual concepts and user preference information, generate their relationships, and save them. Based on this, the agent can identify and determine the relationships between factual concept nodes and preference information nodes, the relationships between factual concept nodes, and the relationships between preference information nodes based on the factual concept nodes and preference information nodes already included in the target knowledge graph. It should be noted that if there is no relationship between any two nodes, the relationship between the two nodes can be determined to be empty. In this case, it is not necessary to save the empty relationship in the target knowledge graph. Then, the agent can save the identified and determined relationships in the target knowledge graph by calling the `save_concept_relation` tool, which can be called multiple times.
[0063] In addition, the relationships between user nodes and topic nodes, between topic nodes and fact concept nodes, and between topic nodes and preference information nodes in the target knowledge graph can be determined and stored in the target knowledge graph to enrich the information content of the knowledge graph, improve the reliability and accuracy of the target knowledge graph, and thus improve long-range conversation capabilities.
[0064] A knowledge graph construction method provided in some embodiments of this application may further include: Extract the relationships between user information and dialogue topics from the current dialogue record; the relationships between dialogue topics and factual concepts and user preference information; the relationships between factual concepts and user preference information; the relationships between factual concepts; and the relationships between user preference information. A knowledge graph can be constructed based on user information, dialogue topics, factual concepts, and user preference information, and may include: A knowledge graph is constructed based on user information, dialogue topics, factual concepts, user preference information, the relationship between user information and dialogue topics, the relationship between dialogue topics and factual concepts and user preference information, the relationship between factual concepts and user preference information, the relationship between factual concepts, and the relationship between user preference information.
[0065] In some embodiments of this application, while, before, or after extracting the dialogue topic, factual concepts, and user preference information from the current dialogue record, the association between user information and the dialogue topic, the association between the dialogue topic and the factual concepts, the association between the dialogue topic and the user preference information, the association between factual concepts and user preference information, the association between factual concepts, and the association between user preference information can also be extracted from the current dialogue record.
[0066] Building upon the above, constructing a knowledge graph based on user information, dialogue topics, factual concepts, and user preference information can specifically involve constructing a knowledge graph based on user information, dialogue topics, factual concepts, user preference information, the relationships between user information and dialogue topics, the relationships between dialogue topics and factual concepts, the relationships between dialogue topics and user preference information, the relationships between factual concepts, and the relationships between user preference information. This enriches the information content of the constructed knowledge graph, improves its reliability and accuracy, and thus enhances long-range conversation capabilities.
[0067] It should be noted that if there is no relationship between any two entities mentioned above, then the relationship between the two entities can be determined to be empty. In this case, it is not necessary to include the empty relationship in the knowledge graph.
[0068] This application provides a knowledge graph construction method in some embodiments, which determines whether a target knowledge graph corresponding to user information is stored in a data storage system, and may include: Determine whether the target knowledge graph is stored in the graph database; Storing knowledge graphs in a data storage system can include: Store the knowledge graph in a graph database.
[0069] In some embodiments of this application, the data storage system can be a graph database; for example, the data storage system can be the graph database Neo4j. Accordingly, determining whether the data storage system stores a target knowledge graph corresponding to the user information can specifically involve determining whether the graph database stores the target knowledge graph, and storing the knowledge graph in the data storage system can specifically involve storing the knowledge graph in the graph database.
[0070] By storing knowledge graphs in a graph database, the relationships between user information, dialogue topics, factual concepts, and user preference information can be intuitively mapped. This enables intelligent agents to efficiently handle complex relational queries and perform deep relational analysis, and also supports flexible dynamic expansion to adapt to the iterative updates of the knowledge graph.
[0071] As can be seen from the above embodiments, this application constructs a knowledge graph by extracting factual concepts and user preference information from dialogue records to achieve long-term memory storage of user context modules, thereby improving conversation capabilities. Moreover, the generated knowledge graph not only highly refines the original dialogue information but also maintains key details according to the dialogue topic dimension. This structured storage supports multi-granularity retrieval: the agent can perform deep reasoning around specific conceptual entities based on query complexity, or can efficiently summarize information around the dialogue topic.
[0072] Some embodiments of this application also provide a knowledge graph construction apparatus, see [link to relevant documentation]. Figure 3 This is a schematic diagram of the structure of a knowledge graph construction device provided in some embodiments of this application, which may include: The acquisition module 31 is used to acquire user information corresponding to the current dialogue record and extract dialogue topic, factual concepts and user preference information from the current dialogue record. The judgment module 32 is used to determine whether the data storage system stores a target knowledge graph corresponding to the user information; Module 33 is used to construct a knowledge graph based on user information, dialogue topic, factual concepts and user preference information if the target knowledge graph corresponding to user information is not stored in the data storage system, and then store the knowledge graph in the data storage system. The update module 34 is used to update the target knowledge graph in the data storage system according to the dialogue topic, factual concepts and user preference information if the data storage system stores a target knowledge graph corresponding to the user information.
[0073] A knowledge graph construction apparatus provided in some embodiments of this application may further include: The association module is used to associate the factual concepts, user preferences and dialogue topics with the dialogue topics after extracting the dialogue topics, factual concepts and user preference information from the current dialogue record. Update module 34 may include: The first judgment submodule is used to determine whether the target knowledge graph stores a topic node corresponding to the dialogue topic. The first construction submodule is used to construct the topic node corresponding to the dialogue topic on the target knowledge graph if the target knowledge graph does not store the topic node corresponding to the dialogue topic, and construct the fact concept node and preference information node associated with the topic node based on the fact concept and user preference information associated with the dialogue topic. The update submodule is used to update the fact concept nodes and preference information nodes associated with the topic nodes in the target knowledge graph, based on the fact concepts and user preference information associated with the dialogue topic, if the target knowledge graph stores topic nodes corresponding to the dialogue topic.
[0074] This application provides a knowledge graph construction apparatus in some embodiments, wherein the update submodule may include: The first deletion unit is used to delete the corresponding fact concept node in the target knowledge graph if the corresponding fact concept node in the target knowledge graph is invalid based on the fact concept. The first newly created unit is used to create corresponding fact concept nodes in the target knowledge graph if it is determined that corresponding fact concept nodes need to be created in the target knowledge graph based on fact concepts. The first deletion and creation unit is used to delete the corresponding fact concept node in the target knowledge graph if it is determined that the corresponding fact concept node in the target knowledge graph can be covered based on the fact concept, and to create the corresponding fact concept node in the target knowledge graph based on the fact concept.
[0075] This application provides a knowledge graph construction apparatus in some embodiments, wherein the update submodule may include: The second deletion unit is used to delete the corresponding preference information node in the target knowledge graph if it is determined that the corresponding preference information node in the target knowledge graph is invalid based on user preference information. The second newly created unit is used to create a corresponding preference information node in the target knowledge graph if it is determined from the user preference information that a corresponding preference information node needs to be created in the target knowledge graph. The second deletion and creation unit is used to delete the corresponding preference information node in the target knowledge graph if it is determined from the user preference information that the corresponding preference information node in the target knowledge graph can be covered, and to create the corresponding preference information node in the target knowledge graph based on the user preference information.
[0076] A knowledge graph construction apparatus provided in some embodiments of this application may further include: The determination module is used to determine the relationships between fact concept nodes and preference information nodes, the relationships between fact concept nodes, and the relationships between preference information nodes in the target knowledge graph. The storage module is used to store the relationships between fact concept nodes and preference information nodes, the relationships between fact concept nodes, and the relationships between preference information nodes in the target knowledge graph.
[0077] A knowledge graph construction apparatus provided in some embodiments of this application may further include: The extraction module is used to extract the relationships between user information and dialogue topics, the relationships between dialogue topics and factual concepts and user preference information, the relationships between factual concepts and user preference information, the relationships between factual concepts, and the relationships between user preference information from the current dialogue record; Module 33 may include: The second construction submodule is used to construct a knowledge graph based on user information, dialogue topics, factual concepts, user preference information, the relationship between user information and dialogue topics, the relationship between dialogue topics and factual concepts and user preference information, the relationship between factual concepts and user preference information, the relationship between factual concepts, and the relationship between user preference information.
[0078] Some embodiments of this application provide a knowledge graph construction apparatus, wherein the judgment module 32 may include: The second judgment submodule is used to determine whether the target knowledge graph is stored in the graph database. Module 33 may include: The third submodule is used to store the knowledge graph in a graph database.
[0079] Some embodiments of this application also provide an electronic device, see [link to relevant documentation] Figure 4 This is a schematic diagram of the structure of an electronic device provided in some embodiments of this application, which may include: Memory 41 is used to store computer programs; When the processor 42 executes the computer program stored in the memory 41, it can implement the steps of any of the above-described knowledge graph construction methods.
[0080] Some embodiments of this application also provide a computer-readable storage medium storing a computer program, which, when executed by a processor, can implement the steps of any of the knowledge graph construction methods described above.
[0081] For descriptions of relevant parts in the knowledge graph construction apparatus, electronic device, and computer-readable storage medium provided in some embodiments of this application, please refer to the detailed description of the corresponding parts in the knowledge graph construction method provided in some embodiments of this application, which will not be repeated here.
[0082] It should be noted that the logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be specifically implemented in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus, or device (such as a computer-based system, a processor-included system, or other system that can fetch and execute instructions from, an instruction execution system, apparatus, or device). For the purposes of this specification, "computer-readable medium" can be any means that can contain, store, communicate, propagate, or transmit programs for use by, or in conjunction with, an instruction execution system, apparatus, or device. More specific examples (a non-exhaustive list) of computer-readable media include: an electrical connection having one or more wires (electronic device), a portable computer disk drive (magnetic device), random access memory (RAM), read-only memory (ROM), erasable and editable read-only memory (EPROM or flash memory), fiber optic devices, and portable optical disc read-only memory (CDROM). Alternatively, the computer-readable medium may be paper or other suitable media on which the program can be printed, since the program can be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, interpreting, or otherwise processing as necessary, and then stored in a computer memory.
[0083] It should be understood that various parts of this application can be implemented using hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented using software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, it can be implemented using any one or a combination of the following techniques known in the art: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.
[0084] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of this application. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.
[0085] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of that feature. In the description of this application, "multiple" means at least two, such as two, three, etc., unless otherwise explicitly specified.
[0086] In this application, unless otherwise expressly specified and limited, the terms "installation," "connection," "joining," and "fixing," etc., should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral part; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; they can refer to the internal communication of two components or the interaction between two components, unless otherwise expressly limited. Those skilled in the art can understand the specific meaning of the above terms in this application according to the specific circumstances.
[0087] Although embodiments of this application have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting this application. Those skilled in the art can make changes, modifications, substitutions and variations to the above embodiments within the scope of this application.
Claims
1. A method for constructing a knowledge graph, characterized in that, include: Obtain user information corresponding to the current dialogue record, and extract dialogue topic, factual concepts, and user preference information from the current dialogue record; Determine whether the data storage system stores the target knowledge graph corresponding to the user information; If not, a knowledge graph is constructed based on the user information, the dialogue topic, the factual concepts, and the user preference information, and the knowledge graph is stored in the data storage system. If so, the target knowledge graph in the data storage system is updated based on the dialogue topic, the factual concept, and the user preference information.
2. The knowledge graph construction method according to claim 1, characterized in that, After extracting the conversation topic, factual concepts, and user preference information from the current conversation record, the process also includes: Associate the factual concepts, the user preference information, and the dialogue topic; Updating the target knowledge graph in the data storage system based on the dialogue topic, the factual concepts, and the user preference information includes: Determine whether the target knowledge graph stores a topic node corresponding to the dialogue topic; If not, then construct a topic node corresponding to the dialogue topic on the target knowledge graph, and construct a fact concept node and a preference information node associated with the topic node based on the fact concept associated with the dialogue topic and the user preference information. If so, the fact concept nodes and preference information nodes associated with the topic node in the target knowledge graph are updated based on the fact concepts and user preference information associated with the dialogue topic.
3. The knowledge graph construction method according to claim 2, characterized in that, Based on the factual concepts associated with the dialogue topic, the factual concept nodes in the target knowledge graph associated with the topic node are updated, including: If, based on the stated factual concept, the corresponding factual concept node in the target knowledge graph is determined to be invalid, then the corresponding factual concept node in the target knowledge graph is deleted. If it is determined based on the factual concept that a corresponding factual concept node needs to be newly created in the target knowledge graph, then a corresponding factual concept node is newly created in the target knowledge graph based on the factual concept. If it is determined that the corresponding fact concept node in the target knowledge graph can be covered based on the fact concept, then the corresponding fact concept node in the target knowledge graph is deleted, and a corresponding fact concept node is created in the target knowledge graph based on the fact concept.
4. The knowledge graph construction method according to claim 2, characterized in that, Based on the user preference information associated with the dialogue topic, the preference information nodes in the target knowledge graph associated with the topic node are updated, including: If it is determined that the corresponding preference information node in the target knowledge graph is invalid based on the user preference information, then the corresponding preference information node in the target knowledge graph is deleted. If it is determined based on the user preference information that a corresponding preference information node needs to be created in the target knowledge graph, then a corresponding preference information node is created in the target knowledge graph based on the user preference information. If it is determined based on the user preference information that the corresponding preference information node in the target knowledge graph can be covered, then the corresponding preference information node in the target knowledge graph is deleted, and a new corresponding preference information node is created in the target knowledge graph based on the user preference information.
5. The knowledge graph construction method according to any one of claims 1 to 4, characterized in that, Also includes: Determine the relationships between fact concept nodes and preference information nodes, the relationships between fact concept nodes, and the relationships between preference information nodes in the target knowledge graph; The relationships between fact concept nodes and preference information nodes, the relationships between fact concept nodes, and the relationships between preference information nodes are stored in the target knowledge graph.
6. The knowledge graph construction method according to claim 1, characterized in that, Also includes: Extract from the current dialogue record the relationships between the user information and the dialogue topic, the relationships between the dialogue topic and the factual concepts and the user preference information, the relationships between the factual concepts and the user preference information, the relationships between the factual concepts, and the relationships between the user preference information; Constructing a knowledge graph based on the user information, the dialogue topic, the factual concepts, and the user preference information includes: The knowledge graph is constructed based on the user information, the dialogue topic, the factual concepts, the user preference information, the relationship between the user information and the dialogue topic, the relationship between the dialogue topic and the factual concepts and the user preference information, the relationship between the factual concepts and the user preference information, the relationship between the factual concepts, and the relationship between the user preference information.
7. The knowledge graph construction method according to claim 1, characterized in that, Determining whether the data storage system stores a target knowledge graph corresponding to the user information includes: Determine whether the target knowledge graph is stored in the graph database; Storing the knowledge graph in the data storage system includes: The knowledge graph is stored in the graph database.
8. A knowledge graph construction device, characterized in that, include: The acquisition module is used to acquire user information corresponding to the current dialogue record, and extract dialogue topic, factual concepts and user preference information from the current dialogue record; The judgment module is used to determine whether the data storage system stores a target knowledge graph corresponding to the user information; A construction module is used to construct a knowledge graph based on the user information, the dialogue topic, the factual concept, and the user preference information if the target knowledge graph corresponding to the user information is not stored in the data storage system, and then store the knowledge graph in the data storage system. An update module is used to update the target knowledge graph in the data storage system according to the dialogue topic, the factual concept, and the user preference information if the data storage system stores the target knowledge graph corresponding to the user information.
9. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor, configured to implement the steps of the knowledge graph construction method as described in any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the knowledge graph construction method as described in any one of claims 1 to 7.