Agricultural disease question-oriented entity-aware document re-ranking method and system
By using an entity-aware document reordering method, key entities in agricultural disease consultation questions and candidate evidence documents are identified, and entity adaptation information is constructed. This solves the problem of insufficient adaptation between candidate document ordering and production conditions in agricultural disease question answering, and improves the reliability and executability of question answering.
Patent Information
- Application Number
- CN202611025374.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-10
- Publication Date
- 2026-11-06
AI Technical Summary
Existing agricultural disease question-and-answer systems do not fully consider agricultural entity constraints, resulting in insufficient adaptability of candidate document ranking results to production conditions.
By acquiring agricultural disease consultation questions and candidate evidence documents, entity identification is performed, entity adaptation information is constructed, question entity weights and evidence adaptation scores are calculated, and an agricultural entity perception mechanism is introduced for re-ranking.
It effectively alleviates the problem of evidence misalignment caused by similar topics but inconsistent conditions, and provides more reliable, traceable and production-compliant intelligent question-and-answer support for agricultural diseases.
Smart Images

Figure CN123048701A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of natural language processing and information retrieval technology, and in particular to an entity-aware document reordering method and system for agricultural disease question answering. Background Technology
[0002] With the rapid development of smart agriculture and agricultural technology knowledge services, intelligent question-and-answer (Q&A) for agricultural diseases is playing an increasingly important role in disease diagnosis, pesticide selection, and field management. Agricultural disease Q&A services require that answers be supported by traceable evidence, and that recommendations be actionable and appropriate for specific production conditions. Retrieval-Augmented Generation (RAG), by incorporating external agricultural knowledge documents, enhances the factual basis and updatable nature of answers and has been used in recent years for scenarios such as agricultural technology consultation, crop pest and disease Q&A, and localized agricultural services.
[0003] However, the quality of responses from the RAG system is highly dependent on the quality of evidence entering the generation context. Agricultural disease question answering exhibits significant conditional sensitivity. Entities such as crops, diseases, pests, pesticides, fertilizers, timing, location, and pathogens are not only semantic units in the text but also production constraints that determine whether control recommendations can be implemented. When candidate documents contain a large amount of interfering evidence with similar themes but different production conditions—for example, different diseases under the same crop, different growth stages under the same disease, or different pesticide regimens for the same control target—if such documents are prioritized, the generation model may suffer from problems such as control target bias, insufficient pesticide applicability, or generalization of measures.
[0004] Existing document re-ranking techniques mainly include the following categories: First, re-ranking methods based on BERT cross-encoders improve relevance judgment through deep interaction modeling between queries and documents. However, re-ranking is usually treated as a general semantic matching task, failing to fully model the fine-grained constraints of key entities in the agricultural field. Second, list-based re-ranking methods based on large language models, such as RankGPT and jina-reranker-v3, can compare the relative relationships of multiple documents in the same candidate set, improving the accuracy of semantic ranking. However, they also fail to explicitly model agricultural entity constraints. Third, general entity-enhanced ranking methods introduce entity information into the ranking model to improve fine-grained relevance judgment. For example, Word-Entity Duet combines term representations with entity representations to model document relevance, EDRM introduces knowledge graph semantics into the neural ranking model, and DREQ improves ranking performance by highlighting relevant entities and weakening irrelevant entities. The above-mentioned entity-aware ranking research is mostly geared towards general knowledge graphs or encyclopedic entities, lacking specific modeling for production condition constraints such as crops, diseases, pesticides, and timing in agricultural disease question-and-answer.
[0005] Furthermore, existing research on agricultural question answering has begun to focus on the impact of re-ranking on the performance of RAG (Related Aspects of Question Answering). Agricultural named entity recognition datasets such as AgCNER have also provided a data foundation for extracting entities in fields such as crops, diseases, pests, and pesticides. However, how to further transform the types, matching relationships, and distinguishing effects within candidate sets of agricultural entities into effective document ranking signals, and extend evidence selection from general semantic relevance judgment to production condition adaptation judgment, still requires further research. Summary of the Invention
[0006] Therefore, the technical problem to be solved by the present invention is to overcome the problem that the existing technology does not fully consider the agricultural entity constraints in agricultural disease question and answer, resulting in insufficient adaptability of candidate document ranking results to agricultural production conditions.
[0007] To address the aforementioned technical problems, this invention provides an entity-aware document reordering method for agricultural disease question answering, comprising: Obtain agricultural disease consultation questions and a set of candidate evidence documents corresponding to the agricultural disease consultation questions; determine the semantic information related to each candidate evidence document in the agricultural disease consultation questions and the set of candidate evidence documents; Based on a preset set of agricultural entity types, entity recognition is performed on the agricultural disease consultation questions and each candidate evidence document to obtain the question entity information corresponding to the agricultural disease consultation questions and the document entity information corresponding to each candidate evidence document. Based on the question entity information and the document entity information, determine the entity matching information between the agricultural disease consultation question and each candidate evidence document; Based on the problem entity information and the document entity information, determine the distribution of the problem entity information in the candidate evidence document set, and determine the problem entity weight corresponding to the problem entity information based on the distribution. Based on the entity adaptation information and the issue entity weight, determine the weighted entity adaptation information corresponding to each candidate evidence document; based on the semantic related information and the weighted entity adaptation information, determine the evidence adaptation score corresponding to each candidate evidence document. Based on the evidence fit score, the candidate evidence documents in the candidate evidence document set are reordered.
[0008] In one embodiment of the present invention, the distribution of the problem entity information in the candidate evidence document set is determined based on the problem entity information and the document entity information, and the method for determining the problem entity weight corresponding to the problem entity information based on the distribution is as follows: Based on the problem entity information and the document entity information, the document frequency of each problem entity in the problem entity information in the candidate evidence document set is calculated. Based on the document frequencies, determine the candidate set inverse document frequencies corresponding to each question entity; The weight of each question entity is determined based on the inverse document frequency of the candidate set corresponding to each question entity. The weight of the problem entity is represented as follows: , in, For the problem entity The corresponding problem entity weights, The first in the problem entity information One problem entity, For the problem entity The corresponding candidate set inverse document frequency, This is the inverse document frequency weighted intensity coefficient.
[0009] In one embodiment of the present invention, the method for determining the inverse document frequency of the candidate set corresponding to each question entity based on the document frequency is as follows: For each problem entity in the problem entity information, the number of candidate evidence documents containing that problem entity is counted to obtain the document frequency of that problem entity in the candidate evidence document set; Based on the number of candidate evidence documents in the candidate evidence document set and the document frequency, determine the candidate set inverse document frequency corresponding to the problem entity; The inverse document frequency of the candidate set is represented as: , in, The number of candidate evidence documents in the candidate evidence document set. For the problem entity Document frequency in the candidate evidence document set.
[0010] In one embodiment of the present invention, the method for determining the weighted entity adaptation information corresponding to each candidate evidence document based on the entity adaptation information and the problem entity weight is as follows: Based on the weight of the problem entity, the entity adaptation contribution corresponding to each problem entity in the entity adaptation information is weighted to obtain the weighted entity adaptation information corresponding to each candidate evidence document. The weighted entity adaptation information includes a weighted alignment matrix, which is represented as follows: , in, Candidate evidence documents The corresponding weighted alignment matrix, The first in the candidate evidence document set One candidate evidence document, The weight vector is composed of the weights of the problem entities. For dimensions and candidate evidence documents The vector of all 1s corresponding to the number of document entities in the document. Candidate evidence documents The corresponding basic entity attention matrix, This indicates element-wise multiplication.
[0011] In one embodiment of the present invention, the method for determining the evidence adaptation score corresponding to each candidate evidence document based on the semantically related information and the weighted entity adaptation information is as follows: Based on the semantic information, determine the question vector corresponding to the agricultural disease consultation question and the candidate document vector corresponding to each candidate evidence document; The candidate document vector corresponding to each candidate evidence document is fused with the corresponding weighted entity adaptation information to obtain the enhanced candidate document vector corresponding to each candidate evidence document. Based on the question vector and the vectors of each augmentation candidate document, the evidence fit score corresponding to each candidate evidence document is determined, as follows: , in, Candidate evidence documents The corresponding evidence fit score, Let be the question vector corresponding to the agricultural disease consultation question. Candidate evidence documents The corresponding enhanced candidate document vectors, This is the cosine similarity function.
[0012] In one embodiment of the present invention, the method for determining the entity matching information between the agricultural disease consultation question and each candidate evidence document based on the question entity information and the document entity information is as follows: Based on the entity position of each issue entity in the issue entity information, extract the issue entity representation corresponding to each issue entity from the list-based semantic encoding result; Based on the entity position of each document entity in the document entity information, extract the document entity representation corresponding to each document entity from the list-style semantic encoding result; Construct a problem entity representation matrix based on the problem entity representation corresponding to each problem entity, and construct a document entity representation matrix corresponding to each candidate evidence document based on the document entity representation corresponding to each document entity. Based on the problem entity representation matrix and the document entity representation matrix corresponding to each candidate evidence document, the entity adaptation information between the agricultural disease consultation problem and each candidate evidence document is determined. The question entity representation matrix and the document entity representation matrix are represented as follows: , , in, Let the problem entity be represented by a matrix. Candidate evidence documents The corresponding document entity representation matrix, For the number of problem entities, Candidate evidence documents The number of document entities in the document. Dimensions for representing entities.
[0013] In one embodiment of the present invention, the method for determining the entity matching information between the agricultural disease consultation question and each candidate evidence document, based on the question entity representation matrix and the document entity representation matrix corresponding to each candidate evidence document, is as follows: Based on the entity representation information of the question and the document entity representation information corresponding to each candidate evidence document, calculate the entity similarity matrix between the agricultural disease consultation question and each candidate evidence document; The entity similarity matrix is normalized to obtain the basic entity attention matrix corresponding to each candidate evidence document; The basic entity attention matrix is determined as the entity adaptation information; The basic entity attention matrix is represented as follows: , in, Candidate evidence documents The corresponding basic entity attention matrix, For the agricultural disease consultation questions and candidate evidence documents Entity similarity matrix between them This is the normalization function.
[0014] The method for determining the semantic information related to the agricultural disease consultation question and the candidate evidence documents in the candidate evidence document set is as follows: List-based semantic encoding is performed on the agricultural disease consultation question and the candidate evidence document set to obtain the question vector corresponding to the agricultural disease consultation question and the candidate document vector corresponding to each candidate evidence document. The question vector and each candidate document vector are represented as follows: , in, For the aforementioned agricultural disease consultation issues. The set of candidate evidence documents, Let the problem vector be... Candidate evidence documents The candidate document vectors, wherein the semantically related information includes the question vector and each candidate document vector.
[0015] In one embodiment of the present invention, the method for performing entity recognition on the agricultural disease consultation question and each candidate evidence document based on a preset set of agricultural entity types to obtain the question entity information corresponding to the agricultural disease consultation question and the document entity information corresponding to each candidate evidence document is as follows: Based on the preset agricultural entity type set, entity recognition is performed on the agricultural disease consultation questions to obtain the question entities related to agricultural production conditions in the agricultural disease consultation questions. Based on the preset agricultural entity type set, entity recognition is performed on each candidate evidence document to obtain document entities related to agricultural production conditions in each candidate evidence document. Based on the entity content, entity type, and entity location of the problem entity, construct the problem entity information; Based on the entity content, entity type, and entity location of the document entity, construct the document entity information corresponding to each candidate evidence document.
[0016] Based on the same inventive concept, this invention also provides an entity-aware document reordering system for agricultural disease question answering, comprising: The information acquisition and semantic encoding module is used to acquire agricultural disease consultation questions and a set of candidate evidence documents corresponding to the agricultural disease consultation questions; and to determine the semantic information related between the agricultural disease consultation questions and each candidate evidence document in the set of candidate evidence documents. The entity recognition module is used to perform entity recognition on the agricultural disease consultation question and each candidate evidence document based on a preset set of agricultural entity types, so as to obtain the question entity information corresponding to the agricultural disease consultation question and the document entity information corresponding to each candidate evidence document. The entity matching determination module is used to determine the entity matching information between the agricultural disease consultation question and each candidate evidence document based on the question entity information and the document entity information. The entity weight determination module is used to determine the distribution of the problem entity information in the candidate evidence document set based on the problem entity information and the document entity information, and to determine the problem entity weight corresponding to the problem entity information based on the distribution. The weighted adaptation and evidence score determination module is used to determine the weighted entity adaptation information corresponding to each candidate evidence document based on the entity adaptation information and the weight of the problem entity; and to determine the evidence adaptation score corresponding to each candidate evidence document based on the semantic related information and the weighted entity adaptation information. The document reordering module is used to reorder each candidate evidence document in the candidate evidence document set according to the evidence fit score.
[0017] The technical solution of the present invention has the following advantages compared with the prior art: This invention introduces an agricultural entity perception mechanism based on list-based semantic reordering. By identifying key entities such as crops, diseases, pesticides, and periods in agricultural disease consultation questions and candidate evidence documents, and constructing entity adaptation information, it overcomes the shortcomings of existing reordering methods that do not fully model agricultural entity constraints. Simultaneously, by calculating the inverse document frequency of the candidate set by statistically analyzing the document frequency of the question entity in the candidate evidence document set, it dynamically determines the weight of the question entity, allowing low-frequency, high-discrimination entities to contribute more and preventing high-frequency, low-discrimination entities from overwhelming key information. Furthermore, it integrates the weighted entity adaptation information with the list-based semantic encoding results to calculate the evidence adaptation score, enabling the ranking score to possess both global semantic matching capabilities and local agricultural production condition adaptation capabilities. This effectively alleviates the problem of evidence misalignment caused by similar topics but inconsistent conditions, allowing the entity constraint modeling in the ranking stage to be effectively transmitted to downstream question-answering generation, providing more reliable, traceable, and production-condition-compliant technical support for intelligent question answering of agricultural diseases. Attached Figure Description
[0018] To make the content of this invention easier to understand, the invention will be further described in detail below with reference to specific embodiments and accompanying drawings.
[0019] Figure 1 This is a flowchart illustrating the entity-aware document reordering method for agricultural disease question answering in Embodiment 1 of the present invention. Figure 2 This is a comparison chart of RAG-F1@3 for different retrieval and reordering methods in Embodiment 2 of the present invention when the number of input documents K=3; Figure 3 This is a graph showing the RAG-F1@K variation of different retrieval and reordering methods under different numbers of input documents in Embodiment 2 of the present invention. Detailed Implementation
[0020] The present invention will be further described below with reference to the accompanying drawings and specific embodiments, so that those skilled in the art can better understand and implement the present invention. However, the embodiments described are not intended to limit the present invention.
[0021] Example 1: like Figure 1 As shown, this invention provides an entity-aware document reordering method for agricultural disease question answering, comprising: Obtain agricultural disease consultation questions and a set of candidate evidence documents corresponding to the agricultural disease consultation questions; determine the semantic information related to each candidate evidence document in the agricultural disease consultation questions and the set of candidate evidence documents; Based on a preset set of agricultural entity types, entity recognition is performed on the agricultural disease consultation questions and each candidate evidence document to obtain the question entity information corresponding to the agricultural disease consultation questions and the document entity information corresponding to each candidate evidence document. Based on the question entity information and the document entity information, determine the entity matching information between the agricultural disease consultation question and each candidate evidence document; Based on the problem entity information and the document entity information, determine the distribution of the problem entity information in the candidate evidence document set, and determine the problem entity weight corresponding to the problem entity information based on the distribution. Based on the entity adaptation information and the issue entity weight, determine the weighted entity adaptation information corresponding to each candidate evidence document; based on the semantic related information and the weighted entity adaptation information, determine the evidence adaptation score corresponding to each candidate evidence document. Based on the evidence fit score, the candidate evidence documents in the candidate evidence document set are reordered.
[0022] This invention acquires a set of agricultural disease consultation questions and candidate evidence documents, and determines semantically relevant information through list-based semantic encoding. Based on a preset set of agricultural entity types, it performs entity recognition on the questions and candidate documents to obtain question entity information and document entity information. Entity fit information is determined based on the question entity information and document entity information, and the distribution of question entities in the candidate evidence document set is statistically analyzed and question entity weights are calculated. The entity fit information is weighted using the question entity weights to obtain weighted entity fit information. The evidence fit score is calculated by fusing semantically relevant information and weighted entity fit information, and the documents are re-ranked based on the score. This method explicitly models constraints on key agricultural entities such as crops, diseases, pesticides, and time periods, and dynamically adjusts the contribution of entities based on their discriminative power in the candidate set. It improves document ranking from global semantic relevance to consideration of adaptability to agricultural production conditions, effectively alleviating the problem of evidence misplacement caused by similar themes but inconsistent key conditions. This improves the matching degree between the re-ranking results and actual production needs, providing support for generating more reliable and actionable prevention and control suggestions for downstream agricultural question answering.
[0023] Agricultural disease consultation questions are natural language questions raised by users concerning at least one of the following: crop disease symptoms, disease diagnosis, pesticides, timing of control, and control measures. In agricultural disease question-and-answer scenarios, user questions typically include agricultural production condition information such as crop type, disease name, occurrence time, affected parts, pesticide name, or control method. This information is dispersed as entities within the question text. The candidate evidence document set is obtained from an initial search of the agricultural disease knowledge base. The agricultural disease knowledge base includes document fragments on disease symptoms, control targets, control timing, pesticides, and control measures. In one implementation, candidate evidence documents can be retrieved from the agricultural disease knowledge base through keyword retrieval, semantic retrieval, or a combination of both, forming a candidate evidence document set. Each candidate evidence document in the set has a certain degree of thematic relevance to the agricultural disease consultation question, but the agricultural production conditions (crops, diseases, pesticides, timing, parts, etc.) involved in each candidate evidence document may not be entirely consistent with the actual constraints in the question.
[0024] Before candidate evidence documents enter the agricultural disease question-and-answer generation model, the goal of re-ranking the candidate evidence document set is to use both semantic relevance and suitability to agricultural production conditions as ranking criteria. This ensures that the top-ranked candidate evidence documents are not only semantically related to the agricultural disease consultation question, but also consistent with the question in terms of key agricultural entity conditions such as crop, disease, pesticide, period, and part. Evidence documents that are suitable for specific production scenarios are selected from the relevant documents.
[0025] In this embodiment of the invention, agricultural disease consultation questions and corresponding candidate evidence document sets are obtained. The agricultural disease consultation question is denoted as... The set of candidate evidence documents corresponding to agricultural disease consultation questions is denoted as . ,in Indicates the first document in the candidate evidence document set. One candidate evidence document, This indicates the number of candidate evidence documents.
[0026] To fully utilize the semantic relationships between agricultural disease consultation questions and candidate evidence documents, while also considering the relative ranking information among documents within the same candidate evidence document set, this embodiment of the invention employs a list-based semantic encoding method to jointly encode the agricultural disease consultation questions and their candidate evidence document sets. List-based semantic encoding refers to constructing an input sequence containing the agricultural disease consultation question and all its corresponding candidate evidence documents. This sequence is then encoded by a semantic re-ranking model within the same context. The encoding result includes not only the semantic matching information between the agricultural disease consultation question and individual candidate evidence documents, but also the relative semantic relationship information of each candidate evidence document relative to other candidate evidence documents within the same candidate set. Through list-based encoding, the vector representation of each candidate evidence document is obtained within the comparative context with other candidate evidence documents, which facilitates the subsequent ranking stage's determination of relative importance within the same candidate set.
[0027] Specifically, agricultural disease consultation issues With candidate evidence document set The common input list-based semantic reordering model, after list-based semantic encoding, yields the question vector corresponding to the agricultural disease consultation question and the candidate document vector corresponding to each candidate evidence document, represented as follows: , in, Indicating agricultural disease consultation issues The corresponding problem vector, Indicates candidate evidence documents The corresponding candidate document vectors, Represents the vector dimension. This represents a semantic reordering model used for list-based semantic encoding. The semantically relevant information includes the question vector. and the vectors of each candidate document .
[0028] In a preferred embodiment, the list-based semantic encoding model can employ jina-reranker-v3 or a semantic re-ranking model with list-based candidate document encoding capabilities. This model sets question representation tags and document representation tags in the input sequence to aggregate contextual information from the question and document sides, respectively, and outputs the hidden states at the corresponding tag positions as question vectors and candidate document vectors. The question vectors and candidate document vectors obtained through list-based encoding provide a semantic foundation containing list-level contextual interaction information for subsequent steps, enabling subsequent entity-aware re-ranking to be performed within a global semantic comparison framework.
[0029] Furthermore, after obtaining the question vector corresponding to the agricultural disease consultation question and the candidate document vector corresponding to each candidate evidence document, this embodiment further performs agricultural entity recognition on the agricultural disease consultation question and each candidate evidence document to obtain entity-level information for judging the suitability of agricultural production conditions.
[0030] Specifically, in agricultural disease question-and-answer scenarios, agricultural entities such as crops, diseases, pests, pesticides, varieties, fertilizers, pathogens, timing, location, and biological mediators are crucial production constraints determining whether prevention and control recommendations can be implemented. To effectively identify these entities and serve subsequent evidence fit judgments, a pre-defined set of agricultural entity types is established. This pre-defined set of agricultural entity types limits the scope of entities affecting evidence fit judgments in agricultural disease question-and-answer scenarios. In a preferred embodiment, the pre-defined set of agricultural entity types includes at least the following entity types: crops, diseases, pests, pesticides, varieties, fertilizers, pathogens, timing, location, and biological mediators. These entity types cover the main agricultural production conditions affecting the applicability of agricultural disease prevention and control answers. For example, crop type determines whether the prevention and control target is suitable for the current planting scenario; disease and pest type determines whether the prevention and control target is correct; pesticide type determines whether the prevention and control method is feasible; timing type determines whether the prevention and control measures are consistent with the crop growth stage or disease occurrence cycle; and location type determines whether the prevention and control operation targets the correct disease location. By limiting the scope of the aforementioned entity types, subsequent processing can focus on key agricultural entities that have a real impact on the determination of evidence fit, thereby reducing the interference of other weakly related entities on the ranking decision.
[0031] Based on this, entity recognition is performed on the agricultural disease consultation questions using the preset agricultural entity type set to obtain question entities related to agricultural production conditions. Simultaneously, entity recognition is performed on each candidate evidence document using the preset agricultural entity type set to obtain document entities related to agricultural production conditions in each candidate evidence document. The question entities are entities identified from the agricultural disease consultation questions that belong to the preset agricultural entity type set, and the document entities are entities identified from each candidate evidence document that belong to the preset agricultural entity type set. Both question entities and document entities involve agricultural production condition types such as crops, diseases, pests, pesticides, varieties, fertilizers, pathogens, time periods, parts of plants, or biological mediators. By performing entity recognition on the agricultural disease consultation questions and each candidate evidence document, discrete natural language text can be transformed into structured entity information, providing a data foundation for subsequently establishing a matching relationship between questions and documents at the entity level.
[0032] In a preferred embodiment, the entity recognition described above can be implemented using an agricultural entity recognition model. The agricultural entity recognition model is used to identify entities belonging to a preset set of agricultural entity types from the input text, and outputs the entity content, entity type, and entity location of each entity. The agricultural entity recognition model can be built based on an encoder, converting the input text into sequence label format, and predicting the entity label for each token through a classification layer, thereby identifying entities belonging to the preset set of agricultural entity types from the input text. In one preferred embodiment, the agricultural entity recognition model can use chinese-roberta-wwm-ext as the encoder, converting the input text into BIO sequence label format, and then using a token classification layer to predict entity labels. The agricultural entity recognition model can be trained using an agricultural entity labeling corpus.
[0033] In a preferred embodiment, the agricultural entity recognition model can be fine-tuned using agricultural semantically relevant entity annotation data from the AgCNER agricultural pest and disease named entity recognition dataset. During fine-tuning, entity categories weakly correlated with agricultural disease evidence fitting judgments are removed, while agricultural semantically relevant entities such as pests, diseases, crops, pesticides, varieties, fertilizers, pathogens, periods, parts, and biological mediators are retained. After this fine-tuning training, the agricultural entity recognition model can accurately extract agricultural entities related to agricultural production conditions from agricultural disease consultation questions and candidate evidence documents. It should be noted that the AgCNER dataset is only used as an optional training data source, and the implementation of the agricultural entity recognition model is not limited to it. Any model capable of identifying agricultural entities from text based on a preset set of agricultural entity types and outputting entity content, entity type, and entity location can be used to implement this embodiment.
[0034] For each question entity identified from agricultural disease consultation questions, question entity information is constructed. This information includes the question entities identified from the agricultural disease consultation questions, and each question entity includes at least three attributes: entity content, entity type, and entity location. Entity content refers to the specific text segment of the entity within the text; entity type refers to the agricultural entity category to which the entity belongs; and entity location refers to the entity's position information in the original text, used to locate and extract the corresponding vector representation from the list-style semantic encoding results in subsequent steps. Regarding the representation of entity location, in one embodiment, entity location can be represented as the start and end character indices of the entity in the original text, or as the token start and end positions of the entity in the input sequence, as long as the encoded segment corresponding to the entity can be uniquely determined from the encoder output based on this location information. Similarly, for document entities identified from each candidate evidence document, this embodiment constructs document entity information corresponding to each candidate evidence document, and each document entity also includes at least three attributes: entity content, entity type, and entity location.
[0035] The entity location attributes in the question entity information and document entity information are the foundation for extracting entity representations from the list-based semantic encoding results. In list-based semantic encoding, each token in the input sequence corresponds to an encoded hidden state vector. The entity location records the token span of the entity in the original input text. Based on this, one or more token positions corresponding to the entity can be located from the encoder output, and thus the encoded representation corresponding to the entity can be extracted. Specifically, the entity location is mapped to the token sequence of the list-based semantic encoding result to locate the token interval covered by the entity. Then, the hidden state vector corresponding to that token interval is extracted from the hidden state sequence output by the encoder, thus obtaining the vector representation of the entity in the list-based semantic encoding context. Without entity location information, it is impossible to establish a correspondence between discrete entity recognition results and a continuous vector representation space, making subsequent entity representation construction and entity adaptation information determination impossible.
[0036] Furthermore, the discrete entity recognition results are transformed into computable vector representations to construct the problem entity representation and the document entity representation corresponding to each candidate evidence document.
[0037] Specifically, based on the aforementioned entity recognition results, the set of problem entities corresponding to agricultural disease consultation issues can be obtained. ,in The number of question entities; and the set of document entities corresponding to each candidate evidence document. ,in Candidate evidence documents The number of document entities in the dataset. Each entity consists of three attributes: entity content, entity type, and entity location. Entity location serves as the bridge connecting the discrete entity recognition result and the continuous vector representation space. Since the input sequence containing agricultural disease consultation questions and all candidate evidence documents has been encoded during the list-based semantic encoding process, each token position in the encoder output corresponds to a hidden state vector that incorporates contextual information. Therefore, the vector representation corresponding to the entity can be extracted from the list-based semantic encoding result based on the entity's location information.
[0038] For each issue entity in the aforementioned agricultural disease consultation issue Based on the entity position of the question entity, the corresponding encoding segment is located in the list-based semantic encoding result. The hidden state vectors corresponding to each token within this encoding segment are extracted from the hidden state sequence output by the encoder. In one implementation, the entity position can be represented as the start and end token positions corresponding to the entity in the input sequence. Based on this, all token hidden state vectors between the start and end tokens can be extracted from the hidden state sequence output by the encoder. For any question entity, its position is mapped to the token span of the encoder, and the token hidden state vectors within this span are average-pooled. Then, the trainable entity type embedding corresponding to the entity type of the question entity is superimposed to obtain the question entity representation of the question entity. Through the above method, each question entity... All of them are transformed into a problem entity representation vector that integrates list-style semantic encoding context information and entity type information.
[0039] Similarly, for any candidate evidence document Each document entity in Based on the entity position of the document entity, the corresponding encoding segment is located in the list-based semantic encoding result. The hidden state vectors corresponding to each token within this encoding segment are extracted from the hidden state sequence output by the encoder. After mapping the document entity's position to the encoder's token span, the hidden state vectors of the tokens within this span are average-pooled, and then superimposed with the trainable entity type embeddings corresponding to the document entity's entity type to obtain the document entity representation. Through this method, each document entity... All of them are transformed into a document entity representation vector that integrates list-style semantic encoding context information and entity type information.
[0040] The problem entity representations of various problem entities in the same agricultural disease consultation problem are stacked according to the order in which the entities appear in the problem or any fixed order, to obtain a problem entity representation matrix. The same candidate evidence document The document entity representations of each document entity in the document are stacked according to the order in which the entities appear in the document or any fixed order, to obtain the document entity representation matrix corresponding to the candidate evidence document. The problem entity representation matrix and the document entity representation matrix corresponding to each candidate evidence document are represented as follows: , , in, Let the problem entity be represented by a matrix. Candidate evidence documents The corresponding document entity representation matrix, This refers to the number of problem entities in the aforementioned agricultural disease consultation issue. Candidate evidence documents The number of document entities in the document. The entity representation dimension is consistent with the vector dimension of the list-style semantic encoding result.
[0041] In practice, the number of problem entities in different agricultural disease consultation issues The number of document entities in different candidate evidence documents may differ. It may also differ. In one implementation, the maximum number of question entities and the maximum number of document entities can be set, and entity representations that are less than the maximum number can be padded with zeros, or entity representations that exceed the maximum number can be truncated, to maintain the regularity of the matrix dimensions and facilitate subsequent batch calculations. If no valid entities are identified in the agricultural disease consultation question or candidate evidence document, the corresponding entity representation matrix can be set to a zero matrix, and subsequent entity interaction vectors can be set to zero accordingly.
[0042] By using the above method, the context-related vector representations of each entity are extracted from the list-based semantic encoding results using entity location information. Furthermore, the type information of the entity is introduced into the vector representation by superimposing trainable entity type embeddings. This results in question entity representations and document entity representations that contain both the semantic information of the entity in the list-based semantic encoding context and the agricultural type information of the entity, providing a high-quality foundation for vectorized entity representation.
[0043] Furthermore, at the entity level, a fine-grained matching relationship is established between the agricultural disease consultation question and each candidate evidence document to determine the entity adaptation information between the agricultural disease consultation question and each candidate evidence document.
[0044] To obtain fine-grained matching relationships between question entities and document entities, this embodiment performs entity alignment processing on the question entity representation and the document entity representation. Specifically, the question entity representation is used as the query-side representation, and the document entity representation of the candidate evidence document is used as the matching-side representation. A similarity matrix is calculated between the question entities and document entities, and then normalized along the document entity dimension of the candidate evidence document to obtain a basic entity attention matrix. This basic entity attention matrix is used to characterize the matching relationships, missing relationships, or potential inconsistencies between question entities in agricultural disease consultation issues and document entities in candidate evidence documents. Agricultural entity attention alignment only calculates attention between key agricultural entities to highlight local conditions that determine the applicability of evidence.
[0045] In a preferred embodiment, for the candidate evidence documents corresponding to the agricultural disease consultation question. According to the problem entity representation matrix The document entity representation matrix corresponding to the candidate evidence document Perform query projection, key projection, and value projection respectively: , , , in, For the entity query representation of the problem, For document entity matching representation, For document entity content representation, , , This is a trainable projection weight matrix. The projection operation described above maps the question entity representation and the document entity representation to the query space, key space, and value space, respectively, enabling the model to compute the matching relationship between question entities and document entities in a unified vector space.
[0046] Furthermore, the agricultural disease consultation question and candidate evidence documents are calculated. The entity similarity matrix between them. In one implementation, the entity similarity matrix is represented by the question entity query. Matching the document entity indicates The result, obtained by performing a dot product calculation and scaling, is represented as: , in, For the agricultural disease consultation questions and candidate evidence documents Entity similarity matrix between them For the number of problem entities, Candidate evidence documents The number of document entities in the document. Dimensions for representing entities The scaling factor is used for the entity similarity matrix. Each element in the array represents the degree of similarity between a question entity and a document entity.
[0047] Furthermore, regarding the entity similarity matrix Normalization is performed to obtain candidate evidence documents. The corresponding basic entity attention matrix. Normalization is performed along the document entity dimension of the candidate evidence documents, i.e., the entity similarity matrix is normalized. Each row (corresponding to a question entity) is normalized across all document entities so that the sum of the attention weights of all document entities in that row is 1, as shown below: , in, Candidate evidence documents The corresponding basic entity attention matrix, This is the normalization function. Basic entity attention matrix. Each element in the table represents a normalized matching weight between a question entity and a document entity, reflecting the relative matching strength of the document entity on the corresponding question entity. By normalizing along the document entity dimension, the sum of the attention weights of all document entities is made equal to 1 for each question entity, thus allowing for comparison of the matching degree between each document entity and the same question entity within the candidate evidence documents.
[0048] The basic entity attention matrix Documents identified as candidate evidence The corresponding entity adaptation information. The basic entity attention matrix. It characterizes the matching relationship between the problem entity and the candidate document entity, enabling subsequent processing to quantify the degree of fit between the problem and the document at the entity level.
[0049] By employing the above method, a fine-grained attention alignment relationship is established between question entities and document entities, enabling the model to capture matches, omissions, or inconsistencies between each agricultural entity in the question and each agricultural entity in the document. This entity adaptation information provides an entity-level alignment basis for subsequent weighted processing and fusion scoring, helping to highlight local agricultural condition information that determines the applicability of evidence in re-ranking decisions. If no valid entities are identified in the agricultural disease consultation question or candidate evidence document, i.e., the number of question entities... or number of document entities If the value is zero, the basic entity attention matrix cannot be calculated normally. In this case, the entity interaction vector can be set to zero so that subsequent scoring mainly relies on semantically relevant information.
[0050] Furthermore, a candidate set entity reweighting mechanism is introduced to dynamically adjust the contribution of each question entity to entity adaptation information based on the distribution of different question entities in the current candidate evidence document set.
[0051] In agricultural disease question-and-answer scenarios, different question entities within the same set of candidate evidence documents often have different distinguishing effects. For example, common crop names such as "strawberry" and "watermelon" may appear frequently in multiple candidate evidence documents, resulting in relatively low distinguishability. Specific disease names such as "root rot" and "wilt," specific pesticide names such as "mancozeb" and "potassium permanganate," specific time periods such as "seedling stage" and "spring / summer," or specific parts such as "leaf tip" and "stem base" may only appear in a few candidate evidence documents, better reflecting the production condition constraints and evidence fit requirements of the user's question. If all question entities are treated equally, high-frequency but low-discrimination entities may overshadow the contributions of low-frequency but high-discrimination entities, causing the ranking results to deviate from the production condition fit target. Therefore, this embodiment estimates the distinguishing contribution of each question entity based on its document frequency in the current set of candidate evidence documents, giving question entities that appear less frequently in the candidate evidence document set a higher entity fit contribution, thereby highlighting more discriminative key entities.
[0052] Regarding the first in the problem entity information Problem entities The document frequency of an entity within the candidate evidence document set is defined as the number of candidate evidence documents containing that entity, rather than the total number of times that entity appears in all candidate evidence documents. The advantage of using document frequency instead of total occurrences is that it avoids weight bias caused by repeated entities in long documents.
[0053] Specifically, for the problem entity Iterate through each candidate evidence document in the candidate evidence document set. Determine the document entity information of the candidate evidence document. Does it exist in the middle? If a matching document entity exists, it is counted once. The final count result is the document frequency of that question entity in the candidate evidence document set. The document frequency is expressed as: , in, For the problem entity Document frequency in the candidate evidence document set The number of candidate evidence documents in the candidate evidence document set. This is an indicator function that takes the value 1 when the condition within the parentheses is true, and 0 otherwise. Candidate evidence documents Corresponding document entity information, Candidate evidence documents The first in Each document entity, This is an entity text matching function used to determine whether two entities match.
[0054] In a preferred embodiment, the entity text matching function may employ text inclusion matching, that is, determining whether the entity content of one entity contains the entity content of another entity or whether the two are completely identical. In one embodiment, the entity text matching function does not impose entity type constraints, that is, entities of different types but with the same text (such as "strawberry" could be either a crop type or a variety type) are still considered a match, in order to avoid omissions in document frequency statistics due to entity type recognition errors.
[0055] After obtaining the document frequency of each problem entity, the candidate set inverse document frequency corresponding to each problem entity is further determined based on the document frequency. The candidate set inverse document frequency is based on the number of candidate evidence documents in the candidate evidence document set. and the document frequency of each issue entity. The calculation is expressed as: , in, For the problem entity The corresponding candidate set inverse document frequency. The range of the candidate set inverse document frequency varies with the document frequency: the lower the document frequency of a problem entity in the candidate evidence document set, the higher its candidate set inverse document frequency; conversely, the higher the document frequency of a problem entity in the candidate evidence document set, the lower its candidate set inverse document frequency. This design allows the candidate set inverse document frequency to reflect the scarcity and discriminative power of the problem entity in the current candidate set.
[0056] Furthermore, the inverse document frequencies of candidate sets for each issue entity in the same agricultural disease consultation problem are normalized to avoid abnormal weights from excessively affecting the ranking results.
[0057] Specifically, after calculating the candidate set inverse document frequencies (CVFs) of each question entity in the same agricultural disease consultation problem, the CVF of each question entity is divided by the maximum value of the CVFs of all question entities in that problem, and a smoothing term is added to ensure that the normalized CVF distribution is within a controllable range. The normalized CVF is expressed as: , in, For the normalized problem entity The corresponding candidate set inverse document frequency, This represents the maximum inverse document frequency of the candidate set of all question entities in the same agricultural disease consultation question. This is a smoothing term used to prevent the denominator from being zero and to control the range of normalized values. Through the above normalization process, the inverse document frequencies of the candidate sets for each problem entity are scaled to... Within the interval, this avoids situations where an entity's candidate set inverse document frequency is abnormally high, causing that entity to excessively dominate the ranking decision in subsequent weighting.
[0058] After determining the normalized candidate set inverse document frequency (IDF) for each question entity, the question entity weight is determined based on the IDF of each question entity. The question entity weight is calculated based on the IDF of the normalized candidate set, giving higher weights to question entities that appear less frequently in the candidate evidence document set, and relatively lower weights to question entities that appear more frequently. The question entity weight is expressed as: , in, For the problem entity The corresponding problem entity weights, The first in the problem entity information One problem entity, For the problem entity The corresponding normalized candidate set inverse document frequency, This is the inverse document frequency weighting strength coefficient, used to control the contribution of the candidate set's inverse document frequency to the weight of the problem entity. When When the value is 0, the weight of all problem entities is 1, meaning no reweighting of candidate entities is performed; when... When the value is positive, the question entity with a higher inverse document frequency in the normalized candidate set receives a higher weight. In this way, the fewer times an entity appears in the candidate set, the higher its weight; normalization and... This can help prevent abnormal weights from excessively affecting the ranking.
[0059] The above method calculates the inverse document frequency of the candidate set based on the document frequency of the question entity in the current candidate evidence document set. After normalization, the weight of the question entity is further determined, so that question entities that appear less frequently in the candidate evidence document set have a higher entity fit contribution. This candidate set entity reweighting mechanism is dynamically calculated for each agricultural disease consultation question and its corresponding candidate evidence document set, and can adapt to changes in entity distribution in different questions.
[0060] Furthermore, the weights of the problem entities are applied to the entity adaptation contributions corresponding to each problem entity in the entity adaptation information, so as to dynamically adjust the contribution of each problem entity to the entity adaptation information according to the distinguishing role of the problem entity in the current candidate evidence document set, thereby obtaining the weighted entity adaptation information corresponding to each candidate evidence document.
[0061] Specifically, for candidate evidence documents In the agricultural entity attention alignment module, the problem entity weight vector is... Attention matrix applied to the basic entity Each row. In the underlying entity attention matrix In the middle, the first OK Indicates the first Problem entities Candidate evidence documents The basic attention distribution of each document entity. The weights of the question entities. Multiply to the corresponding number In the row, the attention distribution corresponding to problem entities with higher weights is enhanced, while the attention distribution corresponding to problem entities with lower weights is suppressed: , in, For the problem entity For candidate documents The basic attention distribution of each document entity in the document, Represents the weighted alignment matrix The Okay. After expanding the weights of all problem entities to a dimension corresponding to the number of document entities, apply them element-wise to the base entity attention matrix to obtain the weighted alignment matrix: , in, Candidate evidence documents The corresponding weighted alignment matrix, It is a weight vector composed of the weights of the problem entities corresponding to each problem entity. For dimensions and candidate evidence documents Number of document entities The corresponding all-1 vector, Candidate evidence documents The corresponding basic entity attention matrix, This represents element-wise multiplication. Through the above operations... Dimension is The weight vector is expanded to The weight matrix is a set of identical columns in each row, representing the weight values of the corresponding problem entities. These weights are then multiplied element-wise by the base entity attention matrix. After this weighting process, Strict normalization of each row is no longer required; the sum of the elements in each row equals the weight value of the corresponding problem entity.
[0062] Based on the weighted alignment matrix and the document entity content representation of the candidate evidence documents, a document-side alignment representation is obtained. The document entity content representation... The weighted alignment matrix has already been obtained through value projection during the entity adaptation information determination process. With respect to the content of the document entity Multiplying them together gives the document side alignment representation: , in, The weighted alignment information obtained by the problem entity from the document entity. For document entity content representation, This is the dimension for entity representation. The document-side alignment representation... Each row in the table corresponds to a problem entity, representing the weighted alignment information that the problem entity obtains from the document entities in the candidate evidence documents. Its representation reflects the amount of alignment information that each problem entity can obtain from the document entities after introducing problem entity weights.
[0063] Furthermore, entity interaction features are constructed to comprehensively characterize the matching relationships, missing relationships, and potential inconsistencies between problem entities and document entities. The problem entity representation matrix is then used. The document side alignment representation The difference between the two is expressed as follows and their element-wise product representation By concatenating along the feature dimensions, we obtain the entity interaction features: , in, This indicates concatenation along the feature dimension. This represents element-wise multiplication. The entity interaction features Each row in the document corresponds to a question entity, containing the original representation of the question entity, weighted alignment information obtained from the document entity, the difference information between the two, and the interaction information between them. Through the combination of these four features, It can characterize the matching, missing, or inconsistency relationships between issue entities and document entities from multiple perspectives: when issue entities match document entities, The corresponding line in the document contains rich information, and the difference representation is close to a zero vector; when the question entity is missing in the document... The information in the corresponding row is close to the zero vector, and the difference representation is close to... The value of the corresponding row in the middle; when there is a semantic inconsistency between the question entity and the document entity, the difference representation and the product representation can reflect the degree of this inconsistency.
[0064] Furthermore, the entity interaction features are subjected to average pooling, converting the interaction results of different numbers of question entities into vectors of fixed dimensions to obtain candidate evidence documents. Corresponding entity interaction vector: , in, Entity interaction features The line, corresponding to the first The interaction characteristics of each problem entity. Candidate evidence documents The corresponding entity interaction vector. Average pooling operation will... The interaction features of each problem entity are averaged across the problem entity dimension to obtain a fixed-dimensional vector representation that does not depend on the number of problem entities. The specific values will facilitate subsequent interaction with candidate document vectors. To integrate.
[0065] The aforementioned mechanism dynamically calculates normalized weights for each question based on the inverse document frequency of entities in the candidate set, thereby increasing the influence of low-frequency key entities and adaptively adapting to differences in entity distribution across different questions. In one implementation, when no valid entities are identified in the agricultural disease consultation question, i.e., the number of question entities... When it is zero, the entity interaction vector This can be set to a zero vector, making subsequent scoring primarily dependent on semantically relevant information. Similarly, when no valid entities are identified in the candidate evidence document, i.e., the number of document entities... When it is zero, the basic entity attention matrix Unable to calculate the entity interaction vector correctly. It is also set to zero vector.
[0066] The weighted alignment matrix Document side alignment representation Entity interaction features and entity interaction vectors Together they constitute candidate evidence documents The corresponding weighted entity adaptation information, including entity interaction vectors This serves as the final vectorized representation of the weighted entity adaptation information.
[0067] Furthermore, the semantically relevant information is fused with the weighted entity adaptation information to determine the evidence adaptation score corresponding to each candidate evidence document.
[0068] Based on the semantic information, the question vector corresponding to the agricultural disease consultation question can be determined. and the candidate document vectors corresponding to each candidate evidence document. The problem vector and candidate document vectors It is obtained during the list-based semantic encoding stage, where Consultation on agricultural diseases The corresponding problem vector, Candidate evidence documents The corresponding candidate document vector. The candidate document vector It includes global semantic matching information between agricultural disease consultation questions and candidate evidence documents, as well as relative semantic relationship information between candidate evidence documents and other candidate evidence documents in the same candidate set.
[0069] In a preferred embodiment, the candidate document vector corresponding to each candidate evidence document is fused with the corresponding weighted entity adaptation information to obtain the enhanced candidate document vector corresponding to each candidate evidence document. Specifically, for candidate evidence documents... The candidate document vector Interaction vector with the entity Concatenate the vectors to obtain the concatenated vector. The concatenated vector is then input into a fusion multilayer perceptron, whereby the semantic vector and entity interaction vector are fused at the representation layer and unified into the same sorting space. The fusion multilayer perceptron can be represented as: , in, For the input vector, It is a non-linear activation function. , For a trainable weight matrix, , This is a trainable bias term. The fusion multilayer perceptron learns the fusion relationship between semantic vectors and entity interaction vectors through nonlinear transformations, so that the fused vector retains both the global semantic matching capability of list-based semantic encoding and incorporates local entity conditional matching information.
[0070] The enhanced candidate document vector is represented as follows: , in, Candidate evidence documents The corresponding enhanced candidate document vectors, Candidate evidence documents The corresponding candidate document vectors, Candidate evidence documents The corresponding entity interaction vector, This represents a vector concatenation operation. This represents a fusion of a multilayer perceptron. The enhanced candidate document vector... The dimension and the candidate document vector The dimensions are the same to ensure that subsequent operations are consistent with the problem vector. Dimensional consistency when performing similarity calculations.
[0071] When no valid agricultural entity is identified in the agricultural disease consultation question or candidate evidence document, the entity interaction vector... It can be set to a zero vector, in which case the enhanced candidate document vector That is, the enhanced candidate document vector is mainly determined by semantically relevant information, so that the subsequent evidence fitting score mainly reflects the degree of semantic relevance. When a valid agricultural entity is identified, the entity interaction vector... The enhanced candidate document vector includes weighted entity adaptation information. It also integrates global semantic matching information and local entity condition matching information, enabling subsequent evidence matching scores to take into account both semantic relevance and agricultural production condition suitability.
[0072] After obtaining the augmented candidate document vectors corresponding to each candidate evidence document, the evidence fit score for each candidate evidence document is determined based on the question vector and the augmented candidate document vectors. This embodiment uses cosine similarity as the calculation method for the evidence fit score, by calculating the question vector corresponding to the agricultural disease consultation question. With candidate evidence documents The corresponding enhanced candidate document vector The cosine similarity between the two documents yields the evidence fit score for the candidate evidence document. , in, Candidate evidence documents The corresponding evidence fit score, Let be the question vector corresponding to the agricultural disease consultation question. Candidate evidence documents The corresponding enhanced candidate document vectors, The cosine similarity function is used. Representing vectors Norm. The range of values for cosine similarity is... A higher value indicates that the question vector and the augmentation candidate document vector are more aligned in direction in the vector space, meaning that the candidate evidence document performs better in terms of semantic relevance and agricultural entity condition suitability. The evidence fit score is... It inherits the global semantic matching capability of the list-based semantic reordering model and incorporates matching information of local agricultural entity conditions, so that the sorting results not only reflect the overall semantic relevance between the question and the document, but also reflect the consistency of key agricultural production conditions such as crops, diseases, pesticides, time, and parts.
[0073] Global semantic matching information and local entity condition matching information are fused at the vector representation layer. The evidence fit score of each candidate evidence document is obtained by calculating cosine similarity. The evidence fit score comprehensively reflects two dimensions: semantic relevance and agricultural production condition suitability. This provides a ranking basis that integrates semantic and entity information for subsequent re-ranking.
[0074] Furthermore, after obtaining the evidence fit score corresponding to each candidate evidence document, the candidate evidence documents in the candidate evidence document set are reordered according to the evidence fit score.
[0075] Specifically, the candidate evidence document set is sorted according to the evidence fit scores of each candidate evidence document from high to low. The candidate evidence documents are sorted to obtain a reordered set of candidate evidence documents. In the reordered set, candidate evidence documents with higher evidence fit scores are ranked higher, and those with lower scores are ranked lower. This reordering operation changes the original order of candidate evidence documents in the candidate set, giving higher rankings to candidate evidence documents that are semantically relevant to the agricultural disease consultation problem and fit the production conditions, thereby increasing the probability that standard evidence documents are ranked higher in the candidate list.
[0076] Example 2: To verify the effectiveness of the entity-aware document reordering method for agricultural disease question answering described in Example 1, this example constructs an agricultural disease knowledge base and an agricultural disease RAG question answering dataset, and conducts retrieval reordering experiments and downstream RAG question answering experiments based on this dataset.
[0077] This embodiment constructs an agricultural disease knowledge base and an agricultural disease RAG question-and-answer dataset. The agricultural disease knowledge base is sourced from agricultural science and technology information websites, agricultural and rural information websites, national agricultural technology extension websites, books on pest and disease control, and agricultural papers. The original documents were denoised, deduplicated, formatted, and segmented before being stored in the database, ultimately forming 86,398 document fragments. These document fragments may include fragments on disease symptoms, target pests, control periods, pesticides, and control measures.
[0078] The agricultural disease RAG question-answering dataset was constructed using a combination of large language model generation and manual verification. Each sample contains a user question, a standard answer, a standard evidence document, and a set of candidate documents. The dataset contains a total of 11,584 samples, divided into training, validation, and test sets in an 8:1:1 ratio, with 9,268, 1,158, and 1,158 samples respectively. An example of the dataset is shown in Table 1.
[0079] Table 1:
[0080] The entity recognition step described in Example 1 can be implemented using an agricultural entity recognition model. In this example, the agricultural entity recognition model is built based on the chinese-roberta-wwm-ext encoder. The input text is converted into BIO sequence labeling format and then connected to a token classification layer to predict entity labels. During the training phase, the HuggingFace Trainer is used, with a maximum input length of 256, 8 training epochs, a learning rate of 2e-5, and the optimal model is selected using entity-level F1.
[0081] In this embodiment, agricultural semantic related entity annotation data from the AgCNER agricultural pest and disease named entity recognition dataset is used to fine-tune the agricultural entity recognition model. During fine-tuning, entity categories that are weakly related to the agricultural disease evidence adaptation judgment are removed, and a total of 10 categories of agricultural semantic related entities are retained, including pests, diseases, crops, pesticides, varieties, fertilizers, pathogens, periods, parts, and biological mediators.
[0082] The fine-tuning results of the agricultural entity recognition model are shown in Table 2. The Token metric, after removing class O (non-entity tokens), calculates the token-level BIO prediction results. The Entity metric requires both entity boundaries and types to match. The model's entity-level F1 score reaches 0.9168, indicating that it can provide relatively reliable entity input for subsequent re-ranking.
[0083] Table 2:
[0084] Table 3 shows examples of entity extraction in the agricultural entity recognition model.
[0085] Table 3:
[0086] Candidate documents were jointly recalled using BM25 and BAAI / bge-small-zh-v1.5, with the scores from both sources fused at a 1:1 ratio. After deduplication, the Top-20 documents were retained. In the method described in Example 1, the main parameters of the list-based semantic coding model were frozen, and only the entity type embedding, query projection layer, key projection layer, value projection layer, and fusion multilayer perceptron were trained. The maximum number of question entities was set to 16, the maximum number of document entities was set to 32, the number of training epochs was 5, the AdamW optimizer was used, and the learning rate was 1×10⁻⁶. -4 The inverse document frequency weighted intensity coefficient λ is set to 1.0.
[0087] To verify the technical effect of the method described in Embodiment 1, the following comparison method is set up in this embodiment: (1) Hybrid retrieval: The ranking results after the fusion of BM25 and BAAI / bge-small-zh-v1.5 are used to measure the top hit rate of standard evidence when it is not re-ranked; (2) General neural reranking baseline: including BAAI / bge-reranker-v2-m3, BCE reranker and mxbai-rerank-base-v2, used to test the transfer effect of existing open source semantic rerankers in agricultural disease question answering scenarios; (3) Re-ranking baselines based on large language models: including Qwen3-Reranker-0.6B and Qwen3-Reranker-4B, used to test the effect of re-rankers trained by large language models in agricultural disease question answering scenarios; (4) List-based reranking baselines: including RankGPT (deepseek-v4-pro) and jina-reranker-v3, both of which can compare the relative relationships of multiple documents in the same candidate set. Among them, jina-reranker-v3 is the direct base model of the method described in Example 1.
[0088] All reordering methods were evaluated on the same test set, the same initial candidate set, and the same standard evidence.
[0089] This embodiment uses Recall@K, nDCG@K, and MRR@K to evaluate the retrieval re-ranking effect. K represents the top K documents in the ranking list. The experiment uses a binary relevance setting: standard evidence documents are marked as 1, and other candidate documents are marked as 0. The experimental equipment uses an NVIDIA RTX 4090 GPU and the PyTorch framework.
[0090] The retrieval results of different reordering methods are shown in Table 4.
[0091] Table 4:
[0092] Table 4 shows that the hybrid retrieval can recall most standard evidence under a large K, but its first-ranking ability is insufficient, indicating that the main bottleneck of agricultural disease RAG lies in the ranking of standard evidence. The general re-ranking model and the re-ranker trained based on a large language model outperform the hybrid retrieval overall, but the improvement is limited, indicating that simply relying on general semantic matching is still insufficient to fully handle fine-grained differences in conditions such as crop, disease, pesticide, and time. jina-reranker-v3 performs well in the ranking metrics, indicating that list-based semantic representation is suitable for comparing agricultural candidate evidence with similar themes but different applicable conditions. The method described in Example 1 further introduces entity constraints and achieves optimal results in various metrics, demonstrating that explicit agricultural entity modeling can improve the pre-recording of standard evidence and provide a more production-appropriate basis for downstream generation. Compared to jina-reranker-v3, the method described in Example 1 improves Recall@1, Recall@3, and MRR@10 by 2.94, 1.99, and 2.02 percentage points, respectively.
[0093] To verify the effectiveness of each entity enhancement module in the method described in Embodiment 1, this embodiment sets two ablation settings: removing candidate set entity reweighting (i.e., setting the weight of all problem entities to 1), and removing agricultural entity attention alignment (i.e., skipping the determination of entity adaptation information and the calculation of weighted entity adaptation information, and directly using semantically relevant information for scoring). The ablation experiment results are shown in Table 5.
[0094] Table 5:
[0095] Table 5 shows that the complete method outperforms the two ablation versions, indicating that both agricultural entity attention alignment and candidate set entity reweighting are effective. After removing candidate set entity reweighting, the model can still utilize entity matching information, but it struggles to distinguish between high-frequency entities and more discriminative key entities in the candidate set; the decline is more pronounced after removing agricultural entity attention alignment, indicating that fine-grained interactions between problem entities and document entities are the main source of gain. The two modules, corresponding to entity matching modeling and entity importance estimation respectively, can jointly support consistent judgments of agricultural conditions such as crops, diseases, pesticides, and timing.
[0096] To verify the impact of reordering on question-answering effectiveness, this embodiment integrates different reordering methods into the same RAG question-answering system. Downstream question-answering experiments use a fixed generation model and prompt word template, replacing only the reordering module and inputting Top-K documents (K values are 1, 2, 3, 4, 5, and 10). The evaluation metric is RAG-F1@K, which calculates the correctness, evidence support, and conditional consistency of answers at the suggestion unit level. Precision, recall, and F1 score are calculated by accumulating true positives, false positives, and false negatives, more closely reflecting the actual requirements of agricultural disease counseling for the reliability, traceability, and executability of suggestions.
[0097] Comparison of RAG-F1 with different retrieval and re-ranking methods at K=3 Figure 2 As shown, the RAG-F1@3 of direct answers (without accessing retrieval evidence) is lower than all retrieval enhancement methods, indicating that agricultural disease question answering relies on external evidence. The question answering performance of different reordering methods is basically consistent with the quality of their evidence ranking. The method described in Example 1 achieves the highest RAG-F1@3, reaching 0.9274, indicating that entity constraint ranking optimization can be transferred to the generation stage.
[0098] RAG-F1@K variation with different numbers of input documents is as follows Figure 3 As shown, RAG-F1@K does not monotonically increase with the number of input documents: increasing the number of documents increases the probability of standard evidence entering the context, but it also introduces weakly relevant or conditionally mismatched evidence. The method described in Example 1 maintains superior performance under different K values, indicating that condition-fit-oriented evidence ranking is more beneficial for generating reliable agricultural recommendations than simply increasing the number of context documents.
[0099] To analyze the actual impact of the method described in Example 1 on downstream question answering, this example selects typical cases to compare the Top-3 evidence documents and generated answers before and after rearrangement. As shown in Table 6, the two cases respectively demonstrate two typical correction scenarios: the similarity of disease entities leading to the shift in control targets, and the user-specified pesticide not being matched.
[0100] Table 6:
[0101] Table 6 shows that although the Top-3 documents before rearrangement were similar to the question topic, the key entity conditions were not sufficiently consistent: in the case of greenhouse strawberries, the system prioritized returning evidence of similar diseases such as bud blight and Verticillium wilt, leading to a deviation in the target of control; in the case of watermelon wilt, the results matched the disease topic but did not match the potassium permanganate agent explicitly specified by the user. The method described in Example 1 can prioritize evidence with more consistent conditions, such as strawberry root rot and potassium permanganate control, so that the generated answer revolves around the correct disease target, agent concentration, treatment method, and expected effect. The above cases show that errors in agricultural disease question answering are often caused by interfering evidence that is topic-related but mismatched. The method described in Example 1, through entity-aware reordering, helps to reduce deviation in the target of control, insufficient agent applicability, and generalization of measures, thereby improving the accuracy, pertinence, and feasibility of agricultural technical recommendations.
[0102] The experimental results above show that the entity-aware document re-ranking method for agricultural disease question answering described in Example 1 achieves optimal results in retrieval re-ranking metrics such as Recall@1, Recall@3, Recall@10, nDCG@10, and MRR@10. Compared to jina-reranker-v3, Recall@1, Recall@3, and MRR@10 are improved by 2.94, 1.99, and 2.02 percentage points, respectively; the downstream RAG-F1@3 reaches 0.9274. Ablation experiments and case studies show that agricultural entity attention alignment and candidate set entity re-weighting can effectively reduce the deviation of control targets, pesticide applicability bias, and measure generalization, indicating that entity constraint modeling in the ranking stage can be transformed into more reliable, more field-appropriate, and actionable agricultural recommendations, verifying the effectiveness of the method described in Example 1 in agricultural disease question answering scenarios.
[0103] Example 3: Based on the same inventive concept as Embodiment 1, the present invention also provides an entity-aware document reordering system for agricultural disease question answering, comprising: The information acquisition and semantic encoding module is used to acquire agricultural disease consultation questions and a set of candidate evidence documents corresponding to the agricultural disease consultation questions; and to determine the semantic information related between the agricultural disease consultation questions and each candidate evidence document in the set of candidate evidence documents. The entity recognition module is used to perform entity recognition on the agricultural disease consultation question and each candidate evidence document based on a preset set of agricultural entity types, so as to obtain the question entity information corresponding to the agricultural disease consultation question and the document entity information corresponding to each candidate evidence document. The entity matching determination module is used to determine the entity matching information between the agricultural disease consultation question and each candidate evidence document based on the question entity information and the document entity information. The entity weight determination module is used to determine the distribution of the problem entity information in the candidate evidence document set based on the problem entity information and the document entity information, and to determine the problem entity weight corresponding to the problem entity information based on the distribution. The weighted adaptation and evidence score determination module is used to determine the weighted entity adaptation information corresponding to each candidate evidence document based on the entity adaptation information and the weight of the problem entity; and to determine the evidence adaptation score corresponding to each candidate evidence document based on the semantic related information and the weighted entity adaptation information. The document reordering module is used to reorder each candidate evidence document in the candidate evidence document set according to the evidence fit score.
[0104] Each module of the entity-aware document reordering system for agricultural disease question answering proposed in this embodiment is used to implement the corresponding steps of the entity-aware document reordering method for agricultural disease question answering in Embodiment 1. To avoid redundancy, these steps will not be repeated here.
[0105] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0106] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0107] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1The function specified in one or more boxes.
[0108] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0109] Obviously, the above embodiments are merely illustrative examples for clear explanation and are not intended to limit the implementation. Those skilled in the art will recognize that other variations or modifications can be made based on the above description. It is neither necessary nor possible to exhaustively list all possible implementations here. However, obvious variations or modifications derived therefrom are still within the scope of protection of this invention.
Claims
1. A method for entity-aware document reordering for agricultural disease question answering, characterized in that, include: Obtain agricultural disease consultation questions and a set of candidate evidence documents corresponding to the agricultural disease consultation questions; Determine the semantic information related to the agricultural disease consultation question and the candidate evidence documents in the candidate evidence document set; Based on a preset set of agricultural entity types, entity recognition is performed on the agricultural disease consultation questions and each candidate evidence document to obtain the question entity information corresponding to the agricultural disease consultation questions and the document entity information corresponding to each candidate evidence document. Based on the question entity information and the document entity information, determine the entity matching information between the agricultural disease consultation question and each candidate evidence document; Based on the problem entity information and the document entity information, determine the distribution of the problem entity information in the candidate evidence document set, and determine the problem entity weight corresponding to the problem entity information based on the distribution. Based on the entity adaptation information and the issue entity weight, determine the weighted entity adaptation information corresponding to each candidate evidence document; based on the semantic related information and the weighted entity adaptation information, determine the evidence adaptation score corresponding to each candidate evidence document. Based on the evidence fit score, the candidate evidence documents in the candidate evidence document set are reordered.
2. The entity-aware document reordering method for agricultural disease question answering according to claim 1, characterized in that: Based on the question entity information and the document entity information, the distribution of the question entity information in the candidate evidence document set is determined, and the method for determining the question entity weight corresponding to the question entity information based on the distribution is as follows: Based on the problem entity information and the document entity information, the document frequency of each problem entity in the problem entity information in the candidate evidence document set is calculated. Based on the document frequencies, determine the candidate set inverse document frequencies corresponding to each question entity; The weight of each question entity is determined based on the inverse document frequency of the candidate set corresponding to each question entity. The weight of the problem entity is represented as follows: , in, For the problem entity The corresponding problem entity weights, The first in the problem entity information One problem entity, For the problem entity The corresponding candidate set inverse document frequency, This is the inverse document frequency weighted intensity coefficient.
3. The entity-aware document reordering method for agricultural disease question answering according to claim 2, characterized in that: The method for determining the inverse document frequency of the candidate set corresponding to each question entity based on the document frequency is as follows: For each problem entity in the problem entity information, the number of candidate evidence documents containing that problem entity is counted to obtain the document frequency of that problem entity in the candidate evidence document set; Based on the number of candidate evidence documents in the candidate evidence document set and the document frequency, determine the candidate set inverse document frequency corresponding to the problem entity; The inverse document frequency of the candidate set is represented as: , in, The number of candidate evidence documents in the candidate evidence document set. For the problem entity Document frequency in the candidate evidence document set.
4. The entity-aware document reordering method for agricultural disease question answering according to claim 1, characterized in that: The method for determining the weighted entity adaptation information corresponding to each candidate evidence document based on the entity adaptation information and the issue entity weight is as follows: Based on the weight of the problem entity, the entity adaptation contribution corresponding to each problem entity in the entity adaptation information is weighted to obtain the weighted entity adaptation information corresponding to each candidate evidence document. The weighted entity adaptation information includes a weighted alignment matrix, which is represented as follows: , in, Candidate evidence documents The corresponding weighted alignment matrix, The first in the candidate evidence document set One candidate evidence document, The weight vector is composed of the weights of the problem entities. For dimensions and candidate evidence documents The vector of all 1s corresponding to the number of document entities in the document. Candidate evidence documents The corresponding basic entity attention matrix, This indicates element-wise multiplication.
5. The entity-aware document reordering method for agricultural disease question answering according to claim 1, characterized in that: The method for determining the evidence fit score corresponding to each candidate evidence document based on the semantic information and the weighted entity fit information is as follows: Based on the semantic information, determine the question vector corresponding to the agricultural disease consultation question and the candidate document vector corresponding to each candidate evidence document; The candidate document vector corresponding to each candidate evidence document is fused with the corresponding weighted entity adaptation information to obtain the enhanced candidate document vector corresponding to each candidate evidence document. Based on the question vector and the vectors of each augmentation candidate document, the evidence fit score corresponding to each candidate evidence document is determined, as follows: , in, Candidate evidence documents The corresponding evidence fit score, Let be the question vector corresponding to the agricultural disease consultation question. Candidate evidence documents The corresponding enhanced candidate document vectors, This is the cosine similarity function.
6. The entity-aware document reordering method for agricultural disease question answering according to claim 1, characterized in that: The method for determining the entity matching information between the agricultural disease consultation question and each candidate evidence document based on the question entity information and the document entity information is as follows: Based on the entity position of each issue entity in the issue entity information, extract the issue entity representation corresponding to each issue entity from the list-based semantic encoding result; Based on the entity position of each document entity in the document entity information, extract the document entity representation corresponding to each document entity from the list-style semantic encoding result; Construct a problem entity representation matrix based on the problem entity representation corresponding to each problem entity, and construct a document entity representation matrix corresponding to each candidate evidence document based on the document entity representation corresponding to each document entity. Based on the problem entity representation matrix and the document entity representation matrix corresponding to each candidate evidence document, the entity adaptation information between the agricultural disease consultation problem and each candidate evidence document is determined. The question entity representation matrix and the document entity representation matrix are represented as follows: , , in, Let the problem entity be represented by a matrix. Candidate evidence documents The corresponding document entity representation matrix, For the number of problem entities, Candidate evidence documents The number of document entities in the document. Dimensions for representing entities.
7. The entity-aware document reordering method for agricultural disease question answering according to claim 6, characterized in that: The method for determining the entity matching information between the agricultural disease consultation question and each candidate evidence document, based on the question entity representation matrix and the document entity representation matrix corresponding to each candidate evidence document, is as follows: Based on the entity representation information of the question and the document entity representation information corresponding to each candidate evidence document, calculate the entity similarity matrix between the agricultural disease consultation question and each candidate evidence document; The entity similarity matrix is normalized to obtain the basic entity attention matrix corresponding to each candidate evidence document; The basic entity attention matrix is determined as the entity adaptation information; The basic entity attention matrix is represented as follows: , in, Candidate evidence documents The corresponding basic entity attention matrix, For the agricultural disease consultation questions and candidate evidence documents Entity similarity matrix between them This is the normalization function.
8. The entity-aware document reordering method for agricultural disease question answering according to claim 1, characterized in that: The method for determining the semantic information related to the agricultural disease consultation question and the candidate evidence documents in the candidate evidence document set is as follows: List-based semantic encoding is performed on the agricultural disease consultation question and the candidate evidence document set to obtain the question vector corresponding to the agricultural disease consultation question and the candidate document vector corresponding to each candidate evidence document. The question vector and each candidate document vector are represented as follows: , in, For the aforementioned agricultural disease consultation issues. The set of candidate evidence documents, Let the problem vector be... Candidate evidence documents The candidate document vectors, wherein the semantically related information includes the question vector and each candidate document vector.
9. The entity-aware document reordering method for agricultural disease question answering according to claim 1, characterized in that: Based on a preset set of agricultural entity types, the method for performing entity recognition on the agricultural disease consultation questions and candidate evidence documents to obtain the question entity information corresponding to the agricultural disease consultation questions and the document entity information corresponding to each candidate evidence document is as follows: Based on the preset agricultural entity type set, entity recognition is performed on the agricultural disease consultation questions to obtain the question entities related to agricultural production conditions in the agricultural disease consultation questions. Based on the preset agricultural entity type set, entity recognition is performed on each candidate evidence document to obtain document entities related to agricultural production conditions in each candidate evidence document. Based on the entity content, entity type, and entity location of the problem entity, construct the problem entity information; Based on the entity content, entity type, and entity location of the document entity, construct the document entity information corresponding to each candidate evidence document.
10. An entity-aware document reordering system for agricultural disease question answering, characterized in that, include: The information acquisition and semantic encoding module is used to acquire agricultural disease consultation questions and a set of candidate evidence documents corresponding to the agricultural disease consultation questions; Determine the semantic information related to the agricultural disease consultation question and the candidate evidence documents in the candidate evidence document set; The entity recognition module is used to perform entity recognition on the agricultural disease consultation question and each candidate evidence document based on a preset set of agricultural entity types, so as to obtain the question entity information corresponding to the agricultural disease consultation question and the document entity information corresponding to each candidate evidence document. The entity matching determination module is used to determine the entity matching information between the agricultural disease consultation question and each candidate evidence document based on the question entity information and the document entity information. The entity weight determination module is used to determine the distribution of the problem entity information in the candidate evidence document set based on the problem entity information and the document entity information, and to determine the problem entity weight corresponding to the problem entity information based on the distribution. The weighted adaptation and evidence score determination module is used to determine the weighted entity adaptation information corresponding to each candidate evidence document based on the entity adaptation information and the weight of the problem entity; and to determine the evidence adaptation score corresponding to each candidate evidence document based on the semantic related information and the weighted entity adaptation information. The document reordering module is used to reorder each candidate evidence document in the candidate evidence document set according to the evidence fit score.
