Agricultural disease and insect pest question-answering method based on knowledge graph adaptive mixed retrieval enhancement
By constructing an adaptive hybrid retrieval enhancement method of crop pest knowledge graph and semantic vector library, the problems of slow speed and insufficient accuracy in traditional pest diagnosis are solved, and fast and accurate agricultural pest and disease Q&A are achieved, meeting the efficient diagnosis needs of modern agriculture.
Patent Information
- Application Number
- CN202510633770.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-16
- Publication Date
- 2025-08-08
AI Technical Summary
Traditional pest diagnosis methods rely on expert experience and are slow, Internet query is not accurate enough, and existing large language models are difficult to ensure accuracy and timeliness in agricultural pest diagnosis. The independent use of knowledge graphs and vector library technology has failed to effectively play its advantages and cannot meet the needs of rapid response and large-scale promotion.
Build a field-specific knowledge graph and semantic vector library for crop diseases, pests, and semantic vector library. Combined with a large language model, and through adaptive hybrid search enhancement methods, accurate and intelligent question-and-answer questions are achieved, including data collection, knowledge graph and vector library construction, question-and-answer pre-classification, automatic question type classification and adaptive knowledge retrieval, dynamic selection of search strategies and Prompt to generate accurate answers.
It significantly improves the speed and accuracy of agricultural pest diagnosis, meets the rapid response needs of modern agricultural production, realizes real-time updates and interpretability of knowledge, improves search efficiency and accuracy, reduces the average search response time and improves the F1/EM indicators of the answers.
Smart Images

Figure CN120448502A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the intersection of artificial intelligence and agricultural information technology, and in particular to an agricultural pest and disease question-answering method based on knowledge graph adaptive hybrid retrieval enhancement. Background Art
[0002] With the rapid development of agricultural production technology, crop disease and pest control has become a key issue affecting crop yield and quality. Important food crops, such as rice and wheat, are constantly at risk from various pests and diseases, causing significant economic losses to agricultural production. Therefore, how to quickly and accurately identify pests and diseases and provide precise and effective prevention and control measures has become a key research topic in modern agricultural science and technology.
[0003] Traditional pest and disease diagnosis relies primarily on the expertise of agricultural experts or pest and disease atlases. This approach not only suffers from insufficient expert resources and slow diagnostic speeds, but is also limited by individual differences in diagnostic experience, making it difficult to meet the practical needs of rapid response and widespread adoption in large-scale agricultural production. Internet searches can also lead to inaccurate problem location and low accuracy in knowledge acquisition, making it impossible to accurately answer questions.
[0004] With the development of artificial intelligence (AI), intelligent question-answering (Q&A) based on large language models (LLMs) has become increasingly popular. LLM-based intelligent Q&A leverages natural language processing (NLP) and machine learning techniques to rapidly respond to users' natural language questions and perform effective knowledge inference. However, traditional LLMs have limitations in terms of knowledge accuracy and timeliness, particularly in the field of agricultural pest and disease diagnosis. Because pest and disease knowledge is frequently updated and highly specialized, relying solely on LLMs cannot guarantee diagnostic accuracy. Furthermore, memorizing all (constantly changing) world knowledge may be impossible. To address this issue, a retrieval-enhanced LLM is needed that combines nonparametric knowledge with an additional retrieval module.
[0005] The emergence of knowledge graphs and vector databases offers new solutions to these problems. Knowledge graphs represent domain knowledge through structured entity-relationship networks, enabling clear, efficient, and explainable knowledge queries. Vector databases, on the other hand, enable rapid semantic retrieval of unstructured text, addressing the shortcomings of knowledge graphs in terms of knowledge coverage and semantic similarity matching.
[0006] Although knowledge graphs and vector database technologies have been applied to agricultural pest and disease diagnosis, traditional approaches often use them independently, failing to effectively leverage the strengths of each technology. Furthermore, existing methods often fail to adaptively integrate knowledge and select reasoning strategies for different types of questions, making it difficult to ensure the accuracy and practicality of answers to complex agricultural questions. Summary of the Invention
[0007] The purpose of the present invention is to overcome the shortcomings of the existing technology and provide an agricultural pest and disease question-answering method based on knowledge graph adaptive hybrid retrieval enhancement. By constructing a field-specific crop pest and disease knowledge graph and semantic vector library, combined with the reasoning ability of a large language model, an accurate and adaptive intelligent question-answering technology for rice and wheat pest and disease problems is established, which significantly improves the speed, accuracy and intelligence level of agricultural pest and disease diagnosis, and meets the urgent needs of rapid response, efficient and accurate diagnosis and continuous knowledge updating in modern agricultural production practice.
[0008] The object of the present invention is achieved as follows: a method for agricultural pest and disease question answering based on knowledge graph adaptive hybrid retrieval enhancement, comprising the following steps:
[0009] Step 1) Data collection and organization: Relying on industry-specific platforms as information sources, automated collection tools are used to obtain unstructured text data on agricultural pests and diseases;
[0010] Step 2) Construction of the knowledge graph and vector library: Based on the organized text corpus, a knowledge graph of agricultural pests and diseases was constructed. A standardized agricultural pest and disease QA dataset was constructed and a large amount of unstructured text was cleaned. A pre-trained semantic vector model was used to encode the semantic vectors of each text data segment to construct an agricultural pest and disease vector library.
[0011] Step 3) Constructing a question-answer pre-classification system: pre-classify natural language questions that users may ask about rice and wheat pests and diseases;
[0012] Step 4) Build and train an automatic classification model for question types: Use a small classification model to automatically identify and classify questions input by users in real time, forming a classifier for adaptive retrieval;
[0013] Step 5) Adaptive knowledge retrieval based on question type: Adaptively and dynamically select different retrieval methods of knowledge graphs and vector libraries based on the query type;
[0014] Step 6) Integrate the search results of the knowledge graph and vector library, select the corresponding thinking chain reasoning method according to the question type, and construct prompt words for different types of questions;
[0015] Step 7) Combine the prompt to generate an accurate answer: Input the prompt constructed in step 6) into the large language model for reasoning and generation, and output the accurate answer to the final question.
[0016] As a further limitation of the present invention, the step 1) specifically includes:
[0017] Step 1.1) Using information obtained from various channels in the agricultural field as the original information source, automated web crawler technology and data collection tools were used to collect unstructured raw text data related to major crop pests and diseases;
[0018] Step 1.2) The collected raw data is preliminarily cleaned to remove irrelevant or duplicate content, forming a set of raw data on agricultural pests and diseases to be labeled, which is recorded as:
[0019] Data raw ={Text1,Text2,...,Text n},
[0020] Data raw Represents the original text data set after preliminary cleaning, Text i Represents specific raw text content and unstructured data related to pests and diseases;
[0021] Step 1.3) The raw data are uniformly stored in the database system, standardized and formatted, and finally the agricultural data corpus is constructed.
[0022] As a further limitation of the present invention, the step 2) specifically includes:
[0023] Step 2.1) Organize agronomy experts and professional data annotators to construct a knowledge graph for agricultural pests and diseases based on the original data set related to agricultural pests and diseases obtained in Step 1). Clarify the entity relationships in the knowledge graph and use semi-automated entity and relationship extraction tools to extract knowledge elements and annotate relationships from the text. Perform manual verification to generate entity-relationship-entity triples. Using the graph database technology Neo4j, import the annotated triples into the graph database to construct a specific mapping of the knowledge graph entity nodes, relationship edges, node attributes, and relationship attributes to form the final knowledge graph.
[0024] Step 2.2) Construct a semantic vector library for the agricultural pest and disease field; design and construct a QA dataset for the agricultural pest and disease field, manually compiling, automatically generating, and semi-automatically annotating common pest and disease questions, covering various types of questions and standardized answers; initially clean the agricultural pest and disease data using keywords, and then use manual rescreening to secondary screen and supplement the incomplete parts of the above data; after the text data is processed into a unified format and semantic features are extracted, a text knowledge base suitable for semantic vector retrieval is constructed to support semantic retrieval methods based on the vector library.
[0025] As a further limitation of the present invention, the step 3) specifically includes:
[0026] Step 3.1) Collect a large number of natural language questions related to rice and wheat pests and diseases that users may raise in actual production, extract the semantic and structural features of different question types, and form a feature library of agricultural pest and disease question types;
[0027] Step 3.2) Classify the QA question library and collected natural language questions based on question type characteristics, including simple questions, conditional questions, aggregation questions, comparison questions, multi-hop questions, and judgment questions. Build a dataset of crop pest and disease questions and use automated and semi-automated data augmentation techniques to expand the volume and diversity of question sample data, forming a comprehensive set of question samples to support accurate training of the classification model.
[0028] In step 3.3, all generated sample data are submitted to agricultural experts for manual review and annotation confirmation to form a high-quality labeled agricultural pest problem type classification dataset.
[0029] As a further limitation of the present invention, the step 4) specifically includes:
[0030] Step 4.1) When the user inputs a question related to rice or wheat pests and diseases, the system automatically pre-processes the input text, standardizes the text format and grammatical structure, and forms a standardized question input text;
[0031] In step 4.2), the T5-large neural network model is used to perform supervised fine-tuning training on the agricultural pest and disease problem type classification dataset constructed in step 3.3) to achieve automatic classification of problem types;
[0032] In step 4.3, we use the cross entropy loss function as the training objective function for the T5-large fine-tuned classification model. During model training, we optimize the loss for all categories, specifically expressed as:
[0033]
[0034] In formula (1), N represents the total number of training samples; C represents the total number of question type categories; y ni is the one-hot label of the true category of the nth sample; After generating category predictions for the T5-large model, the predicted category probabilities are obtained through the softmax function; θ is all the trainable parameters of the T5-large model;
[0035] Step 4.4) The training process aims to minimize the loss function and obtain the optimal T5-large model parameters θ * :
[0036]
[0037] Step 4.5) The user-entered question text is fed into the sequence and fed into the fine-tuned T5-large model. The model outputs the predicted question type category in text form:
[0038] label=Classifier T5 (input_text) (3)
[0039] The system converts the generated category text into the corresponding category label through the defined mapping relationship, and at the same time, records the predicted probability output by the model:
[0040]
[0041] Perform threshold judgment on the output classification labels, and conduct manual or rule-assisted review on classification results below the threshold.
[0042] As a further limitation of the present invention, step 5) specifically includes: based on the question type label output by the automatic classification model, the system automatically determines to adopt a knowledge graph search strategy, a vector library search strategy, or a hybrid search strategy of the two;
[0043] a) Simple problems: direct single-step semantic similarity retrieval and single-step graph query;
[0044] b) Conditional questions: single-step conditional semantic retrieval, single-step conditional graph attribute query;
[0045] Through the vector library retrieval strategy, according to the conditions in the question, a conditional semantic query vector is constructed, and a single-step conditional semantic constraint retrieval is performed; through the knowledge graph retrieval strategy, the query is filtered by attribute conditions in the knowledge graph G;
[0046] c) Aggregation problem: two-step coarse-fine search in vector database and batch graph entity relationship query;
[0047] Vector library search strategy: This strategy uses a two-step aggregate search strategy. The first step is a coarse search, followed by a fine search. The large LLM model processes the coarse search results of the first step to generate a more accurate secondary query vector. The new fine vector is then used for a second search to obtain a refined result set. Knowledge graph search strategy: This strategy implements aggregated question search through batch entity relationship queries.
[0048] d) Comparison problem: multi-entity parallel semantic retrieval and multi-entity attribute graph query;
[0049] Vector library search strategy: Using a method of parallel semantic search and merging of multiple entity keywords, the method first extracts keyword sets corresponding to multiple entities to be compared from the comparison question text posed by the user, forming multiple keyword query sequences. The second step is to independently semantically vectorize each keyword, and then perform vector search in parallel. The third step is to merge the result sets of parallel searches of multiple entity keywords to obtain the final comprehensive search result set. Knowledge graph search strategy: Construct a multi-entity attribute comparison query.
[0050] e) Multi-hop problem: After generating the ToT sub-problem, iterative semantic retrieval and iterative multi-step graph retrieval with path attenuation confidence are performed;
[0051] Vector library retrieval strategy: A large language model is used to perform ToT reasoning, expanding the possible reasoning paths of complex multi-hop problems in a tree-like manner to generate multiple clear sub-problems or sub-queries. The feasibility of each path is evaluated through the LLM, the optimal path is selected, and iterative retrieval is performed on each sub-problem in the selected ToT optimal path. A new query text is dynamically generated based on the knowledge set obtained in the previous retrieval step and the original question, clarifying the next retrieval direction, generating the next reasoning step, and then executing the knowledge retrieval in the i-th step. The knowledge fragments retrieved in all ToT steps are integrated to form the final multi-hop knowledge context and generate the final answer.
[0052] Knowledge graph retrieval strategy: Use entity recognition methods to extract initial nodes from the original question and form an initial node set; adopt an iterative knowledge graph retrieval strategy to gradually clarify the final answer to the question through the continuous expansion of nodes and relationships; use the path decay confidence method to expand nodes and deduce relationships in the graph;
[0053] Breadth-first search (BFS) and depth-first search (DFS) strategies are used for path expansion. That is, when expanding each layer of nodes, all adjacent nodes are expanded first, and then the next layer is expanded and the single path is expanded until the end of the path is reached and then backtracked. After the path expansion is completed, the termination conditions of the knowledge graph path expansion and attenuation are set, and finally a knowledge graph result set is formed;
[0054] f) Judgment problem: single-step semantic similarity retrieval and single-step graph attribute judgment retrieval;
[0055] Vector library retrieval strategy: The judgment question text raised by the user is semantically encoded into a vector to obtain a semantic query vector that expresses the user's question intent. By calculating the cosine similarity between the user's question semantic vector and the text semantic vector stored in the vector library, a single-step precise matching retrieval is achieved.
[0056] Knowledge graph retrieval strategy: The goal of knowledge graph retrieval is to determine whether the specific relationship or attribute involved in the user's question exists in the graph, so as to clearly return a "yes" or "no" answer.
[0057] As a further limitation of the present invention, the specific search strategy for the aggregation problem is:
[0058] Vector library search strategy: A two-step aggregation search strategy is used to implement the first coarse search followed by the fine search. The first step is a coarse search. The formula is as follows:
[0059]
[0060] In formula (5), q represents the vector representation of the question raised by the user after embedding; Represents the cosine similarity between the question vector and each knowledge vector; Top k It means taking the first k knowledge fragments closest to the question semantics from the vector library to form a coarse-grained result set D coarse ;
[0061] The second step is fine search, using the large model LLM to search the first step of the rough search results D coarse Process and generate a secondary query vector q fine :
[0062] q fine =LLM(D coarse ) (6)
[0063] In formula (6), q fine Indicates that LLM is used to generate specific query expressions based on rough search results; D coarse Represents the larger set retrieved in the first step;
[0064] Use the new precision vector q fine Perform a second search to obtain a refined result set. The formula is as follows:
[0065]
[0066] In formula (7), n is much smaller than k in the first step;
[0067] Knowledge graph retrieval strategy: aggregate question retrieval is achieved through batch entity relationship query. The formula is as follows:
[0068] R agg ={(e,r,o)|(e,r,o)∈G,e∈E agg ,r∈R agg} (8)
[0069] In formula (8), E agg Represents the entity set required for aggregation; R agg Represents an aggregation target relationship.
[0070] As a further limitation of the present invention, the specific search strategy for the multi-hop problem is:
[0071] A large language model is used to perform ToT reasoning, which expands the possible reasoning paths of complex multi-hop problems in a tree-like manner and generates multiple clear sub-questions or sub-queries. The specific formula is expressed as follows:
[0072] ToT tree-like thinking chain path expansion:
[0073] T paths =LLM ToT (q)={path1,path2,…,path n} (9)
[0074] In formula (9), q represents the input questions, T paths Represents multiple possible reasoning paths explicitly generated by the ToT method; each path i It is a set of ordered sub-problems, representing different reasoning directions;
[0075] Use LLM to evaluate the feasibility of each path and select the optimal path:
[0076]
[0077] For each sub-path in the ToT optimal path selected by formula (10), out ; Perform iterative retrieval separately:
[0078] The first sub-question retrieval process:
[0079]
[0080] represents the set of knowledge fragments that are explicitly retrieved for the first time; q 1a For the first sub-problem;
[0081] Step i: Reasoning and retrieval iteration: Based on the knowledge set obtained in the previous retrieval step and the original question, a new query text is dynamically generated to clarify the next retrieval direction and generate the next reasoning step:
[0082]
[0083] Then explicitly perform the knowledge retrieval in step i:
[0084]
[0085] The knowledge fragments retrieved by all ToT steps are integrated to form the final multi-hop knowledge context:
[0086]
[0087] In formula (14), context multi-hop represents the final fusion of all sub-question retrieval results to form a complete and comprehensive multi-hop knowledge context; Concat(·) represents the merging of the retrieval results of multiple sub-questions;
[0088] Final answer generation formula:
[0089] Answer final =LLM(q,context multi-hop ) (15)
[0090] Knowledge graph retrieval strategy: Use entity recognition method to extract initial nodes from the original question to form an initial node set: E init ={n1,n2,n3,…,n i};
[0091] Adopting the knowledge graph iterative retrieval strategy, through the continuous expansion of nodes and relationships, the final answer to the question is gradually identified. The specific steps and formula are as follows:
[0092] Initial node confidence setting: The confidence of each node in the initial node set is 1:
[0093] s(n init )=1,n init ∈E init (16)
[0094] Using the path attenuation confidence method, we expand the graph nodes and deduce relationships. The specific implementation process is as follows:
[0095] Starting from the initial node, the knowledge graph entity relationship path is expanded. During the path expansion process, the node confidence decays as the path depth increases. The formula for path decay confidence is:
[0096] s(nj )=s(n i )×α L ×s(r ij ) (17)
[0097] In formula (17), s(n j ) represents the expansion of the new node n j Confidence level; s(n i ) represents the current node n i confidence; α: explicitly represents the path attenuation coefficient, which is used to control the degree of attenuation of the confidence of path extension as the path length increases; L represents the number of nodes from the initial node n init To the current node n j The path length s(r ij ) represents the slave node n i To node n j Relationship between ij confidence level;
[0098] Breadth-first search (BFS) and depth-first search (DFS) strategies are used for path expansion. That is, when expanding each layer of nodes, all adjacent nodes are expanded first, and then the next layer is expanded and the single path is expanded until the end of the path is reached and then backtracked. After the path expansion is completed, the termination conditions for the knowledge graph path expansion and attenuation are set:
[0099] Termination=(s(n j ) <Threshold) OR (L≥max_length) (18)
[0100] In formula (18), Threshold is the confidence threshold that is clearly set, and max_length is the maximum number of iterations that is preset. Finally, the knowledge graph result set is formed: {R1, R2, …, R m}.
[0101] As a further limitation of the present invention, the step 6) specifically includes:
[0102] Step 6.1) According to the vector library and knowledge graph retrieval strategies executed for different types of questions, the corresponding retrieval result sets are obtained respectively: the vector library retrieval result set is recorded as D vector ; The knowledge graph retrieval result set is recorded as R KG , the search results are clearly integrated to form the final complete knowledge context. The specific integration formula is:
[0103] Context final =Concat(D vector ,R KG ) (19)
[0104] In formula (19), Context final Represents the complete knowledge context for final answer generation, and Concat(·) represents merging the vector library with the retrieval result set of the knowledge graph;
[0105] Step 6.2) Based on the obtained question type label, an adaptive thought chain reasoning strategy suitable for different question types is adopted, and through the implementation of the thought chain strategy, clear prompts are constructed to guide the large language model to gradually generate answers.
[0106] As a further limitation of the present invention, step 7) specifically includes: inputting the prompts for different types of questions and the corresponding knowledge context constructed in step 6) into the selected large language model LLM for reasoning calculation; the large language model reasoning process is expressed by the following formula:
[0107] Answer final =LLM(Prompt,Context final ) (20)
[0108] In formula (20), Prompt represents the adaptive prompt content constructed in step 6) for different types of questions; Context final Represents the knowledge context formed by integrating the vector library and the knowledge graph retrieval results in step 6); Answer final Represents the final question answering result generated by the large language model after inference.
[0109] The present invention utilizes the above technical solutions, achieving the following benefits compared to existing technologies: 1) Improved retrieval efficiency and accuracy: Through hybrid retrieval using an adaptive knowledge graph and vector library, the system eliminates redundant computation for simple queries and fully supplements evidence for complex queries, reducing average retrieval response time by over 40% while maintaining or improving the F1 / EM performance of answers by approximately 10%–18%. 2) Adaptive question type processing: A small T5-large classifier distinguishes six question categories in real time, enabling dynamic switching of search depth, thought chain strategies, and prompt structures as needed. This avoids the drawbacks of "one-size-fits-all" approaches, which waste computing power on simple questions or lack information for complex ones. 3) Enhanced knowledge updating and interpretability: The vector library can incrementally embed new documents daily or weekly; the knowledge graph supports node-relationship addition and deletion, as well as confidence decay, ensuring real-time updates of agricultural pest and disease knowledge. Generated answers simultaneously return graph paths, semantic search fragments, and reasoning chains, making them traceable and auditable, meeting the interpretability requirements of scientific research and production management. 4) Multi-level thought chain integration: Least-to-Most, Step-Back, Tree-of-Thought (ToT), and Self-Ask strategies are automatically invoked based on question difficulty, maintaining the inference depth of large language models while controlling token consumption. 5) Digitization and sharing of expert experience: Triples annotated by agricultural experts are graphed and deposited into reusable assets, addressing the traditional manual Q&A process, which is prone to forgetfulness and difficult to review. This provides a unified knowledge base for grassroots agricultural technology promotion, intelligent field monitoring, and precision agriculture decision-making. BRIEF DESCRIPTION OF THE DRAWINGS
[0110] Figure 1 Flowchart of the present invention. DETAILED DESCRIPTION
[0111] like Figure 1 The agricultural pest question answering method based on knowledge graph adaptive hybrid retrieval enhancement includes the following steps:
[0112] Step 1) Data collection and organization: Relying on industry-specific platforms as information sources, automated collection tools are used to obtain unstructured text data on agricultural pests and diseases;
[0113] Step 1.1) Using professional agricultural websites (e.g., China Crop Material Information Network), professional databases (e.g., OpenKG), agricultural science and technology journals, agricultural pest and disease knowledge platforms, agricultural technical guidance manuals, agricultural expert forums, pest and disease knowledge books (e.g., China Plant Protection Atlas, China Crop Pests and Diseases), and academic literature as original information sources, we used automated web crawler technology and data collection tools to extensively collect unstructured raw text data related to pests and diseases of major crops such as rice and wheat.
[0114] Step 1.2) Perform preliminary cleaning on the collected raw data, remove the obviously irrelevant or repeated content, and form the raw data set of agricultural pests and diseases to be labeled, which is recorded as: Data raw ={Text1,Text2,...,Text n}, where Data raw Represents the original text data set after preliminary cleaning, Text i Represents specific raw text content and unstructured data related to pests and diseases;
[0115] Step 1.3) The raw data are uniformly stored in the database system, standardized and formatted, and finally the agricultural data corpus is constructed.
[0116] Step 2) Construction of a knowledge graph and vector library: Based on the organized text corpus, a knowledge graph for agricultural pests and diseases was constructed. A standardized agricultural pest and disease QA (question-answer) dataset was constructed, and a large amount of unstructured text was cleaned. A pre-trained semantic vector model was used to encode the semantic vectors of each text data segment to construct an agricultural pest and disease vector library.
[0117] Step 2.1) Organize agronomy experts and professional data labelers to build a knowledge graph in the field of agricultural pests and diseases based on the original data set related to agricultural pests and diseases obtained in step 1). The specific process of knowledge graph construction includes:
[0118] Step 2.1.1) Identify 22 entities in the knowledge graph, as follows: crops, diseases, pests, pathogens, natural enemies, affected parts, symptoms, treatment methods, therapeutic agents, morphological characteristics, developmental stages, growth stages, occurrence sites, varieties, transmission methods, usage guidelines, prevention and control periods, common names / aliases, introductions / descriptions, disease conditions, hosts, and pathogen introductions. 41 relationships in the knowledge graph are clarified, as follows: the relationship between crops and pests, the relationship between crops and diseases, the relationship between pests and pests, the relationship between diseases and pathogens, the relationship between pests and natural enemies, the relationship between pests and damaged parts, the relationship between pests and damage symptoms, the relationship between pests and treatment methods, the relationship between pests and morphological characteristics, the relationship between pests and developmental stages, the relationship between pests and growth stages, the relationship between pests and occurrence sites, the relationship between pests and transmission methods, the relationship between pests and control periods, the relationship between pests and living habits, the relationship between pests and common names / aliases, the relationship between pests and disease conditions, the relationship between pests and hosts, the relationship between pests and pest introductions, the relationship between pests and pest introductions, The relationship between pests and their impacts, the relationship between pests and the causes of pest disease, the relationship between pests and therapeutic agents, the relationship between agents and their methods of use, the relationship between diseases and therapeutic agents, the relationship between diseases and affected parts, the relationship between diseases and symptoms of damage, the relationship between diseases and treatment methods, the relationship between diseases and morphological characteristics, the relationship between diseases and developmental stages, the relationship between diseases and places of occurrence, the relationship between diseases and transmission methods, the relationship between diseases and prevention and control periods, the relationship between diseases and common names / aliases, the relationship between diseases and disease introductions, the relationship between diseases and pathogen introductions, the relationship between diseases and disease conditions, the relationship between diseases and their impacts, the relationship between diseases and hosts, the relationship between pests and varieties, and the relationship between diseases and varieties.
[0119] Step 2.1.2) Based on the high-quality agricultural pest and disease text corpus obtained in step 1), agricultural experts and professional data annotators use manual annotation and semi-automated entity and relationship extraction tools to extract knowledge elements and annotate relationships from the text. They clearly annotate entities and the multidimensional relationships between entities to form entity-relationship-entity triples. Ultimately, 3,000 rice triples and 4,459 wheat triples were obtained.
[0120] In step 2.1.3, Neo4j, a graph database technology, is used to import the triple data annotated in step 2.1.2) into the graph database. This allows for the explicit mapping of knowledge graph entity nodes, relationship edges, node attributes, and relationship attributes to form the final knowledge graph.
[0121] Step 2.2) Construct a semantic vector library for the agricultural pest and disease field. The specific process of constructing the vector library includes:
[0122] Step 2.2.1) Based on the agricultural data corpus from step 1), agronomy experts and data annotators collaborated to design and construct a specialized QA (question-answer) dataset for agricultural pests and diseases. A total of 1,500 high-quality rice and wheat QA datasets were manually annotated.
[0123] Step 2.2.2) The agricultural pest and disease data in step 1) are first preliminarily cleaned using keywords, and then the incomplete parts of the above data are screened and supplemented by manual rescreening to make the data clear and convenient for subsequent analysis; high-quality text data is processed in a unified format and semantic features are extracted (such as vector representation model), and semantic vector encoding is performed on each text data segment. The vector encoding formula is expressed as Vec i =EmbeddingModel(Text i ), the semantic vector representations generated for all text fragments are stored together with the identifiers of the original text fragments in a vector database (FAISS), a text knowledge base suitable for semantic vector retrieval is constructed, and semantic retrieval methods based on the vector library are supported.
[0124] Step 3) Constructing a question-answer pre-classification system: pre-classify natural language questions that users may ask about rice and wheat pests and diseases;
[0125] Step 3.1) Through communication with agricultural experts and farmers, as well as from actual agricultural production scenarios and agricultural knowledge platforms, we collected a large number of natural language questions related to rice and wheat pests and diseases that users may raise in actual production. We extracted the semantic and structural features of different question types and formed a feature library of agricultural pest and disease question types.
[0126] Step 3.2) Based on question type characteristics, common questions are divided into the following six specific question types: simple questions, conditional questions, aggregation questions, comparison questions, multi-hop questions, and judgment questions. The QA question library and collected natural language questions are classified according to the six specific question types to construct a crop pest and disease question dataset. Automated and semi-automated data augmentation techniques (such as question transformation, semantic rewriting, and synonym replacement) are used to expand the sample data volume and ensure the diversity of question samples, forming a more complete set of question samples to support accurate training of the classification model.
[0127] Specific definitions of these issues:
[0128] Simple questions: Questions raised by users that can be answered quickly and accurately through a simple search (example question: What diseases is rice susceptible to?).
[0129] Conditional questions: User questions clearly contain one or more specific conditions or restrictions, and require a single or a small number of searches under the given conditions to accurately answer the questions (example question: What diseases is wheat susceptible to in spring?).
[0130] Aggregate questions: These are questions that require statistics, sorting, filtering, or summarizing of multiple retrieved entities or information, and ultimately provide them to users in an aggregated form (example question: What are the three most common rice diseases?).
[0131] Comparative questions: These are questions in which the user needs to compare or contrast the attributes, characteristics, or impacts of two or more entities, ultimately concluding that one or more entities are superior, more serious, or more important (example question: Which is more serious, rice blast or sheath blight?).
[0132] Multi-hop questions: Questions raised by users cannot be answered directly through a simple search, but must be answered through multiple iterations or multi-step reasoning and retrieval. The results of each step affect the next question, and the final reasoning results in a clear answer. (Example question: Some leaves in the rice field have turned yellow and have some small brown spots on them. The soil has been wet for the past week, and some small flying insects are flying in the field. What pests and diseases may be causing this?)
[0133] Judgment questions: After the user asks a question, they expect a clear "yes" or "no" answer, or the answer can be obtained through simple reasoning and single-step search (example question: Will wheat definitely not be infected with stripe rust in winter?).
[0134] Step 3.3) Submit all the sample data generated above to agricultural experts for manual review and annotation confirmation; ensure that each problem is accurately classified into the corresponding type, forming a high-quality labeled agricultural pest problem type classification dataset.
[0135] Step 4) Build and train an automatic classification model for question types: Use a small classification model to automatically identify and classify questions input by users in real time, forming a classifier for adaptive retrieval;
[0136] Step 4.1) When the user enters a question related to rice or wheat pests and diseases, the system automatically preprocesses the input text, including removing special symbols, cleaning abnormal characters, filtering stop words, and text segmentation, standardizing the text format and grammatical structure to form a standardized question input text;
[0137] In step 4.2), the T5-large (Text-To-Text Transfer Transformer) neural network model is used to perform supervised fine-tuning training on the agricultural pest and disease problem classification dataset constructed in step 3.4) to automatically classify the problem types. The T5-large model implements the classification function through sequence-to-sequence (Seq2Seq) generation tasks, which are specifically expressed as follows:
[0138] Input sequence construction:
[0139] input_text = "Classification Task:" + q
[0140] q is the question text entered by the user, that is, the natural language question the user asks about agricultural pests and diseases. "Classification task:" is a manually designed task prompt that tells the T5 model: "The text content entered next is for the classification task."
[0141] Model output format:
[0142] output_text∈{simple problem, conditional problem, aggregation problem, comparison problem, multi-hop problem, judgment problem}
[0143] In step 4.3, we use the cross entropy loss function as the training objective function for the T5-large fine-tuned classification model. During model training, we optimize the loss for all categories, specifically expressed as:
[0144]
[0145] In formula (1), N represents the total number of training samples; C represents the total number of question types (six categories); y ni is the one-hot label of the true category of the nth sample; After generating category predictions for the T5-large model, the predicted category probabilities are obtained through the softmax function; θ is all the trainable parameters of the T5-large model.
[0146] Step 4.4) The training process aims to minimize the loss function and obtain the optimal T5-large model parameters θ * :
[0147]
[0148] The training process uses a commonly used optimization algorithm, AdamW optimizer for parameter optimization.
[0149] Step 4.5) The question text entered by the user is constructed into an input sequence according to step 4.2) and then fed into the fine-tuned T5-large model. The model outputs the predicted question type category in text form:
[0150] label=Classifier T5 (input_text)
[0151] The system converts the generated category text into the corresponding category label through the defined mapping relationship, and at the same time, records the predicted probability output by the model (obtained through the softmax function):
[0152]
[0153] Perform threshold judgment on the output classification labels, and conduct manual or rule-assisted review on classification results below the threshold to ensure the high accuracy of the classification results.
[0154] Step 5) Adaptive knowledge retrieval based on question type: Based on the query question type, different retrieval methods of the knowledge graph and vector library are adaptively and dynamically selected. Based on the question type label (simple question, conditional question, aggregation question, comparison question, multi-hop question, judgment question) output by the automatic classification model in step 4), an adaptive knowledge retrieval strategy suitable for that type of question is dynamically selected. Knowledge retrieval strategies include knowledge graph retrieval strategies and vector library retrieval strategies.
[0155] a) Simple problems: direct single-step semantic similarity retrieval and single-step graph query;
[0156] When the user's question is simple, the system does not perform knowledge graph or vector library retrieval, but directly sends the user's question text into the large language model to generate the answer directly.
[0157] b) Conditional questions: single-step conditional semantic retrieval, single-step conditional graph attribute query;
[0158] When the user's question is a conditional question, the following search steps are performed:
[0159] Vector library retrieval strategy: Based on the conditions in the question, construct a conditional semantic query vector and perform a single-step conditional semantic constraint retrieval;
[0160] Combine the conditions directly in the question query, the formula is as follows:
[0161] q cond =Embedding(q+condition)
[0162] Use the vector similarity retrieval formula:
[0163]
[0164] In formula (2), the conditional information is added to the original question text encoding to obtain a more accurate semantic expression vector q cond
[0165] Knowledge graph retrieval strategy: In the knowledge graph G, the query is filtered by attribute conditions. The graph single-step attribute condition retrieval formula is expressed as:
[0166] R cond (e, condition) = {e j |(e,r,e j )∈G,Condition(e j )=True} (3)
[0167] In formula (3), e represents the entity node in the problem, Condition represents the clear condition, and Condition(e j ) represents the node attribute condition filtering function.
[0168] c) Aggregation problem: two-step coarse-fine search in vector database and batch graph entity relationship query;
[0169] When the user question belongs to the aggregated question, the following retrieval steps are performed:
[0170] Vector library search strategy: A two-step aggregate search (coarse search first, then fine search) strategy is used. The first step is a coarse search. The formula is as follows:
[0171]
[0172] In formula (4), q represents the vector representation of the question raised by the user after embedding; Represents the cosine similarity between the question vector and each knowledge vector; Top k It means taking the first k knowledge fragments closest to the question semantics from the vector library to form a coarse-grained result set D coarse ;
[0173] The second step is fine search, using the large model (LLM) to analyze the rough search results D in the first step. coarse Processing is performed to generate a more accurate secondary query vector q fine :
[0174] q fine =LLM(D coarse ) (5)
[0175] In formula (5), q fine Indicates that based on the rough search results, LLM is used to generate a more refined and specific query expression; D coarse Represents the larger collection retrieved in the first step.
[0176] Then, use the new accurate vector q fine Perform a second search to obtain a more precise and focused set of refined results. The formula is as follows:
[0177]
[0178] In formula (6), n is clearly much smaller than k in the first step, ensuring that the returned result is more precise and accurate;
[0179] Knowledge graph retrieval strategy: aggregate question retrieval is achieved through batch entity relationship query. The formula is as follows:
[0180] R agg ={(e,r,o)|(e,r,o)∈G,e∈E agg ,r∈R agg} (7)
[0181] In formula (7), E agg Represents the entity set required for aggregation; R agg Represents an aggregation target relationship.
[0182] d) Comparison problem: multi-entity parallel semantic retrieval and multi-entity attribute graph query;
[0183] When the user's question is a comparison question, the following retrieval steps are performed:
[0184] Vector library retrieval strategy: adopt the method of parallel semantic retrieval and merging of multiple entity keywords. First, extract the keyword sets corresponding to multiple entities to be compared from the comparison question text raised by the user to form multiple keyword query sequences. The keyword set of the entity to be compared is: Q = {q1, q2, ..., q n}, where q i is the keyword of the i-th entity to be compared.
[0185] The second step is to convert each keyword q i Separate semantic vectorization is performed separately, and then vector retrieval is performed in parallel. Each entity keyword q i The separate search formula is:
[0186]
[0187] In formula (8), Represents the semantic vector of the i-th keyword; d j The semantic vector corresponding to the j-th knowledge item in the vector library; is the cosine similarity between the i-th entity keyword and the knowledge item;
[0188] The third step is to merge the result sets of multiple entity keyword parallel searches to obtain the final comprehensive search result set. The specific formula is:
[0189]
[0190] In formula (9), D comparison In order to finally define the comprehensive search result set for comparative analysis, Merge represents the merging operation, including result deduplication, sorting, and integration;
[0191] Knowledge graph retrieval strategy: Construct a multi-entity attribute comparison query. The formula is as follows:
[0192] R comparison ={(e,p,o)|(e,p,o)∈G,e∈E compare ,p∈P compare} (10)
[0193] In formula (10), E compare To compare entity sets; P compare A collection of attributes to compare against.
[0194] e) Multi-hop problem: After generating the ToT sub-problem, iterative semantic retrieval and iterative graph expansion with path attenuation confidence are performed;
[0195] Vector library retrieval strategy: A large language model is used to perform Tree-of-Thought (ToT) reasoning, which expands the possible reasoning paths of complex multi-hop problems in a tree-like manner and generates multiple clear sub-questions or sub-queries. The specific formula is expressed as follows:
[0196] ToT tree-like thinking chain path expansion (path generation):
[0197] T paths =LLM ToT (q)={path1,path2,…,path n} (11)
[0198] In formula (11), q represents the input questions, T paths Represents multiple possible reasoning paths explicitly generated by the ToT method; each path i It is a set of ordered sub-problems, representing different reasoning directions. The path diagram is: path1 = [q 1a ,q 1b ,q 1c ],path2=[q 2a ,q 2b ,q 2c ];
[0199] Path optimization (path evaluation and selection): Use LLM to evaluate the feasibility of each path and select the optimal path;
[0200]
[0201] For each subproblem path in the ToT optimal path selected by formula (12) out =[q 1a ,q 1b ,q 1c ], perform iterative retrieval respectively;
[0202] The first sub-question retrieval process (the example is sub-question q 1a ):
[0203]
[0204] represents the set of knowledge fragments that are explicitly retrieved for the first time;
[0205] Step i: Reasoning and retrieval iteration: Based on the knowledge set obtained in the previous retrieval step and the original question, a new query text is dynamically generated to more accurately determine the next retrieval direction and clearly generate the next reasoning step: Then explicitly perform the knowledge retrieval in step i:
[0206]
[0207] The knowledge fragments retrieved by all steps of TOT are integrated to form the final multi-hop knowledge context:
[0208]
[0209] In formula (15), context multi-hop Indicates the final clear fusion of all sub-question retrieval results to form a complete and comprehensive multi-hop knowledge context; Concat(·) means merging the retrieval results of multiple sub-questions
[0210] Final answer generation formula:
[0211] Answer final =LLM(q,context multi-hop ) (16)
[0212] Knowledge graph retrieval strategy: Use entity recognition method to extract initial nodes from the original question to form an initial node set: E init ={n1,n2,n3,…,n i};
[0213] Adopting the knowledge graph iterative retrieval strategy, through the continuous expansion of nodes and relationships, the final answer to the question is gradually identified. The specific steps and formula are as follows:
[0214] Initial node confidence setting: The confidence of each node in the initial node set is 1:
[0215] s(n init )=1,n init ∈E init
[0216] Using the path attenuation confidence method, we expand the graph nodes and deduce relationships. The specific implementation process is as follows:
[0217] Starting from the initial node, the knowledge graph entity relationship path is expanded. During the path expansion process, the node confidence decays as the path depth increases. The formula for path decay confidence is:
[0218] s(n j )=s(n i )×α L ×s(r ij ) (17)
[0219] In formula (17), s(n j ) represents the expansion of the new node n j Confidence level; s(n i ) represents the current node n i confidence; α: explicitly represents the path attenuation coefficient, which is used to control the degree of attenuation of the confidence of path extension as the path length (number of hops) increases; L represents the number of nodes from the initial node n init To the current node n j Path length (number of hops); s(r ij ) represents the slave node n i To node n j Relationship between ij The confidence level of the test (set to 1 by default).
[0220] Breadth-first search (BFS) and depth-first search (DFS) strategies are used for path expansion. That is, when expanding each layer of nodes, all adjacent nodes are expanded first, and then the next layer is expanded and the single path is expanded in depth until the end of the path is reached and then backtracked. After the path expansion is completed, the termination conditions of the knowledge graph path expansion and decay are set:
[0221] Termination=(s(n j ) <Threshold) OR (L≥max_length) (18)
[0222] In formula (18), Threshold is the confidence threshold that is clearly set, and max_length is the maximum number of iterations that is preset. Finally, the knowledge graph result set is formed: {R1, R2, ..., R m}.
[0223] f) Judgment problem: single-step semantic similarity retrieval and single-step graph attribute judgment retrieval;
[0224] Vector library retrieval strategy: encode the judgment question text raised by the user into a semantic vector to obtain the semantic query vector q that expresses the user's question intention judge ; By calculating the user question semantic vector q judge The text semantic vector d stored in the vector library i The cosine similarity between them clearly implements single-step exact match retrieval:
[0225]
[0226] In formula (19), q judge Represents the semantic vector of the question text, and θ represents the set higher similarity threshold, which is used to ensure that the retrieved results are highly accurate and avoid ambiguity;
[0227] Knowledge graph retrieval strategy: The goal of knowledge graph retrieval is to determine whether the specific relationship or attribute involved in the user's question exists in the graph, so as to clearly return a "yes" or "no" answer. The formula is as follows:
[0228]
[0229] In formula (20), R judge The Boolean value (True or False) indicating the judgment result, that is, whether the relationship or attribute to be judged exists in the graph, E judge Represents the subject entity to be judged extracted from the question raised by the user, R query Indicates the specific type of relationship that the problem involves.
[0230] Step 6) Integrate the search results of the knowledge graph and vector library, select the corresponding thinking chain reasoning method according to the question type, and construct a highly targeted prompt word;
[0231] Step 6.1) According to the vector library and knowledge graph retrieval strategies executed in step 5) for different types of questions, the corresponding retrieval result sets are obtained respectively: the vector library retrieval result set is recorded as D vector ; The knowledge graph retrieval result set is recorded as R KG , the above search results are clearly integrated to form the final complete knowledge context. The specific integration formula is:
[0232] Context final =Concat(D vector ,R KG ) (twenty one)
[0233] In formula (21), Context final Represents the complete knowledge context for final answer generation, and Concat(·) represents merging the vector library with the retrieval result set of the knowledge graph;
[0234] Step 6.2) Based on the question type labels obtained in step 4), an adaptive chaining reasoning strategy suitable for different question types is adopted (the chaining strategy for multi-hop questions has been used in the previous iteration in step 5 and is no longer used separately in this step): Simple and conditional questions do not use the chaining method, and the large model is used to generate answers directly; aggregation questions use the least-to-most chaining reasoning method; comparison questions use the step-back chaining reasoning method; and judgment questions use the self-ask chaining reasoning method. For multi-hop questions, the system has already implemented the pre-reasoning and multi-step knowledge retrieval of the ToT (Tree-of-Thought) chaining strategy in step 5. Therefore, this step no longer uses the chaining strategy to construct the prompt. The complete knowledge context and sub-problem reasoning path formed in step 5 are directly used as the basic prompt input to the large language model in subsequent steps.
[0235] Step 6.2.1) For the aggregation problem, construct the prompt as:
[0236] You are an expert in the field of rice and wheat pests and diseases.
[0237] You will use the Least-to-Most (from simple to complex) thinking chain method to gradually and clearly answer the following aggregation questions:
[0238] Question: {For example: What are the common features of the main control measures for rice blast, sheath blight, and bacterial leaf blight?}
[0239] Step 1: Clearly list the key entities or concepts involved in the above questions.
[0240] Step 2: Identify the specific aggregation criteria used to analyze the common characteristics of these disease control measures.
[0241] Step 3: Based on the criteria of step 2, extract the main prevention and control measures for each disease from the preliminary search results; then clearly analyze and summarize the common characteristics reflected in these prevention and control measures.
[0242] Step 4: Summarize the above clear analysis process and give a clear and concise final answer.
[0243] Knowledge context: [Complete knowledge context retrieved by hybrid enhancement method of adaptive knowledge graph and vector library]
[0244] Step 6.2.2) For comparison questions, use the Step-Back reasoning strategy and construct the prompt as:
[0245] You are an expert in the field of agricultural pests and diseases, proficient in the diagnosis and control techniques of rice and wheat pests and diseases.
[0246] Please use the Step-Back thinking chain method to gradually and clearly answer the following comparison questions:
[0247] Question: {For example: Please compare the differences in symptoms and control strategies between rice stripe disease and rice bacterial leaf streak disease.}
[0248] Step 1: Briefly describe the symptoms and control strategies of rice stripe disease and rice bacterial leaf streak disease respectively;
[0249] Step 2: Take a step back and analyze at a higher level what the key differences are between the two diseases in terms of symptoms and control strategies;
[0250] Step 3: Based on the above clear analysis, summarize and clearly give the final comparison results and briefly explain the reasons.
[0251] Knowledge context: [Complete knowledge context retrieved by hybrid enhancement method of adaptive knowledge graph and vector library]
[0252] Step 6.2.3) For judgment questions, use the Self-Ask reasoning strategy and construct the prompt as:
[0253] You are an expert in the field of agricultural pests and diseases, proficient in rice and wheat pest control and diagnosis techniques.
[0254] Please use the Self-Ask thinking chain method to gradually and clearly answer the following judgment questions:
[0255] Question: {For example: Will persistent wet weather conditions definitely cause rice blast?}
[0256] Step 1 (Ask yourself): Clarify what key factors or conditions are involved in this problem?
[0257] Step 1 (self-answer): Based on the question, clearly indicate the factors or conditions involved.
[0258] Step 2 (Ask yourself): Are persistently wet conditions a necessary or sufficient condition for rice blast?
[0259] Step 2 (self-answer): Based on the given knowledge context, clearly analyze the relationship between conditions and disease occurrence.
[0260] Step 3 (Ask yourself): Are there any cases or counterexamples where rice blast did not occur under continuous humid climate conditions?
[0261] Step 3 (self-answer): Explicitly search and analyze whether there are corresponding counterexamples in the given knowledge context.
[0262] Step 4: Based on the above clear self-questioning and self-answering analysis process, finally give a clear answer of "yes" or "no" and briefly explain the reasons.
[0263] Knowledge context: [Complete knowledge context retrieved by hybrid enhancement method of adaptive knowledge graph and vector library]
[0264] Step 7) Combine the prompt to generate an accurate answer: Input the prompt constructed in step 6) into the large language model for reasoning and generation, and output the accurate answer to the final question.
[0265] Based on the prompts for different types of questions constructed in step 6) and the complete knowledge context constructed in step 5), they are input into the selected large language model (LLM) for reasoning calculation; the large language model reasoning process is expressed by the following clear formula:
[0266] Answer final =LLM(Prompt,Context final ) (twenty two)
[0267] In formula (22), Prompt represents the adaptive prompt content constructed in step 6) for different types of questions; Context final Represents the knowledge context formed by integrating the vector library and the knowledge graph retrieval results in step 6); Answer final Represents the final question answering result generated by the large language model after inference.
[0268] The present invention is not limited to the above-mentioned embodiments. On the basis of the technical solutions disclosed in the present invention, those skilled in the art can make some substitutions and modifications to some of the technical features therein according to the disclosed technical content without creative labor, and these substitutions and modifications are all within the protection scope of the present invention.
Claims
1. A question-answering method for agricultural pests and diseases based on knowledge graph adaptive hybrid retrieval enhancement, characterized by: The following steps are involved: Step 1) Data collection and organization: Relying on industry-specific platforms as information sources, automated collection tools are used to obtain unstructured text data on agricultural pests and diseases; Step 2) Construction of the knowledge graph and vector library: Based on the organized text corpus, a knowledge graph of agricultural pests and diseases was constructed. A standardized agricultural pest and disease QA dataset was constructed and a large amount of unstructured text was cleaned. A pre-trained semantic vector model was used to encode the semantic vectors of each text data segment to construct an agricultural pest and disease vector library. Step 3) Constructing a question-answer pre-classification system: pre-classify natural language questions that users may ask about rice and wheat pests and diseases; Step 4) Build and train an automatic classification model for question types: Use a small classification model to automatically identify and classify questions input by users in real time, forming a classifier for adaptive retrieval; Step 5) Adaptive knowledge retrieval based on question type: Adaptively and dynamically select different retrieval methods of knowledge graphs and vector libraries based on the query type; Step 6) Integrate the search results of the knowledge graph and vector library, select the corresponding thinking chain reasoning method according to the question type, and construct prompt words for different types of questions; Step 7) Combine the prompt to generate an accurate answer: Input the prompt constructed in step 6) into the large language model for reasoning and generation, and output the accurate answer to the final question.
2. The agricultural pest question-answering method based on knowledge graph adaptive hybrid retrieval enhancement according to claim 1 is characterized in that: The step 1) specifically includes: Step 1.1) Using information obtained from various channels in the agricultural field as the original information source, automated web crawler technology and data collection tools were used to collect unstructured raw text data related to major crop pests and diseases; Step 1.2) The collected raw data is preliminarily cleaned to remove irrelevant or duplicate content, forming a set of raw data on agricultural pests and diseases to be labeled, which is recorded as: Data raw ={Text1,Text2,...,Text n }, Data raw Represents the original text data set after preliminary cleaning, Text i Represents specific raw text content and unstructured data related to pests and diseases; Step 1.3) The raw data are uniformly stored in the database system, standardized and formatted, and finally the agricultural data corpus is constructed.
3. The agricultural pest question-answering method based on knowledge graph adaptive hybrid retrieval enhancement according to claim 2 is characterized in that: The step 2) specifically includes: Step 2.1) Organize agronomy experts and professional data annotators to construct a knowledge graph for agricultural pests and diseases based on the original data set related to agricultural pests and diseases obtained in Step 1). Clarify the entity relationships in the knowledge graph and use semi-automated entity and relationship extraction tools to extract knowledge elements and annotate relationships from the text. Perform manual verification to generate entity-relationship-entity triples. Using the graph database technology Neo4j, import the annotated triples into the graph database to construct a specific mapping of the knowledge graph entity nodes, relationship edges, node attributes, and relationship attributes to form the final knowledge graph. Step 2.2) Construct a semantic vector library for the agricultural pest and disease field; design and construct a QA dataset for the agricultural pest and disease field, manually compiling, automatically generating, and semi-automatically annotating common pest and disease questions, covering various types of questions and standardized answers; initially clean the agricultural pest and disease data using keywords, and then use manual rescreening to secondary screen and supplement the incomplete parts of the above data; after the text data is processed into a unified format and semantic features are extracted, a text knowledge base suitable for semantic vector retrieval is constructed to support semantic retrieval methods based on the vector library.
4. The agricultural pest question-answering method based on knowledge graph adaptive hybrid retrieval enhancement according to claim 1 is characterized in that: The step 3) specifically includes: Step 3.1) Collect a large number of natural language questions related to rice and wheat pests and diseases that users may raise in actual production, extract the semantic and structural features of different question types, and form a feature library of agricultural pest and disease question types; Step 3.2) Classify the QA question library and collected natural language questions based on question type characteristics, including simple questions, conditional questions, aggregation questions, comparison questions, multi-hop questions, and judgment questions. Build a dataset of crop pest and disease questions and use automated and semi-automated data augmentation techniques to expand the volume and diversity of question sample data, forming a comprehensive set of question samples to support accurate training of the classification model. In step 3.3, all generated sample data are submitted to agricultural experts for manual review and annotation confirmation to form a high-quality labeled agricultural pest and disease problem type classification dataset.
5. The agricultural pest question-answering method based on knowledge graph adaptive hybrid retrieval enhancement according to claim 4 is characterized in that: The step 4) specifically includes: Step 4.1) When the user inputs a question related to rice or wheat pests and diseases, the system automatically pre-processes the input text, standardizes the text format and grammatical structure, and forms a standardized question input text; In step 4.2), the T5-large neural network model is used to perform supervised fine-tuning training on the agricultural pest and disease problem type classification dataset constructed in step 3.3) to achieve automatic classification of problem types; In step 4.3, we use the cross entropy loss function as the training objective function for the T5-large fine-tuned classification model. During model training, we optimize the loss for all categories, specifically expressed as: In formula (1), N represents the total number of training samples; C represents the total number of question type categories; y ni is the one-hot label of the true category of the nth sample; After generating category predictions for the T5-large model, the predicted category probabilities are obtained through the softmax function; θ is all the trainable parameters of the T5-large model; Step 4.4) The training process aims to minimize the loss function and obtain the optimal T5-large model parameters θ * : Step 4.5) The user-entered question text is fed into the sequence and fed into the fine-tuned T5-large model. The model outputs the predicted question type category in text form: label=Classifier T5 (input_text) (3) The system converts the generated category text into the corresponding category label through the defined mapping relationship, and at the same time, records the predicted probability output by the model: Perform threshold judgment on the output classification labels, and conduct manual or rule-assisted review on classification results below the threshold.
6. The agricultural pest question-answering method based on knowledge graph adaptive hybrid retrieval enhancement according to claim 1 is characterized in that: The step 5) specifically includes: based on the question type label output by the automatic classification model, the system automatically determines to adopt a knowledge graph search strategy, a vector library search strategy, or a hybrid search strategy combining the two; a) Simple questions: No knowledge graph or vector library search is performed, and the user's question text is directly fed into the large language model for answer generation; b) Conditional questions: single-step conditional semantic retrieval, single-step conditional graph attribute query; Through the vector library retrieval strategy, according to the conditions in the question, a conditional semantic query vector is constructed, and a single-step conditional semantic constraint retrieval is performed; through the knowledge graph retrieval strategy, the query is filtered by attribute conditions in the knowledge graph G; c) Aggregation problem: two-step coarse-fine search in vector database and batch graph entity relationship query; Vector library search strategy: This strategy uses a two-step aggregate search strategy. The first step is a coarse search, followed by a fine search. The large LLM model processes the coarse search results of the first step to generate a more accurate secondary query vector. The new fine vector is then used for a second search to obtain a refined result set. Knowledge graph search strategy: This strategy implements aggregated question search through batch entity relationship queries. d) Comparison problem: multi-entity parallel semantic retrieval and multi-entity attribute graph query; Vector library search strategy: Using a method of parallel semantic search and merging of multiple entity keywords, the method first extracts keyword sets corresponding to multiple entities to be compared from the comparison question text posed by the user, forming multiple keyword query sequences. The second step is to independently semantically vectorize each keyword, and then perform vector search in parallel. The third step is to merge the result sets of parallel searches of multiple entity keywords to obtain the final comprehensive search result set. Knowledge graph search strategy: Construct a multi-entity attribute comparison query. e) Multi-hop problem: After generating the ToT sub-problem, iterative semantic retrieval and iterative multi-step graph retrieval with path attenuation confidence are performed; Vector library retrieval strategy: A large language model is used to perform ToT reasoning, expanding the possible reasoning paths of complex multi-hop problems in a tree-like manner to generate multiple clear sub-problems or sub-queries. The feasibility of each path is evaluated through the LLM, the optimal path is selected, and iterative retrieval is performed on each sub-problem in the selected ToT optimal path. A new query text is dynamically generated based on the knowledge set obtained in the previous retrieval step and the original question, clarifying the next retrieval direction, generating the next reasoning step, and then executing the knowledge retrieval in the i-th step. The knowledge fragments retrieved in all ToT steps are integrated to form the final multi-hop knowledge context and generate the final answer. Knowledge graph retrieval strategy: Use entity recognition methods to extract initial nodes from the original question and form an initial node set; adopt an iterative knowledge graph retrieval strategy to gradually clarify the final answer to the question through the continuous expansion of nodes and relationships; use the path decay confidence method to expand nodes and deduce relationships in the graph; Breadth-first search (BFS) and depth-first search (DFS) strategies are used for path expansion. That is, when expanding each layer of nodes, all adjacent nodes are expanded first, and then the next layer is expanded and the single path is expanded until the end of the path is reached and then backtracked. After the path expansion is completed, the termination conditions of the knowledge graph path expansion and attenuation are set, and finally a knowledge graph result set is formed; f) Judgment problem: single-step semantic similarity retrieval and single-step graph attribute judgment retrieval; Vector library retrieval strategy: The judgment question text raised by the user is semantically encoded into a vector to obtain a semantic query vector that expresses the user's question intent. By calculating the cosine similarity between the user's question semantic vector and the text semantic vector stored in the vector library, a single-step precise matching retrieval is achieved. Knowledge graph retrieval strategy: The goal of knowledge graph retrieval is to determine whether the specific relationship or attribute involved in the user's question exists in the graph, so as to clearly return a "yes" or "no" answer.
7. The agricultural pest question-answering method based on knowledge graph adaptive hybrid retrieval enhancement according to claim 6 is characterized in that: The specific retrieval strategy for the aggregation problem is: Vector library search strategy: A two-step aggregation search strategy is used to implement the search. The first step is a coarse search. The formula is as follows: In formula (5), q represents the vector representation of the question raised by the user after embedding; Represents the cosine similarity between the question vector and each knowledge vector; Top k It means taking the first k knowledge fragments closest to the question semantics from the vector library to form a coarse-grained result set D coarse ; The second step is fine search, using the large model LLM to search the first step of the rough search results D coarse Process and generate a secondary query vector q fine : q fine =LLM(D coarse ) (6) In formula (6), q fine Indicates that LLM is used to generate specific query expressions based on rough search results; D coarse Represents the larger set retrieved in the first step; Use the new precision vector q fine Perform a second search to obtain a refined result set. The formula is as follows: In formula (7), n is much smaller than k in the first step; Knowledge graph retrieval strategy: aggregate question retrieval is achieved through batch entity relationship query. The formula is as follows: R agg 6{(e,r,o)|(e,r,o)∈G,e∈E agg ,r∈R agg } (8) In formula (8), E agg Represents the entity set required for aggregation; R agg Represents an aggregation target relationship.
8. The agricultural pest question-answering method based on knowledge graph adaptive hybrid retrieval enhancement according to claim 6 is characterized in that: The specific retrieval strategy for the multi-hop problem is: A large language model is used to perform ToT reasoning, which expands the possible reasoning paths of complex multi-hop problems in a tree-like manner and generates multiple clear sub-questions or sub-queries. The specific formula is expressed as follows: ToT tree-like thinking chain path expansion: T paths =LLM ToT (q)={path1,path2,…,path n } (9) In formula (9), q represents the input questions, T paths Represents multiple possible reasoning paths explicitly generated by the ToT method; each path i It is a set of ordered sub-problems, representing different reasoning directions; Use LLM to evaluate the feasibility of each path and select the optimal path: For each sub-path in the ToT optimal path selected by formula (10), out ; Perform iterative retrieval separately: The first sub-question retrieval process: represents the set of knowledge fragments retrieved for the first time; q 1a For the first sub-problem; Step i: Reasoning and retrieval iteration: Based on the knowledge set obtained in the previous retrieval step and the original question, a new query text is dynamically generated to clarify the next retrieval direction and generate the next reasoning step: Then execute the knowledge retrieval in step i: The knowledge fragments retrieved by all ToT steps are integrated to form the final multi-hop knowledge context: In formula (14), context multi-hop represents the final fusion of all sub-question retrieval results to form a complete and comprehensive multi-hop knowledge context; Concat(·) represents the merging of the retrieval results of multiple sub-questions; Final answer generation formula: Answer final =LLM(q,context multi-hop ) (15) Knowledge graph retrieval strategy: Use entity recognition method to extract initial nodes from the original question to form an initial node set: E init ={n1,n2,n3,…,n i }; Adopting the knowledge graph iterative retrieval strategy, through the continuous expansion of nodes and relationships, the final answer to the question is gradually identified. The specific steps and formula are as follows: Initial node confidence setting: The confidence of each node in the initial node set is 1: s(n init )=1,n init ∈E init (16) Using the path attenuation confidence method, we expand the graph nodes and deduce relationships. The specific implementation process is as follows: Starting from the initial node, the knowledge graph entity relationship path is expanded. During the path expansion process, the node confidence decays as the path depth increases. The formula for path decay confidence is: s(n j )=s(n i )×α L ×s(r ij ) (17) In formula (17), s(n j ) represents the expansion of the new node n j Confidence level; s(n i ) represents the current node n i confidence; α: explicitly represents the path attenuation coefficient, which is used to control the degree of attenuation of the confidence of path extension as the path length increases; L represents the number of nodes from the initial node n init To the current node n j The path length s(r ij ) represents the slave node n i To node n j Relationship between ij confidence level; Breadth-first search (BFS) and depth-first search (DFS) strategies are used for path expansion. That is, when expanding each layer of nodes, all adjacent nodes are expanded first, and then the next layer is expanded and the single path is expanded until the end of the path is reached and then backtracked. After the path expansion is completed, the termination conditions for the knowledge graph path expansion and attenuation are set: Termination=(s(n j )<Threshold) OR (L≥max_length) (18) In formula (18), Threshold is the confidence threshold that is clearly set, and max_length is the maximum number of iterations that is preset. Finally, the knowledge graph result set is formed: {R1, R2, …, R m }.
9. The agricultural pest question-answering method based on knowledge graph adaptive hybrid retrieval enhancement according to claim 1 is characterized in that: The step 6) specifically includes: Step 6.1) According to the vector library and knowledge graph retrieval strategies executed for different types of questions, the corresponding retrieval result sets are obtained respectively: the vector library retrieval result set is recorded as D vector ; The knowledge graph retrieval result set is recorded as R KG , the search results are clearly integrated to form the final complete knowledge context. The specific integration formula is: Context final =Concat(D vector ,R KG ) (19) In formula (19), Context final represents the complete knowledge context for final answer generation, Concat(·) means merging the vector library with the search result set of the knowledge graph; Step 6.2) Based on the obtained question type label, an adaptive thought chain reasoning strategy suitable for different question types is adopted, and through the implementation of the thought chain strategy, clear prompts are constructed to guide the large language model to gradually generate answers.
10. The agricultural pest question-answering method based on knowledge graph adaptive hybrid retrieval enhancement according to claim 1 is characterized in that: The step 7) specifically includes: inputting the prompts for different types of questions and the corresponding knowledge context constructed in step 6) into the selected large language model LLM for reasoning calculation; the large language model reasoning process is expressed by the following formula: Answer final =LLM(Prompt,Context final ) (20) In formula (20), Prompt represents the adaptive prompt content constructed in step 6) for different types of questions; Context final represents the knowledge context formed by fusing the vector library and the knowledge graph retrieval results in step 6); Answer final Represents the final question answering result generated by the large language model after inference.
Citation Information
Cited By
High-performance knowledge base system based on multi-modal mixed retrieval
CN120781933A
A high-performance knowledge base system based on multi-modal hybrid retrieval
CN120781933B
Retrieval enhancement method and system based on unstructured data
CN120994813A
Joint modeling method based on knowledge graph and large model retrieval enhancement
CN121117179A
Road disease cause multi-stage intelligent loop iterative optimization method
CN121189538A