Facility agriculture intelligent question answering method based on big language model retrieval enhancement generation
Through the search and enhancement generation method of large language models, the problems of low answer accuracy and poor query processing capabilities in the intelligent question-and-answer system of facility agriculture are solved, achieving more accurate and efficient answer generation, and improving user experience.
Patent Information
- Application Number
- CN202410950036.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Priority Date
- 2024-04-19
- Filing Date
- 2024-07-16
- Publication Date
- 2024-11-08
AI Technical Summary
The intelligent question and answer system of facility agriculture lacks professional knowledge and incomplete knowledge base construction, resulting in low answer accuracy and poor query processing capabilities.
Using a search enhancement generation method based on a large language model, the user's question text is obtained, query rewrite and vector processing is performed, and related data and vectors are retrieved from the knowledge base to generate accurate answer text. .
It improves the answer accuracy and query processing capabilities of the intelligent question-and-answer system in the facility agriculture, meets the users' refined needs, and significantly improves the user experience.
Smart Images

Figure CN118916457A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and in particular to an intelligent question-answering method for facility agriculture based on large language model retrieval and enhanced generation. Background Art
[0002] In the field of natural language processing in agricultural technology, the facility agriculture intelligent question-answering system in related technologies has the following technical defects:
[0003] 1. Lack of professional knowledge: The existing question-and-answer system lacks a professional knowledge base in the field of facility agriculture and detailed information on the specific processes and operations of facility agriculture management, which means that the existing intelligent question-and-answer system is difficult to meet the refined needs in actual operations.
[0004] 2. Incomplete knowledge base construction: There are a large number of unstructured data such as tables and pictures in the field of facility agriculture, and there is a lack of effective preprocessing algorithms to extract and summarize unstructured data and build a complete knowledge base.
[0005] 3. Low answer accuracy: Due to the lack of effective information understanding and processing mechanisms, intelligent question-answering systems often cannot accurately understand users' complex query intentions and thus cannot provide precise answers, affecting user experience and decision-making accuracy.
[0006] 4. Poor processing capability for complex queries: When faced with complex questions or when comprehensive analysis of multiple information is required, the processing capabilities of existing intelligent question-answering systems seem to be insufficient and it is difficult to provide solutions that meet actual needs.
[0007] At present, no effective solution has been proposed for the problems of low answer accuracy and poor query processing capabilities in the intelligent question-and-answer system for facility agriculture in related technologies. Summary of the invention
[0008] The purpose of this application is to address the deficiencies in the prior art and to provide a method, device, computer equipment and storage medium for intelligent question answering in facility agriculture based on large language model retrieval and enhanced generation, so as to at least solve the problems of low answer accuracy and poor query processing capability existing in the intelligent question answering system in facility agriculture in the related technology.
[0009] To achieve the above purpose, the technical solution adopted by this application is:
[0010] In a first aspect, an embodiment of the present application provides a facility agriculture intelligent question answering method based on large language model retrieval enhanced generation, the method comprising:
[0011] Get the target question text raised by the user;
[0012] Performing query rewriting on the target question text to generate multiple query texts similar to the target question text, and integrating the target question text and the multiple query texts into a question text set;
[0013] Vectorizing the text in the question text set to generate a question vector set, and integrating the question text set and the question vector set into a question library;
[0014] Retrieving data of a plurality of texts related to the problem text set from a knowledge base by using text keyword retrieval;
[0015] Retrieving vectors of a plurality of texts related to the question vector set from the knowledge base by using vector retrieval;
[0016] A target answer text corresponding to the target question text is generated according to the retrieved data of the plurality of texts and the vectors of the plurality of texts.
[0017] In some embodiments, generating a target answer text corresponding to the target question text based on the retrieved data of the plurality of texts and the vectors of the plurality of texts comprises:
[0018] The ranking of each text in the multiple texts is calculated respectively according to the following formula:
[0019]
[0020] in, The ranking of text d among the multiple texts, is the ranking of text d in the plurality of text data, is the ranking of text d in the plurality of text vectors, k is a preset constant, and text d is one of the plurality of texts;
[0021] Filtering out a target text from the multiple texts according to the ranking of each text;
[0022] A target answer text corresponding to the target question text is generated according to the target text.
[0023] In some embodiments, generating a target answer text corresponding to the target question text according to the target text includes:
[0024] Using preset prompt words to perform text polishing on the target text to obtain a prompt text;
[0025] The prompt text is input into a large language model for processing to obtain the target answer text corresponding to the target question text.
[0026] In some embodiments, before obtaining the target question text raised by the user, the method further includes:
[0027] Collect information on target areas;
[0028] Preprocess the unstructured data in the document, extract the text information and store it in a structured manner in a text library;
[0029] Performing vector conversion on the text in the text library to generate a vector library;
[0030] The text library and the vector library are integrated into the knowledge base.
[0031] In some embodiments, the preprocessing of the unstructured data in the document, extracting the text information and storing it in a structured manner in a text library includes:
[0032] The output result of the extraction process is obtained as a Python dictionary, each key in the dictionary corresponds to a page number of a document, and the value associated with it is a list, which includes five nested lists:
[0033] The first nested list includes the text content extracted from each text block in the material;
[0034] The second nested list records the formatting information of the text in each text block;
[0035] The third nested list includes the text extracted from the page image;
[0036] The fourth nested list extracts the text information from the table in a structured form;
[0037] The fifth nested list includes the complete text content of the page.
[0038] In a second aspect, the embodiment of the present application provides a facility agriculture intelligent question-answering device based on large language model retrieval enhanced generation, including:
[0039] An acquisition unit, used for acquiring a target question text raised by a user;
[0040] A rewriting unit, configured to perform query rewriting on the target question text, generate a plurality of query texts similar to the target question text, and integrate the target question text and the plurality of query texts into a question text set;
[0041] A first generating unit is used to perform vectorization processing on the text in the question text set to generate a question vector set, and integrate the question text set and the question vector set into a question library;
[0042] A first retrieval unit, used to retrieve data of a plurality of texts related to the problem text set from a knowledge base by using text keyword retrieval;
[0043] A second retrieval unit, configured to retrieve vectors of a plurality of texts related to the question vector set from the knowledge base by using vector retrieval;
[0044] The second generating unit is used to generate a target answer text corresponding to the target question text according to the retrieved data of the multiple texts and the vectors of the multiple texts.
[0045] In some embodiments, the second generating unit includes:
[0046] The calculation module is used to calculate the ranking of each text in the multiple texts according to the following formula:
[0047]
[0048] in, The ranking of text d among the multiple texts, is the ranking of text d in the plurality of text data, is the ranking of text d in the plurality of text vectors, k is a preset constant, and text d is one of the plurality of texts;
[0049] A screening module, used for screening out a target text from the plurality of texts according to the ranking of each text;
[0050] A generation module is used to generate a target answer text corresponding to the target question text based on the target text.
[0051] In some embodiments, the generating module comprises:
[0052] The first processing submodule is used to perform text polishing on the target text using preset prompt words to obtain a prompt text;
[0053] The second processing submodule is used to input the prompt text into the large language model for processing to obtain the target answer text corresponding to the target question text.
[0054] In the third aspect, an embodiment of the present application provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the intelligent question-answering method for facility agriculture based on large language model retrieval and enhanced generation as described in the first aspect above.
[0055] In a fourth aspect, an embodiment of the present application provides a computer storage medium on which a computer program is stored. When the program is executed by a processor, the method for intelligent question and answer in facility agriculture based on large language model retrieval and enhanced generation as described in the first aspect above is implemented.
[0056] This application adopts the above technical solution. Compared with the prior art, the embodiment of this application provides a facility agriculture intelligent question-answering method based on large language model retrieval enhancement generation, the method comprising: obtaining the target question text proposed by the user; performing query rewriting on the target question text, generating multiple query texts similar to the target question text, and integrating the target question text and the multiple query texts into a question text set; performing vectorization processing on the text in the question text set, generating a question vector set, and integrating the question text set and the question vector set into a question library; using text keyword retrieval to retrieve data of multiple texts related to the question text set from the knowledge base; using vector retrieval to retrieve vectors of multiple texts related to the question vector set from the knowledge base; generating a target answer text corresponding to the target question text based on the retrieved data of the multiple texts and the vectors of the multiple texts. This method solves the problems of low answer accuracy and poor query processing capability of the facility agriculture intelligent question-answering system in the related technology, and achieves the effect of improving the answer accuracy and query processing capability of the agricultural intelligent question-answering system.
[0057] Details of one or more embodiments of the present application are set forth in the following drawings and description to make other features, objects, and advantages of the present application more readily apparent. BRIEF DESCRIPTION OF THE DRAWINGS
[0058] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0059] Figure 1 is a structural block diagram of a mobile terminal according to an embodiment of the present application;
[0060] Figure 2 It is a flow chart of a facility agriculture intelligent question-answering method based on large language model retrieval enhanced generation according to an embodiment of the present application;
[0061] Figure 3 is a flowchart of an intelligent question-answering method according to a preferred embodiment of the present application;
[0062] Figure 4 It is a flowchart of a retrieval optimization method based on query rewriting according to a preferred embodiment of the present application;
[0063] Figure 5It is a flowchart of a method for constructing a knowledge base based on a preprocessing algorithm according to a preferred embodiment of the present application;
[0064] Figure 6 It is a structural block diagram of a facility agriculture intelligent question-answering device based on large language model retrieval enhancement generation according to an embodiment of the present application;
[0065] Figure 7 Schematic diagram of the hardware structure of a computer device according to an embodiment of the present application. DETAILED DESCRIPTION
[0066] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application is described and illustrated below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not intended to limit the present application. Based on the embodiments provided in the present application, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application.
[0067] Obviously, the drawings described below are only some examples or embodiments of the present application. For ordinary technicians in this field, the present application can also be applied to other similar scenarios based on these drawings without creative work. In addition, it can also be understood that although the efforts made in this development process may be complicated and lengthy, for ordinary technicians in this field related to the content disclosed in this application, some changes in design, manufacturing or production based on the technical content disclosed in this application are just conventional technical means, and should not be understood as insufficient content disclosed in this application.
[0068] Reference to "embodiments" in this application means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those of ordinary skill in the art that the embodiments described in this application may be combined with other embodiments without conflict.
[0069] Unless otherwise defined, the technical terms or scientific terms involved in this application should be understood by people with ordinary skills in the technical field to which this application belongs. The words "one", "a", "a", "the" and the like involved in this application do not indicate a quantitative limitation, and may represent the singular or plural. The terms "include", "comprise", "have" and any of their variations involved in this application are intended to cover non-exclusive inclusions; for example, a process, method, system, product or device that includes a series of steps or modules (units) is not limited to the listed steps or units, but may also include steps or units that are not listed, or may also include other steps or units inherent to these processes, methods, products or devices. The words "connect", "connected", "coupled" and the like involved in this application are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. The "multiple" involved in this application refers to two or more. "And / or" describes the association relationship of associated objects, indicating that there may be three relationships, for example, "A and / or B" can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the objects before and after are in an "or" relationship. The terms "first", "second", "third", etc. involved in this application are only used to distinguish similar objects and do not represent a specific ordering of the objects.
[0070] This embodiment provides a mobile terminal. Figure 1 is a structural block diagram of a mobile terminal according to an embodiment of the present application. Figure 1 As shown, the mobile terminal includes: a radio frequency (RF) circuit 110, a memory 120, an input unit 130, a display unit 140, a sensor 150, an audio circuit 160, a wireless fidelity (WiFi) module 170, a processor 180, and a power supply 190. Those skilled in the art will understand that Figure 1 The structure of the mobile terminal shown in the figure does not constitute a limitation on the mobile terminal, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.
[0071] Combine the following Figure 1 The following is a detailed introduction to the various components of the mobile terminal:
[0072] The RF circuit 110 can be used for receiving and sending signals during the process of sending and receiving information or making calls. In particular, after receiving the downlink information of the base station, it is sent to the processor 180 for processing; in addition, the designed uplink data is sent to the base station. Usually, the RF circuit includes but is not limited to an antenna, at least one amplifier, a transceiver, a coupler, a low noise amplifier (Low Noise Amplifier, referred to as LNA), a duplexer, etc. In addition, the RF circuit 110 can also communicate with the network and other devices through wireless communication. The above-mentioned wireless communication can use any communication standard or protocol, including but not limited to the Global System of Mobile communication (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Long Term Evolution (LTE), email, Short Messaging Service (SMS), etc.
[0073] The memory 120 can be used to store software programs and modules. The processor 180 executes various functional applications and data processing of the mobile terminal by running the software programs and modules stored in the memory 120. The memory 120 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area may store data created according to the use of the mobile terminal (such as audio data, a phone book, etc.), etc. In addition, the memory 120 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.
[0074] The input unit 130 can be used to receive input digital or character information, and to generate key signal input related to the user settings and function control of the mobile terminal. Specifically, the input unit 130 may include a touch panel 131 and other input devices 132. The touch panel 131, also known as a touch screen, can collect the user's touch operation on or near it (such as the user's operation on the touch panel 131 or near the touch panel 131 using any suitable object or accessory such as a finger, stylus, etc.), and drive the corresponding connection device according to a pre-set program. Optionally, the touch panel 131 may include two parts: a touch detection device and a touch controller. Among them, the touch detection device detects the user's touch orientation, detects the signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts it into contact coordinates, and then sends it to the processor 180, and can receive and execute commands sent by the processor 180. In addition, the touch panel 131 can be implemented in various types such as resistive, capacitive, infrared, and surface acoustic waves. In addition to the touch panel 131, the input unit 130 may also include other input devices 132. Specifically, other input devices 132 may include but are not limited to one or more of a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, a joystick, etc.
[0075] The display unit 140 can be used to display information input by the user or information provided to the user and various menus of the mobile terminal. The display unit 140 may include a display panel 141. Optionally, the display panel 141 may be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), etc. Further, the touch panel 131 may cover the display panel 141. When the touch panel 131 detects a touch operation on or near it, it is transmitted to the processor 180 to determine the type of touch event. Subsequently, the processor 180 provides a corresponding visual output on the display panel 141 according to the type of touch event. Although in Figure 1 In the embodiment, the touch panel 131 and the display panel 141 are used as two independent components to implement the input and output functions of the mobile terminal, but in some embodiments, the touch panel 131 and the display panel 141 can be integrated to implement the input and output functions of the mobile terminal.
[0076] The mobile terminal may also include at least one sensor 150, such as a light sensor, a motion sensor, and other sensors. Specifically, the light sensor may include an ambient light sensor and a proximity sensor, wherein the ambient light sensor may adjust the brightness of the display panel 141 according to the brightness of the ambient light, and the proximity sensor may turn off the display panel 141 and / or the backlight when the mobile terminal is moved to the ear. As a type of motion sensor, the accelerometer sensor can detect the magnitude of acceleration in all directions (generally three axes), and can detect the magnitude and direction of gravity when stationary. It can be used for applications that identify the posture of the mobile terminal (such as horizontal and vertical screen switching, related games, magnetometer posture calibration), vibration recognition related functions (such as pedometer, tapping), etc.; as for other sensors that can be configured in the mobile terminal, such as gyroscopes, barometers, hygrometers, thermometers, infrared sensors, etc., they will not be repeated here.
[0077] The speaker 161 and microphone 162 in the audio circuit 160 can provide an audio interface between the user and the mobile terminal. The audio circuit 160 can transmit the received audio data to the speaker 161 after converting the received audio data into an electrical signal, which is converted into a sound signal for output; on the other hand, the microphone 162 converts the collected sound signal into an electrical signal, which is received by the audio circuit 160 and converted into audio data, and then the audio data is output to the processor 180 for processing, and then sent to another mobile terminal through the RF circuit 110, or the audio data is output to the memory 120 for further processing.
[0078] WiFi is a short-range wireless transmission technology. Mobile terminals can help users send and receive emails, browse web pages, and access streaming media through WiFi module 170. It provides users with wireless broadband Internet access. Figure 1 A WiFi module 170 is shown, but it is understandable that it is not an essential component of the mobile terminal and can be omitted as needed without changing the essence of the invention, or replaced with other short-range wireless transmission modules, such as a Zigbee module or a WAPI module.
[0079] The processor 180 is the control center of the mobile terminal. It uses various interfaces and lines to connect various parts of the entire mobile terminal. It executes various functions of the mobile terminal and processes data by running or executing software programs and / or modules stored in the memory 120, and calling data stored in the memory 120, so as to monitor the mobile terminal as a whole. Optionally, the processor 180 may include one or more processing units; preferably, the processor 180 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface and application programs, etc., and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 180.
[0080] The mobile terminal also includes a power supply 190 (such as a battery) for supplying power to various components. Preferably, the power supply can be logically connected to the processor 180 through a power management system, so that the power management system can manage charging, discharging, power consumption and other functions.
[0081] Although not shown, the mobile terminal may also include a camera, a Bluetooth module, etc., which will not be described in detail here.
[0082] In this embodiment, the processor 180 is configured to:
[0083] Get the target question text raised by the user;
[0084] Performing query rewriting on the target question text to generate multiple query texts similar to the target question text, and integrating the target question text and the multiple query texts into a question text set;
[0085] Vectorizing the text in the question text set to generate a question vector set, and integrating the question text set and the question vector set into a question library;
[0086] Retrieving data of a plurality of texts related to the problem text set from a knowledge base by using text keyword retrieval;
[0087] Retrieving vectors of a plurality of texts related to the question vector set from the knowledge base by using vector retrieval;
[0088] A target answer text corresponding to the target question text is generated according to the retrieved data of the plurality of texts and the vectors of the plurality of texts.
[0089] In some embodiments, the processor 180 is further configured to:
[0090] The ranking of each text in the multiple texts is calculated respectively according to the following formula:
[0091]
[0092] in, The ranking of text d among the multiple texts, is the ranking of text d in the plurality of text data, is the ranking of text d in the plurality of text vectors, k is a preset constant, and text d is one of the plurality of texts;
[0093] Filtering out a target text from the multiple texts according to the ranking of each text;
[0094] A target answer text corresponding to the target question text is generated according to the target text.
[0095] In some embodiments, the processor 180 is further configured to:
[0096] Using preset prompt words to perform text polishing on the target text to obtain a prompt text;
[0097] The prompt text is input into a large language model for processing to obtain the target answer text corresponding to the target question text.
[0098] In some embodiments, the processor 180 is further configured to:
[0099] Collect information on target areas;
[0100] Preprocess the unstructured data in the document, extract the text information and store it in a structured manner in a text library;
[0101] Performing vector conversion on the text in the text library to generate a vector library;
[0102] The text library and the vector library are integrated into the knowledge base.
[0103] In some embodiments, the processor 180 is further configured to:
[0104] The output result of the extraction process is obtained as a Python dictionary, each key in the dictionary corresponds to a page number of a document, and the value associated with it is a list, which includes five nested lists:
[0105] The first nested list includes the text content extracted from each text block in the material;
[0106] The second nested list records the formatting information of the text in each text block;
[0107] The third nested list includes the text extracted from the page image;
[0108] The fourth nested list extracts the text information from the table in a structured form;
[0109] The fifth nested list includes the complete text content of the page.
[0110] This embodiment provides an intelligent question-answering method. Figure 2 is a flowchart of a method for intelligent question answering in facility agriculture based on large language model retrieval and enhanced generation according to an embodiment of the present application, such as Figure 2 As shown, the process includes the following steps:
[0111] Step S201, obtaining the target question text raised by the user;
[0112] Step S202, performing query rewriting on the target question text to generate a plurality of query texts similar to the target question text, and integrating the target question text and the plurality of query texts into a question text set;
[0113] Step S203, vectorizing the text in the question text set to generate a question vector set, and integrating the question text set and the question vector set into a question library;
[0114] Step S204, using text keyword search to retrieve data of multiple texts related to the problem text set from the knowledge base;
[0115] Step S205, using vector retrieval to retrieve vectors of multiple texts related to the question vector set from the knowledge base;
[0116] Step S206: Generate a target answer text corresponding to the target question text based on the retrieved data of the multiple texts and the vectors of the multiple texts.
[0117] The target question text in the embodiment of the present application is not limited to the language type, and can be Chinese text or English text, etc., and the length of the target question text is not limited, that is, the target question text can be a sentence text (that is, a collection of individual words) or a paragraph text (that is, a collection of individual sentences), etc. After obtaining the target question text, the embodiment of the present application rewrites the query to generate multiple query texts, performs vectorization processing, and integrates them into a question library to provide rich query resources for the subsequent intelligent question and answer system, and uses a hybrid retrieval strategy to combine sparse retrievers (such as BM25) with dense retrievers (such as embedded similarity) to improve the accuracy and efficiency of retrieval.
[0118] In some embodiments, the step S206 of generating a target answer text corresponding to the target question text according to the retrieved data of the plurality of texts and the vectors of the plurality of texts includes:
[0119] The ranking of each text in the multiple texts is calculated respectively according to the following formula:
[0120]
[0121] in, The ranking of text d among the multiple texts, is the ranking of text d in the plurality of text data, is the ranking of text d in the plurality of text vectors, k is a preset constant, and text d is one of the plurality of texts;
[0122] Filtering out a target text from the multiple texts according to the ranking of each text;
[0123] A target answer text corresponding to the target question text is generated according to the target text.
[0124] In some embodiments, generating a target answer text corresponding to the target question text according to the target text further includes:
[0125] Using preset prompt words to perform text polishing on the target text to obtain a prompt text;
[0126] The prompt text is input into a large language model for processing to obtain the target answer text corresponding to the target question text.
[0127] In some embodiments, before the step S201 obtains the target question text raised by the user, the step further includes:
[0128] Collect information on target areas;
[0129] Preprocess the unstructured data in the document, extract the text information and store it in a structured manner in a text library;
[0130] Performing vector conversion on the text in the text library to generate a vector library;
[0131] The text library and the vector library are integrated into the knowledge base.
[0132] In some embodiments, the preprocessing of the unstructured data in the document, extracting the text information and storing it in a structured manner in a text library includes:
[0133] The output result of the extraction process is obtained as a Python dictionary, each key in the dictionary corresponds to a page number of a document, and the value associated with it is a list, which includes five nested lists:
[0134] The first nested list includes the text content extracted from each text block in the material;
[0135] The second nested list records the formatting information of the text in each text block;
[0136] The third nested list includes the text extracted from the page image;
[0137] The fourth nested list extracts the text information from the table in a structured form;
[0138] The fifth nested list includes the complete text content of the page.
[0139] Through the above steps, the present application solves the problems of low answer accuracy and poor query processing capability existing in the intelligent question and answer system for facility agriculture in the related technology, and achieves the effect of improving the answer accuracy and query processing capability of the intelligent question and answer system for agriculture.
[0140] The embodiments of the present application are described and illustrated below through preferred embodiments.
[0141] Figure 3 is a flow chart of an intelligent question-answering method according to a preferred embodiment of the present application, such as Figure 3 As shown in the figure, the execution process specifically includes:
[0142] (1) Intelligently extract text information from unstructured data in the field of facility agriculture and store it in a structured text library. Specifically, it includes: building a local knowledge base for facility agriculture, widely collecting facility agriculture materials, including: technical regulations reports of local governments, university and enterprise management manuals, and related books. By cleaning redundant data and extracting metadata such as file names, chapter titles, pictures, and tables, the conversion of unstructured text to structured data is achieved, and a comprehensive and standardized local knowledge base in the field of facility agriculture is completed.
[0143] (2) Obtain the user's questions, use the large language model to summarize and rewrite the question information, and use the rewritten multiple similar questions as the expansion of the user's questions to form a question set. Specifically, it includes: using recursive segmentation to divide the local knowledge base text into blocks, and intelligently divide the content according to the hierarchical structure to generate blocks with more coherent semantics.
[0144] (3) Convert the text of the question set into vectors to obtain the vector set of the question. Specifically, it includes:
[0145] The divided text is vectorized in batches, the text data is mapped to a low-dimensional vector space, and the construction of the local knowledge text library and vector library is completed to support efficient retrieval, where the local knowledge base includes the text library and the vector library.
[0146] The user's questions are rewritten, and a large language model is used to generate multiple questions with similar semantics to the original query but different expressions, ensuring that more comprehensive and accurate information can be retrieved from the local knowledge base. All questions (plus the original query) are then vectorized to obtain an online question text library and vector library.
[0147] (4) Based on the hybrid retrieval strategy, the text and vector of the question are retrieved separately, similar data of the text and vector in the local knowledge base are recalled, and similar results are re-ranked based on the reciprocal rank fusion (RRF) to obtain the re-ranked target text block. Specifically, it includes: combining a sparse searcher (such as BM25) with a dense searcher (such as embedding similarity) based on the hybrid retrieval strategy, performing a combination of keyword search and vector search on the data of the online question library and the local knowledge base, synthesizing the results of the two searchers into a single result set through the reciprocal rank fusion (RRF), and re-ranking to obtain a re-ranked text block.
[0148] (5) Based on the large language model and preset prompt words, the target text blocks are integrated and summarized into the answer results corresponding to the user's questions. Specifically, it includes: based on the large language model and preset prompt words, the recalled multiple text blocks are polished and summarized and merged to obtain the answers required by the user. The beneficial effects based on the large language model are as follows: 1. By efficiently and intelligently preprocessing and structuring the unstructured data in the field of facility agriculture, this application greatly improves the automation level of knowledge base construction and the systematic nature of information. The intelligently extracted text information and the subsequent vectorization processing not only optimize the data storage structure, but also provide rich data support for text-based retrieval applications. In particular, the identification and extraction of tabular text in unstructured data increases the diversity and completeness of the knowledge base content; 2. By combining a hybrid retrieval strategy, combining the traditional sparse searcher with the advanced dense searcher, this application further improves the retrieval accuracy and efficiency of the question-answering system. In addition, the application of the reciprocal rank fusion (RRF) algorithm overcomes the inconsistencies and conflicts that may occur between different retrieval strategies, providing users with more accurate search results; 3. By combining a large language model and preset prompt words, this application achieves comprehensive induction and optimization processing of reordered text blocks, improves the quality and coherence of generated answers, effectively meets the consulting needs of users in the field of facility agriculture, and significantly improves the user experience of the intelligent question and answer system.
[0149] Specifically, the implementation method is as follows:
[0150] The initial step of this application is to comprehensively preprocess the multi-structured data in facility agriculture related documents (such as crop growth information, pest and disease treatment plans, climate control data, etc.). The preprocessing includes formatting and structuring data in different forms such as text, pictures, tables, etc. to ensure that the data is accurately identified and converted into a processable format. In terms of text data, semantic analysis and keyword extraction are performed; for picture data, key information is extracted through image recognition technology; and tabular data is converted into structured text information. The system integrates various structured facility agriculture data into the text database for subsequent processing.
[0151] After completing the comprehensive preprocessing of the multi-structured data in the facility agriculture related documents, the text in the question text library is converted into a vector library by adopting advanced text vectorization technology to realize the numerical representation of text data, which is convenient for efficient computer processing. Vectorization technology can use mature word embedding vector models such as Word2Vec and GloVe. The next step of this application is to realize the effective integration of the text information library and the vector database. This integration creates a local knowledge base containing vectors and texts, which not only provides professional facility agriculture texts, but also supports efficient vector-based retrieval.
[0152] To understand the user's questions, this application adopts a query rewriting strategy, using a large language model to generate multiple questions similar to the original query, and then vectorizes all the questions (plus the original query) to obtain an online question text library and a vector library. This embodiment does not limit the specific type of large language model, and the optional large language models include but are not limited to GPT, BERT, T5, etc. These models have their own characteristics. GPT, with its excellent continuous text generation ability, can generate query texts that are highly relevant to the original question; BERT, with its powerful two-way context understanding ability, can deeply explore the complex intentions behind the query; T5 handles a wider range of language tasks through text-to-text conversion. In addition, for Chinese text processing, you can also choose specially optimized models, such as qwen, ERNIE, chatglm, etc. These models perform well in Chinese comprehension ability and can further improve the accuracy of the intelligent question-answering system of this embodiment when processing Chinese facility agriculture data.
[0153] For user query processing, this application adopts a hybrid search strategy that combines traditional sparse search engines and modern dense search engines. First, the system uses the BM25 search engine to search for text keywords in the local knowledge base for the query in order to quickly locate text data related to the query content. Then, the system uses a similarity algorithm to perform vector search in the vector database to find the text vector closest to the user's query vector. Among them, the vector index for modern dense search engines can be selected using hierarchical navigable small worlds, Euclidean distance, and cosine similarity.
[0154] In the hybrid search process, there may be inconsistencies and conflicts between vector search and keyword search results. For example, the two search methods may return different result sets, or the similarity scoring criteria obtained by each search method are different, which will bring challenges to result merging and sorting.
[0155] To solve this problem, this application uses the Reciprocal Rank Fusion (RRF) algorithm to synthesize and reorder the results of the two search engines to improve the quality and credibility of the results. The RRF algorithm performs a reciprocal conversion on the ranking of each search result and combines them by weighted summation to obtain a comprehensive result ranking. Specifically, for a document d, its RRF score calculation formula is as follows:
[0156]
[0157] in They represent the ranking of document d in the BM25 retrieval results and the vector retrieval results respectively, and k is a constant used to adjust the influence of the ranking.
[0158] Through this application, even when faced with different recommendations given by two retrieval methods, the RRF algorithm can effectively merge these recommendations into a more accurate and reliable recommendation list. Finally, the system presents the re-ordered text blocks after comprehensive sorting to the user. On this basis, in order to further improve the quality and coherence of the answers, the system also integrates a post-processing module based on a large language model. This module uses preset prompt words to perform subtle text polishing on multiple recalled text blocks, and performs summarization and merging operations at the same time, so as to extract an accurate, coherent and informative ultimate answer. There is no restriction on the specific type of large language models, and the optional large language models include but are not limited to GPT, BERT, T5, etc. Through this deep level of processing, the intelligent question and answer system can output more fluent and natural text while maintaining a high degree of relevance, effectively meeting the consulting needs of users in the field of facility agriculture.
[0159] Specifically, the flowchart of the retrieval optimization method based on query rewriting is as follows: Figure 4 As shown, the implementation steps are as follows:
[0160] Step S401: Obtain the text of the user's question.
[0161] In this embodiment, the execution subject of the facility agriculture intelligent question-answering method can be an agricultural intelligent question-answering device, which can include but is not limited to: a server, a desktop computer, a laptop computer, a tablet computer, a mobile phone, etc. The execution subject of the agricultural knowledge question-answering method can also be an agricultural knowledge question-answering system, which belongs to the agricultural knowledge question-answering device.
[0162] This application does not limit the language type of the target question text, for example, the target question text can be Chinese text or English text, etc. This embodiment also does not limit the length of the target question text, that is, the target question text can be a sentence text (i.e., a collection of individual words) or a paragraph text (i.e., a collection of individual sentences), etc.
[0163] Step S402: Input the target question text asked by the user into the large language model. The large language model uses its deep learning and language processing capabilities to query and rewrite the target question text, generating multiple query texts that are similar to the original question intent but expressed in different ways. These query texts are then integrated into the question text library for subsequent query and matching operations. Next, by adopting advanced text vectorization technology, the text in the question text library is converted into a vector library to achieve numerical representation of text data, which is convenient for efficient computer processing. Finally, the question text library and the vector library are integrated to form a complete question library, providing rich query resources for the subsequent intelligent question-answering system.
[0164] In this process, the selection of a large language model is crucial. This application does not limit the specific type of large language models, and the optional large language models include but are not limited to GPT, BERT, T5, etc. These models have their own characteristics. GPT, with its outstanding continuous text generation capabilities, can generate query texts that are highly relevant to the original question; BERT, with its powerful two-way context understanding capabilities, can deeply explore the complex intentions behind the query; T5 handles a wider range of language tasks through text-to-text conversion. In addition, for Chinese text processing, you can also choose specially optimized models, such as qwen, ERNIE, chatglm, etc. These models perform well in Chinese comprehension capabilities and can further improve the accuracy of the intelligent question-answering system of this embodiment when processing Chinese facility agriculture data.
[0165] It should be noted that this application does not optimize and adjust the large language model to adapt to the specified field. The large language models used in subsequent steps are all trained based on the above method, which will not be repeated later.
[0166] Furthermore, in order to achieve accurate alignment between question text and document semantics, this application uses a large language model to perform query rewriting operations. Through a carefully designed prompt: "Please play the role of a question conversion expert and rewrite the user's question text to generate multiple queries that match the original question semantics." Figure 1 Please generate at least {specified number} of query texts that are similar but expressed differently, and ensure that each query text is closely related to the intent of the original question. "Wherein, {specified number} should be replaced with the number of query texts you want to generate. Generate query texts that are highly matched with the document semantics. These query texts not only retain the core intent of the original question, but also are closer to the relevant content in the document in terms of expression, thereby improving the accuracy and efficiency of the query. In this way, the intelligent question-answering system of this application can more accurately locate document information related to the user's question and provide users with more accurate and useful answers.
[0167] For ease of understanding, for example, if the user's question is "How to solve powdery mildew of strawberries", {specified number} is set to 3 query texts, and the three questions rewritten are "How to effectively treat powdery mildew of strawberries", "What are the prevention and control methods of powdery mildew of strawberries", and "What are the pesticides for powdery mildew of strawberries". These query texts not only cover the core needs of the user's original question, but also increase the diversity of queries through different expressions, thereby increasing the possibility of matching relevant documents.
[0168] Furthermore, the question text library is converted into a vector library, and a pre-trained word embedding vector model is used. The word embedding vector model is a technology for converting words into vector representations, which can capture the semantic relationship between words, thereby realizing the numerical representation of text. In this application, we can use mature word embedding vector models such as Word2Vec and GloVe. These models are pre-trained on large-scale corpora and can accurately convert text in the question text library into vector representations. In this way, computers can process text data more efficiently, achieve accurate alignment of question text and document semantics, and provide more accurate and useful answers for subsequent intelligent question-answering systems.
[0169] After completing the query rewriting and vectorization of the question text, the next step is to integrate the question text library and the question vector library to achieve the diversity of the question library data. Each text entry in the question text library corresponds to a vector representation in the question vector library. The two are interrelated and together constitute a complete question library.
[0170] It should be noted that this application does not optimize and adjust the word vector embedding model to adapt to the specified field. The word vector embedding models used to determine the feature vectors or word vectors of the text in subsequent steps are all trained based on the above method, which will not be repeated later.
[0171] Step S403: After integrating the question text library and the question vector library, the next key step is to perform hybrid retrieval for each query to obtain relevant documents. Hybrid retrieval combines sparse retrieval and dense retrieval to improve the accuracy and efficiency of retrieval.
[0172] Specifically, hybrid retrieval includes keyword-based retrieval and embedding similarity-based retrieval. Keyword-based retrieval uses traditional text matching technology to find relevant documents by calculating the keyword similarity between the query and the document; embedding similarity-based retrieval pays more attention to the deep meaning of the document content, using the pre-trained word embedding vector model to convert both the query and the document into vector representation, and evaluates the relevance between them by calculating the similarity between the vectors.
[0173] In the hybrid search process, these search methods will be applied to each query separately, and the relevant documents obtained will be merged. By combining the results of different search methods, in addition, in order to further improve the accuracy of the search results, this application will also use the reciprocal sorting fusion algorithm to synthesize and re-rank the results of the two search engines. The reciprocal sorting fusion algorithm converts the rankings of each search result inversely and merges them through weighted summation to obtain a comprehensive result ranking.
[0174] Specifically, the flowchart of the knowledge base construction method based on the preprocessing algorithm is as follows: Figure 5 As shown, the implementation steps are as follows:
[0175] Step S501: Collecting data in the field of facility agriculture.
[0176] In this application, a local knowledge base for facility agriculture is constructed. The content of the local knowledge base includes but is not limited to: technical regulations reports issued by governments in various regions for facility agriculture, academic papers and research reports from universities and research institutions, corporate management manuals, practical guidance books, professional training materials, and practical operation guides, etc.
[0177] This application does not limit the language type of agricultural field data to meet the needs of different user groups. Agricultural field texts can be Chinese texts, English texts, or texts in any other language. This application also does not limit the source of facility agriculture field data, which can come from publicly released data sets, public archives of governments and educational institutions, publications of professional organizations and associations, discussion posts of industry forums and communities, and various types of information publicly available through the Internet.
[0178] Step S502: For each unstructured facility agriculture field data, a preprocessing algorithm is used to intelligently extract text information and store it in a structured manner in a text library, and convert it into a feature vector of the text to construct a vector library. The collection of the text library and the vector library is a knowledge base.
[0179] In this application, in the process of building a knowledge base, a preprocessing algorithm was constructed, and appropriate methods were used to extract text from unstructured facility agriculture field data. Whether it is text in a corpus block with metadata, text in an image, or structured text in a table, it can be effectively extracted. It is particularly worth mentioning that for scanned documents without OCR technology, although the work of identifying and extracting text from images in this application is arduous, it can also be completed accurately.
[0180] The output of the extraction process is a Python dictionary that details every page in the PDF file. Each key in the dictionary corresponds to a page number in the document, and the associated value is a list that contains five nested lists:
[0181] 1. The first nested list contains the text content extracted from each text block in the corpus. This information provides the basic material for building the knowledge base.
[0182] 2. The second nested list records the formatting information of the text in each text block, including metadata such as font-family and font-size. These metadata can help us identify the importance or type of text in subsequent processing, such as titles or highlighted text.
[0183] 3. The third nested list contains the text extracted from the page image, which expands the text coverage of the knowledge base and makes it more comprehensive.
[0184] 4. The fourth nested list extracts the text information in the table in a structured form. This structured storage method not only retains the original structure of the table data, but also significantly improves the quality of reasoning about the relationships in the extracted data, making the knowledge base more efficient in processing complex queries.
[0185] 5. The fifth nested list contains the complete text content of the page, which provides us with a global perspective and helps us understand the overall structure and content of the document.
[0186] In addition, this application also retains image information during the extraction process. These images can be used as part of the knowledge base and complement the text information to jointly build a rich and complete knowledge base.
[0187] This processing method not only achieves a more logical separation of the text extracted from each facility agriculture field, but also makes it easier to retrieve information in a specific component. For example, the company name in the LOGO or the corresponding relationship between the data in the table can be easily retrieved, which greatly improves the practicality and convenience of the knowledge base.
[0188] For ease of understanding, for example, taking a document about the planting schedule of lettuce in different regions as an example, the preprocessing algorithm of this application can intelligently extract the text information therein, including key contents such as planting time, region, and lettuce variety. At the same time, the algorithm can also record the format and location information of this information to facilitate subsequent retrieval and analysis.
[0189] In addition, the method of vectorizing the local knowledge base text, generating a knowledge vector library, and integrating the text library and the vector library into a knowledge base refers to the process step S402 of the above-mentioned query rewriting-based retrieval optimization method, which will not be described in detail here.
[0190] This preferred embodiment can achieve the following technical effects:
[0191] 1. Enriching the coverage of professional knowledge: This application significantly enhances the system's coverage and understanding of professional knowledge in facility agriculture by widely collecting information on facility agriculture and combining it with query rewriting of user questions, enabling the system to provide more accurate and specific answers to meet the actual operational needs of professionals and farmers in the agricultural field.
[0192] 2. Optimize knowledge base construction and management: Utilize preprocessing algorithms to efficiently convert and structure unstructured data, optimize the knowledge base construction process, and improve data utilization efficiency and system maintenance convenience.
[0193] 3. Improve the accuracy and relevance of answers: Through the hybrid retrieval strategy and the Reciprocal Ranking Fusion (RRF) algorithm, as well as the polishing processing of the large language model, the accuracy of the answers and the natural fluency of the text are significantly improved while ensuring the high relevance of the answers.
[0194] 4. Enhanced processing capabilities for complex queries: The query rewriting mechanism and hybrid retrieval strategy of this application effectively improve the system's ability to handle complex queries, and can comprehensively analyze and answer complex problems involving multiple aspects of information, providing users with comprehensive and in-depth solutions.
[0195] 5. Improve user interaction experience: By providing professional guidance and answers quickly and accurately, this application significantly improves the user's interaction experience and enhances the user's trust and satisfaction with the system.
[0196] This preferred embodiment is based on an intelligent question-and-answer method, which builds a local knowledge base by collecting specific production processes and operation documents in the field of facility agriculture, and uses retrieval-enhanced generation technology to integrate deep learning and hybrid information retrieval. This technology quickly generates answers that are highly relevant to user queries by retrieving agricultural data and using large language models, thereby improving the relevance of intelligent question-and-answer text generation in facility agriculture, meeting the refined demand guidance of agricultural professionals and farmers in actual operations, and significantly improving response accuracy and the ability to handle complex problems.
[0197] It should be noted that the steps shown in the above process or the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0198] This embodiment provides a facility agriculture intelligent question-answering device based on large language model retrieval enhancement generation, which is used to implement the above-mentioned embodiments and preferred implementation modes, and will not be repeated hereafter. As used below, the terms "module", "unit", "subunit", etc. can implement a combination of software and / or hardware for a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceived.
[0199] Figure 6 is a structural block diagram of a facility agriculture intelligent question-answering device based on large language model retrieval enhanced generation according to an embodiment of the present application, such as Figure 6 As shown, the device comprises:
[0200] An acquisition unit 61 is used to acquire a target question text raised by a user;
[0201] A rewriting unit 62, configured to perform query rewriting on the target question text, generate a plurality of query texts similar to the target question text, and integrate the target question text and the plurality of query texts into a question text set;
[0202] A first generating unit 63 is used to perform vectorization processing on the text in the question text set to generate a question vector set, and integrate the question text set and the question vector set into a question library;
[0203] A first retrieval unit 64 is used to retrieve data of a plurality of texts related to the problem text set from the knowledge base using text keyword retrieval;
[0204] A second retrieval unit 65 is used to retrieve vectors of multiple texts related to the question vector set from the knowledge base by using vector retrieval;
[0205] The second generating unit 66 is used to generate a target answer text corresponding to the target question text according to the retrieved data of the multiple texts and the vectors of the multiple texts.
[0206] In some embodiments, the second generating unit 66 includes:
[0207] The calculation module is used to calculate the ranking of each text in the multiple texts according to the following formula:
[0208]
[0209] in, The ranking of text d among the multiple texts, is the ranking of text d in the plurality of text data, is the ranking of text d in the plurality of text vectors, k is a preset constant, and text d is one of the plurality of texts;
[0210] A screening module, used for screening out a target text from the plurality of texts according to the ranking of each text;
[0211] A generation module is used to generate a target answer text corresponding to the target question text based on the target text.
[0212] In some embodiments, the second generating unit 66 further includes:
[0213] The first processing submodule is used for generating a module, and uses a preset prompt word to perform text polishing on the target text to obtain a prompt text;
[0214] The second processing submodule is used to input the prompt text into the large language model for processing to obtain the target answer text corresponding to the target question text.
[0215] In some embodiments, the device further comprises:
[0216] A collecting unit, used for collecting data in a target field before obtaining the target question text raised by the user;
[0217] An extraction unit, used to pre-process the unstructured data in the document, extract the text information and store it in a structured manner in a text library;
[0218] A conversion unit, used for performing vector conversion on the text in the text library to generate a vector library;
[0219] An integration unit is used to integrate the text library and the vector library into the knowledge base.
[0220] In some embodiments, the extraction unit comprises:
[0221] The output module is used to pre-process the unstructured data in the document, extract the text information and store it in a structured manner in the text library, and obtain the output result of the extraction process as a Python dictionary. Each key in the dictionary corresponds to a page number of a document, and the value associated with it is a list, which includes five nested lists:
[0222] The first nested list includes the text content extracted from each text block in the material;
[0223] The second nested list records the formatting information of the text in each text block;
[0224] The third nested list includes the text extracted from the page image;
[0225] The fourth nested list extracts the text information from the table in a structured form;
[0226] The fifth nested list includes the complete text content of the page.
[0227] It should be noted that the above modules can be functional modules or program modules, and can be implemented by software or hardware. For modules implemented by hardware, the above modules can be located in the same processor; or the above modules can be located in different processors in any combination.
[0228] The embodiment provides a computer device. In combination with the intelligent question-answering method of the embodiment of the present application, the computer device can be used to implement it. Figure 7 Schematic diagram of the hardware structure of a computer device according to an embodiment of the present application.
[0229] The computer device may include a processor 71 and a memory 72 storing computer program instructions.
[0230] Specifically, the processor 71 may include a central processing unit (CPU), or an application specific integrated circuit (ASIC), or may be configured to implement one or more integrated circuits of the embodiments of the present application.
[0231] Among them, the memory 72 may include a large-capacity memory for data or instructions. By way of example and not limitation, the memory 72 may include a hard disk drive (HDD), a floppy disk drive, a solid-state drive (SSD), a flash memory, an optical disk, a magneto-optical disk, a magnetic tape, or a universal serial bus (USB) drive, or a combination of two or more of these. Where appropriate, the memory 72 may include a removable or non-removable (or fixed) medium. Where appropriate, the memory 72 may be inside or outside the data processing device. In a specific embodiment, the memory 72 is a non-volatile memory. In a specific embodiment, the memory 72 includes a read-only memory (ROM) and a random access memory (RAM). Where appropriate, the ROM may be a mask-programmed ROM, a programmable ROM (Programmable Read-Only Memory, PROM for short), an erasable PROM (Erasable ProgrammableRead-Only Memory, EPROM for short), an electrically erasable PROM (Electrically Erasable ProgrammableRead-Only Memory, EEPROM for short), an electrically alterable ROM (Electrically Alterable Read-Only Memory, EAROM for short) or a flash memory (FLASH) or a combination of two or more of these. Under appropriate circumstances, the RAM can be a static random access memory (SRAM) or a dynamic random access memory (DRAM), wherein the DRAM can be a fast page mode dynamic random access memory (FPMDRAM), an extended data output dynamic random access memory (EDODRAM), a synchronous dynamic random access memory (SDRAM), etc.
[0232] The memory 72 may be used to store or cache various data files required for processing and / or communication, as well as possible computer program instructions executed by the processor 71 .
[0233] The processor 71 reads and executes computer program instructions stored in the memory 72 to implement any one of the intelligent question-answering methods for facility agriculture based on large language model retrieval and enhanced generation in the above-mentioned embodiments.
[0234] In some embodiments, the computer device may further include a communication interface 73 and a bus 70. Figure 7 As shown, the processor 71, the memory 72, and the communication interface 73 are connected via a bus 70 and communicate with each other.
[0235] The communication interface 73 is used to implement communication between the modules, devices, units and / or equipment in the embodiment of the present application. The communication interface 73 can also implement data communication with other components such as: external devices, image / data acquisition equipment, databases, external storage, and image / data processing workstations.
[0236] The bus 70 includes hardware, software or both, and couples the components of the computer device to each other. The bus 70 includes but is not limited to at least one of the following: a data bus, an address bus, a control bus, an expansion bus, and a local bus. By way of example and not limitation, bus 70 may include an Accelerated Graphics Port (AGP) or other graphics bus, an Extended Industry Standard Architecture (EISA) bus, a Front Side Bus (FSB), a Hyper Transport (HT) interconnect, an Industry Standard Architecture (ISA) bus, an InfiniBand interconnect, a Low Pin Count (LPC) bus, a memory bus, a Micro Channel Architecture (MCA) bus, a Peripheral Component Interconnect (PCI) bus, a PCI-Express (PCI-X) bus, a Serial Advanced Technology Attachment (SATA) bus, a Video Electronics Standards Association Local Bus (VLB) bus, or other suitable buses or a combination of two or more of these. Where appropriate, bus 50 may include one or more buses. Although embodiments of the present application describe and illustrate a particular bus, the present application contemplates any suitable bus or interconnect.
[0237] In addition, in combination with the facility agriculture intelligent question-answering method based on large language model retrieval enhancement generation in the above embodiment, the embodiment of the present application can provide a computer-readable storage medium for implementation. The computer-readable storage medium stores computer program instructions; when the computer program instructions are executed by the processor, any facility agriculture intelligent question-answering method based on large language model retrieval enhancement generation in the above embodiment is implemented.
[0238] The technical features of the above-described embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above-described embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0239] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.
Claims
1. A facility agriculture intelligent question answering method based on large language model retrieval enhanced generation, characterized in that: include: Get the target question text raised by the user; Performing query rewriting on the target question text to generate multiple query texts similar to the target question text, and integrating the target question text and the multiple query texts into a question text set; Vectorizing the text in the question text set to generate a question vector set, and integrating the question text set and the question vector set into a question library; Retrieving data of a plurality of texts related to the problem text set from a knowledge base by using text keyword retrieval; Retrieving vectors of a plurality of texts related to the question vector set from the knowledge base by using vector retrieval; A target answer text corresponding to the target question text is generated according to the retrieved data of the plurality of texts and the vectors of the plurality of texts.
2. The method according to claim 1, characterized in that The step of generating a target answer text corresponding to the target question text according to the retrieved data of the plurality of texts and the vectors of the plurality of texts comprises: The ranking of each text in the multiple texts is calculated respectively according to the following formula: in, The ranking of text d among the multiple texts, is the ranking of text d in the plurality of text data, is the ranking of text d in the plurality of text vectors, k is a preset constant, and text d is one of the plurality of texts; Filtering out a target text from the multiple texts according to the ranking of each text; A target answer text corresponding to the target question text is generated according to the target text.
3. The method according to claim 2, characterized in that The step of generating a target answer text corresponding to the target question text according to the target text includes: Using preset prompt words to perform text polishing on the target text to obtain a prompt text; The prompt text is input into a large language model for processing to obtain the target answer text corresponding to the target question text.
4. The method according to claim 1, characterized in that: Before obtaining the target question text raised by the user, the method further includes: Collect information on target areas; Preprocess the unstructured data in the document, extract the text information and store it in a structured manner in a text library; Performing vector conversion on the text in the text library to generate a vector library; The text library and the vector library are integrated into the knowledge base.
5. The method according to claim 4, characterized in that The preprocessing of the unstructured data in the document, extracting the text information and storing it in a structured manner in a text library includes: The output result of the extraction process is obtained as a Python dictionary, each key in the dictionary corresponds to a page number of a document, and the value associated with it is a list, which includes five nested lists: The first nested list includes the text content extracted from each text block in the material; The second nested list records the formatting information of the text in each text block; The third nested list includes the text extracted from the page image; The fourth nested list extracts the text information from the table in a structured form; The fifth nested list includes the complete text content of the page.
6. A facility agriculture intelligent question-answering device based on large language model retrieval and enhanced generation, characterized in that: include: An acquisition unit, used for acquiring a target question text raised by a user; A rewriting unit, configured to perform query rewriting on the target question text, generate a plurality of query texts similar to the target question text, and integrate the target question text and the plurality of query texts into a question text set; A first generating unit is used to perform vectorization processing on the text in the question text set to generate a question vector set, and integrate the question text set and the question vector set into a question library; A first retrieval unit, used to retrieve data of a plurality of texts related to the problem text set from a knowledge base by using text keyword retrieval; A second retrieval unit, configured to retrieve vectors of a plurality of texts related to the question vector set from the knowledge base by using vector retrieval; The second generating unit is used to generate a target answer text corresponding to the target question text according to the retrieved data of the multiple texts and the vectors of the multiple texts.
7. The method according to claim 6, characterized in that The second generating unit comprises: The calculation module is used to calculate the ranking of each text in the multiple texts according to the following formula: in, The ranking of text d among the multiple texts, is the ranking of text d in the plurality of text data, is the ranking of text d in the plurality of text vectors, k is a preset constant, and text d is one of the plurality of texts; A screening module, used for screening out a target text from the plurality of texts according to the ranking of each text; A generation module is used to generate a target answer text corresponding to the target question text based on the target text.
8. The device according to claim 7, characterized in that The generation module comprises: The first processing submodule is used to perform text polishing on the target text using preset prompt words to obtain a prompt text; The second processing submodule is used to input the prompt text into the large language model for processing to obtain the target answer text corresponding to the target question text.
9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 5 is implemented.
10. A computer storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 5 is implemented.
Citation Information
Patent Citations
Agricultural intelligent question and answer method and system supporting multi-mode and multi-round dialogues
CN117370506A
Method and system for constructing traffic construction industry standard knowledge base by using ChatGPT
CN117370527A
Document question and answer method based on multi-granularity mixed retrieval and verification editing reasoning framework
CN117435713A
Knowledge question-answering method and device, equipment and storage medium
CN117573821A
Question and answer method and system with traceability based on multi-source knowledge base
CN117874190A
Cited By
Automobile intelligent question-answering system and method based on large model and retrieval enhancement
CN119202206A
Large model retrieval enhancement generation method oriented to policies in electricity price field
CN119940512A
Dialogue method and device based on multi-modal large model, equipment and storage medium
CN120448507A
