Multi-hop agricultural question answering system based on knowledge graph reasoning and large model and text segment retrieval and answer generation method thereof

By constructing a knowledge graph in the agricultural field and using the knowledge graph reasoning path to enhance the question representation, combined with the K-BERT model for text retrieval and generation, the shortcomings of traditional RAG technology in multi-hop reasoning problems are solved, and more accurate and efficient answer generation is achieved.

CN119782467BActive Publication Date: 2026-08-25DALIAN UNIV OF TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411852050.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-16
Publication Date
2026-08-25
Estimated Expiration
2044-12-16

AI Technical Summary

Technical Problem

Traditional RAG technology suffers from incomplete information retrieval, limited relational reasoning ability, and difficulty in text generation when dealing with multi-hop reasoning problems, making it difficult to generate accurate and logical answers.

Method used

We construct a knowledge graph for the agricultural field, extract key entities and relationships for questions, enhance question representation by utilizing the reasoning path of the knowledge graph, combine it with the K-BERT model for text retrieval and generation, and optimize the multi-hop reasoning question answering system.

Benefits of technology

It improves the accuracy and efficiency of answer generation for multi-hop reasoning questions, enhances the reasoning ability of the question-answering system, and provides clear and highly relevant solutions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119782467B_ABST
    Figure CN119782467B_ABST
Patent Text Reader

Abstract

The application discloses a multi-hop agricultural question and answer system based on knowledge graph reasoning and a large model and a text segment retrieval and answer generation method thereof, belongs to the field of agricultural wisdom question and answer, and points are as follows: S10, key entities and relationships of an input question are extracted to construct a structured representation of the input question; S20, according to the structured representation of the input question, a reasoning path related to the question is retrieved in an agricultural field knowledge graph; S30, the reasoning path is embedded in the input question to generate a knowledge enhanced question representation containing multi-hop reasoning information; S40, according to the knowledge enhanced question representation, text retrieval is performed to obtain relevant text segments; and S50, the knowledge enhanced question representation and the text segments are input into a retrieval and enhancement generation model (RAG), and an answer to the input question is output by the retrieval and enhancement generation model, so that the ability of a question and answer system to process complex multi-hop reasoning questions is significantly improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of agricultural intelligent question answering, and particularly relates to an agricultural intelligent question answering system based on knowledge graph reasoning and large model retrieval enhancement generation technology, as well as the system's text fragment retrieval and answer generation method. Background Technology

[0002] Smart agriculture, as a core driving force for modern agricultural development, has immeasurable value in improving agricultural production efficiency, ensuring food security, and promoting rural economic prosperity. It deeply integrates cutting-edge technologies such as the Internet of Things and big data, achieving precision crop planting, intelligent pest and disease control, and efficient utilization of agricultural resources. Against this backdrop, the importance of intelligent question-and-answer systems is increasingly prominent. These systems can provide farmers and agricultural practitioners with timely and accurate technical guidance and policy interpretations, helping them quickly resolve technical bottlenecks and policy confusions encountered in smart agriculture practices. This not only contributes to the popularization and application of smart agriculture technologies but also lays a solid foundation for promoting agricultural modernization.

[0003] In recent years, with the rapid development of artificial intelligence technology, large-scale pre-trained models (such as GPT and BERT) have achieved remarkable results in the field of intelligent question answering. These models possess powerful language understanding and generation capabilities, enabling them to efficiently answer various complex questions and providing strong support for building efficient and intelligent question answering systems. However, traditional question answering systems still have certain limitations when dealing with complex problems requiring multi-step reasoning.

[0004] Retrieval-enhanced generation (RAG) technology, which combines information retrieval with generative models, has become a research hotspot in the field of question-answering systems. RAG technology assists in generating high-quality answers or text content by retrieving relevant information from massive amounts of text data. RAG technology performs exceptionally well in handling simple question-answering tasks because it can efficiently utilize information from external knowledge bases, significantly enhancing the model's answering capabilities.

[0005] However, traditional RAG (Relational Angle and Answering) techniques fall short when faced with complex multi-hop reasoning problems. Multi-hop reasoning problems refer to the type of questions that require traversing multiple text fragments or knowledge nodes and reaching a conclusion through chain-like reasoning. These problems typically involve complex logical relationships, multi-level semantic understanding, and cross-text information integration, posing significant challenges to the information retrieval, relational reasoning, and text generation capabilities of question-answering systems.

[0006] When dealing with multi-hop reasoning problems, the limitations of traditional RAG techniques are mainly reflected in the following aspects: First, in terms of information retrieval, traditional RAG techniques rely heavily on efficient information retrieval mechanisms to accurately capture text fragments closely related to the question. However, due to the wide distribution and complex relationships of information in multi-hop problems, retrieval methods based on keyword matching or semantic similarity often struggle to comprehensively and accurately capture all key information points. This may lead to incomplete retrieval results, affecting the accuracy of subsequent reasoning. Second, in terms of relational reasoning, although traditional RAG models can generate answers using retrieved text fragments, their ability to integrate and parse complex relationships between multiple text fragments is limited in problems requiring multi-step reasoning. This makes it difficult for the model to provide accurate and convincing answers. Finally, traditional RAG techniques also face challenges in the text generation stage. Due to the need to process a large amount of information with complex relationships, RAG models find it particularly difficult to generate coherent and accurate answers. This not only requires the model to have strong text generation capabilities but also to be able to flexibly handle various complex information combinations and relational reasoning to ensure that the generated answers are both accurate and logical. Summary of the Invention

[0007] To address the aforementioned problems, this application provides a text fragment retrieval and answer generation method for a multi-hop agricultural question-answering system based on knowledge graph reasoning and large-scale models, according to some embodiments of the present application.

[0008] S10. Extract the key entities and relationships of the input problem to construct a structured representation of the input problem;

[0009] S20. Based on the structured representation of the input question, retrieve the reasoning path related to the question in the agricultural domain knowledge graph;

[0010] S30. Embed the reasoning path into the input question to generate a knowledge-enhanced question representation containing multi-hop reasoning information;

[0011] S40. Perform text retrieval based on the knowledge-enhanced question representation to obtain relevant text fragments;

[0012] S50. Input the knowledge-enhanced question representation and the text fragment into the retrieval-enhanced generative model (RAG), and have the retrieval-enhanced generative model output the answer to the input question.

[0013] According to some embodiments of this application, the text fragment retrieval and answer generation method of a multi-hop agricultural question-answering system based on knowledge graph reasoning and large models, the construction of the agricultural domain knowledge graph in step S20 includes automatically extracting key entities and relationships from agricultural domain texts to construct an agricultural domain knowledge graph through large language models, prompting engineering, and few-shot learning; including:

[0014] Identify entity and relation types, where: entity types include crops, pests, diseases, fertilizers, pesticides, agronomic measures, regions, and weather; relation types include harm, control, application, planting in, location, and adoption;

[0015] Automatic entity relation extraction and triple construction are performed using cue engineering and few-shot learning. The cue content includes task description, output format and a few labeled examples.

[0016] Represent the triples as a directed graph G = (E, V), where V is the set of entities and E is the set of relations. Each triple corresponds to an edge e = (v...). i ,r,v j ), where v i ,v j ∈V, r is the relation type.

[0017] According to some embodiments of the present application, the text fragment retrieval and answer generation method of a multi-hop agricultural question-answering system based on knowledge graph reasoning and large model, in step S10, the question-answering system extracts key entities and relationships of the input question to construct a structured representation G of the input question. Q .

[0018] According to the text fragment retrieval and answer generation method of a multi-hop agricultural question-answering system based on knowledge graph reasoning and large models according to some embodiments of this application, the reasoning path in step S20 is represented as an ordered sequence of triples:

[0019] P = {e1, r1, e2, ..., e} m}

[0020] Among them, e i Represents an entity, r i Represents entity e i+1 With e i The relationship between them, where M is the path length;

[0021] Step S20 involves retrieving reasoning paths related to the problem from the agricultural knowledge graph, including:

[0022] S21. Search the agricultural domain knowledge graph KG for all subgraphs G containing entities and relations related to the input question. i This forms a candidate reasoning path set {P} i}, each candidate subgraph G i The set of nodes and edges contained are V. i and E i ;

[0023] S22. Compute the structured representation G of the input problem. Q and each candidate subgraph G iThe Jaccard similarity and semantic similarity; where Jaccard similarity measures the degree of overlap between two sets, defined as:

[0024] Jaccard(G Q G i )=(|V Q ∩V i |+|E Q ∩E i |) / (|V Q ∪V i |+|E Q ∪E i |)

[0025] In the formula, V Q and E Q The structured representation G of the input problem Q The set of entities and relations in the input problem, and the Jaccard similarity measure, measures the degree of overlap between the input problem and the candidate subgraph at the entity and relation level.

[0026] Here, semantic similarity is the similarity between the embedding vector of the question and the embedding vector of the reasoning path of the candidate subgraph, and is defined as:

[0027]

[0028] In the formula, X Q The semantic embedding of the input question Q is represented. Represents the reasoning path P i Embedding;

[0029] S23. Based on Jaccard similarity and semantic similarity, the inference path with the highest weighted score of Jaccard similarity and semantic similarity is represented as P. Q .

[0030] According to some embodiments of this application, the text fragment retrieval and answer generation method of a multi-hop agricultural question-answering system based on knowledge graph reasoning and large models, step S30 embeds the reasoning path into the input question to generate a knowledge-enhanced question representation containing multi-hop reasoning information, including embedding the reasoning path P... Q ={e1,r1,e2,…,e m The sequence T of the embedding representation of the input problem Q. Q ={q1,q2,…,q n The sequence T obtained from} Q ', representing The knowledge enhancement problem is represented as Q".

[0031] According to some embodiments of the present application, the text fragment retrieval and answer generation method of a multi-hop agricultural question-answering system based on knowledge graph reasoning and large models includes step S40 as follows:

[0032] The K-BERT model is used to generate D for each document paragraph in the text knowledge base. i Embedded vector representation Instead, the text is mapped to an embedding;

[0033] The knowledge enhancement problem representation Q" is subjected to vector retrieval, and the cosine similarity is used to measure the relationship between the knowledge enhancement problem representation Q" and each text segment D. i Embedded vector representation Similarity to obtain the D of each text paragraph i Similarity score, where the higher the similarity, the higher the score;

[0034] Based on similarity scores, text segment D... i Sort the text and select the top k highest-ranking text paragraphs D. i The set {D1, D2, ... D} k The relevant text fragments represent the knowledge enhancement problem.

[0035] According to some embodiments of the present application, the text fragment retrieval and answer generation method of a multi-hop agricultural question-answering system based on knowledge graph reasoning and large models includes step S50 as follows:

[0036] The knowledge enhancement problem is represented as Q" and the top k ranked text paragraphs D are... i The set {D1, D2, ... D} k Input retrieval augmented generative model (RAG);

[0037] The Retrieval Augmentation Generative Model (RAG) represents the knowledge augmentation problem Q" and the top k ranked text paragraphs D. i The set {D1, D2, ... D} k The sequences are concatenated to form the sequence I = [Q"; D1; D2; ... D]. K ];

[0038] The Retrieval Enhancement Generative Model (RAG) outputs the answer to the input question based on the deep semantics expressed by Sequence I and information related to the reasoning path.

[0039] In a second aspect, embodiments of this application also provide a multi-hop agricultural question-answering system based on knowledge graph reasoning and a large model. The system includes: one or more processors, a memory, and one or more programs; wherein the one or more programs are stored in the memory, and the one or more programs include instructions that, when executed by the system, cause the electronic device to perform the first aspect and any possible technical solution of the first aspect.

[0040] In a third aspect, embodiments of this application also provide a computer-readable storage medium comprising a computer program that, when executed on an electronic device, causes the electronic device to perform the first aspect and any possible technical solution of the first aspect.

[0041] In a fourth aspect, embodiments of this application also provide a computer program product, including a computer program / instructions, characterized in that the computer program / instructions, when executed by a processor, implement the first aspect and any possible technical solution of the first aspect.

[0042] Beneficial effects:

[0043] In the first aspect, the multi-hop reasoning question-answering system based on relational reasoning path enhancement of the present invention can extract key nodes and relationships from text and construct a knowledge graph covering topic keywords and important relationships. Through this knowledge graph, the system captures the core content of the text and provides a clear reasoning path for user questions. This reasoning path provides powerful clues for reasoning about complex multi-hop questions, making the process of text fragment retrieval and answer generation more accurate and efficient.

[0044] Secondly, this invention not only improves the accuracy of answer generation but also significantly enhances the reasoning ability of the question-answering system in multi-hop reasoning scenarios. By optimizing the construction of the knowledge graph and the reasoning process, it further improves the accuracy and efficiency of the question-answering system in handling multi-hop reasoning problems, providing strong technical support for problem-solving in the field of smart agriculture and accelerating the modernization of agriculture.

[0045] On a third-party level, this invention significantly enhances the ability of question-answering systems to handle complex multi-hop reasoning problems by constructing a knowledge graph containing topic keywords and important relationships, and providing reasoning paths based on this graph. This method not only improves the accuracy of answer generation but is also more efficient than multi-turn large-scale model reasoning methods based on thought chains. Furthermore, it can better capture the core content of the text, providing users with more accurate and logical answers.

[0046] Fourthly, this invention significantly enhances the ability of question-answering systems to handle complex multi-hop reasoning problems by constructing a knowledge graph encompassing topic keywords and key relationships, and by utilizing its reasoning paths to semantically enhance questions. By embedding the reasoning paths from the knowledge graph into the question expression, the system is enhanced in understanding the deep semantics and multi-step logical connections of the question. This method not only improves the accuracy of answer generation but also significantly improves reasoning efficiency, being more efficient than traditional multi-turn, large-scale model reasoning methods that rely on thought chains. Furthermore, the system can accurately extract core information from the text, making the generated answers more accurate and logical, providing users with clear and highly relevant solutions. Attached Figure Description

[0047] Figure 1 A flowchart of an agricultural multi-hop question-and-answer system provided in an embodiment of the present invention;

[0048] Figure 2 A flowchart for knowledge graph construction provided in an embodiment of the present invention;

[0049] Figure 3 A soft position coding construction diagram provided for embodiments of the present invention;

[0050] Figure 4 The text retrieval diagram provided for embodiments of the present invention. Detailed Implementation

[0051] The embodiments of this application are described in detail below with reference to the accompanying drawings, examples of which are illustrated in the drawings. This application provides a method, system, computer-readable storage medium, and program product. All are based on the same technical concept, and since the principles for solving the problem are similar, implementations can be referred to each other; repeated details will not be repeated.

[0052] like Figure 1 As shown, the text fragment retrieval and answer generation method of the multi-hop agricultural question-answering system based on knowledge graph reasoning and large model of the present invention includes the following steps:

[0053] S100: Extract key nodes and relationships from text to construct a knowledge graph.

[0054] S200: When a user asks a question, a knowledge graph search is performed to find the relevant reasoning path.

[0055] S300: Supplement key information in the question based on the retrieved reasoning path.

[0056] S400: Use the supplemented information to perform text retrieval and obtain relevant text fragments.

[0057] S500: Generates the final answer by combining the retrieved text fragments using the RAG model.

[0058] Specifically, step S100 further includes: extracting key nodes and relationships from the text and constructing a knowledge graph. The knowledge graph is constructed by extracting core entities and relationships from a batch of text data. These entities and relationships represent important themes and keywords in the text, rather than encompassing all information. Using the obtained entities and relationships, the system can construct a knowledge graph that details the key information in the text and their interrelationships. The beneficial effect of adopting the above further approach is that by constructing a detailed and structured knowledge graph, reasoning and retrieval can be effectively supported, facilitating subsequent multi-hop reasoning and improving the accuracy and efficiency of answer generation.

[0059] Further, step S200 specifically includes: when a user asks a question, performing a knowledge graph retrieval to find relevant reasoning paths. The reasoning paths refer to the entities and relationship networks related to the question retrieved from the knowledge graph. These reasoning paths demonstrate the core entities in the question and their interrelationships, helping the system understand the multi-hop relationships involved in the question. The system uses a similar subgraph retrieval method to find subgraphs similar to the question in the knowledge graph, and determines the most matching answer reasoning path based on a dual scoring mechanism that integrates Jaccard similarity and semantic similarity. The beneficial effect of adopting the above further solution is that by explicitly displaying the multi-layered relationship structure in the question, the reasoning paths provide the system with clear reasoning clues, helping to more accurately understand and answer complex multi-hop reasoning questions.

[0060] Further, step S300 specifically includes: supplementing the question with key information based on the retrieved reasoning path. The system utilizes the K-BERT model to embed relevant entities and relationships from the reasoning path into the original question, forming a knowledge-enhanced question representation. By inserting knowledge nodes from the reasoning path into the question and using mechanisms such as soft positional encoding and visibility matrices, the semantic structure of the original question is maintained while its semantic information is enriched. This process enables the system to gain a deeper understanding of the multi-hop associations involved in the question, providing more accurate query vectors for subsequent text retrieval. The beneficial effect of adopting the above further scheme is that by supplementing key information, the semantic representation of the question is enriched, accurately capturing the user's intent. This improves the accuracy of text retrieval, enabling the system to more effectively obtain text fragments related to the question, ultimately improving the quality of the answer.

[0061] Further, step S400 specifically includes: performing text retrieval using the supplemented information to obtain relevant text fragments. Specifically, the question representation enhanced by K-BERT knowledge is provided as input to the retrieval system. Based on this more complete and accurate question description, the retrieval system uses techniques such as vector retrieval to retrieve text fragments highly relevant to the question from the text knowledge base. The beneficial effect of adopting the above further solution is that by integrating key information in the reasoning path, the semantic representation of the question is enhanced, thereby improving the relevance and accuracy of the retrieval results to the question.

[0062] Further, step S500 specifically includes: inputting the retrieved text fragments and the question together into a large language model to generate the final answer. Specifically, the text fragments highly relevant to the question obtained in the previous step, along with the question enhanced with supplementary information, are input into the large language model. The model uses this information to comprehensively understand the question and related text content, generating a coherent and accurate answer. Because the question has been enriched with supplementary information from the reasoning path, the model can understand the deeper meaning of the question more deeply and generate the answer accordingly. The beneficial effect of adopting the above further approach is that by combining text fragments containing supplementary information, the large language model can generate more accurate answers that meet user needs, thereby improving the answer quality of multi-hop reasoning questions.

[0063] More specifically:

[0064] In step S100 of this invention, key nodes and relationships are extracted from text to construct a knowledge graph. This includes: using a large language model, combined with prompt engineering and few-shot learning, to automatically extract key entities and relationships from text in the agricultural field. The entity extraction process is specifically divided into the following three steps: First, determine the types of entities and relationships. Based on the characteristics of public knowledge graphs in the agricultural field, common entity types are determined, including: crops (e.g., rice, wheat), pests (e.g., rice planthoppers, corn borers), diseases (e.g., rice blast, sheath blight), fertilizers (e.g., urea, diammonium phosphate), pesticides (e.g., chlorothalonil, dichlorvos), agronomic measures (e.g., crop rotation, intercropping), regions, weather, etc. Corresponding relationship types include: harm, prevention, application, planting in, location, and adoption, etc. Second, use prompt engineering and few-shot learning to automatically extract entity relationships and construct triples. The prompt content should include task descriptions, output formats, and a few labeled examples to help the model generate the required triples.

[0065] In knowledge graph construction, the extracted triples are represented as a directed graph G = (E, V), where V is the set of entities and E is the set of relations. Each triple corresponds to an edge e = (v... i,r,v j ), where v i ,v j ∈V, where r is the relation type. This mathematical representation gives the knowledge graph a good structure, facilitating subsequent queries and reasoning. To ensure consistency between entities and relations, normalization is required. Normalization handles synonyms and polysemous words, ensuring that the same entity and the same relation have a unique representation, thus guaranteeing the uniformity and usability of the knowledge graph.

[0066]

[0067] In step S200 of this invention, when a user asks a question, a knowledge graph retrieval is performed to find relevant reasoning paths. This includes: when a user asks question Q, the system first processes it, extracts key entities and relationships, and forms a structured representation G of the question. Q To ensure the correspondence between problem entities and entities in the graph, the method in step 1 can be used to extract entities from the problem. This yields G. Q Then, the system retrieves reasoning paths related to the question from the knowledge graph. A reasoning path refers to the set of paths in the knowledge graph that start from the initial entity in the question, connect through a series of relations and entities, and reach the possible answer entity. Formally, a reasoning path can be represented as an ordered sequence of triples: P = {e1, r1, e2, ..., e...} m}. Among them, e i Represents an entity, r i Let m represent the relationship between entities, and m be the path length. To find the most relevant reasoning path, the system employs a similar subgraph retrieval method. Specifically, the system searches for all possible subgraphs G within the knowledge graph KG. i These subgraphs contain entities and relationships related to the problem, forming a set of candidate reasoning paths {P}. i Each candidate subgraph G i The set of nodes and edges contained are V. i and E i Then, the system represents the problem as G. Q and each candidate subgraph G i Calculate Jaccard similarity and semantic similarity to assess their matching degree. Jaccard similarity measures the degree of overlap between two sets and is defined as:

[0068] Jaccard(G Q G i )=(|V Q ∩V i |+|E Q ∩E i |) / (|V Q ∪Vi |+|E Q ∪E i |).

[0069] Among them, V Q and E Q These represent the sets of entities and relations in the problem representation, respectively. This similarity measure indicates the degree of overlap between the problem and the candidate subgraph at the entity and relation levels.

[0070] Semantic similarity is calculated by directly using the similarity between the question's embedding vector and the embedding vectors of the candidate subgraph's reasoning path. The formula is the cosine similarity calculated over the overall semantic embedding. Let X be the semantic embedding of question Q. Q Reasoning path P i Embedded notation The formula for calculating cosine similarity is:

[0071]

[0072] Based on the above similarity calculation, the path with the highest weighted score of graph similarity and semantic similarity is selected and denoted as the selected P. Q .

[0073] In step S300 of this invention, key information in the problem is supplemented based on the retrieved inference path. This includes: the invention uses K-BERT to embed the retrieved inference path into the original problem, thereby generating a knowledge-enhanced problem representation containing multi-hop inference information. This process ensures that the original problem structure is not destroyed through mechanisms such as soft positional encoding and visibility matrix, while introducing additional knowledge node information, enabling the model to have a deeper understanding of the problem.

[0074] Suppose the embedding of the original problem Q is represented as a sequence T. Q ={q1,q2,…,q n}, reasoning path P Q It is also a sequence, represented as {e1,r1,e2,…,e m We embed the reasoning path into the embedding representation of the problem, forming a new sequence T. Q ':

[0075]

[0076] K-BERT's structure is essentially an improvement on the Transformer model. In the Transformer model, positional encoding provides the model with the positional information of each word in the sequence, enabling the model to perceive the order and structure of the input sequence. However, when knowledge nodes in the inference path are directly inserted into the original question sequence, the positional information of the original words changes, affecting the model's understanding of the original word order. Therefore, soft positional encoding is introduced here. This method assigns relative positional codes to knowledge nodes in the inference path, ensuring that the word order of the original question remains unchanged, while effectively integrating the information of the knowledge nodes into the model's input. Furthermore, since knowledge nodes in the inference path are only related to a portion of the vocabulary in the question sequence and have minimal correlation with other words, a visibility matrix V is introduced to avoid the triples significantly affecting the original question sequence. This matrix defines the information flow between each node and the visibility between words in the original question sequence. (Fully visible), while for knowledge nodes and original question words in the reasoning path, partial visibility can be set according to semantic needs to avoid excessive interference. In this way, the system can obtain knowledge-enhanced question vectors containing multi-hop reasoning information, making subsequent text retrieval more accurate.

[0077] In step S400 of this invention, text retrieval is performed using the supplemented information to obtain relevant text fragments. This includes: before text retrieval, the text needs to be mapped to an embedding using an embedding model. To ensure that the question and text are mapped to the same semantic space, the K-BERT model is still used to generate each document segment D in the text knowledge base. i Embedded vector representation The knowledge-enhanced question representation Q" from step 3 is input into the vector retrieval system, and cosine similarity is used to measure the similarity between the knowledge-enhanced question representation Q" and the representation of each text segment. To assess similarity, all text paragraphs are ranked by similarity score, and the top k paragraphs with the highest scores are selected as the set of text segments most relevant to the question. This set of text segments {D1, D2, ... D...} is then used to determine the most relevant text segments to the question. k The extracted values ​​will be used as input for generating the answer.

[0078] In step S500, generating the final answer by combining the retrieved text fragments using the RAG model includes: during the process of generating the final answer, the question representation Q" enhanced with supplementary information is combined with the retrieved set of relevant text fragments {D1, D2, ... D...}. k The inputs are then fed into a large language model M to generate the answer. Specifically, the question representation and text fragments are first concatenated to form the input sequence: I = [Q"; D1; D2; ... D KThe semicolon "】" indicates sequence concatenation. After receiving the input sequence I, model M uses its reasoning capabilities to comprehensively understand the question and related text content. When generating the answer, the model considers the deep semantics of the question and information related to the reasoning path, thus ensuring the coherence and accuracy of the answer.

[0079] The implementation method of the present invention has been described in detail above, but the present invention is not limited to the above implementation method. The present invention significantly improves the ability of a question-answering system to handle complex multi-hop reasoning problems by constructing a knowledge graph covering topic keywords and key relationships, and using its reasoning paths to semantically enhance questions. By embedding the reasoning paths in the knowledge graph into the question expression, the system is enhanced in understanding the deep semantics and multi-step logical connections of the question. This method not only improves the accuracy of answer generation but also significantly improves reasoning efficiency, being more efficient than traditional multi-turn large-scale model reasoning methods that rely on thought chains. Furthermore, the system can accurately extract core information from the text, making the generated answers more accurate and logical, providing users with clear and highly relevant solutions.

[0080] Based on the above embodiments, this application also provides a computer program that, when run on a computer, causes the computer to execute the methods provided in the above embodiments.

[0081] Based on the above embodiments, this application also provides a computer storage medium storing a computer program, which, when executed by a computer, causes the computer to perform the methods provided in the above embodiments.

[0082] The storage medium can be any available medium that a computer can access. For example, but not limited to, a computer-readable medium can include RAM, ROM, EEPROM, CD-ROM or other optical disk storage, magnetic disk storage media or other magnetic storage devices, or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and that can be accessed by a computer.

[0083] Based on the above embodiments, this application also provides a chip for reading a computer program stored in a memory to implement the method provided in the above embodiments.

[0084] Based on the above embodiments, this application provides a computer program product that implements the methods provided in the above embodiments when the computer program product is run on an electronic device.

[0085] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0086] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to this application. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0087] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0088] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0089] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.

Claims

1. A method for text fragment retrieval and answer generation in a multi-hop agricultural question-answering system based on knowledge graph reasoning and large-scale models, characterized in that, include S10. Extract the key entities and relationships of the input problem to construct a structured representation of the input problem; S20. Based on the structured representation of the input question, retrieve the reasoning path related to the question in the agricultural domain knowledge graph; S30. Embed the reasoning path into the input question, assign relative position codes to the knowledge nodes in the reasoning path using soft position coding, and use the visibility matrix... Define the information flow between each node to generate a knowledge-enhanced problem representation that includes multi-hop reasoning information; S40. Perform text retrieval based on the knowledge-enhanced question representation to obtain relevant text fragments; S50. Input the knowledge-enhanced question representation and the text fragment into the retrieval enhancement generation model (RAG), and have the retrieval enhancement generation model output the answer to the input question; In step S30, embedding the reasoning path into the input question to generate a knowledge-enhanced question representation containing multi-hop reasoning information includes embedding the reasoning path... Embedded input problem The sequence of embedding representations The sequence obtained , represented as The knowledge enhancement problem is represented as described above. ; Step S40 includes: The K-BERT model is used to generate each document paragraph in the text knowledge base. Embedded vector representation Instead, the text is mapped to an embedding; Represent the knowledge augmentation problem Vector retrieval is performed, and the knowledge enhancement problem representation is measured using cosine similarity. With each text paragraph Embedded vector representation Similarity to obtain the text paragraphs Similarity score, where the higher the similarity, the higher the score; Based on similarity scores, text paragraphs are analyzed. Sort, and select the highest-ranking item. a text paragraph set The relevant text fragments represent the knowledge enhancement problem. Step S50 includes: Represent the knowledge augmentation problem and the highest-ranked a text paragraph set Input retrieval augmented generative model (RAG); Retrieval Augmentation Generative Model (RAG) represents the knowledge augmentation problem. and the highest-ranked a text paragraph set To splice together to form a sequence ; Retrieval Enhanced Generative Model (RAG) based on sequence The deep semantics expressed and the information related to the reasoning path are used to output the answer to the input question.

2. The text fragment retrieval and answer generation method for a multi-hop agricultural question-answering system based on knowledge graph reasoning and large-scale models as described in claim 1, is characterized in that, Step S20 involves constructing a knowledge graph for the agricultural domain, including automatically extracting key entities and relationships from agricultural texts using large language models, prompting engineering, and few-shot learning; this includes: Identify entity and relation types, where: entity types include crops, pests, diseases, fertilizers, pesticides, agronomic measures, regions, and weather; relation types include harm, control, application, planting in, location, and adoption; Automatic entity relation extraction and triple construction are performed using cue engineering and few-shot learning. The cue content includes task description, output format and a few labeled examples. Representing triples as directed graphs ,in For a collection of entities, For a set of relations, each triple corresponds to an edge. ,in , It is a relation type.

3. The text fragment retrieval and answer generation method for a multi-hop agricultural question-answering system based on knowledge graph reasoning and large-scale models as described in claim 1, is characterized in that... In step S10, the question-answering system extracts the key entities and relationships of the input question to construct a structured representation of the input question. .

4. The text fragment retrieval and answer generation method for a multi-hop agricultural question-answering system based on knowledge graph reasoning and large-scale models as described in claim 3, is characterized in that... In step S20, the inference path is represented as an ordered sequence of triples: in, Represents an entity, Representing entities and The relationship between them This represents the path length. Step S20 involves retrieving reasoning paths related to the problem from the agricultural knowledge graph, including: S21. Knowledge Graphs in the Agricultural Field Search the subgraph for all entities and relationships related to the input question. This forms a set of candidate reasoning paths. Each candidate subgraph The sets of nodes and edges contained are respectively and ; S22. Calculate the structured representation of the input problem. and each candidate subgraph The Jaccard similarity and semantic similarity; where Jaccard similarity measures the degree of overlap between two sets, defined as: In the formula, and The structured representation of the input problem The set of entities and relations in the input problem, and the Jaccard similarity measure, measures the degree of overlap between the input problem and the candidate subgraph at the entity and relation level. Here, semantic similarity is the similarity between the embedding vector of the question and the embedding vector of the reasoning path of the candidate subgraph, and is defined as: In the formula, Indicates input problem semantic embedding, Indicating the reasoning path Embedding; S23. Based on Jaccard similarity and semantic similarity, the inference path with the highest weighted score of Jaccard similarity and semantic similarity is represented as follows: .

5. A multi-hop agricultural question-answering system based on knowledge graph reasoning and a large-scale model, wherein the multi-hop agricultural question-answering system based on knowledge graph reasoning and a large-scale model includes: One or more processors, a memory, and one or more programs; wherein the one or more programs are stored in the memory, and the one or more programs include instructions that, when executed by the system, cause the system to perform the method of any one of claims 1-4.

6. A computer-readable storage medium comprising a computer program that, when executed on an electronic device, causes the electronic device to perform the method of any one of claims 1-4.

7. A computer program product comprising a computer program / instructions, characterized in that, When the computer program / instructions are executed by the processor, they implement the method described in any one of claims 1-4.

Citation Information

Patent Citations

  • Knowledge graph generation type question answering method and system based on large language model

    CN117033608A

  • Output method, device and equipment for retrieval enhancement generation type questions and answers and storage medium

    CN119046433A