Question and answer method and device based on large language model and nonvolatile storage medium
By combining the knowledge graph and vector knowledge base, the problem of information forgetting in multiple rounds of long-context dialogues of large language models is solved, the consistency and accuracy of dialogue are achieved, the use of computing resources is optimized, and the user experience is significantly improved.
Patent Information
- Application Number
- CN202411312132.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-19
- Publication Date
- 2024-12-20
AI Technical Summary
Large language models are prone to forget previous information in multiple rounds of long-context dialogues, resulting in insufficient coherence and accuracy of dialogues and high consumption of computing resources. Previous technologies such as retrieval enhancement generation technology are insufficient context relevance and difficult information integration in long-conversation. .
By determining entity information and associated edges in the knowledge graph, updating associated edges to extend the knowledge subgraph, and converting problem text information into text feature vectors, searching knowledge entries with similarity matching in the vector knowledge base, combining knowledge graphs and vectors The knowledge base integrates information to generate answers.
It effectively avoids historical forgetting, improves the consistency and accuracy of dialogue, optimizes the use of computing resources, enhances the knowledge acquisition and application capabilities of dialogue systems, and significantly improves the user experience.
Smart Images

Figure CN119168068A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence, and more specifically, to a question-answering method and device based on a large language model, and a non-volatile storage medium. Background Art
[0002] With the rapid development of artificial intelligence technology, especially the rise of Large Language Models (LLM), multi-turn dialogue systems based on Natural Language Processing (NLP) have been widely used in many application scenarios, such as intelligent customer service, virtual assistants, and conversational robots. However, when processing multi-turn long-context dialogues, LLM often faces the problem of historical forgetting, which seriously affects the consistency of the dialogue and user experience.
[0003] Currently, most dialogue systems rely on pre-trained large language models, which are trained with a large amount of text data and have strong language understanding and generation capabilities. These models perform well in single-round dialogues, but often encounter the following problems in multi-round long-context dialogues: 1. Improper context management: LLM needs to maintain the context of the dialogue in each round of dialogue, but as the number of dialogue rounds increases, it is difficult for the model to effectively remember previous information, resulting in reduced dialogue continuity and logic. 2. Information forgetting: When processing long dialogues, LLM often forgets previous important information, causing gaps in the dialogue content or repeated inquiries. 3. Computational resource consumption: In order to maintain context information, all previous dialogue records must be entered in each round of dialogue, resulting in huge consumption of computing resources and reduced processing efficiency.
[0004] Retrieval-Augmented Generation (RAG) technology improves the knowledge acquisition and generation capabilities of language models by combining retrieval and generation. Before generating an answer, the RAG model first retrieves relevant information from the knowledge base, and then generates based on the retrieved content. Although RAG technology performs well in single-round dialogues and knowledge question-answering, it has the following limitations in multi-round long-context dialogues: 1. Insufficient context relevance: The RAG model mainly relies on retrieved instant information and lacks continuous tracking and management of long dialogue history, resulting in poor context coherence in multi-round dialogues. 2. Difficulty in information integration: In long dialogues, RAG requires multiple retrieval and generation, making it difficult to effectively integrate information from previous rounds, and prone to information fragmentation problems. 3. Real-time update challenges: RAG technology relies on the retrieval effect of an external knowledge base, and it is difficult to update and expand the knowledge base in real time.
[0005] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention
[0006] The embodiments of the present application provide a question-answering method and device based on a large language model, and a non-volatile storage medium, so as to at least solve the technical problem of insufficient accuracy of the answer information of the large language model due to historical forgetting in multiple rounds of long context conversations.
[0007] According to one aspect of an embodiment of the present application, a question-answering method based on a large language model is provided, comprising: receiving question text information input into a large language model; determining multiple entity information in the question text information, and determining association information between each entity information; determining a target node including the entity information and an associated edge corresponding to the target node in a knowledge graph; updating the associated edge according to the associated information, and performing expansion processing on the target node according to the updated associated edge to obtain an extended knowledge subgraph; converting the question text information into a text feature vector, and determining a target knowledge item in a vector knowledge base whose similarity with the text feature vector meets a preset condition; and determining an answer text information corresponding to the question text information according to the extended knowledge subgraph and the target knowledge item.
[0008] Optionally, based on the extended knowledge subgraph and the target knowledge item, the answer text information corresponding to the question text information is determined, including: using the extended knowledge subgraph to perform semantic summarization processing on the question text information to obtain first information whose correlation index with the question text information meets a first preset condition; performing semantic filtering processing on the target knowledge item to obtain second information whose correlation index with the question text information meets a second preset condition; integrating the first information and the second information to obtain the answer text information.
[0009] Optionally, semantic filtering is performed on the target knowledge item to obtain second information whose correlation index with the question text information satisfies a second preset condition, including: based on the first technical field, semantic filtering is performed on the target knowledge item to obtain second information whose correlation index with the question text information satisfies a second preset condition.
[0010] Optionally, after integrating the first information and the second information to obtain answer text information, the method also includes: determining whether the entity information in the answer text information is consistent with the entity information in the extended knowledge subgraph, and when the entity information in the answer text information is inconsistent with the entity information in the extended knowledge subgraph, executing the following steps: using the extended knowledge subgraph, semantically summarizing the question text information to obtain the first information; based on the second technical field, semantically filtering the target knowledge items to obtain third information whose correlation index with the question text information meets the second preset condition, wherein the similarity index between the second technical field and the first technical field meets the preset requirements; integrating the first information and the third information to regenerate the answer text information.
[0011] Optionally, receiving question text information input into a large language model includes: receiving the i-th question text information in the i-th round of dialogue, where i is a positive integer; determining multiple entity information in the question text information, and determining the association information between each entity information, including: determining multiple i-th entity information in the i-th question text information, and determining the i-th association information between each i-th entity information; determining a target node including entity information and an association edge corresponding to the target node in the knowledge graph, including: determining the i-th target node including entity information and the i-th association edge corresponding to the i-th target node in the i-th knowledge graph; updating the association edge according to the association information, According to the updated associated edges, the target node is expanded to obtain an extended knowledge subgraph, including: according to the i-th associated information, the i-th associated edge is updated, and according to the updated associated edge, the target node is expanded to obtain the i-th extended knowledge subgraph; the question text information is converted into a text feature vector, and the target knowledge item whose similarity with the text feature vector meets the preset conditions is determined in the vector knowledge base, including: converting the i-th question text information into a text feature vector, and determining the i-th target knowledge item whose similarity with the text feature vector meets the preset conditions in the i-th vector knowledge base; determining the question text information according to the extended knowledge subgraph and the target knowledge item. The method further comprises: integrating and processing the extended knowledge subgraph and the target knowledge item to obtain the i-th answer text information; displaying the i-th answer text information, and determining that the i-th round of dialogue is over; after determining that the i-th round of dialogue is over, the method further comprises: updating the i-th knowledge graph and the i-th vector knowledge base according to the i-th answer text information to obtain the i+1-th knowledge graph and the i+1-th vector knowledge base; receiving the i+1-th question text information in the i+1-th round of dialogue; determining multiple i+1-th entity information in the i+1-th question text information, and determining the i+1-th association information between each i+1-th entity information; in the i+1-th knowledge graph The i+1th target node including entity information and the i+1th associated edge corresponding to the i+1th target node are determined in the spectrum; according to the i+1th associated information, the i+1th associated edge is updated, and according to the updated associated edge, the target node is expanded to obtain the i+1th extended knowledge subgraph; the i+1th question text information is converted into a text feature vector, and the i+1th target knowledge item whose similarity with the text feature vector meets the preset conditions is determined in the i+1th vector knowledge base; the extended knowledge subgraph and the target knowledge item are integrated to obtain the i+1th answer text information; the i+1th answer text information is displayed, and the i+1th round of dialogue is determined to be over.
[0012] Optionally, determining a target knowledge item whose similarity with the text feature vector meets preset conditions in the vector knowledge base includes: in the vector knowledge base, determining the knowledge item with the largest Euclidean distance with the text feature vector as the target knowledge item, or determining the knowledge item with the largest cosine similarity with the text feature vector as the target knowledge item.
[0013] Optionally, multiple entity information in the question text information is determined, and the association information between each entity information is determined, including: performing word segmentation processing on the question text information to obtain first text information; performing part-of-speech tagging processing on the first text information to obtain second text information; performing named entity recognition processing on the second text information to obtain multiple entity information in the question text information and the association information between each entity information.
[0014] According to another aspect of the embodiment of the present application, a question-answering device based on a large language model is also provided, including: a receiving module for receiving question text information input into the large language model; a first determination module for determining multiple entity information in the question text information, and determining the association information between each entity information; a second determination module for determining a target node including the entity information and an associated edge corresponding to the target node in the knowledge graph; an updating module for updating the associated edge according to the associated information, and expanding the target node according to the updated associated edge to obtain an extended knowledge subgraph; a third determination module for converting the question text information into a text feature vector, and determining a target knowledge item in the vector knowledge base whose similarity with the text feature vector meets a preset condition; and a fourth determination module for determining the answer text information corresponding to the question text information according to the extended knowledge subgraph and the target knowledge item.
[0015] According to another aspect of the embodiments of the present application, a non-volatile storage medium is also provided, the storage medium includes a stored program, wherein when the program is running, the device where the storage medium is located is controlled to execute the above question-answering method based on the large language model.
[0016] According to another aspect of the embodiments of the present application, there is also provided an electronic device, including: a memory and a processor, the processor being used to run a program stored in the memory, wherein the above question-answering method based on a large language model is executed when the program is run.
[0017] According to yet another aspect of the embodiments of the present application, a computer program is further provided, wherein when the computer program is executed by a processor, the above question-answering method based on a large language model is implemented.
[0018] According to another aspect of the embodiments of the present application, a computer program product is also provided, the computer program product comprising a non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the above-mentioned question-answering method based on a large language model is implemented.
[0019] In an embodiment of the present application, the following steps are adopted: receiving question text information input into a large language model; determining multiple entity information in the question text information, and determining association information between each entity information; determining a target node including the entity information and an associated edge corresponding to the target node in the knowledge graph; updating the associated edge according to the associated information, and performing expansion processing on the target node according to the updated associated edge to obtain an extended knowledge subgraph; converting the question text information into a text feature vector, and determining a target knowledge item whose similarity with the text feature vector meets a preset condition in a vector knowledge base; and determining the answer text information corresponding to the question text information according to the extended knowledge subgraph and the target knowledge item. By integrating the knowledge graph and the vector knowledge base, the ability of the large language model in processing long context dialogues is enhanced, and the purpose of avoiding the historical forgetting of the large language model in multiple rounds of long context dialogues is achieved, thereby achieving the technical effect of improving the coherence, consistency and accuracy of the dialogue, and further solving the technical problem of insufficient accuracy of the answer information of the large language model caused by the historical forgetting of the large language model in multiple rounds of long context dialogues. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0021] Figure 1 is a flow chart of a question-answering method based on a large language model according to an embodiment of the present application;
[0022] Figure 2 is a flowchart of another question-answering method based on a large language model according to an embodiment of the present application;
[0023] Figure 3 is a flowchart of another question-answering method based on a large language model according to an embodiment of the present application;
[0024] Figure 4 is a structural diagram of a question-answering device based on a large language model according to an embodiment of the present application;
[0025] Figure 5 It is a hardware structure block diagram of a computer terminal according to an embodiment of the present application for a question-answering method based on a large language model. DETAILED DESCRIPTION
[0026] 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 should fall within the scope of protection of the present application.
[0027] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising 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.
[0028] According to an embodiment of the present application, a method embodiment of a question-answering method based on a large language model is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0029] Figure 1 is a flowchart of a question-answering method based on a large language model according to an embodiment of the present application, such as Figure 1 As shown, the method comprises the following steps:
[0030] Step S101, receiving question text information input into a large language model.
[0031] The large language model can accept a variety of question texts. Here are some common types: 1. Knowledge. Science: "What are the basic principles of quantum mechanics?" "What is the process of photosynthesis?" History: "What was the main reason for Qin Shihuang to unify the six kingdoms?" "What are the profound impacts of the Industrial Revolution on society?" Geography: "What is the longest river in the world? What are the characteristics of its basin?" 2. Technology. Computer: "How to optimize the running efficiency of this code?" "What are the differences and connections between different programming languages?" Engineering: "What key factors need to be considered in bridge design?" 3. Life. Health: "How to relieve headaches caused by stress?" "What foods help improve sleep quality?" Leisure activities: "What outdoor activities are suitable for families and children?" 4. Creativity and writing. Creative inspiration: "Give me some inspiration for science fiction." Copywriting: "Write an infectious product promotion copy."
[0032] Step S102, determining multiple entity information in the question text information, and determining the association information between each entity information.
[0033] In the large language model, an entity is a noun or noun phrase with a specific meaning in the text. An entity can refer to an object, concept, place, person, organization, etc. in the real world. The types of entities include but are not limited to: 1. Name: refers to a specific individual, such as "Einstein" and "Marie Curie". 2. Place: refers to a specific geographical location, such as "New York" and "The Great Wall". 3. Organization: refers to a company, etc. 4. Time: refers to a specific time point or time period, such as "2024" and "three o'clock in the afternoon". 5. Value: refers to quantity, percentage, etc., such as "100" and "50%". 6. Date: refers to a specific date, such as "May 21, 2024". 7. Product: refers to a specific product or service, such as "iPhone" and "Windows operating system".
[0034] Entities are objects, concepts or events in the real world, while relations are connections between entities, such as "belongs to", "is located in", etc. These relations can be concrete or abstract, and can be extracted and analyzed by different technical means.
[0035] Step S103, determining the target node including entity information and the associated edges corresponding to the target node in the knowledge graph.
[0036] It should be noted that Retrieval-Augmented Generation (RAG) refers to enhancing the capabilities of LLM by plugging in other data sources in addition to the knowledge that LLM has learned itself, including external vector databases, external knowledge graphs, document data, WEB data, etc. The above knowledge graph is the external knowledge graph in RAG.
[0037] Among them, the knowledge graph is a structured way of representing knowledge. It consists of nodes and edges. Nodes usually represent entities (such as people, places, things, concepts, etc.), and edges represent the relationship between entities (such as parent-child relationship, causal relationship, inclusion relationship, etc.). For example, in a historical knowledge graph, "Qin Shi Huang" and "Qin Dynasty" are two nodes, which can be connected by a relationship edge such as "establishment". In LLM, the knowledge graph can enhance the factual knowledge of the model and improve its performance in various natural language processing tasks, such as question answering, machine translation, and text generation.
[0038] Step S104, updating the associated edges according to the associated information, and performing expansion processing on the target node according to the updated associated edges to obtain an expanded knowledge subgraph.
[0039] The knowledge subgraph is a part of the preset knowledge graph in the large language model. The extended knowledge subgraph is to further add new nodes (entities), edges (relationships) and related attribute information on the basis of the existing knowledge subgraph, so that the large language model can learn the content input by the user and then update the knowledge graph.
[0040] Step S105, converting the question text information into a text feature vector, and determining in the vector knowledge base a target knowledge item whose similarity with the text feature vector meets a preset condition.
[0041] It should be noted that the above-mentioned vector knowledge base is the external vector knowledge base in RAG. The vector knowledge base is a way to store and manage knowledge in the form of vectors. In the large language model, words, sentences, paragraphs and other elements in the text are mapped into high-dimensional vectors through specific mathematical models (such as the word vector generation mechanism in the Transformer architecture). These vectors can capture the semantic information of text elements, and texts with similar semantics are close in position in the vector space.
[0042] The role of the vector knowledge base in RAG is as follows: 1. When receiving a user's query, the large language model converts the query statement into a vector, and then searches for vectors with high similarity in the vector knowledge base, so as to quickly obtain relevant knowledge. For example, the user asks about "the application of artificial intelligence in the medical field". After the model converts this question into a vector, it finds relevant knowledge vectors about medical image analysis, disease diagnosis assistance, etc. in the knowledge base. 2. Help the model better understand the semantics and context of the text. Through the semantic vector information in the vector knowledge base, the model can grasp the meaning of the input text more accurately, thereby generating more accurate and logical responses. 3. When new knowledge is added, the new text can be converted into a vector and integrated into the existing vector knowledge base.
[0043] Step S106: Determine answer text information corresponding to the question text information according to the extended knowledge subgraph and the target knowledge item.
[0044] It can be understood that by combining the extended knowledge subgraph and the target knowledge item, the answer text information can be obtained.
[0045] According to the above steps, the question text information in the input large language model is received; multiple entity information in the question text information is determined, and the association information between each entity information is determined; the target node including the entity information and the associated edge corresponding to the target node are determined in the knowledge graph; according to the associated information, the associated edge is updated, and according to the updated associated edge, the target node is extended to obtain an extended knowledge subgraph; the question text information is converted into a text feature vector, and the target knowledge item whose similarity with the text feature vector meets the preset conditions is determined in the vector knowledge base; according to the extended knowledge subgraph and the target knowledge item, the answer text information corresponding to the question text information is determined, and the ability of the large language model in processing long context dialogues is enhanced by fusing the knowledge graph and the vector knowledge base, so as to achieve the purpose of avoiding the historical forgetting situation of the large language model in multiple rounds of long context dialogues, thereby achieving the technical effect of improving the coherence, consistency and accuracy of the dialogue.
[0046] The following Figure 1 The steps shown are exemplary and explanatory.
[0047] According to some alternative embodiments of the present application, to determine the response text information corresponding to the question text information based on the extended knowledge subgraph and the target knowledge entry, the following method can be adopted: Use the extended knowledge subgraph to perform semantic summarization processing on the question text information to obtain the first information whose relevance index to the question text information meets the first preset condition; perform semantic filtering processing on the target knowledge entry to obtain the second information whose relevance index to the question text information meets the second preset condition; integrate the first information and the second information to obtain the response text information.
[0048] Using the extended knowledge subgraph to perform semantic summarization processing on the question text information, that is, in the extended knowledge subgraph, perform semantic summarization processing on the question text information. For example, the following method can be used to perform semantic summarization processing on the question text information in the extended knowledge subgraph: 1. Identify the key entities from the text. These entities may be names of people, locations, organizations, or other important noun phrases. These entities usually have corresponding nodes in the knowledge graph. 2. Determine the relationships between the entities identified in the text. These relationships exist in the form of edges in the knowledge graph and help to understand the semantic connections between the entities. 3. Use the structured information in the knowledge graph to perform context analysis on the entities and relationships in the text to obtain a deeper semantic understanding. 4. Integrate the information extracted from the text with the existing knowledge in the knowledge graph to fill in the information gaps and enhance the comprehensiveness of the summary. 5. Based on the understanding of the entities, relationships, and context, generate a concise, coherent summary that contains the core meaning of the original text.
[0049] Semantic filtering aims to screen out specific information or exclude irrelevant content from a large amount of text data. In NLP, the purpose of text filtering is to remove noise, interference, and invalid text in order to better perform subsequent text analysis and processing. Common text filtering methods include stop word filtering, part-of-speech filtering, and sensitive word filtering, etc. Among them, stop word filtering includes removing words that frequently appear in the text but have little impact on the meaning of the text, such as "de", "shi", "he", etc., to improve the accuracy of text analysis. Part-of-speech filtering includes screening out specific types of words, such as nouns, verbs, adjectives, etc., to better perform semantic analysis and grammatical processing. Sensitive word filtering includes identifying and filtering out sensitive or inappropriate words in scenarios such as social media and comment systems.
[0050] Through the above steps, determine the information with the highest relevance to the question text information in the extended knowledge subgraph and the target knowledge entry, and use it as the response text information.
[0051] Furthermore, semantic filtering is performed on the target knowledge items to obtain second information whose correlation index with the question text information satisfies the second preset condition. This can be achieved by the following method: based on the first technical field, semantic filtering is performed on the target knowledge items to obtain second information whose correlation index with the question text information satisfies the second preset condition.
[0052] Furthermore, after the first information and the second information are integrated and processed to obtain the answer text information, the following steps can also be performed: determine whether the entity information in the answer text information is consistent with the entity information in the extended knowledge subgraph. When the entity information in the answer text information is inconsistent with the entity information in the extended knowledge subgraph, perform the following steps: use the extended knowledge subgraph to semantically summarize the question text information to obtain the first information; based on the second technical field, perform semantic filtering on the target knowledge items to obtain the third information whose correlation index with the question text information meets the second preset condition, wherein the similarity index between the second technical field and the first technical field meets the preset requirements; integrate the first information and the third information to regenerate the answer text information.
[0053] It is understandable that if the entity information in the answer text information is inconsistent with the entity information in the extended knowledge subgraph, it means that the target knowledge item may be inaccurate. At this time, you can switch to a technical field that is completely different or similar to the first technical field and continue to perform semantic filtering on the target knowledge item.
[0054] According to some other optional embodiments of the present application, the question-answering method based on the large language model can also be implemented by the following method:
[0055] Receive the i-th question text information in the i-th round of dialogue, where i is a positive integer. Determine multiple i-th entity information in the i-th question text information, and determine the i-th association information between each i-th entity information. Determine the i-th target node including the entity information and the i-th association edge corresponding to the i-th target node in the i-th knowledge graph. According to the i-th association information, update the i-th association edge, and according to the updated association edge, expand the target node to obtain the i-th extended knowledge subgraph. Convert the i-th question text information into a text feature vector, and determine the i-th target knowledge item whose similarity with the text feature vector meets the preset conditions in the i-th vector knowledge base.
[0056] The extended knowledge subgraph and the target knowledge item are integrated and processed to obtain the i-th answer text information; the i-th answer text information is displayed, and the i-th round of dialogue is determined to be over.
[0057] After determining that the i-th round of dialogue is over, the following steps are performed: according to the i-th answer text information, the i-th knowledge graph and the i-th vector knowledge base are updated to obtain the i+1-th knowledge graph and the i+1-th vector knowledge base; the i+1-th question text information in the i+1-th round of dialogue is received; multiple i+1-th entity information in the i+1-th question text information are determined, and the i+1-th association information between each i+1-th entity information is determined; in the i+1-th knowledge graph, the i+1-th target node including the entity information and the i+1-th target node corresponding to the i+1-th target node are determined. +1 associated edge; according to the i+1th associated information, update the i+1th associated edge, and according to the updated associated edge, expand the target node to obtain the i+1th extended knowledge subgraph; convert the i+1th question text information into a text feature vector, and determine the i+1th target knowledge item whose similarity with the text feature vector meets the preset conditions in the i+1th vector knowledge base; integrate the extended knowledge subgraph and the target knowledge item to obtain the i+1th answer text information; display the i+1th answer text information, and determine that the i+1th round of dialogue is over.
[0058] For example, the first question text information in the first round of dialogue is received. Multiple first entity information in the first question text information is determined, and the first association information between each first entity information is determined. The first target node including the entity information and the first association edge corresponding to the first target node are determined in the first knowledge graph. According to the first association information, the first association edge is updated, and according to the updated association edge, the target node is expanded to obtain the first extended knowledge subgraph. The first question text information is converted into a text feature vector, and the first target knowledge item whose similarity with the text feature vector meets the preset conditions is determined in the first vector knowledge base. The extended knowledge subgraph and the target knowledge item are integrated to obtain the first answer text information; the first answer text information is displayed, and the end of the first round of dialogue is determined.
[0059] After determining that the first round of dialogue is over, the first knowledge graph and the first vector knowledge base are updated according to the first answer text information to obtain the second knowledge graph and the second vector knowledge base.
[0060] Furthermore, the second question text information in the second round of dialogue is received; multiple second entity information in the second question text information is determined, and the second association information between each second entity information is determined; the second target node including the entity information and the second association edge corresponding to the second target node are determined in the second knowledge graph; according to the second association information, the second association edge is updated, and according to the updated association edge, the target node is expanded to obtain a second extended knowledge subgraph; the second question text information is converted into a text feature vector, and the second target knowledge item whose similarity with the text feature vector meets the preset conditions is determined in the second vector knowledge base; the extended knowledge subgraph and the target knowledge item are integrated to obtain the second answer text information; the second answer text information is displayed, and the end of the second round of dialogue is determined.
[0061] After determining that the second round of dialogue is over, the second knowledge graph and the second vector knowledge base are updated according to the second answer text information to obtain the third knowledge graph and the third vector knowledge base.
[0062] In summary, this process is repeated until the last round of dialogue ends. Assuming there are 10 rounds of dialogue in total, after the 9th round of dialogue ends, the 9th knowledge graph and the 9th vector knowledge base are updated according to the 9th answer text information to obtain the 10th knowledge graph and the 10th vector knowledge base. Then, the following steps are performed: receiving the 10th question text information in the 10th round of dialogue; determining multiple 10th entity information in the 10th question text information, and determining the 10th association information between each 10th entity information; determining the 10th target node including the entity information and the 10th association edge corresponding to the 10th target node in the 10th knowledge graph; updating the 10th association edge according to the 10th association information, and expanding the target node according to the updated association edge to obtain the 10th extended knowledge subgraph; converting the 10th question text information into a text feature vector, and determining the 10th target knowledge item whose similarity with the text feature vector meets the preset conditions in the 10th vector knowledge base; integrating the extended knowledge subgraph and the target knowledge item to obtain the 10th answer text information; displaying the 10th answer text information, and determining the end of the 10th round of dialogue.
[0063] In some optional embodiments of the present application, determining in a vector knowledge base a target knowledge item whose similarity with a text feature vector satisfies a preset condition can be achieved by the following method: in the vector knowledge base, determining the knowledge item with the largest Euclidean distance with the text feature vector as the target knowledge item, or determining the knowledge item with the largest cosine similarity with the text feature vector as the target knowledge item.
[0064] Among them, Euclidean distance is the most intuitive distance metric, which measures the straight-line distance between two points in multidimensional space. In two-dimensional or three-dimensional space, this is equivalent to using the Pythagorean theorem to calculate the distance between two points. The same concept applies to higher-dimensional spaces. When the absolute numerical difference of the data needs to be considered, such as continuous data such as house prices and income, Euclidean distance can be used to calculate similarity. Cosine similarity measures the degree of similarity between two vectors in direction, rather than their difference in size (or length). It is obtained by calculating the cosine value of the angle between the two vectors. The range of cosine values is -1 to 1, where 1 means that the two vectors are completely similar (ie, the same direction), -1 means that the two vectors are completely opposite, and 0 means that the two vectors are orthogonal (ie, perpendicular). When you need to evaluate the similarity of two documents in terms of topic, you can use TF-IDF vectors to calculate their cosine similarity.
[0065] As some optional embodiments of the present application, determining multiple entity information in the question text information and determining the association information between each entity information can be achieved by the following method: performing word segmentation processing on the question text information to obtain first text information; performing part-of-speech tagging processing on the first text information to obtain second text information; performing named entity recognition processing on the second text information to obtain multiple entity information in the question text information and the association information between each entity information.
[0066] The purpose of part-of-speech tagging is to assign a part-of-speech label to each word in the text, such as noun, verb, adjective, etc. This process is crucial to understanding the grammatical structure and semantic information of a sentence, and is a preprocessing step for many advanced NLP tasks such as syntactic analysis, information extraction, and machine translation. Part-of-speech tagging methods include but are not limited to: 1. Relying on rules formulated by linguistic experts, these rules are usually based on features such as affixes, prefixes and suffixes, and word morphology to determine the part of speech. 2. Using a large-scale annotated corpus, training the model through machine learning algorithms (such as hidden Markov model HMM, conditional random field CRF, etc.) to automatically learn the rules of part-of-speech tagging. 3. Using deep learning models for part-of-speech tagging, deep learning models include recurrent neural networks (RNN), long short-term memory networks (LSTM), bidirectional long short-term memory networks (BiLSTM), and convolutional neural networks (CNN).
[0067] Named entity recognition is a basic task in natural language processing. Named entity recognition aims to identify entities with specific meanings from text, such as names of people, places, and organizations, and classify them into corresponding entity types.
[0068] In summary, by introducing knowledge graphs and vector knowledge bases, this application can greatly enhance the knowledge acquisition and application capabilities of the system. The knowledge graph provides structured knowledge representation, and the vector knowledge base provides efficient knowledge retrieval. The combination of the two enables the system to better understand and generate context-related content, thereby improving the quality of conversations and user satisfaction. When processing long-context conversations, traditional LLMs need to take all previous conversation records as input, which consumes a lot of computing resources. Through the combination of knowledge graphs and vector knowledge bases, this application can intelligently manage and retrieve historical conversation information, thereby reducing the consumption of computing resources and improving the response speed and processing efficiency of the system.
[0069] The combination of knowledge graph and vector knowledge base enables the system to not only store and manage knowledge statically, but also dynamically update and expand the knowledge base. Especially when processing dynamic conversation information generated by users, the system can update the knowledge graph and vector knowledge base in a timely manner to ensure that the system always has the latest knowledge and information.
[0070] By solving the problem of historical forgetting, improving the coherence and consistency of the conversation, enhancing the system's knowledge acquisition and application capabilities, and optimizing the use of computing resources, the ultimate goal of this application is to significantly improve the user experience. Users can have more natural, smooth and efficient multi-round conversations with the system and get more accurate and useful responses.
[0071] Figure 2 and Figure 3 is a flowchart of another question-answering method based on a large language model according to an embodiment of the present application. Figure 2 and Figure 3 , a detailed explanation of the question-answering method based on a large language model.
[0072] It should be noted that the overall architecture of the system on which this method is based includes the following modules: 1. Large language model module: responsible for natural language understanding and generation, parsing user input and generating responses. 2. Knowledge graph module: responsible for building and maintaining knowledge graphs, managing structured knowledge representations. 3. Vector knowledge base module: responsible for knowledge vectorization and efficient retrieval, providing semantic-based knowledge matching. 4. Context management module: responsible for managing and dynamically updating context information of multiple rounds of dialogue. 5. Fusion engine: responsible for combining the information of knowledge graphs and vector knowledge bases during the dialogue process to enhance the generation capabilities of large language models.
[0073] Step S201: Process the user input content.
[0074] Step S2011, obtaining user input content; the user inputs text, such as questions or requests, through the system interface.
[0075] The system receives user input and passes it to the context management module.
[0076] Step S2012, pre-process the input content: perform word segmentation, part-of-speech tagging and named entity recognition (NER) on the user input text, extract key entities and relationships in the input, and preliminarily analyze the user's intention.
[0077] Among them, NER is a natural language processing task used to identify and classify entities from text. Classified entities are noun phrases of specific categories, such as names, places, organizations, times, dates, etc. The goal of NER is to understand the types of these entities in the text and the relationships between them. The steps of NER include: 1. Preprocessing: Clean the input text, such as removing punctuation, stop words, etc., so that it is easier to identify entities in subsequent steps. 2. Word segmentation: Split the text into words or phrases for further analysis. 3. Feature extraction: Extract features from the text that help identify entities, such as part of speech, morphology, synonyms, etc. 4. Entity recognition: Use machine learning algorithms (such as conditional random fields, recurrent neural networks, etc.) to classify and identify entities in the text. This usually includes determining the boundaries and types of entities. 5. Post-processing: Correct and integrate the identified entities to improve the accuracy of recognition.
[0078] Step S202: perform knowledge retrieval in the knowledge graph and vector knowledge base.
[0079] Step S2021, preliminary search of the knowledge graph: perform preliminary search in the knowledge graph based on the key entities and relationships in the preprocessing results. The knowledge graph module locates the entity nodes related to the user input and their directly associated relationship edges to form a preliminary knowledge subgraph.
[0080] Step S2022, vector knowledge base enhanced retrieval: vectorize the user input text, use the vector knowledge base to perform similarity calculation, retrieve the vector representation that is most semantically relevant to the input text, and return the corresponding knowledge entry.
[0081] Step S2023, knowledge graph context expansion: further expand the context based on the key entities and relationships in the preliminary knowledge subgraph. Perform deep expansion along the relationship edges in the knowledge graph to obtain more relevant entities and relationships to form an extended knowledge subgraph. Perform semantic filtering on the extended knowledge subgraph to retain the most relevant information to the current conversation context.
[0082] Step S203: context management and integration.
[0083] Step S2031, context recording: The context management module records the user input, system response and related knowledge information of the current round, and saves the key nodes and edge information in the extended knowledge subgraph as the context of the current dialogue.
[0084] Step S2032, dynamic context update: After each round of dialogue, the context management module updates the dialogue history record and dynamically adjusts and optimizes the context subgraph in the knowledge graph based on the newly acquired knowledge.
[0085] Step S2033, context summary and extraction: After each round of dialogue, the system summarizes the current context, extracts key information and updates the context overview. Using the relationship network in the knowledge graph, the long context is semantically summarized, the core information and intent are refined, and a structured context summary is formed.
[0086] Step S204: Generate response information.
[0087] Step S2041, integrating the knowledge graph and the vector knowledge base information: integrating the retrieved knowledge graph and the vector knowledge base information to construct a rich knowledge background. The LLM module combines the context summary provided by the context management module to generate a preliminary response text.
[0088] Step S2042, response optimization: The fusion engine optimizes the initial response to ensure high consistency with the knowledge graph and context information. Check whether the entities and relationships in the response are consistent with the information in the knowledge graph, and make necessary adjustments and supplements.
[0089] Step S2043, generate the final response: ensure that the generated response contains necessary context information, is coherent and logical. The system outputs the final optimized response text.
[0090] Step S205: output response information and update context information.
[0091] Step S2051, outputting response information: the system sends the final response text to the user. The user interface displays the response result and waits for the user's next input.
[0092] Step S2052, context persistence: The context management module persists the complete context information of the current conversation, updates the knowledge graph and vector knowledge base, and maintains the traceability of the conversation history and the dynamic expansion capability of the knowledge graph.
[0093] In summary, the current LLM is prone to forgetting key information from previous rounds when processing multi-round long-context conversations, resulting in gaps in the conversation or information duplication. This application can effectively record and manage the historical information of the conversation by integrating the knowledge graph and the vector knowledge base, thereby avoiding the loss and forgetting of information and ensuring the coherence and consistency of the conversation content.
[0094] In multi-round conversations, the coherence and consistency of the conversation are important indicators for measuring the quality of the conversation. This application can accurately maintain and reference previous conversation information in each round of conversation through the semantic association of the knowledge graph and the efficient retrieval of the vector knowledge base, thereby improving the coherence and consistency of the conversation, allowing the system to communicate more naturally and humanely.
[0095] Exemplarily, the following specific embodiments are used to demonstrate how to integrate knowledge graphs and vector knowledge bases in practical applications to solve the problem of historical forgetting in LLM multi-round long context dialogues.
[0096] Example 1: A question-answering method based on a large language model applied to an intelligent customer service system.
[0097] Scenario description: A user asks questions about the product return process through the online customer service system. Since the return process involves multiple steps, the user needs to gradually understand the details in multiple rounds of dialogue.
[0098] This example specifically includes the following steps.
[0099] 1. User input processing. User input: "How do I return a product?" The system receives the input and pre-processes it, identifying the keyword "return".
[0100] 2. Knowledge retrieval based on knowledge graph and vector knowledge base.
[0101] Preliminary search of the knowledge graph: The system searches for entities and relationships related to "return" in the knowledge graph, and finds nodes and associated edges such as "return process" and "return policy".
[0102] Vector knowledge base enhanced retrieval: vectorize user input and retrieve highly similar knowledge items related to "return" in the vector knowledge base, such as "return steps", "return conditions", etc.
[0103] 3. Context management and integration. Context recording: Record the input of the current conversation and the retrieved knowledge graph nodes and vector knowledge base entries. Context dynamic update: Dynamically update the "return" related subgraph in the knowledge graph, and expand the entities and relationships related to the "return process". Context summarization and extraction: Extract the core information about the "return process" in the current conversation to form a structured context summary.
[0104] 4. Response generation: Fusion of knowledge graph and vector knowledge base information: Integrate the nodes and relationships of the “return process” in the knowledge graph with the relevant knowledge items in the vector knowledge base. LLM generates a preliminary response, including the key steps of the “return process”.
[0105] Response optimization: The fusion engine optimizes the initial response to ensure consistency with the "Return Policy" in the knowledge graph.
[0106] Generate final response: The final response is: "The return process includes the following steps: (1) Log in to your account; (2) Enter the order page; (3) Select the return item; (4) Submit the return application."
[0107] 5. Response output and context update. The system outputs the final response, and the user obtains detailed return process information. The context management module persists the context information of the current conversation and updates the "return process" subgraph in the knowledge graph.
[0108] Example 1 shows the application of knowledge graphs and vector knowledge bases in processing multi-round long-context conversations. The system can continuously track and manage the conversation context to ensure that users receive coherent and accurate information in each round of conversation.
[0109] Example 2: A question-answering method based on a large language model applied to a virtual assistant system.
[0110] Scenario description: The user has a daily conversation with the virtual assistant, asking about the recent weather and recommended outdoor activities.
[0111] This example specifically includes the following steps.
[0112] 1. User input processing. User input: "What is the weather like this weekend?" The system receives the input and pre-processes it, identifying the keywords "this weekend" and "weather".
[0113] 2. Knowledge retrieval of knowledge graph and vector knowledge base. Preliminary retrieval of knowledge graph: Retrieve entities and relationships related to "weather" in the knowledge graph, and find nodes and associated edges such as "weather forecast" and "date". Enhanced retrieval of vector knowledge base: Vectorize user input and retrieve high-similarity knowledge items related to "weather forecast".
[0114] 3. Context management and integration. Context recording: Record the input of the current conversation and the retrieved knowledge graph nodes and vector knowledge base entries. Context dynamic update: Dynamically update the "weather forecast" subgraph in the knowledge graph and expand the entities and relationships related to "this weekend's weather". Context summarization and extraction: Extract the core information about "this weekend's weather" in the current conversation to form a structured context summary.
[0115] 4. Response generation. Fusion of knowledge graph and vector knowledge base information: Integrate the nodes and relationships of “weather forecast” in the knowledge graph with the relevant knowledge items in the vector knowledge base. LLM generates a preliminary response, which contains the key information of “weather this weekend”.
[0116] Response optimization: The fusion engine optimizes the initial response to ensure consistency with the "weather forecast" information in the knowledge graph.
[0117] Generate Final Response: The final response is: "This weekend's weather forecast shows that it will be cloudy with light rain on Saturday and sunny on Sunday. Outdoor activities are recommended on Sunday."
[0118] 5. Response output and context update. The system outputs the final response, and the user obtains detailed weather forecast information and activity recommendations. The context management module persists the context information of the current conversation and updates the "weather forecast" subgraph in the knowledge graph.
[0119] Example 2 demonstrates the advantages of knowledge graphs in dynamic updating and expansion. The system can not only provide accurate weather forecast information, but also give reasonable activity suggestions based on the context to improve user experience.
[0120] Example 3, a question-answering method based on a large language model applied to an educational tutoring system.
[0121] Scenario description: Students learn and solve math problems through the educational tutoring system, and conduct multiple rounds of inquiries and discussions on a difficult problem.
[0122] 1. User input processing. The student inputs: "How do I solve this quadratic equation?" The system receives the input and pre-processes it, identifying the keywords "quadratic equation" and "solution".
[0123] 2. Knowledge retrieval of knowledge graph and vector knowledge base. Preliminary search of knowledge graph: Search for entities and relationships related to "quadratic equation" in the knowledge graph, and find nodes and associated edges such as "quadratic equation", "solution", and "steps". Enhanced search of vector knowledge base: Vectorize user input and retrieve high-similarity knowledge items related to "quadratic equation solution".
[0124] 3. Context management and integration: Context recording: Record the input of the current conversation and the retrieved knowledge graph nodes and vector knowledge base entries. Context dynamic update: Dynamically update the "quadratic equation solution" subgraph in the knowledge graph, and expand the entities and relationships related to the "problem-solving steps". Context summary and extraction: Extract the core information about the "quadratic equation solution" in the current conversation to form a structured context summary.
[0125] 4. Response generation: Fusion of knowledge graph and vector knowledge base information: Integrate the nodes and relationships of “quadratic equation solution” in the knowledge graph with the relevant knowledge items in the vector knowledge base. LLM generates a preliminary response, including the key steps of “quadratic equation solution”.
[0126] Response optimization: The fusion engine optimizes the initial response to ensure consistency with the “problem-solving steps” information in the knowledge graph.
[0127] Generate a final response: The final response is: "The methods for solving quadratic equations are: (1) matching method; (2) root formula; (3) factorization. The specific steps are as follows..."
[0128] 5. Response output and context update: The system outputs the final response, and the student obtains detailed problem-solving steps. The context management module persists the context information of the current conversation and updates the "quadratic equation solution" subgraph in the knowledge graph.
[0129] Example 3 shows the application of knowledge graphs in the education tutoring system. The system can continuously track students' questions and learning progress, provide coherent and detailed problem-solving guidance, and improve students' learning efficiency.
[0130] In summary, this application solves the problem of historical forgetting in LLM multi-round long context dialogues by integrating knowledge graphs and vector knowledge bases, which has significant advantages and effects compared to the existing technology. Specifically, these advantages and effects include the following:
[0131] 1. Improve the coherence and consistency of conversations: Structured information of knowledge graph: The knowledge graph provides structured representation of entities and relationships, enabling the system to maintain the semantic coherence and logical consistency of conversations in multiple rounds of conversations; semantic matching of vector knowledge base: through vectorized knowledge representation, the system can efficiently retrieve and match relevant knowledge in multiple rounds of conversations to ensure the consistency of conversations. The system can effectively remember and manage key information in multiple rounds of conversations, avoiding information gaps and repeated inquiries; by integrating the information of knowledge graph and vector knowledge base, the responses generated by the system are more accurate and relevant, significantly improving the user experience.
[0132] 2. Solve the problem of historical forgetting: Continuously record and update the conversation history to ensure that each round of conversation can be generated based on complete context information; dynamically update the information in the knowledge graph and vector knowledge base in real time to maintain the coherence and consistency of the conversation. Even in long conversations, the system can effectively remember historical information and avoid forgetting key content.
[0133] 3. Enhanced knowledge acquisition and application capabilities: The knowledge graph can provide rich background knowledge and semantic support in the conversation through the association of entities and relationships; using vectorization technology, the system can quickly retrieve knowledge related to the conversation and improve the efficiency of knowledge application. Provide richer and more accurate knowledge background information in the conversation, enhance the depth and breadth of the conversation; through efficient retrieval and semantic association, the quality of the response generated by the system is significantly improved to meet users' higher knowledge needs.
[0134] 4. Optimize the use of computing resources: Through the intelligent context management mechanism, the system avoids the inefficient way of inputting all historical records for each round of dialogue. When processing long-context dialogues, the system responds faster and uses computing resources more efficiently. Optimized computing resource usage reduces the operating cost of the system, making the system more practical and scalable.
[0135] 5. Dynamic update and expansion capabilities: The system can continuously acquire and update the latest knowledge to keep the conversation cutting-edge and real-time; the dynamic update capability enables the system to better cope with complex and changing conversation scenarios and provide always accurate and relevant responses.
[0136] Figure 4 is a structural diagram of a question-answering device based on a large language model according to an embodiment of the present application, such as Figure 4 As shown, the device comprises:
[0137] The receiving module 41 is used to receive question text information input into the large language model.
[0138] The first determination module 42 is used to determine multiple entity information in the question text information and determine the association information between each entity information.
[0139] The second determination module 43 is used to determine the target node including entity information and the associated edges corresponding to the target node in the knowledge graph.
[0140] The updating module 44 is used to update the associated edges according to the associated information, and to expand the target node according to the updated associated edges to obtain an expanded knowledge subgraph.
[0141] The third determination module 45 is used to convert the question text information into a text feature vector, and determine the target knowledge item whose similarity with the text feature vector meets the preset conditions in the vector knowledge base.
[0142] The fourth determination module 46 is used to determine the answer text information corresponding to the question text information according to the extended knowledge subgraph and the target knowledge item.
[0143] Optionally, the fourth determination module 46 is also used to execute the following steps: using the extended knowledge subgraph to perform semantic summarization processing on the question text information to obtain first information whose correlation index with the question text information meets a first preset condition; performing semantic filtering processing on the target knowledge items to obtain second information whose correlation index with the question text information meets a second preset condition; integrating the first information and the second information to obtain answer text information.
[0144] Optionally, the fourth determination module 46 is further configured to execute the following steps: based on the first technical field, perform semantic filtering on the target knowledge item to obtain second information whose correlation index with the question text information meets a second preset condition.
[0145] Optionally, the question-answering device based on the large language model also includes: a fifth determination module, which is used to perform the following steps after integrating the first information and the second information to obtain the answer text information: determine whether the entity information in the answer text information is consistent with the entity information in the extended knowledge subgraph, and when the entity information in the answer text information is inconsistent with the entity information in the extended knowledge subgraph, perform the following steps: use the extended knowledge subgraph to semantically summarize the question text information to obtain the first information; based on the second technical field, perform semantic filtering on the target knowledge items to obtain the third information whose correlation index with the question text information meets the second preset condition, wherein the similarity index between the second technical field and the first technical field meets the preset requirement; integrate the first information and the third information to regenerate the answer text information.
[0146] Optionally, the receiving module 41 is further configured to perform the following steps: receiving the i-th question text information in the i-th round of dialogue, where i is a positive integer.
[0147] The first determination module 42 is further used to perform the following steps: determine multiple i-th entity information in the i-th question text information, and determine i-th association information between each i-th entity information.
[0148] The second determination module 43 is further used to perform the following steps: determine the i-th target node including entity information and the i-th associated edge corresponding to the i-th target node in the i-th knowledge graph.
[0149] The updating module 44 is further used to execute the following steps: updating the i-th associated edge according to the i-th associated information, and expanding the target node according to the updated associated edge to obtain the i-th expanded knowledge subgraph.
[0150] The third determination module 45 is also used to perform the following steps: convert the i-th question text information into a text feature vector, and determine the i-th target knowledge item in the i-th vector knowledge base whose similarity with the text feature vector meets the preset conditions. The fourth determination module 46 is also used to perform the following steps: integrate the extended knowledge subgraph and the target knowledge item to obtain the i-th answer text information; display the i-th answer text information, and determine that the i-th round of dialogue is over.
[0151] The question-answering device based on the large language model also includes: an execution module, which is used to perform the following steps after determining that the i-th round of dialogue is over: updating the i-th knowledge graph and the i-th vector knowledge base according to the i-th answer text information to obtain the i+1-th knowledge graph and the i+1-th vector knowledge base; receiving the i+1-th question text information in the i+1-th round of dialogue; determining multiple i+1-th entity information in the i+1-th question text information, and determining the i+1-th association information between each i+1-th entity information; determining the i+1-th target node including the entity information and the i+1-th knowledge graph in the i+1-th knowledge graph ... +1 target node; update the i+1th associated edge according to the i+1th associated information, and expand the target node according to the updated associated edge to obtain the i+1th extended knowledge subgraph; convert the i+1th question text information into a text feature vector, and determine the i+1th target knowledge item in the i+1th vector knowledge base whose similarity with the text feature vector meets the preset conditions; integrate the extended knowledge subgraph and the target knowledge item to obtain the i+1th answer text information; display the i+1th answer text information, and determine that the i+1th round of dialogue is over.
[0152] Optionally, the third determination module 45 is further used to perform the following steps: in the vector knowledge base, determine the knowledge item with the largest Euclidean distance to the text feature vector as the target knowledge item, or determine the knowledge item with the largest cosine similarity to the text feature vector as the target knowledge item.
[0153] Optionally, the first determination module 42 is also used to execute the following steps: perform word segmentation on the question text information to obtain first text information; perform part-of-speech tagging on the first text information to obtain second text information; perform named entity recognition on the second text information to obtain multiple entity information in the question text information and association information between each entity information.
[0154] According to another aspect of the embodiment of the present application, a question-answering device based on a large language model is also provided, including: a receiving module for receiving question text information input into the large language model; a first determination module for determining multiple entity information in the question text information, and determining the association information between each entity information; a second determination module for determining a target node including the entity information and an associated edge corresponding to the target node in the knowledge graph; an updating module for updating the associated edge according to the associated information, and expanding the target node according to the updated associated edge to obtain an extended knowledge subgraph; a third determination module for converting the question text information into a text feature vector, and determining a target knowledge item in the vector knowledge base whose similarity with the text feature vector meets a preset condition; and a fourth determination module for determining the answer text information corresponding to the question text information according to the extended knowledge subgraph and the target knowledge item.
[0155] It should be noted that the above Figure 4 The modules in the embodiment may be program modules (e.g., a set of program instructions for implementing a specific function) or hardware modules. For the latter, they may be expressed in the following forms, but are not limited thereto: the expression form of the above modules is a processor, or the functions of the above modules are implemented by a processor.
[0156] It should be noted that Figure 4 The preferred implementation of the illustrated embodiment can be found in Figure 1 The relevant description of the illustrated embodiment will not be repeated here.
[0157] Figure 5 FIG. 1 shows a hardware structure block diagram of a computer terminal for implementing a question-answering method based on a large language model. Figure 5 As shown, the computer terminal 50 may include one or more (502a, 502b, ..., 502n are used to illustrate) processors 502 (the processor 502 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA), a memory 504 for storing data, and a transmission module 506 for communication functions. In addition, it may also include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of the BUS bus), a network interface, a power supply and / or a camera. It can be understood by those skilled in the art that Figure 5 The structure shown is only for illustration and does not limit the structure of the above electronic device. Figure 5 More or fewer components as shown, or with Figure 5 Different configurations are shown.
[0158] It should be noted that the one or more processors 502 and / or other data processing circuits described above may generally be referred to herein as "data processing circuits". The data processing circuits may be embodied in whole or in part as software, hardware, firmware, or any other combination thereof. In addition, the data processing circuit may be a single independent processing module, or may be incorporated in whole or in part into any of the other components in the computer terminal 50. As described in the embodiments of the present application, the data processing circuit acts as a processor control (e.g., selection of a variable resistor terminal path connected to an interface).
[0159] The memory 504 can be used to store software programs and modules of application software, such as the program instructions / data storage device corresponding to the question-answering method based on the large language model in the embodiment of the present application. The processor 502 executes various functional applications and data processing by running the software programs and modules stored in the memory 504, that is, realizing the above-mentioned question-answering method based on the large language model. The memory 504 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 504 may further include a memory remotely arranged relative to the processor 502, and these remote memories may be connected to the computer terminal 50 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0160] The transmission module 506 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of the computer terminal 50. In one example, the transmission module 506 includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission module 506 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0161] The display may be, for example, a touch screen liquid crystal display (LCD) that enables a user to interact with a user interface of the computer terminal 50 .
[0162] It should be noted that, in some optional embodiments, the above Figure 5 The computer terminal shown may include hardware elements (including circuits), software elements (including computer code stored on a computer-readable medium), or a combination of hardware elements and software elements. It should be noted that Figure 5 This is merely one example of a particular embodiment and is intended to illustrate the types of components that may be present in the computer terminal described above.
[0163] It should be noted that Figure 5 The computer terminal shown is used to execute Figure 1 The question-answering method based on the large language model shown in the figure, therefore the relevant explanations in the execution method of the above commands are also applicable to the electronic device and will not be repeated here.
[0164] An embodiment of the present application further provides a non-volatile storage medium, which includes a stored program, wherein when the program runs, the device where the storage medium is located is controlled to execute the above question-answering method based on the large language model.
[0165] A program for a non-volatile storage medium to perform the following functions: receiving question text information in an input large language model; determining multiple entity information in the question text information, and determining association information between each entity information; determining a target node including the entity information and an association edge corresponding to the target node in a knowledge graph; updating the association edge according to the association information, and performing expansion processing on the target node according to the updated association edge to obtain an extended knowledge subgraph; converting the question text information into a text feature vector, and determining a target knowledge item in a vector knowledge base whose similarity with the text feature vector meets a preset condition; and determining an answer text information corresponding to the question text information according to the extended knowledge subgraph and the target knowledge item.
[0166] An embodiment of the present application also provides an electronic device, including: a memory and a processor, the processor being used to run a program stored in the memory, wherein the above question-answering method based on a large language model is executed when the program is run.
[0167] The processor is used to run a program that performs the following functions: receiving question text information in an input large language model; determining multiple entity information in the question text information, and determining the association information between each entity information; determining a target node including the entity information and an associated edge corresponding to the target node in the knowledge graph; updating the associated edge according to the associated information, and performing expansion processing on the target node according to the updated associated edge to obtain an extended knowledge subgraph; converting the question text information into a text feature vector, and determining a target knowledge item in a vector knowledge base whose similarity with the text feature vector meets a preset condition; and determining the answer text information corresponding to the question text information according to the extended knowledge subgraph and the target knowledge item.
[0168] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0169] In the above embodiments of the present application, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.
[0170] In the above-mentioned embodiments of the present application, the collected information is information and data authorized by the user or fully authorized by all parties, and the collection, storage, use, processing, transmission, provision, disclosure and application of the relevant data comply with relevant laws, regulations and standards, take necessary protection measures, do not violate public order and good morals, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0171] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units can be a logical function division. There may be other division methods in actual implementation. For example, 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 units or modules, which can be electrical or other forms.
[0172] 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 units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0173] 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.
[0174] 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, or the part that contributes to the relevant technology or all or part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or optical disk, etc. Various media that can store program codes.
[0175] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A question-answering method based on a large language model, characterized in that: include: Receiving question text information input into a large language model; Determine multiple entity information in the question text information, and determine association information between each of the entity information; Determine in the knowledge graph a target node including the entity information and an associated edge corresponding to the target node; According to the association information, the association edge is updated, and according to the updated association edge, the target node is extended to obtain an extended knowledge subgraph; Convert the question text information into a text feature vector, and determine in a vector knowledge base a target knowledge item whose similarity with the text feature vector meets a preset condition; According to the extended knowledge subgraph and the target knowledge item, answer text information corresponding to the question text information is determined.
2. The method according to claim 1, characterized in that: Determining answer text information corresponding to the question text information according to the extended knowledge subgraph and the target knowledge item includes: Using the extended knowledge subgraph, semantically summarizing the question text information to obtain first information whose correlation index with the question text information satisfies a first preset condition; Performing semantic filtering on the target knowledge item to obtain second information whose correlation index with the question text information satisfies a second preset condition; The first information and the second information are integrated and processed to obtain the answer text information.
3. The method according to claim 2, characterized in that The target knowledge item is subjected to semantic filtering to obtain second information whose correlation index with the question text information satisfies a second preset condition, including: Based on the first technical field, semantic filtering is performed on the target knowledge item to obtain second information whose correlation index with the question text information meets a second preset condition.
4. The method according to claim 3, characterized in that After integrating the first information and the second information to obtain the answer text information, the method further includes: Determine whether the entity information in the answer text information is consistent with the entity information in the extended knowledge subgraph. When the entity information in the answer text information is inconsistent with the entity information in the extended knowledge subgraph, perform the following steps: use the extended knowledge subgraph to semantically summarize the question text information to obtain the first information; based on the second technical field, perform semantic filtering on the target knowledge items to obtain third information whose correlation index with the question text information meets the second preset condition, wherein the similarity index between the second technical field and the first technical field meets the preset requirement; integrate the first information and the third information to regenerate the answer text information.
5. The method according to claim 1, characterized in that Receiving question text information input into the large language model, including: receiving the i-th question text information in the i-th round of dialogue, where i is a positive integer; Determining multiple entity information in the question text information, and determining association information between each of the entity information, including: determining multiple i-th entity information in the i-th question text information, and determining i-th association information between each of the i-th entity information; Determining a target node including the entity information and an associated edge corresponding to the target node in the knowledge graph, including: determining an i-th target node including the entity information and an i-th associated edge corresponding to the i-th target node in the i-th knowledge graph; According to the association information, updating the association edge, and according to the updated association edge, extending the target node to obtain an extended knowledge subgraph, including: according to the i-th association information, updating the i-th association edge, and according to the updated association edge, extending the target node to obtain an i-th extended knowledge subgraph; Converting the question text information into a text feature vector, and determining in a vector knowledge base a target knowledge item whose similarity with the text feature vector satisfies a preset condition, including: converting the i-th question text information into a text feature vector, and determining in an i-th vector knowledge base an i-th target knowledge item whose similarity with the text feature vector satisfies the preset condition; Determining answer text information corresponding to the question text information according to the extended knowledge subgraph and the target knowledge item, including: integrating the extended knowledge subgraph and the target knowledge item to obtain the i-th answer text information; displaying the i-th answer text information, and determining that the i-th round of dialogue is over; After determining that the i-th round of dialogue is over, the method further includes: updating the i-th knowledge graph and the i-th vector knowledge base according to the i-th answer text information to obtain the i+1-th knowledge graph and the i+1-th vector knowledge base; receiving the i+1-th question text information in the i+1-th round of dialogue; determining multiple i+1-th entity information in the i+1-th question text information, and determining the i+1-th association information between each of the i+1-th entity information; determining the i+1-th target node including the entity information and the i+1-th target node corresponding to the i+1-th target node in the i+1-th knowledge graph. associated edge; according to the i+1th associated information, updating the i+1th associated edge, according to the updated associated edge, expanding the target node to obtain the i+1th extended knowledge subgraph; converting the i+1th question text information into a text feature vector, determining the i+1th target knowledge item in the i+1th vector knowledge base whose similarity with the text feature vector meets the preset condition; integrating the extended knowledge subgraph and the target knowledge item to obtain the i+1th answer text information; displaying the i+1th answer text information, and determining that the i+1th round of dialogue is over.
6. The method according to claim 1, characterized in that Determining in the vector knowledge base a target knowledge item whose similarity with the text feature vector meets a preset condition, comprising: In the vector knowledge base, the knowledge item with the largest Euclidean distance to the text feature vector is determined as the target knowledge item, or the knowledge item with the largest cosine similarity to the text feature vector is determined as the target knowledge item.
7. The method according to claim 1, characterized in that Determining multiple entity information in the question text information, and determining association information between each of the entity information, including: Performing word segmentation processing on the question text information to obtain first text information; Performing part-of-speech tagging on the first text information to obtain second text information; The second text information is processed by named entity recognition to obtain a plurality of entity information in the question text information and association information between each of the entity information.
8. A question-answering device based on a large language model, characterized in that: include: A receiving module, used for receiving question text information input into the large language model; A first determination module is used to determine multiple entity information in the question text information, and determine association information between each of the entity information; A second determination module is used to determine a target node including the entity information and an associated edge corresponding to the target node in the knowledge graph; An updating module, configured to update the associated edge according to the associated information, and perform expansion processing on the target node according to the updated associated edge to obtain an expanded knowledge subgraph; A third determination module is used to convert the question text information into a text feature vector, and determine a target knowledge item in a vector knowledge base whose similarity with the text feature vector meets a preset condition; The fourth determination module is used to determine the answer text information corresponding to the question text information according to the extended knowledge subgraph and the target knowledge item.
9. A non-volatile storage medium, characterized in that: The non-volatile storage medium includes a stored program, wherein when the program is executed, the device where the non-volatile storage medium is located is controlled to execute the question-answering method based on a large language model as described in any one of claims 1 to 7.
10. An electronic device, characterized in that: include: A memory and a processor, wherein the processor is used to run a program stored in the memory, wherein the program, when running, executes the question-answering method based on a large language model as described in any one of claims 1 to 7.
11. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the question-answering method based on a large language model described in any one of claims 1 to 7 is implemented.
Citation Information
Cited By
Text processing method and device, electronic equipment, storage medium and program product
CN119357365A
Text processing method, device, electronic device, storage medium and program product
CN119357365B
Labeling method for security management knowledge graph data
CN119357411A
Advanced plan and scheduling generation method and system assisted by large model agent
CN120181487A
Online teaching interaction method based on multi-modal knowledge graph, medium and equipment
CN120339011A
