Question and answer model fine tuning method and device, electronic equipment and storage medium
Through the collaborative work of multi-level large language models, knowledge data in the agricultural field is extracted, processed and enhanced, and the problem of low output accuracy of large models in specific fields is solved, and more efficient fine-tuning of agricultural Q&A model is achieved.
Patent Information
- Application Number
- CN202411749996.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-02
- Publication Date
- 2025-05-02
AI Technical Summary
The existing fine-tuning methods of large models are average, and the output accuracy of large models is not high, especially in tasks in specific fields.
A method of fine-tuning of question-and-answer model is proposed. By obtaining the knowledge data of the target crop, multiple large language models are called for data extraction, processing, and data enhancement, and finally fine-tuning the fourth largest language model to form the target large language model.
It improves the output accuracy of large models on specific domain tasks, especially in the agricultural field, and can generate more accurate and professional Q&A pairs, improving user satisfaction.
Smart Images

Figure CN119917607A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and in particular to a question-answering model fine-tuning method and device, an electronic device, and a storage medium. Background Art
[0002] In recent years, the continuous development and progress of artificial intelligence technology has brought great convenience to people's lives. Among them, the application of large language models based on artificial intelligence technology is particularly extensive. For example, they are used in various chat robots, smart assistants, and various content generation products. The wide application of large language models has improved people's experience in knowledge acquisition in multiple fields.
[0003] Large models have powerful language understanding and generation capabilities through pre-training on massive text data. Although pre-trained large models have extensive language knowledge and semantic representation capabilities, they may not perform well on tasks in specific fields. Large model fine-tuning is a process of further training the model based on the pre-trained model by using a dataset in a specific field, with the aim of enabling the model to better adapt to and meet the needs of a specific task or field. This process involves adjusting the weights and parameters of the model to improve its performance on specific tasks.
[0004] However, the current method of fine-tuning large models is generally ineffective, and the output accuracy of large models is not high. Summary of the invention
[0005] The main purpose of the embodiments of the present application is to propose a question-answering model fine-tuning method and device, electronic device and storage medium, aiming to improve the output accuracy of large models.
[0006] To achieve the above objectives, a first aspect of an embodiment of the present application proposes a question-answering model fine-tuning method, the method comprising:
[0007] Acquiring first data, the first data including knowledge data of a target crop;
[0008] Calling the first language model to extract data from the first data to obtain second data;
[0009] Calling the second largest language model to process the second data and the preset first prompt word to obtain a first question-answer data set, where the first question-answer data set includes a plurality of first question-answer pairs;
[0010] Calling the third language model to perform data enhancement on each first question-answer pair and a preset second prompt word to obtain a second question-answer data set, where the second question-answer data set includes the second question-answer pair corresponding to each first question-answer pair;
[0011] The fourth language model is fine-tuned according to the second question-answering dataset to obtain a target large language model. The fourth language model is a question-answering model related to the target crop.
[0012] In some embodiments, the second question-answering dataset includes a test set and a validation set, and fine-tuning the fourth large language model according to the second question-answering dataset to obtain a target large language model includes:
[0013] The fourth language model is fine-tuned according to the test set to obtain the fifth language model;
[0014] Call the fifth language model to infer the answer to the question data in each second question-answer pair in the validation set to obtain the inferred answer data;
[0015] Determine the accuracy of the fifth language model based on the relationship between the inference answer data and the labeled answers in the validation set;
[0016] When the accuracy is greater than a preset accuracy threshold, the fifth largest language model is determined as the target large language model.
[0017] In some embodiments, the method further comprises:
[0018] When the accuracy is not greater than the preset accuracy threshold, the fourth language model is updated based on the fifth language model, and the process returns to the step of fine-tuning the fourth language model based on the test set, and calculating the accuracy of the fine-tuned fifth language model based on the validation set.
[0019] In some embodiments, the accuracy rate includes one or more of answer fluency, answer professionalism, and user satisfaction.
[0020] In some embodiments, fine-tuning the fourth large language model according to the second question-answering dataset to obtain the target large language model includes:
[0021] Obtain a score for each second question-answer pair in the second question-answer dataset;
[0022] Adjust the second question-answering dataset according to the scores to obtain a third question-answering dataset;
[0023] The fourth language model is fine-tuned based on the third question-answering dataset.
[0024] In some embodiments, obtaining the first data includes:
[0025] Obtain various knowledge data URLs;
[0026] The knowledge data related to the target crop is crawled from each knowledge data website to obtain the first data.
[0027] In some embodiments, crawling knowledge data related to the target crop from each knowledge data website to obtain the first data includes:
[0028] crawling knowledge data related to the target crop from each knowledge data website to obtain third data;
[0029] Data whose semantic similarity satisfies a condition is selected from the third data to obtain the first data.
[0030] To achieve the above-mentioned purpose, a second aspect of an embodiment of the present application proposes a question-answering model fine-tuning device, the device comprising:
[0031] An acquisition unit, configured to acquire first data, wherein the first data includes knowledge data of a target crop;
[0032] An extraction unit, configured to extract data from the first data by calling the first language model to obtain second data;
[0033] a processing unit, configured to call a second language model to process the second data and a preset first prompt word to obtain a first question-answer data set, wherein the first question-answer data set includes a plurality of first question-answer pairs;
[0034] an enhancement unit, configured to call the third language model to perform data enhancement on each first question-answer pair and a preset second prompt word to obtain a second question-answer data set, wherein the second question-answer data set includes a second question-answer pair corresponding to each first question-answer pair;
[0035] The fine-tuning unit is used to fine-tune the fourth language model according to the second question-answering data set to obtain a target large language model, where the fourth language model is a question-answering model related to the target crop.
[0036] To achieve the above-mentioned purpose, the third aspect of an embodiment of the present application proposes an electronic device, which includes a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the method described in the first aspect is implemented.
[0037] To achieve the above-mentioned purpose, the fourth aspect of an embodiment of the present application proposes a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method described in the first aspect is implemented.
[0038] The question-answer model fine-tuning method and device, electronic device and storage medium proposed in the present application obtain first data, the first data includes knowledge data of the target crop; call the first large language model to extract data from the first data to obtain second data; call the second large language model to process the second data and a preset first prompt word to obtain a first question-answer data set, the first question-answer data set includes multiple first question-answer pairs; call the third large language model to perform data enhancement on each first question-answer pair and a preset second prompt word to obtain a second question-answer data set, the second question-answer data set includes a second question-answer pair corresponding to each first question-answer pair; fine-tune the fourth large language model according to the second question-answer data set to obtain a target large language model, the fourth large language model is a question-answer model related to the target crop. Through the above method, the first language model is first used to extract structured data from unstructured data, and then the second language model and the first prompt word are used to convert the structured data into question-answer pairs, and the third language model is called to perform data enhancement on the question-answer pairs. A large amount of non-target information has been removed during the structuring process, which can reduce the interference of noise and irrelevant information in the data enhancement process. The second prompt word provides samples that can clarify the specific requirements of the third language model task, reduce the possibility of misunderstanding or deviation from the topic during the data enhancement process, and improve data quality. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] Figure 1 It is a system architecture diagram provided by an embodiment of the present application;
[0040] Figure 2 It is a flowchart of a method for fine-tuning a question-answering model provided in an embodiment of the present application;
[0041] Figure 3 It is a flow chart of the loop iteration mechanism provided in the embodiment of the present application;
[0042] Figure 4 is a schematic diagram of the adaptive fine-tuning process provided by an embodiment of the present application;
[0043] Figure 5 It is a schematic diagram of the question-answering model fine-tuning process provided in an embodiment of the present application;
[0044] Figure 6 It is a structural schematic diagram of a question-answering model fine-tuning device provided in an embodiment of the present application;
[0045] Figure 7 It is a schematic diagram of the hardware structure of the electronic device provided in the embodiment of the present application. DETAILED DESCRIPTION
[0046] The embodiments of the present disclosure provide a question-answering model fine-tuning method and device, an electronic device, and a storage medium, aiming to improve the output accuracy of a large model.
[0047] The terms "first", "second", "third", "fourth", etc. (if any) in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein, for example. In addition, the terms "including" and "corresponding to" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0048] The word “exemplary” is used exclusively herein to mean “serving as an example, example, or illustration.” Any embodiment described herein as “exemplary” is not necessarily to be construed as preferred or advantageous over other embodiments.
[0049] In the embodiments of the present application, the term "module" or "unit" refers to a computer program or a part of a computer program with a predetermined function, and works together with other related parts to achieve a predetermined goal, and can be implemented in whole or in part by using software, hardware (such as processing circuits or memories) or a combination thereof. Similarly, a processor (or multiple processors or memories) can be used to implement one or more modules or units. In addition, each module or unit can be part of an overall module or unit that includes the function of the module or unit.
[0050] In addition, in order to better illustrate the present application, numerous specific details are given in the following specific embodiments. It should be understood by those skilled in the art that the present application can also be implemented without certain specific details. In some examples, methods, means, components and circuits well known to those skilled in the art are not described in detail in order to highlight the subject matter of the present application.
[0051] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.
[0052] First, some nouns involved in this application are analyzed:
[0053] Natural Language Processing (NLP) is a branch of artificial intelligence and linguistics that is dedicated to enabling computers to understand, interpret, and generate human language. The core goal of this field is to narrow the gap between human language and computers, enabling computers to perform tasks such as language translation, sentiment analysis, text summarization, and question-answering systems. The development of NLP technology relies on advances in machine learning, deep learning, and linguistic theory, which enable computers to recognize language patterns, understand context and semantics, and even generate fluent and natural language texts.
[0054] Large models have powerful language understanding and generation capabilities through pre-training on massive text data. Although pre-trained large models have extensive language knowledge and semantic representation capabilities, they may not perform well on tasks in specific fields. Large model fine-tuning is a process of further training the model based on the pre-trained model by using a data set in a specific field, with the aim of enabling the model to better adapt to and complete the needs of a specific task or field. This process involves adjusting the weights and parameters of the model to improve its performance on specific tasks. For example, the agricultural field, as a basic industry, involves a complex knowledge system, including expertise in crop management, soil quality, climatic conditions, pest and disease control, and other aspects. Therefore, how to build a large question-answering model suitable for the agricultural field has become a technical challenge of great value.
[0055] Most of the existing agricultural knowledge exists in a semi-structured or even unstructured form, such as government public data, agricultural technology reports, research papers, WeChat articles, etc. These knowledge sources are rich, but they are usually expressed in the form of natural language text, lack standardized structure, and are scattered in different data sources. Due to its unstructured characteristics, traditional natural language processing methods are difficult to directly extract effective information from it for model fine-tuning. In addition, agricultural knowledge involves a wide range of fields and is highly professional. The knowledge content is complex and diverse, covering crop cultivation, pest control, meteorological conditions, soil management and many other aspects. Although the existing large-scale pre-trained language models perform well in general fields, they are difficult to cope with the specific knowledge needs in the agricultural field without special fine-tuning training, especially in question-and-answer scenarios, where the models often cannot provide accurate and professional answers. Traditional data sets for large model fine-tuning rely on manual annotation, that is, manual verification by experts and researchers in related fields. This method is time-consuming and labor-intensive, and the process is easily affected by subjective factors, resulting in uneven data quality. Moreover, the distribution of knowledge points in the agricultural field is wide and constantly updated, and manual annotation is difficult to keep up with the development of agricultural technology and the needs of actual application scenarios.
[0056] Based on this, an embodiment of the present application provides a question-answer model fine-tuning method, which obtains first data, the first data includes knowledge data of a target crop; calls a first large language model to extract data from the first data to obtain second data; calls a second large language model to process the second data and a preset first prompt word to obtain a first question-answer data set, the first question-answer data set includes multiple first question-answer pairs; calls a third large language model to perform data enhancement on each first question-answer pair and a preset second prompt word to obtain a second question-answer data set, the second question-answer data set includes a second question-answer pair corresponding to each first question-answer pair; fine-tunes the fourth large language model according to the second question-answer data set to obtain a target large language model, the fourth large language model is a question-answer model related to the target crop. Through the above method, the first language model is first used to extract structured data from unstructured data, and then the second language model and the first prompt word are used to convert the structured data into question-answer pairs, and the third language model is called to perform data enhancement on the question-answer pairs. A large amount of non-target information has been removed during the structuring process, which can reduce the interference of noise and irrelevant information in the data enhancement process. The second prompt word provides samples that can clarify the specific requirements of the third language model task, reduce the possibility of misunderstanding or deviation from the topic during the data enhancement process, and improve data quality.
[0057] System architecture and scenario description of the application of the embodiments of the present disclosure
[0058] Figure 1 It is a system architecture diagram applied by the question-answer model fine-tuning method according to the embodiment of the present application, which includes a terminal 140, the Internet 130, a gateway 120, a server 110, and the like.
[0059] The terminal 140 includes a variety of device forms with a display screen, such as a desktop computer, a laptop computer, a PDA (personal digital assistant), a mobile phone, a vehicle terminal, a home theater terminal, a dedicated terminal, an intelligent voice interaction device, an intelligent home appliance or an aircraft. In addition, it can be a single device or a collection of multiple devices. The terminal 140 can communicate with the Internet 130 in a wired or wireless manner to exchange data.
[0060] The server 110 refers to a computer system that can provide certain services to the terminal 140. Compared with the ordinary terminal 140, the server 110 has higher requirements in terms of stability, security, performance, etc. The server 110 can be a high-performance computer in a network platform, a cluster of multiple high-performance computers, a part of a high-performance computer (such as a virtual machine), a combination of parts of multiple high-performance computers (such as virtual machines), etc.
[0061] The gateway 120 is also called an internetwork connector or a protocol converter. The gateway realizes network interconnection at the transport layer and is a computer system or device that acts as a converter. The gateway is a translator between two systems that use different communication protocols, data formats or languages, or even completely different architectures. At the same time, the gateway can also provide filtering and security functions. The message sent by the terminal 140 to the server 110 must be sent to the corresponding server 110 through the gateway 120. The message sent by the server 110 to the terminal 140 must also be sent to the corresponding terminal 140 through the gateway 120.
[0062] The question-answer model fine-tuning method provided in the embodiment of the present application may be implemented solely in the terminal 140 , may be implemented solely in the server 110 , or may be implemented partially in the terminal 140 and partially in the server 110 .
[0063] When the prompt word processing method provided in the embodiment of the present application is implemented alone in the terminal 140, the terminal 140 obtains the first data; the terminal 140 calls the first largest language model to extract the first data to obtain the second data; the terminal 140 calls the second largest language model to process the second data and the preset first prompt word to obtain the first question and answer data set; the terminal 140 calls the third largest language model to perform data enhancement on the preset second prompt word for each first question and answer pair to obtain the second question and answer data set; the terminal 140 fine-tunes the fourth largest language model according to the second question and answer data set to obtain the target large language model.
[0064] The question-answer model fine-tuning method provided in the embodiment of the present application will be described below in conjunction with the accompanying drawings. The executor of the following prompt word processing method takes the terminal device as an example, and can be specifically implemented by the terminal device by running the various computer programs mentioned above; of course, based on the understanding of the following text, it is not difficult to see that the question-answer model fine-tuning method provided in the embodiment of the present application can also be implemented collaboratively by the terminal device and the server.
[0065] See also Figure 2 ,like Figure 2 FIG. 1 is a flow chart of a method for fine-tuning a question-answering model provided in this embodiment, the method comprising:
[0066] Step 201: Obtain first data.
[0067] In this embodiment, the first data may include knowledge data of the target crop. The target crop is the crop type oriented to the fourth language model. The knowledge data may be data covering multiple aspects such as crop cultivation, pest and disease control, meteorological conditions, and soil management.
[0068] In a possible implementation manner, obtaining the first data includes:
[0069] Obtain various knowledge data URLs;
[0070] The knowledge data related to the target crop is crawled from each knowledge data website to obtain the first data.
[0071] In this embodiment, the knowledge data URL can be a URL that can search for knowledge data related to the target crop, such as professional websites on the Internet, agricultural technology forums, agricultural databases, scientific research papers, government public data and other sources, that is, knowledge data from multiple sources is collected.
[0072] From these websites, crawler programs can be designed to crawl target crop-related knowledge data, such as but not limited to the biological characteristics of crops, growth cycles, suitable climate and soil conditions, planting techniques, pest and disease control methods, fertilizer and pesticide use guidelines, market information, etc. These data will constitute the first data.
[0073] In a possible implementation manner, crawling knowledge data related to the target crop from each knowledge data website to obtain the first data includes:
[0074] crawling knowledge data related to the target crop from each knowledge data website to obtain third data;
[0075] Data whose semantic similarity satisfies a condition is selected from the third data to obtain the first data.
[0076] In this embodiment, the third data may be data directly captured from a knowledge data website by a crawler program, and may be a large amount of original, unprocessed information collection.
[0077] Next, the third data can be screened and processed to extract the most valuable information. Semantic analysis can be performed on the third data. By calculating the semantic similarity between the data, the data that meets specific conditions can be selected as the first data to ensure that the collected first data has high domain relevance.
[0078] Step 202: Call the first large language model to extract data from the first data to obtain second data.
[0079] In this embodiment, the first language model can understand a large amount of unstructured text data, including professional literature, research reports, online forum discussions, etc., and extract information related to the target crop from it. That is, the first language model can identify specific entities in the first data, such as crop names, types of pests and diseases, geographical locations, chemical names, etc. In addition to identifying entities, the first language model can also identify relationships between entities, such as the association between a certain crop and a specific pest and disease, or the relationship between crop growth and climatic conditions. And classify the data in the first data into predefined categories, such as planting technology, pest and disease control, soil management, etc., which helps to organize and retrieve information. Based on entities, relationships and data classification, unstructured first data can be converted into structured second data, such as knowledge graphs, database entries or information cards.
[0080] The first large language model may be a pre-trained large language model, such as a Generative Pre-trained Transformer (GPT) series, a General Language Model (GLM), and the like.
[0081] Step 203: Call the second largest language model to process the second data and the preset first prompt word to obtain a first question and answer data set.
[0082] In this embodiment, the second language model can be a natural language processing capability that performs in-depth analysis on the second data (structured data) processed by the first language model. It can understand the preset first prompt words and generate various questions and answers related to the target crop accordingly.
[0083] The first prompt word can define an execution scenario task of the second largest language model, so that the second largest language model outputs a question and answer data set related to the execution scenario task.
[0084] The first question-answer data set includes a plurality of first question-answer pairs, each of which is in the form of a key-value pair, and each of which includes a question data and an answer label corresponding to the question data, and the answer label is the correct answer to the question data. Exemplarily, the question data is generated based on the knowledge points in the second data, such as "What is the suitable growth temperature for a certain crop?" The corresponding answer label is extracted from the second data, such as "20-25 degrees Celsius".
[0085] That is, the pre-trained large language model is used in combination with agricultural field knowledge to automatically generate agricultural vertical field question-answer pairs. The second large language model input includes summarized and screened agricultural knowledge data, the first prompt word used to generate structured question-answer pairs, and outputs structured agricultural knowledge question-answer pairs (the first question-answer dataset).
[0086] Step 204: Call the third language model to perform data enhancement on the second prompt word preset in each first question-answer pair to obtain a second question-answer data set.
[0087] In this embodiment, the third language model can be a data enhancement of the generated first question-answer data set, and each first question-answer pair and the preset second prompt word are processed to generate a second question-answer data set.
[0088] The second prompt word can be a rewritten prompt word set according to scenario requirements, containing additional information, context, or a semantic expansion description of the fifth prompt word, to help the third language model to semantically expand the first question-and-answer data set.
[0089] The second question-answer data set includes the second question-answer pair corresponding to each first question-answer pair. The third language model performs semantic expansion on the basis of the second prompt word for each first question-answer pair. Semantic expansion can add or modify text data to make it richer and more diverse without changing the original intention or meaning, helping the model learn a wider range of vocabulary, sentence patterns and context information. Increasing the diversity and coverage of data will improve the generalization ability of the model.
[0090] The process of data enhancement may include a variety of techniques, such as creating variants of question-answer pairs through synonym replacement, sentence reorganization, and background information addition. These techniques can help the model learn richer language patterns and contextual relationships, and enhance the model's ability to understand different forms of questions and answers. For example, by using LLM to annotate unlabeled data, labeled synthetic data can be generated to improve the performance of the model on specific tasks. Among them, data enhancement can also be distilled from multiple powerful models instead of relying on a single model to reduce bias and increase the diversity of responses.
[0091] For example, the third language model input includes structured agricultural knowledge question-answer pairs and the second prompt word for data enhancement, and outputs agricultural knowledge question-answer pairs with richer, more detailed and complete content. Taking the target crop as litchi as an example:
[0092] Structured question-answer pairs:
[0093] {instruction: "What diseases can be caused by the piercing and sucking behavior of the lychee stink bug?"
[0094] input: ""
[0095] output: “The wounds caused by the stinging of litchi stink bugs are easily infected by downy mildew, causing downy mildew disease.
[0096] ”}
[0097] Question-answer pairs after data augmentation:
[0098] {instruction: "What diseases can be caused by the piercing and sucking behavior of the lychee stink bug?"
[0099] input: ""
[0100] output:"The piercing and sucking behavior of litchi stink bugs can cause a variety of diseases, the most common of which is downy mildew. Specifically, litchi stink bugs leave wounds on plant tissues when sucking litchi leaves, branches or fruits. These wounds provide a pathway for pathogens to invade. In particular, the downy mildew fungus (Peronophythora litchii) can easily infect plant tissues through these wounds, causing downy mildew. This disease causes brown spots on litchi leaves and water-soaked spots on the surface of the fruit. In severe cases, it can cause the fruit to rot, seriously affecting the yield and quality of litchi. In addition, the piercing and sucking behavior of litchi stink bugs may also cause other diseases, such as anthracnose and bacterial canker, which further threaten the health of litchi trees. Therefore, controlling the number of litchi stink bugs is one of the important prevention and control measures in litchi cultivation."}
[0101] Afterwards, the embodiment of the present application can also perform data verification by using a pre-trained large language model to verify the answer pair. After verification, manual verification is performed again to ensure that there are no errors in the question and answer pair.
[0102] Step 205. Fine-tune the fourth large language model according to the second question-answering dataset to obtain a target large language model.
[0103] In this embodiment, the fourth language model can be a question-answering model for the target crop, which can generate new and reasonable text according to the input text data, that is, generate the corresponding answer according to the user's question. The target crop can be the question-answering object that the fourth language model is best at applying, that is, the fourth language model is trained and generated based on the question-answering data related to the target crop.
[0104] The second question-answering dataset contains data-augmented question-answer pairs, each of which is carefully designed to cover all aspects of target crop knowledge. These question-answer pairs, as training data, will be used to adjust the parameters of the fourth language model. The purpose of fine-tuning is to enable the fourth language model to better understand and answer questions related to the target crop, making it a professional question-answering system. During the fine-tuning process, the fourth language model will identify keywords and phrases in the questions by learning these question-answer pairs and associate them with the correct answers, including understanding of the questions and the generation of corresponding answers. The fourth language model will learn how to generate accurate and relevant answers based on the context of the question. The fine-tuned fourth language model can be called the target language model.
[0105] In a possible implementation, the second question-answering dataset includes a test set and a validation set, and the fourth large language model is fine-tuned according to the second question-answering dataset to obtain a target large language model including:
[0106] The fourth language model is fine-tuned according to the test set to obtain the fifth language model;
[0107] Call the fifth language model to infer the answer to the question data in each second question-answer pair in the validation set to obtain the inferred answer data;
[0108] Determine the accuracy of the fifth language model based on the relationship between the inference answer data and the labeled answers in the validation set;
[0109] When the accuracy is greater than a preset accuracy threshold, the fifth largest language model is determined as the target large language model.
[0110] In this implementation, the second question-and-answer dataset can be divided into a test set and a validation set, so that the model can use different data in the training and evaluation stages, thereby avoiding overfitting and being able to more accurately evaluate the generalization ability of the model.
[0111] The test set can be used to fine-tune the fourth language model. By training on the test set, the question and answer pairs learned by the model will help it understand the expertise and language patterns related to the target crop.
[0112] The fifth language model can be the fine-tuning result of the fourth language model based on the test set, that is, the fifth language model can better understand and answer questions related to the target crop than the fourth language model. This model is then called to reason about the answer to the question data in each second question-answer pair in the validation set. The fifth language model will generate reasoning answers to each question, which can be used to evaluate the performance of the fifth language model.
[0113] To determine the accuracy of the fifth language model, we compare the inference answers with the corresponding labeled answers in the validation set, that is, the question data corresponding to the inference answers is the same as the question data corresponding to the labeled answers. If the model's accuracy exceeds the preset accuracy threshold, the fifth language model has met the expected standards in understanding and answering questions related to the target crop. The fifth language model can be identified as the target large language model, which not only performs well on the test set, but also shows excellent performance on the independent validation set.
[0114] In a possible implementation manner, the method further includes:
[0115] When the accuracy is not greater than the preset accuracy threshold, the fourth language model is updated based on the fifth language model, and the process returns to the step of fine-tuning the fourth language model based on the second question and answer dataset, and calculating the accuracy of the fine-tuned fifth language model based on the second question and answer dataset.
[0116] In this implementation, when the accuracy of the fifth language model does not meet the preset accuracy threshold, it means that the performance of the model has not yet reached the expected standard. In this case, the fourth language model can be further optimized and adjusted. Among them, we will update the fourth language model based on the performance of the fifth language model. It can be to adjust the model's architecture, learning rate, optimization algorithm, etc. to improve the model's learning effect and generalization ability, or it can be to directly replace the fourth language model with the fifth language model, that is, to use the fifth language model as the new fourth language model.
[0117] The updated fourth language model will be fine-tuned again using the test set. During the fine-tuning process, the model will learn question-answer pairs again and further optimize its parameters in order to achieve higher accuracy.
[0118] After fine-tuning is completed, the accuracy of the fifth largest language model after fine-tuning can be calculated based on the validation set to verify the effect of model update and fine-tuning. If the accuracy still does not meet the requirements, you can further adjust the model parameters or try other optimization strategies, that is, perform fine-tuning and verification repeatedly until the accuracy of the model exceeds the preset threshold.
[0119] For example, a loop iteration mechanism can be designed during the fine-tuning process, and the model will generate questions and answers and evaluate accuracy after each iteration. If the model reaches a preset accuracy threshold (e.g., 90% accuracy) in a specific question-answering scenario, the iteration is stopped and the model is considered to have a sufficient level of expertise.
[0120] In the embodiment of the present application, the flowchart of the loop iteration mechanism can be referred to Figure 3As shown, step 301. fine-tune the fourth language model according to the test set to obtain the fifth language model. Fine-tune is to train the model through the test set to make it better adapt to the task, adjust the weight of the model, and optimize its performance on the test set. After fine-tuning, the fifth language model is obtained. Step 302. Evaluate the accuracy of the fifth language model according to the validation set. The validation set is a set of data that is not used in the fine-tuning process. It is used to evaluate the generalization ability of the model, that is, the performance of the model on new data. The accuracy evaluation is calculated by comparing the prediction results of the model with the actual labels. Step 303. Determine whether the accuracy meets the preset accuracy threshold. If so, execute step 304, otherwise execute step 301. This threshold is a performance target set in advance, which is used to determine whether the model is good enough for practical applications. If the accuracy of the model reaches this threshold, the fine-tuning process can be terminated. If not, the fine-tuning process needs to continue, and the current fifth language model can be used as the new fourth language model, and step 301 is continued. Step 304. Determine the current fifth language model as the target large language model. If the accuracy of the fifth largest language model meets the preset accuracy threshold, then this model is determined as the target large language model, which means that it has reached the expected performance standard and can be used for actual question-answering tasks or other language processing tasks.
[0121] In a possible implementation, the accuracy rate includes one or more of answer fluency, answer professionalism, and user satisfaction.
[0122] In this implementation, answer fluency refers to the naturalness and coherence of the language of the answer generated by the model. A highly fluent answer should be able to express ideas fluently like a human, use appropriate grammar and vocabulary, and be easy for users to understand and accept.
[0123] The professionalism of the answer involves whether the information provided by the model is accurate, in-depth, and meets professional standards. In the field of target crops, professionalism is particularly important. The model needs to demonstrate the ability to have a deep understanding of crop knowledge, including but not limited to cultivation techniques, pest and disease control, soil management, etc.
[0124] User satisfaction is a more subjective evaluation criterion that reflects the user's overall feeling about the answers provided by the model. This includes the user's satisfaction with the content of the answer, the model's response speed, and the model's interactive experience. The level of user satisfaction directly affects the practicality and popularity of the model. For example, user satisfaction data can be collected through user questionnaires, and the fluency of answers can be evaluated through language quality assessment tools.
[0125] Combining these evaluation criteria, the accuracy of the model can more comprehensively reflect its performance in practical applications. This multi-dimensional evaluation method helps developers identify and improve the shortcomings of the model, thereby continuously improving the performance of the model, better adapting to different application scenarios and user groups, and ultimately achieving more intelligent, efficient and user-friendly information services. In this way, the model can not only provide high-quality answers, but also establish good interactions with users, bringing users a richer and more satisfying user experience.
[0126] In a possible implementation, fine-tuning the fourth large language model according to the second question-answering dataset to obtain a target large language model includes:
[0127] Obtain a score for each second question-answer pair in the second question-answer dataset;
[0128] Adjust the second question-answering dataset according to the scores to obtain a third question-answering dataset;
[0129] The fourth language model is fine-tuned based on the third question-answering dataset.
[0130] In this embodiment, the score can be a quantitative indicator of the quality of each second question-answer pair, and can be collected through the interaction between the actual user and the model to collect user satisfaction feedback on the answer. This can be achieved through online surveys, user rating systems, or direct user comments. It can also be achieved by using NLP technology, such as language models, machine learning algorithms, etc., to automatically evaluate the quality of the answer.
[0131] After obtaining the scores, the second question-answer dataset can be adjusted according to these scores to form a third question-answer dataset. The second question-answer pairs with lower scores can be removed from the second question-answer dataset, or the question-answer pairs with higher scores can be weighted to ensure that the model can learn more high-quality data during the fine-tuning process. In addition, the data can be further optimized according to the scoring results, such as correcting wrong answers, improving expressions, etc. The adjusted second question-answer dataset can be called the third question-answer dataset, and the third question-answer dataset is then used to fine-tune the fourth language model.
[0132] For example, an adaptive fine-tuning strategy can be introduced, using parameter-efficient fine-tuning (PEFT) methods, such as low-rank adaptation (LoRA), P-Tuning-v2, and prefix tuning methods, to dynamically adjust the training data set based on agricultural question-answering feedback (such as user reviews or scores from automatic evaluation systems), and selectively add or replace fine-tuning data based on performance. Through this adaptive mechanism, the accuracy of the model in agricultural vertical field question-answering can be gradually improved.
[0133] The schematic diagram of the adaptive fine-tuning process of the embodiment of the present application can be referred to Figure 4 As shown in the figure, users can ask questions, the big model generates answers based on the questions, and users give feedback on the answers of the question-answering model. If the user is not satisfied with the answer, that is, gives negative feedback, the question-answering dataset can be dynamically adjusted to identify and solve the problems in the answer. The adjusted question-answering dataset is then used to fine-tune the question-answering model.
[0134] When the user is satisfied with the answer, that is, gives positive feedback, the question-answer pair can be used as a positive sample to strengthen the performance of the model in similar situations.
[0135] If the user does not provide any feedback, they can evaluate the question and answer session themselves.
[0136] After fine-tuning, the question-answering model can enter an iterative optimization process, which means constantly obtaining users' actual experience to continuously improve the performance of the model. In this way, the model can better adapt to users' needs and provide more accurate and satisfactory services.
[0137] The schematic diagram of the question-answering model fine-tuning process of the embodiment of the present application can be referred to Figure 5 As shown, step 501. crawl professional data. By designing a crawler program, crawl the knowledge data related to the target crop from the professional website. Step 502. Extract key data from professional data. The large language model can understand a large amount of unstructured text data, including professional literature, research reports, online forum discussions, etc., and extract information related to the target crop from it. Step 503. Convert the key data into a structured question-answer pair. The question-answer pair includes a question data and the answer label corresponding to the question data, and the answer label is the correct answer to the question data. Step 504. Perform data enhancement on the question-answer pair. For example, create variants of the question-answer pair by synonym replacement, sentence reorganization, background information addition, etc. Step 505. Fine-tune the question-answer model with the data-enhanced question-answer pair, and iterate and optimize it in a loop. Calculate the accuracy corresponding to the fine-tuned question-answer model based on the validation set. Verify the effect of model update and fine-tuning. If the accuracy still does not meet the requirements, you can further adjust the model parameters or try other optimization strategies, that is, perform fine-tuning and verification in a loop until the accuracy of the model exceeds the preset threshold. Step 506: Automated iterative optimization based on user feedback. Based on the cumulative effect of user feedback and system evaluation results. Each user feedback and system evaluation provides an opportunity for the model to learn and improve. Through continuous iteration, the performance of the model will gradually improve and eventually reach a more optimized state. This iterative process may be repeated multiple times until the model's answer meets the preset performance standards or user satisfaction requirements.
[0138] The embodiment of the present application obtains first data, which includes knowledge data of the target crop; calls a first large language model to extract data from the first data to obtain second data; calls a second large language model to process the second data and a preset first prompt word to obtain a first question and answer data set, and the first question and answer data set includes multiple first question and answer pairs; calls a third large language model to perform data enhancement on each first question and answer pair and a preset second prompt word to obtain a second question and answer data set, and the second question and answer data set includes a second question and answer pair corresponding to each first question and answer pair; fine-tunes the fourth large language model according to the second question and answer data set to obtain a target large language model, and the fourth large language model is a question and answer model related to the target crop. Through the above method, the first language model is first used to extract structured data from unstructured data, and then the second language model and the first prompt word are used to convert the structured data into question-answer pairs, and the third language model is called to perform data enhancement on the question-answer pairs. A large amount of non-target information has been removed during the structuring process, which can reduce the interference of noise and irrelevant information in the data enhancement process. The second prompt word provides samples that can clarify the specific requirements of the third language model task, reduce the possibility of misunderstanding or deviation from the topic during the data enhancement process, and improve data quality.
[0139] The above describes the question-answering model fine-tuning method, and the following describes the device for executing the method.
[0140] See also Figure 6 ,like Figure 6 The present invention provides a question-answer model fine-tuning device according to an embodiment of the present invention. The device 60 includes:
[0141] An acquisition unit 601 is used to acquire first data, where the first data includes knowledge data of a target crop;
[0142] An extraction unit 602 is used to call the first language model to extract data from the first data to obtain second data;
[0143] A processing unit 603 is used to call the second largest language model to process the second data and the preset first prompt word to obtain a first question and answer data set, where the first question and answer data set includes a plurality of first question and answer pairs;
[0144] An enhancement unit 604 is used to call the third language model to perform data enhancement on each first question-answer pair and a preset second prompt word to obtain a second question-answer data set, where the second question-answer data set includes a second question-answer pair corresponding to each first question-answer pair;
[0145] The fine-tuning unit 605 is used to fine-tune the fourth language model according to the second question-answering data set to obtain a target large language model, where the fourth language model is a question-answering model related to the target crop.
[0146] In some embodiments, the second question-answering dataset includes a test set and a validation set, and the fine-tuning unit 605 is specifically used to:
[0147] The fourth language model is fine-tuned according to the test set to obtain the fifth language model;
[0148] Call the fifth language model to infer the answer to the question data in each second question-answer pair in the validation set to obtain the inferred answer data;
[0149] Determine the accuracy of the fifth language model based on the relationship between the inference answer data and the labeled answers in the validation set;
[0150] When the accuracy is greater than a preset accuracy threshold, the fifth largest language model is determined as the target large language model.
[0151] In some embodiments, the fine-tuning unit 605 is further configured to:
[0152] When the accuracy is not greater than the preset accuracy threshold, the fourth language model is updated based on the fifth language model, and the process returns to the step of fine-tuning the fourth language model based on the test set, and calculating the accuracy of the fine-tuned fifth language model based on the validation set.
[0153] In some embodiments, the accuracy rate includes one or more of answer fluency, answer professionalism, and user satisfaction.
[0154] In some embodiments, the fine-tuning unit 605 is specifically configured to:
[0155] Obtain a score for each second question-answer pair in the second question-answer dataset;
[0156] Adjust the second question-answering dataset according to the scores to obtain a third question-answering dataset;
[0157] The fourth language model is fine-tuned based on the third question-answering dataset.
[0158] In some embodiments, the acquisition unit 601 is specifically used to:
[0159] Obtain various knowledge data URLs;
[0160] The knowledge data related to the target crop is crawled from each knowledge data website to obtain the first data.
[0161] In some embodiments, the acquisition unit 601 is specifically used to:
[0162] crawling knowledge data related to the target crop from each knowledge data website to obtain third data;
[0163] Data whose semantic similarity satisfies a condition is selected from the third data to obtain the first data.
[0164] The specific implementation of the question-answer model fine-tuning device is basically the same as the specific implementation example of the above-mentioned question-answer model fine-tuning method, and will not be repeated here.
[0165] The embodiment of the present application also provides an electronic device, the electronic device includes a memory and a processor, the memory stores a computer program, and the processor implements the above-mentioned question-answering model fine-tuning method when executing the computer program. The electronic device can be any intelligent terminal including a tablet computer, a car computer, etc.
[0166] See also Figure 7 , Figure 7 The hardware structure of an electronic device of another embodiment is illustrated, and the electronic device includes:
[0167] The processor 701 may be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of the present application;
[0168] The memory 702 can be implemented in the form of a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 702 can store an operating system and other applications. When the technical solution provided in the embodiment of this specification is implemented by software or firmware, the relevant program code is stored in the memory 702, and the processor 701 calls and executes the question-answering model fine-tuning method of the embodiment of this application;
[0169] Input / output interface 703, used to implement information input and output;
[0170] Communication interface 704, used to realize communication interaction between the device and other devices, which can be realized through wired mode (such as USB, network cable, etc.) or wireless mode (such as mobile network, WIFI, Bluetooth, etc.);
[0171] A bus 705 that transmits information between the various components of the device (e.g., the processor 701, the memory 702, the input / output interface 703, and the communication interface 704);
[0172] The processor 701 , the memory 702 , the input / output interface 703 and the communication interface 704 are connected to each other in communication within the device via a bus 705 .
[0173] An embodiment of the present application also provides a computer-readable storage medium, which stores a computer program, and when the computer program is executed by a processor, the above-mentioned question and answer model fine-tuning method is implemented.
[0174] The memory, as a non-transient computer-readable storage medium, can be used to store non-transient software programs and non-transient computer executable programs. In addition, the memory may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory may optionally include a memory remotely disposed relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0175] The embodiments described in the embodiments of the present application are intended to more clearly illustrate the technical solutions of the embodiments of the present application and do not constitute a limitation on the technical solutions provided in the embodiments of the present application. Those skilled in the art will appreciate that with the evolution of technology and the emergence of new application scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
[0176] Those skilled in the art will appreciate that the technical solutions shown in the figures do not constitute a limitation on the embodiments of the present application, and may include more or fewer steps than shown in the figures, or a combination of certain steps, or different steps.
[0177] The device embodiments described above are merely illustrative, and the units described as separate components may or may not be physically separated, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0178] Those skilled in the art will appreciate that all or some of the steps in the methods disclosed above, and the functional modules / units in the systems and devices may be implemented as software, firmware, hardware, or a suitable combination thereof.
[0179] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0180] It should be understood that in the present application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.
[0181] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the above units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0182] The units described above as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0183] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0184] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes multiple instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods of various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk, and other media that can store programs.
[0185] The preferred embodiments of the present invention are described above with reference to the accompanying drawings, but the scope of the rights of the present invention is not limited thereto. Any modification, equivalent substitution and improvement made by a person skilled in the art without departing from the scope and essence of the present invention should be within the scope of the rights of the present invention.
Claims
1. A method for fine-tuning a question-answering model, characterized in that: The method comprises: Acquiring first data, wherein the first data includes knowledge data of a target crop; Calling a first language model to extract data from the first data to obtain second data; Calling a second language model to process the second data and a preset first prompt word to obtain a first question-answer data set, where the first question-answer data set includes a plurality of first question-answer pairs; Calling the third language model to perform data enhancement on each first question-answer pair and a preset second prompt word to obtain a second question-answer data set, where the second question-answer data set includes a second question-answer pair corresponding to each first question-answer pair; The fourth language model is fine-tuned according to the second question-answering dataset to obtain a target large language model, where the fourth language model is a question-answering model related to the target crop.
2. The method according to claim 1, characterized in that The second question-answering dataset includes a test set and a validation set, and the fine-tuning of the fourth language model according to the second question-answering dataset to obtain a target language model includes: Fine-tune the fourth language model according to the test set to obtain a fifth language model; Calling the fifth language model to perform answer inference on the question data in each second question-answer pair in the validation set to obtain inferred answer data; Determining the accuracy of the fifth language model according to the relationship between the inference answer data and the label answers in the validation set; When the accuracy is greater than a preset accuracy threshold, the fifth largest language model is determined as the target large language model.
3. The method according to claim 2, characterized in that The method further comprises: When the accuracy is not greater than the preset accuracy threshold, the fourth language model is updated based on the fifth language model, and the process returns to the step of fine-tuning the fourth language model based on the test set, and calculating the accuracy of the fine-tuned fifth language model based on the validation set.
4. The method according to claim 2, characterized in that: The accuracy rate includes one or more of answer fluency, answer professionalism and user satisfaction.
5. The method according to claim 1, characterized in that The fine-tuning of the fourth language model according to the second question-answering dataset to obtain a target large language model includes: Obtaining a score for each second question-answer pair in the second question-answer dataset; Adjust the second question-answering dataset according to the score to obtain a third question-answering dataset; The fourth language model is fine-tuned according to the third question-answering dataset.
6. The method according to claim 1, characterized in that The obtaining of the first data comprises: Obtain various knowledge data URLs; The knowledge data related to the target crop is crawled from each knowledge data website to obtain first data.
7. The method according to claim 6, characterized in that The step of crawling the target crop-related knowledge data from each knowledge data website to obtain the first data includes: crawling the knowledge data related to the target crop from each knowledge data website to obtain third data; Data whose semantic similarity satisfies a condition is selected from the third data to obtain the first data.
8. A question-answering model fine-tuning device, characterized in that: The device comprises: An acquisition unit, configured to acquire first data, wherein the first data includes knowledge data of a target crop; An extraction unit, configured to call a first large language model to extract data from the first data to obtain second data; a processing unit, configured to call a second language model to process the second data and a preset first prompt word to obtain a first question-answer data set, wherein the first question-answer data set includes a plurality of first question-answer pairs; an enhancement unit, configured to perform data enhancement on each first question-answer pair and a preset second prompt word by calling a third language model to obtain a second question-answer data set, wherein the second question-answer data set includes a second question-answer pair corresponding to each first question-answer pair; A fine-tuning unit is used to fine-tune the fourth large language model according to the second question and answer data set to obtain a target large language model, wherein the fourth large language model is a question and answer model related to the target crop.
9. An electronic device, characterized in that: The electronic device includes a memory and a processor, the memory stores a computer program, and the processor implements the question-answering model fine-tuning method according to any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the question-answering model fine-tuning method described in any one of claims 1 to 7 is implemented.
Citation Information
Cited By
Large model fine tuning method and device, equipment, storage medium and program product
CN120745836A
Large model workflow-based data processing and fine tuning data synthesis method, system and device, and medium
CN121053667A