Intelligent question answering method and system in agricultural field based on retrieval enhancement generation
By constructing a fusion index library to process semantic similarity and keyword matching in parallel, combining it with a large language model to generate answers, and setting up security checks, the problem of lack of professional knowledge and inaccurate answers in agricultural question-answering systems has been solved, achieving highly accurate and secure intelligent agricultural question answering.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-09
- Publication Date
- 2026-03-10
AI Technical Summary
Existing intelligent question-answering systems lack professional knowledge in the agricultural field, have low accuracy in their answers, and are prone to producing illusions (fabricated answers). They have failed to effectively expand keywords, dynamically adjust weights, or prioritize key information for agricultural terminology.
A fusion index library is constructed, including vector indexes and full-text indexes. Semantic similarity retrieval and keyword matching are processed in parallel, and answers are generated by combining a large language model. A security verification mechanism is set up to ensure the accuracy and security of the answers.
It improves the accuracy and security of Q&A in the agricultural field, can deeply understand technical terms, reduce illusion generation, and enhance the system's reliability and user trust.
Smart Images

Figure CN121636666A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of artificial intelligence, in particular to an agricultural field intelligent question and answer method and system based on retrieval augmented generation. BACKGROUND
[0002] In recent years, retrieval augmented generation (RAG) technology centered on large language models has important application value in agricultural intelligent question and answer, pest and disease diagnosis, pesticide application guidance, and other scenarios. To constrain the generation of LLM and reduce the "hallucination" risk, existing inventions have proposed solutions based on vector retrieval, knowledge graph, or RAG architecture.
[0003] Existing technologies such as the agricultural question and answer system based on knowledge graph construction disclosed in patent document CN119226454A do not provide specific implementations for the fine integration and sorting of keyword retrieval and semantic retrieval, the de-duplication strategy, and the output safety threshold control. The general RAG solution (for example, CN118394890A) implements the process of understanding and rewriting user queries, retrieving relevant documents, combining the retrieved knowledge with the original query, and forming a prompt text input to the generation model, but does not propose key word expansion, weight dynamic adjustment, or key information priority guarantee strategies for high-frequency agricultural terminology, key information (such as dosage, dilution ratio, application time point) sensitive vertical scenarios.
[0004] In addition, some agricultural question and answer related patents (for example, CN114860917A) propose a dual-model architecture based on question and answer knowledge base and knowledge graph, aiming to improve question and answer efficiency, but their retrieval and sorting strategies are not optimized, and they cannot ensure that documents containing key terms (such as pest and disease names) are prioritized for retrieval and sorting, and also lack de-duplication processing of redundant results. SUMMARY
[0005] To solve the problem of existing general intelligent question and answer systems lacking professional knowledge in the agricultural field, low accuracy of answers, and easy hallucination (fabricating), the present application provides an agricultural field intelligent question and answer method and device based on fusion retrieval augmented generation (RAG) to achieve fast, accurate, and safe response to agricultural user questions.
[0006] To achieve the above-mentioned purpose, the present application provides the following technical solutions:
[0007] On the one hand, the present application provides an agricultural field intelligent question and answer method based on retrieval augmented generation, which comprises the following steps:
[0008] S100, obtaining unstructured text data in the agricultural field, preprocessing and knowledge extraction on the unstructured text data, and constructing a fusion index library containing vector index and full-text index;
[0009] S200, receiving an agricultural related question input by a user, converting the question into a query vector and a query keyword set in parallel, performing semantic similarity retrieval in the vector index based on the query vector to obtain a first document set, and performing keyword matching retrieval in the full-text index based on the query keyword set to obtain a second document set;
[0010] S300, performing deduplication, normalization and weighted fusion processing on the first document set and the second document set, and generating Top-K final retrieval documents in descending order according to comprehensive scores;
[0011] S400, combining the Top-K final retrieval documents and the user question into prompt words, inputting the prompt words into a large language model to generate an answer, and setting a security verification step, if the highest relevance score of the final retrieval document is lower than a preset threshold, triggering a reply suppression mechanism to output a preset prompt information.
[0012] Optionally, in S100, the unstructured text data in the agricultural field is obtained, the unstructured text data is preprocessed and knowledge is extracted, and a fusion index library containing a vector index and a full-text index is constructed, comprising:
[0013] S110, collecting unstructured text data in the agricultural field from multiple sources;
[0014] S120, cleaning, deduplicating and formatting the collected unstructured text data, and using a natural language processing tool to extract entities and relationships to form structured knowledge;
[0015] S130, converting the structured knowledge into a high-dimensional vector using a field fine-tuned embedding model, constructing a vector index, and performing word segmentation processing on the structured knowledge to construct a full-text index, obtaining a fusion index library containing a vector index and a full-text index.
[0016] Optionally, in S130, the structured knowledge is converted into a high-dimensional vector using a field fine-tuned embedding model, a vector index is constructed, and the structured knowledge is processed by word segmentation to construct a full-text index, obtaining a fusion index library containing a vector index and a full-text index, comprising:
[0017] S131, selecting a pre-trained model bge-base-zh as a basic embedding model, and fine-tuning the pre-trained model using agricultural field professional corpus to obtain a model bge-base-zh-ag;
[0018] S132, converting the structured knowledge into a high-dimensional vector by using the model bge-base-zh-ag, and constructing a vector index based on the high-dimensional vector;
[0019] S133, performing word segmentation on the structured knowledge by using a word segmentation tool to obtain a word segmentation result, and constructing a full-text index based on the word segmentation result;
[0020] S134, storing the vector index and the full-text index in association to obtain a fusion index library containing the vector index and the full-text index.
[0021] Optionally, in S200, the user input agricultural related question is received, the question is converted into a query vector and a query keyword set in parallel, a first document set is obtained by performing semantic similarity retrieval in the vector index based on the query vector, and a second document set is obtained by performing keyword matching retrieval in the full-text index based on the query keyword set, including:
[0022] S210, receiving a user input agricultural related question, converting the question into a query vector by using a domain fine-tuned embedding model; and extracting keywords from the question based on an agricultural domain dictionary, and expanding synonyms and / or hypernyms to form a query keyword set.
[0023] S220, performing semantic similarity retrieval in the vector index based on the query vector, calculating the similarity between the query vector and each vector in the vector index, and grouping the documents corresponding to the vectors with a similarity higher than a preset similarity threshold to form a first document set;
[0024] S230, performing keyword matching retrieval in the full-text index based on the query keyword set, and grouping the documents containing at least one keyword in the query keyword set to form a second document set.
[0025] Optionally, in S210, the question is converted into a query vector by using a domain fine-tuned embedding model, including:
[0026] S211, fine-tuning a pre-trained model bge-base-zh by using an agricultural domain professional corpus to obtain a domain fine-tuned embedding model;
[0027] S212, inputting the user input agricultural related question into the domain fine-tuned embedding model to output a corresponding query vector.
[0028] Optionally, in S300, the first document set and the second document set are de-duplicated, normalized, and weighted and fused, and Top-K final retrieval documents are generated in descending order according to a comprehensive score, including:
[0029] S310, perform deduplication processing on the first document set and the second document set to remove duplicate documents from the two sets, and obtain a deduplicated document set;
[0030] S320, normalize each document in the deduplicated document set, and normalize the semantic similarity score and keyword matching score of each document to the same numerical range.
[0031] S330 uses a weighted fusion algorithm to give a comprehensive score to the normalized documents, and obtains a comprehensive score for each document.
[0032] S340, Based on the comprehensive score, sort the documents in the deduplicated document set in descending order, and select the top K documents as the final search documents.
[0033] Optionally, in step S400, the step of combining the Top-K final retrieved documents with the user's question to form prompt words and inputting them into a large language model to generate an answer, and setting a security verification step, if the highest relevance score of the final retrieved document is lower than a preset threshold, triggers an answer suppression mechanism to output preset prompt information, including:
[0034] S410, The Top-K final search documents and the user question are combined according to a preset prompt word template to obtain prompt words; the prompt words are used to separate the background knowledge context from the user question;
[0035] S420, Input the prompt words into the large language model, and use the large language model to generate the answer;
[0036] S430, Set a security verification step, calculate the highest relevance score of the Top-K final retrieved documents. If the highest relevance score is lower than a preset threshold, trigger the answer suppression mechanism and output a preset prompt message; otherwise, output the answer generated by the large language model.
[0037] On the other hand, embodiments of the present invention provide an intelligent question-answering system for the agricultural field based on retrieval enhancement generation, including:
[0038] At least one processor;
[0039] At least one memory for storing at least one program;
[0040] When the at least one program is executed by the at least one processor, the at least one processor performs the method described above.
[0041] On the other hand, embodiments of the present invention provide a computer-readable storage medium storing a processor-executable program, which, when executed by a processor, is used to perform the above-described method.
[0042] The beneficial effects of this invention are:
[0043] 1. High accuracy: The vectorized model is fine-tuned using agricultural data, resulting in a more accurate handling of agricultural terminology. It integrates semantic retrieval and keyword retrieval, leveraging the strengths of both to significantly improve the recall and accuracy of specialized knowledge retrieval.
[0044] 2. Strong security: Through an innovative fusion scoring and threshold judgment mechanism, it can effectively identify problems that exceed the scope of the knowledge base, actively suppress the generation of illusions in large language models, and greatly improve the reliability of the system and user trust.
[0045] 3. High professionalism: The entire solution, from data preprocessing and knowledge extraction to retrieval and ranking, is optimized for the characteristics of agricultural texts. It has strong domain adaptability and can effectively understand agricultural terminology and complex query intents.
[0046] 4. This invention is not only applicable to agricultural intelligent question-and-answer systems, but also has important reference value for other vertical fields that require high-precision and high-security knowledge question-and-answer systems. Attached Figure Description
[0047] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0048] Figure 1 This is a flowchart illustrating an intelligent question-answering method for the agricultural field based on retrieval enhancement in an embodiment of the present invention;
[0049] Figure 2 This is a flowchart of an intelligent question-answering method and system for the agricultural field based on RAG fusion retrieval, provided by an embodiment of the present invention;
[0050] Figure 3 This is a comparison chart of the effects of the fine-tuned vectorized model provided in the embodiments of the present invention. Detailed Implementation
[0051] The following will provide a clear and complete description of the concept, specific structure, and technical effects of the present invention in conjunction with embodiments and accompanying drawings, so as to fully understand the purpose, solution, and effects of the present invention. It should be noted that, unless otherwise specified, the embodiments and features described in this application can be combined with each other.
[0052] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention. In the following description, when referring to the accompanying drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the embodiments of this invention; they are merely examples of apparatuses and methods consistent with some aspects of the embodiments of this invention as detailed in the appended claims.
[0053] It is understood that the terms “first,” “second,” etc., used in this invention may be used herein to describe various concepts, but unless specifically stated otherwise, these concepts are not limited by these terms. These terms are used only to distinguish one concept from another. For example, first information may also be referred to as second information without departing from the scope of embodiments of the invention, and similarly, second information may also be referred to as first information. Depending on the context, the words “if,” “when,” or “in response to determination” as used herein may be interpreted as “when…” or “when…” or “in response to determination.”
[0054] The terms “at least one,” “multiple,” “each,” “any,” etc., used in this invention, “at least one” includes one, two, or more than two; “multiple” includes two or more than two; “each” refers to each of the corresponding multiple; and “any” refers to any one of the multiple.
[0055] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains. The terminology used herein is for the purpose of describing embodiments of the invention only and is not intended to limit the invention.
[0056] refer to Figure 1 ,like Figure 1 The image shows an intelligent question-answering method for the agricultural field based on retrieval enhancement generation, provided by an embodiment of the present invention. The method includes the following steps:
[0057] S100: Obtain unstructured text data in the agricultural field, preprocess and extract knowledge from the unstructured text data, and construct a fusion index library that includes both vector index and full-text index.
[0058] S200: Receive agricultural-related questions input by the user, convert the questions into query vectors and query keyword sets in parallel, perform semantic similarity retrieval in the vector index based on the query vectors to obtain a first document set, and perform keyword matching retrieval in the full-text index based on the query keyword set to obtain a second document set;
[0059] S300, the first document set and the second document set are deduplicated, normalized and weighted fusion processed, and the Top-K final search documents are generated by sorting them in descending order according to the comprehensive score;
[0060] S400, the Top-K final search documents are combined with the user's question to form prompt words, which are then input into the large language model to generate an answer. A security verification step is set. If the highest relevance score of the final search document is lower than a preset threshold, an answer suppression mechanism is triggered to output a preset prompt message.
[0061] In the embodiments provided by this invention, by integrating professional data from the agricultural field into the vectorized model training process, the model's semantic understanding of agricultural terminology becomes more accurate. During the retrieval phase, semantic retrieval and keyword retrieval are used in parallel. Semantic retrieval captures the semantic relationship between the question and the document, while keyword retrieval accurately locates documents containing specific words. The combination of these two methods effectively improves the comprehensiveness and accuracy of the retrieval results. In the answer generation stage, the security verification steps are crucial. By calculating the highest relevance score of the final retrieved document and comparing it with a preset threshold, when the score falls below the threshold, an answer suppression mechanism is triggered in a timely manner, outputting preset prompts to prevent the large language model from generating inaccurate or unreliable answers, thereby ensuring the security and reliability of the system output. Furthermore, the entire system, from data preprocessing stages such as cleaning, deduplication, format unification, and entity and relation extraction, to the construction of structured knowledge during knowledge extraction, and finally to operations such as deduplication, normalization, and weighted fusion during retrieval ranking, is closely optimized around the characteristics of agricultural text. This enables the system to deeply understand agricultural terminology, accurately grasp complex query intentions, and demonstrate excellent professionalism.
[0062] In some embodiments, S100, the step of acquiring unstructured text data in the agricultural field, preprocessing and extracting knowledge from the unstructured text data, and constructing a fusion index library that simultaneously includes vector indexes and full-text indexes includes:
[0063] S110, collects unstructured text data from multiple sources in the agricultural field;
[0064] S120, the collected unstructured text data is cleaned, deduplicated, and formatted, and entities and relations are extracted using natural language processing tools to form structured knowledge.
[0065] S130, the structured knowledge is converted into a high-dimensional vector using the domain-fine-tuned embedding model, and a vector index is constructed. The structured knowledge is then segmented into words to construct a full-text index, resulting in a fused index library containing both vector and full-text indexes.
[0066] In this embodiment, data collection from multiple sources enables the acquisition of rich and diverse information in the agricultural field, laying a solid foundation for subsequent precise processing and retrieval. Cleaning, deduplication, and format standardization of the collected unstructured text data effectively removes noise and redundant information, ensuring data quality and consistency. Entity and relation extraction using natural language processing tools transforms messy unstructured data into structured knowledge, facilitating subsequent vector conversion and index construction. Using a domain-adjusted embedding model to convert structured knowledge into high-dimensional vectors and construct vector indexes better captures the semantic features of agricultural terms, making semantic retrieval more accurate. Simultaneously, word segmentation of structured knowledge to construct a full-text index enables rapid location of documents containing specific keywords. The resulting fusion index library, including vector and full-text indexes, combines the advantages of semantic and keyword retrieval, providing strong support for accurately obtaining the information needed by users.
[0067] In some embodiments, in S130, the embedded model fine-tuned by the domain converts the structured knowledge into a high-dimensional vector and constructs a vector index, and performs word segmentation on the structured knowledge to construct a full-text index, resulting in a fused index library containing both the vector index and the full-text index, including:
[0068] S131, select the pre-trained model bge-base-zh as the basic embedding model, and fine-tune the pre-trained model using agricultural professional corpus to obtain the model bge-base-zh-ag;
[0069] S132, the structured knowledge is converted into a high-dimensional vector using the model bge-base-zh-ag, and a vector index is constructed based on the high-dimensional vector;
[0070] S133, The structured knowledge is segmented using a word segmentation tool to obtain the segmentation results, and a full-text index is constructed based on the segmentation results;
[0071] S134, the vector index and the full-text index are associated and stored to obtain a fused index library containing the vector index and the full-text index.
[0072] In this embodiment, by selecting the pre-trained model bge-base-zh and fine-tuning it using agricultural corpus, it can better adapt to the characteristics of agricultural texts, thus more accurately converting structured knowledge into high-dimensional vectors. The constructed vector index can more accurately reflect the semantic relationships between agricultural terms. Using a word segmentation tool to segment the structured knowledge and construct a full-text index enables rapid retrieval of documents containing specific agricultural keywords. The vector index and full-text index are stored together to form a fused index library. This fusion approach fully leverages the advantages of semantic retrieval and keyword retrieval. In subsequent retrieval processes, it can find relevant documents through semantic similarity and accurately locate documents through keyword matching, greatly improving the comprehensiveness and accuracy of the retrieval and providing a solid data retrieval foundation for an intelligent question-answering system in the agricultural field.
[0073] In some embodiments, S200, receiving an agricultural-related question input by a user, converting the question into a query vector and a set of query keywords in parallel, performing semantic similarity retrieval in the vector index based on the query vector to obtain a first document set, and performing keyword matching retrieval in the full-text index based on the set of query keywords to obtain a second document set, includes:
[0074] S210: Receive agricultural-related questions input by the user, convert the questions into query vectors using a domain-adjusted embedding model; simultaneously, extract keywords from the questions based on an agricultural domain dictionary, and expand synonyms and / or hypernyms to form a query keyword set.
[0075] S220, based on the query vector, perform semantic similarity retrieval in the vector index, calculate the similarity between the query vector and each vector in the vector index, and form a first document set by combining the documents corresponding to the vectors with similarity higher than a preset similarity threshold;
[0076] S230, based on the query keyword set, perform keyword matching retrieval in the full-text index, and form a second document set by combining documents containing at least one keyword from the query keyword set.
[0077] In this embodiment, by utilizing a domain-adjusted embedding model to convert user questions into query vectors, the semantic features of the questions can be captured more accurately, making semantic similarity retrieval more accurate. Simultaneously, keyword extraction based on an agricultural domain dictionary, and the expansion of synonyms and / or hypernyms to form a query keyword set, broadens the search scope and avoids missing relevant documents due to different keyword expressions. Semantic similarity retrieval is performed on the vector index based on the query vectors, forming a first document set with vectors having a similarity higher than a preset similarity threshold, thus obtaining documents semantically related to the question. Keyword matching retrieval is then performed on the full-text index based on the query keyword set, forming a second document set with documents containing at least one keyword from the query keyword set, accurately locating documents containing specific keywords. This parallel retrieval method fully leverages the advantages of semantic retrieval and keyword retrieval, providing a rich document foundation for generating accurate answers.
[0078] In some embodiments, S210, converting the question into a query vector using a domain-fine-tuned embedding model includes:
[0079] S211 uses agricultural domain-specific corpus to fine-tune the pre-trained model bge-base-zh, resulting in a domain-fine-tuned embedding model.
[0080] S212, Input the agricultural-related questions input by the user into the domain-fine-tuned embedding model, and output the corresponding query vector.
[0081] In this embodiment, by fine-tuning the pre-trained model using agricultural domain-specific corpus, the model can better adapt to the semantic features and expression habits of agricultural text, thereby more accurately converting user-inputted agricultural-related questions into query vectors. These accurately converted query vectors, when used for subsequent semantic similarity retrieval based on vector indexes, can more accurately match documents semantically related to the question, laying the foundation for obtaining high-quality search results. After the user-input question is fed into the domain-fine-tuned embedding model, the model, based on its learned agricultural domain semantic knowledge, performs in-depth understanding and analysis of each word and sentence in the question, and then outputs a query vector that accurately represents the question's semantics, ensuring the accuracy and effectiveness of the entire retrieval process.
[0082] In some embodiments, S300, the process of deduplicating, normalizing, and weighting the first document set and the second document set, and generating the Top-K final search documents in descending order based on the comprehensive score, includes:
[0083] S310, perform deduplication processing on the first document set and the second document set to remove duplicate documents from the two sets, and obtain a deduplicated document set;
[0084] S320, normalize each document in the deduplicated document set, and normalize the semantic similarity score and keyword matching score of each document to the same numerical range.
[0085] S330 uses a weighted fusion algorithm to give a comprehensive score to the normalized documents, and obtains a comprehensive score for each document.
[0086] S340, Based on the comprehensive score, sort the documents in the deduplicated document set in descending order, and select the top K documents as the final search documents.
[0087] In this embodiment, by deduplicating the first and second document sets, the influence of duplicate documents on subsequent search results can be effectively avoided, ensuring that each document participates in scoring and ranking only once, thus improving the accuracy and reliability of the search results. Normalization is performed on each document in the deduplicated document set, normalizing the semantic similarity score and keyword matching score to the same numerical range. This eliminates differences in the units and numerical ranges between different scoring indicators, allowing for comparison and fusion of scores from different indicators under the same standard, providing a fair and reasonable basis for subsequent comprehensive scoring. A weighted fusion algorithm is used to comprehensively score the normalized documents, taking into account both semantic similarity and keyword matching. Different weights are assigned to different indicators according to actual needs, resulting in a more accurate comprehensive score reflecting the relevance of documents to user questions. Based on the comprehensive score, the documents in the deduplicated document set are sorted in descending order, and the top K documents are selected as the final search documents. This provides users with the most relevant and valuable documents, meeting their precise needs for information in the agricultural field and improving the service quality and user experience of the intelligent question-answering system.
[0088] In some embodiments, in S400, the step of combining the Top-K final retrieved documents with the user's question to form prompt words and inputting them into a large language model to generate an answer, and setting a security verification step, if the highest relevance score of the final retrieved document is lower than a preset threshold, triggers an answer suppression mechanism to output preset prompt information, including:
[0089] S410, The Top-K final search documents and the user question are combined according to a preset prompt word template to obtain prompt words; the prompt words are used to separate the background knowledge context from the user question;
[0090] S420, Input the prompt words into the large language model, and use the large language model to generate the answer;
[0091] S430, Set a security verification step, calculate the highest relevance score of the Top-K final retrieved documents. If the highest relevance score is lower than a preset threshold, trigger the answer suppression mechanism and output a preset prompt message; otherwise, output the answer generated by the large language model.
[0092] In this embodiment, by combining the Top-K final retrieved documents with the user question according to a preset prompt word template, a clear and complete background knowledge context can be provided to the large language model. This allows the model to better understand the user's intent and background information, thereby generating more accurate answers that better meet the user's needs. The prompt word template separates the background knowledge context from the user question, helping the model distinguish between different parts of the information and avoiding information confusion that could interfere with answer generation. After inputting the combined prompt words into the large language model, the model can generate high-quality answers based on its powerful language understanding and generation capabilities, combining the background knowledge in the prompt words with the user question. Setting up a security verification step is an important step in ensuring the security and reliability of the system output. By calculating the highest relevance score of the Top-K final retrieved documents and comparing it with a preset threshold, the relevance of the search results to the user question can be determined. When the highest relevance score is lower than the preset threshold, it indicates that the retrieved documents have a low relevance to the user question. At this time, an answer suppression mechanism is triggered, and preset prompt information is output to prevent the large language model from generating inaccurate or unreliable answers that could mislead the user. If the highest relevance score is higher than or equal to a preset threshold, it indicates that the search results are highly relevant to the user's question. In this case, the answer generated by the large language model is output, providing valuable information to the user. This security verification mechanism effectively improves the output quality of the intelligent question-answering system and enhances user trust.
[0093] The following are specific embodiments provided by the present invention:
[0094] Figure 2 A flowchart of an intelligent question-answering method for the agricultural field based on RAG fusion retrieval, provided for embodiments of the present invention, specifically includes the following steps:
[0095] S1. Construct a knowledge base from raw agricultural text data that can be used for efficient fusion retrieval. The core of this is to construct vector indexes and full-text indexes respectively.
[0096] Step S1 specifically includes:
[0097] S11: A high-quality, multi-source text dataset in the agricultural field was constructed, collecting approximately 60,000 documents, totaling about 3GB of text. The data specifically originates from:
[0098] Digitalized texts of authoritative publications: Scanning and OCR (Optical Character Recognition) text extraction of professional books such as "Atlas of Diagnosis and Control of Fruit Tree Diseases and Pests" and "Complete Guide to Vegetable Cultivation Techniques" published by China Agriculture Press to ensure the authority and accuracy of the knowledge.
[0099] Agricultural research institutions reported that they obtained highly structured documents such as crop cultivation technology guidelines and pest and disease early warning and control bulletins published by the Chinese Academy of Agricultural Sciences and agricultural academies of various provinces.
[0100] High-quality online text: Technical Q&A articles and technical point descriptions are crawled and cleaned from certified agricultural technology extension websites (such as China Agricultural Technology Extension Network) and official websites of well-known agricultural colleges (such as China Agricultural University).
[0101] S12: The original text obtained from the above channels is rigorously cleaned to remove noise and standardize the format.
[0102] Specifically, the Beautiful Soup library in Python was used to remove HTML / XML tags; the Pandas library was used to convert any existing Excel or CSV table data into plain text; and all text encoding was unified to UTF-8.
[0103] Specifically, based on regular expressions, meaningless advertising characters, copyright notices, page numbers, and other irrelevant information in the text are filtered out. Rules are established to automatically filter out excessively short text paragraphs with fewer than 50 characters to ensure that text fragments stored in the knowledge base contain basic information.
[0104] S13. Because agricultural knowledge is often highly contextualized (e.g., a passage simultaneously describes disease "symptoms" and "control methods"), it is not suitable to simply segment it by a fixed size. Therefore, a recursive character text splitting strategy is adopted. "\n\n" (double newline character) is used as the primary delimiter to preserve natural paragraph structure. For excessively long paragraphs, secondary segmentation is performed using semantic delimiters such as "\n", ".", "?", and "!".
[0105] When setting the parameters, the chunk size (chunk_size) is set to 512 characters, and the chunk overlap (chunk_overlap) is set to 64 characters. The overlap effectively prevents a complete sentence or knowledge point from being split into two different segments, maintaining the coherence of the context.
[0106] S14. To improve the retrieval performance of agricultural terminology and fine-grained semantics, this embodiment performs domain-adaptive fine-tuning on the general embedding model bge-base-zh-v1.5 to obtain the specialized model bge-base-zh-ag. The fine-tuning process includes three parts: training data construction, fine-tuning training, and performance verification, as detailed below:
[0107] First, text was collected from sources such as the China Agricultural Technology Extension Network, CNKI agricultural journal abstracts, and agricultural forums (high-quality QA queries selected through screening). Candidate paragraphs were generated based on the S13 segmentation strategy. Positive and negative samples were constructed separately. For positive samples, high-quality (highly rated, expert-adopted) question-and-answer pairs from community forums or QA databases were used as QA pairs. Chapter titles and core paragraphs under those titles were extracted from technical documents or papers based on their headings and paragraphs as positive samples. Finally, a large language model was used to perform diverse synonym rewriting of the original questions to enhance diversity. Negative samples were constructed in two ways: difficult negative samples and domain-deceptive negative samples. For difficult negative samples, BM25 was used to retrieve the Top-50 candidates from the full-text database for each query, and 2-3 of these (excluding positive samples) were selected as difficult negative samples. Domain-deceptive negative samples were manually constructed, creating negative samples with similar but not identical target semantics to improve the model's discriminative ability. Finally, Query-Positive-Negative triples were constructed, with an exemplary scale of approximately 10,000 triples.
[0108] Because bge-base-zh-v1.5 outperforms other models when dealing with Chinese data, it was chosen as the base model. A contrastive learning framework and the InfoNCE loss function were employed, aiming to maximize the vector similarity between the query and the positive while minimizing the similarity with the negative. To enhance the model's understanding of retrieval intent, a uniform prefix (e.g., "Generate representation for retrieval:") was added to all queries to guide the model in better learning retrieval-related representations. For hyperparameter settings, the AdamW optimizer was chosen, with a learning rate typically between 1e-6 and 5e-5 (3e-5 in this example). Batch... The recommended size range is 16 to 128 (64 for the example), the number of training epochs is between 1 and 10 (3 for the example), and a cosine learning rate decay and linear warm-up strategy are used. At the same time, fusion precision training (FP16) is used to improve training efficiency. In terms of vector processing, the generated vectors are L2 normalized during training to make them consistent with the normalized vectors in the retrieval library, so that the vector inner product is equivalent to cosine similarity. Finally, by monitoring retrieval performance indicators such as nDCG@10, Recall@1, and Recall@10 on the validation set, an early stopping strategy is implemented when the model performance no longer improves, and the optimal model is finally saved as bge-base-zh-ag.
[0109] To verify the effectiveness of the fine-tuning method of this invention, we designed a comparative experiment. In this example, the bge-base-zh-ag model is compared with existing models bge-base-zh-v1.5, m3e-base, and OpenAI text-embedding-3-small in terms of nDCG@10 (ranking quality of the top 10 search results), Recall@1 (probability that the first-ranked result is the correct answer), and Recall@10 (probability that the correct answer exists among the top 10 results). The results are shown in the table below.
[0110]
[0111] The results show that among the bge-base-zh-ag, bge-base-zh-v1.5, m3e-base, and OpenAItext-embedding-3-small models, bge-base-zh-ag has the best performance in all aspects. Moreover, the nDCG@10, Recall@1, and Recall@10 of the model in this invention are improved by 0.114, 12.2%, and 14.8% in absolute terms, respectively, and by 23.8%, 40.0%, and 25.0% in relative terms, respectively, compared with the corresponding performance of its base model bge-base-zh-v1.5.
[0112] S15. Use bge-base-zh-ag to convert each text block obtained in S13 into a 768-dimensional floating-point vector. Perform L2 normalization on the vector and save both the original vector and the normalized vector to support different retrieval metrics. Store all text vectors and their corresponding metadata (such as the original text and source) in the open-source vector database Milvus and build an approximate nearest neighbor index (preferably HNSW or IVF_FLAT, selected according to scale and latency requirements). At the same time, build a full-text index, store the original content of the text blocks in the full-text search engine Elasticsearch, and configure the ik_smart Chinese word segmenter. This word segmenter can index professional compound words such as "rice sheath blight" as a whole, instead of splitting them into "rice", "sheath", "blight", and "blight", thereby improving the accuracy of keyword retrieval.
[0113] S16. The dataset is divided into a training set, a validation set, and a test set. The training set contains approximately 8,000 queries and their corresponding positive and negative triplets. The validation set and the test set each contain 1,000 queries and their triplets. The training set is used to fine-tune the embedding model (bge-base-zh-v1.5) and optimize the parameters of the retrieval model (such as the fusion weight α). The validation set is used to adjust hyperparameters and perform early stopping during training to prevent overfitting. The test set serves as the benchmark set for the final evaluation of system performance. This set is not used throughout the development process to ensure the objectivity of the evaluation results.
[0114] S2. This step describes how the system understands the user's intent after the user inputs an agricultural question and retrieves the most relevant information from the knowledge base in parallel. Its core lies in comprehensively capturing the query intent through two parallel channels: semantic retrieval and keyword retrieval.
[0115] Step S2 specifically includes:
[0116] S21. Receive the raw query statement (e.g., "What disease causes rice leaves to turn yellow? What medicine should be used?") input by the user through the natural language interactive interface. First, perform basic text preprocessing on the query: use regular expressions to remove special characters and irrelevant spaces that the user may have entered incorrectly, and perform Unicode normalization to convert all text to UTF-8 encoding format, providing clean and uniform input for subsequent analysis.
[0117] S22. To gain a deeper understanding of the semantic information of user queries, the preprocessed queries are converted into high-dimensional vector representations:
[0118] First, a pre-defined instruction prefix is concatenated with the user query to guide the model in performing the retrieval task more effectively. The concatenated text is: "Generate a representation for this sentence for retrieval:" + "user query".
[0119] Subsequently, the concatenated text is input into the model bge-base-zh-ag, which outputs a 768-dimensional floating-point vector as the deep semantic representation of the query, denoted as the query vector. .
[0120] S23. To fully utilize the advantages of exact keyword matching, the query is processed in parallel as follows:
[0121] Chinese word segmentation: The Jieba word segmentation tool is used to segment user queries, and a custom agricultural dictionary is loaded to ensure that professional terms (such as "two-leaved stem borer" and "downy mildew") can be accurately segmented and avoid missegmentation.
[0122] Synonym Expansion: Based on a self-built thesaurus of agricultural terms, the keywords obtained from word segmentation are expanded. For example, for the query "rice leaves turn yellow", the initial set of words segmentation is {'rice', 'leaves', 'turn yellow'}, which is expanded to obtain the final set of query keywords {'rice', 'leaves', 'turn yellow', 'yellowing'}, denoted as Q. This step can significantly improve the recall rate and avoid missed detections due to different expressions.
[0123] S24. The system starts two independent threads to execute two different retrieval mechanisms respectively, in order to achieve the advantage of "fusion":
[0124] Semantic retrieval thread:
[0125] query vector Input the data into the Milvus vector database, select Cosine as the metric, and return a top_k=1000 result set. Perform an approximate nearest neighbor (ANN) search and calculate... Calculate the cosine similarity between the candidate and all document vectors in the library, and record the semantic score for each candidate. The calculation formula is as follows:
[0126] ;
[0127] Where · represents the dot product of vectors, and ||·|| represents the L2 norm of the vectors. The closer this value is to 1, the more semantically similar the vectors are. After the search is completed, the results are obtained by score. A preliminary collection of documents, Cvector, sorted in descending order.
[0128] Keyword search thread:
[0129] The expanded keyword set Q is fed into the Elasticsearch full-text search engine. A query is constructed using Boolean Query, and the number of returned results is set to size=1000. For each matching document D, the BM25 algorithm is used to calculate its relevance score to the query keyword set. BM25 is a standard algorithm in the field of information retrieval, and its calculation formula is as follows:
[0130] ;
[0131] ;
[0132] in: Keywords The inverse document frequency is used to measure the scarcity of a word; Keywords The word frequency in document D; |D| is the length of document D (number of words); It is the average length of all documents in the entire knowledge base. b are free parameters, and b are preferred parameters. b=0.75.
[0133] After the search is completed, a collection of documents Ckeyword is obtained, sorted in descending order by the score Skeyword.
[0134] S25. After the two retrieval threads mentioned above have finished executing, the system obtains two preliminary result sets from different sources and with different scoring systems:
[0135] A set Cvector based on deep semantic similarity and its score Ssemantic.
[0136] The set Ckeyword and its score Skeyword are based on surface keyword matching.
[0137] At this point, the fusion retrieval step is complete. These two sets will serve as input for the next step, S3, retrieval result fusion and reordering, for further integration and refinement.
[0138] S3. This step aims to integrate, deduplicate, and finely sort the two preliminary search result sets generated in S2, providing the most relevant and reliable contextual information for the final answer generation. Its core is to use a weighted fusion score-based strategy to uniformly re-rank the heterogeneous search results and introduce a confidence-based security pre-verification mechanism to reduce the risk of "illusionary" answers generated by the large model from the source.
[0139] Step S3 specifically includes:
[0140] S31: Receive the preliminary semantic retrieval result set Cvector (containing documents and semantic similarity scores Ssemantic) and the preliminary keyword retrieval result set Ckeyword (containing documents and BM25 relevance scores Skeyword) from S24. First, perform preliminary deduplication based on the unique IDs of the documents. For documents with different IDs but substantially duplicated content, calculate the cosine similarity between their document vectors. If it is greater than the experimentally verified threshold θ (preferably θ=0.87 in this embodiment), it is determined to be a redundant document, and only the one with the higher Ssemantic score is retained, finally obtaining a deduplicated basic candidate set Ccandidate.
[0141] S32: Due to the significant differences in the numerical scale and distribution between Ssemantic (cosine similarity, range [-1,1]) and Skeyword (BM25 score, theoretically unbounded), direct weighted fusion will result in one becoming dominant while the other becomes ineffective. To address this issue, this embodiment performs min-max normalization on both scores for all documents in Ccandidate, linearly transforming them to the [0,1] interval, as shown in the following formula:
[0142] ;
[0143] Where: S represents the original score to be normalized (Ssemantic or Skeyword). and These are the maximum and minimum scores of this type in the current Ccandidate set, respectively; ε is a very small constant (1e-8 in this example) used to ensure that the denominator is not zero. and If the scores of this class are identical (i.e., there is no significant difference within the set), the normalized score of this class can be set as an example constant (e.g., 0.5) to ensure numerical stability. After normalization, the normalized semantic score is obtained. Normalized keyword scores .
[0144] S33: To combine the advantages of semantic matching and keyword matching, this embodiment uses a linear weighted method to calculate the final fusion score F for each document. The calculation formula is as follows:
[0145] ;
[0146] Where α is the fusion weight of the semantic score, which is an adjustable hyperparameter.
[0147] Parameter tuning was performed using Grid Search on the validation set described in S16. The results show that when the value of α ranges between 0.6 and 0.8 (in this embodiment, α = 0.7 is preferred), the system achieves optimal performance in retrieval metrics such as nDCG@10. This weight assignment reflects that in the agricultural technology Q&A scenario, understanding the deep semantics of queries is more important than surface lexical matching.
[0148] Subsequently, the documents in Ccandidate are re-sorted in descending order according to the fusion score F, and the top K documents with the highest ranking (in this embodiment, K = 5 is set according to the context window size and experimental results) are intercepted as the most relevant context fragments and output to the S4 process.
[0149] S34: To fundamentally prevent the large language model from generating fictional answers for queries not covered by the knowledge base or with low confidence, this embodiment adds a security verification checkpoint before submitting the retrieval results to the large model. First, calculate the highest fusion score Fmax in the final output top-K documents, and determine whether Fmax is lower than the preset security threshold T, which is determined by balancing the correct answer rate and the rejection rate on the validation set (in this embodiment, T = 0.65 is preferred). If Fmax < T, it is determined that the current retrieval results are insufficiently relevant to the user's question, or the question itself exceeds the scope of the knowledge base. The system will immediately terminate the process and directly return a preset security prompt message to the user (for example: "Your question currently exceeds my answering ability. Please try asking other agricultural-related questions."), thus avoiding calling the large model and preventing hallucinations; if Fmax ≥ T, the retrieval results are considered reliable, and the process continues to the S4 secure answer generation step.
[0150] S4. This step is the final link of the method, aiming to transform the refined retrieval results output by S3 into a safe, reliable, fluent, and easy-to-understand natural language answer and finally present it to the user. The core is to ensure the accuracy and controllability of answer generation through carefully designed large language model prompt engineering (Prompt Engineering), and form a dual protection mechanism with the security pre-check of S3 to constitute a complete defense system.
[0151] Step S4 specifically includes: [[ID=
[0154] "You are a professional assistant for agricultural technology experts. Your task is to answer users' questions based on the following provided background knowledge only. Please ensure your answers are accurate, clear, and easy to practice."
[0155] "Please note: If the provided background knowledge is completely irrelevant to the user's question, or if an exact answer cannot be obtained from the background knowledge, you must honestly reply 'The question cannot be answered based on the existing knowledge' and are strictly prohibited from fabricating any information."
[0156] "Background knowledge:"
[0157] {context}
[0158] "User question:"
[0159] {question}
[0160] "Please start your answer:"
[0161] "Among them, the {context} variable is composed of the top-K (K = 5) most relevant document fragments output by S33 concatenated in descending order of relevance; the {question} variable is the original query input by the user."
[0162] "Input the filled complete prompt into Qwen3.8. To pursue the accuracy and certainty of the answer, in this embodiment, the following configurations are made for the model generation parameters: Set the temperature parameter to 0.1 to significantly reduce the randomness during the generation process and make the output more concentrated and reliable; set the maximum generation length to 1024 to ensure that the generated answer content is complete and not accidentally truncated."
[0163] "S42: This step serves as the last safety barrier before the system's final output and forms a redundant design with the pre-check in S34 to ensure absolute safety. The system's final output behavior is completely determined by the result of the safety pre-check in step S34. If S34 determines that Fmax >= T, it indicates that the relevance confidence of the retrieval result is high, and the process continues. At this time, the answer generated by the large language model in S41 is used as the final output content. If S34 determines that Fmax < T: it indicates that the retrieval result cannot effectively support question answering, and the answer suppression mechanism has been triggered in S34. The system will completely skip the large model call step in S41 and directly select the preset safety prompt information as the final output content (for example: 'Your question currently exceeds my knowledge scope. Please try asking other agriculture-related questions.'), and finally, the system clearly and stably returns the generated final answer and presents it to the user, completing the entire intelligent question-answering process for the agricultural field based on the integrated retrieval RAG."
[0164] In summary, the intelligent question-answering method for the agricultural field based on fusion retrieval (RAG) provided in this embodiment of the invention constructs a professional knowledge base of fusion vectors and full-text indexes (S1), performs fusion retrieval (S2), fuses and reorders heterogeneous results and performs security verification (S3), and finally generates a safe and reliable answer (S4), forming a complete, efficient, and reliable intelligent question-answering solution for the agricultural field. This method effectively improves the accuracy and security of domain-specific question answering and has good prospects for industrial application.
[0165] This invention also provides an intelligent question-answering system for the agricultural field based on retrieval enhancement generation, comprising:
[0166] At least one processor;
[0167] At least one memory for storing at least one program;
[0168] When the at least one program is executed by the at least one processor, the at least one processor performs the method described above.
[0169] The content of the above method embodiments is applicable to this embodiment. The specific functions implemented in this embodiment are the same as those in the above method embodiments, and the beneficial effects achieved are also the same as those achieved in the above method embodiments. Therefore, they will not be repeated here.
[0170] This invention also provides an electronic device, which includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the method described above. This electronic device can be any smart terminal, including tablet computers, in-vehicle computers, etc.
[0171] It is understood that the content of the above method embodiments is applicable to this device embodiment. The specific functions implemented by this device embodiment are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0172] This invention also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the above-described method.
[0173] It is understood that the content of the above method embodiments is applicable to this storage medium embodiment. The specific functions implemented in this storage medium embodiment are the same as those in the above method embodiments, and the beneficial effects achieved are also the same as those achieved in the above method embodiments.
[0174] This invention also provides a computer program product, including a computer program or computer instructions, which are stored in a memory. A processor of a computer device reads the computer program or computer instructions from the memory and executes the computer program or computer instructions, causing the computer device to perform the above-described method.
[0175] It is understood that the content of the above method embodiments is applicable to the embodiments of this program product. The specific functions implemented by the embodiments of this program product are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0176] Memory, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs and non-transitory computer-executable programs. Furthermore, memory may include high-speed random access memory, and may also include non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid-state storage device. In some embodiments, memory may optionally include memory remotely located relative to the processor, and these remote memories can be connected to the processor via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.
[0177] It will be understood by those skilled in the art that all or some of the steps and systems in the methods disclosed above can be implemented as software, firmware, hardware, and suitable combinations thereof. Some or all of the physical components can be implemented as software executed by a processor, such as a central processing unit, digital signal processor, or microprocessor, or as hardware, or as an integrated circuit, such as an application-specific integrated circuit. Such software can be distributed on a computer-readable medium, which can include computer storage media (or non-transitory media) and communication media (or transient media). As is known to those skilled in the art, the term computer storage media includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, program modules, or other data). Computer storage media includes, but is not limited to, RAM, ROM, EEPROM, flash memory or other memory technologies, CD-ROM, digital versatile disc (DVD) or other optical disc storage, magnetic cartridges, magnetic tape, disk storage or other magnetic storage devices, or any other medium that can be used to store desired information and is accessible to a computer. Furthermore, as is known to those skilled in the art, communication media typically include computer-readable instructions, data structures, program modules, or other data in modulated data signals such as carrier waves or other transmission mechanisms, and may include any information delivery medium.
[0178] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.
Claims
1. An intelligent question and answer method in the field of agriculture based on search enhancement generation, characterized by, The method comprises the following steps: S100, obtaining unstructured text data in the field of agriculture, preprocessing and knowledge extraction are performed on the unstructured text data, and a fusion index library containing vector index and full-text index is constructed; S200, receiving a user-input agricultural-related question, converting the question into a query vector and a query keyword set in parallel, performing semantic similarity retrieval in the vector index based on the query vector to obtain a first document set, and performing keyword matching retrieval in the full-text index based on the query keyword set to obtain a second document set; S300, performing deduplication, normalization and weighted fusion processing on the first document set and the second document set, and generating Top-K final retrieval documents in descending order of comprehensive score; S400, combining the Top-K final retrieval documents and the user question into prompt words, inputting the prompt words into a large language model to generate an answer, and setting a security check step, if the highest relevance score of the final retrieval document is lower than a preset threshold, triggering a reply suppression mechanism to output a preset prompt information.
2. The method of claim 1, wherein, In S100, the unstructured text data in the field of agriculture is obtained, preprocessing and knowledge extraction are performed on the unstructured text data, and a fusion index library containing vector index and full-text index is constructed, comprising: S110, collecting unstructured text data in the field of agriculture from multiple sources; S120, cleaning, deduplicating and formatting the collected unstructured text data, and using natural language processing tools to extract entities and relationships to form structured knowledge; S130, using a field fine-tuned embedding model to convert the structured knowledge into a high-dimensional vector, constructing a vector index, and performing word segmentation processing on the structured knowledge to construct a full-text index, obtaining a fusion index library containing vector index and full-text index.
3. The method of claim 2, wherein, In S130, the structured knowledge is converted into a high-dimensional vector using a field fine-tuned embedding model, a vector index is constructed, and the structured knowledge is processed by word segmentation to construct a full-text index, obtaining a fusion index library containing vector index and full-text index, comprising: S131, selecting a pre-trained model bge-base-zh as a basic embedding model, and fine-tuning the pre-trained model using agricultural field professional corpus to obtain a model bge-base-zh-ag; S132, converting the structured knowledge into a high-dimensional vector using the model bge-base-zh-ag, and constructing a vector index based on the high-dimensional vector; S133, performing word segmentation processing on the structured knowledge using a word segmentation tool to obtain a word segmentation result, and constructing a full-text index based on the word segmentation result; S134, associatively storing the vector index and the full-text index to obtain a fusion index library containing vector index and full-text index.
4. The method of claim 1, wherein, In S200, the received user input agricultural related question is converted into a query vector and a query keyword set in parallel, semantic similarity retrieval is performed in the vector index based on the query vector to obtain a first document set, and keyword matching retrieval is performed in the full-text index based on the query keyword set to obtain a second document set, including: In S210, the user input agricultural related question is converted into a query vector by using a domain fine-tuned embedding model, and keywords are extracted from the question based on an agricultural domain dictionary, and synonyms and / or hypernyms are expanded to form a query keyword set. In S220, semantic similarity retrieval is performed in the vector index based on the query vector, similarity between the query vector and each vector in the vector index is calculated, and documents corresponding to vectors with similarity higher than a preset similarity threshold are grouped to form a first document set. In S230, keyword matching retrieval is performed in the full-text index based on the query keyword set, and documents containing at least one keyword in the query keyword set are grouped to form a second document set.
5. The method of claim 4, wherein, In S210, the user input agricultural related question is converted into a query vector by using a domain fine-tuned embedding model, including: In S211, a pre-trained model bge-base-zh is fine-tuned by using an agricultural domain professional corpus to obtain a domain fine-tuned embedding model. In S212, the user input agricultural related question is input into the domain fine-tuned embedding model, and a corresponding query vector is output.
6. The method of claim 1, wherein, In S300, the first document set and the second document set are subjected to deduplication, normalization and weighted fusion processing, and Top-K final retrieval documents are generated in descending order according to comprehensive scores, including: In S310, the first document set and the second document set are subjected to deduplication processing to remove duplicate documents in the two sets, and a deduplicated document set is obtained. In S320, each document in the deduplicated document set is subjected to normalization processing, and semantic similarity scores and keyword matching scores of each document are normalized to the same numerical range. In S330, a weighted fusion algorithm is used to give a comprehensive score to the normalized document, and a comprehensive score of each document is obtained. In S340, the documents in the deduplicated document set are arranged in descending order according to the comprehensive scores, and the top K documents are selected as the final retrieval documents.
7. The method of claim 1, wherein, In S400, the Top-K final retrieval documents and the user question are combined into a prompt word, which is input into a large language model to generate an answer, and a security verification step is set, if the highest relevance score of the final retrieval document is lower than a preset threshold, a reply suppression mechanism is triggered to output a preset prompt information, including: In S410, the Top-K final retrieval documents and the user question are combined according to a preset prompt word template to obtain a prompt word; the prompt word is used to separate the background knowledge context from the user question. In S420, the prompt word is input into a large language model, and an answer is generated by using the large language model. S430, a security verification step is set, the highest relevance score of the Top-K final retrieval documents is calculated, if the highest relevance score is lower than a preset threshold, a response suppression mechanism is triggered, a preset prompt information is output, otherwise an answer generated by the large language model is output.
8. An intelligent question answering system in the field of agriculture based on search augmentation generation, characterized by, Comprising: at least one processor; at least one memory for storing at least one program; when the at least one program is executed by the at least one processor, the at least one processor implements the method of any one of claims 1 to 7.
9. A computer-readable storage medium storing a computer program, the computer program comprising instructions that, when executed by a computer, cause the computer to perform the method of any one of claims 1 to 8. The computer program is executed by the processor to implement the method of any one of claims 1 to 7. The computer program is executed by the processor to implement the method of any one of claims 1 to 7.
Citation Information
Patent Citations
Agricultural knowledge question and answer method and device, electronic equipment and storage medium
CN114860917A
Knowledge retrieval enhancement generation method and system based on large language model
CN118394890A
Agricultural knowledge intelligent question-answering system based on retrieval enhancement generation and large model
CN119226454A