Question and answer generation method and device, electronic equipment, storage medium and program product
Through a mixture of multi-grained retrieval strategies and hierarchical retrieval mechanisms, the elements of entities, relationships and text block granularity are comprehensively retrieved from the knowledge graph, and the problem of information splitting in multi-grained and multi-theme queries is solved, and logically consistent, comprehensive and accurate answers are generated.
Patent Information
- Application Number
- CN202510529448.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-25
- Publication Date
- 2025-08-12
AI Technical Summary
When the prior art generates answers by extracting entities and relationships from the knowledge graph in complex queries with multiple granularity and multi-themes, it is easy to cause information fragmentation and lack of coherence, and cannot meet the need for global generalization and detailed description.
The mixed multi-grained search strategy and hierarchical search mechanism are adopted to comprehensively search elements of entity granularity, relation granularity and text block granularity from the knowledge graph, and combine pre-trained answer generation models to generate multi-grained search text to ensure the comprehensiveness and logical consistency of the answers.
Avoid information fragmentation in complex queries with multiple granularity and multi-themes, and generate accurate answers consistent with the user query context, which improves the comprehensiveness and logical consistency of the answers and provides a more accurate and efficient query service experience.
Smart Images

Figure CN120470084A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a question and answer generation method, device, electronic device, storage medium and program product. Background Art
[0002] The Knowledge Graph (KG)-based Retrieval-Augmented Generation (RAG) method is commonly used by Large Language Models (LLMs) to process queries in highly specialized fields such as finance, technology, medicine, life sciences, and engineering. It is used to improve the accuracy and reliability of LLM answers.
[0003] Specifically, a knowledge graph is a structured representation of real-world entities, their attributes, and relationships. It primarily consists of nodes representing entities and edges representing relationships. Structured knowledge graph information possesses explicit semantic expression and logical reasoning capabilities. During the knowledge construction phase, natural language processing (NLP) technology is used to extract entities and relationships from unstructured text to construct the knowledge graph. During the reasoning query phase of question and answer generation, user query input is matched with entity and relationship information in the knowledge graph. Similar entity and relationship information is retrieved and extracted, serving as context for the larger language model to generate the final answer.
[0004] However, simply extracting similar entity information and similar relationship information from the knowledge graph to generate answers to user queries is prone to information fragmentation and lack of coherence in complex queries involving multiple granularities and topics, and cannot meet the needs of both global summary and detailed description. Summary of the Invention
[0005] The present invention provides a question-answer generation method, device, electronic device, storage medium and program product to solve the problem in the prior art of generating answers by simply extracting entities and relationships related to user query input from a knowledge graph, which is prone to information fragmentation and lack of coherence in complex queries involving multiple granularities and multiple topics, and realizes an answer generation solution with excellent global and detailed understanding capabilities for complex queries.
[0006] The present invention provides a question-answer generation method, comprising: Based on the user query text, obtain keyword text, concept text and pseudo context; Based on the keyword text, determining a first element set of entity granularity from a pre-built knowledge graph; Based on the concept text, determining a second element set of relationship granularity from the knowledge graph; Based on the pseudo context, determining a third element set of text block granularity from the knowledge graph; Determining a multi-granularity retrieval text of the user query text based on the first element set, the second element set, and the third element set; Inputting the multi-granularity search text into a pre-trained answer generation model to obtain an answer text output by the answer generation model; The first element set, the second element set and the third element set are all composed of entity elements, relationship elements and text block elements of the knowledge graph.
[0007] According to a question-answer generation method provided by the present invention, determining a multi-granularity retrieval text of the user query text based on the first element set, the second element set, and the third element set includes: Based on the first element set, the second element set and the third element set, a total element set is determined; for each element in the total element set, a score of each element is determined based on the similarity between each element and the user query text and the weight corresponding to the element category of each element; target entity elements, target relationship elements and target text block elements are determined from the total element set in order from high to low scores; based on the target entity elements, the target relationship elements and the target text block elements, the multi-granularity retrieval text is determined; the element category is a fully matched element, a dual-granularity element or a single-granularity element; the fully matched element is an element that appears in the first element set, the second element set and the third element set at the same time; the dual-granularity element is an element that appears in the first element set and the third element set at the same time, or an element that appears in the second element set and the third element set at the same time; the single-granularity element is an element that appears in any one of the first element set, the second element set and the third element set.
[0008] According to a question-answer generation method provided by the present invention, the knowledge graph is pre-constructed based on the following method: Based on the text logical unit division graph, the text is constructed to obtain the original text block; based on the original text block and the extraction prompt word template, the original entity text and the original relationship text are extracted from the original text block; based on the original text block, the original entity text and the original relationship text, the knowledge graph is constructed; the nodes of the knowledge graph correspond to the entity elements determined based on the original entity text; the edges of the knowledge graph correspond to the relationship elements determined based on the original relationship text; the node is associated with the first original text block element; the first original text block element is determined based on the original text block of the original relationship text corresponding to the node extracted; the edge is associated with the second original text block element; the second original text block element is determined based on the original text block of the original entity text corresponding to the edge extracted.
[0009] According to a question-answer generation method provided by the present invention, constructing the knowledge graph based on the original text block, the original entity text, and the original relationship text includes: Based on the original text block, the original entity text, the original relationship text and the description generation prompt word template, keyword information corresponding to the original entity text and concept information corresponding to the original relationship text are generated; based on the entity name and keyword information of the original entity text, a first similarity between the original entity texts is determined, and the original entity texts with the first similarity greater than a first preset threshold are disambiguated to obtain disambiguated entity texts; based on the relationship name and concept information of the original relationship texts, a second similarity between the original relationship texts is determined, and the original relationship texts with the second similarity greater than a second preset threshold are disambiguated to obtain disambiguated relationship texts; based on the third similarity between the summary texts of the original text blocks, the original text blocks with the third similarity greater than a third preset threshold are deduplicated to obtain deduplicated text blocks; the summary text is generated based on the summary information of the original text block and the summary generation prompt word template; based on the disambiguated entity texts, the disambiguated relationship texts and the deduplicated text blocks, the knowledge graph is constructed.
[0010] According to a question-answer generation method provided by the present invention, determining a first element set of entity granularity from a pre-constructed knowledge graph based on the keyword text includes: Determine similar nodes of the keyword text from the knowledge graph; determine a first entity element, a first relationship element and a first text block element based on the similar nodes, the adjacent edges of the similar nodes and the first-order neighbor nodes of the similar nodes; the first entity element is the entity element corresponding to the similar node and the first-order neighbor node; the first relationship element is the relationship element corresponding to the adjacent edge; the first text block element is the text block element associated with the similar node, the first-order neighbor node and the adjacent edge respectively; determine the first element set based on the first entity element, the first relationship element and the first text block element.
[0011] According to a question-answer generation method provided by the present invention, determining a second element set of relationship granularity from the knowledge graph based on the concept text includes: Determine the similar edges of the concept text from the knowledge graph; determine the second entity element, the second relationship element, and the second text block element based on the similar edges and the adjacent nodes of the similar edges; the second entity element is the entity element corresponding to the adjacent node; the second relationship element is the relationship element corresponding to the similar edge; the second text block element is the text block element associated with the adjacent node and the similar edge respectively; determine the second element set based on the second entity element, the second relationship element, and the second text block element.
[0012] According to a question-answer generation method provided by the present invention, determining a third element set of text block granularity from the knowledge graph based on the pseudo context includes: Determine similar text block elements of the pseudo-context from the knowledge graph, and determine associated nodes and associated edges associated with the similar text block elements; determine a third entity element, a third relationship element, and a third text block element based on the similar text block elements, the associated nodes, and the associated edges; the third entity element is the entity element corresponding to the associated node; the third relationship element is the relationship element corresponding to the associated edge; the third text block element is determined based on the similar text block elements; and determine the third element set based on the third entity element, the third relationship element, and the third text block element.
[0013] According to a question-answer generation method provided by the present invention, obtaining keyword text, concept text and pseudo context based on user query text includes: The user query text is input into a pre-trained keyword extraction model to obtain the keyword text output by the keyword extraction model; the user query text is input into a pre-trained concept extraction model to obtain the concept text output by the concept extraction model; the user query text is input into a pre-trained semantic extension model to obtain the pseudo context output by the semantic extension model; the keyword extraction model and the concept extraction model are implemented based on a large language model; the semantic extension model is implemented based on a zero-sample retrieval algorithm.
[0014] The present invention also provides a question-answer generation device, comprising: A query text processing module is used to obtain keyword text, concept text and pseudo context based on the user query text; An entity granularity text acquisition module, configured to determine a first element set of entity granularity from a pre-built knowledge graph based on the keyword text; A relational granularity text acquisition module, configured to determine a second element set of relational granularity from the knowledge graph based on the concept text; A text block granularity text acquisition module, configured to determine a third element set of text block granularity from the knowledge graph based on the pseudo context; a multi-granularity text fusion module, configured to determine a multi-granularity retrieval text of the user query text based on the first element set, the second element set, and the third element set; An answer text generation module, configured to input the multi-granularity search text into a pre-trained answer generation model to obtain an answer text output by the answer generation model; The first element set, the second element set and the third element set are all composed of entity elements, relationship elements and text block elements of the knowledge graph.
[0015] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and running on the processor, wherein when the processor executes the computer program, it implements any of the above-described question and answer generation methods.
[0016] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements any of the above-described question-answer generation methods.
[0017] The present invention also provides a computer program product, comprising a computer program, which, when executed by a processor, implements any of the above-described question-answer generation methods.
[0018] The question-and-answer generation method, device, electronic device, storage medium, and program product provided by the present invention use a hybrid multi-granularity retrieval strategy and a hierarchical retrieval mechanism to comprehensively and comprehensively retrieve entity elements, relationship elements, and text block elements of three granularities, namely, entity granularity, relationship granularity, and text block granularity, from the knowledge graph, which helps to improve retrieval accuracy and retain the text hierarchical information of the user query. Combined with the generation capability of the answer generation model, it can avoid information fragmentation and lack of coherence in complex queries involving multiple granularities and multiple topics, and generate accurate answers that are consistent with the user query context and have excellent global and detailed understanding capabilities, ensuring the comprehensiveness and logical consistency of the answers, and providing users with a more accurate and efficient query service experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the technical solutions in the present invention or the prior art, a brief introduction is given below to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0020] Figure 1 This is one of the flow charts of the question-answer generation method provided by the present invention.
[0021] Figure 2 It is a schematic diagram of the process of constructing a knowledge graph provided by the present invention.
[0022] Figure 3 This is the second flow chart of the question and answer generation method provided by the present invention.
[0023] Figure 4 It is a structural diagram of the question and answer generating device provided by the present invention.
[0024] Figure 5 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION
[0025] To make the objectives, technical solutions, and advantages of the present invention more clear, the technical solutions of the present invention will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the embodiments described are only some of the embodiments of the present invention, not all of them. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts shall fall within the scope of protection of the present invention.
[0026] It should be noted that, in the description of the present invention, the terms "comprises," "includes," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus comprising a series of elements includes not only those elements but also other elements not explicitly listed, or also includes elements inherent to such process, method, article, or apparatus. Those skilled in the art will understand the specific meanings of the above terms in the present invention based on specific circumstances.
[0027] The terms "first," "second," and the like in the present invention are used to distinguish similar objects, and are not used to describe a particular order or precedence. It should be understood that the terms used in this manner are interchangeable where appropriate, such that embodiments of the present invention can be implemented in orders other than those illustrated or described herein. Furthermore, the objects distinguished by "first," "second," and the like generally refer to a class of objects, and do not limit the number of objects. For example, the first object may be one or more.
[0028] The following combination Figure 1-Figure 5 The question and answer generation method, device, electronic device, storage medium and program product provided by the present invention are described.
[0029] Figure 1 This is one of the flow charts of the question-answer generation method provided by the present invention, such as Figure 1 As shown, the question and answer generation method includes but is not limited to steps 101 to 106.
[0030] It should be noted that the execution entity of the question-and-answer generation method provided by the present invention is the corresponding question-and-answer generation device, which can specifically be a server or computer device, such as a mobile phone, tablet computer, laptop computer, PDA, vehicle-mounted electronic device, wearable device, ultra-mobile personal computer (UMPC), netbook or personal digital assistant (PDA), etc.
[0031] Step 101: Based on the user query text, obtain keyword text, concept text and pseudo context.
[0032] The user query text is a text determined based on the user query input (including but not limited to text input, voice input, image input, etc.).
[0033] Keyword text is the specific information of user query text at the entity granularity.
[0034] Conceptual text is the abstract information of user query text at the relational granularity.
[0035] Pseudo-context is a semantic extension or hypothetical supplement to the user query text, which is used to enrich the expression of the user query text.
[0036] Specifically, NLP technologies including but not limited to rule-based information extraction methods and LLM-based information extraction methods are used to extract keyword text and concept text from user query text, and semantic expansion and other processing are performed on the user query text to obtain pseudo context.
[0037] Step 102: Based on the keyword text, determine a first element set of entity granularity from a pre-constructed knowledge graph.
[0038] Among them, the pre-constructed knowledge graph includes nodes corresponding to entity elements and edges corresponding to relationship elements, and both nodes and edges are associated with text block elements.
[0039] Specifically, the user query text is analyzed and rewritten to generate a first search formula at the entity granularity. This first search formula is executed to retrieve entity elements corresponding to similar nodes similar to the keyword text from the pre-built knowledge graph. Based on the similar nodes, relevant edges are determined, and then the relationship elements corresponding to the relevant edges are determined, as well as the text block elements associated with the similar nodes and relevant edges. A first element set is constructed based on the entity elements, relationship elements, and text block elements retrieved at the entity granularity.
[0040] It is understandable that the first element set of entity granularity includes entity elements, relationship elements, and text block elements of the knowledge graph. Similarly, the second element set of relationship granularity and the third element set of text block granularity both include entity elements, relationship elements, and text block elements of the knowledge graph.
[0041] That is, the first element set, the second element set, and the third element set are all composed of entity elements, relationship elements, and text block elements of the knowledge graph.
[0042] Step 103: Based on the concept text, determine a second element set of relationship granularity from the knowledge graph.
[0043] Specifically, the user query text is analyzed and rewritten to generate a second search formula at a relational granularity. This second search formula retrieves relationship elements that are similar to the concept text and correspond to similar edges from the pre-built knowledge graph. Related nodes are identified based on similar edges, and then the entity elements corresponding to the related nodes are determined, as well as the text block elements associated with the similar edges and related nodes. A second element set is constructed based on the entity elements, relationship elements, and text block elements retrieved at the relational granularity.
[0044] Step 104: Based on the pseudo context, determine a third element set of text block granularity from the knowledge graph.
[0045] Specifically, the user query text is analyzed and rewritten to generate a third search formula at the text block granularity. This third search formula is executed to retrieve text block elements similar to the pseudo-context from the pre-built knowledge graph. Based on the associated nodes and associated edges associated with the text block elements, the entity elements corresponding to the associated nodes and the relationship elements corresponding to the associated edges are determined. A third element set is constructed based on the entity elements, relationship elements, and text block elements retrieved at the text block granularity.
[0046] It should be noted that when the question-answer generation method provided by the present invention is implemented, step 102, step 103 and step 104 are executed simultaneously or successively; when step 102, step 103 and step 104 are executed successively, the present invention does not limit the order of execution.
[0047] Step 105: Determine a multi-granularity retrieval text of the user query text based on the first element set, the second element set, and the third element set.
[0048] Specifically, a mixed granularity information retrieval of entity granularity, relationship granularity and text block granularity is performed. After obtaining element sets of entity granularity, relationship granularity and text block granularity, all entity elements, relationship elements and text block elements in the first element set, the second element set and the third element set are directly used to generate a multi-granularity retrieval text corresponding to the user query text, or all entity elements, relationship elements and text block elements are deduplicated and then a multi-granularity retrieval text of the user query text is generated, or important elements are screened out from all entity elements, relationship elements and text block elements and a multi-granularity retrieval text of the user query text is generated based on the important elements.
[0049] Step 106: Input the multi-granularity search text into the pre-trained answer generation model to obtain the answer text output by the answer generation model.
[0050] Among them, the answer generation model is built based on LLM.
[0051] Specifically, an answer generation model is pre-built based on the LLM and pre-trained. Furthermore, multi-granularity search text generated from entity elements, relationship elements, and text block elements at entity, relationship, and text block granularity retrieved from the knowledge graph is input into the answer generation model. The answer generation model combines a pre-set query answer instruction template for guiding the answer generation model and the multi-granularity search text to organize the context structure, ultimately generating and outputting the answer text, and feeding the answer text back to the user.
[0052] During the reasoning query phase, traditional knowledge graph-based search enhancement solutions typically focus on extracting entities and relationships at a single granularity, lacking the ability to preserve the original text block elements, and thus struggle to achieve comprehensive expression of multi-level semantics. Some search enhancement solutions based on complex clustering community concepts also suffer from high graph construction overhead and slow construction speed.
[0053] The question-answer generation method provided by the present invention uses a hybrid multi-granularity retrieval strategy and a hierarchical retrieval mechanism to comprehensively and comprehensively retrieve entity elements, relationship elements and text block elements of three granularities, namely entity granularity, relationship granularity and text block granularity, from the knowledge graph, which helps to improve retrieval accuracy and retain the text hierarchical information of user queries. Combined with the generation capability of the answer generation model, it can avoid information fragmentation and lack of coherence in complex queries involving multiple granularities and multiple topics, and generate accurate answers that are consistent with the user query context and have excellent global and detailed understanding capabilities, ensuring the comprehensiveness and logical consistency of the answers, and providing users with a more accurate and efficient query service experience.
[0054] Based on the above embodiment, as an optional embodiment, determining the multi-granularity search text of the user query text based on the first element set, the second element set, and the third element set includes: Determining a total set of elements based on the first set of elements, the second set of elements, and the third set of elements; For each element in the total set of elements, determining a score for each element based on a similarity between each element and the user query text and a weight corresponding to an element category of each element; Determining the target entity element, the target relationship element, and the target text block element from the total set of elements in descending order of scores; Determining the multi-granularity search text based on the target entity element, the target relationship element, and the target text block element; The element category is a fully matched element, a dual-granularity element or a single-granularity element; the fully matched element is an element that appears simultaneously in the first element set, the second element set and the third element set; the dual-granularity element is an element that appears simultaneously in the first element set and the third element set, or an element that appears simultaneously in the second element set and the third element set; the single-granularity element is an element that appears in any one of the first element set, the second element set and the third element set.
[0055] Specifically, when generating a multi-granularity retrieval text of a user query text, based on the first element set, the second element set and the third element set, the same elements in the first element set, the second element set and the third element set are merged to obtain a total set of elements that are different from each other.
[0056] For each element in the total element set, the element category of the element is determined according to whether the first element set, the second element set, and the third element set include the element.
[0057] If the first element set, the second element set and the third element set all contain the element, that is, the element appears in the retrieval results of entity granularity, relationship granularity and text block granularity at the same time, the element category of the element is determined to be a fully matched element; if the first element set and the third element set contain the element at the same time, or the second element set and the third element set contain the element at the same time, that is, the element appears in the retrieval results of entity granularity and text block granularity at the same time, or appears in the retrieval results of entity granularity and relationship granularity at the same time, the element category of the element is determined to be a dual-granularity element; if only any one of the first element set, the second element set and the third element set includes the element, that is, the element only appears in the retrieval results of entity granularity, relationship granularity or text block granularity, the element category of the element is determined to be a single-granularity element.
[0058] It can be understood that the element category of the element is determined based on the set category and the number of sets of elements included in the first element set, the second element set, and the third element set.
[0059] Furthermore, for each element in the total set of elements, a score of the element is calculated based on the similarity between the element and the user query text, and a weight corresponding to the element category of the element and reflecting the confidence level.
[0060] For example, if entity element A appears in both the first element set and the third element set, that is, entity element A is a dual-granularity element, the score Score_A of entity element A is calculated based on the similarity such as the semantic similarity between entity element A and the user query text, and the weight a corresponding to the dual-granularity element.
[0061] For another example, if text block element B only appears in the second element set, that is, text block element B is a single-granularity element, the score Score_B of text block element B is calculated based on the similarity between text block element B and the user query text, and the weight b corresponding to the single-granularity element.
[0062] Repeat the steps of determining the element category of each element in the total set of elements and calculating the score of each element to obtain the scores of all elements in the total set of elements.
[0063] All elements in the total element set are sorted in descending order of scores, and a preset number or a preset proportion of elements are determined from all the sorted elements as target entity elements, target relationship elements, and target text block elements.
[0064] Finally, a multi-granularity retrieval text of the user query text is generated according to the target entity elements, target relationship elements and target text block elements.
[0065] Optionally, the weight corresponding to the fully matched element is greater than the weight corresponding to the double-granularity element, and the weight corresponding to the double-granularity element is greater than the weight corresponding to the single-granularity element.
[0066] For example, a perfect match element has a weight of 0.3, a double-grained element has a weight of 0.2, and a single-grained element has a weight of 0.1.
[0067] For another example, the weight of a fully matched element is 0.3, the weight of the double-granularity elements contained in the first element set and the third element set is 0.25, the weight of the double-granularity elements contained in the second element set and the third element set is 0.15, the weight of the single-granularity elements contained in the first element set is 0.12, the weight of the single-granularity elements contained in the second element set is 0.1, and the weight of the single-granularity elements contained in the third element set is 0.8.
[0068] Optionally, the similarity between each element and the user query text is determined based on semantic similarity such as BM25 or vector similarity between the embedding vector corresponding to each element and the embedding vector corresponding to the user query text.
[0069] In one embodiment, the calculation formula for determining the score of each element based on the similarity between each element and the user query text and the weight corresponding to the element category of each element is as follows: ; in, For elements score; For elements In the Elements category The weight under Belongs to the element category ,but For element categories The corresponding weight, if the element Does not belong to the element category ,but is 0; is the similarity operation; Query text for the user.
[0070] Since traditional knowledge graph-based retrieval enhancement generation solutions usually focus on the extraction of entities and relationships at a single granularity, when filtering retrieval results, they are usually based on a single scoring mechanism, simply sorting the retrieval results and then filtering them, and are unable to consider the differences in information from sources of different granularities.
[0071] The question-answer generation method provided by the present invention performs intersection and union operations on the elements in the first element set, the second element set, and the third element set, supplements the missing information through the union operation, and screens the information with consistent multi-granularity through the intersection operation. It performs a cross-granularity cross-comparison on the retrieval results of the three granularities of entity, relationship, and text block, combines the semantic similarity calculation in the comprehensive score calculation of the retrieval results, and introduces weights determined according to the categories and quantities of elements contained in the element sets of different granularities. It can take into account the differences in information from different granularity sources, balance the weight distribution between multi-granularity information, avoid the one-sidedness that may be caused by a single scoring mechanism, and thus screen highly reliable questions. The system combines the reliability of content and removes duplicates to more accurately reflect the comprehensive value of the search results and optimize the search performance. By designing a hierarchical weight mechanism for complete match sets, dual-granularity intersection sets, and single-granularity sets, it ensures the accuracy and comprehensiveness of the search results. Overall, through a mixed-granularity retrieval strategy and a dynamic fusion sorting strategy based on multiple granularities, it can conduct comprehensive retrieval and screening of information at three granularities: entities, relationships, and text blocks, providing a reliable input basis for answer generation. Combined with the generation capabilities of large language models, it can further optimize the comprehensiveness and logical consistency of the generated answers that are consistent with the user's query context, providing users with a more accurate and efficient query service experience.
[0072] Based on the above embodiment, as an optional embodiment, the knowledge graph is pre-constructed based on the following method: Construct text based on the text logical unit division map to obtain the original text block; Extracting original entity text and original relationship text from the original text block based on the original text block and the extraction prompt word template; Constructing the knowledge graph based on the original text block, the original entity text, and the original relationship text; The nodes of the knowledge graph correspond to entity elements determined based on the original entity text; The edges of the knowledge graph correspond to the relationship elements determined based on the original relationship text; The node is associated with a first original text block element; the first original text block element is determined based on extracting the original text block of the original relationship text corresponding to the node; The edge is associated with a second original text block element; the second original text block element is determined based on extracting the original text block of the original entity text corresponding to the edge.
[0073] Chunk is the basic unit for building graphs.
[0074] Specifically, Figure 2 This is a schematic diagram of the process of constructing a knowledge graph provided by the present invention, such as Figure 2 As shown, the graph-constructed text is intelligently divided into original text blocks according to text logical units such as paragraphs, titles, formulas, and tables, retaining semantic integrity.
[0075] An extraction scheme based on a large language model is adopted to traverse each original text block. Based on the original text block and the extraction prompt word template, the original text block is used as the input of the large language model. Combined with the extraction prompt word template (also called content extraction prompt word template), the large prediction model is used to extract the original entity text and original relationship text from the original text block.
[0076] Further based on the original text block, original entity text and original relationship text, the entity elements corresponding to the nodes of the knowledge graph are determined according to the original entity text; the relationship elements corresponding to the nodes of the knowledge graph are determined according to the original relationship text; the first original text block element is determined based on the original text block of the original entity text corresponding to the entity element corresponding to each node, and each node and its corresponding first original text block element are associated; the second original text block element is determined based on the original relationship text block corresponding to the relationship element corresponding to each edge, and each edge and its corresponding second original text block element are associated, thereby constructing a multi-granularity knowledge graph with entities as nodes, relationships as edges, and both nodes and edges are associated with text blocks.
[0077] Optionally, the graph construction text is obtained based on: Parse the graph construction documents in various formats input by the user, read the first text content of the graph construction document, convert the image content of the graph construction document into the second text content based on the optical character recognition (OCR) technology, and determine the graph construction text according to the first text content and the second text content.
[0078] Optionally, the graph construction text is standardized into Markdown format text to ensure that various file formats are input into the large language model in a unified and easy-to-understand format.
[0079] Optionally, tables, formulas, and other contents in the atlas construction text are converted into Markdown and LaTeX syntax to ensure the compatibility and readability of the structured data.
[0080] The question-answer generation method provided by the present invention obtains text blocks by dividing the graph to construct text, extracts original entity text and original relationship text in units of text blocks, and designs a knowledge graph nested structure with entities as nodes, relationships as edges, and both nodes and edges are associated with text blocks. It covers multi-level information of fine-grained entities, relationships, and coarse-grained text blocks, while retaining the original text content, and can support multi-granularity and efficient retrieval of knowledge graphs.
[0081] Based on the above embodiment, as an optional embodiment, constructing the knowledge graph based on the original text block, the original entity text, and the original relationship text includes: Generate a prompt word template based on the original text block, the original entity text, the original relationship text and the description, and generate keyword information corresponding to the original entity text and concept information corresponding to the original relationship text; Determining a first similarity between the original entity texts based on the entity names and keyword information of the original entity texts, and performing disambiguation processing on the original entity texts whose first similarity is greater than a first preset threshold to obtain disambiguated entity texts; Determining a second similarity between the original relationship texts based on the relationship names and concept information of the original relationship texts, and performing disambiguation processing on the original relationship texts whose second similarity is greater than a second preset threshold to obtain disambiguated relationship texts; performing deduplication processing on original text blocks having a third similarity greater than a third preset threshold value based on a third similarity between summary texts of the original text blocks to obtain deduplicated text blocks; wherein the summary text is generated based on summary information of the original text blocks and a summary generation prompt word template; The knowledge graph is constructed based on the disambiguated entity text, the disambiguated relationship text and the deduplicated text blocks.
[0082] Specifically, combined Figure 2 As shown, an extraction scheme based on a large language model is adopted, and the original text blocks of the divided graph-constructed text, the original entity text extracted from the original text blocks, and the original relationship text are used as input. A prompt word template is generated in combination with a pre-set description to generate keyword information corresponding to the original entity text and concept information corresponding to the original relationship text.
[0083] The entity name and keyword information of the original entity text are used as the entity description content, the first similarity between the original entity texts is calculated according to the entity description content, and the original entity texts whose first similarity is greater than a first preset threshold are used to construct a repeated entity set. Then, the large language model is used to perform entity disambiguation judgment and disambiguation processing on the entity texts in the repeated entity set to obtain disambiguated entity text.
[0084] The relationship name and concept information of the original relationship text are used as the relationship description content, the second similarity between the original relationship texts is calculated according to the relationship description content, and the original relationship texts whose second similarity is greater than the second preset threshold are used to construct a repeated relationship set. Then, the large language model is used to perform relationship disambiguation judgment and disambiguation processing on the relationship texts in the repeated relationship set to obtain disambiguated relationship texts.
[0085] The summary information of the original text block and the summary generation prompt word template are used to generate summary text for the original text block based on the large language model. A third similarity between the original text blocks is calculated based on the summary text. Original text blocks with third similarity greater than a third preset threshold are deduplicated to obtain deduplicated text blocks.
[0086] Based on the disambiguated entity text, disambiguated relationship text, and deduplicated text blocks, a multi-granularity knowledge graph is constructed, with entities as nodes, relationships as edges, and both nodes and edges associated with text blocks. The nodes of the knowledge graph correspond to entity elements determined based on the disambiguated entity text; the edges of the knowledge graph correspond to relationship elements determined based on the disambiguated relationship text; the nodes are associated with first deduplicated text block elements; the first deduplicated text block elements are determined based on the deduplicated text blocks extracted from the disambiguated relationship text corresponding to the nodes; the edges are associated with second deduplicated text block elements; the second deduplicated text block elements are determined based on the deduplicated text blocks extracted from the disambiguated relationship text corresponding to the edges.
[0087] Optionally, both the first similarity and the second similarity are determined based on a BM25 correlation score.
[0088] Optionally, the third similarity is determined based on an approximate match of SimHash.
[0089] Optionally, the generating of keyword information corresponding to the original entity text and concept information corresponding to the original relationship text further includes: generating keyword information corresponding to the original entity text, concept information corresponding to the original relationship text, entity extension description text and relationship extension description text.
[0090] The question-answer generation method provided by the present invention generates descriptive information such as keyword information corresponding to entity text and concept information corresponding to relationship text, disambiguates entity text and relationship text extracted from graph construction text, deduplicates text blocks, and constructs a knowledge graph based on disambiguated entity text, disambiguated relationship text and deduplicated text blocks. This can ensure the accurate construction of the knowledge graph, avoid the knowledge graph from including too much repeated information, and support multi-granularity efficient retrieval, thereby ensuring the efficient organization and semantic integrity of graph information.
[0091] Optionally, the construction of the knowledge graph further includes: storing relevant Schema information of the entity elements corresponding to each node, the relationship elements corresponding to each edge, and the text block elements associated with each node and each edge.
[0092] Optionally, the knowledge graph construction further includes: generating a text block vector based on the summary text of the text block; generating an entity vector based on the entity name, keyword information, and extended entity description text; generating a relationship vector based on the relationship name, concept information, and extended relationship description text; and constructing a vector database based on the text block vectors, entity vectors, and relationship vectors; the vector database is used to support the retrieval of multi-granularity element sets (i.e., first element sets, second element sets, and third element sets) from the knowledge graph. By constructing the vector database, an index can be generated to support semantic retrieval, ensuring accurate retrieval of relevant content during the query dialogue.
[0093] Based on the above embodiment, as an optional embodiment, determining a first element set of entity granularity from a pre-built knowledge graph based on the keyword text includes: Determining similar nodes of the keyword text from the knowledge graph; Determine a first entity element, a first relationship element, and a first text block element based on the similar node, the adjacent edge of the similar node, and the first-order neighbor node of the similar node; the first entity element is the entity element corresponding to the similar node and the first-order neighbor node; the first relationship element is the relationship element corresponding to the adjacent edge; and the first text block element is the text block element associated with the similar node, the first-order neighbor node, and the adjacent edge, respectively; The first element set is determined based on the first entity element, the first relationship element, and the first text block element.
[0094] Specifically, Figure 3 This is the second flow chart of the question-answer generation method provided by the present invention. Figure 3 As shown, after obtaining the keyword text of the user query text, all keyword texts are traversed, and nodes corresponding to entity vectors with a similarity greater than a certain threshold to the keyword text are retrieved from the knowledge graph as similar nodes for the keyword text. Based on the structure of the knowledge graph, the edges directly connected to the similar nodes are regarded as adjacent edges, and the nodes connected to the similar nodes by an edge are regarded as first-order neighbor nodes. The entity elements corresponding to the similar nodes and first-order neighbor nodes are determined as first entity elements, the relationship elements corresponding to the adjacent edges are determined as first relationship elements, and the text block elements associated with the similar nodes, first-order neighbor nodes, and adjacent edges are determined as first text block elements. The first element set of entity granularity is constructed using the first entity element, the first relationship element, and the first text block element.
[0095] Based on the above embodiment, as an optional embodiment, determining a second element set of relationship granularity from the knowledge graph based on the concept text includes: Determining similar edges of the concept text from the knowledge graph; Determining a second entity element, a second relationship element, and a second text block element based on the similar edge and the adjacent node of the similar edge; the second entity element is the entity element corresponding to the adjacent node; the second relationship element is the relationship element corresponding to the similar edge; and the second text block element is the text block element associated with the adjacent node and the similar edge, respectively; The second element set is determined based on the second entity element, the second relationship element, and the second text block element.
[0096] Specifically, combined Figure 3 As shown, after obtaining the concept text of the user query text, all concept texts are traversed and nodes corresponding to entity vectors with a similarity greater than a certain threshold with the concept text are retrieved from the knowledge graph as similar edges of the concept text. Based on the structure of the knowledge graph, nodes directly connected to similar edges are regarded as adjacent nodes. The entity element corresponding to the adjacent node is determined as the second entity element, the relationship element corresponding to the similar edge is determined as the second relationship element, and the text block element associated with the adjacent node and the similar edge is determined as the second text block element. Based on the second entity element, the second relationship element, and the second text block element, a second element set of relationship granularity is constructed.
[0097] Based on the above embodiment, as an optional embodiment, determining a third element set of text block granularity from the knowledge graph based on the pseudo context includes: Determining similar text block elements of the pseudo context from the knowledge graph, and determining associated nodes and associated edges associated with the similar text block elements; Determining a third entity element, a third relationship element, and a third text block element based on the similar text block elements, the associated nodes, and the associated edges; the third entity element is the entity element corresponding to the associated nodes; the third relationship element is the relationship element corresponding to the associated edges; and the third text block element is determined based on the similar text block elements; The third element set is determined based on the third entity element, the third relationship element, and the third text block element.
[0098] Specifically, combined Figure 3As shown, after obtaining the pseudo-context of the user's query text, all pseudo-contexts are traversed and dense vector retrieval is performed using the pseudo-context. Similar text block elements corresponding to text block vectors whose similarity to the pseudo-context exceeds a certain threshold are retrieved from the knowledge graph and used as third text block elements. Based on the nodes and edges associated with the similar text block elements, associated nodes and associated edges are determined. The entity elements corresponding to the associated nodes are determined as third entity elements, and the relationship elements corresponding to the associated edges are determined as third relationship elements. Based on the third entity elements, third relationship elements, and third text block elements, a third element set at the text block granularity is constructed.
[0099] Traditional search methods are often based on a single granularity, such as entity- or relationship-based retrieval, which lacks cross-granularity connectivity. Furthermore, single-granularity retrieval can easily lead to information omissions and fail to fully respond to users' diverse query needs for both specific and abstract questions.
[0100] The question-answer generation method provided by the present invention adopts a hybrid granularity information retrieval strategy to retrieve and recall similar nodes of keyword text in entity granularity, similar edges of concept text in relationship granularity, and similar text block elements of pseudo-context in text block granularity from a pre-constructed knowledge graph based on the user query text, and further expands the retrieval results of the three granularities of entity, relationship, and text block based on the knowledge graph structure, the association relationship between text block elements and nodes and edges. That is, the adjacency structure of the knowledge graph is used to expand the retrieval results, associate more potential relevant information, significantly improve the coverage and accuracy of information recall, ensure the comprehensiveness and relevance of information recall, and realize the associated recall of multi-level semantic information, which helps to improve retrieval accuracy and retain the text-level information of user queries. It can avoid the problems of information fragmentation and lack of coherence in complex queries involving multiple granularities and multiple topics, and generate accurate answers that are consistent with the user query context and have excellent global and detailed, concrete and abstract understanding capabilities, providing users with a more accurate and efficient query service experience.
[0101] Based on the above embodiment, as an optional embodiment, obtaining keyword text, concept text and pseudo context based on the user query text includes: Inputting the user query text into a pre-trained keyword extraction model to obtain the keyword text output by the keyword extraction model; Inputting the user query text into a pre-trained concept extraction model to obtain the concept text output by the concept extraction model; Inputting the user query text into a pre-trained semantic extension model to obtain the pseudo context output by the semantic extension model; The keyword extraction model and the concept extraction model are implemented based on a large language model; the semantic extension model is implemented based on a zero-sample retrieval algorithm.
[0102] Specifically, before obtaining the keyword text, concept text and pseudo-context of the user query text, a keyword extraction model and a concept extraction model are pre-built based on the large language model, and a semantic extension model is built based on zero-sample retrieval algorithms such as the HyDE (Hypothetical Document Embeddings) algorithm. The pre-training of the keyword extraction model, concept extraction model and semantic extension model is completed.
[0103] Combine Figure 3 As shown in the figure, the user query text is input into a pre-trained keyword extraction model, which extracts specific information from the user query text to determine the keyword text and outputs the keyword text. The user query text is then input into a pre-trained concept extraction model, which extracts abstract information from the user query text to determine the concept text and outputs the concept text. The user query text is then input into a pre-trained semantic extension model, which performs semantic extension or hypothetical supplementation to obtain a rich pseudo-context. Subsequently, the keyword text, concept text, and pseudo-context are used instead of the unprocessed user query text to retrieve and recall related information from the knowledge graph.
[0104] The question-answer generation method provided by the present invention expands the semantic scope of the user query text through a zero-sample retrieval algorithm to obtain the pseudo-context of the user query text, which can enhance the ability to handle fuzzy and open questions. It also flexibly and accurately extracts keyword text and concept text in the user query text through a large language model, realizing a more optimal hybrid granularity retrieval strategy and better covering the relevant content of the user query text.
[0105] In one embodiment, the user query text is obtained in the following manner: based on the user query input, the original query text is determined; the original query text is input into a pre-trained context optimization model to obtain the user query text output by the context optimization model; the context optimization model is constructed based on a large language model; the context optimization model is used to perform the following processing on the original query text in sequence: the pronouns in the original query text are parsed into keywords or concepts to achieve semantic parsing and restoration of fuzzy pronouns; the model identifies the core topic of the original query text, and determines whether to maintain the current topic or switch the topic based on the core topic; and the context content that is highly relevant to the original query text is screened out, and low-relevance or outdated information is filtered out.
[0106] By resolving fuzzy references, maintaining topic coherence, and filtering out contextual redundancies, the system accurately parses the semantic relationships of user queries and dynamically adjusts query content to ensure that responses are consistent with the contextual semantics. This effectively avoids information omissions and semantic deviations in continuous query and topic switching scenarios, providing greater adaptability in conversational context processing.
[0107] Figure 4 It is a structural diagram of the question-answer generation device provided by the present invention. Figure 4 As shown, the question and answer generation device includes but is not limited to a query text processing module 401, an entity granularity text acquisition module 402, a relationship granularity text acquisition module 403, a text block granularity text acquisition module 404, a multi-granularity text fusion module 405 and an answer text generation module 406.
[0108] The query text processing module 401 is used to obtain keyword text, concept text and pseudo context based on the user query text.
[0109] The entity granularity text acquisition module 402 is used to determine a first element set of entity granularity from a pre-built knowledge graph based on the keyword text.
[0110] The relational granularity text acquisition module 403 is used to determine a second element set of relational granularity from the knowledge graph based on the concept text.
[0111] The text block granularity text acquisition module 404 is used to determine a third element set of text block granularity from the knowledge graph based on the pseudo context.
[0112] The multi-granularity text fusion module 405 is configured to determine a multi-granularity retrieval text of the user query text based on the first element set, the second element set, and the third element set.
[0113] The answer text generation module 406 is used to input the multi-granularity search text into the pre-trained answer generation model to obtain the answer text output by the answer generation model.
[0114] The first element set, the second element set and the third element set are all composed of entity elements, relationship elements and text block elements of the knowledge graph.
[0115] It should be noted that the question and answer generation device provided by the present invention can execute the question and answer generation method described in any of the above embodiments during specific operation, which will not be described in detail in this embodiment.
[0116] The question-and-answer generation device provided by the present invention uses a hybrid multi-granularity retrieval strategy and a hierarchical retrieval mechanism to comprehensively and comprehensively retrieve entity elements, relationship elements and text block elements of three granularities, namely entity granularity, relationship granularity and text block granularity, from the knowledge graph, which helps to improve retrieval accuracy and retain the text hierarchical information of user queries. Combined with the generation capability of the answer generation model, it can avoid information fragmentation and lack of coherence in complex queries involving multiple granularities and multiple topics, and generate accurate answers that are consistent with the user query context and have excellent global and detailed understanding capabilities, ensuring the comprehensiveness and logical consistency of the answers, and providing users with a more accurate and efficient query service experience.
[0117] Figure 5 Schematic diagram of the structure of the electronic device provided by the present invention, such as Figure 5 As shown, the electronic device may include: a processor (Processor) 510, a communication interface (Communications Interface) 520, a memory (Memory) 530 and a communication bus 540, wherein the processor 510, the communication interface 520, and the memory 530 communicate with each other through the communication bus 540. The processor 510 can call the logical instructions in the memory 530 to execute the question and answer generation method provided by any of the above embodiments, and the question and answer generation method includes but is not limited to the following steps: based on the user query text, obtaining keyword text, concept text and pseudo context; based on the keyword text, determining a first element set of entity granularity from a pre-built knowledge graph; based on the concept text, determining a second element set of relationship granularity from the knowledge graph; based on the pseudo context, determining a third element set of text block granularity from the knowledge graph; based on the first element set, the second element set and the third element set, determining a multi-granularity retrieval text of the user query text; inputting the multi-granularity retrieval text into a pre-trained answer generation model to obtain the answer text output by the answer generation model; the first element set, the second element set and the third element set are all composed of entity elements, relationship elements and text block elements of the knowledge graph.
[0118] Furthermore, the logic instructions in the aforementioned memory 530 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the portion that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product, stored in a storage medium, includes several instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the methods described in various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as a USB flash drive, a mobile hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.
[0119] On the other hand, the present invention also provides a computer program product, which includes a computer program, which can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the question and answer generation method provided in any of the above embodiments, and the question and answer generation method includes but is not limited to the following steps: based on the user query text, obtaining keyword text, concept text and pseudo context; based on the keyword text, determining a first element set of entity granularity from a pre-constructed knowledge graph; based on the concept text, determining a second element set of relationship granularity from the knowledge graph; based on the pseudo context, determining a third element set of text block granularity from the knowledge graph; based on the first element set, the second element set and the third element set, determining a multi-granularity retrieval text of the user query text; inputting the multi-granularity retrieval text into a pre-trained answer generation model to obtain the answer text output by the answer generation model; the first element set, the second element set and the third element set are all composed of entity elements, relationship elements and text block elements of the knowledge graph.
[0120] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the question and answer generation method provided in any of the above embodiments, the question and answer generation method including but not limited to the following steps: based on the user query text, obtaining keyword text, concept text and pseudo context; based on the keyword text, determining a first element set of entity granularity from a pre-constructed knowledge graph; based on the concept text, determining a second element set of relationship granularity from the knowledge graph; based on the pseudo context, determining a third element set of text block granularity from the knowledge graph; based on the first element set, the second element set and the third element set, determining a multi-granularity retrieval text of the user query text; inputting the multi-granularity retrieval text into a pre-trained answer generation model to obtain the answer text output by the answer generation model; the first element set, the second element set and the third element set are all composed of entity elements, relationship elements and text block elements of the knowledge graph.
[0121] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, i.e., they may be located in one location or distributed across multiple network units. Some or all of the modules may be selected based on actual needs to achieve the objectives of the present embodiment. Persons of ordinary skill in the art will be able to understand and implement the present invention without inventive effort.
[0122] Through the above description of the embodiments, those skilled in the art will clearly understand that each embodiment can be implemented using software plus a necessary general-purpose hardware platform, or of course, hardware. Based on this understanding, the essence of the above technical solution, or the portion that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a magnetic disk, or an optical disk, and includes a number of instructions for causing a computer device (such as a personal computer, server, or network device) to execute the methods described in each embodiment or certain portions of the embodiments.
[0123] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present invention.
Claims
1. A question-answer generation method, characterized in that: include: Based on the user query text, obtain keyword text, concept text and pseudo context; Based on the keyword text, determining a first element set of entity granularity from a pre-built knowledge graph; Based on the concept text, determining a second element set of relationship granularity from the knowledge graph; Based on the pseudo context, determining a third element set of text block granularity from the knowledge graph; Determining a multi-granularity retrieval text of the user query text based on the first element set, the second element set, and the third element set; Inputting the multi-granularity search text into a pre-trained answer generation model to obtain an answer text output by the answer generation model; The first element set, the second element set and the third element set are all composed of entity elements, relationship elements and text block elements of the knowledge graph.
2. The question-answer generation method according to claim 1, wherein: The determining of the multi-granularity retrieval text of the user query text based on the first element set, the second element set, and the third element set includes: Determining a total set of elements based on the first set of elements, the second set of elements, and the third set of elements; For each element in the total set of elements, determining a score for each element based on a similarity between each element and the user query text and a weight corresponding to an element category of each element; Determining the target entity element, the target relationship element, and the target text block element from the total set of elements in descending order of scores; Determining the multi-granularity search text based on the target entity element, the target relationship element, and the target text block element; The element category is a fully matched element, a dual-granularity element or a single-granularity element; the fully matched element is an element that appears simultaneously in the first element set, the second element set and the third element set; the dual-granularity element is an element that appears simultaneously in the first element set and the third element set, or an element that appears simultaneously in the second element set and the third element set; the single-granularity element is an element that appears in any one of the first element set, the second element set and the third element set.
3. The question-answer generation method according to claim 1, wherein: The knowledge graph is pre-built based on the following: Construct text based on the text logical unit division map to obtain the original text block; Extracting original entity text and original relationship text from the original text block based on the original text block and the extraction prompt word template; Constructing the knowledge graph based on the original text block, the original entity text, and the original relationship text; The nodes of the knowledge graph correspond to entity elements determined based on the original entity text; The edges of the knowledge graph correspond to the relationship elements determined based on the original relationship text; The node is associated with a first original text block element; the first original text block element is determined based on extracting the original text block of the original relationship text corresponding to the node; The edge is associated with a second original text block element; the second original text block element is determined based on extracting the original text block of the original entity text corresponding to the edge.
4. The question-answer generation method according to claim 3, wherein: The step of constructing the knowledge graph based on the original text block, the original entity text, and the original relationship text includes: Generate a prompt word template based on the original text block, the original entity text, the original relationship text and the description, and generate keyword information corresponding to the original entity text and concept information corresponding to the original relationship text; Determining a first similarity between the original entity texts based on the entity names and keyword information of the original entity texts, and performing disambiguation processing on the original entity texts whose first similarity is greater than a first preset threshold to obtain disambiguated entity texts; Determining a second similarity between the original relationship texts based on the relationship names and concept information of the original relationship texts, and performing disambiguation processing on the original relationship texts whose second similarity is greater than a second preset threshold to obtain disambiguated relationship texts; performing deduplication processing on original text blocks having a third similarity greater than a third preset threshold value based on a third similarity between summary texts of the original text blocks to obtain deduplicated text blocks; wherein the summary text is generated based on summary information of the original text blocks and a summary generation prompt word template; The knowledge graph is constructed based on the disambiguated entity text, the disambiguated relationship text and the deduplicated text blocks.
5. The question-answer generation method according to claim 1, wherein: The determining of a first element set of entity granularity from a pre-built knowledge graph based on the keyword text includes: Determining similar nodes of the keyword text from the knowledge graph; Determine a first entity element, a first relationship element, and a first text block element based on the similar node, the adjacent edge of the similar node, and the first-order neighbor node of the similar node; the first entity element is the entity element corresponding to the similar node and the first-order neighbor node; the first relationship element is the relationship element corresponding to the adjacent edge; and the first text block element is the text block element associated with the similar node, the first-order neighbor node, and the adjacent edge, respectively; The first element set is determined based on the first entity element, the first relationship element, and the first text block element.
6. The question-answer generation method according to claim 1, wherein: The determining of a second element set of relationship granularity from the knowledge graph based on the concept text includes: Determining similar edges of the concept text from the knowledge graph; Determining a second entity element, a second relationship element, and a second text block element based on the similar edge and the adjacent node of the similar edge; the second entity element is the entity element corresponding to the adjacent node; the second relationship element is the relationship element corresponding to the similar edge; and the second text block element is the text block element associated with the adjacent node and the similar edge, respectively; The second element set is determined based on the second entity element, the second relationship element, and the second text block element.
7. The question-answer generation method according to claim 1, wherein: The step of determining a third element set of text block granularity from the knowledge graph based on the pseudo context includes: Determining similar text block elements of the pseudo context from the knowledge graph, and determining associated nodes and associated edges associated with the similar text block elements; Determining a third entity element, a third relationship element, and a third text block element based on the similar text block elements, the associated nodes, and the associated edges; the third entity element is the entity element corresponding to the associated nodes; the third relationship element is the relationship element corresponding to the associated edges; and the third text block element is determined based on the similar text block elements; The third element set is determined based on the third entity element, the third relationship element, and the third text block element.
8. The question-answer generation method according to claim 1, wherein: The step of obtaining keyword text, concept text, and pseudo-context based on the user query text includes: Inputting the user query text into a pre-trained keyword extraction model to obtain the keyword text output by the keyword extraction model; Inputting the user query text into a pre-trained concept extraction model to obtain the concept text output by the concept extraction model; Inputting the user query text into a pre-trained semantic extension model to obtain the pseudo context output by the semantic extension model; The keyword extraction model and the concept extraction model are implemented based on a large language model; the semantic extension model is implemented based on a zero-sample retrieval algorithm.
9. A question-answer generation device, characterized in that: include: A query text processing module is used to obtain keyword text, concept text and pseudo context based on the user query text; An entity granularity text acquisition module, configured to determine a first element set of entity granularity from a pre-built knowledge graph based on the keyword text; A relational granularity text acquisition module, configured to determine a second element set of relational granularity from the knowledge graph based on the concept text; A text block granularity text acquisition module, configured to determine a third element set of text block granularity from the knowledge graph based on the pseudo context; a multi-granularity text fusion module, configured to determine a multi-granularity retrieval text of the user query text based on the first element set, the second element set, and the third element set; An answer text generation module, configured to input the multi-granularity search text into a pre-trained answer generation model to obtain an answer text output by the answer generation model; The first element set, the second element set and the third element set are all composed of entity elements, relationship elements and text block elements of the knowledge graph.
10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that: When the processor executes the computer program, the question and answer generating method according to any one of claims 1 to 8 is implemented.
11. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the question and answer generating method according to any one of claims 1 to 8 is implemented.
12. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the question and answer generating method according to any one of claims 1 to 8 is implemented.
Citation Information
Cited By
Data query method and device, equipment, storage medium and program product
CN122173635A