Retrieval enhancement generation method and device, equipment and medium
By constructing a prior knowledge base with first and second hypergraph structures, the problem of large language models ignoring multi-entity relationships and logical dependencies in professional domains is solved, and higher quality and more logical answer generation is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-22
- Publication Date
- 2026-03-10
AI Technical Summary
When building domain-specific knowledge bases, large language models tend to overlook complex multi-entity relationships and logical dependencies, resulting in low-quality answer generation and potentially generating incorrect or incoherent answers when faced with complex logical problems.
A prior knowledge base is constructed, comprising a first hypergraph structure and a second hypergraph structure. Entity associations in the first hypergraph structure are unconstrained, while entity associations in the second hypergraph structure satisfy predicate definition constraints. Answers are generated through predicate transitive reasoning and bidirectional expansion operations.
It improves the quality and logic of answer generation, enabling it to more comprehensively capture diverse relationships and complex logical dependencies in professional fields, thereby enhancing the ability of large language models to answer questions in professional domains.
Smart Images

Figure CN121638460A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of natural language processing technology, and in particular to a retrieval enhancement generation method, apparatus, device, and medium. Background Technology
[0002] Retrieval-enhanced generation is a technical architecture that combines the advantages of information retrieval and text generation. When a large language model needs to answer a user's question or generate text according to the user's needs, in addition to relying on the knowledge acquired during the training of the large language model, it can also retrieve the most relevant information to the current question or task in real time from external knowledge sources such as document libraries and web pages, so that the large language model can generate the final answer or text.
[0003] However, when building knowledge bases and retrieving information, large language models are prone to logical defects such as ignoring transitive associations or mistakenly supplementing non-transitive associations. This makes it impossible to model the extensive multi-entity relationships and complex logical dependencies in professional knowledge, which in turn affects the quality of answer generation. Summary of the Invention
[0004] Therefore, it is necessary to provide a retrieval enhancement generation method, apparatus, device, and medium to address the aforementioned technical problems, thereby resolving the shortcomings of low retrieval enhancement generation quality in the prior art and improving the quality of answer generation.
[0005] The following technical solution is adopted in this specification: This specification provides a method for generating enhanced search results, including: Using professional terms in natural language documents of a professional domain as knowledge entities and semantic relationships between professional terms as entity associations, a first hypergraph structure and a second hypergraph structure including knowledge entities and entity associations are constructed. In the first hypergraph structure, the semantic relationships corresponding to entity associations are unconstrained; in the second hypergraph structure, the semantic relationships corresponding to entity associations satisfy the predefined predicate definition constraints. A prior knowledge base is constructed based on entities and entity relationships in the first and second hypergraph structures. Obtain the query to be answered, and extract candidate entities and their associations from the prior knowledge base; Predicate transitive reasoning is performed on candidate entities to obtain predicate-related facts; predicate-related facts are entity associations that satisfy the predicate definition constraints through semantic relations, forming entity association links by connecting candidate entities according to semantic relations; Perform bidirectional extension operations on candidate entities and their associations to obtain multi-entity relation facts. Multi-entity relation facts are multi-entity association links formed by connecting extended entities or extended entity associations that have semantic relationships with candidate entities and their associations according to semantic relationships. The target answer to the query to be answered is generated based on predicate-related facts and multi-relational facts.
[0006] Furthermore, the predicate-passive reasoning on the candidate entities specifically includes: Obtain the preset predicate transitive rules: in, Represents the predefined set of predicate transitive rules; Indicates the first The predicate transitive rule is used in the first predicate transitive rule. The predicate and the first The predicates are passed between each other. , The total number of predicate passing rules; and Each represents a predefined set of predicates. The Middle The and the first Each predicate definition; Predicate-passing inference is performed on candidate entities based on predefined predicate-passing rules: in, Indicates by the first Candidate entities , No. Candidate entities as well as and Entity association between The resulting first predicate transitive feasible path, Conforms to the Each predicate definition; Indicates a feasible path for predicate passing; Indicates by the first Candidate entities , No. Candidate entities as well as and Entity association between The resulting feasible path for passing the second predicate. Conforms to the Each predicate definition; Indicates the first Candidate entities The predicate-related facts obtained by performing predicate transitive reasoning.
[0007] Furthermore, the construction includes a first hypergraph structure and a second hypergraph structure of knowledge entities and entity associations, specifically including: Construct a first prompt word template and a second prompt word template: The first prompt word template is used to guide the preset large language model to extract knowledge entities from natural language documents and associate them with entities without preset constraints; the second prompt word template is used to guide the preset large language model to extract knowledge entities from natural language documents and associate them with entities that conform to preset predicate definitions. The first prompt word template and the natural language document are input into a preset large language model. The preset large language model is used to extract the association between the knowledge entities in the natural language document and the entities without preset constraints. The first hypergraph structure is constructed based on the association between the knowledge entities and the entities without preset constraints. The second prompt word template and the natural language document are input into the preset large language model. The knowledge entities of the natural language document are extracted through the preset large language model and associated with entities that conform to the preset predicate definition. The second hypergraph structure is constructed based on the association between the knowledge entities and entities that conform to the preset predicate definition.
[0008] Furthermore, the second prompt word template specifically includes: A set of predefined association types, including multiple predefined association types, each of which is used to classify the predicate type corresponding to the entity association; A predefined set of predicate definitions, including general predicate definitions and at least one configurable domain-specific predicate definition; Entity recognition prompt templates are used to guide the preset large language model to recognize knowledge entities; Low-order predicate association recognition prompt word templates are used to guide the preset large language model to recognize binary entity associations that conform to the preset predicate definition; Higher-order predicate association recognition prompt word templates are used to guide the preset large language model to recognize multi-entity associations that conform to the preset predicate definition; A keyword set, comprising multiple keywords, each used to characterize the core concept or theme of a specific text unit in a natural language document; The predicate constraint reference example is used to provide a specific operational process and judgment criteria for identifying and extracting entity associations that conform to the preset predicate definition from natural language documents to a pre-defined large language model.
[0009] Furthermore, the step of generating the target answer corresponding to the query to be answered based on predicate-related facts and multi-relational facts specifically includes: Extract text block fragments corresponding to predicate-related facts and multi-relational facts from natural language documents, respectively; Integrate predicate-related facts, multi-relational facts, and text blocks corresponding to predicate-related facts and multi-relational facts into enhanced knowledge input; The input of enhanced knowledge and the query to be answered are input together into a preset search enhancement prompt word template to generate input prompt words adapted to the preset large language model; Input the input prompts into a preset large language model, and then use the preset large language model to query the corresponding target answer.
[0010] Furthermore, the construction of a priori knowledge base based on entities and entity associations in the first and second hypergraph structures specifically includes: The entities and entity associations in the first and second hypergraph structures are transformed into entity vectors and hyperedge vectors by using a preset embedding model or vector function. A prior knowledge base consisting of entity vector libraries and hyperedge vector libraries is constructed based on entity vectors and hyperedge vectors.
[0011] Furthermore, the extraction of candidate entities and candidate entity associations related to the query to be answered from the prior knowledge base specifically includes: The query to be answered is encoded into a query vector using a preset encoder; Construct an entity retrieval function to calculate the entity similarity between the query vector and each entity vector in the entity vector library; select entities in the entity vector library whose entity similarity is greater than a preset entity similarity threshold as candidate entities; A hyperedge retrieval function is constructed to calculate the entity association similarity between the query vector and each hyperedge vector in the hyperedge vector library; the entity associations corresponding to hyperedges in the hyperedge vector library whose entity association similarity is greater than a preset entity association similarity threshold are selected as candidate entity associations.
[0012] This specification provides a retrieval enhancement generation apparatus, comprising: The hypergraph structure acquisition module is used to construct a first hypergraph structure and a second hypergraph structure, which include knowledge entities and entity associations, using professional terms in professional domain natural language documents as knowledge entities and semantic relationships between professional terms as entity associations. In the first hypergraph structure, the semantic relationships corresponding to entity associations are unconstrained; in the second hypergraph structure, the semantic relationships corresponding to entity associations satisfy preset predicate definition constraints. The prior knowledge base acquisition module is used to construct a prior knowledge base based on entities and entity relationships in the first and second hypergraph structures. The knowledge retrieval module is used to obtain the query to be answered and extract candidate entities and candidate entity associations related to the query from the prior knowledge base. Predicate transitive reasoning is performed on candidate entities to obtain predicate-related facts; predicate-related facts are entity associations that satisfy the predicate definition constraints through semantic relations, forming entity association links by connecting candidate entities according to semantic relations; Perform bidirectional extension operations on candidate entities and their associations to obtain multi-entity relation facts. Multi-entity relation facts are multi-entity association links formed by connecting extended entities or extended entity associations that have semantic relationships with candidate entities and their associations according to semantic relationships. The answer generation module is used to generate the target answer to the query to be answered based on predicate-related facts and multi-relational facts.
[0013] This specification provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the above-described search enhancement generation method.
[0014] This specification provides a computer device including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the above-described search enhancement generation method.
[0015] The above-mentioned technical solutions adopted in this specification can achieve the following beneficial effects: The first hypergraph structure constructed in this invention provides as many knowledge entities as possible for bidirectional expansion operations by unconstrained entity associations, ensuring that bidirectional expansion operations can obtain explicit or implicit complex associations between multiple entities, providing a more comprehensive reference for generating answers. The second hypergraph structure provides logical support for predicate transitive reasoning by entity associations conforming to the predicate definition. Predicate transitive reasoning uses the predicate definition as the logical boundary, which can sort out the complex logical links of various knowledge entities in natural language documents. Through the synergy of dual hypergraph modeling and bidirectional expansion + predicate transitive reasoning, comprehensive multi-relational facts and logically supported predicate association facts are provided for the answer, providing technical support for generating high-quality answers. Attached Figure Description
[0016] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:
[0017] Figure 1 This is one of the flowcharts illustrating the search enhancement generation method provided in this specification; Figure 2 This is the second flowchart illustrating the search enhancement generation method provided in this specification; Figure 3This is a schematic diagram of an overall framework for retrieval enhancement generation provided in this specification; Figure 4 A schematic diagram of a knowledge modeling framework provided in this specification; Figure 5 A schematic diagram illustrating a knowledge retrieval framework provided in this specification; Figure 6 This is a schematic diagram of a search enhancement generation device provided in this specification; Figure 7 This is a schematic diagram of a computer device provided for this specification. Detailed Implementation
[0018] To make the objectives, technical solutions, and advantages of this specification clearer, the technical solutions of this application will be clearly and completely described below in conjunction with specific embodiments and corresponding drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. All other embodiments obtained by those skilled in the art based on the embodiments in this specification without creative effort are within the scope of protection of this application.
[0019] The technical solution provided by this invention can be applied to question-answering scenarios based on large language models. With the rapid development of large language model technology, artificial intelligence has achieved significant results in content generation and intelligent question answering. For example, large language models can typically generate text content that meets user requirements to a certain extent, and are widely used in copywriting, creative writing, and other scenarios. By understanding user intent and answering user queries, large language models have been applied in customer service systems, search engines, virtual assistants, and other areas, optimizing the human-computer interaction experience. However, despite these advancements, large language models still face significant bottlenecks in their applications. For instance, large language models are still insufficient in understanding deep semantic logic, and may generate incorrect or incoherent answers when faced with complex, multi-step questions. The factual accuracy and controllability of the content generated by large language models are difficult to guarantee, leading to "illusion" phenomena and potentially causing information misleading risks in specific application scenarios and industry-specific fields. The answers generated by large language models depend on the timeliness and quality of the training data, and as time progresses, they may fail to cover the latest developments or specialized knowledge.
[0020] To address the aforementioned issues, the concept of "retrieval-enhanced generation technology" was proposed. This technology aims to assist large language models in generating more accurate and richer text content by retrieving relevant information from external knowledge bases. Retrieval-enhanced generation technology can alleviate the aforementioned difficulties faced by large language models to some extent. For example, loading the latest knowledge base can alleviate the problem of outdated training knowledge in large language models; displaying retrieved document fragments provides evidence for answers, enhancing the interpretability of the generated documents to a certain extent. Representative achievements in retrieval enhancement technology research include GraphRAG, LightRAG, and HtmlRAG. GraphRAG uses a knowledge graph to organize the knowledge base, achieving structured storage of unstructured text and enhancing the large language model's ability to recognize relationships between knowledge. LightRAG aims for lightweight design, focusing on improving deployment efficiency and resource utilization, enabling it to run in resource-constrained scenarios. HtmlRAG uses HTML as the external knowledge format for the RAG system to solve the information loss problem caused by converting HTML to plain text. However, despite the promising results achieved in many studies on retrieval enhancement techniques, current retrieval enhancement generation techniques face significant challenges in specific application areas characterized by high specialization, strong logical dependencies, and complex knowledge systems, and there is still room for further optimization.
[0021] First, when building knowledge bases for specific domains and generating answers for practitioners in those domains, the knowledge used in these domains often involves complex logical dependencies. This poses a challenge for large language models in terms of insufficient consideration of logical relationships during knowledge base construction and retrieval. Specifically, in complex business scenarios, there might be entity relationships like: "Entity A has logical relationship 1 with entity B, entity B has logical relationship 2 with entity C, and entity B has logical relationship 3 with entity D. Logical relationship 1 and logical relationship 2 are transitive, but logical relationship 1 and logical relationship 3 are not transitive." Therefore, ignoring the logical relationship between entity A and entity C is incorrect. Furthermore, during the logical relationship completion process, the logical relationship between entity A and entity D should not be completed. Ignoring or misjudging logical relationships during retrieval increases the difficulty of retrieval and affects retrieval quality.
[0022] Secondly, knowledge entities in specialized domains typically exhibit diverse relationships. Even ignoring predicate logic constraints, entities within a domain knowledge system still possess multiple correlations and complex dependencies. While graph-based retrieval enhancement generation techniques model relationships by representing knowledge as graph structures, they are limited to binary relations and cannot effectively model the widespread multi-entity relationships, complex logical dependencies, and higher-order relationships within professional knowledge systems. Therefore, how to address both the diverse relationships within specialized domain knowledge and varied business scenarios—simultaneously constructing a hypergraph based on graph structures and considering multi-relationships based on predicate logic—has become a pressing issue.
[0023] Based on this, the present invention provides a retrieval enhancement generation method to solve the above-mentioned defects.
[0024] The following is combined Figures 1-5 The retrieval enhancement generation method of the present invention is described.
[0025] Figure 1 This is one of the flowcharts illustrating the retrieval enhancement generation method provided by the present invention, such as... Figure 1 As shown, the method includes the following: S100. Using professional terms in natural language documents of a professional field as knowledge entities and semantic relationships between professional terms as entity associations, construct a first hypergraph structure and a second hypergraph structure including knowledge entities and entity associations. In the first hypergraph structure, the semantic relationships corresponding to entity associations are unconstrained; in the second hypergraph structure, the semantic relationships corresponding to entity associations satisfy the preset predicate definition constraints.
[0026] For example, both the first and second hypergraph structures are hypergraph data structures formed based on knowledge entities and entity associations in natural language documents. The nodes of the hypergraph correspond to knowledge entities, and the hyperedges correspond to entity associations. The difference is that the hyperedges of the first hypergraph structure have no preset constraints and directly associate all entity pairs mentioned in the document, while the hyperedges of the second hypergraph structure only retain entity associations that conform to the preset predicate definition, such as causal relationships and subordinate relationships.
[0027] S200. Construct a prior knowledge base based on entities and entity relationships in the first and second hypergraph structures.
[0028] For example, the entities and entity associations obtained from the first and second hypergraph structures are stored as entity vector libraries and hyperedge vector libraries using a unified embedding model and vector functions, so that entities and hyperedges are in the same vector space for use in subsequent knowledge retrieval steps. The embedding process is completed using preset vector embedding models such as text-embedding-3-small and BGE-M3.
[0029] S300. Obtain the query to be answered, extract candidate entities and candidate entity associations related to the query from the prior knowledge base; perform predicate transitive reasoning on the candidate entities to obtain predicate association facts; the predicate association facts are entity associations that satisfy the preset predicate definition constraints through semantic relations, and form entity association links by connecting candidate entities according to semantic relations; perform bidirectional extension operations on the candidate entities and candidate entity associations to obtain multi-relationship facts, which are multi-entity association links formed by connecting extended entities or extended entity associations that have semantic relations with the candidate entities and candidate entity associations according to semantic relations.
[0030] For example, the query to be answered is encoded into a query vector using a preset encoder; an entity retrieval function is constructed to calculate the entity similarity between the query vector and each entity vector in the entity vector library; entities in the entity vector library with an entity similarity greater than a preset entity similarity threshold are selected as candidate entities; a hyperedge retrieval function is constructed to calculate the entity association similarity between the query vector and each hyperedge vector in the hyperedge vector library; entity associations corresponding to hyperedges in the hyperedge vector library with an entity association similarity greater than a preset entity association similarity threshold are selected as candidate entity associations.
[0031] For example, when a query to be answered arrives, a hybrid retrieval strategy combining predicate transitive reasoning and bidirectional expansion is used to search the knowledge base, guiding the large language model to generate an answer by combining the original query and the retrieval results. Specifically: An entity retrieval function and a hyperedge retrieval function based on cosine similarity are defined to retrieve entities and hyperedges extracted from the question in the knowledge base. The large model extracts entities present in the query and uses the defined retrieval functions to retrieve relevant entities and hyperedges from the knowledge base. Using the obtained relevant entities, transitive reasoning is performed on the entity and its associated predicates according to the predicate transitive rules to retrieve other transitive entities, obtaining predicate association facts based on logical deduction. The predicate transitive rules consider domain-specific predicate transitive rules in addition to general predicate transitive rules. Using the obtained relevant entities and hyperedges, new entity and hyperedge information is expanded through a bidirectional expansion strategy to obtain multivariate relational facts based on a hypergraph structure.
[0032] For example, the bidirectional expansion strategy specifically refers to taking candidate entities and candidate multi-relationships related to the query to be answered as the initial starting point or core, extracted from the prior knowledge base, and then exploring and extending in two different directions along the relational links in the entity association network. This includes expanding candidate entities to multi-relationships and expanding candidate relations to entities. Expanding candidate relations to entities explores the entity information connected by the candidate relations, and other entities that can be directly or indirectly reached through their associations (i.e., extended entities). This helps to discover the downstream entities and relationships that the candidate association can "influence" or "associate" with. Expanding candidate entities to multi-relationships explores the extended multi-relationship information connected to the entities, helping to discover the local spatial structure of the candidate entities. Through this bidirectional expansion, the multi-relationship facts related to the candidate entities can be captured more comprehensively, constructing a richer and more complete knowledge subgraph around the candidate entities, thereby providing more sufficient information support for generating comprehensive and accurate answers.
[0033] S400: Generate the target answer to the query to be answered based on predicate-related facts and multi-relational facts.
[0034] For example, by combining the predicate association facts based on logical inference and the multivariate relation facts based on hypergraph structure obtained from the retrieval, and combining them with the corresponding text block fragments, the final knowledge input is formed. Then, the retrieval enhancement is used again to generate prompts. The fused knowledge and user questions are input into the large language model to generate the final answer.
[0035] This invention achieves a global effect through a hybrid retrieval system based on a first hypergraph structure (hypergraph spatial association) and a second hypergraph structure (logical association). The hierarchical and diversified knowledge modeling strategy employs fine-grained prompt word template design to guide the large language model in extracting cross-level and multi-dimensional knowledge association information from natural language documents. By guiding the large language model to extract multi-dimensional associations between knowledge entities, the knowledge base can identify complex dependencies between knowledge entities during construction, overcoming the limitations of binary dependencies in association modeling. More importantly, by guiding the large language model to perform hierarchical association modeling of knowledge entities in natural language documents, the large language model's association extraction capabilities under high degrees of freedom and logical constraints are simultaneously utilized. Therefore, the hierarchical and diversified knowledge modeling strategy, by combining hypergraph construction with predicate association construction, significantly enhances the large language model's ability to extract and recognize natural language knowledge during knowledge base construction, effectively improving the comprehensiveness of information obtained during knowledge retrieval and providing assistance in addressing challenges such as diversified associations, complex topological structures, and strong contextual dependencies in knowledge systems and application scenarios.
[0036] Furthermore, based on the constructed hierarchical and diversified knowledge base, this invention fully leverages the advantages of this structure through a hybrid retrieval strategy, providing an effective tool for knowledge retrieval in intelligent question-answering technology. First, the hybrid retrieval strategy combines hypergraph-based spatial association with predicate-based logical association, enabling different types of retrieval methods to collaborate fully, complementing and enhancing each other. Specifically, hypergraph-based spatial association focuses on reflecting the entities and edges in the knowledge base that are closest to and most relevant to the searched entities and edges, fully representing the salient information in the candidate set; predicate-based logical association focuses on reflecting the logical connections between related searched entities, representing more implicit information between knowledge entities, while the retrieval links of related entities reflect the knowledge retrieval process, enhancing the reliability and logic of the knowledge retrieval process. Second, by introducing domain-specific predicate definitions and inference rules, this invention is applicable to different application scenarios, improving the adaptability of large language models and retrieval enhancement generation technologies in specific domains.
[0037] Based on the above Figure 1 In the illustrated embodiment, step S100 may, for example, include: S110. Construct a first prompt word template and a second prompt word template: The first prompt word template is used to guide the preset large language model to extract knowledge entities from natural language documents and associate them with entities without preset constraints; the second prompt word template is used to guide the preset large language model to extract knowledge entities from natural language documents and associate them with entities that conform to the preset predicate definition.
[0038] For example, a large language model is preset to perform the core task of knowledge extraction. The specific model can be flexibly determined according to the actual application scenario, such as Baidu Wenxin Yiyan, Alibaba Tongyi Qianwen, OpenAI's GPT series models or open source LLaMA series models, etc. There are no restrictions here.
[0039] For example, the first prompt word template includes extraction types such as knowledge entities, low-order entity associations, high-order entity associations, and keywords, along with vivid and specific extraction examples, to intuitively describe the content that the large model should freely extract from the given knowledge.
[0040] For example, the second prompt word template includes: knowledge entities, predefined association types, predefined predicate types and definitions under each association type, low-order entity associations based on predicate definitions, high-order entity associations based on predicate definitions, keywords, and other extraction types, along with vivid and concrete extraction examples. This is used to intuitively describe the content that the large model should extract from given knowledge that conforms to given predicate constraints. Furthermore, the second prompt word template can consider domain-specific predicate definitions in addition to general predicate definitions.
[0041] Guided by the constructed first and second prompt word templates, a hierarchical, multi-entity associated knowledge base can be built, enhancing the knowledge base's ability to represent complex dependencies.
[0042] S120. Input the first prompt word template and the natural language document into a preset large language model, and extract the associations between knowledge entities and entities without preset constraints from the natural language document through the preset large language model; construct a first hypergraph structure based on the associations between knowledge entities and entities without preset constraints; input the second prompt word template and the natural language document into the preset large language model, and extract the associations between knowledge entities and entities that conform to preset predicate definitions from the natural language document through the preset large language model; construct a second hypergraph structure based on the associations between knowledge entities and entities that conform to preset predicate definitions. Specifically:
[0043] Given a set of corpora ,in Indicates the first A preprocessed corpus. Next, using... This represents the set of prompt word templates designed in this embodiment, wherein Indicates the first The class's prompt word template. Therefore, the extraction process for natural language documents is as follows:
[0044] in, Indicates the first The corpus is in the first The results are obtained by extracting from a large language model under the guidance of a prompt word template. This embodiment focuses on the first type of prompt word template. (Spatial Association Based on Hypergraph) Results Second type of prompt word template (Results based on predicate logical associations) Processing is performed to complete knowledge modeling.
[0045] Type 1 prompt word template Only include the basic concepts that need to be extracted, such as entities. Keywords to be extracted The low-order (binary) associations to be extracted The higher-order (multivariate) associations to be extracted And related examples Without imposing stricter constraints. Template-based. Large language models offer high flexibility and freedom in natural language document extraction, fully leveraging their generative capabilities. Correspondingly, the resulting extraction results... ,in Represents an entity set. Represents a low-order binary association set. Represents a higher-order multivariate association set. A set of keywords. The resulting set, composed of entity sets and association sets, can be structured into ordinary graph structures and hypergraph structures, as shown in the following equation:
[0046] in For entities in an entity set, Keywords describing the association. (Through) and The associations between knowledge entities in natural language documents are established, and the coexistence of binary and multi-ary associations effectively models the complex dependencies and multi-ary associations existing in professional fields.
[0047] To mitigate the illusion and uncertainty inherent in large language models during high-degree-of-freedom relational modeling, and to promote greater logical coherence in professional application scenarios, a second type of prompt word template is constructed. (Predicate-based logical association) is used to guide large language models to extract the associations between knowledge entities that conform to logical constraints as much as possible. Its components are as follows: in, It is a predefined set of relations, including multiple predefined association types. Each predefined association type is used to classify the predicate type corresponding to the entity association. This relation type is different from the entity association extracted by the large language model and represents the division of predicate types. This represents a pre-set of all predicates, including general predicate definitions and at least one configurable domain-specific predicate definition. It uses intuitive and clear definitions to explain the meaning of predicates and is used to guide large language models in identifying fixed predicate associations when processing corpora. It consists of general predicate definitions and domain-specific predicate definitions. Changing the domain-specific predicate definitions helps to apply it to different scenarios.
[0048] This represents a prompt word template for entity recognition, used to guide the pre-defined large language model in recognizing knowledge entities. For example, the format of the prompt word template for entity recognition can be ("entity"{tuple_delimiter}).<entity_name> {tuple_delimiter}<entity_type> {tuple_delimiter}<entity_description> {tuple_delimiter}<additional_properties> Here, `entity_name` represents the name of the entity, using the same language as the input text; if it is English, the name should be capitalized. `entity_type` represents the entity's category, which is one of the predefined types [{entity_type}]. `entity_description` represents a comprehensive description of the entity's attributes and activities. `additional_properties` represents other attributes that may be related to the entity, such as time, space, emotion, motivation, etc.
[0049] Format each entity as This represents a prompt word template for recognizing low-order hyperedges, used to guide the predefined large language model to recognize binary entity associations that conform to the predefined predicate definition. For example, the format of the prompt word template for recognizing low-order hyperedges can be ("Low-order Hyperedge"{tuple_delimiter}).<relation_type> {tuple_delimiter} <predicate>{tuple_delimiter}subject_entity:<subject_entity>{tuple_delimiter}object_entity:<object_entity>{tuple_delimiter} <description>{tuple_delimiter} <keywords>{tuple_delimiter} <strength>); where, Low-order Hyperedge represents a fixed identifier, indicating that this is a low-order hyperedge (binary relation); relation_type represents a fixed relation type, which must be selected from the following 7 types: CAUSAL, TEMPORAL, SPATIAL, HIERARCHICAL, FUNCTIONAL, SEMANTIC, SOCIAL; predicate represents a logical predicate, indicating the specific relation type, which must be selected from the predefined predicates under the corresponding relation_type; subject_entity represents the subject entity in the relation, which is the initiator or core subject of the predicate relation; object_entity represents the object entity in the relation, which is the receiver or core object of the predicate relation; description represents a detailed description of the relation, explaining the specific relationship between the subject entity and the object entity; keywords represent keywords related to the relation, separated by commas; strength represents a numerical score of the relation strength between entities (1-10 points, 10 points represents the strongest relation).
[0050] This represents a prompt word template for recognizing higher-order associations, used to guide a predefined large language model to recognize multi-entity associations that conform to a predefined predicate definition. For example, the format of the prompt word template for recognizing higher-order associations can be ("High-orderHyperedge"{tuple_delimiter}).<relation_type> {tuple_delimiter} <predicate>{tuple_delimiter}subject_entity:<subject_entity1>{tuple_delimiter}subject_entity:<subject_entity2>{tuple_delimiter}subject_entity:<subject_entityN>{tuple_delimiter}object_entity:<object_entity1>{tuple_delimiter}object_entity:<object_entity2>{tuple_delimiter}object_entity:<object_entityN>{tuple_delimiter} <description>{tuple_delimiter} <generalization>{tuple_delimiter} <keywords>{tuple_delimiter} <strength>). Here, High-order Hyperedge represents a fixed identifier, indicating that this is a high-order hyperedge (multi-element relation); relation_type represents a fixed relation type, which must be selected from the following 7 types: CAUSAL, TEMPORAL, SPATIAL, HIERARCHICAL, FUNCTIONAL, SEMANTIC, SOCIAL; predicate represents a logical predicate, indicating a specific relation type, which must be selected from the predefined predicates under the corresponding relation_type; subject_entity1, subject_entity2, ..., subject_entityN represent the subject composed of one or more entities in the relation, which is the initiator of the predicate relation and points to the object; object_entity1, object_entity2, ..., object_entityN represent the object composed of one or more entities in the relation, which is the receiver of the predicate relation and responds to the subject; description represents a detailed description of the multi-element relation, clearly stating the relationship between the set of subject entities and the set of object entities; generalization represents a general summary of the relation, emphasizing the interaction pattern between the subject and object; keywords represent keywords related to the relation; and strength represents the overall strength score of the multi-element relation (1-10 points).
[0051] and The related prompt word templates are different. The associations constructed by the association prompts must conform to the content of the predicate definition template. That is, the constructed low-order associations must conform to the defined binary predicate relations, and the constructed high-order associations must conform to the defined multi-predicate relations. This provides strong constraints and clear guidance for the association recognition of large language models. Furthermore, This represents the set of keywords to be extracted for each association, including multiple keywords. Each keyword represents the core concept or theme of a specific text unit in a natural language document. Since entities under the same predicate association may still have different association meanings, keywords are used to summarize the actual meaning of the association. For example, the format of keywords can be ("High-level keywords"{tuple_delimiter}).<high_level_keywords> ), where High-level keywords represent keywords.
[0052] This section provides concrete examples that the large language model can directly refer to when processing natural language documents. It serves to provide the predefined large language model with specific operational procedures and judgment criteria for identifying and extracting entity associations that conform to the predefined predicate definitions from natural language documents. For example, the reference examples for hierarchical predicate constraints can be: ①.belongTo: Indicates the subordinate relationship between an instance and a concept, meaning that one or more things belong to one or more categories or sets. For example: Chamber (subject) belongTo Legislative Body (object) (The chamber belongs to the legislative body) or France, Germany and Italy (subject set) belongTo European Union (object) (France, Germany, and Italy belong to the European Union). ②.isA: Indicates the relationship between a hyponym and a hypernym, meaning that one or more things are a type of one or more categories. For example: Car (subject) isA Vehicle (object) (A car is a means of transportation) or Lions, Tigers and Panthers (subject set) isA Felines (object) (Lions, tigers, and panthers are felines). ③.isPartOf: Indicates the relationship between a component and the whole, meaning that one or more things are components of one or more larger wholes. For example: Wheel (subject) is Part Of Car (object) (the wheel is part of the car) or Chapters and Appendices (subject set) is Part Of Book (object) (chapters and appendices are part of the book).
[0053] Based on template The extraction results generated by the large language model are shown below: in, Represents an entity set. This represents a low-order binary association set under predicate constraints. Represents a higher-order multivariate relation set under predicate constraints. Represents a set of keywords. This represents a set of relation types corresponding to associations. This represents the set of predicate types corresponding to the associations. For the resulting set, the entity set, association set, and corresponding relation types and predicates can form binary predicate associations and multi-predicate associations, as shown in the following formula:
[0054] in For entities in an entity set, To describe the associated keywords, For predefined predicates, For predefined relation types. and Binary and multivariate associations that conform to predicate constraints can help large language models identify and extract associations that conform to predicate logic constraints in corpora, thereby forming a knowledge base with more logical and clear knowledge links and making it easier for large language models to understand complex business scenarios common in specific domains.
[0055] Step S100 not only utilizes the large model to extract entities and free associations following the hypergraph structure, but also fully leverages predicate definition templates to guide the large model in extracting entity and predicate associations under logical constraints. The first type of prompt word template capturing the hypergraph structure fully utilizes the powerful generation capabilities of the large language model, while the second type of prompt word template capturing predicate associations enhances the large model's ability to process logical associations between entities. The hierarchical prompt word templates collaboratively guide the large language model from diverse extraction perspectives, forming a comprehensive description of knowledge associations. Through the synergistic effect of dual hypergraph modeling and hybrid retrieval strategies, a dual guarantee of comprehensive knowledge associations and inference accuracy can be achieved. The first hypergraph maximizes the retention of all entity associations without preset constraints in natural language documents, capturing the connection relationships between various types of entities without limitations, completely avoiding the omission of transitive entity associations, and providing sufficient "knowledge material" for subsequent inference. The second hypergraph performs targeted filtering of entity associations based on preset predicate definitions, retaining only association content that conforms to logical rules, effectively excluding invalid associations without transitivity, and avoiding knowledge base deviations caused by incorrect association additions. The dual-hypergraph structure, through hierarchical design, forms an entity association modeling mechanism of "unconstrained capture - constrained filtering," providing a comprehensive and logical entity association capture capability for the construction of prior knowledge bases, thus avoiding the problems of association omission and mis-filling from the source.
[0056] Based on any of the above embodiments, for example, in step S300, the knowledge retrieval process is based on a hierarchical and diversified knowledge base obtained during knowledge modeling. Knowledge retrieval employs an innovative retrieval mode using a hybrid retrieval strategy, encompassing hypergraph-based retrieval and logical-based retrieval. This provides reliable retrieval knowledge for newly arrived queries, aiming to fully utilize the fine-grained hierarchical advantages of the knowledge structure in the knowledge base. It overcomes the predicament of a single retrieval perspective and incomplete information during the knowledge retrieval process, thus balancing flexible relational information with strongly constrained logical relational information. It comprehensively uncovers the implicit information of the target in the knowledge base and provides a comprehensive description of the target, thereby laying a foundation for subsequent large language model-generated answers. Specifically:
[0057] Given a series of newly arrived queries For each specific query Large language model Use keyword extraction templates for the query. Extract the core content that the user cares about in the current query, i.e. ,in This represents the i-th arriving query. This represents the results extracted from the large model. This represents a template for extracting keywords from a query. This indicates the entity keywords present in the query. This indicates related keywords present in the query. Because the content described in the user's query incorporates the user's subjective description, the query target is usually... The target query is not entirely identical to the knowledge stored in the knowledge base, therefore it needs to be transformed into the most similar knowledge in the knowledge base, as shown in the following formula:
[0058] in, This represents a vector-based similarity scoring function used to select from a knowledge base. The most similar knowledge, candidate entity set Association set of candidate entities This will serve as a necessary input for the hybrid retrieval process; Represents an entity vector library. Represents the first entity in the entity vector library One entity vector; Represents the hyperedge vector library, Represents the first hyperedge vector in the hyperedge vector library. A super-edge.
[0059] For the retrieval target located in the knowledge base and By leveraging the characteristics of hypergraph structures, spatial structure-based retrieval methods will... The attached set of associations will be summarized as follows: The attached entity set is summarized to obtain the local spatial structure in the knowledge base as supplementary information to guide the large language model in generating answers, as shown in the following formula: in, express The attached associations, express The attached entities, the entities retrieved through the hypergraph structure, the hyperedges, and the corresponding text block information together form the result. .
[0060] For the retrieval target located in the knowledge base Simultaneously, available information is retrieved from the knowledge base based on logical relationships. This involves constructing knowledge retrieval links using predicate definitions and predicate transitivity rules to uncover the logical correlations between entities in the knowledge base and the retrieval target. A predefined set of predicates is used during the knowledge modeling process. During the knowledge retrieval process, the following rules are predefined:
[0061] in, This represents a set of predefined predicate transitive rules. Indicates the first The specific rules can be found in the first section. The predicate and the first Passing between predicates , The total number of rules passed to the predicate. For example, when the entity A With entity B Predicate association exists between them ,entity B With entity C Predicate association exists between them ,entity B With entity D Predicate association exists between them At the same time, only predicate transitive rules ,therefore A and C The knowledge chain has been opened up, that is... ,and A and D There is no knowledge link between them. The knowledge link construction process is as follows:
[0062] in, Indicates a feasible path. Indicates by the first Candidate entities , No. Candidate entities as well as and Entity association between The resulting first predicate transitive feasible path, Conforms to the Each predicate definition; Indicates a feasible path for predicate passing; Indicates by the first Candidate entities , No. Candidate entities as well as and Entity association between The resulting feasible path for passing the second predicate. Conforms to the Each predicate definition; Indicates the first Candidate entities The predicate-related facts obtained through predicate transitive reasoning. Feasible paths, along with text blocks corresponding to entities and associations recorded during the retrieval process, together constitute the results obtained from the retrieval process. Unlike retrieval methods based on local spatial structure, retrieval modes based on logical associations are grounded in the logical relationships between entities. This helps to discover implicit connections between entities; that is, when there is no direct relationship between entities, implicit connections can be discovered through logical transmission processes. Although retrieval methods based on local spatial structure can construct relationships between entities after multi-hop transmission, the logicality and reliability of these relationships tend to decrease during flooding transmission, leading to an increased frequency of "illusion" phenomena. Furthermore, when the application domain changes, predicate definitions and rules specific to the application domain can be added to the predicate definitions and predicate transmission rules, thereby improving the versatility of predicate association retrieval modes.
[0063] Based on a comprehensive and rigorous prior knowledge base constructed using a dual hypergraph, a hybrid retrieval mechanism combining predicate transitive reasoning and a bidirectional expansion strategy further enhances the logicality of the reasoning process and the completeness of entity relationship representation. Preset predicate definitions delineate the boundaries of reasoning constraints, providing a clear logical benchmark for entity association reasoning. Only logical entity associations conforming to the predicate definitions are allowed for deduction, eliminating meaningless and invalid reasoning at the rule level and ensuring the accuracy of the reasoning direction. Predicate transitive reasoning extends the dimensions of knowledge associations. Based on preset predicate transitive rules, it has the ability to dynamically extend knowledge boundaries, expanding traditional point-to-point binary entity associations into multi-node, multi-link multi-predicate transitive knowledge links, enriching the levels and dimensions of knowledge associations. The bidirectional expansion strategy fully represents multi-dimensional relationships. Using candidate entities and associations as the core, bidirectional expansion captures extended entities and associations with which they have path connections, ultimately forming a hypergraph structure containing multi-dimensional relationship facts. This achieves complete modeling of multi-entity relationships in professional knowledge, addressing the pain point of "one-sided relationship representation" in traditional methods. The dual-hypergraph modeling and hybrid retrieval strategy form a tightly synergistic closed loop: the dual-hypergraph provides a comprehensive and unbiased knowledge foundation for retrieval reasoning, ensuring reliable material support for the reasoning process; hybrid retrieval, through precise constraints and dynamic extensions, fully explores the effective connections within the dual-hypergraph, achieving efficient transformation from "knowledge storage" to "knowledge application." This synergistic effect ultimately achieves the core goals of "comprehensive coverage of knowledge connections, rigorous logical reasoning process, and high-quality and reliable answer generation," providing an efficient solution for knowledge services in professional fields.
[0064] Based on any of the above embodiments, for example, when generating the target answer corresponding to the query to be answered in step S400, text block fragments corresponding to predicate-related facts and multi-relational facts are extracted from the natural language document; the predicate-related facts, multi-relational facts, and the text block fragments corresponding to the predicate-related facts and multi-relational facts are integrated into enhanced knowledge input; the enhanced knowledge input and the query to be answered are jointly input into a preset retrieval enhancement generation prompt word template to generate input prompt words adapted to the preset large language model; the input prompt words are input into the preset large language model, and the target answer corresponding to the query to be answered is obtained through the preset large language model. Specifically:
[0065] First, the large language model is invoked, combined with prompt word templates used to extract entity keywords and related keywords from the query, to identify the entity keywords and related keywords that the user is interested in. Next, a set of retrieval functions, including entity retrieval and related keyword retrieval, is used to locate the closest knowledge entities and related terms in the knowledge base as retrieval targets. Then, a set of functions for expansion is used to perform a one-hop retrieval based on a hypergraph structure on these retrieval targets, returning the entity, related terms, and corresponding text block information as the retrieval results. Simultaneously, combining general and domain-specific predicate passing rules, a set of functions based on predicate passing retrieval is used to perform predicate passing retrieval on the target entity, obtaining retrieval results 2. Finally, combining the prompt word templates used to guide the large language model in generating answers, the results generated during the hybrid retrieval process are analyzed. and Combine it with the query and combine it with the answer to generate a template. The large language model is then used to generate the answer, as shown in the following formula: .
[0066] Figure 2 This is the second flowchart illustrating the retrieval enhancement generation method provided in this specification, as shown below. Figure 2 As shown, the method includes: S1, designing two types of prompt word templates with different focuses; S2, using a large language model to construct a hierarchical, multi-entity associated knowledge base based on the prompt words, enhancing the knowledge base's ability to represent complex dependencies; S3, when a query arrives, using a hybrid retrieval strategy to search the knowledge base, and guiding the large language model to generate an answer by combining the original query and the retrieval results. This invention, through a hierarchical knowledge extraction method and a complex association modeling strategy based on hypergraphs, strengthens the large language model's ability to perceive domain-specific knowledge, enabling it to capture multi-relevance and complex dependencies in domain-specific data under the dual guidance of associated predicate constraints and complex domain knowledge associations. Therefore, this invention not only enhances the large language model's modeling ability in domain-specific areas but also further improves the reliability and interpretability of generated knowledge, making it an effective technology for addressing a series of challenges in domain-specific knowledge retrieval and intelligent question-answering systems.
[0067] In the knowledge modeling process, existing methods focus on leveraging the powerful generative capabilities of large language models to extract relationships between knowledge entities, while neglecting the illusion problem that may arise when large language models construct relationships with high flexibility. This invention achieves a balance between the high flexibility of relationship construction under large language models and the construction of relationships under logical constraints through a collaborative design. This invention uses hierarchical knowledge and complex relationship modeling for enhanced retrieval generation to capture the complex and diverse relationships existing in natural language documents within specific domains. Figure 3 This is a schematic diagram of an overall framework for retrieval enhancement generation provided in this specification, such as... Figure 3 As shown, the present invention includes two parts: building a knowledge base for natural language documents and retrieving and answering knowledge for newly arrived queries. Knowledge modeling and knowledge retrieval together form the entire process of intelligent answering.
[0068] Before constructing the first and second suggestion word templates, it is necessary to first determine the professional fields and application scenarios in which the search enhancement generation technology should be applied, and collect professional knowledge documents TEXT1, TEXT2...TEXT in that field. n These documents are preprocessed, including extraction and segmentation, to form a corpus. Subsequently, knowledge is extracted and modeled from the corpus through knowledge modeling, and the knowledge is stored. When a user query is received, knowledge retrieval retrieves relevant knowledge from the knowledge storage and finally generates an answer.
[0069] Knowledge modeling is a necessary step in retrieval enhancement generation technology. The quality of knowledge modeling significantly affects the subsequent knowledge retrieval and answer generation process. Therefore, this invention introduces a hierarchical knowledge modeling approach and focuses on the relationships between multiple entities during the knowledge modeling process. Figure 4 This specification provides a schematic diagram of a knowledge modeling framework, such as... Figure 4 As shown, this refers to professional knowledge documents TEXT1, TEXT2...TEXT n First, a first prompt word template for extracting hypergraph structures is constructed, including definitions and specific extraction examples for entities, low-order associations, high-order associations, and keywords. Simultaneously, a second prompt word template for extracting predicate associations is constructed, including definitions and specific extraction examples for relation types, predicate types, entities, low-order associations, high-order associations, and keywords. Relation types and predicate types and definitions applicable to specific application domains can be added. Both templates are input into a Large Language Model (LLM) to guide it in extracting hypergraph structure knowledge containing binary regular edges, multi-predicateless edges, binary predicate edges, and multi-predicate edges from knowledge documents. Then, a set of processing functions is constructed to identify and process the results extracted by the LLM, and finally, the processed knowledge is stored.
[0070] In the knowledge retrieval process, in order to make full use of the hierarchical characteristics of the knowledge base, this invention uses a hybrid retrieval strategy to retrieve knowledge information from different perspectives. The information from different perspectives reflects the characteristics of the same retrieval target in the knowledge base. Figure 5 This specification provides a schematic diagram of a knowledge retrieval framework, such as... Figure 5 As shown, before conducting knowledge retrieval and answer generation, a series of core components need to be constructed: First, a query prompt template is constructed, clarifying the extraction requirements for entity keywords and related keywords; next, a function set including entity retrieval, related retrieval, entity expansion, and related expansion is constructed to locate the target to be retrieved in the knowledge base and implement retrieval based on the hypergraph structure; then, general predicate passing rules and predicate passing rules adapted to specific domains are constructed; subsequently, a function set based on predicate passing retrieval is constructed to search for entities in the knowledge base that meet the rule constraints and record link-related information; finally, a prompt template is constructed to guide the large language model to generate answers by combining query and mixed retrieval results. After the above construction is completed, the process officially starts: First, the user's query is received, the query is input into the large language model (LLM), and keywords in the query are extracted in combination with the "query prompt template"; then, based on the extracted keywords, the "retrieval and expansion function set" is called to retrieve core content from the "knowledge storage", first obtaining the initial entities and regular associations that directly match the keywords. After obtaining the initial entities and regular associations, on the one hand, the "retrieval and expansion function set" is called to expand the initial entities and regular associations, resulting in expanded entities and associations. On the other hand, combining the "general and domain-specific predicate passing rules" and the "predicate passing-based retrieval function set," the extended predicate associations obtained from the initial entity retrieval are further obtained through predicate retrieval rules to form a predicate retrieval path. Finally, all retrieved entities and associations, along with the "answer generation prompt word template," are input into the Large Language Model (LLM). The LLM combines these retrieval results with the user's original query to generate the final answer. The entire process, through the collaboration of "keyword extraction - entity association retrieval - template generation," achieves accurate understanding of the user's query and knowledge-enhanced answer generation. The hybrid retrieval strategy promotes the collaboration and complementarity of characteristics from different perspectives to achieve comprehensive retrieval of the retrieval target, providing sufficient information support for the large model to generate answers. Finally, considering the results of the retrieval process and the original question, an answer is generated for the arrived query.
[0071] The retrieval enhancement generation apparatus provided by the present invention is described below. The retrieval enhancement generation apparatus described below can be referred to in correspondence with the retrieval enhancement generation method described above.
[0072] Figure 6 For an example, please refer to the structural schematic diagram of a retrieval enhancement generation device provided by the present invention. Figure 6 As shown, the retrieval enhancement generation apparatus may include [the following].
[0073] The hypergraph structure acquisition module is used to construct a first hypergraph structure and a second hypergraph structure, which include knowledge entities and entity associations, using professional terms in professional domain natural language documents as knowledge entities and semantic relationships between professional terms as entity associations. In the first hypergraph structure, the semantic relationships corresponding to entity associations are unconstrained; in the second hypergraph structure, the semantic relationships corresponding to entity associations satisfy preset predicate definition constraints.
[0074] The prior knowledge base acquisition module is used to construct a prior knowledge base based on entities and entity relationships in the first and second hypergraph structures.
[0075] The knowledge retrieval module is used to obtain the query to be answered and extract candidate entities and candidate entity associations related to the query from the prior knowledge base. Predicate transitive reasoning is performed on candidate entities to obtain predicate-related facts; predicate-related facts are entity associations that satisfy the predicate definition constraints through semantic relations, forming entity association links by connecting candidate entities according to semantic relations; Perform bidirectional extension operations on candidate entities and their associations to obtain multi-entity relational facts. These multi-entity relational facts are multi-entity association links formed by connecting extended entities or extended entity associations that have semantic relationships with candidate entities and their associations according to semantic relationships.
[0076] The answer generation module is used to generate the target answer to the query to be answered based on predicate-related facts and multi-relational facts.
[0077] Specific limitations regarding the search enhancement generation device can be found in the limitations on search enhancement generation described above, and will not be repeated here. Each module in the aforementioned search enhancement generation device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in the computer device in hardware form, or stored in the memory of the computer device in software form, so that the processor can call and execute the operations corresponding to each module.
[0078] This specification also provides a computer-readable storage medium storing a computer program that can be used to execute the above-described... Figure 1 The provided search enhancement generation method.
[0079] This instruction manual also provides Figure 7 The schematic diagram of the computer device shown is as follows: Figure 7 At the hardware level, the computer device includes a processor, internal bus, network interface, memory, and non-volatile memory, and may also include other hardware required for business operations. The processor reads the corresponding computer program from the non-volatile memory into memory and then runs it to achieve the above-mentioned functions. Figure 1 The provided search enhancement generation method.
[0080] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the methods described above. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, or optical storage, etc. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc.
[0081] The technical features of the above embodiments can be combined in any way. For the sake of brevity, 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.< / strength> < / keywords> < / generalization> < / description> < / predicate> < / strength> < / keywords> < / description> < / predicate>
Claims
1. A method for retrieval augmentation generation, the method comprising: The method comprises the following steps: Constructing a first hypergraph structure and a second hypergraph structure comprising knowledge entities and entity associations, wherein the semantic relationship corresponding to the entity association in the first hypergraph structure is unconstrained; the semantic relationship corresponding to the entity association in the second hypergraph structure satisfies a preset predicate definition constraint; Constructing a priori knowledge base based on the entities and entity associations in the first hypergraph structure and the second hypergraph structure; Obtaining a query to be answered, and extracting candidate entities and candidate entity associations related to the query to be answered from the a priori knowledge base; Performing predicate propagation reasoning on the candidate entities to obtain predicate association facts; the predicate association fact is an entity association chain formed by connecting the candidate entities according to the semantic relationship that satisfies the preset predicate definition constraint; Performing bidirectional expansion operation on the candidate entities and the candidate entity associations to obtain multi-element relationship facts; the multi-element relationship fact is a multi-element association chain formed by connecting the expansion entities or expansion entity associations having a semantic relationship with the candidate entities and the candidate entity associations according to the semantic relationship; Generating a target answer corresponding to the query to be answered based on the predicate association fact and the multi-element relationship fact.
2. The search enhancement generation method of claim 1, wherein, The method further comprises the following steps: Obtaining a preset predicate propagation rule; wherein, denotes a set of pre-defined predicate transfer rules; denotes a th predicate transfer rule for transferring between a th predicate and a th predicate, , denotes the total number of predicate transfer rules; and denote a th and a th predicate definition in a set of pre-defined predicate definitions , respectively. Performing predicate propagation reasoning on the candidate entities based on the preset predicate propagation rule; wherein, denotes a first predicate transitive feasible path formed by the entity association between the first candidate entity , the second candidate entity , and and the third candidate entity , which conforms to the second predicate definition; denotes a predicate transitive feasible path; Indicates by the first Candidate entities , No. Candidate entities as well as and Entity association between The resulting feasible path for passing the second predicate. Conforms to the Each predicate definition; represents a predicate association fact obtained by performing predicate propagation reasoning on the th candidate entity .
3. The search enhancement generation method of claim 1, wherein, The method further comprises the following steps: Constructing a first prompt word template and a second prompt word template; wherein the first prompt word template is used to guide the preset large language model to extract the knowledge entities and the entity associations without the preset constraint from the natural language document; and the second prompt word template is used to guide the preset large language model to extract the knowledge entities and the entity associations satisfying the preset predicate definition from the natural language document; Inputting the first prompt word template and the natural language document into the preset large language model, and extracting the knowledge entities and the entity associations without the preset constraint from the natural language document by the preset large language model; and constructing the first hypergraph structure based on the knowledge entities and the entity associations without the preset constraint; Inputting the second prompt word template and the natural language document into the preset large language model, and extracting the knowledge entities and the entity associations satisfying the preset predicate definition from the natural language document by the preset large language model; and constructing the second hypergraph structure based on the knowledge entities and the entity associations satisfying the preset predicate definition.
4. The search enhancement generation method of claim 3, wherein, The second prompt word template comprises the following: A set of predefined association types, comprising a plurality of predefined association types, each of which is used to classify the predicate type corresponding to the entity association; A set of preset predicate definitions, comprising a general predicate definition and at least one configurable predicate definition of a specific field; An entity recognition prompt word template used to guide the preset large language model to recognize the knowledge entities; A low-order predicate association recognition prompt word template used to guide the preset large language model to recognize the binary entity association satisfying the preset predicate definition; A high-order predicate association recognition prompt word template used to guide the preset large language model to recognize the multi-element entity association satisfying the preset predicate definition; and The keyword set includes a plurality of keywords, and each keyword is used to represent a core concept or theme of a specific text unit in the natural language document; Predicate constraint reference examples are used to provide specific operation procedures and judgment criteria for identifying and extracting entity associations that meet the preset predicate definition from the natural language document to the preset large language model.
5. The method of claim 1, wherein the search query is enhanced by: The target answer corresponding to the to-be-answered query is generated based on the predicate association fact and the multi-element relationship fact, specifically including: Respectively extracting text block segments corresponding to the predicate association fact and the multi-element relationship fact from the natural language document; Integrating the predicate association fact, the multi-element relationship fact, and the text block segments corresponding to the predicate association fact and the multi-element relationship fact into enhanced knowledge input; Inputting the enhanced knowledge input and the to-be-answered query into a preset retrieval enhancement generation prompt word template to generate an input prompt word adapted to the preset large language model; Inputting the input prompt word into the preset large language model to obtain the target answer corresponding to the to-be-answered query through the preset large language model.
6. The search enhancement generation method of claim 1, wherein, The prior knowledge base is constructed based on the entities and entity associations in the first supergraph structure and the second supergraph structure, specifically including: The entities and entity associations in the first supergraph structure and the second supergraph structure are converted into entity vectors and super-edge vectors through a preset embedding model or vector function; The prior knowledge base including an entity vector library and a super-edge vector library is constructed based on the entity vectors and super-edge vectors.
7. The search enhancement generation method of claim 6, wherein, The candidate entities and candidate entity associations related to the to-be-answered query are extracted from the prior knowledge base, specifically including: Encoding the to-be-answered query into a query vector through a preset encoder; An entity retrieval function is constructed, which is used to calculate the entity similarity of the query vector and each entity vector in the entity vector library; and the entities in the entity vector library with an entity similarity greater than a preset entity similarity threshold are taken as candidate entities; A super-edge retrieval function is constructed, which is used to calculate the entity association similarity of the query vector and each super-edge vector in the super-edge vector library; and the entity associations corresponding to the super-edges in the super-edge vector library with an entity association similarity greater than a preset entity association similarity threshold are taken as candidate entity associations.
8. A retrieval augmentation generation apparatus characterized by comprising: Including: A supergraph structure acquisition module is configured to construct a first supergraph structure and a second supergraph structure including knowledge entities and entity associations by taking professional terms in professional field natural language documents as the knowledge entities and taking semantic relationships between the professional terms as the entity associations, wherein the semantic relationships corresponding to the entity associations in the first supergraph structure are unconstrained; and the semantic relationships corresponding to the entity associations in the second supergraph structure satisfy preset predicate definition constraints; A prior knowledge base acquisition module is configured to construct a prior knowledge base based on the entities and entity associations in the first supergraph structure and the second supergraph structure; A knowledge retrieval module is configured to obtain a to-be-answered query and extract candidate entities and candidate entity associations related to the to-be-answered query from the prior knowledge base; Predicate transmission reasoning is performed on the candidate entities to obtain a predicate association fact; the predicate association fact is an entity association link formed by connecting the candidate entities according to semantic relationships that satisfy preset predicate definition constraints; The bidirectional expansion operation is performed on the candidate entity and the candidate entity association to obtain a multi-element relationship fact, the multi-element relationship fact being a multi-element association link formed by connecting an expansion entity or an expansion entity association having a semantic relationship with the candidate entity and the candidate entity association according to the semantic relationship; The answering generation module is configured to generate a target answer corresponding to the query to be answered based on the predicate association fact and the multi-element relationship fact.
9. An electronic device comprising a memory, a processor, and a computer program stored on the memory and running on the processor, characterized in that, The processor implements the search enhancement generation method according to any one of claims 1 to 7 when executing the computer program.
10. A non-transitory computer-readable storage medium having stored thereon a computer program, characterized in that, The computer program is executed by the processor to implement the search enhancement generation method according to any one of claims 1 to 7.