Model fine tuning data set generation method and device, equipment, medium and program product

Through automated text extraction and segmentation technology, combined with pre-configured prompt word templates, a suitable fine-tuned data set is generated, which solves the problem of manual annotation dependence in the existing technology and improves the efficiency and quality of data set generation.

CN119849493APending Publication Date: 2025-04-18CHONGQING WUTONG CAR LINK TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411914425.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-24
Publication Date
2025-04-18

AI Technical Summary

Technical Problem

In the prior art, fine-tuning data set generation relies on manual annotation, resulting in large workload, time-consuming and data deviations, affecting model performance.

Method used

By receiving the initial file, text extraction and segmentation are automatically performed, multiple text blocks are generated that are suitable for text content, and prompt words are automatically generated based on pre-configured prompt word templates and text blocks, and finally a fine-tuning data set for fine-tuning the pre-trained model.

Benefits of technology

It effectively avoids the workload and data deviation caused by manual annotation, improves the generation efficiency and quality of fine-tuning data sets, and reduces the possibility of human error.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119849493A_ABST
    Figure CN119849493A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of natural language processing, and discloses a model fine tuning data set generation method, device and equipment, a medium and a program product.The model fine tuning data set is used for performing fine tuning on a pre-training model.The method comprises the steps that firstly, an initial file used for performing fine tuning on the pre-training model is received, and text extraction is performed on the initial file; the method comprises the following steps: extracting a text content, and segmenting the extracted text content to obtain a plurality of semantic text blocks adapted to the text content, thereby generating a cue word adapted to the text content based on a pre-configured cue word template and the plurality of text blocks, and further, generating a cue word adapted to the text content based on the cue word. And obtaining a fine tuning data set for performing fine tuning on the pre-training model. The workload caused by manually extracting and labeling the content of the initial file is effectively avoided, and the data deviation caused by the understanding difference and subjectivity of an individual to the text in the manual labeling process is effectively avoided.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of natural language technology, and in particular to a method, device, equipment, medium and program product for generating a model fine-tuning data set. Background Art

[0002] Large language models such as GPT-4 (chatbot language model) and BERT (Bidirectional Encoder Representations from Transformers) can generate natural language text and understand complex contexts and semantics by pre-training on massive text data. In order to improve the performance of the model in a specific task or field, it is usually necessary to fine-tune the pre-trained model. Fine-tuning is the process of further training the pre-trained model to adapt to a specific task or field. During the fine-tuning process, the model needs to be adjusted according to the data of the specific task to improve the performance of the model on the task.

[0003] In related technologies, the generation of fine-tuning datasets usually relies on manual annotation, which requires a lot of time and expertise. The whole process is cumbersome and time-consuming, especially when a large amount of files and information needs to be processed. The problems of labor cost and error rate are particularly prominent. At the same time, there are problems such as the subjectivity of manual processing, which leads to deviations in the dataset and affects the performance of the model. Therefore, how to quickly obtain an effective fine-tuning dataset has become a technical problem that needs to be solved urgently. Summary of the invention

[0004] In view of this, the present invention provides a method, device, equipment, medium and program product for generating a model fine-tuning dataset to solve the technical problem of how to quickly obtain an effective fine-tuning dataset, which has become an urgent problem to be solved.

[0005] In a first aspect, the present invention provides a method for generating a model fine-tuning dataset, where the model fine-tuning dataset is used to fine-tune a pre-trained model, the method comprising:

[0006] Receive initial files for fine-tuning a pre-trained model;

[0007] Perform text extraction on the initial file to obtain the text content;

[0008] Segmenting the text content to obtain multiple text blocks that are semantically adapted to the text content, wherein the multiple text blocks have the same number of characters;

[0009] Generate prompt words adapted to the text content based on pre-configured prompt word templates and multiple text blocks;

[0010] Based on the prompt words, a fine-tuning dataset is obtained to fine-tune the pre-trained model.

[0011] The model fine-tuning data set generation method of the present invention, the model fine-tuning data set is used to fine-tune the pre-trained model, first receiving the initial file used to fine-tune the pre-trained model, performing text extraction on the initial file, and segmenting the extracted text content to obtain multiple text blocks with semantics adapted to the text content, thereby generating prompt words adapted to the text content based on the pre-configured prompt word template and multiple text blocks, and further, based on the prompt words, a fine-tuning data set for fine-tuning the pre-trained model can be obtained. Thus, the initial file is automatically subjected to text extraction, and the extracted text content is segmented to obtain multiple text blocks with semantics adapted to the text content, thereby automatically generating prompt words adapted to the text content using the pre-configured prompt word template and text blocks. The workload caused by manually extracting and annotating the content of the initial file, as well as the data deviation caused by individual differences in understanding of the text and subjectivity during the manual annotation process are effectively avoided.

[0012] In some optional implementations, the encoding format of the initial file is one of a plurality of text encoding formats;

[0013] Perform text extraction on the initial file, including:

[0014] Automatically detect the file encoding format of the initial file;

[0015] Based on the file encoding format, the initial file is identified and parsed to obtain the text content.

[0016] The model fine-tuning data set generation method of the present invention can automatically identify the file encoding format of the initial file, and based on the file encoding format, automatically perform text recognition and parsing, thereby automatically extracting information from text files in various formats, effectively improving the processing efficiency of the initial file and the accuracy of information extraction.

[0017] In some optional implementations, the file encoding format is a pdf document;

[0018] Based on the file encoding format, the initial file is identified and parsed, including:

[0019] Optical character recognition technology is used to identify the initial document.

[0020] In some optional implementations, the file encoding format is a Markdown file;

[0021] Based on the file encoding format, the initial file is identified and parsed, including:

[0022] Parse the text syntax of the initial file to distinguish the initial file's headers, lists, and code blocks;

[0023] Based on the text syntax parsing results, the text content is obtained.

[0024] In some optional implementations, segmenting the text content includes:

[0025] Using natural language processing technology, the text content is divided into a plurality of initial segments that are no longer than a first set length and conform to set semantic integrity rules;

[0026] According to the set padding rule, the initial segment is padded to a text block of the second set length.

[0027] The model fine-tuning data set generation method of the present invention adopts natural language processing technology to perform text segmentation on the extracted text content, ensuring that the segmented text blocks are both semantically complete and adaptable to the processing requirements of the large language model, and further completing the context paragraphs to ensure the contextual relevance between text blocks, significantly reducing the information bias caused by segmenting the text content to generate text blocks, and effectively ensuring the quality of the text blocks.

[0028] In some optional implementations, obtaining a fine-tuning dataset for fine-tuning a pre-trained model based on a prompt word includes:

[0029] Input the prompt words into the pre-trained model through the application programming interface;

[0030] Receiving a question-answer pair generated by a pre-trained model in response to a prompt word;

[0031] Based on the question-answer pairs, generate a fine-tuning dataset in a specified format.

[0032] The model fine-tuning dataset generation method of the present invention interacts with the pre-trained model through a stable application programming interface, reasonably solves problems such as model call limitations, delays and version updates, and has a complete fault tolerance and retry mechanism, which effectively ensures the stability of the fine-tuning dataset generated based on the prompt words combined with the pre-trained model, and significantly improves the reliability of the generated fine-tuning dataset.

[0033] In some optional implementations, the prompt word template is designed based on an initial file.

[0034] The model fine-tuning dataset generation method of the present invention, the system flexibly designs prompt word templates based on the initial file, can intelligently generate suitable question and answer pairs according to the content and context of the text, and the design of the prompt word template can fully consider the independence, depth and accuracy of text citations of questions based on the initial file, thereby generating high-quality fine-tuning data to meet the needs of different text types and topics.

[0035] In some optional implementations, the initial file is in one of the following file encoding formats: doc, docx, md, pdf, csv, txt, json.

[0036] In a second aspect, the present invention provides a device for generating a model fine-tuning dataset, where the model fine-tuning dataset is used to fine-tune a pre-trained model, and the device includes:

[0037] A receiving module, configured to receive an initial file for fine-tuning a pre-trained model;

[0038] An extraction module is used to extract text from the initial file to obtain text content;

[0039] A segmentation module is used to segment the text content to obtain multiple text blocks that are semantically adapted to the text content, and the multiple text blocks have the same number of characters;

[0040] A prompt word module, used for generating prompt words adapted to text content based on a pre-configured prompt word template and a plurality of text blocks;

[0041] The generation module is used to obtain a fine-tuning dataset for fine-tuning the pre-training model based on the prompt words.

[0042] In a third aspect, the present invention provides a computer device, comprising: a memory and a processor, the memory and the processor being communicatively connected to each other, the memory storing computer instructions, and the processor executing the model fine-tuning dataset generation method of the first aspect or any corresponding embodiment thereof by executing the computer instructions.

[0043] In a fourth aspect, the present invention provides a computer-readable storage medium having computer instructions stored thereon, the computer instructions being used to enable a computer to execute the method for generating a model fine-tuning dataset according to the first aspect or any corresponding embodiment thereof.

[0044] In a fifth aspect, the present invention provides a computer program product, comprising computer instructions, wherein the computer instructions are used to enable a computer to execute the method for generating a model fine-tuning dataset according to the first aspect or any corresponding embodiment thereof.

[0045] In the method, device, equipment, medium and program product for generating a model fine-tuning data set of the present invention, the model fine-tuning data set is used to fine-tune the pre-trained model. First, an initial file for fine-tuning the pre-trained model is received, text is extracted from the initial file, and the extracted text content is segmented to obtain multiple text blocks with semantics adapted to the text content, thereby generating prompt words adapted to the text content based on a pre-configured prompt word template and multiple text blocks. Further, based on the prompt words, a fine-tuning data set for fine-tuning the pre-trained model can be obtained. Thus, the initial file is automatically subjected to text extraction, and the extracted text content is segmented to obtain multiple text blocks with semantics adapted to the text content, thereby automatically generating prompt words adapted to the text content using the pre-configured prompt word template and text blocks. The workload caused by manually extracting and annotating the content of the initial file, as well as the data deviation caused by individual differences in understanding of the text and subjectivity during the manual annotation process are effectively avoided. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0047] Figure 1 Schematic diagram of an application scenario of a method for generating a model fine-tuning dataset according to an embodiment of the present invention;

[0048] Figure 2 is a flowchart of a method for generating a model fine-tuning dataset according to an embodiment of the present invention;

[0049] Figure 3 is a flowchart of another method for generating a model fine-tuning dataset according to an embodiment of the present invention;

[0050] Figure 4 is a structural block diagram of a device for generating a model fine-tuning dataset according to an embodiment of the present invention;

[0051] Figure 5 It is a schematic diagram of the hardware structure of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION

[0052] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.

[0053] The present invention provides a method for generating a model fine-tuning dataset, aiming to solve the problem of how to quickly obtain an effective fine-tuning dataset, effectively avoiding the waste of human resources caused by manually annotating data used to fine-tune a pre-trained large language model. At the same time, it effectively avoids the deviation of the manually created fine-tuning dataset due to the subjective views of the annotator, thereby avoiding the impact of the fine-tuning dataset deviation on the generalization ability of the model.

[0054] Specifically, the present invention utilizes a well-trained pre-trained model and designs a coherent and efficient automated fine-tuning dataset generation method. Figure 1 Schematic diagram of an application scenario of the method for generating a model fine-tuning dataset according to an embodiment of the present invention. Figure 1 As shown, the embodiment of the present invention implements a model fine-tuning dataset generation method based on a fine-tuning dataset generation system. The system may include a text loader 101, a text splitter 102, prompt templates 103, and a large model request interface (LLM APIs) 104.

[0055] The text loader 101 can receive initial files in various text encoding formats such as .docx, .md, .pdf, .csv, .txt, and .json, and perform text extraction operations such as reading and parsing the initial files to obtain text content, which can be stored and transmitted in the form of txt text. The text segmenter 102 can segment the text content to obtain multiple text blocks that are semantically adapted to the text content, and the multiple text blocks have the same number of characters.

[0056] The prompt word template 103 can be used to generate a template for a question-answer pair. Specifically, a suitable prompt word can be generated according to the text content and context. The prompt word template is flexible and can generate a variety of question-answer data. The prompt word template can include specific information such as format requirements for questions and answers, independence and depth of questions, and how to quote text content.

[0057] The large model request interface 104 can be used to interact with the pre-trained large language model, send the generated prompt word request (Prompt), and receive the answer generated by the pre-trained large language model, so as to generate a question-answer pair, and further generate a fine-tuning data set that meets the format requirements, for example: json format. The pre-trained large language model is also referred to as the pre-trained model in other descriptions in the text. From receiving the prompt word to generating a fine-tuning data set in json format, it can be achieved by the generation module described below. Through the large model request interface 104, the prompt word (Prompt) generated based on the prompt word template 103 and the text block can be input into the pre-training, and the answer generated by the pre-trained large model is received, thereby generating a question-answer pair. The question-answer pair can also further generate a fine-tuning data set that meets the format requirements. Here, the large model request interface 104 can use some open source API interfaces. Specifically, it is necessary to focus on practical issues such as call restrictions, delays, version updates, etc. of the pre-trained large model, and there should be fault tolerance and retry mechanisms to effectively ensure the stability and reliability of the system.

[0058] According to an embodiment of the present invention, an embodiment of a method for generating a model fine-tuning dataset is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in an order different from that shown here.

[0059] In this embodiment, a method for generating a model fine-tuning dataset is provided, which can be used in a server for model training, etc. Figure 2 is a flowchart of a method for generating a model fine-tuning dataset according to an embodiment of the present invention. Figure 2 As shown, the process includes the following steps:

[0060] Step S201, receiving an initial file for fine-tuning a pre-trained model.

[0061] The initial file can be in various text encoding formats such as .docx, .md, .pdf, .csv, .txt, .json, etc. The initial file contains data for fine-tuning the pre-trained model.

[0062] The model fine-tuning data set generation method provided in the embodiment of the present invention is used to accurately extract and quickly annotate valid information in an initial file.

[0063] Step S202, extracting text from the initial file to obtain text content.

[0064] Step S203, segmenting the text content to obtain multiple text blocks that are semantically adapted to the text content, wherein the multiple text blocks have the same number of characters.

[0065] Here, the above-mentioned text segmenter 102 can be used to implement this operation. The main purpose of segmenting the text content is to cut the loaded text content into text chunks of appropriate length and complete semantics. This operation step is crucial because suitable text chunks help improve the quality and efficiency of generating fine-tuning datasets.

[0066] Therefore, the text content segmentation can be divided into two steps. First, according to different knowledge fields, text encoding formats, etc., a customized segmentation strategy is configured to segment the text into initial texts of different sizes. In the second step, trunk_size (text block length) and repeat_size (number of repeated characters) are set according to different needs, and multiple initial texts are padded into text blocks of equal length. In this way, the loaded text content can be cut into text blocks of appropriate length and complete semantics.

[0067] Step S204: Generate prompt words adapted to the text content based on the pre-configured prompt word template and multiple text blocks.

[0068] In some optional embodiments of the present invention, flexible prompt word templates may be used, for example, prompt word templates may be customized based on different knowledge fields and pre-trained models. Thus, prompt words adapted to the text content are generated based on the pre-configured prompt word templates and multiple text blocks. This further ensures the diversity and pertinence of the question-answer pairs generated after the prompt words are input into the pre-trained model, and can meet the needs of different topics and text styles.

[0069] Step S205: Based on the prompt words, a fine-tuning data set for fine-tuning the pre-training model is obtained.

[0070] Here, the prompt words can be first input into the pre-trained model to obtain rich question-answer pairs, and the obtained question-answer pairs can be converted into a fine-tuning dataset in a set text encoding format. Here, the output format of the question-answer pairs can also be directly set to the set text encoding format.

[0071] The model fine-tuning data set generation method of the present invention, the model fine-tuning data set is used to fine-tune the pre-trained model, first receiving the initial file used to fine-tune the pre-trained model, performing text extraction on the initial file, and segmenting the extracted text content to obtain multiple text blocks with semantics adapted to the text content, thereby generating prompt words adapted to the text content based on the pre-configured prompt word template and multiple text blocks, and further, based on the prompt words, a fine-tuning data set for fine-tuning the pre-trained model can be obtained. Thus, the initial file is automatically subjected to text extraction, and the extracted text content is segmented to obtain multiple text blocks with semantics adapted to the text content, thereby automatically generating prompt words adapted to the text content using the pre-configured prompt word template and text blocks. The workload caused by manually extracting and annotating the content of the initial file, as well as the data deviation caused by individual differences in understanding of the text and subjectivity during the manual annotation process are effectively avoided.

[0072] In this embodiment, a method for generating a model fine-tuning dataset is provided, which can be used in a server for model training, etc. Figure 3 is a flowchart of a method for generating a model fine-tuning dataset according to an embodiment of the present invention. Figure 3 As shown, the process includes the following steps:

[0073] Step S301, receiving an initial file for fine-tuning a pre-trained model.

[0074] See above Figure 2 The step S201 shown is not repeated here.

[0075] Step S302: extract text from the initial file to obtain text content.

[0076] Specifically, the encoding format of the initial file is one of multiple text encoding formats;

[0077] The above step S302 may include:

[0078] Step S3021, automatically detecting the file encoding format of the initial file.

[0079] In some optional implementations, the file encoding format may be identified based on set characters in the file name of the initial file, such as .docx, .md, .pdf, .csv, .txt, .json, and other text encoding formats.

[0080] Step S3022: Based on the file encoding format, perform text recognition and analysis on the initial file to obtain text content.

[0081] In some optional implementations, the file encoding format is a PDF document, and optical character recognition technology can be used to identify the initial file.

[0082] In some optional implementations, the file encoding format is a Markdown file, and the text syntax of the initial file can be parsed first to distinguish the title, list and code block of the initial file, and then the text content is obtained based on the text syntax parsing result.

[0083] The model fine-tuning data set generation method of the present invention can automatically identify the file encoding format of the initial file, and based on the file encoding format, automatically perform text recognition and parsing, thereby automatically extracting information from text files of various formats, effectively improving the processing efficiency of the initial file and the accuracy of information extraction.

[0084] Step S303, segmenting the text content to obtain multiple text blocks that are semantically adapted to the text content, wherein the multiple text blocks have the same number of characters.

[0085] In some optional implementations, the above step S303 may include:

[0086] Step S3031, using natural language processing technology, divide the text content into multiple initial segments that are no longer than a first set length and comply with set semantic integrity rules.

[0087] In some optional implementations, natural language processing (NLP) technology can be used to segment text content based on identifiers such as titles, paragraphs, sentences, etc. For example, sentence boundary detection can be used to determine text breakpoints to ensure the coherence and integrity of text units.

[0088] The first set length can be set according to actual needs, and the present invention does not limit the specific value of the first set length.

[0089] Step S3032: padding the initial segment into a text block of a second set length according to a set padding rule.

[0090] The main purpose of padding the initial segment to a text block of the second set length is to pad the context paragraph. Here, the number of text characters in the text block can be determined by setting trunk_size. For example, the second set length can be 250, so that each text block has the same size. Here, the repeated part of the text block can also be determined by setting repeat_size. Repeat_size can be 50, so that each trunk has a context association.

[0091] In natural language data processing, repeat_size usually refers to the number of times a data block is repeated, which is used to increase the size of the data block. For example, in the MindSpore framework, repeat_size is an optional parameter with a default value of 1. When repeat_size is set to a value greater than 1, the data set is repeated the specified number of times, thereby increasing the amount of training data, which helps improve the generalization ability and training effect of the pre-trained model.

[0092] At the same time, in natural language processing, contextual information is crucial for understanding and generating language. In order to ensure the relevance of context in text generation tasks, the repeat_size parameter can be used to control the extent to which the model repeats previous information when generating text.

[0093] repeat_size usually refers to a parameter in the self-attention mechanism when using the transformer model for text generation, which determines how many previous words the model will consider when generating new words. If repeat_size is small, the model will rely more on short-term memory to generate text, and if repeat_size is large, the model will rely more on long-term memory and contextual information.

[0094] In practice, repeat_size can be set by adjusting the model's hyperparameters. When using the transformer model for text generation, you can set repeat_size to control the size of the context window that the model looks at when generating each word.

[0095] The model fine-tuning data set generation method of the present invention adopts natural language processing technology to perform text segmentation on the extracted text content, ensuring that the segmented text blocks are both semantically complete and adaptable to the processing requirements of the large language model, and further completing the context paragraphs to ensure the contextual relevance between text blocks, significantly reducing the information bias caused by segmenting the text content to generate text blocks, and effectively ensuring the quality of the text blocks.

[0096] Step S304: Generate prompt words adapted to the text content based on the pre-configured prompt word template and multiple text blocks.

[0097] In some optional implementations, the prompt word template is designed based on an initial file.

[0098] The prompt word template is the key to generating question-answer pairs. Therefore, the prompt word template is designed according to the text content and context of the initial file, so that the generated question-answer pairs are both targeted and easy for the large language model to understand. The prompt word template should be flexible and can be adjusted according to different topics and text styles to generate diverse question-answer data.

[0099] In some optional implementations, an effective prompt word template is provided as follows:

[0100] "Write some questions and answers based on the following literature, at least 10 questions, requirements:

[0101] (1) Format requirements: Questions and answers must be written directly in JSON format, with each question and answer in a curly bracket, without any extra words. For example:

[0102] [{"question":"",

[0103] "answer":""}]

[0104] (2) Questions should be as clear as possible in context (they can be answered without reference to the literature, and words such as "according to the report" or "original text" should not appear in the question. If you want to use the content of the report, you can directly quote the original text). If it is unclear, you can add appropriate qualifiers (time, place, person). The answer should be completely dependent on (loyal to) the content of the literature, and the content should be detailed, sufficient, and easy to understand. You can assume that the content of the literature does not exist when the question is asked, but it is visible when the answer is given.

[0105] (3) Each question is independent, and there should be no duplication or shared context between questions. Therefore, each question should have appropriate limitations. Secondly, the questions should be in-depth and based on your understanding of the entire text of the document.

[0106] (4) The content of the document is as follows:

[0107] ....text trunk content...

[0108] }

[0109] ”

[0110] The model fine-tuning dataset generation method of the present invention, the system flexibly designs prompt word templates based on the initial file, can intelligently generate suitable question and answer pairs according to the content and context of the text, and the design of the prompt word template can fully consider the independence, depth and accuracy of text citations of questions based on the initial file, thereby generating high-quality fine-tuning data to meet the needs of different text types and topics.

[0111] Step S305: Based on the prompt words, a fine-tuning data set for fine-tuning the pre-training model is obtained.

[0112] Specifically, step S305 may include:

[0113] Step S3051, inputting the prompt word into the pre-trained model through the application programming interface.

[0114] Step S3052, receiving the question-answer pair generated by the pre-trained model in response to the prompt word.

[0115] Step S3053: Generate a fine-tuning dataset in a set format based on the question-answer pair.

[0116] The format set here can be json format.

[0117] The model fine-tuning dataset generation method of the present invention interacts with the pre-trained model through a stable application programming interface, reasonably solves problems such as model call limitations, delays and version updates, and has a complete fault tolerance and retry mechanism, which effectively ensures the stability of the fine-tuning dataset generated based on the prompt words combined with the pre-trained model, and significantly improves the reliability of the generated fine-tuning dataset.

[0118] The model fine-tuning dataset generation method provided in the embodiment of the present invention automatically generates a fine-tuning dataset without manual intervention, and efficiently completes the generation of the fine-tuning dataset through intelligent technical means, effectively reducing the annotation cost and time, significantly improving production efficiency, and reducing the possibility of human errors, ensuring the quality and reliability of the data. Further, through reasonable text processing and generation technology, it is guaranteed that the generated fine-tuning dataset has high accuracy and consistency. At the same time, the model fine-tuning dataset generation method of the embodiment of the present invention has good scalability and customizability. Specifically, the system supports a variety of text encoding formats, and can provide customized segmentation strategies and prompt word template configurations for different fields and data features. This modular design enables the system to quickly adapt to technology upgrades and functional expansions, and meet a wide range of research and commercial needs. In addition, through flexible prompt word templates and efficient API interfaces, the model fine-tuning dataset generation method provided in the embodiment of the present invention can adapt to the needs of different topics and text styles, improve the fine-tuning effect of large language models in specific tasks and fields, and improve the adaptability and application breadth of the model.

[0119] In this embodiment, a model fine-tuning data set generation device is also provided, which is used to implement the above-mentioned embodiments and preferred implementation modes, and will not be repeated here. As used below, the term "module" can implement a combination of software and / or hardware for a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.

[0120] This embodiment provides a device for generating a model fine-tuning dataset, where the model fine-tuning dataset is used to fine-tune a pre-trained model. Figure 4 As shown, including:

[0121] A receiving module 401 is used to receive an initial file for fine-tuning a pre-trained model;

[0122] Extraction module 402, used to extract text from the initial file to obtain text content;

[0123] A segmentation module 403 is used to segment the text content to obtain multiple text blocks that are semantically adapted to the text content, and the multiple text blocks have the same number of characters;

[0124] A prompt word module 404, for generating prompt words adapted to the text content based on a pre-configured prompt word template and a plurality of text blocks;

[0125] The generation module 405 is used to obtain a fine-tuning data set for fine-tuning the pre-training model based on the prompt word.

[0126] The further functional description of each of the above modules and units is the same as that of the above corresponding embodiments and will not be repeated here.

[0127] In some optional implementations, the encoding format of the initial file is one of a plurality of text encoding formats;

[0128] The extraction module 402 includes:

[0129] Format unit, used to automatically detect the file encoding format of the initial file;

[0130] The extraction unit is used to perform text recognition and parsing on the initial file based on the file encoding format to obtain the text content.

[0131] In some optional implementations, the file encoding format is a pdf document;

[0132] The extraction unit includes:

[0133] The recognition subunit is used to recognize the initial document by using the optical character recognition technology.

[0134] In some optional implementations, the file encoding format is a Markdown file;

[0135] The extraction unit includes:

[0136] A parsing subunit, for parsing the text syntax of the initial file to distinguish the header, list and code block of the initial file;

[0137] The text subunit is used to obtain the text content based on the text grammar parsing result.

[0138] In some optional implementations, the segmentation module 403 includes:

[0139] A segmentation unit, used to segment the text content into a plurality of initial segments not greater than a first set length and conforming to a set semantic integrity rule by using a natural language processing technology;

[0140] The padding unit is used to pad the initial segment into a text block of a second set length according to a set padding rule.

[0141] In some optional implementations, the generation module 405 includes:

[0142] An input unit, used for inputting a prompt word into a pre-trained model through an application programming interface;

[0143] A receiving unit, configured to receive a question-answer pair generated by a pre-trained model in response to a prompt word;

[0144] The generation unit is used to generate a fine-tuning dataset in a specified format based on the question-answer pairs.

[0145] In some optional implementations, the prompt word template is designed based on an initial file.

[0146] In some optional implementations, the initial file is in one of the following file encoding formats: doc, docx, md, pdf, csv, txt, json.

[0147] The model fine-tuning dataset generation device in this embodiment is presented in the form of a functional unit, where the unit refers to an ASIC (Application Specific Integrated Circuit) circuit, a processor and memory that executes one or more software or fixed programs, and / or other devices that can provide the above functions.

[0148] The embodiment of the present invention also provides a computer device having the above Figure 4 The model fine-tuning dataset generation apparatus shown.

[0149] See also Figure 5 , Figure 5 is a schematic diagram of the structure of a computer device provided by an optional embodiment of the present invention, such as Figure 5As shown, the computer device includes: one or more processors 10, a memory 20, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. Various components are connected to each other using different buses for communication, and can be installed on a common mainboard or installed in other ways as needed. The processor can process the instructions executed in the computer device, including instructions stored in or on the memory to display the graphical information of the GUI on an external input / output device (such as, a display device coupled to the interface). In some optional embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple computer devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Figure 5 A processor 10 is taken as an example.

[0150] The processor 10 may be a central processing unit, a network processor or a combination thereof. The processor 10 may further include a hardware chip. The hardware chip may be a dedicated integrated circuit, a programmable logic device or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general purpose array logic or any combination thereof.

[0151] The memory 20 stores instructions executable by at least one processor 10, so that at least one processor 10 executes the method shown in the above embodiment.

[0152] The memory 20 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created according to the use of the computer device, etc. In addition, the memory 20 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 optional embodiments, the memory 20 may optionally include a memory remotely arranged relative to the processor 10, and these remote memories may be connected to the computer device 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.

[0153] The memory 20 may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a flash memory, a hard disk or a solid state drive; the memory 20 may also include a combination of the above types of memory.

[0154] The computer device further comprises a communication interface 30 for the computer device to communicate with other devices or a communication network.

[0155] The embodiment of the present invention also provides a computer-readable storage medium. The method according to the embodiment of the present invention can be implemented in hardware, firmware, or can be implemented as a computer code that can be recorded in a storage medium, or can be implemented as a computer code that is originally stored in a remote storage medium or a non-temporary machine-readable storage medium and will be stored in a local storage medium through a network download, so that the method described herein can be stored in such software processing on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only storage memory, a random access memory, a flash memory, a hard disk or a solid-state hard disk, etc.; further, the storage medium can also include a combination of the above types of memories. It can be understood that a computer, a processor, a microprocessor controller, or programmable hardware includes a storage component that can store or receive software or computer code. When the software or computer code is accessed and executed by a computer, a processor, or hardware, the method shown in the above embodiment is implemented.

[0156] A part of the present invention may be applied as a computer program product, such as a computer program instruction, which, when executed by a computer, can call or provide the method and / or technical solution according to the present invention through the operation of the computer. Those skilled in the art should understand that the existence of the computer program instruction in a computer-readable medium includes, but is not limited to, a source file, an executable file, an installation package file, etc., and accordingly, the way in which the computer program instruction is executed by the computer includes, but is not limited to: the computer directly executes the instruction, or the computer compiles the instruction and then executes the corresponding compiled program, or the computer reads and executes the instruction, or the computer reads and installs the instruction and then executes the corresponding installed program. Here, the computer-readable medium may be any available computer-readable storage medium or communication medium accessible to the computer.

[0157] Although the embodiments of the present invention have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present invention, and such modifications and variations are all within the scope defined by the appended claims.

Claims

1. A method for generating a model fine-tuning dataset, characterized in that: The model fine-tuning dataset is used to fine-tune the pre-trained model, and the method includes: Receiving an initial file for fine-tuning the pre-trained model; Performing text extraction on the initial file to obtain text content; Segmenting the text content to obtain a plurality of text blocks that are semantically adapted to the text content, wherein the plurality of text blocks have the same number of characters; Based on a preconfigured prompt word template and the plurality of text blocks, generating prompt words adapted to the text content; Based on the prompt word, a fine-tuning dataset for fine-tuning the pre-training model is obtained.

2. The method according to claim 1, characterized in that The encoding format of the initial file is one of multiple text encoding formats; The extracting text from the initial file comprises: Automatically detecting the file encoding format of the initial file; Based on the file encoding format, text recognition and parsing are performed on the initial file to obtain the text content.

3. The method according to claim 2, characterized in that The file encoding format is a pdf document; The performing text recognition and parsing on the initial file based on the file encoding format includes: The initial document is recognized using optical character recognition technology.

4. The method according to claim 2, characterized in that: The file encoding format is Markdown file; The performing text recognition and parsing on the initial file based on the file encoding format includes: Parsing the text syntax of the initial file to distinguish the header, list and code block of the initial file; Based on the text grammar parsing result, the text content is obtained.

5. The method according to claim 1, characterized in that: The segmenting of the text content includes: Using natural language processing technology, the text content is divided into a plurality of initial segments that are no longer than a first set length and conform to a set semantic integrity rule; According to a set padding rule, the initial segment is padded to a text block of a second set length.

6. The method according to claim 1, characterized in that The step of obtaining a fine-tuning data set for fine-tuning the pre-training model based on the prompt word includes: Inputting the prompt word into the pre-trained model through an application programming interface; Receiving a question-answer pair generated by the pre-trained model in response to the prompt word; Based on the question-answer pairs, a fine-tuning dataset in a set format is generated.

7. The method according to any one of claims 1 to 6, characterized in that The prompt word template is designed based on the initial file.

8. The method according to any one of claims 1 to 6, characterized in that The initial file is in one of the following file encoding formats: doc, docx, md, pdf, csv, txt, json.

9. A device for generating a model fine-tuning dataset, characterized in that: The model fine-tuning dataset is used to fine-tune the pre-training model, and the device includes: A receiving module, configured to receive an initial file for fine-tuning the pre-trained model; An extraction module, used for extracting text from the initial file to obtain text content; A segmentation module, used for segmenting the text content to obtain a plurality of text blocks that are semantically adapted to the text content, wherein the plurality of text blocks have the same number of characters; A prompt word module, used for generating prompt words adapted to the text content based on a pre-configured prompt word template and the plurality of text blocks; A generation module is used to obtain a fine-tuning data set for fine-tuning the pre-training model based on the prompt word.

10. A computer device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the model fine-tuning dataset generation method according to any one of claims 1 to 8 by executing the computer instructions.

11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the model fine-tuning dataset generation method according to any one of claims 1 to 8.

12. A computer program product, characterized in that The method comprises computer instructions for causing a computer to execute the method for generating a model fine-tuning dataset according to any one of claims 1 to 8.