Sample set generation method, model training method and related device
By augmenting the vertical field sample data of the natural language processing model, high-quality sample Q&A pairs are generated, which solves the problem of insufficient sample data in the vertical field, and improves the training effect and answer accuracy of the model.
Patent Information
- Application Number
- CN202311028830.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-15
- Publication Date
- 2025-02-25
AI Technical Summary
The existing natural language processing models have low answer accuracy in vertical fields, which is mainly due to insufficient sample data in vertical fields, resulting in unsatisfactory training results.
Through two natural language processing models, a small amount of problem templates and text data are augmented, and a sample collection includes a large number of sample question-and-answer pairs are generated. The specific steps include: generating initial question text based on the question template and text data, inputting it to the converged natural language processing model to obtain the target question text and answer text, forming a sample question and answer pair, and forming a sample set.
It effectively improves the training effect of natural language processing models in the vertical field, increases the number and quality of sample sets, and improves the accuracy of the model's answers.
Smart Images

Figure CN119513588A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of natural language processing, and in particular to a sample set generation method, a model training method and related devices. Background Art
[0002] Natural language processing (NLP) is an important direction in the fields of computer science and artificial intelligence. With the popularity of Chat Generative Pre-trained Transformer (chatGPT) on social media, large models with huge parameter counts have attracted more and more attention, and larger models usually have better performance. For example, the GPT-3 model has 175 billion parameters, while the GPT-4 model has an even larger parameter scale. These models are applied in the field of Natural Language Processing (NLP), can understand and generate human language, and perform well in tasks such as text translation, question-answering systems, and language generation.
[0003] However, ChatGPT is not a panacea. Its accuracy in answering questions in vertical fields is not high, which is limited by the problem of insufficient sample data in vertical fields. For example, if you want to train a natural language processing model similar to ChatGPT, and the answer accuracy of this natural language processing model in the field of network security meets the expected accuracy, it is usually necessary to fine-tune the general basic model of the natural language processing model with the help of prompt word training Prompt Tuning and reinforcement learning (RLHF) technology that optimizes language based on human feedback, so that the trained natural language processing model can fluently and accurately answer questions in the field of network security. However, such training usually requires a sample set that includes at least one labeled sample data, and due to the requirement of generalization, the number of sample data in this sample set is usually very high. Summary of the invention
[0004] The embodiments of the present application provide a sample set generation method, a model training method and related devices, which can improve the quantity and quality of sample sets used for training natural language processing models. The technical solution is as follows:
[0005] In a first aspect, an embodiment of the present application provides a method for generating a sample set, the method comprising:
[0006] Obtaining a plurality of initial question texts about the target domain according to at least one question template and text data about the target domain;
[0007] Inputting the multiple initial question texts into a converged first natural language processing model to obtain a first dialogue result, wherein the first dialogue result includes multiple target question texts corresponding to each of the initial question texts;
[0008] Inputting the multiple target question texts into a converged second natural language processing model to obtain a second dialogue result, wherein the second dialogue result includes at least one first answer text corresponding to each of the target question texts;
[0009] The target question text and at least one first answer text corresponding to the target question text are combined into a first sample question-answer pair, a first sample set includes a plurality of the first sample question-answer pairs, and the sample set includes the first sample set.
[0010] In a second aspect, an embodiment of the present application provides a model training method, the model training method comprising:
[0011] Acquire a sample set, where the sample set is obtained by the sample set generation method described in the first aspect;
[0012] The natural language processing model to be trained is trained according to the sample set until the natural language processing model to be trained is trained to converge, thereby obtaining a target natural language processing model for performing a dialogue task on a target domain.
[0013] In a third aspect, an embodiment of the present application provides a sample set generation device, the sample set generation device comprising:
[0014] An initial question module, used to obtain a plurality of initial question texts about the target field according to at least one question template and text data about the target field;
[0015] A first dialogue module, configured to input the multiple initial question texts into a converged first natural language processing model to obtain a first dialogue result, wherein the first dialogue result includes multiple target question texts corresponding to each of the initial question texts;
[0016] A second dialogue module, configured to input the plurality of target question texts into a converged second natural language processing model to obtain a second dialogue result, wherein the second dialogue result includes at least one first answer text corresponding to each of the target question texts;
[0017] The first sample module is used to form a first sample question-answer pair by combining the target question text and at least one first answer text corresponding to the target question text. The first sample set includes multiple first sample question-answer pairs, and the sample set includes the first sample set.
[0018] In a fourth aspect, an embodiment of the present application provides a model training device, the model training device comprising:
[0019] A first acquisition module, configured to acquire a sample set, wherein the sample set is obtained by the sample set generation method described in the first aspect;
[0020] The model training module is used to train the natural language processing model to be trained according to the sample set until the natural language processing model to be trained is trained to convergence, thereby obtaining a target natural language processing model for performing a dialogue task on a target domain.
[0021] In a fifth aspect, an embodiment of the present application provides a computer storage medium, wherein the computer storage medium stores a plurality of instructions, wherein the instructions are suitable for being loaded by a processor and executing the above-mentioned method steps.
[0022] In a sixth aspect, an embodiment of the present application provides an electronic device, which may include: a processor and a memory; wherein the memory stores a computer program, and the computer program is suitable for being loaded by the processor and executing the above-mentioned method steps.
[0023] The beneficial effects brought about by the technical solutions provided by some embodiments of the present application include at least:
[0024] In the present application, a small amount of question templates and text data are expanded by two natural language processing models to obtain a sample set including a large number of sample question-answer pairs. Specifically, multiple initial question texts are obtained through at least one question template and text data about the target field, and the multiple initial question texts are used as input data of the first natural language processing model, and the first dialogue results including multiple target question texts corresponding to each initial question text are further obtained as output data. Further, the multiple target question texts are used as input data of the second natural language processing model, and the second dialogue results including at least one first answer text corresponding to each target question text are obtained as output data. The target question text and the at least one first answer text corresponding to the target question text constitute a first sample question-answer pair, thereby obtaining a first sample set including multiple first sample question-answer pairs, and the sample set includes the first sample set. In the present application, a sample set for training a natural language processing model to be trained can be obtained through a small number of question templates, and the sample set includes a large number of high-quality and annotated sample question-answer pairs about the target field. The sample set can effectively improve the training effect of training the natural language processing model to be trained, and the acquisition efficiency of the sample set is high. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0026] Figure 1 It is a flowchart of a natural language processing model training provided in an embodiment of the present application;
[0027] Figure 2 It is a flowchart of a sample set generation method provided in an embodiment of the present application;
[0028] Figure 3 is a schematic diagram of a process for obtaining a first sample set provided by an embodiment of the present application;
[0029] Figure 4 It is a flowchart of a sample set generation method provided in an embodiment of the present application;
[0030] Figure 5 is a schematic diagram of a process for obtaining a second sample set provided in an embodiment of the present application;
[0031] Figure 6 It is a flowchart of a sample set generation method provided in an embodiment of the present application;
[0032] Figure 7 is a schematic diagram of a process for obtaining a third sample set provided in an embodiment of the present application;
[0033] Figure 8 It is a flowchart of a model training method provided in an embodiment of the present application;
[0034] Fig. 9 It is a flowchart of another model training method provided in an embodiment of the present application;
[0035] Fig.10 is a structural schematic diagram of a sample set generating device provided in an embodiment of the present application;
[0036] Fig.11 It is a structural schematic diagram of a model training device provided in an embodiment of the present application;
[0037] Fig.12 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0038] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0039] In the description of the present application, it should be understood that the terms "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or implying relative importance. In the description of the present application, it should be noted that, unless otherwise clearly specified and limited, "including" and "having" 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 limited to the listed steps or units, but optionally also includes steps or units that are not listed, or optionally also includes other steps or units inherent to these processes, methods, products or devices. For those of ordinary skill in the art, the specific meanings of the above terms in the present application can be understood in specific circumstances. In addition, in the description of the present application, unless otherwise specified, "multiple" refers to two or more. "And / or" describes the association relationship of associated objects, indicating that there can be three relationships, for example, A and / or B, which can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the associated objects before and after are an "or" relationship.
[0040] The present application is described in detail below with reference to specific embodiments.
[0041] It should be noted that the information (including but not limited to user device information, user personal information, etc.), data (including but not limited to data for analysis, stored data, displayed data, etc.) and signals involved in the embodiments of this application are all authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards of relevant countries and regions. For example, the data information involved in this application is obtained with full authorization, for example, the data information is text data about the target field.
[0042] Natural language processing (NLP) is an important direction in the fields of computer science and artificial intelligence. It studies various theories and methods that can achieve effective communication between people and computers using natural language. Natural language processing is a science that integrates linguistics, computer science, and mathematics. Therefore, research in this field will involve natural language, that is, the language people use in daily life, so it is closely related to the study of linguistics. Natural language processing technology usually includes text processing, semantic understanding, machine translation, robot question answering, knowledge graph and other technologies.
[0043] As Chat Generative Pre-trained Transformer (chatGPT) has become popular on social media, large models with huge parameter counts have attracted more and more attention, and larger models usually have better performance. For example, the GPT-3 model has 175 billion parameters, while the GPT-4 model has an even larger parameter scale. These models are applied in the field of Natural Language Processing (NLP), can understand and generate human language, and perform well in tasks such as text translation, question-answering systems, and language generation.
[0044] The method in which users use this type of natural language processing model to process dialogue tasks usually involves inputting a question text into the natural language processing model in the form of a question, thereby obtaining an answer text corresponding to the question text as a dialogue result. For example, a user inputs the question text "What is a crawler?" into a large model, and obtains the answer text "A crawler is a program that automatically obtains web page content" or "A crawler is a vertebrate" output by the large model as a dialogue result. When a user wants the natural language processing model to perform a dialogue task in the field of network security, that is, when the user wants the natural language processing model to output the answer text "A crawler is a program that automatically obtains web page content" as a dialogue result, the natural language processing model needs to be trained in a vertical field. In other words, a natural language processing model is trained to perform dialogue tasks in the target field.
[0045] Therefore, a fine-tuning training method based on prompt words came into being. Specifically, when the user inputs the question text into the natural language processing model in the form of a question, he also inputs the prompt word, and the prompt word instructs the natural language processing model to obtain a more accurate answer text. Figure 1 As shown, Figure 1 This is a process for training a natural language processing model provided by an embodiment of the present application. When inputting a question sample text 1021 into the natural language processing model 103, a prompt word 101 is also input, thereby obtaining an answer text 104 corresponding to the input question sample text 102 output by the natural language processing model 103, and further adjusting the parameters of the natural language processing model 103 through the answer sample text 1022 corresponding to the question sample text 1021 and the answer text 104, thereby finally obtaining a natural language processing model for performing a dialogue task in the target field. For example, the content of the prompt word 101 is "You are an expert in the field of network security", the prompt word 101 is related to the field of network security, and the content of the question sample text 102 is "What is a crawler?" The difference information between the answer text 104 generated by the natural language dialogue model 103 and the answer sample text 1022 corresponding to the question sample text 102 "A crawler is a program that automatically obtains web page content" is used to adjust the parameters of the natural language processing model 103.
[0046] However, due to the problem of insufficient sample data in vertical fields, the training effect of natural language processing models is not ideal. For example, if you want to train a natural language processing model similar to ChatGPT and achieve the expected accuracy of the natural language processing model in the field of network security, you need to fine-tune the general basic model of the natural language processing model with the help of prompt word training Prompt Tuning and reinforcement learning (RLHF) technology that optimizes language based on human feedback. The general basic model can be fine-tuned so that the trained natural language processing model can fluently and accurately answer questions in the field of network security. However, such training usually requires a sample set that includes at least one labeled sample data, and due to the requirement of generalization, the number of sample data in the sample set is usually very high.
[0047] Therefore, the present application proposes a sample set generation method, which is used to solve some or all of the above problems. Figure 2As shown, it is a schematic diagram of a sample set generation method proposed in an embodiment of the present application, which can be implemented by a computer program and can be run on a sample set generation device based on the von Neumann system. The computer program can be integrated into an application or run as an independent tool application.
[0048] Specifically, the sample set generation method includes:
[0049] S101. Obtain a plurality of initial question texts about a target domain according to at least one question template and text data about a target domain.
[0050] The execution subject of the embodiment of the present application is a terminal device, which is an electronic device used by a user. The electronic device can be a personal computer, a mobile phone, a tablet computer, etc., which has a certain computing power and runs an application or web page with a prompt word generation function. It can also be a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms. It can be understood that the number and type of the above-mentioned terminal devices are only for illustration, and the embodiment of the present application does not impose any restrictions on this.
[0051] Text data can be understood as a text segment that can express meaning and is composed of Chinese or non-Chinese natural languages, including any text quantity such as sentences, paragraphs, articles, and any language form such as English, Chinese, German, Japanese, etc., and the sample text includes any information that technicians in this field need to extract, such as text, semantics, text location, punctuation, and the frequency of repeated words. Natural language includes multiple fields, for example, natural language includes multiple large and small fields such as medicine, science, food, and safety. The target field can be understood as one of the above multiple fields.
[0052] In one embodiment, the text data about the target domain is obtained by: obtaining through one or more natural language public data sets, or obtaining through professional corpora about the target domain. For example, the natural language public data sets can be three classic natural language public data sets, including: Reuters News Corpus Dataset (Reuters Corpus Volume I, RCV1-V2) data set, The New York Times Annotated Corpus data set (The New York Times Annotated Corpus, NYT) and Science Corpus Dataset (Web of Science, WOS) data set. RCV1-V2 data set and NYT data set are both news text corpora, while WOS data set includes abstracts of published papers from Web of Science. For another example, the professional corpus about the target domain can be a professional magazine in the target domain or a local corpus uploaded by professionals about the target domain.
[0053] Question templates can be understood as a fixed format for generating specific question text based on text data. Templates are the result of fixing and standardizing the structural rules of a prompt word, which reflects the standardization of structural forms. For example, question templates are "What is [name]?" "Which software or systems does [name] affect?" "Is there a known attack that exploits [name]?" "Who discovered [name]?" "Which manufacturers have released security patches for [name]?" "If I use software or systems affected by [name], what measures should I take?" "Does this [name] require physical access to be exploited?" and so on. Question templates can be obtained from user input or other methods.
[0054] Based on at least one question template and text data about the target domain, multiple initial question texts about the target domain are obtained. The multiple initial question texts are used as input data of the first natural language processing model. For example, the target domain is network security, the text data about the target domain includes a large amount of text data related to vulnerabilities, at least one question template includes at least the above-mentioned question template, and the initial question text obtained is "Give me questions related to the [name] vulnerability, similar to: 'What is [name]?' 'Which software or systems will be affected by [name]?' 'Are there any known attacks that exploit [name]?'", or the initial question text obtained is "Give me questions related to the [name] vulnerability, similar to: 'Which manufacturers have already released security patches for [name]?' 'If I use software or systems affected by [name], what measures should I take?'".
[0055] Specifically, if Figure 3As shown, Figure 3 It is a flowchart of obtaining a first sample set provided by an embodiment of the present application. Obtain multiple question templates 201 and text data 202 about the target field, wherein the multiple question templates 201 include "What is [name]?" "Which software or systems will be affected by [name]?" "Is there a known attack that exploits [name]?" "Who discovered [name]?" "Which manufacturers have released security patches for [name]?" "If I use software or systems affected by [name], what measures should I take?" "Does this [name] require physical access to be exploited?" and so on.
[0056] Further, based on the multiple question templates 201 and the text data 202 about the target domain, multiple initial question texts are obtained as input data of the converged first natural language processing model 204. The multiple initial question texts at least include initial question text 2031, initial question text 2032, and initial question text 2033. For example, initial question text 2031 is "Give me questions related to the [name1] vulnerability, similar to: 'What is [name]?' 'What software or systems does [name] affect?' 'Is there a known attack that exploits [name]?'", initial question text 2032 is "Give me questions related to the [name2] vulnerability, similar to: 'What is [name]?' 'What software or systems does [name] affect?' 'Is there a known attack that exploits [name]?'", and initial question text 2033 is "Give me questions related to the [name2] vulnerability, similar to: 'If I use software or systems affected by [name], what measures should I take?'".
[0057] It can be understood that the above-mentioned multiple question templates and specific contents and the specific content of the initial question text are only for illustration and are not limitations of the embodiments of the present application.
[0058] S102: Input a plurality of initial question texts into a converged first natural language processing model to obtain a first dialogue result.
[0059] The first dialogue result includes multiple target question texts corresponding to each initial question text. In other words, the first dialogue result is the output data of the first natural language processing model for the multiple initial question texts, and specifically multiple target question texts corresponding to each initial question text.
[0060] For example, the initial question text is "Give me questions about the vulnerability CVE-2021-2429, similar to 'What is [name]?' 'What software or systems does [name] affect?' 'Are there any known attacks that exploit [name]?'", and the initial question text is input into the first natural language processing model to obtain a first dialogue result including multiple target question texts corresponding to the initial question text. The multiple target question texts include the target question text "What is CVE-2021-2429?", the target question text "What software or systems does CVE-2021-2429 affect?", and the target question text "Are there any known attacks that exploit CVE-2021-2429?", etc.
[0061] For another example, the initial question text is "Give me questions about the vulnerability CVE-2021-2429, similar to: 'If I use software or a system affected by [name], what measures should I take?'", and the initial question text is input into the first natural language processing model to obtain a first dialogue result including multiple target question texts corresponding to the initial question text. The multiple target question texts include the target question text "If I use software affected by CVE-2021-2429, can I delete the software?", the target question text "If I use a system affected by CVE-2021-2429, can I reinstall the system?", and the target question "If I use software affected by CVE-2021-2429, can I report CVE-2021-2429 to the software operation and maintenance personnel?", etc.
[0062] like Figure 3 As shown, multiple initial question texts are output to the first natural language processing model 204, and the multiple initial question texts include at least an initial question text 2031, an initial question text 2032, and an initial question text 2034. Further, a first dialogue result 205 of the first natural language processing model 204 for the multiple initial question texts is obtained. The first dialogue result 205 includes at least one target question text corresponding to each initial question text. Specifically, the first dialogue result 205 includes at least one target question text 2051 corresponding to the initial question text 2031, at least one target question text 2052 corresponding to the initial question text 2032, and at least one target question text 2053 corresponding to the initial question text 2033. It can be understood that Figure 3 The number of initial question texts and target question texts shown in the figure is for illustration only and this application does not impose any limitation on this.
[0063] The first natural language processing model 204 is a natural language processing model trained to convergence, and may include a convolutional neural network (CNN), a recurrent neural network (RNN), or a Transformer network based on the attention mechanism Attention and a classification layer, wherein CNN, RNN, and Transformer are used to semantically encode the input prompt words, and the classification layer is used to map the label dimension of the encoding vector. For another example, the first natural language processing model 204 may be a BERT pre-trained model, and the BERT (Bidirectional Encoder Representation from Transformers) pre-trained model is a model that recalls at least one dialogue result corresponding to the prompt word by running a self-supervised learning method based on a massive corpus, and self-supervised learning refers to supervised learning running on data without manual annotation. For another example, the first natural language processing model 204 is a Chat Generative Pre-trained Transforme (chatGPT), or a causal language model (CLM, Causal Language Model).
[0064] Preferably, the first natural language processing module 204 is a GPT-4 model or a GPT-3 model. The GPT-4 model has a stronger interactive capability, and it is easier to obtain multiple target question texts with stronger generalization and reliability through the GPT-4 model.
[0065] S103: Input multiple target question texts into a converged second natural language processing model to obtain a second dialogue result.
[0066] The second dialogue result includes at least one first answer text corresponding to each target question text. In other words, the second dialogue result is the output data of the second natural language processing model for multiple target question texts, and specifically at least one answer text corresponding to each target question text.
[0067] The answer text can be understood as the explanation text or answer text corresponding to the target question text. For example, for the target question text "What is CVE-2021-2429?", the first answer text is obtained, and the first answer text includes "CVE-2021-2429 is a heap-based buffer overflow vulnerability located in the Inno DB memecached plugin." For another example, for the target question text "Are there any known attacks that exploit CVE-2021-2429?", the first answer text includes "Yes, the attack exists."
[0068] like Figure 3 As shown, multiple target question texts in the first dialogue result 205 are input into the second natural language processing model 206 to obtain a second dialogue result 207 of the second natural language processing model 206. The second dialogue result 207 includes at least one first answer text corresponding to each target question text, specifically including at least one first answer text 2071 corresponding to the target question text 2051, at least one first answer text 2072 corresponding to the target question text 2052, at least one first answer text 2073 corresponding to the target question text 2053, at least one first answer text 2074 corresponding to a target question text similar to the target question text 2051 and obtained through the initial question text 2031, at least one first answer text 2075 corresponding to a target question text similar to the target question text 2052 and obtained through the initial question text 2032, and at least one first answer text 2076 corresponding to a target question text similar to the target question text 2053 and obtained through the initial question text 2033.
[0069] The types of the first natural language processing model and the second natural language processing model may be the same or different, and this application does not impose any limitation on this.
[0070] S104: The target question text and at least one first answer text corresponding to the target question text form a first sample text pair.
[0071] The first sample set includes multiple first sample question-answer pairs, and the sample set includes the first sample set. At least one first answer text corresponding to the target question text is sorted, and the sorting rule is the accuracy of the first answer text. Further obtain at least one first target answer text whose ranking is before a preset ranking, or whose ranking accounts for a preset number of the total number of at least one first answer text corresponding to the target question text, and form a first sample text pair with the target question. In this embodiment, at least one first answer text corresponding to the target question text is sorted, so as to obtain at least one first target answer text corresponding to the target question text to generate a first sample text pair, thereby improving the question and answer quality of multiple first sample text pairs in the first sample set.
[0072] like Figure 3As shown, at least one first answer text 2071 corresponding to the target question text 2051 is composed of a first sample text answer 2081, at least one first answer text 2072 corresponding to the target question text 2052 is composed of a first sample text answer 2082, at least one first answer text 2073 corresponding to the target question text 2053 is composed of a first sample text answer 2083, at least one first answer text 2074 corresponding to the target question text 2054 is composed of a first sample text answer 2084, etc. The first dialogue set 2081 includes at least a first sample question and answer pair 2081, a first sample question and answer pair 2082, a first sample question and answer pair 2083, and a first sample question and answer pair 2084.
[0073] In one embodiment, each target question text is annotated according to the detailed information corresponding to each target question text, and the annotated target question text and at least one first answer text corresponding to the annotated target question text form a first sample question-answer pair. The detailed information corresponding to the target question text can be understood as annotation information on the specific content of the target question text. For example, the target question text is "What is CVE-2021-2429?" The detailed information corresponding to the target question text includes at least: the detailed information and impact of CVE-2021-2429, the attack path, the difficulty or complexity of the attack, the PoC reference document, the repair suggestions and steps, the script for detecting whether CVE-2021-2429 exists, the impact of CVE-2021-2429 on data confidentiality, the impact of CVE-2021-2429 on data security, the requirements of CVE-2021-2429 for data permissions, the patch repair link of CVE-2021-2429, the scope of impact of CVE-2021-2429, etc.
[0074] In this embodiment, by annotating the target question text with detailed information of the target question text, the annotated target question text and at least one first answer text corresponding to the annotated target question text are further combined into a first sample question-answer pair, thereby improving the data quality of the first sample set including multiple first sample question-answer pairs, thereby improving the training effect of the natural language processing model to be trained through the first sample set.
[0075] In another embodiment, according to the detailed information corresponding to each target question text, before the target question text is annotated, the method further includes: inputting the preset prompt words and the target question text into the converged fourth natural language processing model to obtain a fifth dialogue result, wherein the fifth dialogue result includes the detailed information corresponding to each target question text. In other words, the input data of the fourth natural language processing model is generated by the preset prompt words and the target question text, and the detailed information corresponding to each target question text is generated by the fourth natural language processing model. The detailed information corresponding to the target question text is also the fifth dialogue result, so that the target question text is annotated. The fourth natural language processing model and the first natural language processing model and the second natural language processing model may be the same, not completely the same, or completely different, and this application does not impose any restrictions on this.
[0076] In this embodiment, detailed information of the target question text is obtained through a converged natural language processing model, which can improve the efficiency of obtaining detailed information of the target question text, and the accuracy of the obtained detailed information is relatively high.
[0077] In the present application, a small amount of question templates and text data are expanded by two natural language processing models to obtain a sample set including a large number of sample question-answer pairs. Specifically, multiple initial question texts are obtained through at least one question template and text data about the target field, and the multiple initial question texts are used as input data of the first natural language processing model, and the first dialogue results including multiple target question texts corresponding to each initial question text are further obtained as output data. Further, the multiple target question texts are used as input data of the second natural language processing model, and the second dialogue results including at least one first answer text corresponding to each target question text are obtained as output data. The target question text and the at least one first answer text corresponding to the target question text constitute a first sample question-answer pair, thereby obtaining a first sample set including multiple first sample question-answer pairs, and the sample set includes the first sample set. In the present application, a sample set for training a natural language processing model to be trained can be obtained through a small number of question templates, and the sample set includes a large number of high-quality and annotated sample question-answer pairs about the target field. The sample set can effectively improve the training effect of training the natural language processing model to be trained, and the acquisition efficiency of the sample set is high.
[0078] In one embodiment, Figure 4 As shown, it is a schematic diagram of a sample set generation method proposed in an embodiment of the present application, which can be implemented by a computer program and can be run on a sample set generation device based on the von Neumann system. The computer program can be integrated into an application or run as an independent tool application.
[0079] Specifically, the sample set generation method includes:
[0080] S201. Obtain a plurality of initial question texts about a target domain according to at least one question template and text data about a target domain.
[0081] See the above S101, which will not be repeated here.
[0082] S202: Input a plurality of initial question texts into a converged first natural language processing model to obtain a dialogue result.
[0083] The first dialogue result includes a plurality of target question texts corresponding to the initial question texts. See S102 above, which will not be described in detail here.
[0084] S203: Input the multiple target question texts into the converged second natural language processing model to obtain a second dialogue result.
[0085] The second dialogue result includes at least one first answer text corresponding to each target question text. See S106 above, which will not be described in detail here.
[0086] S204: The target question text and at least one first answer text corresponding to the target question text form a first sample text pair.
[0087] The first sample set includes a plurality of first sample question-answer pairs, and the sample set includes the first sample set. See S104 above, which will not be described in detail here.
[0088] S205: Obtain a third dialogue result obtained when the natural language processing model to be trained is trained according to the first sample set.
[0089] The third dialogue result includes at least one second answer text generated by the natural language processing model to be trained for each target question text. In other words, the electronic device or other electronic device executing the sample set generation method uses the multiple target question texts in the first sample set as input data of the natural language processing model to be trained, and obtains the third dialogue result output by the natural language processing model to be trained, including at least one second answer text corresponding to each target question text, and the third dialogue result serves as the output data of the natural language processing model to be trained.
[0090] The natural language processing model to be trained can be understood as a basic model of a natural language processing model that needs to be trained to perform a dialogue task on the target domain. The type of the natural language processing model to be trained can be the same as or different from the type of the first natural language processing model and the second natural language processing model. For example, the natural language processing model to be trained is a GPT-like model.
[0091] like Figure 5 As shown, a flow chart of obtaining a second sample set provided by an embodiment of the present application. The first sample set includes multiple target question texts, and the multiple target question texts include at least target question text 3012, target question text 3013, and target question text 3014. The electronic device or other electronic device that executes the sample set generation method inputs the multiple target question texts into the natural language processing model to be trained 302, and the electronic device that executes the sample set generation method obtains a third dialogue result, which includes at least one second answer text corresponding to each target question text, specifically including: at least one second answer text 3031 corresponding to the target question text 3011, at least one second answer text 3032 corresponding to the target question text 3012, at least one second answer text 3033 corresponding to the target question text 3013, and at least one second answer text 3034 corresponding to the target question text 3014.
[0092] S206. Score the at least one second answer text corresponding to each target question text respectively, and form a second sample question-answer pair with the target question text and the at least one scored second answer text corresponding to the target question text.
[0093] The second sample set includes a plurality of second sample question-answer pairs, and the sample set also includes a second sample set. The at least one second answer text corresponding to each target question text is scored respectively, and the second answer text is scored according to preset rules such as whether the second answer text is related to the target field, whether it is related to the target question text, and / or the difference information between the at least one first answer text corresponding to the target question text, and the preset rules can be set by relevant personnel as needed.
[0094] For example, the target field is network security, and the target question text is "What is CVE-2021-2429?" The natural language processing model to be trained obtains a second answer text "is a string of garbled characters" and another second answer text "is a vulnerability" for the target question text. According to the comparison between the above two second answer texts and the first answer text corresponding to the target question text in the first sample set, the score of the latter second answer text is higher than that of the former second answer text.
[0095] like Figure 5As shown, at least one second answer text corresponding to each target question text is scored respectively. Specifically, at least one second answer text 3031 corresponding to the target question text 3011 is scored respectively, at least one second answer text 3032 corresponding to the target question text 3012 is scored respectively, at least one second answer text 3033 corresponding to the target question text 3013 is scored respectively, at least one second answer text 3034 corresponding to the target question text 3014 is scored respectively, etc. Further, the target question text and at least one scored second answer text corresponding to the target question text are composed of a second sample question-answer pair. Specifically, the target question text 3011 and at least one scored second answer text 3031 are composed of a second sample question-answer pair 3041, the target question text 3012 and at least one scored second answer text 3032 are composed of a second sample question-answer pair 3042, the target question text 3013 and at least one scored second answer text 3033 are composed of a second sample question-answer pair 3043, etc. The second sample set 304 includes a plurality of second sample question-answer pairs, and the sample set includes a first sample set and a second sample set.
[0096] The second sample set is used for reward training of the natural language processing model to be trained. Specifically, by scoring at least one second answer text generated by the natural language processing model to be trained for each target question text, the natural language processing model to be trained is further trained with at least one second answer text that has been scored for reward training, so that the natural language processing model to be trained pays more attention to the second answer text with a high score, thereby improving the accuracy of the natural language processing model to be trained in answering the target question text.
[0097] In the present application, a small amount of question templates and text data are expanded by two natural language processing models to obtain a sample set including a large number of sample question-answer pairs. Specifically, multiple initial question texts are obtained through at least one question template and text data about the target field, and the multiple initial question texts are used as input data of the first natural language processing model, and the first dialogue results including multiple target question texts corresponding to each initial question text are further obtained as output data. Further, the multiple target question texts are used as input data of the second natural language processing model, and the second dialogue results including at least one first answer text corresponding to each target question text are obtained as output data. The target question text and the at least one first answer text corresponding to the target question text constitute a first sample question-answer pair, thereby obtaining a first sample set including multiple first sample question-answer pairs, and the sample set includes the first sample set. In the present application, a sample set for training a natural language processing model to be trained can be obtained through a small number of question templates, and the sample set includes a large number of high-quality and annotated sample question-answer pairs about the target field. The sample set can effectively improve the training effect of training the natural language processing model to be trained, and the acquisition efficiency of the sample set is high.
[0098] In one embodiment, Figure 6 As shown, it is a schematic diagram of a sample set generation method proposed in an embodiment of the present application, which can be implemented by a computer program and can be run on a sample set generation device based on the von Neumann system. The computer program can be integrated into an application or run as an independent tool application.
[0099] Specifically, the sample set generation method includes:
[0100] S301. Obtain a plurality of initial question texts about a target domain according to at least one question template and text data about a target domain.
[0101] See 101 above, which will not be repeated here.
[0102] S302: Input a plurality of initial question texts into a converged first natural language processing model to obtain a dialogue result.
[0103] The first dialogue result includes a plurality of target question texts corresponding to the initial question texts. See S102 above, which will not be described in detail here.
[0104] S303: Input multiple target question texts into a converged second natural language processing model to obtain a second dialogue result.
[0105] The second dialogue result includes at least one first answer text corresponding to each target question text. See S103 above, which will not be described in detail here.
[0106] S304: The target question text and at least one first answer text corresponding to the target question text form a first sample text pair.
[0107] The first sample set includes a plurality of first sample question-answer pairs, and the sample set includes the first sample set. See S104 above, which will not be described in detail here.
[0108] S305: Obtain a third dialogue result obtained when the natural language processing model to be trained is trained according to the first sample set.
[0109] The third dialogue result includes at least one second answer text generated by the natural language processing model to be trained for each target question text. See S305 above, which will not be described in detail here.
[0110] S306. Score the at least one second answer text corresponding to each target question text, and form a second sample question-answer pair consisting of the target question text and the at least one scored second answer text corresponding to each target question text.
[0111] The second sample set includes a plurality of second sample question-answer pairs, and the sample set also includes a second sample set. See S306 above, which will not be described in detail here.
[0112] S307: Perform random sampling on multiple first sample question-answer pairs included in the first sample set to obtain a third sample set.
[0113] The sample set also includes a third sample set. The first sample set includes a plurality of first sample question-answer pairs, and some of the first sample question-answer pairs are obtained by random sampling, and the first sample question-answer pairs are used as the third sample set.
[0114] like Figure 7 As shown, Figure 7 It is a flow chart of obtaining a third sample set provided by an embodiment of the present application. The first sample set 403 includes multiple first sample question-answer pairs, specifically, the first sample set 403 includes: a first sample question-answer pair 4031 consisting of a target question text 4011 and at least one first answer text 4021 corresponding to the target question text 4011, a first sample question-answer pair 4032 consisting of a target question text 4012 and at least one first answer text 4022 corresponding to the target question text 4012, a first sample question-answer pair 4033 consisting of a target question text 4013 and at least one first answer text 4023 corresponding to the target question text 4013, and a first sample question-answer pair 4034 consisting of a target question text 4014 and at least one first answer text 4024 corresponding to the target question text 4014.
[0115] A plurality of first sample question-answer pairs included in the first sample set 403 are randomly sampled to obtain a third sample set 404. The third sample set 404 includes a first sample question-answer pair 4041 and a first sample question-answer pair 4044.
[0116] In this embodiment, a third sample set is obtained by randomly sampling the first sample set, and deep learning intensive training is performed on the natural language processing model to be trained through the third sample set. Preferably, in the application, deep intensive training is performed on the natural language processing model to be trained through proximal policy optimization (PPO for short). PPO is an improved algorithm for policy gradient, and its core lies in converting the On-Policy training in Policy Gradient to Off-Policy, that is, converting from online learning to offline learning. By performing deep learning intensive training on the natural language processing model to be trained through the third sample set, the convergence speed of the natural language processing model to be trained can be improved.
[0117] In one embodiment, a plurality of sample question-answer pairs included in the first sample set are randomly sampled to obtain a third sample set, including: randomly sampling a plurality of first sample question-answer pairs included in the first sample set to obtain a third sample set to be processed, the third sample set to be processed including some of the first sample question-answer pairs in the plurality of first sample question-answer pairs; inputting a target question text of each first sample question-answer pair in the third sample set to be processed into a converged third natural language processing model to obtain a fourth dialogue result, the fourth dialogue result including at least one third answer text corresponding to each target question text; forming a third sample question-answer pair from the target question text and the at least one third answer text corresponding to the target question text, the third sample set including a plurality of third sample question-answer pairs.
[0118] In other words, firstly, a third sample set to be processed including some first sample question-answer pairs is obtained by random sampling, and then the target question text of the first sample question-answer pairs is used as input data of the third natural language processing model to obtain a fourth dialogue result including at least one third answer text corresponding to each target question text as output data, and then the target question text and at least one third answer text corresponding to the target question text are further combined into a third sample question-answer pair.
[0119] At least one third answer text corresponding to the target question text is obtained by the third natural language processing model for the target question text, and the at least one third answer text is not completely the same as the at least one first answer text obtained by the first natural language processing model. Therefore, by generating a third sample question-answer pair based on at least the first answer text and then training the natural language processing model to be trained by the third sample question-answer pair, the problem of overfitting of the natural language processing model to be trained caused by repeatedly training the natural language processing model to be trained by only using multiple first sample question-answer pairs can be avoided, thereby improving the generalization of the target natural language processing model finally obtained for performing question-answering tasks in the target field.
[0120] In the present application, a small amount of question templates and text data are expanded by two natural language processing models to obtain a sample set including a large number of sample question-answer pairs. Specifically, multiple initial question texts are obtained through at least one question template and text data about the target field, and the multiple initial question texts are used as input data of the first natural language processing model, and the first dialogue results including multiple target question texts corresponding to each initial question text are further obtained as output data. Further, the multiple target question texts are used as input data of the second natural language processing model, and the second dialogue results including at least one first answer text corresponding to each target question text are obtained as output data. The target question text and the at least one first answer text corresponding to the target question text constitute a first sample question-answer pair, thereby obtaining a first sample set including multiple first sample question-answer pairs, and the sample set includes the first sample set. In the present application, a sample set for training a natural language processing model to be trained can be obtained through a small number of question templates, and the sample set includes a large number of high-quality and annotated sample question-answer pairs about the target field. The sample set can effectively improve the training effect of training the natural language processing model to be trained, and the acquisition efficiency of the sample set is high.
[0121] In one embodiment, Figure 8 As shown, it is a schematic diagram of a model training method proposed in an embodiment of the present application, which can be implemented by a computer program and can be run on a model training device based on the von Neumann system. The computer program can be integrated into an application or run as an independent tool application.
[0122] Specifically, the model training method includes:
[0123] S401: Obtain a sample set.
[0124] The sample set is Figure 2-Figure 7 Any sample set generation method shown is obtained and will not be described again this time.
[0125] S402: Train the natural language processing model to be trained according to the sample set until the natural language processing model to be trained converges, thereby obtaining a target natural language processing model for performing a dialogue task on the target domain.
[0126] The natural language processing model to be trained is trained according to the multiple first sample question-answer pairs and / or multiple second sample question-answer pairs and / or third sample question-answer pairs included in the sample set. Until the preset conditions are met, a target natural language processing model for performing a dialogue task on the target domain is obtained. The preset condition can be that the difference information between the answer training text obtained by the natural language processing model according to the target question text and the first answer text meets expectations. The preset condition can also be that the number of adjustments to the natural language processing model meets expectations. It can be understood that the specific content of the preset conditions is set by relevant personnel as needed, and the above is only an example.
[0127] like Fig. 9 As shown, Fig. 9 5021 is a flow chart of another model training method provided in an embodiment of the present application. The sample set 502 includes a first sample set 5021, a second sample set 5022 and a third sample set 5023. The first sample set 5021 is obtained by Figure 2-Figure 3 The sample set generation method shown in FIG. 5 is obtained by: Figure 4-Figure 5 The sample set generation method shown in FIG. 1 is obtained by Figure 6-Figure 7 The sample set generation method shown is obtained and will not be described again this time.
[0128] The natural language processing model 501 to be trained is fine-tuned by P-trunning through multiple target question texts in the first sample set 5021 and at least one first answer text corresponding to each target question text, and further rewarded by P-trunning through multiple target question texts in the second sample set 5022 and at least one second answer text corresponding to each target question text, and finally deep learning intensive training PPO is performed on the natural language model 501 to be trained through multiple target question texts in the third sample set 5023 and at least one first answer text or at least one third answer text corresponding to each target question text, until a target natural language processing model for performing a dialogue task on the target domain is obtained. For example, if the target domain is the network security domain, a dialogue result related to the network security domain can be obtained by training the target natural language processing model to convergence.
[0129] In the present application, a small amount of question templates and text data are expanded by two natural language processing models to obtain a sample set including a large number of sample question-answer pairs. Specifically, multiple initial question texts are obtained through at least one question template and text data about the target field, and the multiple initial question texts are used as input data of the first natural language processing model, and the first dialogue results including multiple target question texts corresponding to each initial question text are further obtained as output data. Further, the multiple target question texts are used as input data of the second natural language processing model, and the second dialogue results including at least one first answer text corresponding to each target question text are obtained as output data. The target question text and the at least one first answer text corresponding to the target question text constitute a first sample question-answer pair, thereby obtaining a first sample set including multiple first sample question-answer pairs, and the sample set includes the first sample set. In the present application, a sample set for training a natural language processing model to be trained can be obtained through a small number of question templates, and the sample set includes a large number of high-quality and annotated sample question-answer pairs about the target field. The sample set can effectively improve the training effect of training the natural language processing model to be trained, and the acquisition efficiency of the sample set is high.
[0130] The following is an embodiment of the device of the present application, which can be used to execute the embodiment of the method of the present application. For details not disclosed in the embodiment of the device of the present application, please refer to the embodiment of the method of the present application.
[0131] See also Fig.10 , which shows a schematic diagram of the structure of a sample set generation device provided by an exemplary embodiment of the present application. The sample set generation device can be implemented as all or part of the device through software, hardware or a combination of both. The sample set generation device includes an initial question module 1001, a first dialogue module 1002, a second dialogue module 1003 and a first sample module 1004.
[0132] An initial question module 1001 is used to obtain a plurality of initial question texts about the target field according to at least one question template and text data about the target field;
[0133] A first dialogue module 1002, configured to input the multiple initial question texts into a converged first natural language processing model to obtain a first dialogue result, wherein the first dialogue result includes multiple target question texts corresponding to each of the initial question texts;
[0134] A second dialogue module 1003 is used to input the multiple target question texts into a converged second natural language processing model to obtain a second dialogue result, wherein the second dialogue result includes at least one first answer text corresponding to each of the target question texts;
[0135] The first sample module 1004 is used to form a first sample question-answer pair by combining the target question text and at least one first answer text corresponding to the target question text. The first sample set includes multiple first sample question-answer pairs, and the sample set includes the first sample set.
[0136] In one embodiment, the sample set generating device further includes:
[0137] A third dialogue module is used to obtain a third dialogue result obtained when the natural language processing model to be trained is trained according to the first sample set, and the third dialogue result includes at least one second answer text generated by the natural language processing model to be trained for each target question text;
[0138] The second sample module is used to score the at least one second answer text corresponding to each of the target question texts, and to form a second sample question-answer pair with the target question text and the at least one scored second answer text corresponding to the target question text. The second sample set includes multiple second sample question-answer pairs, and the sample set also includes the second sample set.
[0139] In one embodiment, the sample set generating device further includes:
[0140] The third sample module is used to perform random sampling processing on the multiple first sample question-answer pairs included in the first sample set to obtain a third sample set, wherein the third sample set includes some of the first sample question-answer pairs among the multiple first sample question-answer pairs, and the sample set also includes the third sample set.
[0141] In one embodiment, the third sample module includes:
[0142] a sampling unit, configured to randomly sample a plurality of first sample question-answer pairs included in the first sample set to obtain a third sample set to be processed, wherein the third sample set to be processed includes some of the first sample question-answer pairs among the plurality of first sample question-answer pairs;
[0143] a dialogue unit, configured to input the target question text of each first sample question-answer pair in the third sample set to be processed into a converged third natural language processing model to obtain a fourth dialogue result, wherein the fourth dialogue result includes at least one third answer text corresponding to each target question text;
[0144] The sample unit is used to form a third sample question-answer pair by combining the target question text and at least one third answer text corresponding to the target question text, wherein the third sample set includes a plurality of the third sample question-answer pairs.
[0145] In one embodiment, the first sample module 1004 includes:
[0146] A labeling unit is used to label each target question text according to the detailed information corresponding to each target question text, and to form the first sample question-answer pair with the labeled target question text and at least one first answer text corresponding to the labeled target question text.
[0147] In one embodiment, the first sample module 1004 includes:
[0148] The information unit is used to input the preset prompt words and the target question text into the converged fourth natural language processing model to obtain a fifth dialogue result, wherein the fifth dialogue result includes detailed information corresponding to each of the target question texts.
[0149] It should be noted that the sample set generation device provided in the above embodiment only uses the division of the above functional modules as an example when executing the sample set generation method. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the sample set generation device provided in the above embodiment and the sample set generation method embodiment belong to the same concept, and the implementation process thereof is detailed in the method embodiment, which will not be repeated here.
[0150] See also Fig.11 , which shows a schematic diagram of the structure of a model training device provided by an exemplary embodiment of the present application. The model training device can be implemented as all or part of the device through software, hardware or a combination of both. The model training device includes a first acquisition module 1101 and a model training module 1102.
[0151] The first acquisition module is used to acquire a sample set. The sample set is obtained by Figure 2-Figure 8 Any of the sample set generation methods shown is obtained.
[0152] The model training module 1102 is used to train the natural language processing model to be trained according to the sample set until the natural language processing model to be trained is trained to convergence, thereby obtaining a target natural language processing model for performing a dialogue task on a target domain.
[0153] It should be noted that the model training device provided in the above embodiment only uses the division of the above functional modules as an example when executing the model training method. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. In addition, the model training device provided in the above embodiment belongs to the same concept as the model training method embodiment. The implementation process is detailed in the method embodiment and will not be repeated here.
[0154] In the present application, a small amount of question templates and text data are expanded by two natural language processing models to obtain a sample set including a large number of sample question-answer pairs. Specifically, multiple initial question texts are obtained through at least one question template and text data about the target field, and the multiple initial question texts are used as input data of the first natural language processing model, and the first dialogue results including multiple target question texts corresponding to each initial question text are further obtained as output data. Further, the multiple target question texts are used as input data of the second natural language processing model, and the second dialogue results including at least one first answer text corresponding to each target question text are obtained as output data. The target question text and the at least one first answer text corresponding to the target question text constitute a first sample question-answer pair, thereby obtaining a first sample set including multiple first sample question-answer pairs, and the sample set includes the first sample set. In the present application, a sample set for training a natural language processing model to be trained can be obtained through a small number of question templates, and the sample set includes a large number of high-quality and annotated sample question-answer pairs about the target field. The sample set can effectively improve the training effect of training the natural language processing model to be trained, and the acquisition efficiency of the sample set is high.
[0155] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0156] The present application also provides a computer storage medium, which can store multiple instructions, and the instructions are suitable for being loaded and executed by a processor as described above. Figure 1 - Fig. 9 The sample set generation method of the embodiment shown in the figure can be specifically executed by referring to Figure 1 - Fig. 9 The specific description of the illustrated embodiment will not be repeated here.
[0157] The present application also provides a computer program product, which stores at least one instruction, and the at least one instruction is loaded and executed by the processor as described above. Figure 1 - Fig. 9 The sample set generation method of the embodiment shown in the figure can be specifically executed by referring to Figure 1 - Fig. 9 The specific description of the illustrated embodiment will not be repeated here.
[0158] See also Fig.12 , is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Fig.12 As shown, the electronic device 1200 may include: at least one processor 1201 , at least one network interface 1204 , a user interface 1203 , a memory 1205 , and at least one communication bus 1202 .
[0159] The communication bus 1202 is used to realize the connection and communication between these components.
[0160] The user interface 1203 may include a display screen (Display) and a camera (Camera), and the optional user interface 1203 may also include a standard wired interface and a wireless interface.
[0161] The network interface 1204 may optionally include a standard wired interface or a wireless interface (such as a WI-FI interface).
[0162] Among them, the processor 1201 may include one or more processing cores. The processor 1201 uses various interfaces and lines to connect the various parts of the entire server 1200, and executes various functions and processes data of the server 1200 by running or executing instructions, programs, code sets or instruction sets stored in the memory 1205, and calling data stored in the memory 1205. Optionally, the processor 1201 can be implemented in at least one hardware form of digital signal processing (Digital Signal Processing, DSP), field programmable gate array (Field-Programmable Gate Array, FPGA), and programmable logic array (Programmable Logic Array, PLA). The processor 1201 can integrate one or more combinations of a central processing unit (Central Processing Unit, CPU), a graphics processing unit (Graphics Processing Unit, GPU) and a modem. Among them, the CPU mainly processes the operating system, user interface and application programs; the GPU is responsible for rendering and drawing the content to be displayed on the display screen; the modem is used to process wireless communications. It can be understood that the above-mentioned modem may not be integrated into the processor 1201, and it can be implemented separately through a chip.
[0163] Among them, the memory 1205 may include a random access memory (Random Access Memory, RAM) and may also include a read-only memory (Read-Only Memory). Optionally, the memory 1205 includes a non-transitory computer-readable storage medium. The memory 1205 can be used to store instructions, programs, codes, code sets or instruction sets. The memory 1205 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the above-mentioned various method embodiments, etc.; the data storage area may store data involved in the above-mentioned various method embodiments, etc. The memory 1205 may also be optionally at least one storage device located away from the aforementioned processor 1201. As Fig.12 As shown, the memory 1205 as a computer storage medium may include an operating system, a network communication module, a user interface module, and a sample set generation and / or model training application.
[0164] exist Fig.12 In the electronic device 1200 shown, the user interface 1203 is mainly used to provide an input interface for the user and obtain data input by the user; and the processor 1201 can be used to call the sample set generation application stored in the memory 1205 and specifically perform the following operations:
[0165] Obtaining a plurality of initial question texts about the target domain according to at least one question template and text data about the target domain;
[0166] Inputting the multiple initial question texts into a converged first natural language processing model to obtain a first dialogue result, wherein the first dialogue result includes multiple target question texts corresponding to each of the initial question texts;
[0167] Inputting the multiple target question texts into a converged second natural language processing model to obtain a second dialogue result, wherein the second dialogue result includes at least one first answer text corresponding to each of the target question texts;
[0168] The target question text and at least one first answer text corresponding to the target question text are combined into a first sample question-answer pair, a first sample set includes a plurality of the first sample question-answer pairs, and the sample set includes the first sample set.
[0169] In one embodiment, the processor 1205 executes the sample set for training the natural language processing model to be trained, and after inputting the multiple target question texts into the converged second natural language processing model and obtaining the second dialogue result, further executes:
[0170] Acquire a third dialogue result obtained when the natural language processing model to be trained is trained according to the first sample set, the third dialogue result comprising at least one second answer text generated by the natural language processing model to be trained for each of the target question texts;
[0171] The at least one second answer text corresponding to each of the target question texts is scored respectively, and the target question text and the at least one scored second answer text corresponding to the target question text are combined into a second sample question-answer pair, the second sample set includes multiple second sample question-answer pairs, and the sample set also includes the second sample set.
[0172] In one embodiment, after the processor 1205 executes the step of inputting the plurality of target question texts into the converged second natural language processing model and obtaining the second dialogue result, the processor 1205 further executes:
[0173] A third sample set is obtained by performing random sampling processing on the multiple first sample question-answer pairs included in the first sample set, wherein the third sample set includes some of the first sample question-answer pairs among the multiple first sample question-answer pairs, and the sample set also includes the third sample set.
[0174] In one embodiment, the processor 1205 performs the random sampling of the plurality of sample question-answer pairs included in the first sample set to obtain the third sample set, specifically performing:
[0175] Randomly sampling a plurality of first sample question-answer pairs included in the first sample set to obtain a third sample set to be processed, wherein the third sample set to be processed includes some of the first sample question-answer pairs in the plurality of first sample question-answer pairs;
[0176] Inputting the target question text of each first sample question-answer pair in the third sample set to be processed into a converged third natural language processing model to obtain a fourth dialogue result, wherein the fourth dialogue result includes at least one third answer text corresponding to each target question text;
[0177] The target question text and at least one third answer text corresponding to the target question text are combined into a third sample question-answer pair, and the third sample set includes a plurality of the third sample question-answer pairs.
[0178] In one embodiment, the processor 1205 performs the step of combining the target question text and at least one first answer text corresponding to the target question text into a first sample question-answer pair, specifically performing:
[0179] According to the detailed information corresponding to each of the target question texts, each of the target question texts is annotated, and the annotated target question texts and at least one first answer text corresponding to the annotated target question texts form the first sample question-answer pair.
[0180] In one embodiment, before the processor 1205 performs the tagging process on each target question text according to the detailed information corresponding to each target question text, it further performs:
[0181] The preset prompt words and the target question text are input into the converged fourth natural language processing model to obtain a fifth dialogue result, wherein the fifth dialogue result includes detailed information corresponding to each of the target question texts.
[0182] In one embodiment, the processor 1201 may be used to call a model training application stored in the memory 1205, and specifically perform the following operations:
[0183] Get a sample set, the sample set is obtained by Figure 2-Figure 8 Any of the sample set generation methods shown is obtained;
[0184] The natural language processing model to be trained is trained according to the sample set until the natural language processing model to be trained is trained to converge, thereby obtaining a target natural language processing model for performing a dialogue task on a target domain.
[0185] In the present application, a small amount of question templates and text data are expanded by two natural language processing models to obtain a sample set including a large number of sample question-answer pairs. Specifically, multiple initial question texts are obtained through at least one question template and text data about the target field, and the multiple initial question texts are used as input data of the first natural language processing model, and the first dialogue results including multiple target question texts corresponding to each initial question text are further obtained as output data. Further, the multiple target question texts are used as input data of the second natural language processing model, and the second dialogue results including at least one first answer text corresponding to each target question text are obtained as output data. The target question text and the at least one first answer text corresponding to the target question text constitute a first sample question-answer pair, thereby obtaining a first sample set including multiple first sample question-answer pairs, and the sample set includes the first sample set. In the present application, a sample set for training a natural language processing model to be trained can be obtained through a small number of question templates, and the sample set includes a large number of high-quality and annotated sample question-answer pairs about the target field. The sample set can effectively improve the training effect of training the natural language processing model to be trained, and the acquisition efficiency of the sample set is high.
[0186] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing related hardware through a computer program, and the program can be stored in a computer-readable storage medium, and when the program is executed, it can include the processes of the embodiments of the above-mentioned methods. The storage medium can be a disk, an optical disk, a read-only storage memory, or a random access memory, etc.
[0187] The above disclosure is only the preferred embodiment of the present application, which certainly cannot be used to limit the scope of rights of the present application. Therefore, equivalent changes made according to the claims of the present application are still within the scope covered by the present application.
Claims
1. A method for generating a sample set, characterized in that: The sample set generation method comprises: Obtaining a plurality of initial question texts about the target domain according to at least one question template and text data about the target domain; Inputting the multiple initial question texts into a converged first natural language processing model to obtain a first dialogue result, wherein the first dialogue result includes multiple target question texts corresponding to each of the initial question texts; Inputting the multiple target question texts into a converged second natural language processing model to obtain a second dialogue result, wherein the second dialogue result includes at least one first answer text corresponding to each of the target question texts; The target question text and at least one first answer text corresponding to the target question text are combined into a first sample question-answer pair, a first sample set includes a plurality of the first sample question-answer pairs, and the sample set includes the first sample set.
2. The method for generating a sample set according to claim 1, characterized in that: The sample set is used to train the natural language processing model to be trained, and after the multiple target question texts are input into the converged second natural language processing model to obtain the second dialogue result, the method further includes: Acquire a third dialogue result obtained when the natural language processing model to be trained is trained according to the first sample set, the third dialogue result comprising at least one second answer text generated by the natural language processing model to be trained for each of the target question texts; The at least one second answer text corresponding to each of the target question texts is scored respectively, and the target question text and the at least one scored second answer text corresponding to the target question text are combined into a second sample question-answer pair, the second sample set includes multiple second sample question-answer pairs, and the sample set also includes the second sample set.
3. The sample set generation method according to claim 1 or 2, characterized in that: After inputting the plurality of target question texts into the converged second natural language processing model to obtain the second dialogue result, the method further includes: A third sample set is obtained by performing random sampling processing on the multiple first sample question-answer pairs included in the first sample set, wherein the third sample set includes some of the first sample question-answer pairs among the multiple first sample question-answer pairs, and the sample set also includes the third sample set.
4. The method for generating a sample set according to claim 3, characterized in that: The randomly sampling the plurality of sample question-answer pairs included in the first sample set to obtain a third sample set includes: Randomly sampling a plurality of first sample question-answer pairs included in the first sample set to obtain a third sample set to be processed, wherein the third sample set to be processed includes some of the first sample question-answer pairs in the plurality of first sample question-answer pairs; Inputting the target question text of each first sample question-answer pair in the third sample set to be processed into a converged third natural language processing model to obtain a fourth dialogue result, wherein the fourth dialogue result includes at least one third answer text corresponding to each target question text; The target question text and at least one third answer text corresponding to the target question text are combined into a third sample question-answer pair, and the third sample set includes a plurality of the third sample question-answer pairs.
5. The method for generating a sample set according to claim 1, characterized in that: The step of forming a first sample question-answer pair from the target question text and at least one first answer text corresponding to the target question text includes: According to the detailed information corresponding to each of the target question texts, each of the target question texts is annotated, and the annotated target question texts and at least one first answer text corresponding to the annotated target question texts form the first sample question-answer pair.
6. A model training method, characterized in that: The model training method comprises: Acquire a sample set, where the sample set is obtained by the sample set generation method according to any one of claims 1 to 6; The natural language processing model to be trained is trained according to the sample set until the natural language processing model to be trained is trained to converge, thereby obtaining a target natural language processing model for performing a dialogue task on a target domain.
7. A sample set generating device, characterized in that: The sample set generating device comprises: An initial question module, used to obtain a plurality of initial question texts about the target field according to at least one question template and text data about the target field; A first dialogue module, configured to input the multiple initial question texts into a converged first natural language processing model to obtain a first dialogue result, wherein the first dialogue result includes multiple target question texts corresponding to each of the initial question texts; A second dialogue module, configured to input the plurality of target question texts into a converged second natural language processing model to obtain a second dialogue result, wherein the second dialogue result includes at least one first answer text corresponding to each of the target question texts; The first sample module is used to form a first sample question-answer pair by combining the target question text and at least one first answer text corresponding to the target question text. The first sample set includes multiple first sample question-answer pairs, and the sample set includes the first sample set.
8. A model training device, characterized in that: The model training device comprises: A first acquisition module, configured to acquire a sample set, wherein the sample set is obtained by the sample set generation method according to any one of claims 1 to 5; The model training module is used to train the natural language processing model to be trained according to the sample set until the natural language processing model to be trained is trained to convergence, thereby obtaining a target natural language processing model for performing a dialogue task on a target domain.
9. A computer storage medium, characterized in that The computer storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor and executing the method steps according to any one of claims 1 to 6.
10. An electronic device, characterized in that: include: A processor and a memory; wherein the memory stores a computer program, and the computer program is suitable for being loaded by the processor and executing the method steps as claimed in any one of claims 1 to 6.