Method and apparatus for obtaining pre-processed text for fine-tuning large language models
By integrating quantitative statistics and conversation templates to generate preprocessed text, the problems of poor preprocessed text quality and high human resource consumption in existing technologies are solved, and efficient fine-tuning of large language models is achieved.
Patent Information
- Application Number
- CN202411549961.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-01
- Publication Date
- 2026-01-16
- Estimated Expiration
- 2044-11-01
AI Technical Summary
Existing methods for generating preprocessed text suffer from poor quality and high human resource consumption, failing to effectively guarantee the practicality of large language models in various scenarios.
By defining the preprocessing task of the large language model, performing quantitative statistics, retrieving matching conversation templates, determining retrieval constraints based on quantitative elements and conversation templates, searching for text objects in the target retrieval domain, and integrating them with conversation templates to generate preprocessed text.
It achieves accuracy and effectiveness in preprocessing text, reduces the consumption of human resources, and improves the matching of fine-tuned corpora with tasks.
Smart Images

Figure CN119558290B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of text processing, in particular to a method and device for obtaining pre-processing text for fine-tuning a large language model. BACKGROUND
[0002] With the rapid development of natural language processing technology, generative pre-training large models may not perform well in some specific tasks or fields. At this time, it is usually necessary to fine-tune the large model using fine-tuning corpus as pre-processing text. A common form of large model (LLM) fine-tuning corpus is a question and answer form of "one question and one answer", which realizes various tasks such as generating an outline, generating an abstract, text continuation, keyword extraction, translation, etc. through question and answer.
[0003] At present, the generation of existing pre-processing text usually includes screening from source corpus or manual writing. However, the pre-processing text screened from the source corpus has a large error with the processing task, so that the quality of the pre-processing text is poor, which cannot guarantee the scene practicability of the large model, and manual writing requires a large amount of human resources, which puts forward a higher requirement for the professional knowledge of the staff, has high cost, and greatly reduces the effectiveness of obtaining pre-processing text. SUMMARY
[0004] Therefore, the present application provides a method and device for obtaining pre-processing text for fine-tuning a large language model, which mainly aims to solve the problem of obtaining pre-processing text for fine-tuning a large language model.
[0005] According to one aspect of the present application, a method for obtaining pre-processing text for fine-tuning a large language model is provided, comprising:
[0006] determining a pre-processing task of a to-be-processed large language model, and quantitatively counting the pre-processing task to obtain a quantitative element, the pre-processing task being used to represent content that the large language model is applicable to a specific language processing scene;
[0007] retrieving a conversation template matched with the pre-processing task, and determining a retrieval constraint condition of a target retrieval field based on the quantitative element and the conversation template;
[0008] in response to a text object retrieval instruction, searching for a text object in the target retrieval field according to the retrieval constraint condition, and integrating the searched text object with the conversation template to obtain pre-processing text, so as to fine-tune the large language model based on the pre-processing text.
[0009] Further, the quantitatively counting the pre-processing task to obtain a quantitative element comprises:
[0010] obtain historical session text of the preprocessing task, and perform template splitting on the historical session text to obtain answer text;
[0011] determine an element object in the answer text that matches the preprocessing task, and count a quantity of the element object in the answer text;
[0012] generate a quantitative element based on the element object, the quantity, and a preset element condition that matches the element object.
[0013] Further, the determining, based on the quantitative element and the conversation template, of a retrieval constraint condition of a target retrieval field comprises:
[0014] receiving a selected target retrieval field;
[0015] extracting element limitation condition information of the quantitative element according to the conversation template;
[0016] generating a retrieval constraint condition based on the target retrieval field and the element limitation condition information.
[0017] Further, the determining of the preprocessing task of the to-be-processed large language model comprises:
[0018] in response to a text generation instruction, obtaining an expected target expected to be processed by a large language model;
[0019] querying a preprocessing task matching the expected target according to different task types, different task types matching different preprocessing tasks.
[0020] Further, the integrating, of the searched text object and the conversation template, to obtain preprocessing text comprises:
[0021] parsing a question template and an answer template of the conversation template according to the preprocessing task;
[0022] extracting question text matching the question template and answer text matching the answer template from the text object;
[0023] combining the question text and the answer text according to the conversation template to obtain preprocessing text.
[0024] Further, before the integrating, of the searched text object and the conversation template, to obtain preprocessing text, the method further comprises:
[0025] obtaining sensitive information matching the preprocessing task;
[0026] If the sensitive information exists in the text object, the sensitive information in the text object is deleted or replaced by a preset character, and the text object after the sensitive information is deleted or replaced is integrated.
[0027] Further, the method further comprises:
[0028] determining a compiling format of the large language model;
[0029] If the text format of the preprocessed text does not match the editing format, the preprocessed text is converted according to the compiling format, and the preprocessed text after conversion is preprocessed based on the preprocessed text after conversion.
[0030] According to another aspect of the present application, an acquisition device for fine-tuning preprocessed text of a large language model is provided, comprising:
[0031] A determination module is configured to determine a preprocessing task of a large language model to be processed, and quantitatively count the preprocessing task to obtain a quantitative element, wherein the preprocessing task is used to represent content of the large language model applicable to a specific language processing scenario;
[0032] A calling module is configured to call a conversation template matched with the preprocessing task, and determine a retrieval constraint condition of a target retrieval field based on the quantitative element and the conversation template;
[0033] An integration module is configured to search for a text object in the target retrieval field according to the retrieval constraint condition in response to a text object retrieval instruction, and integrate the searched text object with the conversation template to obtain preprocessed text, so as to fine-tune the large language model based on the preprocessed text.
[0034] Further, the determination module is specifically configured to obtain historical conversation text of the preprocessing task, and perform template splitting on the historical conversation text to obtain answer text; determine an element object matched with the preprocessing task in the answer text, and count a number of the element object in the answer text; and generate a quantitative element based on the element object, the number, and a preset element condition matched with the element object.
[0035] Further, the calling module is specifically configured to receive a selected target retrieval field; extract element limitation condition information of the quantitative element according to the conversation template; and generate a retrieval constraint condition based on the target retrieval field and the element limitation condition information.
[0036] Further, the determining module is specifically further configured to, in response to a text generation instruction, acquire an expected target expected to be processed by the large language model; and acquire a pre-processing task matched with the expected target according to different task types, wherein different task types match different pre-processing tasks.
[0037] Further, the integrating module is configured to parse a question template and an answer template of the conversation template according to the pre-processing task; extract question text matched with the question template and answer text matched with the answer template from the text object; and combine the question text and the answer text according to the conversation template to obtain pre-processed text.
[0038] Further, the apparatus further comprises:
[0039] The acquiring module is configured to acquire sensitive information matched with the pre-processing task.
[0040] The deleting module is configured to, if the sensitive information exists in the text object, delete the sensitive information in the text object or replace the sensitive information in the text object by a preset character, and integrate the text object after the sensitive information is deleted or replaced.
[0041] Further, the determining module is further configured to determine a compiling format of the large language model; and if a text format of the pre-processed text does not match the compiling format, convert the pre-processed text according to the compiling format to perform pre-processing based on the converted pre-processed text.
[0042] According to another aspect of the present application, a storage medium is provided, wherein the storage medium stores at least one executable instruction, and the executable instruction causes a processor to perform operations corresponding to the above-mentioned method for acquiring pre-processed text for fine-tuning a large language model.
[0043] According to still another aspect of the present application, a terminal is provided, which comprises a processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface complete communication with each other through the communication bus.
[0044] The memory is configured to store at least one executable instruction, and the executable instruction causes the processor to perform operations corresponding to the above-mentioned method for acquiring pre-processed text for fine-tuning a large language model.
[0045] By means of the above technical solutions, the technical solutions provided by the embodiments of the present application have at least the following advantages:
[0046] The application provides an acquisition method and device for pre-processing text for fine-tuning a large language model, compared with the prior art, the embodiment of the application determines a pre-processing task of a large language model to be processed, and quantitatively counts the pre-processing task to obtain a quantitative element, the pre-processing task is used to represent that the large language model is suitable for content of a specific language processing scene; a conversation template matched with the pre-processing task is called, and a retrieval constraint condition of a target retrieval field is determined based on the quantitative element and the conversation template; in response to a text object retrieval instruction, the target retrieval field is searched for a text object according to the retrieval constraint condition, and the searched text object is integrated with the conversation template to obtain pre-processing text, so that the large language model is fine-tuned based on the pre-processing text, the fine-tuning corpus and the task are high in matching, the automatic fine-tuning corpus generation purpose is achieved, a large amount of human resources is reduced, and therefore the accuracy and effectiveness of the pre-processing text acquisition for fine-tuning the large language model are realized.
[0047] The above description is only a summary of the technical scheme of the application, in order to more clearly understand the technical means of the application, the specific embodiments of the application can be implemented according to the content of the specification, and in order to make the above and other purposes, characteristics and advantages of the application more obvious and easy to understand, the following specific embodiments of the application are described. BRIEF DESCRIPTION OF DRAWINGS
[0048] Various other advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiments. The accompanying drawings are intended to further assist in understanding the preferred embodiments, and are not intended to limit the application thereto. Moreover, like reference numerals designate like parts throughout the several views in the drawings. In the drawings:
[0049] Figure 1 A flow chart of an acquisition method for pre-processing text for fine-tuning a large language model provided by an embodiment of the application is shown;
[0050] Figure 2 A block diagram of an acquisition device for pre-processing text for fine-tuning a large language model provided by an embodiment of the application is shown;
[0051] Figure 3 A structural schematic diagram of a terminal provided by an embodiment of the application is shown. DETAILED DESCRIPTION
[0052] Exemplary embodiments of the present disclosure will be described more fully hereinafter with reference to the accompanying drawings, in which exemplary embodiments of the present disclosure are shown. It is to be understood that the present disclosure can be embodied in various forms and should not be limited by the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the present disclosure to those skilled in the art.
[0053] The embodiment of the present application provides an acquisition method for fine-tuning preprocessed text of a large language model, as shown in the figure, the method comprises: Figure 1
[0054] 101, determine the preprocessing task of the large language model to be processed, and quantitatively analyze the preprocessing task to obtain quantization elements.
[0055] In the embodiment of the present application, as the execution subject of generating preprocessed text when fine-tuning the large language model, the current execution end can be a server or a cloud server, or a terminal device or a client device, that is, a large amount of text data in different fields can be searched to construct the required preprocessed text for fine-tuning the large language model. Wherein, the large language model (Large Language Model, LLM for short) is a deep learning model trained using a large amount of text data, which can generate natural language text or understand the meaning of language text, and can process various natural language tasks such as text classification, question and answer, dialogue, etc., including but not limited to LLaMA, ChatGLM and BLOOM, etc., which are not limited in the embodiment of the present application. Wherein, since the large language model needs to be pre-trained with different corpora for different language recognition needs, after pre-training, in order to make the large language model more suitable for business scenario needs, it needs to be fine-tuned with specific corpora, therefore, in the embodiment of the present application, first, the preprocessing task of the large language model to be fine-tuned is determined, at this time, the preprocessing task is used to represent the content of the large language model applicable to a specific language processing scene, including but not limited to open and closed question and answer, text generation, information extraction, multilingual translation, sentiment analysis, content recommendation, etc., which can be configured and determined based on different business parties, or can be determined based on the task label of the pre-training sample of the large language model, or can be based on automatic scoring tools such as BLEU, METEOR, ROUGE, etc. Scoring the output results of different tasks output by the pre-trained large language model, determining the task type with a score lower than the preset target value as the fine-tuning task type, which is not limited in the embodiment of the present application.
[0056] It should be noted that in order to make the generated preprocessed text more standardized, the current execution end quantitatively analyzes the determined preprocessing task, at this time, the quantization element is the numerical requirement of corpus extraction required for the preprocessing task of different task types, for example, the preprocessing task of the knowledge question and answer task type, the quantization element obtained by quantitative analysis is that the total number of characters of the answer is between 300-800, which is not limited in the embodiment of the present application.
[0057] 102. Retrieve the session template that matches the preprocessing task, and determine the retrieval constraints of the target retrieval domain based on the quantification elements and the session template.
[0058] In this embodiment of the invention, the conversation template is used to represent the template for the conversation corpus constituted by the preprocessing task, including question templates and answer templates. Different preprocessing tasks can be matched with one conversation template or multiple conversation templates; this embodiment of the invention does not impose specific limitations. Furthermore, since fine-tuning of the large language model is required for specific business operations, to make the specified business more adaptable and increase the diversity of the fine-tuning corpus, the retrieval domain is used to represent the subject area of the obtained paper corpus, such as major categories like "Basic Science," "Engineering Technology Series I," "Engineering Technology Series II," "Agricultural Technology," and "Medical and Health Technology" in a web-based full-domain paper collection, or several minor categories; this embodiment of the invention does not impose specific limitations. Simultaneously, the target retrieval domain can be selected based on task requirements or task type, or multiple target retrieval domains can be randomly determined; this embodiment of the invention does not impose specific limitations. Furthermore, retrieval constraints in the target retrieval domain are determined according to quantitative elements and the conversation template, so that the required content can be accurately retrieved according to these retrieval constraints.
[0059] It should be noted that when retrieving the session template, the current execution end can pre-compile large model instructions (Prompt, such as GPT4) to abstract the template. The expected number of question templates is obtained by configuring the quantity requirements in the instructions. Answer templates can be obtained using the same method; this embodiment of the invention does not impose specific limitations. Alternatively, the question and answer templates output by the large model can be manually reviewed and supplemented to determine the final session template; this embodiment of the invention does not impose specific limitations on this method either.
[0060] The following is a sample question template: Template: Please generate a paper outline for my topic [XXX].
[0061] Templates for the same task type can also be:
[0062] 1. Please help me design an outline for the thesis topic [XXX].
[0063] 2. I need to create an outline for the thesis topic [XXX]. Please help me.
[0064] 3. Could you please provide an outline for my thesis topic [XXX]?
[0065] 4. Please help me develop an outline based on the thesis title [XXX].
[0066] 103. In response to the text object retrieval instruction, search for text objects in the target retrieval field according to the retrieval constraint condition, and integrate the searched text objects with the conversation template to obtain preprocessed text, so as to fine-tune the large language model based on the preprocessed text.
[0067] In the embodiment of the application, the user triggers the retrieval instruction of the text object to instruct the current execution end to search for text objects in the target retrieval field according to the retrieval constraint condition, that is, to search in the target retrieval field of the academic paper according to the retrieval constraint condition, and obtain a target number of paper corpus as text objects. Further, the searched text objects are integrated with the conversation template to obtain preprocessed text, so as to fine-tune the large language model based on the preprocessed text.
[0068] It should be noted that when the text objects are integrated with the conversation template, the text objects can be inserted into the question template and the answer template in the order of question and answer to obtain complete question and answer corpus for fine-tuning of the large language model.
[0069] The embodiment of the application provides a method for obtaining preprocessed text for fine-tuning a large language model. Compared with the prior art, the embodiment of the application determines a preprocessing task of a to-be-processed large language model, and quantitatively counts the preprocessing task to obtain a quantitative element. The preprocessing task is used to represent content to which the large language model is applicable in a specific language processing scenario. A conversation template matched with the preprocessing task is called, and retrieval constraint conditions of a target retrieval field are determined based on the quantitative element and the conversation template. In response to a text object retrieval instruction, text objects are searched in the target retrieval field according to the retrieval constraint conditions, and the searched text objects are integrated with the conversation template to obtain preprocessed text. The large language model is fine-tuned based on the preprocessed text. The fine-tuning corpus and the task have high matching, and the automatic fine-tuning corpus generation purpose is achieved. A large amount of human resources is reduced, so that the accuracy and effectiveness of the preprocessed text for fine-tuning the large language model are obtained.
[0070] In another embodiment of the application, to further limit and illustrate, the step of quantitatively counting the preprocessing task to obtain a quantitative element includes:
[0071] Obtain historical conversation text of the preprocessing task, and perform template splitting on the historical conversation text to obtain answer text.
[0072] Determine an element object in the answer text matched with the preprocessing task, and count the number of the element object in the answer text.
[0073] generate a quantitative element based on the element object, the number, and a preset element condition matched with the element object.
[0074] In order to ensure the quality of the preprocessed corpus and reduce the occurrence of non-specific, ambiguous, and the like, the current execution end first acquires historical session text of the preprocessing task, that is, the historical session text is session text that has been fine-tuned by the preprocessing task, which can include text content of any field. Further, the current execution end splits the historical session text into templates, that is, splits the historical session text into question text and answer text in the form of question and answer. At this time, the splitting can be performed by using keywords (such as “question” and “reply”) or based on punctuation marks (such as “:” and “?”) representing questions or statement moods, which is not specifically limited in the embodiments of the present application. After the current execution end splits the answer text, the element object matched with the preprocessing task in the answer text is determined. At this time, the element object is used to represent specific content in the form of a reply in different task types, for example, the element object is the number of answers for a knowledge question and answer task type, the element object is the outline level for a generating outline task type, and the element object is the number of words and paragraphs for a continuing writing task type. The element object can be matched by querying a preconfigured element correspondence relationship, which is not specifically limited in the embodiments of the present application. Further, the current execution end determines the number of element objects from the answer text, for example, the number of paragraphs, the number of words, and the number of outline levels, which can be counted by using compiled query counting instructions, which is not specifically limited in the embodiments of the present application.
[0075] It should be noted that after counting the number, a quantitative element is generated based on the element object, the number, and a preset element condition matched with the element object. At this time, the preset element condition is a condition for limiting the counted number of element objects, for example, when the element object is the number of words and the counted number of words is 300, if the preset element condition is that the number of words cannot be more than 500, then the generated quantitative element is that the number of words is between 300 and 500, which is not specifically limited in the embodiments of the present application. Table 1 is a quantitative statistical result obtained by quantitatively counting different preprocessing tasks of different task types:
[0076] Table 1:
[0077]
[0078]
[0079] In another embodiment of the present application, in order to further limit and illustrate, the step of determining the search constraint condition of the target search field based on the quantitative element and the session template includes:
[0080] receiving a selected target search field;
[0081] extracting element limitation condition information of the quantified element according to the conversation template;
[0082] generating a search constraint condition based on the target search field and the element limitation condition information.
[0083] In order to realize the automatic search purpose of the corpus content and improve the search efficiency of the text object, when determining the search constraint condition, the current execution end first receives the target search field selected by the user. Among them, the user can select one or more target search fields from all search fields through the current execution end, such as "Engineering Science I", "Engineering Science II", "Agricultural Science", etc. The embodiment of the present application does not make specific limitation, and then the element limitation condition information of the generated quantified element is extracted according to the conversation template. At this time, the element limitation condition information is the specific limitation content such as quantity and words in the quantified element, for example, the quantified element is the number of characters required in the instruction, and the number of characters in the paragraph continuation writing in the instruction is between 500-1000, and the corresponding element limitation condition information is the number of characters 500-1000. At this time, the extraction according to the conversation template is to determine the element limitation condition information according to the question template and the answer template, so that the content searched when entering the question or outputting the answer can match the quantified element. The embodiment of the present application does not make specific limitation. Among them, the element limitation condition does not only include quantity and other conditions, but also includes specific conditions such as outline level and paragraph number, and includes the template form in the conversation template as the limitation condition. Further, the current execution end generates a search constraint condition based on the target search field and the element limitation condition information, that is, uses this search constraint condition as the condition for searching the text object from the target search field, so as to accurately select useful and adaptive text as the fine-tuning corpus.
[0084] In another embodiment of the present application, in order to further limit and illustrate, the step of determining the preprocessing task of the to-be-processed large language model includes:
[0085] In response to the text generation instruction, an expected target expected to be processed by the large language model is obtained;
[0086] According to different task types, a preprocessing task matched with the expected target is queried.
[0087] In order to make the fine-tuning corpus more targeted and improve the construction accuracy of the corpus, when determining the preprocessing task, the current execution end can first receive a text generation instruction triggered by a user to instruct the current execution end to obtain an expected target of the large language model. The expected target is used to represent the scenario target of the large language model for corpus fine-tuning, and can be carried in the text generation instruction so that the current execution end directly extracts it from the instruction. Then, the preprocessing task matching the expected target is queried according to different task types. The current execution end has a prior corresponding relationship between different task types and different preprocessing tasks, so as to directly query and match. For example, the task type is query, and the corresponding preprocessing task is query corpus fine-tuning task of the large language model, which is not limited in the embodiment of the application.
[0088] In another embodiment of the application, in order to further limit and illustrate, the step of integrating the searched text object and the conversation template to obtain the preprocessing text comprises:
[0089] parsing the question template and the answer template of the conversation template according to the preprocessing task;
[0090] extracting the question text matching the question template and the answer text matching the answer template in the text object;
[0091] combining the question text and the answer text according to the conversation template to obtain the preprocessing text.
[0092] In order to realize the effectiveness of obtaining the fine-tuning corpus and improve the fine-tuning effect of the large language model, when integrating the text object and the conversation template, the current execution end specifically first parses the question template and the answer template in the conversation template according to the preprocessing task. The question template is used to assist the user to input the content to be retrieved, and the answer template is used to form a standard answer text from the retrieved text object. Then, the question text matching the question template and the answer text matching the answer template are extracted from the retrieved text object, so as to insert the question text and the answer text into the conversation template for combination to obtain the preprocessing text. For example, the preprocessing task is to extract keywords, the question template of the parsed conversation template is "What are the keywords of XXX article?", the answer template is "The keywords of XXX article are....", the question text matching the question template in the text object is "Y article", and the answer text matching the answer template is "keyword A, keyword B, keyword C". Then, after combination, the obtained preprocessing text is "What are the keywords of Y article? The keywords of Y article are keyword A, keyword B, keyword C".
[0093] In one specific embodiment, as shown in Table 2, the preprocessed text finally generated for the task type is:
[0094] Table 2:
[0095]
[0096]
[0097]
[0098]
[0099] In another embodiment of the present application, in order to further define and illustrate, before the step of integrating the text object searched and the conversation template to obtain the preprocessed text, the method further comprises:
[0100] Obtaining sensitive information matched with the preprocessing task;
[0101] If the sensitive information exists in the text object, deleting the sensitive information in the text object, or replacing the sensitive information in the text object by a preset character, and integrating the text object after deleting or replacing the sensitive information.
[0102] In order to ensure the effectiveness of the text object and the security of the data, and to avoid invalid text content affecting the fine-tuning effect of the fine-tuning corpus on the large language model, the current execution end can also obtain sensitive information matched with the preprocessing task before integration. Different preprocessing tasks can be pre-configured with different sensitive information. At this time, the sensitive information includes but is not limited to address, mobile phone number, ID number, insult, prejudice, etc. The embodiments of the present application are not limited. After the current execution end obtains the sensitive information, the text words in the text object are matched with the sensitive information in sequence. If the above sensitive information exists in the text object, the sensitive information in the text object can be deleted, or the above sensitive information can be replaced by a preset character. The preset character includes but is not limited to space, specified letters or numbers, etc. so as to desensitize the text object.
[0103] In another embodiment of the present application, in order to further define and illustrate, the step further comprises:
[0104] Determining the compilation format of the large language model;
[0105] If the text format of the preprocessed text does not match the editing format, converting the preprocessed text according to the compilation format, and preprocessing based on the converted preprocessed text.
[0106] In order to meet the flexible fine-tuning processing requirements of different large language models, and improve the fine-tuning efficiency of the large language model based on the preprocessed text, the current execution end first determines the compilation format of the large language model, such as the json format, and the embodiment of the application does not make specific limitation. Further, it is judged whether the text format of the preprocessed text matches the compilation format. If it does not match, it means that the preprocessed text obtained by integration cannot be directly input into the large language model for fine-tuning processing. Therefore, the preprocessed text is converted according to the compilation format, and the preprocessed text in the compilation format is converted, so as to fine-tune the large language model according to the converted preprocessed text.
[0107] The embodiment of the application provides another method for obtaining preprocessed text for fine-tuning a large language model. Compared with the prior art, the embodiment of the application determines a preprocessing task of a large language model to be processed, and quantitatively counts the preprocessing task to obtain a quantitative element. The preprocessing task is used to represent the content of the large language model suitable for a specific language processing scene. A conversation template matched with the preprocessing task is called, and a retrieval constraint condition of a target retrieval field is determined based on the quantitative element and the conversation template. In response to a text object retrieval instruction, the text object is searched in the target retrieval field according to the retrieval constraint condition, and the searched text object is integrated with the conversation template to obtain preprocessed text. The large language model is fine-tuned based on the preprocessed text, the high matching of fine-tuning corpus and task is realized, and the automatic fine-tuning corpus generation purpose is realized. A large amount of human resources is reduced, so that the accuracy and effectiveness of the preprocessed text for fine-tuning the large language model are realized.
[0108] Further, as an implementation of the method shown in the above Figure 1 The embodiment of the application provides an acquisition device for preprocessed text for fine-tuning a large language model, as shown in the above Figure 2 The device comprises:
[0109] A determination module 21 is configured to determine a preprocessing task of a large language model to be processed, and quantitatively count the preprocessing task to obtain a quantitative element. The preprocessing task is used to represent the content of the large language model suitable for a specific language processing scene.
[0110] A calling module 22 is configured to call a conversation template matched with the preprocessing task, and determine a retrieval constraint condition of a target retrieval field based on the quantitative element and the conversation template.
[0111] The integration module 23 is configured to search for a text object in the target search field according to the search constraint condition in response to the text object retrieval instruction, and integrate the searched text object with the conversation template to obtain preprocessed text, so as to fine-tune the large language model based on the preprocessed text.
[0112] Further, the determination module is specifically configured to obtain historical conversation text of the preprocessed task, and perform template splitting on the historical conversation text to obtain answer text; determine an element object matched with the preprocessed task in the answer text, and count a quantity of the element object in the answer text; and generate a quantitative element based on the element object, the quantity, and a preset element condition matched with the element object.
[0113] Further, the retrieval module is specifically configured to receive a selected target search field; extract element limitation condition information of the quantitative element according to the conversation template; and generate a search constraint condition based on the target search field and the element limitation condition information.
[0114] Further, the determination module is specifically configured to obtain an expected target expected to be processed by the large language model in response to a text generation instruction; and query a preprocessed task matched with the expected target according to different task types, different task types matching different preprocessed tasks.
[0115] Further, the integration module is configured to parse a question template and an answer template of the conversation template according to the preprocessed task; extract a question text matched with the question template and an answer text matched with the answer template in the text object; and combine the question text and the answer text according to the conversation template to obtain preprocessed text.
[0116] Further, the apparatus further comprises:
[0117] The acquisition module is configured to acquire sensitive information matched with the preprocessed task;
[0118] The deletion module is configured to delete the sensitive information in the text object, or replace the sensitive information in the text object by a preset character, so as to integrate the text object after the sensitive information is deleted or replaced.
[0119] Further, the determination module is further configured to determine a compilation format of the large language model; and if a text format of the preprocessed text does not match the compilation format, convert the preprocessed text according to the compilation format, so as to perform preprocessing based on the converted preprocessed text.
[0120] This invention provides a preprocessed text acquisition device for fine-tuning a large language model. Compared with the prior art, this invention determines the preprocessing task of the large language model to be processed, and performs quantitative statistics on the preprocessing task to obtain quantitative elements. The preprocessing task is used to characterize the content of the large language model applicable to a specific language processing scenario. A conversation template matching the preprocessing task is retrieved, and retrieval constraints for the target retrieval domain are determined based on the quantitative elements and the conversation template. In response to a text object retrieval instruction, text objects are searched in the target retrieval domain according to the retrieval constraints, and the searched text objects are integrated with the conversation template to obtain preprocessed text. The large language model is then fine-tuned based on the preprocessed text, achieving high matching between the fine-tuning corpus and the task, and achieving automatic fine-tuning corpus generation, reducing a large amount of human resources. This results in accurate and effective acquisition of preprocessed text for fine-tuning the large language model.
[0121] According to one embodiment of the present invention, a storage medium is provided, the storage medium storing at least one executable instruction, the computer-executable instruction being able to execute the method for obtaining preprocessed text for fine-tuning a large language model in any of the above method embodiments.
[0122] Figure 3 The diagram shows a structural schematic of a terminal according to an embodiment of the present invention. The specific implementation of the terminal is not limited by the specific embodiments of the present invention.
[0123] like Figure 3 As shown, the terminal may include: a processor 302, a communications interface 304, a memory 306, and a communications bus 308.
[0124] The processor 302, communication interface 304, and memory 306 communicate with each other via communication bus 308.
[0125] Communication interface 304 is used to communicate with other network elements such as clients or other servers.
[0126] The processor 302 is used to execute program 310, specifically to execute the relevant steps in the above embodiment of the method for obtaining preprocessed text for fine-tuning a large language model.
[0127] Specifically, program 310 may include program code that includes computer operation instructions.
[0128] The processor 302 can be a central processing unit (CPU), or an application specific integrated circuit (ASIC), or one or more integrated circuits configured to perform the embodiments of the present application. The terminal can include one or more processors of the same type, such as one or more CPUs, or processors of different types, such as one or more CPUs and one or more ASICs.
[0129] The memory 306 is configured to store a program 310. The memory 306 can include a high-speed RAM memory, and can also include a non-volatile memory, such as at least one disk memory.
[0130] The program 310 can be specifically configured to cause the processor 302 to perform the following operations:
[0131] determining a pre-processing task of a large language model to be processed, and performing quantitative statistics on the pre-processing task to obtain a quantitative element, the pre-processing task being used to represent content of the large language model suitable for a specific language processing scenario;
[0132] retrieving a conversation template matched with the pre-processing task, and determining a retrieval constraint condition of a target retrieval field based on the quantitative element and the conversation template;
[0133] in response to a text object retrieval instruction, searching for a text object in the target retrieval field according to the retrieval constraint condition, and integrating the searched text object with the conversation template to obtain a pre-processed text, so as to fine-tune the large language model based on the pre-processed text.
[0134] Obviously, those skilled in the art should understand that the above-mentioned modules or steps of the present application can be realized by general computing devices, which can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, and optionally, they can be realized by program codes executable by computing devices, so that they can be stored in storage devices and executed by computing devices, and in some cases, the steps shown or described can be executed in different order, or they can be manufactured into individual integrated circuit modules, or multiple modules or steps can be manufactured into a single integrated circuit module. Therefore, the present application is not limited to any specific combination of hardware and software.
[0135] The above merely provides the preferred embodiments of the present application, and is not used to limit the present application. For those skilled in the art, the present application can have various modifications and changes. Any modifications, equivalent replacements, improvements, etc. made within the principles and technical scope of the present application shall fall into the scope of the present application.
Claims
1. An acquisition method for fine-tuning pre-processed text of a large language model, characterized in that, The method comprises the following steps: determining a preprocessing task of a large language model to be processed, and performing quantitative statistics on the preprocessing task to obtain a quantitative element, the preprocessing task being used to represent that the large language model is suitable for a specific language processing scene; retrieving a conversation template matched with the preprocessing task, and determining a retrieval constraint condition of a target retrieval field based on the quantitative element and the conversation template; in response to a text object retrieval instruction, searching for a text object in the target retrieval field according to the retrieval constraint condition, and integrating the searched text object with the conversation template to obtain a preprocessing text, so as to fine-tune the large language model based on the preprocessing text; the quantitative statistics on the preprocessing task to obtain the quantitative element comprises: obtaining historical conversation text of the preprocessing task, and performing template splitting on the historical conversation text to obtain answer text; determining an element object matched with the preprocessing task in the answer text, and counting the number of the element object in the answer text; generating a quantitative element based on the element object, the number, and a preset element condition matched with the element object.
2. The method of claim 1, wherein, the determination of the retrieval constraint condition of the target retrieval field based on the quantitative element and the conversation template comprises: receiving a selected target retrieval field; extracting element limitation condition information of the quantitative element according to the conversation template; generating a retrieval constraint condition based on the target retrieval field and the element limitation condition information.
3. The method of claim 1, wherein, the determination of the preprocessing task of the large language model to be processed comprises: in response to a text generation instruction, obtaining an expected target expected to be processed by a large language model; querying a preprocessing task matched with the expected target according to different task types, different task types matching different preprocessing tasks.
4. The method of claim 1, wherein, the integration of the searched text object with the conversation template to obtain the preprocessing text comprises: analyzing a question template and an answer template of the conversation template according to the preprocessing task; extracting question text matched with the question template and answer text matched with the answer template from the text object; combining the question text and the answer text according to the conversation template to obtain the preprocessing text.
5. The method of claim 1, wherein, before the integration of the searched text object with the conversation template to obtain the preprocessing text, the method further comprises: obtaining sensitive information matched with the preprocessing task; if the sensitive information exists in the text object, deleting the sensitive information in the text object or replacing the sensitive information in the text object with a preset character, so as to integrate the text object after the deletion of the sensitive information or the replacement of the sensitive information.
6. The method of claim 1, wherein, the method further comprises: determining a compilation format of the large language model; if the text format of the preprocessing text does not match the compilation format, converting the preprocessing text according to the compilation format to perform preprocessing based on the converted preprocessing text.
7. An acquisition device for fine-tuning pre-processed text of a large language model, characterized in that, The determining module is configured to determine a preprocessing task of a large language model to be processed, and perform quantitative statistics on the preprocessing task to obtain a quantitative element, the preprocessing task being used to represent content of the large language model applicable to a specific language processing scenario; The calling module is configured to call a conversation template matched with the preprocessing task, and determine a retrieval constraint condition of a target retrieval field based on the quantitative element and the conversation template; The integration module is configured to search for a text object in the target retrieval field according to the retrieval constraint condition in response to a text object retrieval instruction, and integrate the searched text object with the conversation template to obtain a preprocessing text, so as to fine-tune the large language model based on the preprocessing text. The determining module is specifically configured to obtain historical conversation text of the preprocessing task, and perform template splitting on the historical conversation text to obtain an answer text. An element object matched with the preprocessing task in the answer text is determined, and a quantity of the element object in the answer text is counted. A quantitative element is generated based on the element object, the quantity, and a preset element condition matched with the element object.
8. A storage medium, the storage medium storing at least one executable instruction, the executable instruction causing a processor to perform operations corresponding to the preprocessing text acquisition method for fine-tuning a large language model according to any one of claims 1-6.
9. A terminal comprising: A processor, a memory, a communication interface, and a communication bus, the processor, the memory, and the communication interface completing communication with each other through the communication bus; The memory is used to store at least one executable instruction, and the executable instruction causes the processor to perform operations corresponding to the preprocessing text acquisition method for fine-tuning a large language model according to any one of claims 1-6.
Citation Information
Patent Citations
Method and system for finely adjusting pre-training language large model based on structured data
CN117271734A
Data processing method and device, equipment and storage medium
CN117520523A