Task processing method, model training method and code generating method

By expanding the corpus and training large language models, the problem that large language model corpus is difficult to obtain in specific industries or fields is solved, and the accuracy and model performance of text generation tasks are improved.

CN119692464AInactive Publication Date: 2025-03-25ALIBABA CLOUD FEITIAN (HANGZHOU) CLOUD COMPUTING TECH CO LTD

Patent Information

Application Number
CN202411675632.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-21
Publication Date
2025-03-25
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Because the corpus of training large language models in a specific industry or field is difficult to obtain, the accuracy of the output results of the text generation task is low through the large language model.

Method used

By extending the initial corpus, a large number of extended corpus are generated, and training a large language model for processing target type text generation tasks based on the extended corpus, the construction cost and difficulty of obtaining model training data is reduced, and the diversity and richness of the data is increased.

Benefits of technology

The accuracy of the output results of the large language model processing target type text generation task is improved, the performance of the model is improved, and the problem of low accuracy caused by difficult corpus is solved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119692464A_ABST
    Figure CN119692464A_ABST
Patent Text Reader

Abstract

The invention discloses a task processing method, a model training method and a code generating method. The method comprises the following steps: determining target request information and target prompt information of a target task; the target request information and the target prompt information are input into a first large language model to be processed, reply information corresponding to the target task is obtained, the first large language model is obtained based on extended corpus training, and the extended corpus is corpus obtained through extension of initial corpus associated with the text generation task of the target type. The technical problem that the accuracy of the output result of the text generation task processed through the large language model is low due to the fact that the corpus for training the large language model of the specific industry or field is difficult to obtain is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of large language models, and more specifically, to a task processing method, a model training method, and a code generation method. Background Art

[0002] The big language model is a natural language processing model based on deep learning technology. With the gradual popularization of the application of big language models, more and more users are beginning to use big language models in their work and life.

[0003] However, the performance of large language models in general fields cannot directly meet the needs of users in professional fields. Since the basic large language models have insufficient understanding of the terms and concepts of specific industries or fields, the generated content is inaccurate or does not meet professional standards.

[0004] In order to enable large language models to handle text generation tasks in specific industries or fields, the related technology uses SFT (supervised fine-tuning) to train large language models, that is, using a pre-trained model as the initial state, and then fine-tuning it on the training set of the target task so that the model can better adapt to the target task. However, the high-quality corpus required for SFT training of large language models is difficult to obtain, resulting in poor performance of large language models.

[0005] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention

[0006] The embodiments of the present application provide a task processing method, a model training method, and a code generation method, so as to at least solve the technical problem that the accuracy of the output results of the text generation task processed by the large language model is low due to the difficulty in obtaining the corpus for training the large language model for a specific industry or field.

[0007] According to one aspect of an embodiment of the present application, a task processing method is provided, including: determining target request information and target prompt information of a target task, wherein the target task is a text generation task of a target type, and the target prompt information is used to describe information required to complete the target task; inputting the target request information and the target prompt information into a first large language model for processing to obtain reply information corresponding to the target task, wherein the first large language model is trained based on extended corpus, the extended corpus is corpus expanded from initial corpus associated with the text generation task of the target type, and the extended corpus includes extended request information, prompt information and extended reply information.

[0008] According to another aspect of an embodiment of the present application, a model training method is provided, comprising: expanding an initial corpus associated with a target type of text generation task to obtain an extended corpus, wherein the extended corpus includes extended request information, prompt information, and extended reply information, the prompt information is used to describe information required to complete the text generation task, and the reply information is reply information corresponding to the text generation task; determining a sample data set based on the extended corpus, wherein a sample data in the sample data set includes an extended request information, a prompt information, and at least one extended reply information; and using the sample data set to train a natural language processing model to obtain a first language model, wherein the natural language processing model is used to process the text generation task.

[0009] According to another aspect of an embodiment of the present application, a code generation method is provided, comprising: determining target request information and target prompt information of a code generation task, wherein the target request information requests generation of a target code that implements a target function, and the target prompt information is used to describe information required to generate the target code; inputting the target request information and the target prompt information into a first large language model for processing to obtain a target code for implementing the target function, wherein the first large language model is trained based on an extended corpus, the extended corpus is a corpus expanded based on an initial corpus, and the extended corpus includes extended request information, prompt information and extended code of the code generation task.

[0010] According to another aspect of an embodiment of the present application, a task processing device is also provided, including: a first determination unit, used to determine target request information and target prompt information of a target task, wherein the target task is a text generation task of a target type, and the target prompt information is used to describe information required to complete the target task; an input unit, used to input the target request information and the target prompt information into a first large language model for processing to obtain reply information corresponding to the target task, wherein the first large language model is trained based on extended corpus, the extended corpus is corpus expanded from initial corpus associated with the text generation task of the target type, and the extended corpus includes extended request information, prompt information and extended reply information.

[0011] According to another aspect of the embodiments of the present application, an electronic device is further provided, including: a memory storing an executable program; and a processor for running the program, wherein the method of each embodiment of the present application is executed when the program is running.

[0012] According to another aspect of an embodiment of the present application, a computer program product is also provided, including a non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method in each embodiment of the present application is implemented.

[0013] In an embodiment of the present application, an initial corpus associated with a text generation task of the target type is expanded as a basis to generate a large amount of extended corpus, and a first language model for processing the text generation task of the target type is trained with the extended corpus, thereby reducing the construction cost and difficulty of obtaining the model training data of the first language model, and increasing the diversity and richness of the model training data. Furthermore, based on the trained first language model, the reply information of the target task of the target type is accurately generated, thereby achieving the purpose of improving the performance of the first language model, thereby achieving the technical effect of improving the accuracy of the output results of the first language model processing the text generation task of the target type, and thereby solving the technical problem of low accuracy of the output results of the text generation task processed by the large language model due to the difficulty in obtaining corpus for training the large language model of a specific industry or field.

[0014] It is easy to notice that the above general description and the following detailed description are only for the purpose of exemplifying and explaining the present application, and do not constitute a limitation of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0015] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0016] Figure 1 It is a hardware structure block diagram of a computer terminal (or mobile device) for implementing a task processing method according to an embodiment of the present application;

[0017] Figure 2 is a structural block diagram of a computing environment according to an embodiment of the present application;

[0018] Figure 3 is a flowchart of a method for processing a task according to an embodiment of the present application;

[0019] Figure 4 is a schematic diagram of a model distillation process according to an embodiment of the present application;

[0020] Figure 5 is a flow chart of a model training method according to an embodiment of the present application;

[0021] Figure 6 is a flow chart of a method for generating a code according to an embodiment of the present application;

[0022] Figure 7 is a flowchart of an optional task processing method according to an embodiment of the present application;

[0023] Figure 8is a schematic diagram of an optional model training method according to an embodiment of the present application;

[0024] Fig. 9 is a schematic diagram of a task processing device according to an embodiment of the present application;

[0025] Fig.10 is a schematic diagram of a training device for a model according to an embodiment of the present application;

[0026] Fig.11 It is a structural block diagram of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION

[0027] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.

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

[0029] First, some nouns or terms that appear in the description of the embodiments of the present application are subject to the following explanations:

[0030] LLM: Large Language Model, a language model based on the Transformer (a deep learning model architecture for natural language processing and machine translation tasks) architecture, whose parameters are usually in the billions to hundreds of billions.

[0031] Distillation: Use a larger model to guide a smaller model to improve training results.

[0032] Nl2Sql: Natural Language to Structured Query Language, converts natural language into structured query statements that can be executed by the database.

[0033] Example 1

[0034] According to an embodiment of the present application, a method for processing a task 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 can be executed in an order different from that shown here.

[0035] The method embodiment provided in Embodiment 1 of the present application can be executed in a mobile terminal, a computer terminal or a similar computing device. Figure 1 1 is a hardware structure block diagram of a computer terminal (or mobile device) for implementing a task processing method according to an embodiment of the present application. Figure 1 As shown, the computer terminal 10 (or mobile device) may include one or more (102a, 102b, ..., 102n are used to illustrate in the figure) processors 102 (the processor 102 may include but is not limited to a processing device such as an MCU (Microcontroller Unit) or an FPGA (Field-Programmable Gate Array), a memory 104 for storing data, and a transmission module 106 for communication functions. In addition, it may also include: a display, an input / output interface (I / O interface), a Universal Serial Bus (USB) port (which may be included as one of the ports of the BUS bus), a network interface, a power supply and / or a camera. Those skilled in the art will understand that Figure 1 The structure shown is only for illustration and does not limit the structure of the above electronic device. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations shown.

[0036] It should be noted that the one or more processors 102 and / or other data processing circuits described above may generally be referred to herein as "data processing circuits". The data processing circuits may be embodied in whole or in part as software, hardware, firmware, or any other combination thereof. In addition, the data processing circuit may be a single independent processing module, or may be incorporated in whole or in part into any of the other components in the computer terminal 10 (or mobile device). As involved in the embodiments of the present application, the data processing circuit acts as a processor control (e.g., selection of a variable resistor terminal path connected to an interface).

[0037] The memory 104 can be used to store software programs and modules of application software, such as program instructions / data storage devices corresponding to the methods in the embodiments of the present application. The processor 102 executes various functional applications and data processing by running the software programs and modules stored in the memory 104, that is, implementing the methods in the above embodiments. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the computer terminal 10 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.

[0038] The transmission device 106 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of the computer terminal 10. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.

[0039] The display may be, for example, a touch screen liquid crystal display (LCD), which may enable a user to interact with a user interface of the computer terminal 10 (or mobile device).

[0040] Figure 1 The hardware structure block diagram shown can be used not only as an exemplary block diagram of the above-mentioned computer terminal 10 (or mobile device), but also as an exemplary block diagram of the above-mentioned server. In an optional embodiment, Figure 2 is a structural block diagram of a computing environment according to an embodiment of the present application, such as Figure 2 As shown, Figure 2The block diagram shows the use of the above Figure 1 The computer terminal 10 (or mobile device) shown is an embodiment of a computing node in a computing environment 201. The computing environment 201 includes multiple (210-1, 210-2, ..., shown in the figure) computing nodes (such as servers) running on a distributed network. The computing nodes all contain local processing and memory resources, and the end user 202 can remotely run applications or store data in the computing environment 201. The application can be provided as multiple services 220-1, 220-2, 220-3 and 220-4 in the computing environment 201, representing services "A", "D", "E" and "H" respectively.

[0041] The end user 202 can provide and access services through a web browser or other software application on the client, and in some embodiments, the end user 202's provision and / or request can be provided to the entry gateway 230. The entry gateway 230 can include a corresponding agent to handle the provision and / or request for the service (one or more services provided in the computing environment 201).

[0042] Services are provided or deployed based on various virtualization technologies supported by the computing environment 201. In some embodiments, services can be provided based on virtual machine (VM)-based virtualization, container-based virtualization, and / or similar methods. Virtual machine-based virtualization can be to simulate a real computer by initializing a virtual machine, and execute programs and applications without directly contacting any actual hardware resources. While the virtual machine virtualizes the machine, according to container-based virtualization, a container can be started to virtualize the entire operating system (OS) so that multiple workloads can run on a single operating system instance.

[0043] In an embodiment based on container virtualization, several containers of a service can be assembled into a Pod (e.g., a Kubernetes Pod). Figure 2 As shown, service 220-2 can be equipped with one or more Pods 240-1, 240-2, ..., 240-N (collectively referred to as Pods). Pods can include a proxy 245 and one or more containers 242-1, 242-2, ..., 242-M (collectively referred to as containers). One or more containers in a Pod process requests related to one or more corresponding functions of the service, and the proxy 245 generally controls network functions related to the service, such as routing, load balancing, etc. Other services can also be equipped with similar Pods.

[0044] During operation, executing a user request from end user 202 may require invoking one or more services in computing environment 201, and executing one or more functions of a service may require invoking one or more functions of another service. Figure 2 As shown, service "A" 220-1 receives a user request from end user 202 from ingress gateway 230, service "A" 220-1 may call service "D" 220-2, and service "D" 220-2 may request service "E" 220-3 to perform one or more functions.

[0045] The computing environment described above can be a cloud computing environment, where the allocation of resources is managed by the cloud service provider, allowing the development of functions without considering the implementation, adjustment or expansion of servers. The computing environment allows developers to execute code in response to events without building or maintaining complex infrastructure. Services can be divided into a set of functions that can be automatically and independently scaled, rather than expanding a single hardware device to handle potential loads.

[0046] In the scenario where a large language model is used to process text generation tasks in a specific industry or field, in order for the large language model to accurately process the text generation task, it is necessary to train the large language model with a large amount of text data from the corresponding industry or field. At the same time, it is necessary to ensure the generalization ability of the large language model so that the large language model can also adapt to text processing tasks in new scenarios or situations.

[0047] In the above operating environment and scenario, this application provides the following Figure 3 The processing method of the task shown. Figure 3 is a flowchart of a method for processing a task according to an embodiment of the present application, such as Figure 3 As shown, the method includes:

[0048] Step S302, determining target request information and target prompt information of the target task, wherein the target task is a text generation task of a target type, and the target prompt information is used to describe information required to complete the target task.

[0049] Exemplarily, the target task may be a language template generation task, a machine translation task, a dialogue generation task, a summary generation task, a code generation task, etc. The target request information is a type of input information input into the large language model, and is used to make a request to the large language model to process the target task. The target prompt information is also a type of input information input into the large language model, and is used to describe the background of the target task.

[0050] In an optional embodiment, the target task may be a task for generating SQL statements, the target request information and the target prompt information are input information that the user needs to input into the large language model to obtain the SQL statement, and the target request information may be a query, wherein in the NL2SQL scenario, a query refers to a request for a database operation expressed in natural language. The target prompt information may be recall information, which is a background description of the query, and is used to describe the information required to generate the SQL statement. The recall information may include tables, fields, field values, associations between data tables, industry terms, etc.

[0051] Step S304, input the target request information and the target prompt information into the first language model for processing to obtain reply information corresponding to the target task, wherein the first language model is trained based on extended corpus, and the extended corpus is a corpus expanded from the initial corpus associated with the text generation task of the target type, and the extended corpus includes extended request information, prompt information and extended reply information.

[0052] Among them, the first language model can be a model obtained by training a natural language processing model, and the natural language processing model is trained using extended corpus.

[0053] After the first language model is trained, the first language model is used to process the input target request information and target prompt information, so that more accurate response information corresponding to the target task can be obtained, that is, the SQL statement used to achieve the target task. For example, the target task is to generate an SQL statement for finding products, the target request information is "Please generate an SQL statement to find all products with a price lower than 100 yuan", and the target prompt information is "product table (number, product name, price)". After the target request information and target prompt information are input into the first language model trained by the extended corpus and the preset data structure, the first language model outputs the SQL statement: "SELECT * FROM product table WHERE price < 100".

[0054] In an embodiment of the present application, an initial corpus associated with a text generation task of the target type is expanded as a basis to generate a large amount of extended corpus, and a first language model for processing the text generation task of the target type is trained with the extended corpus, thereby reducing the construction cost and difficulty of obtaining the model training data of the first language model, and increasing the diversity and richness of the model training data. Furthermore, based on the trained first language model, the reply information of the target task of the target type is accurately generated, thereby achieving the purpose of improving the performance of the first language model, thereby achieving the technical effect of improving the accuracy of the output results of the first language model processing the text generation task of the target type, and thereby solving the technical problem of low accuracy of the output results of the text generation task processed by the large language model due to the difficulty in obtaining corpus for training the large language model of a specific industry or field.

[0055] Since the performance of large language models in general fields in processing text generation tasks is poor, this embodiment trains a natural language processing model by extending the corpus and preset data structure to obtain a first large language model with better performance in processing text generation tasks. Optionally, in the task processing method of the embodiment of the present invention, the first large language model is obtained by: determining initial request information and prompt information of different tasks of the target type, and generating extended request information based on the initial request information and prompt information; inputting the extended request information and prompt information into different large language models for processing to obtain a candidate reply information set, and determining the extended reply information based on the candidate reply information set; training a natural language processing model based on the extended request information, prompt information, and extended reply information to obtain the first large language model, wherein the natural language processing model is used to process the text generation task.

[0056] Among them, different tasks of the target type can generate tasks for different SQL statements, for example, generate SQL query statements, SQL insert statements, SQL update statements and SQL delete statements suitable for a specific database structure, etc. A small amount of initial request information and prompt information is written through an engineering construction method or a code script construction method. The initial request information can be used to request the generation of an SQL query statement for querying a certain field. The initial request information and prompt information are input into the third language model, and the request information for generating related extended request information based on the initial request information and prompt information is given, so that the third language model outputs the extended request information. It should be noted that the third language model can be a large language model for a general field, and the third language model can be the same as the second language model or different from the second language model.

[0057] After obtaining the extended request information, multiple reply information is generated based on the extended request information and prompt information using multiple different large language models to obtain a set of candidate reply information. The large language model here can be a pre-trained model of various types such as a proprietary field or a general field. These different large language models can generate SQL statements as responses to natural language queries during the processing of the NL2SQL task. For each request information, after being input into different large language models, at least one SQL statement for each request information will be obtained. For example, the request information "find all products with a price higher than 100 yuan" and the prompt information "product table (number, product name, price)" are input into different large language models such as large language model a, large language model b, and large language model c, and multiple SQL statements output by each large language model are obtained. These SQL statements may be different in structure and logic, but they are all used to implement the SQL statement generation task indicated by the request information.

[0058] After obtaining the candidate reply information set, this embodiment screens out the extended reply information from the candidate reply information set by a rejection sampling method, including steps such as data deduplication, data verification and sorting, through which the extended reply information that is more suitable for the text generation task is screened out from the candidate reply information set.

[0059] After the extended corpus is determined, the extended corpus is used as a training sample for training a natural language processing model. The natural language processing model may be a recurrent neural network model or a Transformer model. The natural language processing model is trained with the extended corpus, and finally the first largest language model is trained.

[0060] This embodiment trains a natural language processing model by expanding the corpus to obtain the first largest language model. By expanding the corpus, the construction cost of the model training samples is reduced and the performance of the model is improved.

[0061] In order to expand the training samples of the large language model, extended request information can be generated through the large language model of the general field and the initial request information and prompt information. Optionally, in the task processing method of the embodiment of the present invention, generating the extended request information according to the initial request information and the prompt information includes: generating an extended task for extending the request information, and determining the request information and the prompt information of the extended task, wherein the request information of the extended task is used to request to generate the extended request information according to the initial request information and the prompt information, and the prompt information of the extended task includes the initial request information and the prompt information; the request information and the prompt information of the extended task are input into the pre-trained third large language model of the general field for processing to obtain the extended request information.

[0062] Exemplarily, the extended task may be a task for generating request information for SQL statements, and the third language model may be a large language model for a general domain, and the third language model generates new and different request information based on the prompt information of the extended task and the initial request information. By utilizing the ICL (In-Context Learning) capability of the third language model and providing the third language model with request information examples, the third language model can generate new extended request information, thereby expanding the model training data set.

[0063] For example, the initial request information is "Find all products with prices lower than 100 yuan", the prompt information is "Product table (number, product name, price)", and the request information of the extended task is "Please generate other extended request information similar to the above initial request information". After the initial request information, prompt information and extended task request information are input into the third language model, the third language model outputs extended request information including "Find all products with prices higher than 100 yuan", "Find all products with prices lower than 50 yuan", etc.

[0064] This embodiment generates a series of new and extended request information through the contextual learning ability of the third language model. Then, these newly generated extended request information are reassembled with the original recall information to form an extended corpus for training the first language model. This reduces the construction cost and acquisition difficulty of training data, increases the diversity and richness of training data, and lays the foundation for subsequent model training and optimization.

[0065] The candidate reply information set is used to determine the extended reply information, thereby constituting a part of the extended corpus for training the first language model. There is a large amount of repeated information in the candidate reply information set, and the redundant reply information needs to be deduplicated. Optionally, in the task processing method of an embodiment of the present invention, determining the extended reply information based on the candidate reply information set includes: deduplicating the semantically identical reply information in the candidate reply information set to obtain the deduplicated candidate reply information set; and determining the extended reply information based on the deduplicated candidate reply information set.

[0066] For example, for the same set of extended request information and prompt information input into the large language model, different large language models may generate multiple similar or identical SQL statements. Since a large amount of repeated extended corpus is used to train the natural language processing model, the generalization of the first large language model will deteriorate. In order to improve the diversity of the extended corpus, it is necessary to remove duplicates from these repeated statements.

[0067] In the process of deduplicating the candidate reply information set, this embodiment first performs preliminary standardization on the SQL statements (unification of uppercase and lowercase letters, processing of line breaks) to ensure the consistency of the statement format. For a group of SQL statements with high similarity, one verified SQL statement is retained and the remaining duplicate SQL statements are deleted.

[0068] This embodiment improves the quality of the extended corpus by removing duplicates from the candidate reply information set, avoids the model's over-reliance on certain types of sentences during training, which leads to a decrease in generalization ability, and thus lays a foundation for optimizing the performance of the first language model.

[0069] In order to ensure the accuracy of sample data for training large language models, it is also necessary to filter out erroneous information in the candidate reply information set. Optionally, in the task processing method of an embodiment of the present invention, before deduplicating semantically identical reply information in the candidate reply information set, the method also includes: filtering erroneous reply information in the candidate reply information set to obtain a filtered candidate reply information set; deduplicating semantically identical reply information in the candidate reply information set includes: deduplicating semantically identical reply information in the filtered candidate reply information set.

[0070] For example, since a large number of extended reply messages are generated by the third language model, and there is no manually verified standard answer as a reference for verification, some reply messages may have grammatical errors, resulting in inability to be used when training the model, wherein the erroneous reply messages may be reply messages with incorrect characters or incorrect values. The reply messages with errors in the candidate reply message set can be filtered to ensure the accuracy of the extended reply messages.

[0071] In this embodiment, the target type of text processing task can be a SQL statement generation task, and the reply information with errors can be a SQL statement that cannot be executed in the database. The candidate reply information set may contain some inappropriate or incorrect SQL statements. First, the SQL statements in the candidate reply information set are parsed and extracted, and then the execution is checked on the corresponding database. The SQL statements that cannot be executed due to syntax errors are filtered, and the accuracy of the SQL statements is ensured by filtering out all SQL statements that cannot be correctly executed in the database.

[0072] This embodiment ensures the accuracy of the extended reply information by filtering out erroneous reply information in the candidate reply information set, thereby ensuring the availability of the extended reservation, so that the performance of the first language model trained based on the extended corpus is better.

[0073] After database verification and deduplication processing are performed on the candidate reply information set, the reply information obtained has different levels of accuracy. When the size of the reply information obtained is large, the reply information with higher accuracy can be further selected therefrom. Optionally, in the task processing method of the embodiment of the present invention, determining the extended reply information based on the deduplicated candidate reply information set includes: inputting the reply information in the deduplicated candidate reply information set into a sorting model to obtain a sorting result, wherein the sorting model at least sorts the reply information in descending order according to the accuracy of the reply information; and determining a preset number of reply information at the front of the sorting result as the extended reply information.

[0074] Exemplarily, a sorting model is used to sort multiple reply messages generated by the same set of extended request information and prompt information. The sorting model can sort according to the accuracy of the reply information, and the accuracy can be determined based on the similarity between the extended request information and prompt information and the reply information. Since some reply information is not accurate enough, using this part of data to train the model will also lead to a decrease in model performance. After sorting the reply information, this embodiment removes some reply information at the back of the order, and determines a preset number of reply information at the front of the sorting result as the extended reply information required for the training model.

[0075] It should be noted that the sorting model can also sort the reply information based on factors such as the complexity of the SQL statement, execution efficiency, and the degree of matching with the extended request information and prompt information, and determine the appropriate reply information from the sorting results. This embodiment does not limit the indicator parameters used by the sorting model when sorting.

[0076] This embodiment uses a sorting model to eliminate some reply information that is in the later order, which helps to expand the overall quality of the corpus and ensures that the first language model is trained with accurate extended corpus, thereby improving the accuracy of the first language model in processing text generation tasks.

[0077] Since the sample information will affect the reply information generated by the model and make the reply information similar to the sample information, when expanding the reply information, in order to generate diversified reply information, it is necessary to remove the sample information. Optionally, in the task processing method of an embodiment of the present invention, inputting the extended request information and prompt information into different large language models includes: removing the sample information in the prompt information, and inputting the extended request information and the prompt information with the sample information removed into different large language models.

[0078] For example, after obtaining the extended request information, different large language models are used to generate reply information. A large language model can be called multiple times to generate multiple SQL statements for a request information. The generation results of many large language models may have low randomness, that is, they tend to generate similar SQL statements, thereby limiting the richness of the generated results. If the prompt information contains ICL (Interactive Common Lisp, an interactive interpreter based on CommonLisp) examples, the model may rely too much on these examples when generating reply information, thereby limiting the creativity of the model.

[0079] In this embodiment, when generating reply information through different large language models, thereby expanding the corpus for training the first large language model, by removing the sample information in the prompt information, the large language model is no longer constrained by specific samples when generating reply information, so that the model generates more diverse and richer reply information, thereby enriching the corpus for training the first large language model.

[0080] It should be noted that after removing the ICL samples, the present embodiment may also prompt the model in the prompt information to add explanatory or descriptive text when outputting the reply information. For example, the prompt model may add a brief description before the generated SQL statement to explain the function of the generated SQL statement, so that the generated reply information not only provides the SQL statement, but also provides the context and intention of the statement. When the first language model is trained based on training data composed of such reply information, it helps to improve the performance of the first language model.

[0081] It should be noted that in addition to the difficulty in obtaining the high-quality corpus required for SFT training of large language models, large language models trained with SFT are prone to overfitting, which reduces the general performance and cross-domain generalization of large language models. When faced with data that is not in the training data, the performance of the large language model trained with SFT may be worse than that of the basic large language model.

[0082] In order to improve the generalization ability of the first largest language model, the first largest language model is trained by learning the probability distribution information of the tokens of the second largest language model. Optionally, in the task processing method of the embodiment of the present invention, the natural language processing model is trained according to the extended request information, the prompt information, and the extended reply information to obtain the first largest language model, including: obtaining a preset data structure of the tokens of the second largest language model of the pre-trained general field, wherein the preset data structure represents the semantic processing ability of the second largest language model; determining a sample data set according to the extended request information, the prompt information and the extended reply information, wherein a sample data in the sample data set includes an extended request information, a prompt information and at least one extended reply information; and using the sample data set and the preset data structure to train the natural language processing model to obtain the first largest language model.

[0083] Among them, the second largest language model can be a model suitable for text generation tasks in different fields. The second largest language model is trained using large-scale data sets in different fields and has good generalization in text generation tasks. The preset data structure can be the probability distribution of tokens (tokens are the smallest unit for segmenting and encoding input text, which can be words, subwords, characters or other forms of text fragments) generated by the second largest language model during the training process. The probability distribution information of the token refers to the probability of the second largest language model predicting the next possible output token for each input token. In the scenario of generating SQL statements through a large language model, the probability distribution of the tokens of the second largest language model reflects the model's judgment and understanding of how to convert natural language into SQL statements, that is, the second largest language model gives the probability of each word or phrase in a natural language request information being converted into a part of an SQL statement. For example, for a certain word in a natural language query, the second largest language model will give a probability distribution, indicating the possibility of different SQL keywords or grammatical structures appearing after the word.

[0084] Directly training a natural language processing model with an extended corpus may lead to overfitting, that is, the accuracy of the reply information output by the model on the training data is high, but the accuracy of the reply information output on the newly input data decreases. This embodiment uses a model distillation method to enable the natural language processing model to learn the probability of the token of the second largest language model. Figure 4 is a schematic diagram of a model distillation process according to an embodiment of the present application, such as Figure 4As shown, the second largest language model is used as the teacher model, the natural language processing model is used as the student model, and the natural language processing model learns the token probability distribution of the second largest language model in the following way: the natural language processing model is trained with a sample data set to learn the probability distribution information of the token, and the distillation loss is minimized as the learning goal. Among them, the distillation loss is calculated by the distillation loss function, and the distillation loss function can be Kullback-Leibler Divergence (KL divergence), which is used to measure the difference between the probability distribution predicted by the natural language processing model and the probability distribution given by the second largest language model.

[0085] This embodiment uses the model distillation method to enable the natural language processing model to learn the probability of the token of the second largest language model, avoiding the overfitting problem that may be caused by learning directly from the training data, and enhancing the ability of the first largest language model to process new data, that is, enhancing the generalization ability of the first largest language model.

[0086] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described order of actions, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present application.

[0087] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, disk, CD), and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in each embodiment of the present application.

[0088] Example 2

[0089] According to an embodiment of the present application, a model training method is also provided. Figure 5 is a flow chart of a model training method according to an embodiment of the present application, such as Figure 5 As shown, the method includes:

[0090] Step S502, expand the initial corpus associated with the target type of text generation task to obtain an extended corpus, wherein the extended corpus includes extended request information, prompt information and extended reply information, the prompt information is used to describe the information required to complete the text generation task, and the reply information is the reply information corresponding to the text generation task.

[0091] Exemplarily, the target type of text generation task can be a SQL statement generation task, and the initial request information and prompt information of different target type SQL statement generation tasks are obtained to obtain the initial corpus. For example, a small amount of initial request information and prompt information is written through engineering construction or code script construction. Then, a large amount of extended corpus is expanded based on the small amount of initial corpus. For example, the initial corpus can be expanded based on a large language model in a general field to obtain an extended corpus.

[0092] Step S504: determining a sample data set according to the extended corpus, wherein a sample data in the sample data set includes an extended request message, a prompt message and at least one extended reply message.

[0093] The sample data set may be a data set containing multiple sample data, and the sample data may be obtained from an extended corpus. Each sample data may contain an extended request message, a prompt message corresponding to the request message, and at least one extended reply message corresponding to the extended request message. The request message may be a request for a database operation expressed in a natural language, the prompt message may include tables, fields, field values, associations between data tables, industry terms, etc., and the reply message may be an SQL statement.

[0094] Step S506, using the sample data set to train a natural language processing model to obtain a first language model, wherein the natural language processing model is used to process the text generation task.

[0095] Exemplarily, the natural language processing model may be a recurrent neural network model or a Transformer model. After obtaining the sample data set, the natural language processing model is trained based on the sample data set to obtain a trained first language model.

[0096] In an embodiment of the present application, an initial corpus associated with a target type of text generation task is expanded as a basis to generate a large amount of extended corpus. The first large language model used to process the target type of text generation task is trained with the extended corpus, thereby reducing the construction cost and difficulty of obtaining the model training data of the first large language model, increasing the diversity and richness of the model training data, and thereby achieving the purpose of improving the performance of the first large language model, thereby solving the technical problem that the corpus for training a large language model in a specific industry or field is difficult to obtain, resulting in poor performance of the large language model.

[0097] The initial corpus associated with the target type of text generation task is expanded to obtain the extended corpus, including: determining the initial request information and prompt information of different text generation tasks of the target type, and generating extended request information according to the initial request information and prompt information; inputting the extended request information and prompt information into different large language models for processing to obtain a candidate reply information set, and determining the extended reply information according to the candidate reply information set; determining a sample data set according to the extended request information, the prompt information and the extended reply information, wherein a sample data in the sample data set includes an extended request information, a prompt information and at least one extended reply information.

[0098] Among them, different tasks of the target type can generate tasks for different SQL statements, for example, generate SQL query statements, SQL insert statements, SQL update statements and SQL delete statements suitable for a specific database structure, etc. A small amount of initial request information and prompt information is written through an engineering construction method or a code script construction method. The initial request information can be used to request the generation of an SQL query statement for querying a certain field. The initial request information and prompt information are input into the third language model, and the request information for generating related extended request information based on the initial request information and prompt information is given, so that the third language model outputs the extended request information. It should be noted that the third language model can be a large language model for a general field, and the third language model can be the same as the second language model or different from the second language model.

[0099] After obtaining the extended request information, multiple reply information is generated based on the extended request information and prompt information using multiple different large language models to obtain a set of candidate reply information. The large language model here can be a pre-trained model of various types such as a proprietary field or a general field. These different large language models can generate SQL statements as responses to natural language queries during the processing of the NL2SQL task. For each request information, after being input into different large language models, at least one SQL statement for each request information will be obtained. For example, the request information "find all products with a price higher than 100 yuan" and the prompt information "product table (number, product name, price)" are input into different large language models such as large language model a, large language model b, and large language model c, and multiple SQL statements output by each large language model are obtained. These SQL statements may be different in structure and logic, but they are all used to implement the SQL statement generation task indicated by the request information.

[0100] After obtaining the candidate reply information set, this embodiment screens out the extended reply information from the candidate reply information set by a rejection sampling method. This includes steps such as data deduplication, data verification and sorting, through which extended reply information that is more suitable for the text generation task is screened out from the candidate reply information set. The sample data set is determined based on the extended request information, prompt information and extended reply information, which reduces the construction cost and acquisition difficulty of the training data, increases the diversity and richness of the training data, and lays the foundation for subsequent model training and optimization.

[0101] It should be noted that in addition to the difficulty in obtaining the high-quality corpus required for SFT training of large language models, large language models trained with SFT are prone to overfitting, which reduces the general performance and cross-domain generalization of large language models. When faced with data that is not in the training data, the performance of the large language model trained with SFT may be worse than that of the basic large language model.

[0102] In order to improve the generalization ability of the model, optionally, in the training method of the model of an embodiment of the present invention, using a sample data set to train a natural language processing model includes obtaining a preset data structure of a pre-trained second largest language model in a general field, wherein the preset data structure represents the semantic processing capability of the second largest language model; and using the sample data set and the preset data structure to train the natural language processing model.

[0103] Among them, the second largest language model can be a model suitable for text generation tasks in different fields. The second largest language model is trained using large-scale data sets in different fields and has good generalization in text generation tasks. The preset data structure can be the distribution probability of the token (the smallest unit for segmenting and encoding input text, which can be a word, subword, character or other form of text fragment) of the second largest language model. The natural language model is trained by the extended corpus and the preset data structure, and finally the first largest language model is trained.

[0104] This embodiment helps the first language model to better capture language features and rules by learning the preset data structure of the second language model during the training of the first language model, so that the first language model can more accurately infer and generate text, thereby improving the generalization performance of the first language model and avoiding the overfitting problem of the model.

[0105] Example 3

[0106] According to an embodiment of the present application, a method for generating a code is also provided. Figure 6 is a flow chart of a method for generating a code according to an embodiment of the present application, such as Figure 6 As shown, the method includes:

[0107] Step S602, determining target request information and target prompt information of the code generation task, wherein the target request information requests the generation of target code to implement the target function, and the target prompt information is used to describe the information required to generate the target code;

[0108] Exemplarily, the code generation task may be a SQL statement generation task, and the target function may be to generate a SQL statement under a certain condition, for example, a SQL query statement for querying data in a certain database. The target code may be a SQL statement, and the target request information may be a query, wherein in the NL2SQL scenario, a query refers to a request for a database operation expressed in natural language. The target prompt information may be recall information, which is a background description of the query, used to describe the information required to generate the SQL statement. The recall information may include tables, fields, field values, associations between data tables, industry terms, etc.

[0109] Step S604, input the target request information and the target prompt information into the first language model for processing to obtain the target code for realizing the target function, wherein the first language model is trained based on the extended corpus, the extended corpus is the corpus expanded based on the initial corpus, and the extended corpus includes the extended request information, prompt information and extended code of the code generation task.

[0110] Among them, the first language model can be a model obtained by training a natural language processing model, and the natural language processing model is trained using extended corpus.

[0111] After the first language model is trained, the first language model is used to process the input target request information and target prompt information, so that more accurate response information corresponding to the target function can be obtained, that is, the SQL statement used to implement the target function. For example, the target function is to generate an SQL statement for finding products, the target request information is "Please generate an SQL statement for finding all products priced below 100 yuan", and the target prompt information is "Product table (number, product name, price)". After the target request information and target prompt information are input into the first language model trained by the extended corpus and the preset data structure, the first language model outputs the SQL statement: "SELECT * FROM product table WHERE price < 100".

[0112] In an embodiment of the present application, an initial corpus associated with a code generation task is expanded as a basis to generate a large amount of extended corpus. The first large language model used to process the code generation task is trained with the extended corpus, thereby reducing the construction cost and difficulty of obtaining model training data for the first large language model, and increasing the diversity and richness of the model training data. The reply information of the target task of the target type is accurately generated based on the trained first large language model, thereby achieving the purpose of improving the performance of the first large language model, thereby achieving the technical effect of improving the accuracy of the output results of the first large language model processing the code generation task, and thereby solving the technical problem of low accuracy of the output results of the text generation task processed by the large language model due to the difficulty in obtaining corpus for training the large language model in a specific industry or field.

[0113] In addition, it should be noted that in order to improve the generalization ability of the model, the present embodiment can use the model distillation method to enable the natural language processing model to learn the preset data structure of the second largest language model in the general field, wherein the second largest language model can be a model suitable for text generation tasks in different fields, and the second largest language model is trained using large-scale data sets in different fields, and has good generalization in text generation tasks, and the preset data structure can be the probability distribution of the token (the smallest unit for segmenting and encoding the input text, which can be a word, subword, character or other form of text fragment) generated by the second largest language model during the training process. In the process of training the first largest language model, the preset data structure of the second largest language model is learned to help the first largest language model better capture language features and rules, so that the first largest language model can more accurately infer and generate text, improve the generalization performance of the first largest language model, avoid the problem of overfitting of the model, and thus improve the code generation ability of the first largest language model.

[0114] Example 4

[0115] According to an embodiment of the present application, an optional task processing method is also provided. Figure 7 is a flowchart of an optional task processing method according to an embodiment of the present application, such as Figure 7 As shown, the method includes:

[0116] Step S702, the cloud server receives target request information and target prompt information of the target task sent by the client, wherein the target task is a text generation task of a target type, and the target prompt information is used to describe information required to complete the target task;

[0117] Exemplarily, the client may be a large language model software product installed on a terminal device, and a first large language model is deployed on a cloud server. The target task may be a language template generation task, a machine translation task, a dialogue generation task, a summary generation task, and a code generation task, etc. The target request information is a type of input information input into the large language model, and is used to make a request to the large language model to process the target task. The target prompt information is also a type of input information input into the large language model, and is used to describe the background of the target task.

[0118] In an optional embodiment, the target task may be a task for generating SQL statements, the target request information and the target prompt information are input information that the user needs to input into the large language model to obtain the SQL statement, and the target request information may be a query, wherein in the NL2SQL scenario, a query refers to a request for a database operation expressed in natural language. The target prompt information may be recall information, which is a background description of the query, and is used to describe the information required to generate the SQL statement. The recall information may include tables, fields, field values, associations between data tables, industry terms, etc.

[0119] Step S704: the cloud server processes the target request information and the target prompt information through the first language model to obtain reply information corresponding to the target task, wherein the first language model is trained based on the extended corpus, the extended corpus is a corpus obtained by expanding the initial corpus associated with the text generation task of the target type, and the extended corpus includes extended request information, prompt information, and extended reply information;

[0120] Among them, the first language model can be a model obtained by training a natural language processing model, and the natural language processing model is trained using extended corpus.

[0121] After the first language model is trained, the first language model is used to process the input target request information and target prompt information, so as to obtain more accurate response information corresponding to the target task, that is, the SQL statement used to implement the target task.

[0122] Step S706: The cloud server sends the reply information corresponding to the target task to the client.

[0123] Exemplarily, after the reply information is obtained, the reply information corresponding to the target task is sent to the client through the cloud server, so that the user can obtain the reply information of the first language model from the client.

[0124] In an embodiment of the present application, an initial corpus associated with a text generation task of the target type is expanded as a basis to generate a large amount of extended corpus, and a first language model for processing the text generation task of the target type is trained with the extended corpus, thereby reducing the construction cost and difficulty of obtaining the model training data of the first language model, increasing the diversity and richness of the model training data, and accurately generating reply information of the target task of the target type based on the trained first language model, thereby achieving the purpose of improving the performance of the first language model, thereby achieving the technical effect of improving the accuracy of the output results of the first language model processing the text generation task of the target type, and thereby solving the technical problem of low accuracy of the output results of the text generation task processed by the large language model due to the difficulty in obtaining corpus for training the large language model of a specific industry or field.

[0125] In addition, it should be noted that in order to improve the generalization ability of the model, the present embodiment can use the model distillation method to enable the natural language processing model to learn the preset data structure of the second largest language model in the general field, wherein the second largest language model can be a model suitable for text generation tasks in different fields, and the second largest language model is trained using large-scale data sets in different fields, and has good generalization in text generation tasks, and the preset data structure can be the probability distribution of tokens (the smallest unit for segmenting and encoding input text, which can be words, subwords, characters or other forms of text fragments) generated by the second largest language model during the training process. In the process of training the first largest language model, the preset data structure of the second largest language model is learned to help the first largest language model better capture language features and rules, so that the first largest language model can more accurately infer and generate text, improve the generalization performance of the first largest language model, avoid the problem of overfitting of the model, and thus improve the text generation task processing ability of the first largest language model.

[0126] Example 5

[0127] According to an embodiment of the present application, an optional model training method is also provided. Figure 8 is a schematic diagram of an optional model training method according to an embodiment of the present application, such as Figure 8 As shown, the method includes:

[0128] Input the table structure field information and the initial query into the large model to generate full generated data. The full generated data is executed in the database to obtain executable generated data. The executable generated data is deduplicated and rejected for sampling to obtain the final training data. The natural language processing model is trained based on the final training data, and the natural language processing model is distilled to obtain the trained first large language model.

[0129] Exemplarily, the table structure field information is also the prompt information in Example 1, and the initial query is also the initial request information in Example 1. The table structure field information and the initial query are input into the third largest language model to obtain the extended request information, and the extended request information is input into different large language models to obtain a candidate reply information set. The extended request information and the candidate reply information set are also the full generated data. The candidate reply information set is verified in the database, and the unexecutable reply information is filtered out to obtain the executable generated data. Then, the executable generated data is deduplicated and other rejection sampling processes are performed to obtain the extended reply information. The final training data is composed of the extended request information, the prompt information and the extended reply information. The second largest language model in Example 1 is used as the teacher model, and the natural language processing model is used as the student model for model distillation. The natural language processing model is trained with the final training data to learn the distribution probability of the token of the second largest language model to obtain the trained first largest language model.

[0130] The model training method of this embodiment reduces the construction cost of the model training samples by expanding the corpus, avoids the overfitting problem of the model through model distillation, and improves the generalization ability of the trained large language model.

[0131] Example 6

[0132] According to an embodiment of the present application, a device for implementing the processing method of the above task is also provided. Fig. 9 is a schematic diagram of a task processing device according to an embodiment of the present application, such as Fig. 9 As shown, the device comprises:

[0133] A first determining unit 901 is used to determine target request information and target prompt information of a target task, wherein the target task is a text generation task of a target type, and the target prompt information is used to describe information required to complete the target task;

[0134] Input unit 902 is used to input the target request information and the target prompt information into the first language model for processing to obtain reply information corresponding to the target task, wherein the first language model is trained based on extended corpus, and the extended corpus is a corpus expanded from the initial corpus associated with the text generation task of the target type, and the extended corpus includes extended request information, prompt information and extended reply information.

[0135] Optionally, in the task processing device of the embodiment of the present invention, the device also includes: a second determination unit, used to determine the initial request information and prompt information of different tasks of the target type, and generate extended request information based on the initial request information and prompt information; a processing unit, used to input the extended request information and prompt information into different large language models for processing to obtain a set of candidate reply information, and determine the extended reply information based on the candidate reply information set; a training unit, used to train a natural language processing model based on the extended request information, prompt information, and extended reply information to obtain a first large language model, wherein the natural language processing model is used to process text generation tasks.

[0136] Optionally, in the task processing device of the embodiment of the present invention, the second determination unit includes: a generation module, used to generate an extended task for extending request information, and determine the request information and prompt information of the extended task, wherein the request information of the extended task is used to request to generate extended request information according to the initial request information and the prompt information, and the prompt information of the extended task includes the initial request information and the prompt information; an input module, used to input the request information and the prompt information of the extended task into a pre-trained third language model of the general field for processing to obtain the extended request information.

[0137] Optionally, in the task processing device of the embodiment of the present invention, the processing unit includes: a deduplication module, used to deduplicate reply information with the same semantics in the candidate reply information set to obtain a deduplicated candidate reply information set; a first determination module, used to determine the extended reply information based on the deduplicated candidate reply information set.

[0138] Optionally, in the task processing device of the embodiment of the present invention, the processing unit also includes: a filtering module, used to filter out erroneous reply information in the candidate reply information set to obtain a filtered candidate reply information set; the deduplication module includes: a deduplication sub-module, used to deduplicate reply information with the same semantics in the filtered candidate reply information set.

[0139] Optionally, in the task processing device of the embodiment of the present invention, the first determination module includes: an input sub-module, used to input the reply information in the candidate reply information set after deduplication into the sorting model to obtain a sorting result, wherein the sorting model sorts the reply information in descending order at least according to the accuracy of the reply information; a determination sub-module, used to determine a preset number of reply information located at the front column of the sorting result as extended reply information.

[0140] Optionally, in the task processing device of the embodiment of the present invention, the processing unit includes: a removal module, which is used to remove the sample information in the prompt information, and input the extended request information and the prompt information for removing the sample information into different large language models.

[0141] Optionally, in the task processing device of the embodiment of the present invention, the training unit includes: an acquisition module, which is used to obtain a preset data structure of tokens of a pre-trained second largest language model in a general field, wherein the preset data structure represents the semantic processing capability of the second largest language model; a second determination module, which is used to determine a sample data set based on extended request information, prompt information and extended reply information, wherein a sample data in the sample data set includes an extended request information, a prompt information and at least one extended reply information; a training module, which is used to train a natural language processing model using the sample data set and the preset data structure to obtain the first largest language model.

[0142] It should be noted here that the above-mentioned first determination unit 901 and input unit 902 correspond to steps S402 to S404 in Example 1, and the two modules and the corresponding steps implement the same instances and application scenarios, but are not limited to the contents disclosed in the above-mentioned Example 1.

[0143] It should be noted that the above-mentioned modules or units may be hardware components or software components stored in a memory (e.g., memory 104) and processed by one or more processors (e.g., processors 102a, 102b, ..., 102n), and the above-mentioned modules may also be run as part of the device in the computer terminal 10 provided in Example 1.

[0144] It should be noted that the preferred implementation scheme involved in the above embodiments of the present application is the same as the scheme provided in Example 1, as well as the application scenario and implementation process, but is not limited to the scheme provided in Example 1.

[0145] Example 7

[0146] According to an embodiment of the present application, a device for implementing the training method of the above model is also provided. Fig.10 is a schematic diagram of a training device for a model according to an embodiment of the present application, such as Fig.10 As shown, the device comprises:

[0147] An expansion unit 1001 is used to expand the initial corpus associated with the target type of text generation task to obtain an expanded corpus, wherein the expanded corpus includes expanded request information, prompt information and expanded reply information, the prompt information is used to describe the information required to complete the text generation task, and the reply information is the reply information corresponding to the text generation task;

[0148] The sample determination unit 1002 is used to determine a sample data set according to the extended corpus, wherein a sample data in the sample data set includes an extended request message, a prompt message and at least one extended reply message;

[0149] The model training unit 1003 is used to train a natural language processing model using a sample data set to obtain a first language model, wherein the natural language processing model is used to process a text generation task.

[0150] Optionally, in the training device of the model of the embodiment of the present invention, the extension unit 1001 includes: a request information determination module, which is used to determine the initial request information and prompt information of different text generation tasks of the target type, and generate extended request information based on the initial request information and the prompt information; a reply information determination module, which is used to input the extended request information and the prompt information into different large language models for processing to obtain a candidate reply information set, and determine the extended reply information based on the candidate reply information set; a sample determination module, which is used to determine a sample data set based on the extended request information, the prompt information and the extended reply information, wherein a sample data in the sample data set includes an extended request information, a prompt information and at least one extended reply information.

[0151] Optionally, in the model training device of the embodiment of the present invention, the model training unit 1003 includes: a data structure acquisition module, used to obtain a preset data structure of a pre-trained second largest language model in a general field, wherein the preset data structure represents the semantic processing capability of the second largest language model; and a model training module, used to train a natural language processing model using the sample data set and the preset data structure.

[0152] It should be noted here that the above-mentioned expansion unit 1001, sample determination unit 1002 and model training unit 1003 correspond to steps S502 to S506 in Example 2, and the two modules and the corresponding steps implement the same instances and application scenarios, but are not limited to the contents disclosed in the above-mentioned Example 2.

[0153] Example 8

[0154] The embodiment of the present application may provide an electronic device, which may be any electronic device in a group of electronic devices. Optionally, in this embodiment, the electronic device may also be replaced by a terminal device such as a mobile terminal.

[0155] Optionally, in this embodiment, the electronic device may be located in at least one network device among a plurality of network devices of a computer network.

[0156] In this embodiment, the computer terminal can execute the program code in the method.

[0157] Optionally, Fig.11 is a structural block diagram of an electronic device according to an embodiment of the present application. Fig.11As shown, the electronic device A may include: one or more ( Fig.11 (only one is shown) processor 102, memory 104, storage controller, and peripheral interface, wherein the peripheral interface is connected to the radio frequency module, audio module and display.

[0158] Among them, the memory can be used to store software programs and modules, such as program instructions / modules corresponding to the methods and devices in the embodiments of the present application. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory, that is, implementing the methods in the above embodiments. The memory may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory may further include a memory remotely arranged relative to the processor, and these remote memories may be connected to the terminal A 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.

[0159] The processor can call the information and application stored in the memory through the transmission device to perform the following steps: determine the target request information and target prompt information of the target task, wherein the target task is a text generation task of the target type, and the target prompt information is used to describe the information required to complete the target task; input the target request information and the target prompt information into the first largest language model for processing to obtain reply information corresponding to the target task, wherein the first largest language model is trained based on extended corpus, and the extended corpus is a corpus obtained by expanding the initial corpus associated with the text generation task of the target type, and the extended corpus includes extended request information, prompt information and extended reply information.

[0160] Optionally, the processor may also execute program code for the following steps: determining initial request information and prompt information for different tasks of the target type, and generating extended request information based on the initial request information and prompt information; inputting the extended request information and prompt information into different large language models for processing to obtain a set of candidate reply information, and determining extended reply information based on the set of candidate reply information; training a natural language processing model based on the extended request information, prompt information, and extended reply information to obtain a first large language model, wherein the natural language processing model is used to process text generation tasks.

[0161] By adopting the embodiment of the present application, a scheme of a task processing method is provided. The initial corpus associated with the target type of text generation task is expanded as a basis to generate a large amount of extended corpus, thereby reducing the construction cost and acquisition difficulty of the corpus used to train the first large language model, increasing the diversity and richness of the model training data, and then generating the reply information of the target task based on the trained first large language model, thereby achieving the purpose of enriching the model training corpus and improving the performance of the large language model, thereby achieving the technical effect of improving the accuracy of the output results of the text generation task processed by the large language model, and then solving the technical problem that the accuracy of the output results of the text generation task processed by the large language model is low due to the difficulty in obtaining the corpus for training the large language model in a specific industry or field.

[0162] Those skilled in the art will understand that Fig.11 The structure shown is for illustration only, and the electronic device may also be a smart phone, a tablet computer, a PDA, a mobile Internet device (MID), a PAD, or other terminal devices. Fig.11 It does not limit the structure of the above electronic device. For example, the electronic device A may also include Fig.11 More or fewer components (such as network interfaces, display devices, etc.) shown in the figure, or having Fig.11 Different configurations shown.

[0163] A person of ordinary skill in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing the hardware related to the terminal device through a program, and the program can be stored in a computer-readable storage medium, and the storage medium may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.

[0164] Example 9

[0165] The embodiment of the present application further provides a computer-readable storage medium. Optionally, in this embodiment, the computer-readable storage medium can be used to store the program code executed by the method provided in the above embodiment.

[0166] Optionally, in this embodiment, the above storage medium may be located in any electronic device in a group of electronic devices in a computer network, or in any mobile terminal in a group of mobile terminals.

[0167] Optionally, in this embodiment, the computer-readable storage medium is configured to store program code for executing the following steps: determining target request information and target prompt information of a target task, wherein the target task is a text generation task of a target type, and the target prompt information is used to describe information required to complete the target task; inputting the target request information and the target prompt information into a first language model for processing to obtain reply information corresponding to the target task, wherein the first language model is trained based on extended corpus, the extended corpus is a corpus expanded from an initial corpus associated with the text generation task of the target type, and the extended corpus includes extended request information, prompt information, and extended reply information.

[0168] Example 10

[0169] The embodiment of the present application further provides a computer program product. Optionally, in this embodiment, the computer program product may include a computer program, and the computer program implements the method provided in the embodiment when executed by a processor.

[0170] Embodiment 11

[0171] The embodiments of the present application also provide a computer program product. Optionally, the computer program product may include a non-volatile computer-readable storage medium, which may be used to store a computer program, and when the computer program is executed by a processor, the method provided in the embodiments is implemented.

[0172] Example 12

[0173] The embodiment of the present application further provides a computer program. Optionally, in this embodiment, when the computer program is executed by a processor, the method provided in the above embodiment is implemented.

[0174] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.

[0175] In the above embodiments of the present application, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.

[0176] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.

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

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

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

[0180] The above is only a preferred embodiment of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.

Claims

1. A task processing method, characterized in that: include: Determine target request information and target prompt information of a target task, wherein the target task is a text generation task of a target type, and the target prompt information is used to describe information required to complete the target task; The target request information and the target prompt information are input into a first large language model for processing to obtain reply information corresponding to the target task, wherein the first large language model is trained based on an extended corpus, the extended corpus is a corpus expanded from an initial corpus associated with a text generation task of the target type, and the extended corpus includes extended request information, prompt information and extended reply information.

2. The method according to claim 1, characterized in that The first language model is obtained in the following way: Determining initial request information and prompt information for different tasks of the target type, and generating extended request information according to the initial request information and the prompt information; Inputting the extended request information and the prompt information into different large language models for processing to obtain a candidate reply information set, and determining the extended reply information according to the candidate reply information set; A natural language processing model is trained according to the extended request information, the prompt information, and the extended reply information to obtain the first large language model, wherein the natural language processing model is used to process text generation tasks.

3. The method according to claim 2, characterized in that Generating the extended request information according to the initial request information and the prompt information includes: Generate an extended task for extending the request information, and determine the request information and prompt information of the extended task, wherein the request information of the extended task is used to request to generate extended request information according to the initial request information and the prompt information, and the prompt information of the extended task includes the initial request information and the prompt information; The request information and prompt information of the extended task are input into a pre-trained third language model of a general field for processing to obtain the extended request information.

4. The method according to claim 2, characterized in that: Determining the extended reply information according to the candidate reply information set includes: Deduplication of semantically identical reply information in the candidate reply information set is performed to obtain a deduplicated candidate reply information set; The extended reply information is determined according to the removed duplicate candidate reply information set.

5. The method according to claim 4, characterized in that Before removing duplicate reply information with the same semantics from the candidate reply information set, the method further includes: Filtering the reply information with errors in the candidate reply information set to obtain a filtered candidate reply information set; Deduplicating the reply information with the same semantics in the candidate reply information set includes: deduplicating the reply information with the same semantics in the filtered candidate reply information set.

6. The method according to claim 4, characterized in that Determining the extended reply information according to the candidate reply information set after deduplication includes: Inputting the reply information in the candidate reply information set after deduplication into a ranking model to obtain a ranking result, wherein the ranking model at least ranks the reply information in descending order according to the accuracy of the reply information; A preset number of reply messages located in the front column of the sorting result are determined as the extended reply messages.

7. The method according to claim 2, characterized in that: Inputting the extended request information and the prompt information into different large language models includes: The sample information in the prompt information is removed, and the extended request information and the prompt information for removing the sample information are input into the different large language models.

8. The method according to claim 2, characterized in that: The natural language processing model is trained according to the extended request information, the prompt information, and the extended reply information to obtain the first language model, including: Acquire a preset data structure of tokens of a pre-trained second largest language model of a general domain, wherein the preset data structure represents a semantic processing capability of the second largest language model; Determining a sample data set according to the extended request information, the prompt information, and the extended reply information, wherein a sample data in the sample data set includes a piece of extended request information, a piece of prompt information, and at least one piece of extended reply information; The sample data set and the preset data structure are used to train the natural language processing model to obtain the first large language model.

9. A model training method, characterized in that: include, Expanding the initial corpus associated with the target type of text generation task to obtain an extended corpus, wherein the extended corpus includes extended request information, prompt information, and extended reply information, the prompt information is used to describe the information required to complete the text generation task, and the reply information is the reply information corresponding to the text generation task; Determine a sample data set according to the extended corpus, wherein a sample data in the sample data set includes an extended request message, a prompt message and at least one extended reply message; The sample data set is used to train a natural language processing model to obtain the first large language model described in any one of claims 1 to 8, wherein the natural language processing model is used to process text generation tasks.

10. The method according to claim 9, characterized in that The initial corpus associated with the target type of text generation task is expanded to obtain the expanded corpus including: Determining initial request information and prompt information for different text generation tasks of the target type, and generating extended request information according to the initial request information and the prompt information; Inputting the extended request information and the prompt information into different large language models for processing to obtain a candidate reply information set, and determining the extended reply information according to the candidate reply information set; A sample data set is determined according to the extended request information, the prompt information and the extended reply information, wherein a sample data in the sample data set includes a piece of extended request information, a piece of prompt information and at least one piece of extended reply information.

11. The method according to claim 9, characterized in that Using the sample data set to train a natural language processing model includes: Acquire a preset data structure of a pre-trained second largest language model in a general domain, wherein the preset data structure represents a semantic processing capability of the second largest language model; The sample data set and the preset data structure are used to train a natural language processing model.

12. A method for generating a code, characterized in that: include: Determine target request information and target prompt information of the code generation task, wherein the target request information requests the generation of target code to implement the target function, and the target prompt information is used to describe information required to generate the target code; The target request information and the target prompt information are input into a first large language model for processing to obtain the target code for implementing the target function, wherein the first large language model is trained based on an extended corpus, the extended corpus is a corpus expanded based on an initial corpus, and the extended corpus includes extended request information, prompt information and extended code of a code generation task.

13. A task processing method, characterized in that: include: The cloud server receives target request information and target prompt information of a target task sent by the client, wherein the target task is a text generation task of a target type, and the target prompt information is used to describe information required to complete the target task; The cloud server processes the target request information and the target prompt information through a first large language model to obtain reply information corresponding to the target task, wherein the first large language model is trained based on an extended corpus, the extended corpus is a corpus expanded based on an initial corpus associated with the text generation task of the target type, and the extended corpus includes extended request information, prompt information, and extended reply information; The cloud server sends the reply information corresponding to the target task to the client.

14. An electronic device, characterized in that: include: A memory storing an executable program; A processor, configured to run the program, wherein the program executes the method according to any one of claims 1 to 13 when running.

15. A computer program product, characterized in that It comprises a computer program which, when executed by a processor, implements the method according to any one of claims 1 to 13.

Citation Information

Patent Citations

  • Language model training method and device, electronic equipment and storage medium

    CN114036300A

  • Training corpus set construction method, translation model training method and translation method

    CN115587590A

  • Language generation model improvement method, system and equipment and storage medium

    CN117235523A

  • Large model generation method and device and computer program product

    CN118427214A

  • Method and device for semantic alignment between languages based on word list expansion and electronic equipment

    CN118607532A

Cited By

  • Intelligent number asking method for large model index query

    CN120336360A

  • ASAP.js Framework and Its No-Code Application Development System and Method

    KR102864598B1