Instruction data set construction method and device, electronic equipment and storage medium

By obtaining the sample corpus text and its background hierarchy names, generating nested layer key-value pairs and filling in the prompt template, the problem that the solid template cannot adapt to the diversity data is solved, and the quality and adaptability of the instruction data set is improved.

CN118916692AActive Publication Date: 2024-11-08PENG CHENG LAB
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202410697065.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-30
Publication Date
2024-11-08
Estimated Expiration
2044-05-30

AI Technical Summary

Technical Problem

In the prior art, when building instruction data sets, fixed templates cannot adapt to the diverse original data sets, resulting in the generated instructions being too specific or too general, which reduces the quality of the instruction data set.

Method used

By obtaining the hierarchy name of the sample corpus text and its nested background hierarchy, a nested layer key-value pair is generated, and a preset prompt template is filled, and the target prompt text is input to the large language model is generated, and the sample corpus text is generated. Related target Q&A pairs, build instruction datasets based on these Q&A pairs.

Benefits of technology

Improve the quality of the instruction data set, and the generated target question and answer pairs capture the characteristics of sample corpus text more accurately. They are suitable for corpus with structural information. The generated prompt text is more informative and adaptable, enhancing the universality of the data set. and understandability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118916692A_ABST
    Figure CN118916692A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides an instruction data set construction method and device, electronic equipment and a storage medium, and belongs to the technical field of natural language processing. The method comprises the steps of obtaining a sample corpus text and hierarchy names of a plurality of nested background hierarchies where the sample corpus text is located; obtaining a preset prompt template, taking the plurality of hierarchy names as keywords, and sequentially filling the keywords into a plurality of vacancies in the prompt template according to the sequence of the corresponding background hierarchies to generate a first prompt text; generating a target prompt text according to the first prompt text and the sample corpus text, and inputting the target prompt text into a preset large language model to obtain a target question and answer pair related to the sample corpus text; and constructing an instruction data set based on the target question-answer pair. According to the instruction data set construction method and device, the electronic equipment and the storage medium provided by the embodiment of the invention, the quality of the constructed instruction data set can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of natural language processing technology, and in particular to a method, device, electronic device and storage medium for constructing an instruction data set. Background Art

[0002] Instruction datasets are an important data resource used in the training and fine-tuning of large language models, thereby improving the general conversational capabilities of large language models. Instruction datasets include instructions or tasks with clear goals and structures, which can be used in question-and-answer application scenarios.

[0003] In the related art, constructing an instruction dataset relies on formatting an existing raw dataset, which easily transfers problems of the raw data to the generated instruction dataset. In addition, fixed templates cannot adapt to the diversity of raw datasets, resulting in the generated instructions being too specific or too general, reducing the quality of the instruction dataset. Summary of the invention

[0004] The main purpose of the embodiments of the present application is to propose a method, device, electronic device and storage medium for constructing an instruction data set, which can improve the quality of the constructed instruction data set.

[0005] To achieve the above-mentioned purpose, the first aspect of an embodiment of the present application proposes a method for constructing an instruction dataset, the method comprising: obtaining a sample corpus text and the level names of multiple nested background levels in which the sample corpus text is located; obtaining a preset prompt template, taking multiple level names as keywords, and filling them into multiple spaces in the prompt template in sequence according to the order of the corresponding background levels to generate a first prompt text; generating a target prompt text based on the first prompt text and the sample corpus text, and inputting the target prompt text into a preset large language model to obtain a target question-answer pair related to the sample corpus text; and constructing an instruction dataset based on the target question-answer pair.

[0006] In some embodiments, the method of obtaining a preset prompt template, taking a plurality of the level names as keywords, and sequentially filling them into a plurality of spaces in the prompt template in the order of the corresponding background levels to generate a first prompt text comprises: constructing a nested layer key-value pair according to the level names of the sample corpus text and the plurality of nested background levels in which the sample corpus text is located, wherein the layer key-value pair comprises a plurality of title keys constructed based on the level names; obtaining a preset prompt template, sequentially filling the order of the title keys of the nested layer key-value pairs into a plurality of spaces in the prompt template to generate a first prompt text.

[0007] In some embodiments, the constructing of nested layer key-value pairs based on the sample corpus text and the layer names of the multiple nested background layers in which the sample corpus text is located includes: constructing a first-level layer key-value pair based on the layer name of the first level and the text content of the sample corpus text, wherein the title key of the first-level layer key-value pair includes the first-level layer name, and the value of the first-level layer key-value pair includes the text content of the sample corpus text; constructing the layer key-value pairs above the first level based on the layer names above the first level and the layer key-value pairs of the corresponding next level, wherein the title key of the layer key-value pairs above the first level includes the layer name of the corresponding level, and the value includes the layer key-value pair of the corresponding next level.

[0008] In some embodiments, the obtaining of sample corpus text, and the level names of multiple nested background levels in which the sample corpus text is located, includes: obtaining an initial corpus text, and extracting multiple nested semantic keywords corresponding to the text content in the initial corpus text based on a pre-trained semantic analysis model; obtaining a sample corpus text according to the text content of the initial corpus text, and obtaining the level names of the multiple nested background levels in which the sample corpus text is located according to the multiple nested semantic keywords.

[0009] In some embodiments, the method of obtaining a preset prompt template, taking a plurality of the level names as keywords, and sequentially filling them into a plurality of spaces in the prompt template in the order of the corresponding background levels to generate a first prompt text includes: obtaining a preset prompt template, taking a plurality of the level names as keywords, and sequentially filling them into a plurality of spaces in the prompt template in the order of the corresponding background levels; determining the number of prompt outputs according to the number of sentences and sentence lengths of the sample corpus text to generate a first prompt text.

[0010] In some embodiments, generating a target prompt text based on the first prompt text and the sample corpus text, and inputting the target prompt text into a preset large language model to obtain a target question-answer pair related to the sample corpus text includes: generating a target prompt text based on the first prompt text and the sample corpus text, and inputting the target prompt text into a preset large language model; extracting target question-answer pairs corresponding to the prompt output quantity from the sample corpus text based on the target prompt text based on the preset large language model.

[0011] In some embodiments, generating a target prompt text based on the first prompt text and the sample corpus text, and inputting the target prompt text into a preset large language model to obtain a target question-answer pair related to the sample corpus text, includes: obtaining a text summary corresponding to the sample corpus text, and generating a target prompt text based on the first prompt text and the sample corpus text; inputting the target prompt text and the text summary into a preset large language model to obtain a target question-answer pair related to the sample corpus text.

[0012] In some embodiments, constructing an instruction data set based on the target question and answer pairs includes: filtering the target question and answer pairs according to preset filtering rules, wherein the filtering rules include question and answer pair keyword filtering and question and answer pair length filtering; calculating the similarity between the target question and answer pairs after filtering, merging the target question and answer pairs whose similarity is greater than a preset similarity threshold, and obtaining the instruction data set.

[0013] In some embodiments, the calculating the similarity between the target question-answer pairs after filtering processing, merging the target question-answer pairs whose similarity is greater than a preset similarity threshold, and obtaining the instruction data set includes: encoding the question text and answer text of the filtered target question-answer pairs into question-answer semantic vectors based on a pre-trained semantic representation model; calculating the similarity between the question-answer semantic vectors, merging the target question-answer pairs whose similarity is greater than a preset similarity threshold, and obtaining the instruction data set.

[0014] To achieve the above-mentioned purpose, the second aspect of an embodiment of the present application proposes an instruction dataset construction device, including: a sample acquisition module, used to obtain a sample corpus text, and the level names of multiple nested background levels in which the sample corpus text is located; a prompt template module, used to obtain a preset prompt template, use multiple level names as keywords, and fill them into multiple spaces in the prompt template in the order of the corresponding background levels to generate a first prompt text; a question-answer pair module, used to generate a target prompt text based on the first prompt text and the sample corpus text, and input the target prompt text into a preset large language model to obtain a target question-answer pair related to the sample corpus text; a dataset module, used to construct an instruction dataset based on the target question-answer pair.

[0015] To achieve the above-mentioned purpose, the third aspect of the embodiments of the present application proposes an electronic device, which includes a memory and a processor, the memory stores a computer program, and the processor implements the method described in the above-mentioned first aspect embodiment when executing the computer program.

[0016] To achieve the above-mentioned purpose, the fourth aspect of an embodiment of the present application proposes a storage medium, which is a computer-readable storage medium, and the storage medium stores a computer program. When the computer program is executed by a processor, the method described in the embodiment of the first aspect above is implemented.

[0017] The instruction dataset construction method, device, electronic device and storage medium proposed in the present application have the following beneficial effects: obtaining a sample corpus text and the level names of multiple nested background levels in which the sample corpus text is located, wherein the nested level names can fully reflect the contextual theme of the sample corpus text from the generalization to the specific multiple degrees; obtaining a preset prompt template, using multiple level names as keywords, and filling them into multiple spaces in the prompt template in sequence according to the order of the corresponding background levels to generate a first prompt text, which is suitable for corpus with structural information, and generates a more informative and adaptable first prompt text, which can better help understand the meaning of the sample corpus text and the need to generate instructions, and improve the comprehensibility of the prompt text; generating a target prompt text according to the first prompt text and the sample corpus text, and inputting the target prompt text into a preset large language model to obtain a target question-answer pair related to the sample corpus text, and the obtained target question-answer pair can more accurately capture the characteristics of the sample corpus text, improve the quality of the generated target question-answer pair, and construct an instruction dataset based on the target question-answer pair, which can improve the quality of the constructed instruction dataset. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] Figure 1 is a flowchart of a method for constructing an instruction data set provided in an embodiment of the present application;

[0019] Figure 2 yes Figure 1 Flowchart of step 102;

[0020] Figure 3 yes Figure 2 Flow chart of step 201 in;

[0021] Figure 4 yes Figure 1 Flowchart of step 101 in FIG.

[0022] Figure 5 yes Figure 1 Another flow chart of step 102;

[0023] Figure 6 yes Figure 1 Flow chart of step 103;

[0024] Figure 7 yes Figure 1 Another flow chart of step 103;

[0025] Figure 8 It is a schematic diagram of a text summary and a target prompt text provided in an embodiment of the present application;

[0026] Fig. 9 yes Figure 1 Flow chart of step 104;

[0027] Fig.10 yes Fig. 9 Flowchart of step 802;

[0028] Fig.11 is a schematic diagram of a method for constructing an instruction data set provided in an embodiment of the present application;

[0029] Fig.12 is a flow chart of a data loader provided in an embodiment of the present application;

[0030] Fig.13 It is a schematic diagram of the functional modules of the instruction data set construction device provided in an embodiment of the present application;

[0031] Fig.14 It is a schematic diagram of the hardware structure of the electronic device provided in the embodiment of the present application. DETAILED DESCRIPTION

[0032] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0033] It should be noted that although the functional modules are divided in the device schematic and the logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than the module division in the device or the order in the flowchart.

[0034] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.

[0035] Instruction datasets are an important data resource used in the training and fine-tuning of large language models, thereby improving the general conversational capabilities of large language models. Instruction datasets include instructions or tasks with clear goals and structures, which can be used in question-and-answer application scenarios.

[0036] In the training and fine-tuning process of modern large language models, instruction datasets provide specific tasks and domain knowledge for large model fine-tuning, thereby improving the general conversation ability of large models. There are usually two main methods to build high-quality instruction datasets: manual annotation and methods based on formatted raw datasets. Although these methods have been successful in some aspects, they also have some challenges and limitations. Manual annotation is a traditional method to generate high-quality instruction data, but it requires a lot of manpower and time costs, which limits the scale and diversity of data. The method based on formatted raw datasets uses fixed templates and placeholders, which may cause the generated instructions to be too specific or too general in some cases, and it is difficult to adapt to the diversity of various input samples. At the same time, the automatic application and replacement of templates may cause the generated instructions to have grammatical errors, incoherence or ambiguity. The process of generating instructions depends on the text samples in the original dataset. If there are problems with the original data, such as noise, errors or inconsistent annotations, these problems may be passed on to the generated instruction dataset, affecting the quality and reliability of the dataset.

[0037] In the related art, constructing an instruction dataset relies on formatting an existing raw dataset, which easily transfers problems of the raw data to the generated instruction dataset. In addition, fixed templates cannot adapt to the diversity of raw datasets, resulting in the generated instructions being too specific or too general, reducing the quality of the instruction dataset.

[0038] Based on this, the embodiments of the present application provide a method, device, electronic device and storage medium for constructing an instruction data set, which can improve the quality of the constructed instruction data set.

[0039] The instruction data set construction method, device, electronic device and storage medium provided in the embodiments of the present application are specifically described by the following embodiments. First, the instruction data set construction method in the embodiments of the present application is described. The instruction data set construction method in the embodiments of the present application can be described by the following embodiments.

[0040] Figure 1 is an optional flowchart of the instruction data set construction method provided in the embodiment of the present application. Figure 1 The method may include but is not limited to steps 101 to 104.

[0041] Step 101: Obtain sample corpus text and the level names of multiple nested background levels where the sample corpus text is located.

[0042] It can be understood that the sample corpus text refers to the original text data, such as paragraphs and sentences, including various types of text, such as news articles, conversation records, and explanatory texts. The background level refers to the various contextual information or knowledge backgrounds in which the sample corpus text is located. These background levels are nested, that is, one level is contained in another broader level. For example, an article belongs to the field of "technology", and "technology" belongs to the larger field of "knowledge", which forms a nested background level.

[0043] Exemplarily, the sample corpus text and the level names of the multiple nested background levels in which the sample corpus text is located are shown in Table 1. The sample corpus text is in four nested background levels, and the level names in increasing order are "specific aspect name", "aspect name", "topic name", and "field name".

[0044]

[0045] Table 1 Example of the hierarchical names of the sample corpus texts and the multiple nested background hierarchies in which they are located

[0046] For example, the sample corpus text and the hierarchical names of the multiple nested background hierarchies in which the sample corpus text is located can be obtained through the original corpus of the knowledge forest. The original corpus of the knowledge forest has a structured corpus organization method, which can closely associate the text content with the contextual information such as the field, theme, knowledge point, etc. to which it belongs, thereby forming a "knowledge forest" structure. This corpus format is suitable for training and evaluating natural language processing models, and can provide rich background knowledge for natural language processing models, thereby helping the model to better understand the corpus text and generate relevant content.

[0047] It is understandable that the original corpus of the Knowledge Forest type, as a high-quality original corpus, can provide quality assurance for subsequent generation or training applications. The reason why the original corpus of the Knowledge Forest type is considered to be high-quality corpus is that this type of corpus contains a wide range of topics and domain knowledge from encyclopedias to literary works, covering a very wide range; and these corpus sets contain a large number of real and natural language expressions, involving various styles and tones, which can help the model learn more natural and vivid language use. The original corpus of the Knowledge Forest type has many advantages such as wide topic coverage, rich language expressions, large-scale data volume, reliable quality control and diversity. It is widely regarded as a high-quality corpus for training natural language processing models. These characteristics enable it to play an important role in many downstream tasks.

[0048] Exemplarily, the sample corpus text and the hierarchical names of the multiple nested background hierarchies in which the sample corpus text is located can be obtained, and the key information of the general knowledge corpus can be extracted as the nested background hierarchies by performing semantic analysis and other processing on the unstructured general knowledge corpus. For example, for the general knowledge corpus in a specific field, the relevant field classification system can be searched, and the classification hierarchy corresponding to the general knowledge corpus can be used as the nested background hierarchies.

[0049] Step 102, obtaining a preset prompt template, taking multiple level names as keywords, and sequentially filling them into multiple spaces in the prompt template according to the order of corresponding background levels, to generate a first prompt text.

[0050] It can be understood that the preset prompt template refers to a template that provides some standardized prompts or guidance to the large language model when interacting with the large language model, so as to guide the large language model to complete the task. It may include information such as task description, input content, and expected output format. For example, different prompt templates may be used, such as directive statements ("Write an article about [content]"), question-and-answer formats ("Based on the following background information, answer the question: [background information]. The question is: [question]?"), etc.

[0051] Exemplarily, multiple level names are used as keywords and are sequentially filled into multiple spaces in the prompt template in the order of the corresponding background levels to generate the first prompt text, that is, the spaces or placeholders in the prompt template are filled with level names according to the order of the background levels. For example, the first prompt text generated for the sample corpus text shown in Table 1 is: "Please combine keywords such as "Senior 2 Cells", "Cell Structure", "Organelles", and "Cell Composition" to extract question and answer pairs from the text."

[0052] Step 103, generating a target prompt text according to the first prompt text and the sample corpus text, and inputting the target prompt text into a preset large language model to obtain a target question-answer pair related to the sample corpus text.

[0053] It is understandable that a large language model refers to a pre-trained language model based on deep learning, which has a large number of parameters and training data. It can learn rich language knowledge and general semantic understanding capabilities from a large amount of text data, and performs well in multiple natural language tasks, including text generation, question answering, sentiment analysis, etc. Large language models can be applied to question-answering systems to build high-quality question-answer pairs or answer user questions.

[0054] It can be understood that the target question-answer pair is a question and its answer related to the sample corpus text, and the target prompt text is generated according to the first prompt text and the sample corpus text. The target prompt text includes the sample corpus text to be processed and the first prompt text matching the sample corpus text. The target prompt text is input into the preset large language model to obtain the target question-answer pair related to the sample corpus text.

[0055] Exemplarily, the first prompt text is: "Please extract question-answer pairs from the text based on keywords such as "Senior 2 Cells", "Cell Structure", "Organelles", and "Cell Composition"; the sample corpus text is: "Cells are the basic structural and functional units of organisms. The interior of a cell is composed of many different organelles, each of which is responsible for a specific life activity. For example, the nucleus is the "command center" of the cell, controlling the cell's genetic information and cell division; mitochondria are the "power plants" of the cell, responsible for the cell's energy metabolism; and the endoplasmic reticulum is the cell's "transport system", responsible for the synthesis and transport of proteins. The coordinated work of these organelles maintains the cell's life activities. Only by mastering the basic structure of the cell and the functions of its components can we better understand the mysteries of life phenomena." The target prompt text is input into the preset large language model to obtain the target question-answer pair related to the sample corpus text. The question of the target question-answer pair is: "What organelles are inside the cell?"; the answer to the target question-answer pair is: "The organelles inside the cell include the nucleus, mitochondria, and endoplasmic reticulum. The nucleus is the command center of the cell, the mitochondria are responsible for the cell's energy metabolism, and the endoplasmic reticulum is responsible for the synthesis and transport of proteins."

[0056] Step 104: construct an instruction dataset based on the target question-answer pair.

[0057] It is understandable that the instruction dataset is a special dataset used to train AI models that can execute various instructions and tasks. It contains a large number of question-answer pairs and corresponding execution instructions. Building an instruction dataset can be used to train a general AI assistant or dialogue system that can understand and execute a variety of instructions, which can improve the model's language understanding ability, task execution ability, and flexibility.

[0058] For example, a large number of high-quality target question-answer pairs are generated through a large language model. The target question-answer pairs cover various topics and scenarios. Corresponding execution instructions are written for each target question-answer pair. The execution instructions describe how to complete the task. Each target question-answer pair and its corresponding execution instructions are organized into a unified dataset format to construct an instruction dataset.

[0059] For example, the target question-answer pairs generated by the large language model can be deduplicated by inputting each sample corpus text into the large language model, and the corresponding target question-answer pairs can be compared to identify repeated or highly similar content. Text similarity calculation methods such as cosine similarity and edit distance can be used to deduplicate the target question-answer pairs to avoid overly similar target question-answer pairs generated by the same sample corpus text. The target question-answer pairs after all sample corpus texts have been deduplicated individually can also be deduplicated as a whole, effectively optimizing the target question-answer pairs generated by the large language model and improving their quality and information value.

[0060] Through the above steps 101 to 104, a sample corpus text and the level names of the multiple nested background levels in which the sample corpus text is located are obtained. The nested level names can fully reflect the contextual theme of the sample corpus text in terms of multiple degrees of generalization to specificity; a preset prompt template is obtained, and multiple level names are used as keywords, and are sequentially filled into multiple spaces in the prompt template in the order of the corresponding background levels to generate a first prompt text, which is suitable for corpus with structural information, and generates a more informative and adaptable first prompt text, which can better help understand the meaning of the sample corpus text and the need to generate instructions, and improve the comprehensibility of the prompt text; a target prompt text is generated according to the first prompt text and the sample corpus text, and the target prompt text is input into a preset large language model to obtain a target question-answer pair related to the sample corpus text, and the obtained target question-answer pair can more accurately capture the characteristics of the sample corpus text, improve the quality of the generated target question-answer pair, and construct an instruction data set based on the target question-answer pair, which can improve the quality of the constructed instruction data set.

[0061] See also Figure 2 In some embodiments, step 102 may include steps 201 to 202:

[0062] Step 201 : constructing nested layer key-value pairs according to a sample corpus text and the layer names of multiple nested background layers where the sample corpus text is located.

[0063] The layer key-value pair includes multiple title keys constructed based on the layer name.

[0064] It can be understood that a layer key-value pair refers to a structure consisting of multiple nested key-value pairs. A key-value pair is a structure consisting of a key and a value. For example, a layer key-value pair with k nested layers can be represented as item = {key1: {key2: {key3: ... {key k :value}}}}, where the layer key-value pair includes multiple title keys key1, key2, key3, ...key based on the layer name. k , value is the value.

[0065] Step 202: Obtain a preset prompt template, and fill the sequence of the title keys of the nested layer key-value pairs into multiple spaces in the prompt template in order to generate a first prompt text.

[0066] It can be understood that the title key order of the nested layer key-value pairs constructed by the sample corpus text shown in Table 1 is "Senior 2 Biology", "Cell Structure", "Organelles", and "Cell Composition". The order of the title keys of the nested layer key-value pairs is filled in turn into multiple spaces in the prompt template or replaces the placeholders in the prompt template to generate the first prompt text, for example, "Please combine keywords such as "Senior 2 Cells", "Cell Structure", "Organelles", and "Cell Composition" to extract question and answer pairs from the text."

[0067] Through the above steps 201 to 202, nested layer key-value pairs are constructed according to the sample corpus text and the level names of the multiple nested background levels in which the sample corpus text is located, a preset prompt template is obtained, and the order of the title keys of the nested layer key-value pairs is filled into multiple spaces in the prompt template in sequence to generate a first prompt text. The sample corpus text is organized into a nested dictionary format in the form of key-value pairs, which can more clearly express its structured information. The title keys are filled into the prompt template in sequence to generate the first prompt text, which helps the large language model better understand the sample corpus text and improves the quality of the generated target question-answer pairs.

[0068] participate Figure 3 In some embodiments, step 201 may include steps 301 to 302:

[0069] Step 301: construct a first-level layer key-value pair according to the first-level layer name and the text content of the sample corpus text.

[0070] The title key of the first-level layer key-value pair includes the first-level layer name, and the value of the first-level layer key-value pair includes the text content of the sample corpus text. k The value of the first-level key-value pair is the text content value of the sample corpus text. The first-level key-value pair item1 = {key k :value}.

[0071] Step 302: construct layer key-value pairs above the first level according to the layer names above the first level and the layer key-value pairs of the corresponding next level.

[0072] The title key of the layer key-value pairs above the first level includes the layer name of the corresponding level, and the value includes the layer key-value pairs of the corresponding next level. For example, the title key of the layer key-value pairs of the second level is key k-1, the value is the first-level layer key-value pair, that is, item2 = {key k-1 :{key k :value}}.

[0073] Exemplarily, the sample corpus text shown in Table 1 and the hierarchical names of the multiple nested background hierarchies in which it is located construct nested layer key-value pairs as {Senior 2 Biology: {Cell structure: {Organelle: {Cell composition: Cells are the basic structural and functional units of organisms. The interior of a cell is composed of many different organelles, each of which is responsible for a specific life activity. For example, the nucleus is the "command center" of the cell, controlling the cell's genetic information and cell division; the mitochondria are the cell's "power plant", responsible for the cell's energy metabolism; the endoplasmic reticulum is the cell's "transport system", responsible for the synthesis and transportation of proteins. The coordinated work of these organelles maintains the life activities of the cell. Only by mastering the basic structure of the cell and the functions of its components can we better understand the mysteries of life phenomena}}}}

[0074] Through step 301 to step 302, the first-level layer key-value pairs are constructed according to the layer name of the first level and the text content of the sample corpus text, and the layer key-value pairs above the first level are constructed according to the layer names above the first level and the corresponding layer key-value pairs of the next level, forming nested layer key-value pairs layer by layer, so as to better reflect the hierarchical structure and internal connection of the knowledge in the sample corpus text.

[0075] See also Figure 4 In some embodiments, step 101 may include steps 401 to 402:

[0076] Step 401, obtaining an initial corpus text, and extracting a plurality of nested semantic keywords corresponding to the text content in the initial corpus text based on a pre-trained semantic analysis model.

[0077] Step 402: acquiring a sample corpus text according to the text content of the initial corpus text, and acquiring the level names of the multiple nested background levels where the sample corpus text is located according to the multiple nested semantic keywords.

[0078] It is understandable that a semantic analysis model refers to a machine learning model that can extract text semantic information, such as BERT, GPT and other pre-trained models. The semantic analysis model can capture the semantic meaning and contextual relationship of words, phrases, etc. in the initial corpus text, identify keywords, and discover hidden connections between words, extract the theme and intention of the initial corpus text, and obtain nested semantic keywords.

[0079] Exemplarily, the initial corpus text refers to relevant text data in text format, unstructured data in the form of text. For a news article about artificial intelligence, the semantic analysis model can extract multi-layer nested semantic keywords such as "artificial intelligence", "machine learning", and "deep learning", reflecting the theme and key content of the article, and providing valuable structured information for subsequent text processing and analysis. According to multiple nested semantic keywords, the hierarchical names of the multiple nested background levels where the sample corpus text is located are obtained, that is, the nested semantic keywords are used as the hierarchical names.

[0080] Through steps 401 to 402, keywords of the initial corpus text are extracted based on the pre-trained semantic analysis model, and the hierarchical names of the multiple nested background hierarchies in which the sample corpus text is located are obtained according to the multiple nested semantic keywords. The initial corpus questions without structured information are constructed into structured information with the hierarchical names of the multiple nested background hierarchies through the extracted semantic keywords, thereby improving the applicability of the instruction data set construction method.

[0081] See also Figure 5 In some embodiments, step 102 may include steps 501 to 502:

[0082] Step 501 , obtaining a preset prompt template, taking multiple level names as keywords, and sequentially filling multiple spaces in the prompt template in the order of corresponding background levels.

[0083] Step 502: determine the number of prompt outputs according to the number of sentences and the length of sentences in the sample corpus text, and generate a first prompt text.

[0084] It is understandable that the sample corpus text may include multiple sentences. The design of the prompt template and the number of prompt outputs can be determined according to specific application scenarios and requirements, which can significantly improve the quality and relevance of text generation. The number of target question-answer pairs to be generated can be determined based on the complexity of the sample corpus text, that is, the number of sentences and the length of the sentences.

[0085] Exemplarily, a text processing tool can be used to analyze the sample corpus text. If the sample corpus text is relatively simple, with fewer sentences or shorter sentences, a smaller number of prompt outputs can be determined. Conversely, if the sample corpus text is relatively complex, with more sentences or longer sentences, a larger number of prompt outputs can be determined. Determining the number of prompt outputs based on the number and length of sentences in the sample corpus text can ensure that the number of target question-answer pairs matches the complexity of the sample corpus text, thereby providing better support for the subsequent generation of target prompt texts and question-answer pairs.

[0086] Through steps 501 to 502, a preset prompt template is obtained, multiple level names are used as keywords, and are filled into multiple spaces in the prompt template in sequence according to the order of the corresponding background levels. The number of prompt outputs is determined according to the number of sentences and sentence lengths in the sample corpus text, and the first prompt text is generated. This can ensure that the number of target question-answer pairs generated matches the complexity of the sample corpus text, providing more information for the generation of target question-answer pairs.

[0087] See also Figure 6 In some embodiments, step 103 may include steps 601 to 602:

[0088] Step 601: Generate a target prompt text according to a first prompt text and a sample corpus text, and input the target prompt text into a preset large language model.

[0089] Step 602: extract target question-answer pairs corresponding to the prompt output quantity from the sample corpus text based on the target prompt text based on the preset large language model.

[0090] It is understandable that the target prompt text is generated based on the first prompt text and the original sample corpus text, and this target prompt text can more specifically reflect the content and background of the sample corpus. Then, the generated target prompt text is input into a pre-set large language model for processing. This large language model is a preset model that has been extensively trained and can output corresponding question-answer pairs based on the input prompt text. The large language model will extract a corresponding number of target question-answer pairs from the sample corpus text based on the content of the target prompt text. The number of this target question-answer pair is consistent with the number of prompt outputs determined based on the number of sentences in the sample corpus text.

[0091] For example, there is a sample corpus text about the "Winter Olympics", which contains rich background information, such as the time and location of the event, participating countries, and major events. First, obtain the sample corpus text and extract the various background level information contained therein. Next, use the preset prompt template to fill in these background information in an orderly manner to generate the first prompt text. Next, according to the complexity of the sample corpus text, the number of prompt outputs can be determined to be 5. Then, these first prompt texts can be combined with the original sample corpus text to generate more targeted target prompt texts, and these target prompt texts can be input into the pre-trained large language model, and 5 corresponding high-quality target question-answer pairs can be extracted from the sample corpus text as the data of the instruction data set. By constructing the process in this way, a highly targeted and widely covered instruction data set can be obtained, providing high-quality training resources for subsequent natural language processing tasks.

[0092] Through the above steps 601 to 602, based on the preset large language model and the target prompt text, the target question and answer pairs of the corresponding prompt output quantity are extracted from the sample corpus text. Based on the input target prompt text, the corresponding quantity of high-quality target question and answer pairs can be extracted from the sample corpus text, ensuring that the quantity of generated target question and answer pairs matches the complexity of the sample corpus text, avoiding too many or too few target question and answer pairs.

[0093] participate Figure 7 In some embodiments, step 103 may include steps 701 to 702:

[0094] Step 701, obtain a text summary corresponding to a sample corpus text, and generate a target prompt text according to a first prompt text and the sample corpus text.

[0095] Step 702: Input the target prompt text and the text summary into a preset large language model to obtain a target question-answer pair related to the sample corpus text.

[0096] It can be understood that the text summary is a high-level summary and conclusion of the content of the sample corpus text, which can provide the key information of the article. Then, by combining the generated first prompt text with the original sample corpus text, a more targeted target prompt text is further generated.

[0097] It is understandable that the target prompt text can focus more on the core content of the sample corpus text. Then, the target prompt text and the text summary of the sample corpus text are input into the pre-set large language model for processing. The large language model will extract a series of target question-answer pairs related to the sample corpus text based on these inputs. The target question-answer pairs can better reflect the core content and key information of the sample corpus text.

[0098] Through the above steps 701 to 702, the target prompt text and the text summary are input into the preset large language model in combination with the text summary corresponding to the sample corpus text. The text summary provides summary and conclusion information, which can better help the large language model understand the sample corpus text and extract high-quality target question-answer pairs.

[0099] See also Figure 8 For example, the sample corpus text shown in Table 1 is briefly described as: "This is a primary and secondary school knowledge point compiled by a school teacher." The first prompt text is: "Please combine keywords such as "senior high school cell", "cell structure", "organelle", and "cell composition" to extract a question-answer pair from the text." The target prompt text is formed by combining the sample corpus text and input into the preset large language model together with the text summary.

[0100] See also Fig. 9In some embodiments, step 104 may include steps 801 to 802:

[0101] Step 801, filtering the target question and answer pair according to preset filtering rules, wherein the filtering rules include question and answer pair keyword filtering and question and answer pair length filtering.

[0102] It can be understood that keyword filtering can be to check the keywords of the question and answer parts of the target question and answer pair, remove some irrelevant or noisy target question and answer pairs, or limit the answer to include keywords such as "question" or "question", "answer" or "answer"; length filtering can be to set the shortest and longest length thresholds of the target question and answer pair, and remove target question and answer pairs with unreasonable lengths. Through such filtering processing, the quality of the generated target question and answer pairs can be further improved, and some low-quality or irrelevant samples can be removed.

[0103] Exemplarily, keyword filtering can be implemented based on a pre-established keyword dictionary, which contains some common low-quality or noisy words, such as some meaningless proper nouns, non-standard words, junk words, etc. When processing each target question and answer pair, the question and answer parts can be first segmented, and then the segmentation results can be checked to see whether the keywords in the dictionary are included. If so, the question and answer pair is marked as needing to be filtered. In addition to screening the words that need to be filtered in the keyword dictionary, a list of keywords that must appear can also be established. In addition, when processing each target question and answer pair, it is necessary not only to check whether the question and answer contain exclusive keywords, but also to ensure that at least specified necessary words are included. These necessary words can be core concept words related to the target task or field. If the question and answer parts of the target question and answer pair do not contain any necessary words, it is marked as needing to be filtered. In practical applications, both exclusive keyword filtering and necessary word filtering can be used at the same time, that is, the target question and answer pair must not contain exclusive keywords and must also contain specified necessary words. Only when these two conditions are met at the same time can the target question and answer pair pass the keyword filtering link and enter the subsequent processing flow.

[0104] Step 802, calculate the similarity between the target question-answer pairs after filtering, merge the target question-answer pairs whose similarity is greater than a preset similarity threshold, and obtain an instruction data set.

[0105] It is understandable that to calculate the similarity between each target question and answer pair, some text similarity calculation algorithms, such as cosine similarity, Euclidean distance, etc., can be used, and then a similarity threshold is set. All target question and answer pairs with similarity higher than this threshold are merged into one target question and answer pair to form the final instruction data set. The purpose of this is to remove duplicates and refine the target question and answer pairs, ensuring that the final instruction data set is more refined and high-quality, and avoiding a large number of redundant or repeated samples.

[0106] Exemplarily, the target question-answer pairs corresponding to each sample corpus text can be individually deduplicated, and then all the target question-answer pairs after individual deduplication can be deduplicated as a whole. A clustering algorithm (such as K-Means, DBSCAN, etc.) can be used to identify semantically similar target question-answer pairs, and one or several representative target question-answer pairs are retained from each clustering result, and redundant content is eliminated. The two-step deduplication method can effectively avoid redundancy between target question-answer pairs generated from the same sample corpus text, and can also eliminate duplicate content in the overall results, thereby improving the diversity and coverage of the results.

[0107] For example, the question length can be set between 5-50 characters and the answer length can be set between 10-100 characters, so as to ensure that the length of the target question-answer pair is not too short or too long and maintains a certain rationality. In actual processing, the question length and answer length of each target question-answer pair can be counted separately. If any link exceeds the preset range, the target question-answer pair is marked as needing to be filtered.

[0108] Through the above steps 801 to 802, the target question and answer pairs are filtered according to the preset filtering rules, wherein the filtering rules include question and answer pair keyword filtering and question and answer pair length filtering, the similarity between the target question and answer pairs after filtering is calculated, and the target question and answer pairs whose similarity is greater than the preset similarity threshold are merged, and a higher quality instruction data set is obtained after filtering and deduplication.

[0109] See also Fig.10 In some embodiments, step 802 may include steps 901 to 902:

[0110] Step 901: Encode the question text and answer text of the filtered target question-answer pair into a question-answer semantic vector based on a pre-trained semantic representation model.

[0111] It is understandable that the pre-trained semantic representation model can convert text into dense semantic vectors, which can capture the semantic features of text well. Common semantic representation models include Word2Vec, GloVe, BERT, and Sentence-BERT. By encoding the question and answer into vectors respectively, the semantic vector representation of each question and answer pair is obtained, that is, the question text and answer text of the target question and answer pair are encoded into question and answer semantic vectors to facilitate subsequent similarity calculations.

[0112] Step 902, calculate the similarity between the question and answer semantic vectors, merge the target question and answer pairs whose similarity is greater than a preset similarity threshold, and obtain an instruction data set.

[0113] It can be understood that the similarity between the question and answer semantic vectors of each question and answer pair can be calculated using cosine similarity, Euclidean distance or Pearson correlation coefficient, etc. After calculating the similarity, a similarity threshold is set. All target question and answer pairs with a similarity higher than this threshold are merged into one target question and answer pair to form the final instruction data set.

[0114] In some implementations, when merging target question-answer pairs with high similarity, it is also necessary to consider the difference in importance between the question text and the answer text. The question text contains the core requirements of the task and is the key part of the entire target question-answer pair, while the answer text is a response and supplement to the question text. Therefore, when calculating the similarity of the entire target question-answer pair, a higher weight can be set for the similarity of the question text. For example, the weight of the question text similarity in the total similarity of the target question-answer pair is 70%, and the weight of the answer text similarity is 30%, which can ensure that the importance of the question is reflected.

[0115] Through the above steps 901 to 902, the question text and answer text of the filtered target question and answer pairs are encoded into question and answer semantic vectors based on the pre-trained semantic representation model, the similarity between the question and answer semantic vectors is calculated, and repeated or similar question and answer pairs are eliminated, so that a higher quality and more refined instruction data set can be obtained to better meet the needs of subsequent natural language processing tasks.

[0116] See also Fig.11 , Fig.11This is a schematic diagram of the instruction data set construction method provided in the embodiment of the present application. The structured knowledge corpus is preprocessed to obtain a sample corpus text in a dictionary format and the level names of the multiple nested background levels in which it is located. The data loader reads the sample corpus text and the information of its level names, combines the text summary and the preset prompt template, uses the multiple level names as keywords, and fills them into the multiple spaces in the prompt template in the order of the corresponding background levels to generate the target prompt text as the input of the large language model. The large language model is called to generate the target question-answer pair according to the target prompt text and the sample corpus text, and then the target question-answer pair is verified, filtered, and saved to check whether the sample corpus text has been processed. If not, the data loader continues to load the remaining sample corpus text. After processing, all the obtained target question-answer pairs are deduplicated to obtain the instruction data set. Please refer to Fig.12 , Fig.12 This is a flow chart of the data loader provided in an embodiment of the present application. First, the loader is initialized, and the sample corpus text and its hierarchical name data are loaded from the initial position. After processing the data to obtain the target question and answer pairs, the detection point of the current data is saved, and it is checked whether the loading is completed. If not, it returns to the detection point position to continue loading and processing until all sample corpus texts are processed.

[0117] See also Fig.13 The embodiment of the present application also provides an instruction data set construction device, which can implement the above-mentioned instruction data set construction method. The instruction data set construction device includes: a sample acquisition module, which is used to obtain a sample corpus text and the level names of multiple nested background levels where the sample corpus text is located; a prompt template module, which is used to obtain a preset prompt template, use multiple level names as keywords, and fill them into multiple spaces in the prompt template in the order of the corresponding background levels to generate a first prompt text; a question-answer pair module, which is used to generate a target prompt text according to the first prompt text and the sample corpus text, and input the target prompt text into a preset large language model to obtain a target question-answer pair related to the sample corpus text; a data set module, which is used to construct an instruction data set based on the target question-answer pair.

[0118] The specific implementation of the instruction data set construction device is basically the same as the specific implementation of the instruction data set construction method described above, and will not be repeated here. On the premise of meeting the requirements of the embodiment of this application, the instruction data set construction device can also be provided with other functional modules to implement the instruction data set construction method in the above embodiment.

[0119] The embodiment of the present application also provides an electronic device, the electronic device includes a memory and a processor, the memory stores a computer program, and the processor implements the above instruction data set construction method when executing the computer program. The electronic device can be any intelligent terminal including a tablet computer, a car computer, etc.

[0120] See also Fig.14 , Fig.14 The hardware structure of an electronic device of another embodiment is illustrated, and the electronic device includes:

[0121] The processor 1401 may be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of the present application;

[0122] The memory 1402 may be implemented in the form of a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 1402 may store an operating system and other application programs. When the technical solution provided in the embodiment of this specification is implemented by software or firmware, the relevant program code is stored in the memory 1402, and the processor 1401 calls and executes the instruction data set construction method of the embodiment of this application;

[0123] Input / output interface 1403, used to implement information input and output;

[0124] The communication interface 1404 is used to realize the communication interaction between the device and other devices. The communication can be realized through a wired manner (such as USB, network cable, etc.) or a wireless manner (such as mobile network, WIFI, Bluetooth, etc.);

[0125] A bus 1405 that transmits information between the various components of the device (e.g., the processor 1401, the memory 1402, the input / output interface 1403, and the communication interface 1404);

[0126] The processor 1401 , the memory 1402 , the input / output interface 1403 and the communication interface 1404 are connected to each other in communication within the device via a bus 1405 .

[0127] An embodiment of the present application also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the above-mentioned instruction data set construction method is implemented.

[0128] The memory, as a non-transient computer-readable storage medium, can be used to store non-transient software programs and non-transient computer executable programs. In addition, the memory may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory may optionally include a memory remotely disposed relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0129] The embodiments described in the embodiments of the present application are intended to more clearly illustrate the technical solutions of the embodiments of the present application and do not constitute a limitation on the technical solutions provided in the embodiments of the present application. Those skilled in the art will appreciate that with the evolution of technology and the emergence of new application scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.

[0130] Those skilled in the art will appreciate that the technical solutions shown in the figures do not constitute a limitation on the embodiments of the present application, and may include more or fewer steps than shown in the figures, or a combination of certain steps, or different steps.

[0131] The device embodiments described above are merely illustrative, and the units described as separate components may or may not be physically separated, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0132] Those skilled in the art will appreciate that all or some of the steps in the methods disclosed above, and the functional modules / units in the systems and devices may be implemented as software, firmware, hardware, or a suitable combination thereof.

[0133] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0134] It should be understood that in the present application, "at least one (item)" and "several" refer to one or more, and "plurality" refers to two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the previous and subsequent associated objects are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.

[0135] In the several embodiments provided in the present application, it should be understood that the disclosed systems and methods can be implemented in other ways. For example, the system embodiments described above are only schematic. For example, the division of the above units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. The mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.

[0136] The units described above as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0137] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0138] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including multiple instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, referred to as ROM), random access memory (Random Access Memory, referred to as RAM), disk or optical disk and other media that can store programs.

[0139] The preferred embodiments of the present invention are described above with reference to the accompanying drawings, but the scope of the rights of the present invention is not limited thereto. Any modification, equivalent substitution and improvement made by a person skilled in the art without departing from the scope and essence of the present invention should be within the scope of the rights of the present invention.

Claims

1. A method for constructing an instruction data set, characterized in that: include: Acquire a sample corpus text and the level names of multiple nested background levels where the sample corpus text is located; Obtain a preset prompt template, use the multiple level names as keywords, and fill them into multiple spaces in the prompt template in sequence according to the order of the corresponding background levels to generate a first prompt text; Generate a target prompt text according to the first prompt text and the sample corpus text, and input the target prompt text into a preset large language model to obtain a target question-answer pair related to the sample corpus text; An instruction dataset is constructed based on the target question-answer pair.

2. The method for constructing an instruction data set according to claim 1, characterized in that: The step of obtaining a preset prompt template, using the plurality of level names as keywords, and sequentially filling the plurality of spaces in the prompt template in the order of the corresponding background levels to generate a first prompt text includes: Constructing a nested layer key-value pair according to the sample corpus text and the layer names of the multiple nested background layers where the sample corpus text is located, wherein the layer key-value pair includes multiple title keys constructed based on the layer names; A preset prompt template is obtained, and the order of the title keys of the nested layer key-value pairs is sequentially filled into a plurality of spaces in the prompt template to generate a first prompt text.

3. The method for constructing an instruction data set according to claim 2, characterized in that: The step of constructing a nested layer key-value pair according to the sample corpus text and the layer names of the multiple nested background layers where the sample corpus text is located includes: Constructing a first-level layer key-value pair according to the layer name of the first level and the text content of the sample corpus text, wherein the title key of the first-level layer key-value pair includes the layer name of the first level, and the value of the first-level layer key-value pair includes the text content of the sample corpus text; According to the layer names above the first level and the layer key-value pairs of the corresponding next level, the layer key-value pairs above the first level are constructed, wherein the title key of the layer key-value pairs above the first level includes the layer name of the corresponding level, and the value includes the layer key-value pair of the corresponding next level.

4. The method for constructing an instruction data set according to claim 1, characterized in that: The obtaining of the sample corpus text and the level names of the multiple nested background levels where the sample corpus text is located include: Acquire an initial corpus text, and extract multiple nested semantic keywords corresponding to the text content in the initial corpus text based on a pre-trained semantic analysis model; A sample corpus text is obtained according to the text content of the initial corpus text, and the level names of the multiple nested background levels where the sample corpus text is located are obtained according to the multiple nested semantic keywords.

5. The method for constructing an instruction data set according to claim 1, characterized in that: The step of obtaining a preset prompt template, using the plurality of level names as keywords, and sequentially filling the plurality of spaces in the prompt template in the order of the corresponding background levels to generate a first prompt text includes: Obtain a preset prompt template, use the multiple level names as keywords, and fill them into multiple spaces in the prompt template in sequence according to the order of the corresponding background levels; The number of prompt outputs is determined according to the number of sentences and the length of sentences in the sample corpus text, and a first prompt text is generated.

6. The method for constructing an instruction data set according to claim 5, characterized in that: The step of generating a target prompt text according to the first prompt text and the sample corpus text, and inputting the target prompt text into a preset large language model to obtain a target question-answer pair related to the sample corpus text includes: Generate a target prompt text according to the first prompt text and the sample corpus text, and input the target prompt text into a preset large language model; Based on the preset large language model and the target prompt text, target question-answer pairs corresponding to the prompt output quantity are extracted from the sample corpus text.

7. The method for constructing an instruction data set according to claim 1, characterized in that: The step of generating a target prompt text according to the first prompt text and the sample corpus text, and inputting the target prompt text into a preset large language model to obtain a target question-answer pair related to the sample corpus text includes: Obtaining a text summary corresponding to the sample corpus text, and generating a target prompt text according to the first prompt text and the sample corpus text; The target prompt text and the text summary are input into a preset large language model to obtain a target question-answer pair related to the sample corpus text.

8. The method for constructing an instruction data set according to claim 1, characterized in that: The constructing an instruction dataset based on the target question-answer pair includes: Filtering the target question-answer pair according to a preset filtering rule, wherein the filtering rule includes question-answer pair keyword filtering and question-answer pair length filtering; The similarity between the target question-answer pairs after filtering is calculated, and the target question-answer pairs whose similarity is greater than a preset similarity threshold are merged to obtain the instruction data set.

9. The method for constructing an instruction data set according to claim 8, characterized in that: The calculating the similarity between the target question-answer pairs after filtering, merging the target question-answer pairs whose similarity is greater than a preset similarity threshold, and obtaining the instruction data set includes: Encoding the filtered question text and answer text of the target question-answer pair into a question-answer semantic vector based on a pre-trained semantic representation model; The similarity between the question and answer semantic vectors is calculated, and the target question and answer pairs whose similarity is greater than a preset similarity threshold are merged to obtain the instruction data set.

10. A device for constructing an instruction data set, characterized in that: include: A sample acquisition module, used to acquire a sample corpus text and the level names of multiple nested background levels where the sample corpus text is located; A prompt template module, used to obtain a preset prompt template, use the plurality of level names as keywords, and fill them into a plurality of spaces in the prompt template in sequence according to the order of the corresponding background levels, to generate a first prompt text; A question-answer pair module, configured to generate a target prompt text according to the first prompt text and the sample corpus text, and input the target prompt text into a preset large language model to obtain a target question-answer pair related to the sample corpus text; The data set module is used to construct an instruction data set based on the target question-answer pair.

11. An electronic device, characterized in that: The electronic device includes a memory and a processor, the memory stores a computer program, and the processor implements the instruction data set construction method according to any one of claims 1 to 9 when executing the computer program.

12. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the instruction data set construction method according to any one of claims 1 to 9 is implemented.

Citation Information

Patent Citations

  • Method and device for generating high-quality question and answer data by using large language model

    CN117217315A

  • Text processing method and device, storage medium and electronic equipment

    CN117313719A

  • Question-answer corpus generation method and device based on text generation model

    WO2022095368A1