Multi-hop agricultural question-answering system based on knowledge graph reasoning and large model and text fragment retrieval and answer generation method thereof
By constructing a knowledge graph in the agricultural field and using search enhancement generative model, the traditional question-and-answer system has solved the problems of incomplete information retrieval and limited inference capabilities in multi-hop reasoning problems, achieving more accurate and efficient answer generation.
Patent Information
- Application Number
- CN202411852050.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-16
- Publication Date
- 2025-04-08
- Estimated Expiration
- 2044-12-16
AI Technical Summary
When dealing with complex multi-hop reasoning problems, traditional question-and-answer systems have problems such as incomplete information retrieval, limited relationship reasoning capabilities and difficult text generation.
By constructing a knowledge graph in the agricultural field, key entities and relationships of input problems are extracted, knowledge-enhanced problem representations containing multi-hop reasoning information are generated, and answers are generated using a search enhancement generation model (RAG) combined with text fragments.
It significantly improves the reasoning ability and accuracy of answer generation of the question-and-answer reasoning system in multi-hop reasoning scenarios, and can more accurately understand and answer complex multi-hop reasoning questions.
Smart Images

Figure CN119782467A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of agricultural intelligent question answering, and in particular relates to an agricultural intelligent question answering system based on knowledge graph reasoning and large model retrieval enhancement generation technology, as well as a text fragment retrieval and answer generation method of the system. Background Art
[0002] Smart agriculture, as the core driving force for the development of modern agriculture, 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, and realizes the precision of crop planting, the intelligence of pest and disease prevention and control, and the efficient use of agricultural resources. In this context, the importance of intelligent question-answering systems has become increasingly prominent. Intelligent question-answering systems can provide farmers and agricultural practitioners with timely and accurate technical guidance and policy interpretation, helping them quickly solve technical bottlenecks and policy confusions encountered in smart agricultural practices. This not only contributes to the popularization and application of smart agricultural technologies, but also lays a solid foundation for promoting the process of agricultural modernization.
[0003] In recent years, with the rapid development of artificial intelligence technology, large pre-trained models (such as GPT, BERT, etc.) have achieved remarkable results in the field of intelligent question answering. These models have powerful language understanding and generation capabilities, can efficiently answer various complex questions, and provide strong support for building efficient and intelligent question answering systems. However, when dealing with complex problems that require multi-step reasoning, traditional question answering systems still have certain limitations.
[0004] Retrieval-augmented generation (RAG) technology, as a method that 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 text data. When dealing with simple question-answering tasks, RAG technology performs well because it can efficiently utilize information in external knowledge bases and significantly enhance the model's answering ability.
[0005] However, when faced with complex multi-hop reasoning problems, traditional RAG technology seems to be unable to cope with it. Multi-hop reasoning problems refer to the type of questions that require crossing multiple text fragments or knowledge nodes in the answering process and can only be concluded through chain reasoning. Such questions usually involve complex logical relationships, multi-level semantic understanding, and cross-text information integration, which poses severe challenges to the information retrieval, relational reasoning, and text generation capabilities of the question-answering system.
[0006] When dealing with multi-hop reasoning problems, the limitations of traditional RAG technology are mainly reflected in the following aspects: First, in terms of information retrieval, traditional RAG technology is highly dependent on efficient information retrieval mechanisms to accurately capture text fragments closely related to the problem. However, due to the wide distribution of information and complex associations in multi-hop problems, retrieval methods based on keyword matching or semantic similarity often find it difficult to fully and accurately capture all key information points. This may lead to incomplete retrieval results and affect 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 that require multi-step reasoning. This makes it difficult for the model to give accurate and convincing answers. Finally, in the text generation link, traditional RAG technology also faces challenges. Due to the need to process a large amount of information with complex relationships, RAG models are particularly difficult to generate coherent and accurate answers. This requires not only that the model has strong text generation capabilities, but also that it can flexibly cope with various complex information combinations and relational reasoning to ensure that the generated answers are both accurate and logical. Summary of the invention
[0007] In order to solve the above problems, according to some embodiments of the present application, a text fragment retrieval and answer generation method of a multi-hop agricultural question-answering system based on knowledge graph reasoning and a large model includes:
[0008] S10. Extract key entities and relations of the input question to construct a structured representation of the input question;
[0009] S20. According to the structured representation of the input question, searching the reasoning path related to the question in the agricultural field knowledge graph;
[0010] S30. embedding 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 a retrieval-enhanced generation model (RAG), and the retrieval-enhanced generation model outputs an answer to the input question.
[0013] According to the text fragment retrieval and answer generation method of the multi-hop agricultural question-answering system based on knowledge graph reasoning and large model in some embodiments of the present application, the construction of the agricultural field knowledge graph in step S20 includes automatically extracting key entities and relationships from the agricultural field text to construct the agricultural field knowledge graph through a large language model, prompt engineering and few-sample learning; including:
[0014] Determine entity and relationship types, where: entity types include crops, pests, diseases, fertilizers, pesticides, agronomic measures, regions, and weather; relationship types include harm, control, apply, planted in, located in, and adopt;
[0015] Automatically extract entity relations and construct triples using prompt engineering and few-shot learning, where prompts include task instructions, output format, and a small number of annotated examples.
[0016] The triples are represented as a directed graph G = (E, V), where V is the entity set, E is the relationship set, and each triple corresponds to an edge e = (v i ,r,v j ), where v i ,v j ∈V, r is the relationship type.
[0017] According to the text fragment retrieval and answer generation method of the multi-hop agricultural question-answering system based on knowledge graph reasoning and large model in some embodiments of the present application, in step S10, the question-answering system extracts the 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 the multi-hop agricultural question-answering system based on knowledge graph reasoning and large model in some embodiments of the present 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, M is the path length;
[0021] In step S20, the reasoning path related to the problem is retrieved in the agricultural field knowledge graph, including:
[0022] S21. Search the agricultural knowledge graph KG for all subgraphs G containing entities and relationships related to the input question i , forming a set of candidate reasoning paths {P i}, each candidate subgraph G i The sets of nodes and edges included are V i and E i ;
[0023] S22. Compute the structured representation G of the input problem Q And each candidate subgraph G iJaccard similarity and semantic similarity; Jaccard similarity measures the degree of overlap between two sets and is 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] Where V Q and E Q The structured representation G of the input problem is Q The Jaccard similarity measures the overlap between the input question and the candidate subgraph at the entity and relationship level.
[0026] Among them, the semantic similarity is the similarity between the embedding vector of the question and the embedding vector of the candidate subgraph reasoning path, which is defined as:
[0027]
[0028] Where, X Q represents the semantic embedding of the input question Q, Represents the reasoning path P i Embedding
[0029] S23. According to Jaccard similarity and semantic similarity, the set of reasoning paths with the highest weighted scores of Jaccard similarity and semantic similarity is represented as P Q .
[0030] According to the text fragment retrieval and answer generation method of the multi-hop agricultural question-answering system based on knowledge graph reasoning and large model in some embodiments of the present application, in step S30, the reasoning path is embedded in 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}Embed the sequence T of the embedding representation of the input question Q Q ={q1,q2,…,q n} to get the sequence T Q ', expressed as The knowledge enhancement problem is expressed as Q".
[0031] According to the text fragment retrieval and answer generation method of a multi-hop agricultural question-answering system based on knowledge graph reasoning and a large model in some embodiments of the present application, step S40 includes:
[0032] Through the K-BERT model to generate each document paragraph D in the text knowledge base i The embedding vector representation of Instead, the text is mapped as an embedding;
[0033] The knowledge enhancement question representation Q" is vector retrieved, and the cosine similarity is used to measure the relationship between the knowledge enhancement question representation Q" and each text paragraph D i The embedding vector representation of , and obtain each text paragraph D i Similarity score, where the higher the similarity, the higher the score;
[0034] According to the similarity score, the text paragraph D i Sort, and sort the top k text paragraphs D with the highest ranking i The set {D1,D2,…D k} as the relevant text fragments for the knowledge-enhanced question representation.
[0035] According to the text fragment retrieval and answer generation method of the multi-hop agricultural question-answering system based on knowledge graph reasoning and large model in some embodiments of the present application, step S50 includes:
[0036] The knowledge enhancement question is represented as Q" and the top k text paragraphs with the highest ranking are D i The set {D1,D2,…D k} Input Retrieval Augmented Generation Model (RAG);
[0037] The retrieval-augmented generation model (RAG) represents the knowledge-augmented question Q" and the top k text paragraphs D with the highest ranking. i The set {D1,D2,…D k} are spliced to form a sequence I = [Q"; D1; D2; ... D K ];
[0038] The retrieval-augmented generation model (RAG) outputs the answer to the input question based on the deep semantics expressed by sequence I and the information related to the reasoning path.
[0039] In the second aspect, an embodiment of the present application also provides a multi-hop agricultural question-answering system based on knowledge graph reasoning and large models, the system comprising: 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, which, when executed by the system, enable the electronic device to execute the first aspect and any possible technical solution of the first aspect.
[0040] In a third aspect, an embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium includes a computer program. When the computer program runs on an electronic device, the electronic device executes the first aspect and any possible technical solution of the first aspect.
[0041] In a fourth aspect, an embodiment of the present application further provides a computer program product, comprising a computer program / instruction, characterized in that when the computer program / instruction is executed by a processor, the computer program / instruction implements 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 the enhanced relational reasoning path of the present invention can extract key nodes and relationships from the 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 the reasoning of complex multi-hop questions, making it more accurate and efficient in the process of text fragment retrieval and answer generation.
[0044] In the second aspect, the present 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 and reasoning process of the knowledge graph, the accuracy and efficiency of the question-answering system in dealing with multi-hop reasoning problems are further improved, providing strong technical support for answering questions in the field of smart agriculture and helping to accelerate the development of agricultural modernization.
[0045] On the third aspect, the present invention significantly enhances the ability of the question-answering system 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. This method not only improves the accuracy of answer generation, but is also more efficient than the multi-round large-scale model reasoning method based on the chain of thought. In addition, it can better capture the core content of the text and provide users with more accurate and logical answers.
[0046] In the fourth aspect, the present invention significantly improves the ability of the 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 path to semantically enhance the questions. By embedding the reasoning path in the knowledge graph into the question expression, the system is enhanced in understanding the deep semantics and multi-step logical associations of the problem. This method not only improves the accuracy of answer generation, but also significantly improves the reasoning efficiency, which is more efficient than the traditional multi-round large-scale model reasoning method that relies on the chain of thinking. In addition, the system can accurately extract the core information in the text, making the generated answers more accurate and logical, and providing users with clear and highly relevant answers. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] Figure 1 A flow chart of an agricultural multi-hop question-answering system provided by an embodiment of the present invention;
[0048] Figure 2 A flow chart for constructing a knowledge graph provided by an embodiment of the present invention;
[0049] Figure 3 A soft position coding construction diagram provided by an embodiment of the present invention;
[0050] Figure 4 A text retrieval graph provided for an embodiment of the present invention. DETAILED DESCRIPTION
[0051] The embodiments of the present application are described in detail below with reference to the accompanying drawings, examples of which are shown in the accompanying drawings. The present application provides a method, a system, a computer-readable storage medium, and a program product. They are based on the same technical concept, and since the principles of solving the problems are similar, the implementations can refer to each other, and the repeated parts 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: Obtain key nodes and relationships from text and build a knowledge graph.
[0054] S200: When a user asks a question, a knowledge graph search is performed to find relevant reasoning paths.
[0055] S300: Supplement key information in the question based on the retrieved reasoning path.
[0056] S400: Perform text retrieval using the supplemented information to obtain relevant text fragments.
[0057] S500: Generate the final answer by combining the retrieved text fragments through the RAG model.
[0058] Specifically, further, the step S100 specifically includes: obtaining key nodes and relationships from the text, and constructing a knowledge graph. The method for constructing the knowledge graph is to extract core entities and relationships from a batch of text data. These entities and relationships represent important topics and keywords in the text, rather than covering all information. Using the acquired entities and relationships, the system can construct a knowledge graph that describes in detail the key information in the text and their relationship with each other. The beneficial effect of adopting the above further scheme is: by constructing a detailed and structured knowledge graph, it can effectively support reasoning and retrieval, facilitate subsequent multi-hop reasoning, and improve the accuracy and efficiency of answer generation.
[0059] Furthermore, the step S200 specifically includes: when the user asks a question, a knowledge graph search is performed to find relevant reasoning paths. The reasoning path refers to the entity and relationship network related to the question retrieved from the knowledge graph. These reasoning paths show the core entities in the question and their mutual relationships, helping the system understand the multi-hop relationships involved in the question. The system searches for subgraphs similar to the question from the knowledge graph through a similar subgraph retrieval method, 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 scheme is that by clearly displaying the multi-layer association structure in the question, the reasoning path provides the system with clear reasoning clues, which helps to more accurately understand and answer complex multi-hop reasoning problems.
[0060] Furthermore, the step S300 specifically includes: supplementing the key information of the question according to the retrieved reasoning path. The system uses the K-BERT model to embed the relevant entities and relationships in the reasoning path into the original question to form a knowledge-enhanced question representation. By inserting the knowledge nodes in the reasoning path into the question and using mechanisms such as soft position encoding and visibility matrix, the semantic structure of the original question is maintained while enriching its semantic information. This process enables the system to have a deeper understanding of the multi-hop associations involved in the question and provide a more accurate query vector for subsequent text retrieval. The beneficial effect of adopting the above further scheme is: by supplementing key information, the semantic representation of the question is enriched and the user's intention is accurately captured. This improves the accuracy of text retrieval, enables the system to more effectively obtain text fragments related to the question, and ultimately improves the quality of the answer.
[0061] Furthermore, the step S400 specifically includes: using the supplemented information to perform text retrieval 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 vector retrieval and other technologies to retrieve text fragments that are highly relevant to the question from the text knowledge base. The beneficial effect of adopting the above further scheme is that by integrating the 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] Furthermore, the step S500 specifically includes: inputting the retrieved text fragments together with the question into a large language model to generate a final answer. Specifically, the text fragments highly relevant to the question obtained in the previous step are input into the large language model together with the question enhanced with supplementary information. The model uses this information to comprehensively understand the question and related text content to generate a coherent and accurate answer. Since the question has been enriched with the supplementary information of the reasoning path, the model can more deeply understand the deep meaning of the question and generate an answer accordingly. The beneficial effect of adopting the above further scheme is that by combining the text fragments containing supplementary information, the large language model can generate more accurate answers that meet user needs, thereby improving the quality of solving multi-hop reasoning problems.
[0063] More specifically:
[0064] Among them, in step S100 of the present invention, key nodes and relationships are obtained from the text to construct a knowledge graph, including: using a large language model, combined with prompt engineering (Prompt Engineering) and few-shot learning (Few-shot Learning), automatically extracting key entities and relationships from the text in the agricultural field, and the entity extraction process is specifically divided into the following three steps. The first step is to determine the entity and relationship types. Combined with the characteristics of the public knowledge graph in the agricultural field, common entity types are determined, including: crops (such as rice, wheat), pests (such as rice planthoppers, corn borers), diseases (such as rice blast, sheath blight), fertilizers (such as urea, diammonium phosphate), pesticides (such as thiophanate-methyl, dichlorvos), agronomic measures (such as rotation, intercropping), regions, weather, etc. The corresponding relationship types include: harm, prevention, application, planting, located and adopted, etc. The second step is to use prompt engineering and few-shot learning to automatically extract entity relationships and construct triples. The prompt content should include task instructions, output format, and a small number of annotated examples to help the model generate the required triples.
[0065] In the construction of knowledge graph, the extracted triples are represented as a directed graph G = (E, V), where V is the entity set and E is the relationship set. Each triple corresponds to an edge e = (v i,r,v j ), where v i ,v j ∈V, r is the relationship type. This mathematical representation method makes the knowledge graph well structured, which is convenient for subsequent query and reasoning. In order to ensure the consistency of entities and relationships, entities and relationships need to be normalized. Normalization handles synonyms and polysemous words to ensure that the same entity and the same relationship have a unique representation, which can ensure the unity and availability of the knowledge graph.
[0066]
[0067] In step S200 of the present invention, when a user asks a question, a knowledge graph search is performed to find a relevant reasoning path, including: when a user asks a question Q, the system first processes it, extracts key entities and relationships therein, and forms a structured representation G of the question. Q In order to ensure the correspondence between the problem entity and the entity in the graph, the method in step 1 can be used to extract the entity in the problem. Q After that, the system retrieves the reasoning path related to the question in the knowledge graph. The reasoning path refers to the set of paths in the knowledge graph that start from the starting entity in the question and reach the possible answer entity through a series of relationships and entity connections. Formally, the 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 represents the relationship between entities, and m is the path length. In order to find the most relevant reasoning path, the system uses the similar subgraph retrieval method. Specifically, the system searches for all possible subgraphs G in the knowledge graph KG. i , these subgraphs contain entities and relations related to the problem, forming a set of candidate reasoning paths {P i}. Each candidate subgraph G i The node and edge sets included are V i and E i Then, the system represents the problem G Q And each candidate subgraph G i Calculate Jaccard similarity and semantic similarity to evaluate the degree of match. 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 are the entity and relation sets in the question representation, respectively. This similarity measures the overlap between the question and the candidate subgraph at the entity and relation levels.
[0070] The semantic similarity is calculated by directly using the similarity between the embedding vector of the question and the embedding vector of the candidate subgraph reasoning path. The formula is to calculate the cosine similarity of the overall semantic embedding. The semantic embedding of question Q is denoted as X Q , reasoning path P i The embedding of The formula for calculating cosine similarity is:
[0071]
[0072] According to the calculation of the above similarity, a group of paths with the highest weighted scores of graph similarity and semantic similarity are selected and recorded as the selected P Q .
[0073] Among them, in step S300 of the present invention, the key information in the question is supplemented according to the retrieved reasoning path, including: the present invention uses K-BERT to embed the retrieved reasoning path into the original question, thereby generating a knowledge-enhanced question representation containing multi-hop reasoning information. This process ensures that the original question structure is not destroyed through mechanisms such as soft position encoding and visibility matrix, and at the same time introduces additional knowledge node information, so that the model has a deeper understanding of the problem.
[0074] Assume that the embedding of the original question Q is represented as a sequence T Q ={q1,q2,…,q n}, reasoning path P Q It is also a set of sequences, represented by {e1,r1,e2,…,e m}, we embed the reasoning path into the embedding representation of the problem to form a new sequence T Q ':
[0075]
[0076] The structure of K-BERT is essentially an improvement based on Transformer. In the Transformer model, position encoding provides the model with the position information of each word in the sequence, enabling the model to perceive the order and structure of the input sequence. However, when the knowledge nodes in the reasoning path are directly inserted into the sequence of the original question, the position information of the original words will change, causing the model's understanding of the original word order to be affected. Therefore, soft position encoding is introduced here. This method assigns relative position encodings to the knowledge nodes in the reasoning path to ensure that the word order of the original question remains unchanged, while effectively integrating the information of the knowledge nodes into the input of the model. In addition, since the knowledge nodes on the reasoning path are only related to some of the words in the question sequence and have little correlation with other words, in order to avoid the triples from having a greater impact on the original question sequence, the visibility matrix V is introduced here. This matrix defines the flow of information between each node, and the visibility between the words in the original question. (Fully visible), while for the 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 the present invention, the supplemented information is used to perform text retrieval to obtain relevant text fragments, including: before text retrieval, the text needs to be mapped to embedding using an embedding model. In order to ensure that the question and the text can be mapped to the same semantic space, the K-BERT model is still used to generate each document paragraph D in the text knowledge base. i The embedding vector representation of The knowledge-enhanced question representation Q" in step 3 is input into the vector retrieval system, and the cosine similarity is used to measure the similarity between the knowledge-enhanced question representation Q" and each text paragraph representation. The similarity of all text paragraphs is sorted, and the top k paragraphs with the highest scores are selected as the set of text segments most relevant to the question. k} is extracted and will be used as input for answer generation later.
[0078] Wherein, in step S500, the final answer is generated by combining the RAG model with the retrieved text fragments, including: in the process of generating the final answer, the question representation Q" enhanced with the supplementary information is combined with the retrieved related text fragment set {D1, D2, ... D k} are input into the large language model M to generate the answer. Specifically, the question representation and the text fragment are first concatenated to form an input sequence: I = [Q"; D1; D2; ... D K]. ";" represents the concatenation operation of the sequence. After receiving the input sequence I, the model M uses the reasoning ability of the large model to comprehensively understand the question and related text content. When generating answers, the model considers the deep semantics of the question and information related to the reasoning path, thereby ensuring the coherence and accuracy of the answer.
[0079] The implementation method of the present invention is described in detail above, but the present invention is not limited to the above implementation method. The present invention significantly improves the ability of the 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 path to semantically enhance the question. By embedding the reasoning path in the knowledge graph into the question expression, the system is enhanced in understanding the deep semantics and multi-step logical associations of the question. This method not only improves the accuracy of answer generation, but also significantly improves the reasoning efficiency, which is more efficient than the traditional multi-round large-scale model reasoning method that relies on the chain of thinking. In addition, the system can accurately extract the core information in the text, so that the generated answers are more accurate and logical, providing users with clear and highly relevant answers.
[0080] Based on the above embodiments, the embodiments of the present application further provide a computer program, which, when executed on a computer, enables the computer to execute the methods provided in the above embodiments.
[0081] Based on the above embodiments, the embodiments of the present application further provide a computer storage medium, in which a computer program is stored. When the computer program is executed by a computer, the computer executes the method provided in the above embodiments.
[0082] The storage medium may be any available medium that can be accessed by a computer. For example, but not limited to, a computer-readable medium may include RAM, ROM, EEPROM, CD-ROM or other optical disk storage, magnetic disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer.
[0083] Based on the above embodiments, an embodiment of the present application further provides a chip, which is used to read a computer program stored in a memory to implement the method provided in the above embodiments.
[0084] Based on the above embodiments, an embodiment of the present application provides a computer program product. When the computer program product is run on an electronic device, the method provided in the above embodiments is implemented.
[0085] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0086] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0087] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0088] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0089] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.
Claims
1. A text fragment retrieval and answer generation method for a multi-hop agricultural question-answering system based on knowledge graph reasoning and a large model, characterized in that: include S10. extract key entities and relations of the input question to construct a structured representation of the input question; S20. According to the structured representation of the input question, searching the reasoning path related to the question in the agricultural field knowledge graph; S30. embedding the reasoning path into the input question to generate a knowledge-enhanced question representation containing 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 a retrieval-enhanced generation model (RAG), and the retrieval-enhanced generation model outputs an answer to the input question.
2. The method for text fragment retrieval and answer generation of a multi-hop agricultural question-answering system based on knowledge graph reasoning and large model according to claim 1 is characterized in that: The construction of the agricultural field knowledge graph in step S20 includes automatically extracting key entities and relationships from agricultural field texts through a large language model, prompt engineering, and few-sample learning to construct an agricultural field knowledge graph; including: Determine entity and relationship types, where: entity types include crops, pests, diseases, fertilizers, pesticides, agronomic measures, regions, and weather; relationship types include harm, control, apply, planted in, located in, and adopt; Automatically extract entity relations and construct triples using prompt engineering and few-shot learning, where prompts include task instructions, output format, and a small number of annotated examples. The triples are represented as a directed graph G = (E, V), where V is the entity set, E is the relationship set, and each triple corresponds to an edge e = (v i ,r,v j ), where v i ,v j ∈V, r is the relationship type.
3. The text fragment retrieval and answer generation method of the multi-hop agricultural question-answering system based on knowledge graph reasoning and large model according to claim 1 is characterized in that: In step S10, the question answering system extracts the key entities and relations of the input question to construct a structured representation G of the input question. Q .
4. The method for text fragment retrieval and answer generation of a multi-hop agricultural question-answering system based on knowledge graph reasoning and large model according to claim 3 is characterized in that: The reasoning path in step S20 is represented as an ordered sequence of triples: P={e1,r1,e2,...,e m } Among them, e i Represents an entity, r i Represents entity e i+1 With e i The relationship between them, m is the path length; In step S20, the reasoning path related to the problem is retrieved in the agricultural field knowledge graph, including: S21. Search the agricultural knowledge graph KG for all subgraphs G containing entities and relationships related to the input question i , forming a set of candidate reasoning paths {P i }, each candidate subgraph G i The sets of nodes and edges included are V i and E i ; S22. Compute the structured representation G of the input problem Q And each candidate subgraph G i Jaccard similarity and semantic similarity; Jaccard similarity measures the degree of overlap between two sets and is defined as: Jaccard(G Q ,G i )=(|V Q ∩V i |+|E Q ∩E i |) / (V Q ∪V i |+|E Q ∪E i |) Where V Q and E Q The structured representation G of the input problem is Q The Jaccard similarity measures the overlap between the input question and the candidate subgraph at the entity and relationship level. Among them, the semantic similarity is the similarity between the embedding vector of the question and the embedding vector of the candidate subgraph reasoning path, which is defined as: Where, X Q represents the semantic embedding of the input question Q, Represents the reasoning path P i Embedding S23. According to Jaccard similarity and semantic similarity, the set of reasoning paths with the highest weighted scores of Jaccard similarity and semantic similarity is represented as P Q .
5. The method for text fragment retrieval and answer generation of a multi-hop agricultural question-answering system based on knowledge graph reasoning and large model according to claim 4 is characterized in that: In step S30, the reasoning path is embedded 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 }Embed the sequence T of the embedding representation of the input question Q Q ={q1,q2,…,q n } to get the sequence T Q ', expressed as The knowledge enhancement problem is expressed as Q".
6. The method for text fragment retrieval and answer generation of a multi-hop agricultural question-answering system based on knowledge graph reasoning and large model according to claim 5 is characterized in that: Step S40 includes: Through the K-BERT model to generate each document paragraph D in the text knowledge base i The embedding vector representation of Instead, the text is mapped as an embedding; The knowledge enhancement question representation Q" is vector retrieved, and the cosine similarity is used to measure the relationship between the knowledge enhancement question representation Q" and each text paragraph D i The embedding vector representation of similarity, obtain each text paragraph D i Similarity score, where the higher the similarity, the higher the score; According to the similarity score, the text paragraph D i Sort, and sort the top k text paragraphs D with the highest sorting i The set {D1,D2,…D k } as the relevant text fragments for the knowledge-enhanced question representation.
7. The method for text fragment retrieval and answer generation of a multi-hop agricultural question-answering system based on knowledge graph reasoning and large model according to claim 6 is characterized in that: Step S50 includes: The knowledge enhancement question is represented as Q" and the top k text paragraphs with the highest ranking are D i The set {D1,D2,…D k } Input Retrieval Augmented Generation Model (RAG); The retrieval-augmented generation model (RAG) represents the knowledge-augmented question Q" and the top k text paragraphs D with the highest ranking. i The set {D1,D2,…D k } are spliced to form a sequence I = [Q"; D1; D2; ... D K ]; The retrieval-augmented generation model (RAG) outputs the answer to the input question based on the deep semantics expressed by sequence I and the information related to the reasoning path.
8. A multi-hop agricultural question-answering system based on knowledge graph reasoning and a large model, the multi-hop agricultural question-answering system based on knowledge graph reasoning and a large model comprising: 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, which, when executed by the system, cause the system to perform any one of the methods of claims 1-7.
9. A computer-readable storage medium, comprising a computer program, and when the computer program is executed on an electronic device, the electronic device is enabled to execute the method according to any one of claims 1 to 7.
10. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the method described in any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Question answering method and device based on knowledge graph, equipment and storage medium
CN116069876A
Knowledge graph generation type question answering method and system based on large language model
CN117033608A
Question and answer reasoning method and system for representing hierarchical hyperbolic graph on knowledge graph
CN118052289A
Large language model knowledge question-answering method and system fused with multi-modal knowledge graph
CN118627628A
Method for generating large model agricultural intelligent questions and answers based on knowledge graph enhanced retrieval
CN118939762A
Cited By
Question answering method, optimization method, device and question answering system for photovoltaic cell experiment
CN120653740A
Question-and-answer methods, optimization methods, apparatus, and question-and-answer systems for photovoltaic cell experiments
CN120653740B
Hydroelectric knowledge reasoning-oriented search engine construction method, system, storage medium and device
CN121009983A