Response enhancement method and device based on RAG technology

By using knowledge graphs and user feedback in RAG technology to optimize entity relevance, the problem of unreality and incoherence of context is solved, and more accurate and complete answers are achieved.

CN119005330APending Publication Date: 2024-11-22FUJIAN FUNO MOBILE COMM TECH CO LTD
View PDF 0 Cites 15 Cited by

Patent Information

Application Number
CN202410899737.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-05
Publication Date
2024-11-22

AI Technical Summary

Technical Problem

Although RAG technology enhances the response capabilities of generative models by introducing external knowledge bases, it may still generate untrue or incorrect information and there are problems of incoherence in context.

Method used

By identifying entities from text blocks and linking them to knowledge graphs during the knowledge base construction stage, a general knowledge graph is generated, and user input problems are obtained during the RAG technology use stage, and associated text blocks are retrieved through query vector matching to identify associated entities and entity relationships. Text blocks are used to build a personalized knowledge graph based on user feedback to optimize the accuracy and consistency of answers.

Benefits of technology

Ensure that the correlation between entities is retained in the answers, enhance the system's understanding of the query context, and the generated prompts and answers are more complete, coherent and accurate, and use user feedback to improve the accuracy and completeness of the knowledge graph, providing users with personalized services. Improve the quality of answers.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119005330A_ABST
    Figure CN119005330A_ABST
Patent Text Reader

Abstract

The invention provides an answer enhancement method and device based on an RAG technology, and the method comprises the steps: recognizing an entity from a text block in a knowledge base construction stage, linking the entity to a standard entity in a knowledge graph, and generating a general knowledge graph; in the RAG technology use stage, an input question of a user is obtained, a query vector is obtained, an associated text block is retrieved through similarity matching of the query vector in a vector database, an associated entity is recognized from the associated text block, and other entities related to the associated entity and an entity relationship are retrieved in a general knowledge graph. Adding the associated text blocks into the input question to supplement the associated text blocks, constructing the supplemented associated text blocks and the input question into cue words of a large language model, and inputting to obtain an answer of the input question; user feedback is received in real time, and a personalized knowledge graph of each user is constructed according to the user feedback and then used for processing query of the users. According to the invention, more complete, coherent and accurate prompts and answers can be generated.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of big data technology, and in particular to a method and device for answer enhancement based on RAG technology. Background Art

[0002] Since the breadth of knowledge of large language models depends on the breadth of the training data set and cannot learn specialized or internalized data, RAG technology is introduced as an external knowledge base to solve the problem of knowledge breadth of large models.

[0003] RAG technology enhances the answering ability of the generative model by introducing an external knowledge base or document base, enabling it to generate more detailed and accurate answers. However, although RAG technology reduces the unreality of generated information by introducing a retrieval mechanism of an external knowledge base, the hallucination problem has not been completely solved. In some cases, the text generated by RAG technology may still contain unrealistic or erroneous information, and the prompts and answers generated by RAG technology may be contextually incoherent. Summary of the invention

[0004] In order to solve the above problems in the prior art, the present invention provides a method and device for answer enhancement based on RAG technology, which can generate more coherent and accurate answers.

[0005] In order to achieve the above object, the technical solution adopted by the present invention is:

[0006] In a first aspect, the present invention provides a method for answer enhancement based on RAG technology, comprising the steps of:

[0007] In the knowledge base construction phase, entities are identified from text blocks and linked to standard entities in the knowledge graph to generate a general knowledge graph;

[0008] In the RAG technology use stage, the user's input question is obtained to obtain a query vector, and the related text block is retrieved through similarity matching of the query vector in the vector database, and the related entity is identified from the related text block, and other entities and entity relationships related to the related entity are retrieved in the general knowledge graph to supplement the related text block, and the supplemented related text block and the input question are constructed together as the prompt word of the large language model, and the prompt word is input into the large language model to obtain the answer to the input question;

[0009] Receive user feedback in real time, build a personalized knowledge graph for each user based on the user feedback, and then use the personalized knowledge graph and the general knowledge graph to process the user's query.

[0010] The beneficial effects of the present invention are: through entity extraction and linking, the implicit entity relationship in the text is made explicit, ensuring that the correlation between entities is preserved in the answer. When answering questions, the entity relationship information of the knowledge graph can be combined to enhance the system's understanding of the query context, and the scattered text block information can be reintegrated to make the generated prompts and answers more complete, coherent and accurate. At the same time, user feedback is used to improve the accuracy and completeness of the knowledge graph and make it more personalized, providing users with more accurate and personalized services and further improving the quality of answers.

[0011] Optionally, constructing a personalized knowledge graph for each user based on user feedback includes the following steps:

[0012] When the user feedback is a positive evaluation, the entity contained in the input question and the entity contained in the answer to the input question are associated to generate a personalized knowledge graph for each user.

[0013] Optionally, the method further comprises the steps of:

[0014] If the same entity relationship exists in the personalized knowledge graphs of more than a preset number of users, this entity relationship will be added to the general knowledge graph.

[0015] According to the above description, if a large number of users have associations between the same entities, personalized entity relationships are added to the general knowledge graph, thereby improving the comprehensiveness and accuracy of the general knowledge graph.

[0016] Optionally, the method further comprises the steps of:

[0017] In the knowledge base construction stage, the collected data is cleaned and preprocessed to obtain data text, the data text is divided into blocks to obtain text blocks, the text blocks are vectorized, and the obtained text vectors are stored.

[0018] In a second aspect, the present invention provides an answer enhancement device based on RAG technology, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the following steps are implemented:

[0019] In the knowledge base construction phase, entities are identified from text blocks and linked to standard entities in the knowledge graph to generate a general knowledge graph;

[0020] In the RAG technology use stage, the user's input question is obtained to obtain a query vector, and the related text block is retrieved through similarity matching of the query vector in the vector database, and the related entity is identified from the related text block, and other entities and entity relationships related to the related entity are retrieved in the general knowledge graph to supplement the related text block, and the supplemented related text block and the input question are constructed together as the prompt word of the large language model, and the prompt word is input into the large language model to obtain the answer to the input question;

[0021] Receive user feedback in real time, build a personalized knowledge graph for each user based on the user feedback, and then use the personalized knowledge graph and the general knowledge graph to process the user's query.

[0022] Optionally, constructing a personalized knowledge graph for each user based on user feedback includes the following steps:

[0023] When the user feedback is a positive evaluation, the entity contained in the input question and the entity contained in the answer to the input question are associated to generate a personalized knowledge graph for each user.

[0024] Optionally, the method further comprises the steps of:

[0025] If the same entity relationship exists in the personalized knowledge graphs of more than a preset number of users, this entity relationship will be added to the general knowledge graph.

[0026] Optionally, the method further comprises the steps of:

[0027] In the knowledge base construction stage, the collected data is cleaned and preprocessed to obtain data text, the data text is divided into blocks to obtain text blocks, the text blocks are vectorized, and the obtained text vectors are stored.

[0028] Among them, the technical effect corresponding to the answer enhancement device based on RAG technology provided in the second aspect refers to the relevant description of the answer enhancement method based on RAG technology provided in the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS

[0029] Figure 1 A schematic diagram of the main flow of a method for answer enhancement based on RAG technology according to an embodiment of the present invention;

[0030] Figure 2 A schematic diagram of a specific flow chart of a method for answer enhancement based on RAG technology according to an embodiment of the present invention;

[0031] Figure 3 It is a schematic diagram of the framework of a response enhancement device based on RAG technology according to an embodiment of the present invention.

[0032] Description of reference numerals:

[0033] 1. A response enhancement device based on RAG technology;

[0034] 2. Processor;

[0035] 3. Memory. DETAILED DESCRIPTION

[0036] In order to better understand the above technical solution, exemplary embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. Although exemplary embodiments of the present invention are shown in the accompanying drawings, it should be understood that the present invention can be implemented in various forms and should not be limited by the embodiments described herein. On the contrary, these embodiments are provided to enable a clearer and more thorough understanding of the present invention and to fully convey the scope of the present invention to those skilled in the art.

[0037] Embodiment 1

[0038] This embodiment is suitable for application scenarios that use large language models for answering, especially the use of RAG technology. The existing RAG technology uses vectorized representations that ignore the relationship between entities, especially when the entities are scattered in different text blocks, and cannot effectively capture the correlation between them. At the same time, vector retrieval is mainly based on the local similarity of text blocks, which easily ignores the global context, resulting in the inability to accurately reflect the relationship between entities when answering. This embodiment uses a knowledge graph and dynamically optimizes the knowledge graph to obtain a more complete, coherent and accurate answer. See the following description for details.

[0039] Please refer to Figure 1 and Figure 2 , a RAG-based answer enhancement method, comprising the steps of:

[0040] Step S1: In the knowledge base construction phase, entities are identified from text blocks and linked to standard entities in the knowledge graph to generate a general knowledge graph;

[0041] In this embodiment, entity recognition technology is used to extract entities from the text, such as using a named entity recognition (NER) algorithm. The extracted entities are then linked to standard entities in the knowledge graph to ensure the uniqueness of the entities and the accuracy of the relationships. In this way, through entity extraction and linking, the implicit entity relationships in the text are made explicit, ensuring that the relevance between entities is preserved in the answer.

[0042] Reference Figure 2 It can be seen that before identifying entities from the text block in step S1, the following steps are also included:

[0043] In the knowledge base construction phase, the collected data is cleaned and preprocessed to obtain data text, the data text is divided into blocks to obtain text blocks, the text blocks are vectorized, and the obtained text vectors are stored.

[0044] Step S2: In the RAG technology use phase, the user's input question is obtained to obtain a query vector, and the related text block is retrieved through similarity matching of the query vector in the vector database, and the related entity is identified from the related text block. Other entities and entity relationships related to the related entity are retrieved in the general knowledge graph to supplement the related text block, and the supplemented related text block and the input question are constructed together as the prompt word of the large language model, and the prompt word is input into the large language model to obtain the answer to the input question;

[0045] Step S3: Receive user feedback in real time, build a personalized knowledge graph for each user based on the user feedback, and then use the personalized knowledge graph and the general knowledge graph to process the user's query.

[0046] In this embodiment, step S3 constructs a personalized knowledge graph for each user based on user feedback, including the following steps:

[0047] When the user feedback is positive, the entities contained in the input question and the entities contained in the answer to the input question are associated to generate a personalized knowledge graph for each user;

[0048] If the same entity relationship exists in the personalized knowledge graphs of more than a preset number of users, this entity relationship will be added to the general knowledge graph.

[0049] In this embodiment, user feedback is usually a thumbs up or thumbs down. That is, if a user thumbs up, it means that the entities in the question and answer are associated, so a user-level knowledge graph can be constructed. If a large number of users have associations between the same entities, it means that a large number of users recognize this entity relationship, and then the personalized entity relationship is added to the general knowledge graph, thereby improving the comprehensiveness and accuracy of the general knowledge graph.

[0050] Reference Figure 2 It can be seen that the further description of the RAG technology usage stage is as follows:

[0051] (1) User query: The query entered by the user as a description of the problem.

[0052] (2) Embedding vector: The query is converted into an embedding vector to form a query vector.

[0053] (3) Vector similarity retrieval and entity relationship retrieval: By performing similarity matching in the vector database through the query vector, the related text blocks are retrieved. At the same time, using the entities identified from the query, other entities and relationships related to these entities are retrieved in the knowledge graph to obtain supplementary information.

[0054] In the user query processing, the entities in the query are identified, and the related entities and the relationships between them are retrieved from the knowledge graph. In this embodiment, a graph database or similar technology is used to store and retrieve entities and their relationships to ensure efficient query response speed and accuracy.

[0055] Among them, multi-level information integration is performed by combining query vectorization and information about entity relationships in the knowledge graph. In this embodiment, natural language processing technologies such as word embedding and text vectorization are used to represent user queries and associate them with entity relationship information in the knowledge graph, providing more extensive and accurate context information, multi-hop queries, and implicit relationship reasoning, etc., to ensure that the generated prompts and final answers can better reflect global semantics.

[0056] (4) Associated text block: The supplemented associated text block is obtained according to the above steps.

[0057] (5) Constructing prompt words: The text blocks and questions in the knowledge base together construct the prompt words of the large model.

[0058] Among them, prompt words containing context information and entity relationships are generated according to user queries and related text blocks. In this embodiment, attribute information of text blocks and related entities in the knowledge base is used in combination with natural language generation models such as generative adversarial networks or large pre-trained language models to generate more accurate and coherent answers.

[0059] (6) Generate answers: The large language model generates answers based on the prompt words.

[0060] Among them, based on the entity and relationship information in the knowledge graph, the information extracted from different text blocks is integrated and reconstructed. In this embodiment, the entity relationships in the knowledge graph are used to reorganize the scattered answer fragments into a more complete and coherent answer structure.

[0061] (7) User feedback: Users give likes or dislikes to the generated answers.

[0062] (8) Dynamic optimization of knowledge graph: entity relationship retrieval:

[0063] Among them, the entity and relationship information in the knowledge graph is continuously optimized based on user feedback and system learning. In this embodiment, machine learning and automated algorithms are used to monitor and update the entity attributes and relationships in the knowledge graph, gradually expanding from the personal level knowledge graph to the general knowledge graph to improve the quality of system response and answer.

[0064] In summary, this embodiment makes the implicit entity relationships in the text explicit through entity extraction and linking, ensuring that the correlation between entities is preserved in the answer. When answering questions, it is possible to combine the entity relationship information of the knowledge graph, enhance the system's understanding of the query context, and reintegrate the scattered text block information to make the generated prompts and answers more complete, coherent and accurate. At the same time, user feedback is used to improve the accuracy and completeness of the knowledge graph and make it more personalized, providing users with more accurate and personalized services and further improving the quality of answers.

[0065] Embodiment 2

[0066] Please refer to Figure 3 , an answer enhancement device 1 based on RAG technology, including a memory 3, a processor 2 and a computer program stored in the memory 3 and executable on the processor 2, wherein the processor 2 implements the steps in the above-mentioned embodiment 1 when executing the computer program.

[0067] Since the system / device described in the above embodiments of the present invention is a system / device used to implement the method of the above embodiments of the present invention, a person skilled in the art can understand the specific structure and deformation of the system / device based on the method described in the above embodiments of the present invention, and thus will not be described in detail here. All systems / devices used in the method of the above embodiments of the present invention belong to the scope of protection of the present invention.

[0068] It will be appreciated by those skilled in the art that embodiments of the present invention may be provided as methods, devices or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0069] The present invention is described with reference to the flowcharts and / or block diagrams of the methods, devices (apparatus) and computer program products according to the embodiments of the present invention. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions.

[0070] It should be noted that in the claims, any reference numerals placed between brackets shall not be construed as limiting the claims. The word "comprising" does not exclude the presence of components or steps not listed in the claims. The word "a" or "an" preceding a component does not exclude the presence of a plurality of such components. The invention may be implemented by means of hardware comprising several different components and by means of a suitably programmed computer. In the claims enumerating several means, several of these means may be embodied by the same hardware. The use of the words first, second, third, etc., is for convenience of expression only and does not indicate any order. These words may be understood as part of the component name.

[0071] In addition, it should be noted that, in the description of this specification, the description of the terms "one embodiment", "some embodiments", "embodiment", "example", "specific example" or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, unless they are contradictory.

[0072] Although the preferred embodiments of the present invention have been described, those skilled in the art may make other changes and modifications to these embodiments after knowing the basic creative concept. Therefore, the claims should be interpreted as including the preferred embodiments and all changes and modifications falling within the scope of the present invention.

[0073] Obviously, those skilled in the art can make various modifications and variations to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention should also include these modifications and variations.

Claims

1. A method for answer enhancement based on RAG technology, characterized in that: Includes steps: In the knowledge base construction phase, entities are identified from text blocks and linked to standard entities in the knowledge graph to generate a general knowledge graph; In the RAG technology use stage, the user's input question is obtained to obtain a query vector, and the related text block is retrieved through similarity matching of the query vector in the vector database, and the related entity is identified from the related text block, and other entities and entity relationships related to the related entity are retrieved in the general knowledge graph to supplement the related text block, and the supplemented related text block and the input question are constructed together as the prompt word of the large language model, and the prompt word is input into the large language model to obtain the answer to the input question; Receive user feedback in real time, build a personalized knowledge graph for each user based on the user feedback, and then use the personalized knowledge graph and the general knowledge graph to process the user's query.

2. The answer enhancement method based on RAG technology according to claim 1, characterized in that: The process of constructing a personalized knowledge graph for each user based on user feedback includes the following steps: When the user feedback is a positive evaluation, the entity contained in the input question and the entity contained in the answer to the input question are associated to generate a personalized knowledge graph for each user.

3. The answer enhancement method based on RAG technology according to claim 2, characterized in that: Also includes the steps: If the same entity relationship exists in the personalized knowledge graphs of more than a preset number of users, this entity relationship will be added to the general knowledge graph.

4. A method for enhancing the answer based on RAG technology according to any one of claims 1 to 3, characterized in that: Also includes the steps: In the knowledge base construction stage, the collected data is cleaned and preprocessed to obtain data text, the data text is divided into blocks to obtain text blocks, the text blocks are vectorized, and the obtained text vectors are stored.

5. A RAG-based answer enhancement device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the following steps are implemented: In the knowledge base construction phase, entities are identified from text blocks and linked to standard entities in the knowledge graph to generate a general knowledge graph; In the RAG technology use stage, the user's input question is obtained to obtain a query vector, and the related text block is retrieved through similarity matching of the query vector in the vector database, and the related entity is identified from the related text block, and other entities and entity relationships related to the related entity are retrieved in the general knowledge graph to supplement the related text block, and the supplemented related text block and the input question are constructed together as the prompt word of the large language model, and the prompt word is input into the large language model to obtain the answer to the input question; Receive user feedback in real time, build a personalized knowledge graph for each user based on the user feedback, and then use the personalized knowledge graph and the general knowledge graph to process the user's query.

6. The answer enhancement device based on RAG technology according to claim 5, characterized in that: The process of constructing a personalized knowledge graph for each user based on user feedback includes the following steps: When the user feedback is a positive evaluation, the entity contained in the input question and the entity contained in the answer to the input question are associated to generate a personalized knowledge graph for each user.

7. The answer enhancement device based on RAG technology according to claim 6, characterized in that: Also includes the steps: If the same entity relationship exists in the personalized knowledge graphs of more than a preset number of users, this entity relationship will be added to the general knowledge graph.

8. The answer enhancement device based on RAG technology according to any one of claims 5 to 7, characterized in that: Also includes the steps: In the knowledge base construction stage, the collected data is cleaned and preprocessed to obtain data text, the data text is divided into blocks to obtain text blocks, the text blocks are vectorized, and the obtained text vectors are stored.

Citation Information

Cited By

  • Fault reason analysis method and device for IT operation and maintenance scene

    CN119398182A

  • Intelligent question and answer method and device

    CN119917622A

  • Intelligent question answering method and apparatus

    CN119917622B

  • Scientific and technological service field knowledge base construction method and system based on knowledge graph and RAG

    CN119940500A

  • A knowledge graph and RAG-based scientific and technological service field knowledge base construction method and system

    CN119940500B