Retrieval enhancement generation method and device based on semantic enhancement knowledge graph

By constructing a semantic enhancement knowledge graph and using a large language model to judge entity information and relational information in the subgraph, the existing search enhancement generation methods cannot handle the problem that graph structure knowledge and answer accuracy are low, and higher generalization ability and answer accuracy are achieved.

CN119917636AActive Publication Date: 2025-05-02HANGZHOU DIANZI UNIV

Patent Information

Application Number
CN202510398457.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-01
Publication Date
2025-05-02
Estimated Expiration
2045-04-01

AI Technical Summary

Technical Problem

The existing search enhancement generation method cannot capture the relationship information between texts when processing knowledge with graph structure, resulting in the inability to process graph structure knowledge, and there are problems such as low answer accuracy and insufficient generalization ability.

Method used

The search and enhancement generation method based on semantic enhanced knowledge graph is adopted to build a semantic enhanced knowledge graph that includes entity sets, inter-entity relationship sets, related sentence sets and mapping relationship sets, and a large language model is used to judge whether the entity information and relationship information in the sub-graph can answer user questions, thereby generating more accurate answers.

Benefits of technology

Improve the generalization ability and the accuracy of the answers, and by enhancing the detailed information of the entity and the semantic information of the knowledge graph, more accurate answers are generated, and due to the universality of the method, specific information required by a specific entity can be extracted according to needs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119917636A_ABST
    Figure CN119917636A_ABST
Patent Text Reader

Abstract

The invention discloses a retrieval enhancement generation method and device based on a semantic enhancement knowledge graph, and relates to the technical field of question and answer systems in man-machine interaction dialogues. The method comprises the steps that the semantic enhancement knowledge graph and a retrieval strategy based on the semantic enhancement knowledge graph are constructed, the retrieval result comprises first contextual information or second contextual information, the first contextual information is determined according to entity information in the subgraph and relation information between entities, and the second contextual information is determined according to the entity information in the subgraph, the relation information between the entities and related entity information; and obtaining an answer according to the first context information or the second context information. According to the method, the detail information of the entity and the semantic information of the knowledge graph are enhanced, and more accurate answers can be generated; and the specific information required by the specific entity is extracted according to the requirement instead of extracting the specified entity information during the construction of the knowledge graph, so that the method has universality.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of question-answering systems in human-computer interactive dialogues, and in particular to a retrieval enhancement generation method and device based on a semantically enhanced knowledge graph. Background Art

[0002] Large Language Models (LLMs) have demonstrated powerful natural language understanding and human-like text generation capabilities in practical applications, but they still face the problem of hallucination, that is, the generated content is inconsistent with common sense or inconsistent with the source content.

[0003] Retrieval-Augmented Generation (RAG) helps LLMs obtain external knowledge by retrieving relevant information from an external text corpus, thereby improving the accuracy of the response. However, RAG has the following limitations: (1) Ignoring relational information: Traditional RAG cannot capture relational information between texts, resulting in the inability to process knowledge with a graph structure. (2) Redundant information: RAG uses text fragments to represent external knowledge, which may exceed the LLMs input length limit or information loss.

[0004] In order to solve these problems, some studies in recent years have proposed using knowledge graphs (KG) as external knowledge sources. Unlike traditional RAG, the Graph Retrieval-Augmented Generation (GraphRAG) process retrieves subgraphs containing relationship information from the knowledge graph as context information. GraphRAG can handle the relationship between texts and improve reasoning ability, but it still has the defects of lack of generalization ability and low answer accuracy. Summary of the invention

[0005] The purpose of this application is to provide a retrieval enhancement generation method and device based on a semantically enhanced knowledge graph, which can improve the generalization ability and the accuracy of the answer.

[0006] To achieve the above objectives, this application provides the following solutions: In a first aspect, the present application provides a retrieval enhancement generation method based on a semantically enhanced knowledge graph, comprising: Get the original text document; According to the entity information and the relationship information between entities extracted from the original text document, a semantically enhanced knowledge graph is constructed, wherein the semantically enhanced knowledge graph includes an entity set, a relationship set between entities, a related sentence set, and a mapping relationship set, wherein the related sentence set refers to a sentence set related to entities and relationships between entities, and the mapping relationship set refers to a set of mapping relationships between sentences in the original text document and target objects, wherein the target objects are entity nodes and relationship edges in the knowledge graph; Obtaining a subgraph according to the explicit entity set and the semantically enhanced knowledge graph; Using the large language model, determining whether the entity information and the relationship information between entities in the subgraph can answer the user's question, and obtaining a first determination result; If the first judgment result is yes, the entity information and the relationship information between entities in the subgraph are used as the first context information, and the first prompt information is constructed according to the first context information and the user question; Based on the first prompt information, using a large language model to generate an answer corresponding to the user's question; If the first judgment result is no, extracting relevant entity information from the mixed related sentence set, taking the relevant entity information and the entity information and the relationship information between entities in the subgraph as the second context information, and constructing the second prompt information according to the second context information and the user question, wherein the mixed related sentence set is a set of sentences in the subgraph related to the mixed entities and the relationship between the mixed entities; Based on the second prompt information, a large language model is used to generate an answer corresponding to the user's question.

[0007] In a second aspect, the present application provides a retrieval enhancement generation device based on a semantically enhanced knowledge graph, comprising: A document acquisition module is used to acquire original text documents; A semantically enhanced knowledge graph construction module, used to construct a semantically enhanced knowledge graph based on the entity information and inter-entity relationship information extracted from the original text document, wherein the semantically enhanced knowledge graph includes an entity set, a relationship set between entities, a related sentence set, and a mapping relationship set, wherein the related sentence set refers to a sentence set related to entities and inter-entity relationships, and the mapping relationship set refers to a set of mapping relationships between sentences in the original text document and target objects, and the target objects are entity nodes and relationship edges in the knowledge graph; A subgraph construction module, used for obtaining a subgraph according to the explicit entity set and the semantically enhanced knowledge graph; A judgment module is used to use a large language model to judge whether the entity information and the relationship information between entities in the subgraph can answer the user's question, and obtain a first judgment result; if the first judgment result is yes, the entity information and the relationship information between entities in the subgraph are used as the first context information, and a first prompt information is constructed according to the first context information and the user's question; based on the first prompt information, a large language model is used to generate an answer corresponding to the user's question; if the first judgment result is no, relevant entity information is extracted from a set of mixed related sentences, and the relevant entity information and the entity information and the relationship information between entities in the subgraph are used as the second context information, and a second prompt information is constructed according to the second context information and the user's question; based on the second prompt information, a large language model is used to generate an answer corresponding to the user's question, wherein the set of mixed related sentences is a set of sentences in the subgraph that are related to mixed entities and relationships between mixed entities.

[0008] According to the specific embodiments provided in this application, this application has the following technical effects: The present application provides a method and device for enhancing retrieval generation based on a semantically enhanced knowledge graph, the method includes constructing a semantically enhanced knowledge graph, performing retrieval based on a retrieval strategy of the semantically enhanced knowledge graph, the retrieval result includes first context information or second context information, the first context information is determined based on entity information and inter-entity relationship information in the subgraph, the second context information is determined based on entity information, inter-entity relationship information and related entity information in the subgraph, and an answer is obtained based on the first context information or the second context information. The method enhances the detailed information of the entity and the semantic information of the knowledge graph, and can generate more accurate answers; and because the method extracts the specific information (context information) required for a specific entity according to demand, rather than extracting the specified entity information when the knowledge graph is constructed, the method has universality. BRIEF DESCRIPTION OF THE DRAWINGS

[0009] Figure 1 A flowchart of a retrieval enhancement generation method based on a semantically enhanced knowledge graph provided in Example 1 of the present application; Figure 2 This is a schematic diagram of the semantically enhanced knowledge graph in Example 1 of the present application; Figure 3 This is a flowchart of a specific example of the application of a retrieval enhancement generation method based on a semantically enhanced knowledge graph in Example 1 of the present application. DETAILED DESCRIPTION

[0010] Example 1 The research found that the Graph RAG method still faces the following challenges: (1) Lack of generalization ability: Most existing Graph RAG methods are built based on existing knowledge graphs. However, building a high-quality knowledge graph requires deep expertise and a lot of time investment, which makes the process costly. In addition, before building a knowledge graph, it is necessary to design an architecture suitable for a specific application scenario. However, this pre-definition also limits the information in the knowledge graph.

[0011] (2) Lack of details: In practical applications of Graph RAG, knowledge graphs usually only contain entities and their relationships, ignoring specific information about the entities or evidence supporting the relationships. Compared with using text corpora as external knowledge sources, although knowledge graphs provide powerful relationship information, they are extremely lacking in details.

[0012] In view of the above defects, this embodiment provides a retrieval enhancement generation method based on semantically enhanced knowledge graph, which can improve the generalization ability and accuracy of the answer. Figure 1 As shown, the method includes the following steps 201 to 208. Among them: Step 201, obtaining an original text document.

[0013] Step 202, from the original text document Extract entity information and inter-entity relationship information from the dataset, and build a semantically enhanced knowledge graph based on the extracted entity information and inter-entity relationship information. , wherein the semantically enhanced knowledge graph includes an entity set, a relationship set between entities, a related sentence set, and a mapping relationship set, wherein the mapping relationship set refers to a set of mapping relationships between sentences in the original text document and target objects, and the target objects are entity nodes and relationship edges in the knowledge graph, is a collection of entities, For entity collection The set of relationships between entities in for The set of sentences related to entities and the relationships between entities in , that is, the set of related sentences, It is a set of mapping relationships between sentences in the text and related entity nodes and relationship edges on the knowledge graph, that is, a mapping relationship set.

[0014] The process of extracting entity information and inter-entity relationship information in step 202 (ie, step 202-1) is as follows: Step 202-1-1: original text document provided by the user , respectively, to perform document segmentation and obtain several text block sets .

[0015] Step 202-1-2: Use the language model to analyze the original text document. Perform sentence segmentation to obtain a sentence set containing several sentences ; Step 202-1-3, using the word segmentation model to calculate each sentence in the sentence set (i.e. ) Token quantity, record ; Step 202-1-4: Set the total number of tokens to a size that does not exceed the set text block size The consecutive sentences are divided into a text block; Step 202-1-5, constructing a text block set based on all the text blocks .

[0016] Step 202-1-6, extracting the entity information and the relationship information between the entities from the text block set.

[0017] In step 202, a semantically enhanced knowledge graph is constructed based on the extracted entity information and the relationship information between entities (i.e., step 202-2), which specifically includes: Step 202-2-1, according to each text block (i.e. ) Extracted entity information and relationship information between entities to build a semantically enhanced knowledge graph for text blocks ; Step 202-2-2: Merge all the text blocks to enhance the knowledge graph semantically , get the original text document The semantically enhanced knowledge graph ; Step 202-2-1 specifically includes: (1) Using a large language model to extract the Extracting entity information and entity relationship information of a specified entity type, wherein the entity information includes an entity name, an entity type, and an entity description, and the entity relationship information includes a source entity, a target entity, a relationship description, and a relationship basis; (2) constructing a text block entity set and a text block entity relationship set based on the extracted entity information and entity relationship information of the specified entity type, wherein the text block entity relationship set contains the text block entity set The relationship between several entities in the text block entity set is recorded as , the set of relations between text block entities is recorded as ; (3) Use the large language model to evaluate the information content score of each sentence in the text block, denoted as ; (4) When the information score Not less than the information threshold , and the sentence The entities appearing in belong to the text block entity set (i.e. ), establish a mapping relationship between sentences and entities appearing in sentences (that is, Map to ); (5) Based on the mapping relationship between sentences and entities appearing in sentences, a set of mapping relationships between text block content and entities is constructed. ; (6) When the information score Not less than the information threshold And the sentence The entity relationships (i.e., sentences) in the entity relationship set of the text block It's a relationship , establish a mapping relationship between the sentence and the entity relationships in the entity relationship set of the text block (i.e., the sentence Mapping to Relationship ); (7) Constructing a mapping relationship set between text block text content and entity relationships based on the mapping relationship between the sentence and the entity relationships in the text block entity relationship set ; (8) Determine a text block mapping relationship set based on a mapping relationship set between the text content of the text block and entities and a mapping relationship set between the text content of the text block and the relationship between entities A collection of sentences related to the text block ; (9) Constructing the text block semantically enhanced knowledge graph based on the text block entity set, the text block entity relationship set, the text block related sentence set and the text block mapping relationship set .

[0018] Step 203: the semantically enhanced knowledge graph obtained in step 202 Entity alignment is performed to obtain the aligned semantically enhanced knowledge graph to improve the standardization and consistency of the semantically enhanced knowledge graph.

[0019] Step 203 specifically includes: Step 203-1: sort the entity set according to the entity type Pre-classify the entities in to obtain an entity type set containing several different types of entities ,in Indicates categories; Step 203-2, for entities of the same type in the entity type set ( ) Clustering is performed based on semantic similarity to obtain a clustered entity set; The specific process of step 203-2 is as follows: Step 203-2-1, using the embedding model to perform text vectorization on the entity name and the corresponding entity description of the same type of entity in the entity type set, to obtain each entity vector, that is, converting "<entity name>:<entity description>" into a vector form as The vector representation of ; Step 203-2-2, calculating the second similarity based on the entity vector ; Step 203-2-3: the second similarity is higher than the second similarity threshold. Add association edges to entities and build entity relationship diagrams ,in ; Step 203-2-4, extracting the entity relationship diagram All connected subgraphs in ; Step 203-2-5: construct a clustered entity set according to the nodes included in the connected subgraph (the nodes included in each connected subgraph are a new entity set).

[0020] Step 203-3, using the large language model to determine whether the clustered entities in the clustered entity set are the same entity, to obtain a second determination result; Step 203-4: if the second judgment result is yes, merge the semantically enhanced knowledge graph Entity nodes belonging to the same entity.

[0021] Step 204, answer the user question , using a large language model to extract entities appearing in user questions, and obtain a set of entities containing several explicit entities (i.e. Explicit entity collections of entities that appear in .

[0022] Step 205: the explicit entity set obtained in step 204 , in the semantically enhanced knowledge graph The subgraph is expanded to obtain a mixed entity set containing the explicit entity and the implicit entity. , , and according to the mixed entity set Extracting subgraphs from the aligned semantically enhanced knowledge graph , where the implicit entity refers to the user question Related but not present in user questions Entities in .

[0023] The subgraph extension method is as follows: Step 205-1: Set the explicit entity The explicit entities in are added to the initial entity list middle; Step 205-2: Use the embedding model to solve the user question Perform text vectorization to obtain the question vector , use the embedding model to vectorize the text, remember ; Step 205-3, for each explicit entity in the initial list, traverse the semantically enhanced knowledge graph to determine neighboring nodes, that is, take , traverse In semantically enhanced knowledge graph All neighbor nodes on ; Step 205-4, using the embedding model to vectorize the neighbor relationship description to obtain the neighbor relationship description vector , wherein the neighbor relationship description refers to the entity not in the initial entity list Neighbor nodes in With the corresponding explicit entity Description of the relationship between; Step 205-5, calculating the problem vector and a first similarity between the neighbor relationship description vector; Step 205-6: If the first similarity is greater than the first similarity threshold , then the corresponding neighbor node Add to the initial entity list In the above example, we get the updated entity list; Step 205-7, taking the updated entity list as a new initial entity list, returning to step 205-3, and obtaining a final entity list; Step 205-8: After the expansion is completed, a mixed entity set including the explicit entities and implicit entities is obtained according to the final entity list, that is, .

[0024] Step 206: Using the large language model to determine the subgraph Can the entity information and relationship information between entities answer user questions? , and obtain the first judgment result.

[0025] Step 207: if the first judgment result is yes, the entity information and the relationship information between entities in the subgraph are used as the first context information, the first prompt information is constructed according to the first context information and the user question, and the final response is generated by using the large language model based on the first prompt information. , that is, generate answers corresponding to user questions.

[0026] Step 208: If the first judgment result is no, the large language model is prompted to determine that in addition to the entity information and the relationship information between entities in the subgraph, other relevant entity information is required, and deep extraction is performed. Specifically, from the mixed related sentence set extract relevant entity information, use the relevant entity information and the entity information and the relationship information between entities in the subgraph as second context information, construct second prompt information according to the second context information and the user question, and generate a final response based on the second prompt information using the large language model , that is, generating an answer corresponding to the user's question, wherein the set of mixed-related sentences is a set of sentences in the subgraph that are related to mixed entities and the relationship between mixed entities.

[0027] Extract relevant entity information from a collection of mixed related sentences (for the required entity information , from a collection of mixed related sentences ), including: (1) Use the embedding model to embed the required entity information and the mixed related sentence set Each sentence in the text is vectorized to obtain the required entity information vector and sentence vector , wherein the required entity information refers to the entity information in the subgraph for which the first judgment result is no; (2) Calculate the required entity vector and the sentence vector The semantic similarity between (3) Retrieve the semantic similarity greater than the threshold The target sentence set , that is, according to the semantic similarity being greater than the semantic similarity threshold The corresponding sentences construct the target sentence set; (4) Using a large language model to extract the target sentence set Extract relevant entity information .

[0028] The following takes the retrieval enhancement generation for the question "At what age was XXX the ResNet published" as an example to specifically explain the graph enhancement retrieval method provided in this embodiment.

[0029] Before performing retrieval enhancement generation, it is necessary to first build a semantically enhanced knowledge graph on several documents provided by the user. The method flow is as follows: Figure 2 shown.

[0030] like Figure 3 As shown, this embodiment provides a specific example of a graph enhancement retrieval method, including: Step 1: Use the "en_core_web_sm" language model to parse the document Perform sentence segmentation, use the "cl100k_base" model as the word segmentation model, and calculate the number of tokens for each sentence. When segmenting text, set the text block size to , the total number of tokens does not exceed Several consecutive sentences are divided into a text block, and we get .

[0031] Step 2: For each text block , prompt "gpt-4o-mini" to extract entity information of the specified entity type, including entity name, entity type, and entity description. The specific prompt for entity extraction is "Given a text document and a list of entity types, all entities need to be identified. For each identified entity, the following information is extracted:\n-Entity name: the name of the entity in the text\n-Entity type: one of the following types: {entity type}\n-Entity description: a comprehensive description of the entity\n\nText:\n{input text}\nOutput:". After entity information extraction, continue to prompt "gpt-4o-min" to extract the relationship between the extracted entities. The prompt for relationship extraction is: "Given a text document and a list of entities, identify all tuples (source entity, target entity) that are clearly related to each other. For each pair of related entities, extract the following information: \n-Source entity\n-Target entity\n-Relation description: Description of the relationship between the source entity and the target entity\n-Reference: Sentences in the text that can prove this relationship\n\nEntity: \n{Entity}\nText: \n{Input text}\nOutput: ". The output result of the parsing model is obtained and . Tips for "gpt-4o-mini" model evaluation The evaluation prompt is: "Your task is to score each text in the given list based on its information content. Texts with more detailed information have higher scores. The score range is 0 to 10 (including 0 and 10). Returns in JSON format\nText:\n{input_text}\nOutput:". For scores greater than or equal to the threshold Sentences ,like Appearing Entity Then Map to ,like For Entity and The relationship between Map to , get the sentence set and entity set And the mapping relationship of the relationship set , thus constructing Semantic Enhanced Knowledge Graph .merge have to Semantic Enhanced Knowledge Graph .

[0032] Step 3: For The entity node collection , pre-classify according to entity category, use the "text-embedding-3-small" model as the embedding model, vectorize "<entity name>:<entity description>" as the vector representation of the entity, and calculate the cosine similarity between similar entities: for n-dimensional vector , the cosine similarity calculation formula is as follows: in, Represent n-dimensional vectors, Represents vectors Data for each dimension.

[0033] The similarity is higher than the threshold Add association edges to entities to build an entity relationship diagram ,in . Prompt "gpt-4o-mini" model, judge the relationship diagram The same entity in the entity node set of all connected subgraphs in the . The judgment prompt is "According to the entity description, group all entities in the given list that refer to the same real-world entity.\nEntity list:\n{entity}\nOutput:". Merge semantically enhanced knowledge graph on the same entity.

[0034] Step 4: For the problem "At what age did someone publish ResNet?" prompts the "gpt-4o-mini" model to extract all explicit entities , the prompt for extracting entities is "Extract entities from the given text and return them as a JSON list as follows:\nText:\n{input text}\nOutput:". The entities "XXX" and "ResNet" are extracted.

[0035] Step 5: The explicit entity collection extracted in step 4 Based on this, the subgraph is expanded and the entity list is maintained , the explicit entity collection Add the entity in the entity list , for a list of entities Entities in the semantically enhanced knowledge graph The neighbor nodes on the vectorized user questions are represented by the “text-embedding-3-small” model as the embedding model. ,have to and the relationship information between the entity and its neighbors ,have to ,calculate and The cosine similarity of , then add the neighbor to the entity list , repeat this process until the entity list All entities in have been visited. This results in an entity set containing explicit entities and implicit entities. , and based on the entity collection Enhance knowledge graph from semantics Extract subgraphs from .

[0036] Step 6, prompt "gpt-4o-mini" to judge the sub-graph Whether the entity and relationship information provided can answer the user's question . The judgment prompt is "Please determine whether the given knowledge graph can support answering the question. If it can, output "yes"; otherwise, output "no". \nStandard: The knowledge graph must contain all the information required to fully answer the question. \nKnowledge graph: \n{knowledge graph}\nQuestion: \n{question}\nOutput:". If the answer can be given, the entity and relationship information will be used as context and user question Assemble together into a prompt, so that the "gpt-4o-mini" can finally respond .

[0037] Step 7, prompt "gpt-4o-mini" to determine what other entity information is needed in addition to the entity relationship information provided in step 6. The judgment prompt is "What specific entity information is needed to answer this question? \nOutput:", the output result of the parsing model requires the information "date of birth" of the entity "someone" and the information "date of publication" of the entity "ResNet". Related sentence collection Retrieve sentences related to specific information from the text. Use "text-embedding-3-small" as the embedding model to vectorize the text and vectorize the required entity information separately. and sentence collection For each sentence in . Calculate and sentence collection The cosine similarity of each sentence in , retrieve the sentences with similarity greater than the threshold The prompt "gpt-4o-mini" extracts specific information from the retrieved sentences. The extraction prompt is "Extract the information of the entity based on the provided context, and only output the extracted information.\nEntity: {Entity}\nInformation: {Attribute}\nContext:\n{Context}\nOutput:". The specific information "Date of Birth" of the entity "XXX" is "XXX was born in 1984", and the specific information "Date of Publication" of the entity "ResNet" is "ResNet was published in 2015".

[0038] Step 8: Combine the entity and relationship information provided in step 6 with the entity-specific information extracted in step 7 as context and user questions Assemble together into a prompt, so that the "gpt-4o-mini" can finally respond .

[0039] This embodiment involves a search enhancement generation method, which first uses a large language model to extract rich structured relationship information and semantic information from the original document and constructs a semantically enhanced knowledge graph; then, based on the semantically enhanced knowledge graph, an efficient search enhancement generation method is proposed to answer user questions. The method includes: 1) For the original text document, perform text segmentation, use a large language model to extract information, and build a semantically enhanced knowledge graph; 2) Based on the semantically enhanced knowledge graph, an efficient retrieval enhancement generation method is proposed. Explicit entities are extracted according to user questions, and implicit entities are retrieved on the semantically enhanced knowledge graph. The large language model is used to extract relevant entity information from the semantically enhanced knowledge graph, and then the answer is returned by assembling prompt words and calling the large model.

[0040] Compared with traditional knowledge graphs, the above-mentioned retrieval enhancement generation method provided in this embodiment can provide richer structured relationship information and semantic information (constructing the relationship between the knowledge graph and the original document, enhancing the detailed information of the entity and the semantic information of the knowledge graph), effectively improving the accuracy of question and answering; proposing a deep extraction scheme to extract the specific information required for a specific entity according to needs, rather than extracting specified entity information when constructing the knowledge graph, so that the method of this embodiment has universality.

[0041] Example 2 This embodiment provides a retrieval enhancement generation device based on a semantically enhanced knowledge graph, including: A document acquisition module is used to acquire original text documents; A semantically enhanced knowledge graph construction module, used to construct a semantically enhanced knowledge graph based on the entity information and inter-entity relationship information extracted from the original text document, wherein the semantically enhanced knowledge graph includes an entity set, a relationship set between entities, a related sentence set, and a mapping relationship set, wherein the related sentence set refers to a sentence set related to entities and inter-entity relationships, and the mapping relationship set refers to a set of mapping relationships between sentences in the original text document and target objects, and the target objects are entity nodes and relationship edges in the knowledge graph; A subgraph construction module, used for obtaining a subgraph according to the explicit entity set and the semantically enhanced knowledge graph; A judgment module is used to use a large language model to judge whether the entity information and the relationship information between entities in the subgraph can answer the user's question, and obtain a first judgment result; if the first judgment result is yes, the entity information and the relationship information between entities in the subgraph are used as the first context information, and a first prompt information is constructed according to the first context information and the user's question; based on the first prompt information, a large language model is used to generate an answer corresponding to the user's question; if the first judgment result is no, relevant entity information is extracted from a set of mixed related sentences, and the relevant entity information and the entity information and the relationship information between entities in the subgraph are used as the second context information, and a second prompt information is constructed according to the second context information and the user's question; based on the second prompt information, a large language model is used to generate an answer corresponding to the user's question, wherein the set of mixed related sentences is a set of sentences in the subgraph that are related to mixed entities and relationships between mixed entities.

[0042] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0043] This article uses specific examples to illustrate the principles and implementation methods of this application. The description of the above embodiments is only used to help understand the method and core ideas of this application. At the same time, for those skilled in the art, according to the ideas of this application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as limiting this application.

Claims

1. A retrieval enhancement generation method based on semantically enhanced knowledge graph, characterized in that: The retrieval enhancement generation method based on semantically enhanced knowledge graph includes: Get the original text document; According to the entity information and the relationship information between entities extracted from the original text document, a semantically enhanced knowledge graph is constructed, wherein the semantically enhanced knowledge graph includes an entity set, a relationship set between entities, a related sentence set, and a mapping relationship set, wherein the related sentence set refers to a sentence set related to entities and relationships between entities, and the mapping relationship set refers to a set of mapping relationships between sentences in the original text document and target objects, wherein the target objects are entity nodes and relationship edges in the knowledge graph; Obtaining a subgraph according to the explicit entity set and the semantically enhanced knowledge graph; Using the large language model, determining whether the entity information and the relationship information between entities in the subgraph can answer the user's question, and obtaining a first determination result; If the first judgment result is yes, the entity information and the relationship information between entities in the subgraph are used as the first context information, and the first prompt information is constructed according to the first context information and the user question; Based on the first prompt information, using a large language model to generate an answer corresponding to the user's question; If the first judgment result is no, extracting relevant entity information from the mixed related sentence set, taking the relevant entity information and the entity information and the relationship information between entities in the subgraph as the second context information, and constructing the second prompt information according to the second context information and the user question, wherein the mixed related sentence set is a set of sentences in the subgraph related to the mixed entities and the relationship between the mixed entities; Based on the second prompt information, a large language model is used to generate an answer corresponding to the user's question.

2. The retrieval enhancement generation method based on semantically enhanced knowledge graph according to claim 1 is characterized in that: The process of extracting entity information and relationship information between entities from the original text document specifically includes: Performing document segmentation on the original text document to obtain a text block set including a plurality of text blocks; Segmenting the original text document into sentences using a language model to obtain a sentence set containing a plurality of sentences; Calculate the number of tokens of each sentence in the sentence set using the word segmentation model; Divide consecutive sentences whose total token number does not exceed the set text block size into a text block; Construct a text block set based on all the text blocks; The entity information and the inter-entity relationship information are extracted from the text block set.

3. The retrieval enhancement generation method based on semantically enhanced knowledge graph according to claim 2 is characterized in that: According to the entity information and the relationship information between entities extracted from the original text document, a semantically enhanced knowledge graph is constructed, which specifically includes: Constructing a text block semantically enhanced knowledge graph according to each text block in the text collection; Merging all the semantically enhanced knowledge graphs of the text blocks to obtain the semantically enhanced knowledge graph of the original text document; Constructing a text block semantically enhanced knowledge graph according to each text block in the text collection specifically includes: Extracting entity information and entity relationship information of a specified entity type from each of the text blocks using a large language model, wherein the entity information includes an entity name, an entity type, and an entity description, and the entity relationship information includes a source entity, a target entity, a relationship description, and a relationship basis; According to the entity information and entity relationship information of the specified entity type extracted, a text block entity set and a text block entity relationship set are constructed, wherein the text block entity relationship set includes several entity relationships in the text block entity set; Using a large language model to evaluate the information content score of the sentences in each of the text blocks; When the information score is not less than the information threshold and the entity appearing in the sentence belongs to the text block entity set, establishing a mapping relationship between the sentence and the entity appearing in the sentence; According to the mapping relationship between sentences and entities appearing in the sentences, a mapping relationship set between text content of a text block and entities is constructed; When the information score is not less than the information threshold and the sentence is derived from the entity relationship in the text block entity relationship set, establishing a mapping relationship between the sentence and the entity relationship in the text block entity relationship set; According to the mapping relationship between the sentence and the entity relationship in the text block entity relationship set, a mapping relationship set between the text block text content and the entity relationship is constructed; Determine a text block mapping relationship set and a text block related sentence set according to the mapping relationship set between the text block text content and entities and the mapping relationship set between the text block text content and entities; The text block semantically enhanced knowledge graph is constructed according to the text block entity set, the text block entity relationship set, the text block related sentence set and the text block mapping relationship set.

4. The retrieval enhancement generation method based on semantically enhanced knowledge graph according to claim 3 is characterized in that: A subgraph is obtained according to the explicit entity set and the semantically enhanced knowledge graph, specifically including: Performing entity alignment processing on the semantically enhanced knowledge graph in sequence to obtain an aligned semantically enhanced knowledge graph; Entities appearing in user questions are extracted using a large language model to obtain an explicit entity set containing several explicit entities; According to the explicit entity set, subgraph expansion is performed on the aligned semantically enhanced knowledge graph to obtain a mixed entity set including the explicit entities and implicit entities, wherein the implicit entity refers to an entity involved in the user question but not appearing in the user question; A subgraph is extracted from the aligned semantically enhanced knowledge graph according to the mixed entity set.

5. The retrieval enhancement generation method based on semantically enhanced knowledge graph according to claim 4 is characterized in that: The semantically enhanced knowledge graph is sequentially subjected to entity alignment and entity merging processing to obtain an aligned semantically enhanced knowledge graph, specifically comprising: Pre-classifying entities according to the entity types to obtain an entity type set including a plurality of entities of different types; Clustering entities of the same type in the entity type set based on semantic similarity to obtain a clustered entity set; Using the large language model, determining whether the clustered entities in the clustered entity set are the same entity, and obtaining a second determination result; If the second judgment result is yes, the entity nodes belonging to the same entity in the semantically enhanced knowledge graph are merged.

6. The retrieval enhancement generation method based on semantically enhanced knowledge graph according to claim 4 is characterized in that: According to the explicit entity set, subgraph expansion is performed on the aligned semantically enhanced knowledge graph to obtain a mixed entity set including the explicit entities and implicit entities, specifically including: Adding explicit entities in the explicit entity set to an initial entity list; Use the embedding model to vectorize the user's questions and obtain the question vector; For each explicit entity in the initial list, traverse the semantically enhanced knowledge graph to determine neighboring nodes; Using the embedding model to perform text vectorization on the neighbor relationship description to obtain a neighbor relationship description vector, wherein the neighbor relationship description refers to a relationship description between a neighbor node not in the initial entity list and a corresponding explicit entity; Calculating a first similarity between the question vector and the neighbor relationship description vector; If the first similarity is greater than a first similarity threshold, adding the corresponding neighbor node to the initial entity list to obtain an updated entity list; Take the updated entity list as a new initial entity list, and return to step "for each explicit entity in the initial list, traverse the semantically enhanced knowledge graph to determine neighboring nodes" to obtain a final entity list; A mixed entity set including the explicit entities and implicit entities is obtained according to the final entity list.

7. The retrieval enhancement generation method based on semantically enhanced knowledge graph according to claim 1 is characterized in that: Extract relevant entity information from a set of mixed related sentences, including: Using an embedding model to perform text vectorization on the required entity information and each sentence in the mixed related sentence set to obtain a required entity information vector and a sentence vector, wherein the required entity information refers to the entity information in the subgraph for which the first judgment result is no; Calculating the semantic similarity between the required entity vector and the sentence vector; Construct a target sentence set according to the sentences whose semantic similarity is greater than the semantic similarity threshold; A large language model is used to extract relevant entity information from the target sentence set.

8. The retrieval enhancement generation method based on semantically enhanced knowledge graph according to claim 5 is characterized in that: Clustering entities of the same type in the entity type set based on semantic similarity to obtain a clustered entity set, specifically including: Using the embedding model, text vectorization is performed on the entity names and corresponding entity descriptions of entities of the same type in the entity type set to obtain each entity vector; Calculate a second similarity based on the entity vector; Adding associated edges to entities whose second similarity is higher than a second similarity threshold to construct an entity relationship graph; Extract all connected subgraphs in the entity relationship graph; A clustered entity set is constructed according to the nodes included in the connected subgraph.

9. A retrieval enhancement generation device based on semantically enhanced knowledge graph, characterized in that: The retrieval enhancement generation device based on the semantic enhancement knowledge graph includes: A document acquisition module is used to acquire original text documents; A semantically enhanced knowledge graph construction module, used to construct a semantically enhanced knowledge graph based on the entity information and inter-entity relationship information extracted from the original text document, wherein the semantically enhanced knowledge graph includes an entity set, a relationship set between entities, a related sentence set, and a mapping relationship set, wherein the related sentence set refers to a sentence set related to entities and inter-entity relationships, and the mapping relationship set refers to a set of mapping relationships between sentences in the original text document and target objects, and the target objects are entity nodes and relationship edges in the knowledge graph; A subgraph construction module, used for obtaining a subgraph according to the explicit entity set and the semantically enhanced knowledge graph; A judgment module is used to use a large language model to judge whether the entity information and the relationship information between entities in the subgraph can answer the user's question, and obtain a first judgment result; if the first judgment result is yes, the entity information and the relationship information between entities in the subgraph are used as the first context information, and a first prompt information is constructed according to the first context information and the user's question; based on the first prompt information, a large language model is used to generate an answer corresponding to the user's question; if the first judgment result is no, relevant entity information is extracted from a set of mixed related sentences, and the relevant entity information and the entity information and the relationship information between entities in the subgraph are used as the second context information, and a second prompt information is constructed according to the second context information and the user's question; based on the second prompt information, a large language model is used to generate an answer corresponding to the user's question, wherein the set of mixed related sentences is a set of sentences in the subgraph that are related to mixed entities and relationships between mixed entities.

Citation Information

Patent Citations

  • Knowledge graph question-answering method for sub-graph retrieval optimization

    CN117149974A

  • Large language model enhanced question and answer generation method

    CN118013051A

  • Retrieval enhancement generation system based on medical knowledge graph

    CN118394952A

  • Retrieval enhancement generation system and method based on knowledge graph

    CN118643134A

  • Multi-dimensional knowledge index and application thereof

    US20200012733A1

Cited By

  • Retrieval and tracking method and device for scientific research information

    CN121233697A

  • Question answering method and system based on LLM fusion knowledge graph and retrieval enhancement generation

    CN121542378A