Agricultural question reply method and device based on spatio-temporal information and storage medium

By using the user's latitude and longitude and time information to match the local agricultural knowledge base to obtain crop growth entries, combined with text information to enter the agricultural language model, it solves the problem of low agricultural questions in existing technologies, and improves the accuracy of the answer.

CN119357330APending Publication Date: 2025-01-24HUBEI TAIYUE SATELLITE TECH DEV CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411429762.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-14
Publication Date
2025-01-24

AI Technical Summary

Technical Problem

When dealing with agricultural problems, the existing agricultural language model ignores part of the information of the crop, resulting in low matching between the output answer and the input question.

Method used

By obtaining the latitude and longitude information and time information of the agricultural problem entered by the user, it matches the local agricultural knowledge base to obtain the related agricultural crop growth entries, and input to the agricultural language model with text information to obtain the answer.

Benefits of technology

The output accuracy of the agricultural language model is improved, and the answer is more matched and appropriate to the answer.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119357330A_ABST
    Figure CN119357330A_ABST
Patent Text Reader

Abstract

The invention provides an agricultural question answering method and device based on spatio-temporal information and a storage medium, and relates to the technical field of computers. The method comprises the following steps: acquiring attribute information and text information corresponding to an agricultural problem; matching a local agricultural knowledge base based on the attribute information and the text information, and obtaining associated crop growth entries corresponding to the agricultural problem; and inputting the text information and the associated crop growth entries into an agricultural language model, and determining answers corresponding to the agricultural questions according to the output of the agricultural language model. The agricultural language model not only refers to the text information of the agricultural problem, but also refers to the background information provided by the related crop growth items, and the output answer is more adaptive to the input agricultural problem. Therefore, the output precision degree of the agricultural language model is greatly improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computers, and in particular to a method, device and storage medium for answering agricultural questions based on spatiotemporal information. Background Art

[0002] With the rapid development of agricultural technology and science, the concept of smart agriculture is becoming more and more popular. The neural network model is the key technical support for smart agriculture. With its powerful self-learning and nonlinear processing capabilities, the neural network model can effectively process multivariate data such as soil, climate, and crop growth status. Among them, the agricultural language model is one of the most commonly used neural network models in the agricultural field.

[0003] The agricultural language module is a natural language processing tool specifically for the agricultural field. It can answer various agricultural-related questions and provide convenient agricultural information query channels for farmers, agricultural enterprises, and agricultural researchers. Existing agricultural language models are all trained based on a large amount of agricultural text data. This training method often focuses more on the text of the agricultural text data itself, while ignoring part of the information about crops reflected in the agricultural text data. This will lead to the problem that the answers output by the agricultural language model have a low match with the input questions. Therefore, how to improve the output accuracy of the agricultural language model to obtain answers that are more matched and more appropriate to the input questions has become an urgent problem to be solved. Summary of the invention

[0004] In view of this, the present invention proposes a method, device and storage medium for answering agricultural questions based on spatiotemporal information. Specifically, before using the agricultural language model to obtain the answer to the agricultural question, the user's longitude and latitude information and the user input time information when the user inputs the agricultural question, as well as the text information of the agricultural question itself, are matched to the associated crop growth entry in the local agricultural knowledge base, wherein the local agricultural knowledge base is used to record the historical growth data of the crop, and each entry is used to record the associated crop longitude and latitude information, crop growth status collection time information and crop growth status data information. Therefore, by associating the crop growth entry, the growth longitude and latitude, growth time, growth status and other characteristics of the crop itself reflected in the agricultural question can be extracted, and then the text of the associated crop growth entry and the text of the agricultural question are input into the agricultural language model to obtain the answer. In this way, the agricultural language model not only refers to the text information of the agricultural question, but also refers to the characteristics of the crop itself reflected in the agricultural question, and the output answer is more adapted to the input agricultural question. Therefore, the output accuracy of the agricultural language model is greatly improved.

[0005] The first aspect of the present invention provides an agricultural problem answering method based on spatiotemporal information, the method comprising:

[0006] Acquire attribute information and text information corresponding to the agricultural question; the attribute information includes user latitude and longitude information and user input time information; the user latitude and longitude information is used to indicate the latitude and longitude coordinates when the user inputs the agricultural question, and the user input time information is used to indicate the time when the user inputs the agricultural question;

[0007] Matching the local agricultural knowledge base based on the attribute information and the text information to obtain the associated crop growth items corresponding to the agricultural problem; wherein the local agricultural knowledge base includes a plurality of crop growth items; each of the plurality of crop growth items is used to record the mapping relationship between the crop longitude and latitude information, the crop growth status collection time information, and the crop growth status data information;

[0008] The text information and related crop growth items are input into the agricultural language model, and the answer corresponding to the agricultural question is determined based on the output of the agricultural language model; the agricultural language model is trained based on all agricultural question samples and the question answer sample labels corresponding to each agricultural question sample, and each agricultural question sample includes at least sample text information and sample related crop growth items.

[0009] In an optional implementation, the local agricultural knowledge base is matched based on the attribute information and the text information to obtain the associated crop growth items corresponding to the agricultural problem, including:

[0010] Determine the matching value between the agricultural problem and each crop growth entry based on the attribute information and text information;

[0011] The crop growth entry with the highest matching value in each crop growth entry is determined as the associated crop growth entry corresponding to the agricultural problem.

[0012] In an optional implementation, determining the matching value between the agricultural question and each crop growth entry based on the attribute information and the text information includes:

[0013] For each crop growth entry, a first indicator value is determined according to the user longitude and latitude information and the crop longitude and latitude information; the first indicator value is used to indicate the distance difference between the longitude and latitude corresponding to the user longitude and latitude information and the longitude and latitude corresponding to the crop longitude and latitude information;

[0014] Determine a second index value according to the time information input by the user and the time information of crop growth status collection; the second index value is used to indicate the degree of proximity between the time information input by the user and the time information of crop growth status collection;

[0015] Determine a third index value according to the text information and the crop growth status data information; the third index value is used to indicate the degree of textual association between the text information and the crop growth status data information;

[0016] A matching value is determined according to the first index value, the second index value and the third index value.

[0017] In an optional implementation, determining the matching value according to the first index value, the second index value, and the third index value includes:

[0018] Determine respectively a first weight value corresponding to the first indicator value, a second weight value corresponding to the second indicator value, and a third weight value corresponding to the third indicator value; wherein the sum of the first weight value, the second weight value, and the third weight value is 1; the first weight value, the second weight value, and the third weight value are all greater than or equal to 0, and the first weight value and the second weight value are not 0 at the same time;

[0019] A matching value is determined according to the first index value, the second index value, the third index value, the first weight value, the second weight value and the third weight value.

[0020] In an optional implementation, determining the third indicator value according to the text information and the crop growth status data information includes:

[0021] Convert the text information and the crop growth status data information respectively to obtain a first word vector corresponding to the text information and a second word vector corresponding to the crop growth status data information;

[0022] A third index value is determined according to the similarity between the first word vector and the second word vector.

[0023] In an optional implementation, the longitude and latitude coordinates corresponding to the longitude and latitude information of the user are (lon2, lat2), and the longitude and latitude coordinates corresponding to the longitude and latitude information of the crop are (lon1, lat1). The calculation formula of the first indicator value is:

[0024]

[0025] Among them, Index d Used to indicate the first index value; d(lon2, lat2, lon1, lat1) is used to indicate the distance between (lon2, lat2) and (lon1, lat1); D max The preset maximum distance threshold.

[0026] In an optional implementation, the time corresponding to the time information input by the user is t2, and the time information of crop growth status collection is t1; determining the second indicator value according to the time information input by the user and the time information of crop growth status collection includes:

[0027] Determine the time period length T and the attenuation coefficient k corresponding to the time period length T;

[0028] Determine the proximity between t2 and t1 based on the time period T and the attenuation coefficient k;

[0029] The second index value is determined according to the proximity between t2 and t1.

[0030] In an optional implementation, the calculation formula of the second index value is:

[0031]

[0032] Among them, Index t Used to indicate the second indicator value; year(t1) is used to indicate the time period corresponding to t1; year(t2) is used to indicate the time period corresponding to t2; year(t2)-year(t1) is used to indicate the number of time periods between t2 and t1.

[0033] A second aspect of the present invention provides an agricultural question answering device based on spatiotemporal information, the device comprising:

[0034] An acquisition unit, used to acquire attribute information and text information corresponding to the agricultural question; the attribute information includes user longitude and latitude information and user input time information; the user longitude and latitude information is used to indicate the longitude and latitude coordinates when the user inputs the agricultural question, and the user input time information is used to indicate the time when the user inputs the agricultural question;

[0035] A processing unit is used to match the local agricultural knowledge base based on the attribute information and the text information to obtain the associated crop growth items corresponding to the agricultural problem; wherein the local agricultural knowledge base includes a plurality of crop growth items; each of the plurality of crop growth items is used to record the mapping relationship between the crop longitude and latitude information, the crop growth status collection time information, and the crop growth status data information;

[0036] The transceiver unit is used to input text information and related crop growth items into the agricultural language model, and determine the answer corresponding to the agricultural question based on the output of the agricultural language model; the agricultural language model is trained based on all agricultural question samples and the question answer sample labels corresponding to each agricultural question sample, and each agricultural question sample at least includes sample text information and sample related crop growth items.

[0037] In an optional embodiment, the processing unit is specifically used to determine the matching value between the agricultural problem and each crop growth entry based on attribute information and text information; and determine the crop growth entry with the highest matching value in each crop growth entry as the associated crop growth entry corresponding to the agricultural problem.

[0038] In an optional embodiment, the processing unit is specifically used to determine a first indicator value for each crop growth entry based on the user's longitude and latitude information and the crop's longitude and latitude information; the first indicator value is used to indicate the distance difference between the longitude and latitude corresponding to the user's longitude and latitude information and the longitude and latitude corresponding to the crop's longitude and latitude information; determine a second indicator value based on the user's input time information and the crop growth status collection time information; the second indicator value is used to indicate the proximity between the user's input time information and the crop growth status collection time information; determine a third indicator value based on the text information and the crop growth status data information; the third indicator value is used to indicate the degree of textual association between the text information and the crop growth status data information; determine a matching value based on the first indicator value, the second indicator value and the third indicator value.

[0039] In an optional embodiment, the processing unit is specifically used to respectively determine a first weight value corresponding to the first indicator value, a second weight value corresponding to the second indicator value, and a third weight value corresponding to the third indicator value; wherein the sum of the first weight value, the second weight value, and the third weight value is 1; the first weight value, the second weight value, and the third weight value are all greater than or equal to 0, and the first weight value and the second weight value are not 0 at the same time; the matching value is determined according to the first indicator value, the second indicator value, the third indicator value, the first weight value, the second weight value, and the third weight value.

[0040] In an optional embodiment, the processing unit is specifically used to convert the text information and the crop growth status data information respectively to obtain a first word vector corresponding to the text information and a second word vector corresponding to the crop growth status data information; and determine the third indicator value based on the similarity between the first word vector and the second word vector.

[0041] In an optional implementation, the longitude and latitude coordinates corresponding to the longitude and latitude information of the user are (lon2, lat2), and the longitude and latitude coordinates corresponding to the longitude and latitude information of the crop are (lon1, lat1). The calculation formula of the first indicator value is:

[0042]

[0043] Among them, Index d Used to indicate the first index value; d(lon2, lat2, lon1, lat1) is used to indicate the distance between (lon2, lat2) and (lon1, lat1); D max The preset maximum distance threshold.

[0044] In an optional embodiment, the time corresponding to the time information input by the user is t2, and the time information for collecting the crop growth status is t1; the processing unit is specifically used to determine the time period length T and the attenuation coefficient k corresponding to the time period length T; determine the degree of proximity between t2 and t1 according to the time period T and the attenuation coefficient k; determine the second indicator value according to the degree of proximity between t2 and t1.

[0045] In an optional implementation, the calculation formula of the second index value is:

[0046]

[0047] Among them, Index t Used to indicate the second indicator value; year(t1) is used to indicate the time period corresponding to t1; year(t2) is used to indicate the time period corresponding to t2; year(t2)-year(t1) is used to indicate the number of time periods between t2 and t1.

[0048] The third aspect of the present invention provides a device for answering agricultural questions, which includes a processor and a memory; the processor is coupled to the memory; the memory is used to store computer instructions, and the computer instructions are loaded and executed by the processor so that the answering device implements the method described in the first aspect and any one of the embodiments of the first aspect.

[0049] A fourth aspect of the present invention provides a computer-readable storage medium storing computer instructions; the computer instructions enable the computer to execute the method described in the first aspect and any one of the embodiments of the first aspect.

[0050] The agricultural question answering method, device and storage medium based on spatiotemporal information provided by the present invention have the following beneficial effects compared with the prior art:

[0051] (1) The present invention identifies and responds to agricultural questions input by users based on an agricultural language model. Before inputting the agricultural questions raised by users into the agricultural language model, the local agricultural knowledge base is first matched based on the user's latitude and longitude information when the user raises the agricultural question, the user input time information, and the text information of the agricultural question itself, so as to obtain the most relevant agricultural growth items in the local agricultural knowledge base that are related to the agricultural question. It can be understood that the agricultural growth items in the local agricultural knowledge base are used to record the growth conditions of crops at different times and in different regions, and the most relevant agricultural growth items found to be related to the agricultural question can be used as background information and supplementary information for the agricultural question. In this way, after the related agricultural growth items and agricultural questions are input into the agricultural language model, the agricultural language model can obtain more features and input information, so as to more fully analyze and identify the text semantics, so as to generate more accurate, detailed, and more suitable responses for the agricultural model.

[0052] (2) The growth status of crops is closely related to the geographical location and growth time. The related agricultural growth items matched based on the user's latitude and longitude information and the user's input time information can more fully consider the latitude and longitude features and time features, so that the latitude and longitude features and time features will not be obscured by other features. In this way, the related agricultural growth items, as the most relevant context information for agricultural issues, can be input into the agricultural language model, which can greatly improve the recognition efficiency of the agricultural language model and greatly improve the recognition and response performance of the agricultural language model.

[0053] (3) When matching the local agricultural knowledge base, the present invention measures based on three dimensions: longitude and latitude (geographic location), time, and text. Specifically, for each crop growth entry in the local agricultural knowledge base, the user's longitude and latitude information is compared with the crop's longitude and latitude information to obtain a first index value, the second index value is determined based on the user's input time information and the crop growth status collection time information, and the third index value is determined based on the text information of the agricultural problem and the crop growth status data information; finally, a comprehensive matching value is determined based on the first index value, the second index value, and the third index value, and the final associated agricultural growth entry is determined based on the comprehensive ratio configuration. In this way, multiple feature fusions are achieved, and the most relevant crop growth status data is obtained from multiple dimensions, providing the best background information support for agricultural issues. BRIEF DESCRIPTION OF THE DRAWINGS

[0054] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0055] Figure 1 A flowchart of a method for answering agricultural questions based on spatiotemporal information provided in an embodiment of the present application;

[0056] Figure 2 A flow chart of a method for calculating matching values ​​between crop growth items and agricultural problems provided in an embodiment of the present application;

[0057] Figure 3 A processing flow chart for processing agricultural problems provided in an embodiment of the present application;

[0058] Figure 4 A schematic diagram of the structure of an agricultural question answering device based on spatiotemporal information provided in an embodiment of the present application;

[0059] Figure 5 A schematic diagram of the structure of a device for answering agricultural questions provided in an embodiment of the present application. DETAILED DESCRIPTION

[0060] The following will be combined with the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0061] The agricultural language module is a natural language processing tool specifically for the agricultural field. It can answer various agricultural-related questions and provide convenient agricultural information query channels for farmers, agricultural enterprises, and agricultural researchers. Existing agricultural language models are all trained based on a large amount of agricultural text data. This training method often focuses more on the text of the agricultural text data itself, while ignoring part of the information about crops reflected in the agricultural text data. This will lead to the problem that the answers output by the agricultural language model have a low match with the input questions. Therefore, how to improve the output accuracy of the agricultural language model to obtain answers that are more matched and more appropriate to the input questions has become an urgent problem to be solved.

[0062] In view of the above problems, the present invention proposes a method, device and storage medium for answering agricultural questions based on spatiotemporal information. Specifically, before using the agricultural language model to obtain the answer to the agricultural question, the user's longitude and latitude information and the user input time information when the user inputs the agricultural question, as well as the text information of the agricultural question itself, are matched to the associated crop growth entry in the local agricultural knowledge base, wherein the local agricultural knowledge base is used to record the historical growth data of the crop, and each entry is used to record the associated crop longitude and latitude information, crop growth status collection time information and crop growth status data information. Therefore, by associating the crop growth entry, the growth longitude and latitude, growth time, growth status and other characteristics of the crop itself reflected in the agricultural question can be extracted, and then the text of the associated crop growth entry and the text of the agricultural question are input into the agricultural language model to obtain the answer. In this way, the agricultural language model not only refers to the text information of the agricultural question, but also refers to the characteristics of the crop itself reflected in the agricultural question, and the output answer is more adapted to the input agricultural question. Therefore, the output accuracy of the agricultural language model is greatly improved.

[0063] Before introducing the embodiments of the present application, the local agricultural knowledge base is introduced first:

[0064] In the digital village, geographic information, time information, and growth status data can be collected for crops, and a local agricultural knowledge base can be built based on this. For example, data on the growth process of various crops can be collected through sensors. These data include the latitude and longitude information of the sensor (the specific location of the collection point), the collection time, and various growth status data. For example, soil moisture, pest and disease conditions, crop varieties and growth, etc. Then a local agricultural knowledge base is formed based on these data. It can be understood that this information reflects the dynamic growth process of crops and is an important reference for activities such as crop cultivation, management, and planting.

[0065] Exemplarily, the formed local agricultural knowledge base records the collected data from three dimensions, and specifically, may include multiple crop growth entries, each of which is used to record the mapping relationship between crop longitude and latitude information, crop growth status collection time information, and crop growth status data information. Among them, the crop longitude and latitude information and the crop growth status collection time information are directly from the sensor, while the crop growth status data information can be generated by a specified template. That is, various types of growth status data are summarized by specifying a document template. As a specific example, the document template may be: under the condition of {soil moisture}, {pests and diseases} appear in {crop varieties}, and their growth is {crop growth}. It can be understood that the embodiment of the present application does not limit the specific form of the document template, and the crop growth status data information only needs to reflect the collected growth data of each crop.

[0066] Based on the above description, the crop knowledge base is a query database that records various data of the dynamic growth process of crops. When a user needs to query relevant data, it is necessary to match the relevant crop growth items for feedback. Exemplarily, the query can be matched by the three dimensions of longitude and latitude, time, and crop growth status. Among them, when querying based on the dimension of crop growth status, the crop growth status data information can be converted into word vectors, and then matched based on the word vectors. Therefore, each crop growth item in the crop knowledge base can also add the word vector information corresponding to the crop growth status data information to facilitate user query.

[0067] Based on the above local agricultural knowledge base, Figure 1 A flowchart of a method for answering agricultural questions based on spatiotemporal information provided in an embodiment of the present application. Figure 1 As shown, the agricultural problem answering method based on spatiotemporal information includes the following steps:

[0068] 101. Obtain attribute information and text information corresponding to agricultural issues.

[0069] First, the agricultural question input by the user is obtained. The attribute information corresponding to the agricultural question is determined according to the user's latitude and longitude coordinates and input time when the user inputs the agricultural question, and the text information is determined according to the language of the agricultural question input by the user. Therefore, each agricultural question corresponds to the user's latitude and longitude information, the user input time information, and the text information. These features fully reflect the text semantics of the agricultural question, which is convenient for improving the accuracy of the subsequent agricultural language model in identifying and answering agricultural questions.

[0070] 102. Match the local agricultural knowledge base based on the attribute information and text information to obtain the related crop growth items corresponding to the agricultural problem.

[0071] Then, we need to consider three dimensions and match the most relevant crop growth items from the local agricultural knowledge base. Among them, the related crop growth items, as supplementary information for agricultural issues, can more fully consider the latitude and longitude characteristics and time characteristics. In this way, the related agricultural growth items, as the most relevant context information for agricultural issues, are input into the agricultural language model, which can greatly improve the recognition efficiency of the agricultural language model and greatly improve the recognition and response performance of the agricultural language model.

[0072] For example, when matching, it is necessary to determine the matching value between the agricultural problem and each crop growth item in the local agricultural knowledge base based on the attribute information and text information, and then, according to the matching value corresponding to each crop growth item, the crop growth item with the highest matching value is used as the associated crop growth item corresponding to the agricultural problem. In this way, the most relevant and appropriate contextual information for the agricultural problem can be retrieved. Specifically, the specific matching scheme and the matching degree measurement criteria are described in detail below and will not be repeated here.

[0073] 103. Input text information and related crop growth items into an agricultural language model, and determine the answer corresponding to the agricultural question based on the output of the agricultural language model.

[0074] Finally, the text information and related crop growth items are integrated into an agricultural question input with background information, so that the agricultural language model can capture more dimensional features, thereby more accurately identifying the input semantics and outputting more accurate and appropriate answers.

[0075] As can be seen from the above description, the present invention identifies and responds to agricultural questions input by users based on an agricultural language model. Before the agricultural questions raised by users are input into the agricultural language model, the local agricultural knowledge base is first matched according to the user's latitude and longitude information when the user raises the agricultural question, the user input time information, and the text information of the agricultural question itself, so as to obtain the most relevant agricultural growth items in the local agricultural knowledge base that are related to the agricultural question. It can be understood that the agricultural growth items in the local agricultural knowledge base are used to record the growth conditions of crops at different times and in different regions, and the most relevant agricultural growth items found to be related to the agricultural question can be used as background information and supplementary information for the agricultural question. In this way, after the related agricultural growth items and agricultural questions are input into the agricultural language model, the agricultural language model can obtain more features and input information, so as to more fully analyze and identify the text semantics, so as to generate more accurate, detailed, and more suitable responses for the agricultural model.

[0076] The following is a detailed description of the specific matching process of matching the local agricultural knowledge base based on attribute information and text information to obtain the associated crop growth items corresponding to the agricultural problem:

[0077] It is understandable that the embodiment of the present application needs to be considered from three dimensions in order to match the associated crop growth items that are most relevant to the agricultural problem from the local agricultural knowledge base. Specifically, it is necessary to measure the matching degree of each crop growth item in the local agricultural knowledge base with the agricultural problem. Finally, based on the matching value corresponding to each crop growth item, the associated crop growth item with the highest matching degree is determined. The following introduces the matching degree measurement standard for a crop growth item.

[0078] Figure 2 A flow chart of a method for calculating the matching value between crop growth items and agricultural problems provided in an embodiment of the present application. Figure 2 As shown, the following steps are included:

[0079] 201. Determine a first indicator value according to the user's longitude and latitude information and the crop's longitude and latitude information.

[0080] First, the matching degree between the crop growth item and the agricultural problem is measured from the location dimension. Exemplarily, the first index value can be calculated by the longitude and latitude coordinates corresponding to the user's longitude and latitude information and the longitude and latitude corresponding to the crop longitude and latitude information. The first index value is a distance index, which reflects the distance difference between the longitude and latitude coordinates corresponding to the user's longitude and latitude information and the longitude and latitude coordinates corresponding to the crop longitude and latitude information. It can be understood that if the distance between the two is very close, the environment of the crops recorded in the local agricultural knowledge base is more similar to the environment of the crops consulted by the user, and the information provided by the crop growth item in the local agricultural knowledge base is more valuable for reference. On the contrary, if the distance between the two is very far, the environmental difference is very large, and the reference value of the information provided by the crop growth item in the local agricultural knowledge base is very low. Therefore, the distance between the longitude and latitude coordinates corresponding to the user's longitude and latitude information and the longitude and latitude coordinates corresponding to the crop longitude and latitude information can be calculated. The greater the distance, the lower the first index value, and the smaller the distance, the higher the first index value.

[0081] In a specific example, if the longitude and latitude coordinates corresponding to the user's longitude and latitude information are (lon2, lat2), and the longitude and latitude coordinates corresponding to the crop's longitude and latitude information are (lon1, lat1), then the calculation formula for the first indicator value may be:

[0082]

[0083] Among them, Index d Used to indicate the first index value; d(lon2, lat2, lon1, lat1) is used to indicate the distance between (lon2, lat2) and (lon1, lat1); D max It is a constant, which is the preset maximum distance threshold and represents the maximum distance in a specific area. For example, the distance from the easternmost to the westernmost part of a county is assumed to be 60 kilometers.

[0084] The following is an explanation of the meaning of the above formula. It can be understood that the larger the distance d(lon2, lat2, lon1, lat1), The larger the value of , the greater the Index d On the contrary, Index dAnd, as d(lon2, lat2, lon1, lat1) increases, Index d The value of is nonlinearly decaying, which is more in line with the actual crop growth environment.

[0085] Exemplarily, d(lon2, lat2, lon1, lat1) can be obtained by calculation according to the Haversine formula, and the calculation process is described below:

[0086] First, convert each value in the longitude and latitude coordinates (lon2, lat2) and (lon1, lat1) into radian values ​​to obtain (r_lon2, r_lat2) and (r_lon1, r_lat1). The conversion formula for radian values ​​is:

[0087]

[0088] Where d2r(x) is used to indicate the radian value of x, and x is the number to be converted.

[0089] Next, the longitude difference dlon and latitude difference dlat of the two points are calculated respectively. It can be understood that dlon = r_lon2-r_lon1; dlat = r_lat2-r_lat1.

[0090] Next, calculate d(lon2, lat2, lon1, lat1) according to the following formula, where:

[0091]

[0092] d=Rc (3)

[0093] Wherein, R = 6371 kilometers. It is understandable that the location index may be calculated in other ways, which are not limited in this embodiment.

[0094] 202. Determine a second indicator value according to the time information input by the user and the time information of crop growth status collection.

[0095] Then, the matching degree between the crop growth item and the agricultural problem is measured from the time dimension. Exemplarily, the second index value can be calculated by the user input time information and the crop growth status collection time information, and the second index value is a distance index, which reflects the closeness between the user input time and the crop growth status collection time. It can be understood that if the time of the two is closer, the climatic conditions of the crops recorded in the local agricultural knowledge base and the crops consulted by the user are more similar, and the information provided by the crop growth item in the local agricultural knowledge base is more valuable for reference. On the contrary, if the gap between the two is larger, the difference in climatic conditions is very large, and the reference value of the information provided by the crop growth item in the local agricultural knowledge base is very low. At the same time, since crop growth has obvious periodic characteristics, multiple cycles are repeated, and the climatic conditions of the same growth stage in each cycle are very close, while different stages in a cycle do have significant differences. Taking each year as an example, the climatic conditions of a region in the spring of each year are relatively close, while the climatic conditions in the summer and autumn of the same year are very different. Therefore, the performance of crops in the same season of different years should be regarded as close, and different seasons of the same year should be regarded as not close. At the same time, it is also necessary to consider the time decay effect between cycles, that is, the relevance of historical information may gradually weaken.

[0096] Therefore, when calculating the second index value, it is necessary to first set the time period length T and the attenuation coefficient k corresponding to the time period length T. Then, based on the two, the proximity between the user input time and the crop growth status collection time is measured, and the second index value is determined based on the proximity.

[0097] In a specific example, assuming that the time corresponding to the time information input by the user is t2, and the time information of crop growth status collection is t1; then the second indicator value can be calculated according to the following formula:

[0098]

[0099] Among them, Index t Used to indicate the second indicator value; T is the length of the time period, usually one year; Used to capture periodic changes; year is a time function.

[0100] Specifically, the units of T, t2, and t1 must be consistent. For example, if T is set to 365 days, then t2 and t1 are also in days. Adjust the periodicity to the interval [0,1] to match the exponential

[0101] Attenuation part is combined. year is a time function, which is used to determine the time period in which t2 or t1 is located. For example, if T is 365 days, then year(t2) is used to obtain the year in which t2 is located, and year(t1) is used to obtain the year in which t1 is located. At the same time, year(t2)-year(t1) is used to calculate the number of time periods between t2 and t1, and k(year(t)-year(t1)) is used to indicate the degree of correlation decay after multiple time periods. For example, if the information decays by 0.8 each year compared with the previous year, k=0.2231 is calculated, and if the information decays by 0.9 each year compared with the previous year, k=0.1054 is calculated. Then if there is one year between t2 and t1, the degree of correlation decay is 0.9, and if there is a two-year interval, the degree of decay is 0.81. And ek(year(t2)-year(t1)) is used to indicate that the time decay is exponential decay, not linear decay.

[0102] It is understandable that there are other ways to specifically calculate the second indicator value, as long as it can measure the proximity between the user input time and the crop growth status collection time, and the embodiments of the present application do not limit this.

[0103] 203. Determine a third indicator value according to the text information and the crop growth status data information.

[0104] Next, the matching degree between the crop growth items and the agricultural problems is measured from the dimension of text information. For example, the text information of the agricultural problem input by the user can be matched with the crop growth status data information to find the crop growth items with the closest semantics. For example, the similarity between the word vector corresponding to the text information and the word vector corresponding to the crop growth status data information can be calculated to determine whether they are semantically close. For example, both can be converted into 768-dimensional word vectors, and then the third index value is calculated by the following formula:

[0105]

[0106] Among them, Index q It is used to indicate the third index value. A2 is the word vector of text information, and A1 is the word vector of crop growth data information. A2·A1 represents the dot product of vectors A2 and A1, that is, the sum of the elements of the corresponding dimensions multiplied together. A2 and A1 are the Euclidean norms of vectors A2 and A1, that is, the square root of the sum of the squares of each element. From the above formula, it can be seen that the higher the similarity of the word vectors of the two, the higher the third index value, and the lower the similarity of the word vectors of the two, the lower the third index value.

[0107] 204. Determine a matching value according to the first index value, the second index value, and the third index value.

[0108] After calculating the first indicator value (location indicator), the second indicator value (time indicator) and the third indicator value (text information indicator) from the three dimensions respectively, it is necessary to obtain a comprehensive indicator value based on the three, and the comprehensive indicator value is the final matching degree. Exemplarily, each indicator value also needs to correspond to a weight value, which is used to indicate the importance of each indicator value. It can be understood that each weight value can be adjusted according to the actual agricultural production situation. After determining the first weight value corresponding to the first indicator value, the second weight value corresponding to the second indicator value, and the third weight value corresponding to the third indicator value, the matching value can be calculated according to the following formula:

[0109] Index=wt·Index t +wd Index d +wq·Index q (6)

[0110] Among them, Index is used to indicate the matching value; wd, wt and wq are the first weight value, the second weight value and the third weight value respectively; among them, the three weight values ​​must be greater than or equal to 0 and satisfy wt+wd+wq=1. In particular, wt and wd cannot be zero at the same time.

[0111] At this point, the associated crop growth entries that best match the agricultural problem in the local agricultural knowledge base are obtained. After the associated crop growth entries are input into the agricultural language model as the most appropriate context information for the agricultural problem, they are conducive to the agricultural language model to better identify and respond to agricultural problems.

[0112] Based on the above description, Figure 3 A processing flow chart of an agricultural problem processing provided in an embodiment of the present application. It can be understood that, Figure 3 The illustrated embodiment introduces the entire process from establishing a local agricultural knowledge base to obtaining answers to agricultural questions. Figure 3 As shown, the processing flow includes the following steps:

[0113] Step 1: Collect crop growth data.

[0114] In the digital village system, various sensors are used to collect data on the growth of crops. These data include information such as the time of collection, soil moisture, pest and disease conditions, crop varieties, and growth. Among them, the longitude and latitude information of the sensor is used to determine the specific location of the collection point. It can be understood that this information reflects the dynamic growth process of crops.

[0115] Step 2: Build a local agricultural knowledge base.

[0116] Using the various data collected in step 1, a local agricultural knowledge base is constructed. The local agricultural knowledge base contains three dimensions: location (longitude and latitude information), time (collection time), and text information (crop growth status data information). Among them, the collection time and longitude and latitude information come directly from the sensor data, while the text information can be generated through a specified template. For example, the template can be: Under the condition of {soil moisture}, {crop variety} has {diseases and insect pests}, and its growth is {crop growth}. Among them, the content in the curly brackets corresponds to the column name of the corresponding entry in the digital village database.

[0117] Step 3: Add word vectors corresponding to crop growth status data information.

[0118] Specifically, to facilitate query matching, the text information in the local agricultural knowledge base can be converted into word vectors, and the converted word vector results can be added to the local agricultural knowledge base. For example, the BERT model can be used to convert text information into 758-dimensional word vectors to facilitate subsequent query matching.

[0119] Step 4: Set parameters.

[0120] It is necessary to set the weight parameters of three dimensions, including the first weight value wd corresponding to the position dimension, the second weight value wt corresponding to the time dimension, and the third weight value wq corresponding to the text information dimension, and ensure that wt+wd+wq=1, and wt and wd are not 0 at the same time.

[0121] At the same time, set the time period T and decay coefficient k corresponding to the time dimension. If k = 0.1054, it means that the decay of the information in the previous year is 0.9. If the period T is set to 365, the subsequent user query time and the time comparison of the local agricultural knowledge base are calculated in days.

[0122] It is also necessary to set the regional maximum distance threshold D corresponding to the local agricultural knowledge base max , which is used to indicate the maximum distance range for the local agricultural knowledge base to provide query functions for users, and the maximum distance for the agricultural language model to provide knowledge question-answering services for users. At the same time, it is also necessary to set an input template for the agricultural language model, that is, agricultural questions with background information.

[0123] Step 5: Obtain attribute information and text information corresponding to agricultural issues.

[0124] The attribute information includes the user's latitude and longitude information and the user input time information when the user inputs the agricultural question. Specifically, when the user asks a question to the agricultural language model, in addition to obtaining the agricultural question (text information) input by the user, two implicit information needs to be collected, namely the time and location of the user's question.

[0125] Step 6: Convert text information into word vectors.

[0126] Exemplarily, the same model and method as step 3 can be used to convert the agricultural question (text) input by the user into a word vector.

[0127] Step 7. Initialize temporary variables temp and tmprd.

[0128] Specifically, two variables temp=0 and tmprd=empty are initialized. These two variables are used to store the maximum matching value so far and its corresponding knowledge base record (crop growth entry) respectively.

[0129] Step 8: Read a crop growth entry.

[0130] Select a record from the local agricultural knowledge base. If it is the first time to read, select the first record in the knowledge base; otherwise, select the next record of the current record.

[0131] Step 9, initialize each index value: set the initial values ​​of the first index value (distance index) Indexd, the second index value (time index) Indext, and the third index value (text information index) Indexq to 0.

[0132] Step 10: Determine whether the first indicator value is 0.

[0133] Check whether the weight of the distance index, that is, the first index value wd, is equal to 0. If wd=0, there is no need to calculate the distance index, and directly go to step 12; otherwise, go to step 11.

[0134] Step 11: Calculate the first index value.

[0135] First, the distance between the user's longitude and latitude information and the longitude and latitude information of the crop in the currently selected agricultural growth entry is calculated. Then, the distance index is calculated using the first index value calculation formula. After the calculation is completed, step 12 is entered.

[0136] Step 12: Determine whether the second indicator value is 0.

[0137] Check whether the weight wt of the time index is equal to 0. If wt=0, there is no need to calculate the time index, and go directly to step 14; otherwise, go to step 13.

[0138] Step 13: Calculate the second index value.

[0139] The time index formula is used to calculate the time index between the time information input by the user and the time information of the crop growth status collection in the current crop growth entry. After the time index calculation is completed, step 14 is entered.

[0140] Step 14: Determine whether the third weight value is 0.

[0141] Check whether the weight wq of the text information index is equal to 0. If wq is equal to 0, there is no need to calculate the text information index, and go directly to step 16; otherwise, go to step 15.

[0142] Step 15: Calculate the third index value.

[0143] The text information index formula is used to calculate the information index between the word vector corresponding to the agricultural question input by the user and the word vector recorded in the currently selected agricultural growth entry. After the calculation is completed, go to step 16.

[0144] Step 16, Calculate the matching value Index: After the three indicators are calculated, use the formula to calculate the comprehensive matching value Index. After completion, proceed to step 17.

[0145] Step 17: Determine whether Index is greater than temp.

[0146] Compare the current matching value Index with the previously recorded matching value temp. If Index is larger, go to step 18; otherwise, go to step 20.

[0147] Step 18: Update the record.

[0148] Replace the current record with the previously stored record tmprd. After completion, proceed to step 19.

[0149] Step 19: Update the maximum matching value.

[0150] Replace the current matching value Index with the previous maximum matching value temp, ensuring that temp always remains at the maximum value before the next loop. After completion, proceed to step 20.

[0151] Step 20, check the traversal status: determine whether all the crop growth items in the local agricultural knowledge base have been compared with the agricultural problem. If yes, it means that the most suitable background context has been found; otherwise, continue to search for the remaining crop growth items. After completion, go to step 21.

[0152] Step 21: Output the final optimization result.

[0153] Output temp and tmprd, where temp stores the maximum matching value and tmprd is the corresponding most relevant crop growth entry.

[0154] Step 22: Generate agricultural questions with background information.

[0155] Based on the final associated crop growth entries determined in the previous step, agricultural questions with background information are generated using preset templates.

[0156] Step 23: Input the agricultural language model. The generated agricultural questions with background information are input into the agricultural language model, and the model will give intelligent answers based on the provided background information and agricultural questions.

[0157] Step 24: Get the final answer. The result output by the agricultural language model is the final answer obtained using the RAG technology. At this point, the entire response process ends.

[0158] Based on the above description, Figure 4 The schematic diagram of the structure of an agricultural question answering device based on spatiotemporal information provided in the embodiment of the present application. Figure 4 As shown, the device comprises:

[0159] The acquisition unit 401 is used to acquire attribute information and text information corresponding to the agricultural question; the attribute information includes user longitude and latitude information and user input time information; the user longitude and latitude information is used to indicate the longitude and latitude coordinates when the user inputs the agricultural question, and the user input time information is used to indicate the time when the user inputs the agricultural question;

[0160] The processing unit 402 is used to match the local agricultural knowledge base based on the attribute information and the text information to obtain the associated crop growth items corresponding to the agricultural problem; wherein the local agricultural knowledge base includes a plurality of crop growth items; each of the plurality of crop growth items is used to record the mapping relationship between the crop longitude and latitude information, the crop growth status collection time information, and the crop growth status data information;

[0161] The transceiver unit 403 is used to input text information and related crop growth items into the agricultural language model, and determine the answer corresponding to the agricultural question based on the output of the agricultural language model; the agricultural language model is trained based on all agricultural question samples and the question answer sample labels corresponding to each agricultural question sample, and each agricultural question sample includes at least sample text information and sample related crop growth items.

[0162] In an optional embodiment, the processing unit 402 is specifically used to determine the matching value between the agricultural problem and each crop growth entry based on the attribute information and the text information; and determine the crop growth entry with the highest matching value in each crop growth entry as the associated crop growth entry corresponding to the agricultural problem.

[0163] In an optional embodiment, the processing unit 402 is specifically used to determine, for each crop growth entry, a first indicator value based on the user's longitude and latitude information and the crop's longitude and latitude information; the first indicator value is used to indicate the distance difference between the longitude and latitude corresponding to the user's longitude and latitude information and the longitude and latitude corresponding to the crop's longitude and latitude information; determine a second indicator value based on the user's input time information and the crop growth status collection time information; the second indicator value is used to indicate the proximity between the user's input time information and the crop growth status collection time information; determine a third indicator value based on the text information and the crop growth status data information; the third indicator value is used to indicate the degree of textual association between the text information and the crop growth status data information; and determine a matching value based on the first indicator value, the second indicator value, and the third indicator value.

[0164] In an optional embodiment, the processing unit 402 is specifically used to respectively determine a first weight value corresponding to the first indicator value, a second weight value corresponding to the second indicator value, and a third weight value corresponding to the third indicator value; wherein the sum of the first weight value, the second weight value, and the third weight value is 1; the first weight value, the second weight value, and the third weight value are all greater than or equal to 0, and the first weight value and the second weight value are not 0 at the same time; the matching value is determined according to the first indicator value, the second indicator value, the third indicator value, the first weight value, the second weight value, and the third weight value.

[0165] In an optional embodiment, the processing unit 402 is specifically used to convert the text information and the crop growth status data information respectively to obtain a first word vector corresponding to the text information and a second word vector corresponding to the crop growth status data information; and determine the third indicator value based on the similarity between the first word vector and the second word vector.

[0166] In an optional implementation, the longitude and latitude coordinates corresponding to the longitude and latitude information of the user are (lon2, lat2), and the longitude and latitude coordinates corresponding to the longitude and latitude information of the crop are (lon1, lat1). The calculation formula of the first indicator value is:

[0167]

[0168] Among them, Index d Used to indicate the first index value; d(lon2, lat2, lon1, lat1) is used to indicate the distance between (lon2, lat2) and (lon1, lat1); D max The preset maximum distance threshold.

[0169] In an optional embodiment, the time corresponding to the time information input by the user is t2, and the time information for collecting the crop growth status is t1; the processing unit is specifically used to determine the time period length T and the attenuation coefficient k corresponding to the time period length T; determine the degree of proximity between t2 and t1 according to the time period T and the attenuation coefficient k; determine the second indicator value according to the degree of proximity between t2 and t1.

[0170] In an optional implementation, the calculation formula of the second index value is:

[0171]

[0172] Among them, Index t Used to indicate the second indicator value; year(t1) is used to indicate the time period corresponding to t1; year(t2) is used to indicate the time period corresponding to t2; year(t2)-year(t1) is used to indicate the number of time periods between t2 and t1.

[0173] See also Figure 5 The embodiment of the present application also shows an agricultural question answering device 1000, which may include one or more central processors 1001 and a communication interface 1003. Optionally, a memory 1002 may also be included.

[0174] The memory 1002 may be a temporary storage or a permanent storage. Furthermore, the central processor 1001 may be configured to communicate with the memory 1002 and execute a series of instruction operations in the memory 1002 on the footprint recognition device.

[0175] In this embodiment, the CPU 1001 can execute the aforementioned Figures 1 to 3 The steps performed in the illustrated embodiment will not be described in detail here.

[0176] In this embodiment, the specific functional module division in the central processing unit 1001 can be the same as the above Figure 4 The division method of each module described in is similar and will not be repeated here.

[0177] It should be noted that the information execution process of the central processor 1001 of the above-mentioned agricultural question answering device 1000 and other contents can be specifically referred to in the aforementioned Figures 1 to 3 The description in the method embodiment shown will not be repeated here.

[0178] The present invention also provides a computer-readable storage medium, which stores computer instructions; the computer instructions enable the computer to execute the above Figures 1 to 3 The steps performed in any one of the embodiments shown.

[0179] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the protection scope of the present invention.

Claims

1. A method for answering agricultural questions based on spatiotemporal information, characterized in that: The method comprises: Acquire attribute information and text information corresponding to the agricultural question; the attribute information includes user longitude and latitude information and user input time information; the user longitude and latitude information is used to indicate the longitude and latitude coordinates when the user inputs the agricultural question, and the user input time information is used to indicate the time when the user inputs the agricultural question; Matching the local agricultural knowledge base based on the attribute information and the text information to obtain the associated crop growth entry corresponding to the agricultural problem; wherein the local agricultural knowledge base includes a plurality of crop growth entries; each of the plurality of crop growth entries is used to record the mapping relationship between crop longitude and latitude information, crop growth status collection time information, and crop growth status data information; The text information and the associated crop growth items are input into an agricultural language model, and the answer corresponding to the agricultural question is determined based on the output of the agricultural language model; the agricultural language model is trained based on all agricultural question samples and the question answer sample labels corresponding to each agricultural question sample, and each agricultural question sample includes at least sample text information and sample associated crop growth items.

2. The method according to claim 1, characterized in that: The matching of the local agricultural knowledge base based on the attribute information and the text information to obtain the associated crop growth items corresponding to the agricultural problem includes: Determining a matching value between the agricultural problem and each of the crop growth items based on the attribute information and the text information; The crop growth entry with the highest matching value among each of the crop growth entries is determined as the associated crop growth entry corresponding to the agricultural problem.

3. The method according to claim 2, characterized in that The determining, based on the attribute information and the text information, a matching value between the agricultural problem and each of the crop growth items comprises: For each of the crop growth entries, a first indicator value is determined according to the user longitude and latitude information and the crop longitude and latitude information; the first indicator value is used to indicate the distance difference between the longitude and latitude corresponding to the user longitude and latitude information and the longitude and latitude corresponding to the crop longitude and latitude information; Determine a second index value according to the user input time information and the crop growth status collection time information; the second index value is used to indicate the proximity between the user input time information and the crop growth status collection time information; Determine a third index value according to the text information and the crop growth status data information; the third index value is used to indicate the degree of textual association between the text information and the crop growth status data information; The matching value is determined according to the first index value, the second index value and the third index value.

4. The method according to claim 3, characterized in that The determining the matching value according to the first index value, the second index value and the third index value includes: respectively determining a first weight value corresponding to the first indicator value, a second weight value corresponding to the second indicator value, and a third weight value corresponding to the third indicator value; wherein the sum of the first weight value, the second weight value, and the third weight value is 1; the first weight value, the second weight value, and the third weight value are all greater than or equal to 0, and the first weight value and the second weight value are not 0 at the same time; The matching value is determined according to the first index value, the second index value, the third index value, the first weight value, the second weight value and the third weight value.

5. The method according to claim 4, characterized in that The determining of the third indicator value according to the text information and the crop growth status data information includes: Respectively converting the text information and the crop growth status data information to obtain a first word vector corresponding to the text information and a second word vector corresponding to the crop growth status data information; The third index value is determined according to the similarity between the first word vector and the second word vector.

6. The method according to any one of claims 3 to 5, characterized in that: The longitude and latitude coordinates corresponding to the user's longitude and latitude information are (lon2, lat2), and the longitude and latitude coordinates corresponding to the crop's longitude and latitude information are (lon1, lat1). The calculation formula for the first index value is: Among them, Index d is used to indicate the first index value; d(lon2, lat2, lon1, lat1) is used to indicate the distance between (lon2, lat2) and (lon1, lat1); D max The preset maximum distance threshold.

7. The method according to claim 6, characterized in that The time corresponding to the user input time information is t2, and the crop growth status collection time information is t1; determining the second indicator value according to the user input time information and the crop growth status collection time information includes: Determine a time period length T and an attenuation coefficient k corresponding to the time period length T; Determine the proximity between t2 and t1 according to the time period T and the attenuation coefficient k; The second index value is determined according to the proximity between t2 and t1.

8. The method according to claim 7, characterized in that The calculation formula of the second index value is: Among them, Index t Used to indicate the second indicator value; year(t1) is used to indicate the time period corresponding to t1; year(t2) is used to indicate the time period corresponding to t2; year(t2)-year(t1) is used to indicate the number of time periods between t2 and t1.

9. A device for answering agricultural questions, characterized in that: The reply device comprises a processor and a memory; the processor is coupled to the memory; the memory is used to store computer instructions, and the computer instructions are loaded and executed by the processor, so that the reply device implements the method according to any one of claims 1-8.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions; the computer instructions enable the computer to execute the method according to any one of claims 1 to 8.

Citation Information

Patent Citations

  • Rice fertilization knowledge graph construction and knowledge reasoning method taking spatio-temporal characteristics into consideration

    CN117114099A

  • Agricultural field knowledge question-answering system and method based on local knowledge base

    CN117708291A