Construction and query method of crop variety information knowledge graph
By constructing a crop variety information knowledge graph and applying GraphRAG intelligent dialogue assistant, the problem of low quality of crop variety information query results in the existing technology is solved, and high accuracy and reliability of crop variety information query services are achieved, and agricultural production efficiency is improved. .
Patent Information
- Application Number
- CN202411531897.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-30
- Publication Date
- 2025-02-14
AI Technical Summary
The prior art is difficult to provide accurate and reliable crop variety information, which makes it difficult to guarantee the quality of query or recommendation information obtained by users.
By constructing a crop variety information knowledge graph, including data set collection, classification, quality control, knowledge graph construction, query statement demonstration, large language model prompt optimization and GraphRAG intelligent dialogue assistant application, we provide high-quality crop variety information query services.
It improves the accuracy and reliability of crop variety information query results, meets the actual needs of users, and helps farmers and others better understand and choose excellent crop varieties that suit their own conditions, thereby improving the economic and social benefits of agricultural production.
Smart Images

Figure CN119441312A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of agricultural information technology, and in particular to the construction of a crop variety information knowledge graph and a query method thereof. Background Art
[0002] The selection of crop varieties is crucial to improving agricultural production efficiency and agricultural product quality. Therefore, providing and recommending accurate and reliable crop variety information is of great significance to farmers, agronomists, agricultural technology extension, agricultural material distributors and other users.
[0003] Currently, all kinds of users who have demand for crop variety information have various channels for obtaining crop variety information, but they often lack sufficient reliability, and the quality of the query or recommended information obtained is difficult to guarantee. Although general AI dialogue assistants can now answer questions related to crop variety information through their own knowledge + network search, due to the lack of a professional and reliable crop variety database, the quality of the answers usually cannot meet actual needs. Summary of the invention
[0004] In response to the above problems, the present invention proposes a method for constructing and querying a crop variety information knowledge graph, which solves the problem that the currently available crop variety information query results are generally of low quality, improves the accuracy and reliability of the crop variety information query results, and meets the actual needs of users.
[0005] To achieve the above object, the technical solution of the present invention is: a method for constructing a crop variety knowledge graph and querying the same, comprising the following steps: S1. Crop variety dataset collection, to obtain comprehensive and reliable crop variety dataset; S2, crop variety dataset classification, classify the collected crop variety dataset and create dataset metadata; S3. Crop variety data quality control: quality inspection and necessary correction of the original crop variety data; S4, crop variety knowledge graph construction, using the quality-controlled data set to construct the crop variety knowledge graph; S5. Demonstration of query statements for crop variety knowledge graph, including writing several examples of crop variety query questions and query statements for crop variety knowledge graph; S6. Optimization of large language model prompts: by optimizing large language model task prompts, the quality of data query is guaranteed; S7 and GraphRAG are intelligent conversation assistant applications that can conduct natural language question and answer sessions with users.
[0006] As a further solution of the present invention: in step S1, the crop variety data set collection includes obtaining crop variety information from multiple reliable data sources, and the reliable data sources include but are not limited to the crop variety query system disclosed by the Seed Industry Bureau of the Ministry of Agriculture and Rural Affairs of the People's Republic of China and the "National Crop Excellent Variety Promotion" catalogue issued by the Ministry of Agriculture and Rural Affairs of the People's Republic of China.
[0007] As a further solution of the present invention: in step S2, the crop variety data set classification refers to classification according to the source of the data set, and the metadata of each category must include complete information on the source of the data.
[0008] As a further solution of the present invention: in step S3, the crop variety data quality control includes quality review of the original data, removal of duplicate data, correction of erroneous information and filling of missing data, especially including identification and correction of editing errors of text data in the original data.
[0009] As a further solution of the present invention: in step S4, the crop variety knowledge graph construction includes defining various entities, relationships and attributes related to crop variety information, constructing a knowledge graph, and implementing it as a graph database for storage. The entities related to the crop variety information include but are not limited to data sets, crops, varieties, promotion types, etc. The relationships are the associations between the entities, and the attributes are the attributes of each type of entity or relationship. The graph database must be a graph database that supports Cypher query statements.
[0010] As a further solution of the present invention: in step S5, the crop variety knowledge graph query statement demonstration includes writing several examples of mapping relationships from various types of user common questions to related query statements, the various types of user common questions are questions in natural language form, including but not limited to: what variety of a certain crop is suitable for growing in a certain place, which varieties of a certain crop are resistant to a certain disease, recommending varieties with certain characteristics, etc., the related query statements are Cypher query statements of the graph database, the mapping relationship refers to the one-to-one correspondence between questions and query statements, and the several examples refer to examples that can cover various types of user common questions, and must be continuously improved according to actual usage.
[0011] As a further solution of the present invention: in step S6, the large language model prompt optimization includes task prompt optimization of writing a graph database query language according to a user's natural language question, and task prompt optimization of answering a user's question according to a query result, wherein the task prompt optimization of writing a graph database query language according to a user's natural language question includes but is not limited to telling the large language model that the given graph database is a crop variety knowledge graph, and according to the specific mode of the graph, learn a number of given examples, and do not output any other information except generating a Cypher query statement according to the user's natural language question, and if the area mentioned by the user is lower than a certain level of administrative district, please expand the query scope to a certain level of administrative district, etc.;
[0012] The task prompt optimization of answering user questions based on query results includes but is not limited to telling the large language model: the query results provided are obtained by querying the crop variety graph database using Cypher generated based on the user's natural language questions, the query results are authoritative and must not be doubted or attempted to be corrected with internal knowledge, if the query results are empty, then the answer is that the answer is unknown, if the query results are not sufficient to answer the question, it means that there is not enough information, and the query results are used to answer the question as much as possible, if the query results include the English attribute names of the crop varieties, then they are expressed in Chinese in the answer according to the given comparison table, etc. The large language model must perform well in Chinese.
[0013] According to a further solution of the present invention: in step S7, the GraphRAG intelligent dialogue assistant application implements the natural language question and answer function into an intelligent dialogue assistant to respond to the user's query request. The intelligent dialogue assistant also has the following capabilities: it can organize the data query results related to the user's question into a table as a reliable data source for the user to preview, and support downloading as an Excel file for the user to edit and use later.
[0014] Compared with the prior art, the present invention has the following beneficial effects:
[0015] The crop variety knowledge graph construction and query method provided by the present invention is firstly established on a comprehensive and reliable data source, and then, on the basis of data set classification and data quality control, the crop variety data is reconstructed with the knowledge graph and saved as a graph database, and after query statement demonstration and large language model prompt optimization, it is finally implemented as a GraphRAG intelligent dialogue assistant, which can provide users with high-quality services in answering or recommending crop variety information questions, improve the accuracy and reliability of crop variety information query, and help farmers, agronomists, agricultural extension workers, agricultural material distributors, etc. to better understand and select excellent crop varieties suitable for their own conditions, thereby improving the economic and social benefits of agricultural production. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] Figure 1 This is a step diagram of the method for constructing and querying the crop variety knowledge graph of the present invention. DETAILED DESCRIPTION
[0017] The following will be combined with the drawings in 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.
[0018] Example 1
[0019] refer to Figure 1 , a crop variety knowledge graph construction and query method thereof, comprising the following steps: S1. Crop variety dataset collection, to obtain comprehensive and reliable crop variety dataset; S2, crop variety dataset classification, classify the collected crop variety dataset and create dataset metadata; S3. Crop variety data quality control: quality inspection and necessary correction of the original crop variety data; S4, crop variety knowledge graph construction, using the quality-controlled data set to construct the crop variety knowledge graph; S5. Demonstration of query statements for crop variety knowledge graph, including writing several examples of crop variety query questions and query statements for crop variety knowledge graph; S6. Optimization of large language model prompts: by optimizing large language model task prompts, the quality of data query is guaranteed; S7 and GraphRAG are intelligent conversation assistant applications that can conduct natural language question and answer sessions with users.
[0020] In step S1, the crop variety data set collection includes obtaining crop variety information from multiple reliable data sources, and the reliable data sources include but are not limited to the crop variety query system disclosed by the Seed Industry Department of the Ministry of Agriculture and Rural Affairs of the People's Republic of China and the "National Crop Excellent Variety Promotion" catalogue issued by the Ministry of Agriculture and Rural Affairs of the People's Republic of China.
[0021] In step S2, the classification of crop variety datasets refers to classification based on the source of the datasets, and the metadata of each category must include complete information on the source of the data.
[0022] In step S3, the crop variety data quality control includes quality review of the original data, removal of duplicate data, correction of erroneous information and filling of missing data, especially identification and correction of editing errors of text data in the original data.
[0023] In step S4, the construction of the crop variety knowledge graph includes defining various entities, relationships and attributes related to crop variety information, constructing a knowledge graph, and implementing it as a graph database for storage. Entities related to crop variety information include but are not limited to data sets, crops, varieties, promotion types, etc. Relationships are the associations between entities, and attributes are the attributes of each type of entity or relationship. The graph database must be a graph database that supports Cypher query statements.
[0024] In step S5, the crop variety knowledge graph query statement demonstration includes writing several examples of mapping relationships from various types of user common questions to related query statements. Various types of user common questions are questions in natural language form, including but not limited to: what variety of a certain crop is suitable for growing in a certain place, which varieties of a certain crop are resistant to a certain disease, and recommending varieties with certain characteristics, etc. The related query statements are Cypher query statements of the graph database. The mapping relationship refers to the one-to-one correspondence between the question and the query statement. The several examples refer to examples that can cover various types of user common questions, and must be continuously improved according to actual usage.
[0025] In step S6, the optimization of the large language model prompt includes the optimization of the task prompt of writing the query language of the graph database according to the user's natural language question, and the optimization of the task prompt of answering the user's question according to the query result. The optimization of the task prompt of writing the query language of the graph database according to the user's natural language question includes but is not limited to telling the large language model: the given graph database is a crop variety knowledge graph, according to the specific mode of the graph, learn several given examples, do not output any other information except generating Cypher query statements according to the user's natural language question, if the area mentioned by the user is lower than a certain level of administrative district, please expand the query scope to a certain level of administrative district, etc.;
[0026] Optimize the task prompts for answering user questions based on query results, including but not limited to telling the large language model: the query results provided are obtained by querying the crop variety graph database using Cypher generated based on the user's natural language questions, the query results are authoritative and must not be doubted or attempted to be corrected with internal knowledge, if the query results are empty, answer that you don't know the answer, if the query results are not sufficient to answer the question, it means that there is not enough information, and use the query results to answer the question as much as possible, if the query results include the English attribute names of the crop varieties, then they are expressed in Chinese according to the given comparison table in the answer, etc. The large language model must perform well in Chinese.
[0027] In step S7, the GraphRAG intelligent conversation assistant application implements the natural language question-answering function into an intelligent conversation assistant to respond to the user's query request. The intelligent conversation assistant also has the following capabilities: it can organize the data query results related to the user's question into a table as a reliable data source for the user to preview, and support downloading as an Excel file for the user to edit and use later.
[0028] The working principle of the present invention is as follows: first, it is established on a comprehensive and reliable data source, and then, based on the classification of the data set and data quality control, the crop variety data is reconstructed using the knowledge graph and saved as a graph database. After query statement demonstration and large language model prompt optimization, it is finally implemented as the GraphRAG intelligent dialogue assistant, which can provide users with high-quality services in answering questions or recommending crop variety information.
[0029] Compared to general AI Q&A assistants that are usually trained on a wide range of Internet text datasets and can handle questions on a variety of topics and fields, but are not ideal for highly professional questions, the GraphRAG intelligent Q&A assistant, which is based on a comprehensive and reliable crop variety knowledge graph, can provide more accurate and professional answers in terms of crop variety information, and can provide higher quality services when answering complex questions in this field.
[0030] Example 2
[0031] On the basis of Example 1, in step S4, the construction of the crop variety knowledge graph includes defining various entities, relationships and attributes related to the crop variety information, constructing a knowledge graph, and implementing it as a graph database for storage. The entities related to the crop variety information include but are not limited to data sets, crops, varieties, promotion types, etc. The relationships are the associations between the entities, including but not limited to: (variety)-[:IN_CROP]->(crop), (variety)-[:IN_CATEGORY]->(promotion type), (promotion type)-[:IN_STATE]->(dataset), and the attributes are the attributes of each type of entity or relationship, including but not limited to: [{"entity":"dataset","attribute":["name","time","description"]}, {"entity":"crop","attribute":["name"]}, {"entity":"variety","attribute":["variety name", "Variety characteristics", "Approval or registration number", "Variety right number", "Breeder", "Variety source", "Characteristics", "Key points of cultivation technology", "Suitable promotion area", "Development and promotion unit", "Promotion situation"]}, {"Entity":"Promotion category","Attribute":["Name","Definition"]}, {"Relationship":"IN_CATEGORY","Attribute":["Year"]}], the graph database must be a graph database that supports Cypher query statements, such as Apache AGE (PostgreSQL graph database).
[0032] Typically, the graph database model corresponding to the crop variety knowledge graph is as follows: Entities and their properties: [{'properties': [{'property': 'name', 'type': 'STRING'}, {'property':'rank', 'type': 'STRING'}, {'property': 'definition', 'type': 'STRING'}], 'labels': 'Category'}, {'properties': [{'property': 'name', 'type': 'STRING'}], 'labels': 'Crop'}, {'properties': [{'property': 'preamble', 'type': 'STRING'}, {'property': 'overall', 'type': 'STRING'}, {'property': 'year', 'type': 'STRING'}], 'labels': 'State'}, {'properties': [{'property': 'NumberType', 'type': 'STRING'}, {'property': 'VarietyName', 'type': 'STRING'}, {'property': 'ApprovalOrRegisterNumber', 'type': 'STRING'}, {'property': 'Breeder', 'type': 'STRING'}, {'property': 'name', 'type': 'STRING'}, {'property': 'Features', 'type': 'STRING'}, {'property': 'Promotion', 'type': 'STRING'}, {'property': 'CopyrightNumber', 'type': 'STRING'}, {'property': 'Source', 'type': 'STRING'}, {'property': 'ApplyCompany', 'type': 'STRING'}, {'property': 'CultivationTechniques', 'type': 'STRING'}, {'property': 'Traits', 'type': 'STRING'},{'property': 'SuitableArea', 'type': 'STRING'}], 'labels': 'Variety'}], Relationships and their properties: [{'properties': [{'property': 'year', 'type': 'STRING'}], 'type': 'IN_CATEGORY'}, {'properties': [], 'type': 'IN_CROP'}, {'properties': [], 'type': 'IN_STATE'}] Relationships between entities: ['(:`Variety`)-[:`IN_CATEGORY`]->(:`Category`)', '(:`Variety`)-[:`IN_CROP`]->(:`Crop`)', '(:`Category`)-[:`IN_STATE`]->(:`State`)'] Variety attributes Chinese and English comparison table: "Variety": "VarietyName"; "Features": "Features"; "Number Type": "NumberType"; "Approval or registration number": "ApprovalOrRegisterNumber"; "Copyright Number": "CopyrightNumber"; "Breeder": "Breeder"; "Source": "Source"; "Traits": "Traits"; "Cultivation Techniques"; "Suitable promotion area": "SuitableArea"; "Development and Promotion Unit": "ApplyCompany"; "Promotion": "Promotion".
[0033] Example 3
[0034] Based on Example 1, in step S5, the crop variety knowledge graph query statement is demonstrated as follows: { "What varieties of corn are suitable for planting in Handan?": \ """MATCH (v:Variety)-[:IN_CROP]->(:Crop {name: 'corn'}), (v)-[:IN_CATEGORY]->(c:Category) WHERE v.SuitableArea CONTAINS 'Hebei' RETURN v.VarietyName AS VarietyName, c.name AS Category,v.SuitableArea AS SuitableArea ORDER BY c.rank ASC, v.VarietyName ASC """, "Which rice varieties have good disease resistance?": \ """MATCH (v:Variety)-[:IN_CROP]->(cr:Crop {name: 'rice'}), (v)-[:IN_CATEGORY]->(c:Category) WHERE v.Traits =~ '(resistant|tolerant)[^,、]{0,5}disease RETURN v.VarietyName AS VarietyName, c.name AS Category, v.FeaturesAS Features, v.Traits AS Traits ORDER BY c.rank ASC, v.VarietyName ASC """, "Introduce the cotton variety: Zhong 7700": \ """MATCH (v:Variety {name: 'Zhong 7700'})-[:IN_CROP]->(cr:Crop), (v)-[:IN_CATEGORY]->(c:Category) RETURN v AS variety, cr.name as crop_name, c.name as category_name,c.definition as category_definition """, "Questions about "resistance" or "stress tolerance": """(v:Variety) WHERE v.Traits =~ 'resistance|stress tolerance'""", "Questions about "antiviral" or "viral resistant": """(v:Variety) WHERE v.Traits =~ '(anti|resistant)viral'""", "Questions about "cold resistance" or "cold tolerance": """(v:Variety) WHERE v.Traits =~ '(resistance|tolerance) cold'""", "Questions about "resistance to lodging" or "resistance to lodging" or "tolerance to lodging"": """(v:Variety) WHERE v.Traits=~ '(resistance to lodging|tolerance to lodging)'""", "Questions about "cracking resistance" or "cracking resistance": """(v:Variety) WHERE v.Traits =~ '(cracking resistance|resistance)'""", "Questions about "antibacterial" or "antisclerotinia" or "antisclerotinia disease" or "resistant to bacteria"": """(v:Variety)v.Traits =~ '(anti|resistant) bacteria'""", "Questions about "waterlogging resistance" or "stain resistance" or "waterlogging resistance" or "stain resistance"": """(v:Variety) WHEREv.Traits =~ '(resistance|resistance)(waterlogging|stain resistance)'""", "Which rapeseed varieties are both drought-resistant and flood-resistant?": \ """MATCH (v:Variety)-[:IN_CROP]->(cr:Crop {name: 'rapeseed'}), (v)-[:IN_CATEGORY]->(c:Category) WHERE v.Traits =~ '(resistance|tolerance to)(waterlogging|soillogging)' AND v.Traits =~ '(resistance|tolerance to)drought' RETURN v.VarietyName AS VarietyName, c.name AS Category, v.FeaturesAS Features, v.Traits AS Traits ORDER BY c.rank ASC, v.VarietyName ASC """, }
[0035] Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the appended claims and their equivalents.
Claims
1. A crop variety knowledge graph construction and query method, characterized by: The following steps are involved: S1. Crop variety dataset collection, to obtain comprehensive and reliable crop variety dataset; S2, crop variety dataset classification, classify the collected crop variety dataset and create dataset metadata; S3. Crop variety data quality control: quality inspection and necessary correction of the original crop variety data; S4, crop variety knowledge graph construction, using the quality-controlled data set to construct the crop variety knowledge graph; S5. Demonstration of query statements for crop variety knowledge graph, including writing several examples of crop variety query questions and query statements for crop variety knowledge graph; S6. Optimization of large language model prompts: by optimizing large language model task prompts, the quality of data query is guaranteed; S7 and GraphRAG are intelligent conversation assistant applications that can conduct natural language question and answer sessions with users.
2. The construction of the crop variety information knowledge graph and the query method thereof according to claim 1, characterized in that: In step S1, the crop variety data set collection includes obtaining crop variety information from multiple reliable data sources, and the reliable data sources include but are not limited to the crop variety query system disclosed by the Seed Industry Department of the Ministry of Agriculture and Rural Affairs of the People's Republic of China and the "National Crop Excellent Variety Promotion" catalogue issued by the Ministry of Agriculture and Rural Affairs of the People's Republic of China.
3. The construction of the crop variety information knowledge graph and the query method thereof according to claim 2, characterized in that: In step S2, the crop variety dataset classification refers to classification based on the source of the dataset, and the metadata of each category must include complete information on the source of the data.
4. The construction of the crop variety information knowledge graph and the query method thereof according to claim 3 is characterized in that: In step S3, the crop variety data quality control includes quality review of the original data, removal of duplicate data, correction of erroneous information and filling of missing data, especially identification and correction of editing errors of text data in the original data.
5. The construction of the crop variety information knowledge graph and the query method thereof according to claim 4 is characterized in that: In step S4, the construction of the crop variety knowledge graph includes defining various entities, relationships and attributes related to crop variety information, constructing a knowledge graph, and implementing it as a graph database for storage. The entities related to the crop variety information include but are not limited to data sets, crops, varieties, promotion types, etc. The relationships are the associations between entities, and the attributes are the attributes of each type of entity or relationship. The graph database must be a graph database that supports Cypher query statements.
6. The construction of the crop variety information knowledge graph and the query method thereof according to claim 5, characterized in that: In step S5, the crop variety knowledge graph query statement demonstration includes writing several examples of mapping relationships from various types of user common questions to related query statements, wherein the various types of user common questions are questions in natural language form, including but not limited to: what variety of a certain crop is suitable for growing in a certain place, which varieties of a certain crop are resistant to a certain disease, and recommending varieties with certain characteristics, etc. The related query statements are Cypher query statements of the graph database, and the mapping relationship refers to the one-to-one correspondence between questions and query statements. The several examples refer to examples that can cover various types of user common questions and must be continuously improved according to actual usage.
7. The construction of the crop variety information knowledge graph and the query method thereof according to claim 6 is characterized in that: In step S6, the large language model prompt optimization includes task prompt optimization of writing a graph database query language according to a user's natural language question, and task prompt optimization of answering a user's question according to a query result. The task prompt optimization of writing a graph database query language according to a user's natural language question includes but is not limited to telling the large language model that the given graph database is a crop variety knowledge graph, and according to the specific pattern of the graph, learn a number of given examples, and do not output any other information except generating a Cypher query statement according to the user's natural language question; if the area mentioned by the user is lower than a certain level of administrative district, please expand the query scope to a certain level of administrative district, etc.; The task prompt optimization of answering user questions based on query results includes but is not limited to telling the large language model: the query results provided are obtained by querying the crop variety graph database using Cypher generated based on the user's natural language questions, the query results are authoritative and must not be doubted or attempted to be corrected with internal knowledge, if the query results are empty, then the answer is that the answer is unknown, if the query results are not sufficient to answer the question, it means that there is not enough information, and the query results are used to answer the question as much as possible, if the query results include the English attribute names of the crop varieties, then they are expressed in Chinese in the answer according to the given comparison table, etc. The large language model must perform well in Chinese.
8. The construction of the crop variety information knowledge graph and the query method thereof according to claim 7, characterized in that: In step S7, the GraphRAG intelligent conversation assistant application implements the natural language question-and-answer function into an intelligent conversation assistant to respond to the user's query request. The intelligent conversation assistant also has the following capabilities: it can organize the data query results related to the user's question into a table as a reliable data source for the user to preview, and support downloading as an Excel file for the user to edit and use later.