Generative large language model training method and model-based search method

By constructing a training set of interface call instructions and user preference ranking, supervised fine-tuning and reinforcement learning training are performed on the generative large language model, which solves the problem of inaccurate responses of the generative large language model in real-world tasks and achieves more accurate and efficient user needs are met.

CN116226334BActive Publication Date: 2024-10-18BEIJING BAIDU NETCOM SCI & TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202310233941.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-03-03
Publication Date
2024-10-18
Estimated Expiration
2043-03-03

AI Technical Summary

Technical Problem

When the existing generative large language model is applied to solve real-world tasks, it is difficult to generate responses that match the actual situation, and it is unable to utilize external knowledge, resulting in inaccurate answers.

Method used

By constructing a training set containing interface call instructions, we perform supervised fine-tuning of the pre-trained model, combine user preference ranking and preset templates, and use reinforcement learning to train a target generative large language model, so that it can build interface call instructions on its own to obtain accurate Answer.

Benefits of technology

It realizes the generative large language model to deeply understand user needs, can output results that are more in line with user expectations, and improves the accuracy and efficiency of search results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116226334B_ABST
    Figure CN116226334B_ABST
Patent Text Reader

Abstract

The present disclosure provides a generative large language model training method and a model-based search method, which relate to artificial intelligence technology fields such as generative models and intelligent search. The method includes: constructing a first training set based on the user query text and the matching output results containing interface call instructions; using the first training set to perform supervised fine-tuning training on the pre-trained first generative large language model to obtain a second generative large language model; constructing a second training set based on the user preference ranking and preset template set between the same user query text and different candidate outputs; using the second training set to perform supervised training on the pre-trained third generative large language model to obtain a reward model; and training the second generative large language model in a reinforcement learning manner based on the score returned by the reward model. The generative large language model trained in this way can significantly improve the accuracy of search results and user experience in search scenarios.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of data processing, specifically to the field of artificial intelligence technologies such as generative models and intelligent search, and in particular to a generative large language model training and a search method based on the generative large language model, as well as corresponding devices, electronic devices, computer-readable storage media and computer program products. Background Art

[0002] Large language models (LLM, Large Language Model, which is essentially a generative model), such as ChatGPT (Chat Generative Pre-trained Transformer, a chatbot program developed by OpenAI), can generate fluent human-like responses for many downstream tasks (such as task-oriented dialogues and question answering).

[0003] However, applying LLMs to real-world task-solving applications remains challenging, mainly due to their potential to generate responses that are inconsistent with reality and their inability to use external knowledge as reference for response generation.

[0004] For example, questions such as "What is the current weather in City A?", "What is the exchange rate of currency B to currency C?", and "How long does it take to get from location C to location D?" all require real-time information when answering them. However, this real-time information (such as real-time time, real-time exchange rate, real-time road conditions, and real-time traffic information) cannot be generated simply by relying on the knowledge contained in the LLM parameters. It is necessary to rely on external knowledge to generate accurate results. Summary of the invention

[0005] The embodiments of the present disclosure provide a generative large language model training method and a search method based on the generative large language model, as well as a device, an electronic device, a computer-readable storage medium, and a computer program product supporting the method.

[0006] In a first aspect, an embodiment of the present disclosure proposes a generative large language model training method, comprising: constructing a first training set based on a user query text and a matching output result containing an interface call instruction; wherein the service interface called by the interface call instruction corresponds to the functional usage intention expressed by the user query text; using the first training set to perform supervised fine-tuning training on a pre-trained first generative large language model to obtain a second generative large language model; constructing a second training set based on a user preference ranking and a preset template set between the same user query text and different candidate outputs; using the second training set to perform supervised training on a pre-trained third generative large language model to obtain a reward model; and training the second generative large language model in a reinforcement learning manner based on the score returned by the reward model to obtain a target generative large language model.

[0007] In a second aspect, an embodiment of the present disclosure proposes a generative large language model training device, comprising: a first training set construction unit, configured to construct a first training set based on a user query text and a matching output result containing an interface call instruction; wherein the service interface called by the interface call instruction corresponds to the functional usage intention expressed by the user query text; a supervised fine-tuning training unit, configured to use the first training set to perform supervised fine-tuning training on a pre-trained first generative large language model to obtain a second generative large language model; a second training set construction unit, configured to construct a second training set based on a user preference ranking and a preset template set between the same user query text and different candidate outputs; a reward model training unit, configured to use the second training set to perform supervised training on a pre-trained third generative large language model to obtain a reward model; and a reinforcement learning training unit, configured to train the second generative large language model in a reinforcement learning manner based on the score returned by the reward model to obtain a target generative large language model.

[0008] In a third aspect, an embodiment of the present disclosure proposes a search method based on a generative large language model, comprising: obtaining a user query text input by a user in a search bar; inputting the user query text as input data into a target generative large language model; wherein the target generative large language model is obtained according to the generative large language model training method described in the first aspect above; receiving a query result text returned by the target generative large language model; wherein the query result text is generated based on the response information obtained after executing an interface call instruction.

[0009] In a fourth aspect, an embodiment of the present disclosure proposes a search device based on a generative large language model, comprising: a user query text acquisition unit, configured to acquire a user query text input by a user in a search bar; a model calling unit, configured to input the user query text as input data into a preset target generative large language model; wherein the target generative large language model is obtained according to the generative large language model training device as described in the second aspect; a query result text receiving unit, configured to receive a query result text returned by the target generative large language model; wherein the query result text is generated based on the response information obtained after executing the interface calling instruction.

[0010] In a fifth aspect, an embodiment of the present disclosure provides an electronic device, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that when the at least one processor executes, it can implement the generative large language model training method as described in the first aspect or the search method based on the generative large language model as described in the third aspect.

[0011] In a sixth aspect, an embodiment of the present disclosure provides a non-transitory computer-readable storage medium storing computer instructions, which are used to enable a computer to implement the generative large language model training method as described in the first aspect or the search method based on the generative large language model as described in the third aspect when executed.

[0012] In the seventh aspect, an embodiment of the present disclosure provides a computer program product comprising a computer program, which, when executed by a processor, can implement the steps of the generative large language model training method as described in the first aspect or the steps of the search method based on the generative large language model as described in the third aspect.

[0013] The generative large language model training scheme provided by the embodiment of the present disclosure has a first training set constructed by a user query text and an output result containing an interface call instruction that expresses the corresponding function usage intention, so that the pre-trained first generative large language model is fine-tuned in a supervised manner through the first training set, so that the trained second generative large language model has the ability to rewrite the user query text into a matching output result containing the interface call instruction, and the pre-trained third generative large language model is supervisedly trained with a second training set constructed by a user preference ranking and a preset template set between the same user query text and different candidate outputs, so that the trained reward model has the ability to perform quality scoring for different candidates generated by the generative large language model for the user query text, so that under the training of reinforcement learning based on human feedback, the target generative large language model finally obtained not only has the ability to rewrite the user query text into a matching output result containing the interface call instruction, but also has the ability to output results that better meet user needs. That is, through the above training scheme, the trained target generative large language model has the ability to deeply understand user needs and construct corresponding interface call instructions to query and return accurate answers. It can not only generate natural language output based on natural language input and the knowledge contained in the large model parameters, but also call the corresponding functions with the help of application program interfaces that provide professional capabilities to more effectively solve user needs. Under the influence of the reward model, the returned results will be more in line with the actual needs and expectations of users.

[0014] Based on the beneficial effects of the generative large language model training scheme provided in the above-mentioned embodiments, the search method based on the generative large language model provided in the embodiments of the present disclosure is specifically aimed at the scenario in which the search engine acts as the execution subject, and the target generative large language model trained according to the above-mentioned training scheme is applied to the search scenario. After the search engine inputs the user query text into the target generative large language model, it generates corresponding results with the help of the capabilities of the target generative large language model, and automatically generates interface call instructions and executes them to obtain the returned call results when encountering the need to call the service interface, and returns the query result text generated based on the generated reply text and the call result to the search engine, so that the user can directly obtain the query result text that meets their search needs, thereby improving the accuracy of the search results and the search efficiency.

[0015] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] Other features, objects and advantages of the present disclosure will become more apparent from the detailed description of non-limiting embodiments made with reference to the following drawings:

[0017] Figure 1 is an exemplary system architecture in which the present disclosure may be applied;

[0018] Figure 2 A flowchart of a generative large language model training method provided in an embodiment of the present disclosure;

[0019] Figure 3 A flowchart of a method for constructing a first training set provided in an embodiment of the present disclosure;

[0020] Figure 4 A flowchart of a method for constructing a first training set based on sample pairs consisting of user query text and matching output results provided in an embodiment of the present disclosure;

[0021] Figure 5 A flowchart of a method for constructing a second training set provided in an embodiment of the present disclosure;

[0022] Figure 6 A flowchart of a search method based on a generative large language model provided in an embodiment of the present disclosure;

[0023] Figure 7 A schematic diagram of a search interaction process for a specific example provided in an embodiment of the present disclosure;

[0024] Figure 8 A structural block diagram of a generative large language model training device provided in an embodiment of the present disclosure;

[0025] Fig. 9 A structural block diagram of a search device based on a generative large language model provided in an embodiment of the present disclosure;

[0026] Fig.10 A schematic diagram of the structure of an electronic device suitable for executing a generative large language model training method and / or a search method based on a generative large language model, provided in an embodiment of the present disclosure. DETAILED DESCRIPTION

[0027] The following is a description of exemplary embodiments of the present disclosure in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description. It should be noted that the embodiments in the present disclosure and the features in the embodiments may be combined with each other without conflict.

[0028] In the technical solution of the present disclosure, the collection, storage, use, processing, transmission, provision and disclosure of user personal information involved are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.

[0029] Figure 1 An exemplary system architecture 100 is shown to which the generative large language model training method, the generative large language model-based search method, and the supporting apparatus, electronic device, and computer-readable storage medium of the present application can be applied.

[0030] like Figure 1 As shown, the system architecture 100 may include terminal devices 101, 102, 103, a network 104 and a server 105. The network 104 is used to provide a medium for communication links between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.

[0031] Users can use terminal devices 101, 102, 103 to interact with server 105 through network 104 to receive or send messages, etc. Terminal devices 101, 102, 103 and server 105 can be installed with various applications for realizing information communication between the two, such as search applications, model training applications, etc.

[0032] Terminal devices 101, 102, 103 and server 105 can be hardware or software. When terminal devices 101, 102, 103 are hardware, they can be various electronic devices with display screens, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, etc.; when terminal devices 101, 102, 103 are software, they can be installed in the electronic devices listed above, which can be implemented as multiple software or software modules, or as a single software or software module, and no specific limitation is made here. When server 105 is hardware, it can be implemented as a distributed server cluster composed of multiple servers, or as a single server; when the server is software, it can be implemented as multiple software or software modules, or as a single software or software module, and no specific limitation is made here.

[0033] The server 105 can provide various services through various built-in applications. For example, a search application that can provide search services to users can achieve the following effects when the server 105 runs the search application: first, the user query text entered by the user in the search bar is recorded by the terminal devices 101, 102, and 103 transmitted through the network 104; then, the user query text is input as input data into the pre-trained target generative large language model; next, the query result text returned by the target generative large language model is received; wherein the query result text is generated based on the response information obtained after executing the interface call instruction. Furthermore, the query result text can also be retransmitted back to the terminal devices 101, 102, and 103 through the network 104 so that the terminal devices 101, 102, and 103 can present it to the user through the display screen.

[0034] Among them, the target generative large language model can be trained by the model training application built into the server 105 according to the following steps: first, based on the user query text and the matching output result containing the interface call instruction, a first training set is constructed, and the service interface called by the interface call instruction corresponds to the functional usage intention expressed by the user query text; then, the first training set is used to perform supervised fine-tuning training on the pre-trained first generative large language model to obtain a second generative large language model; then, based on the user preference ranking and preset template set between the same user query text and different candidate outputs, a second training set is constructed; next, the second training set is used to perform supervised training on the pre-trained third generative large language model to obtain a reward model; finally, the second generative large language model is trained in a reinforcement learning manner based on the score returned by the reward model to obtain a target generative large language model.

[0035] Since it takes more computing resources and stronger computing power to train the target generative large language model, the generative large language model training method provided in the subsequent embodiments of the present application is generally performed by a server 105 with stronger computing power and more computing resources. Correspondingly, the generative large language model training device is generally also arranged in the server 105. However, it should also be pointed out that when the terminal devices 101, 102, and 103 also have computing power and computing resources that meet the requirements, the terminal devices 101, 102, and 103 can also complete the above-mentioned various operations handed over to the server 105 through the model training application installed thereon, and then output the same result as the server 105. Correspondingly, the generative large language model training device can also be arranged in the terminal devices 101, 102, and 103. In this case, the exemplary system architecture 100 may also not include the server 105 and the network 104.

[0036] Of course, the server used to train the target generative large language model can be different from the server that calls the trained target generative large language model for use. In particular, the target generative large language model trained by the server 105 can also be used to obtain a lightweight target generative large language model suitable for being placed in the terminal devices 101, 102, and 103 by model distillation, that is, it can be flexibly selected to use the lightweight target generative large language model in the terminal devices 101, 102, and 103 according to the recognition accuracy of actual needs, or to choose to use the more complex target generative large language model in the server 105.

[0037] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to the implementation requirements.

[0038] Please refer to Figure 2 , Figure 2 A flowchart of a generative large language model training method provided in an embodiment of the present disclosure, wherein process 200 includes the following steps:

[0039] Step 201: constructing a first training set based on the user query text and the matching output results containing the interface call instructions;

[0040] This step is intended to be performed by the execution subject of the generative large language model training method (e.g. Figure 1 The server 105 shown in the figure constructs a first training set based on a large number of sample pairs of "user query text-output result containing interface call instructions" consisting of user query text and matched output result containing interface call instructions. The user query text can be obtained from various channels, and can come from the query words (usually also referred to as query) input by users recorded in the search logs of a large number of authorized users, or the query text converted from the query voice input by the user. In order to realize the conversion of user query voice into user query text, automatic speech recognition (Automatic Speech Recognition, ASR) technology can be used to achieve it, and in order to improve the accuracy of the conversion result, it can also be carried out with the help of a speech-to-text model based on deep learning.

[0041] Among them, the service interface called by the interface call instruction corresponds to the functional usage intention expressed by the user query text, that is, the service interface called by the interface call instruction corresponds to the expected demand expressed by the user query text, and then the user demand is realized or a reply that satisfies the user's functional usage intention is obtained by executing the interface call instruction to obtain a return response and organizing the output results based on the response information.

[0042] Among them, the "service interface" described in the present disclosure refers to an application programming interface (Application Programming Interface, API) for providing services. Different APIs can be provided by related applications installed on the operating system (including system-related applications that support the normal operation of the operating system and other applications built on the normal operation of the operating system), or directly provided by the operating system or some system components running on the operating system, such as Weather API (usually provided by weather applications) for implementing weather query functions, Converter API (usually provided by mathematical calculation applications or widget components) for implementing exchange rate conversion functions, Transform API (usually provided by mathematical calculation applications or widget components) for implementing base conversion, Loc API (usually provided by map applications) for implementing location determination functions, Date API (usually provided by clock applications or time components) for implementing specific date acquisition functions, FindSong API (usually provided by song applications or retrieval applications) for implementing song search functions. In addition, it also includes but is not limited to corresponding APIs for implementing the following functions:

[0043] Route navigation, registered license plate number query, user search, friend query, song recognition, image search, task scheduling, multiple option selection based on user preferences, restricted license plate number query, translation, surrounding environment query, encryption and decryption, data download, data transmission, question query, image editing, etc.

[0044] In addition, the output results that match the user query text and include interface call instructions may only include one interface call instruction. In this case, the user query text may only express an intention to use one function, and at this time, only this intention to use the function corresponds to this interface call instruction; it is also possible that the user query text expresses multiple intentions to use multiple functions at the same time, but only one of them must be executed through the corresponding interface call instruction to seek a return response in order to obtain the required accurate results (for example, the situation mentioned in the background technology part that requires real-time and dynamic information to perform real-time calculations). The corresponding interface call instructions can be used to obtain the corresponding answers for the remaining function usage intentions, or the corresponding answers can be directly generated for the user query text only by relying on the knowledge contained in the large model parameters. In this case, whether it is necessary to still choose to generate interface call instructions for it to obtain the corresponding answers can be flexibly selected according to actual conditions, and no specific limitation is made here.

[0045] If the output result containing interface call instructions that matches the user query text contains multiple interface call instructions at the same time, it is also necessary to consider whether there is an execution dependency between different interface call instructions, so as to correctly organize them into a service interface call sequence according to the determined execution order. Specifically, for each interface call instruction, it generally contains the interface name of the target service interface and specific interface call parameters, and the two are combined in the required format. However, for some special APIs, their interface call parameters can be empty; for some other special APIs, their interface call parameters can also be another interface call instruction. In addition, the specific interface call parameters can be directly served by a text fragment in the user query text, or by other forms of content that express the same meaning as the corresponding text fragment.

[0046] Taking the simple user query text "How is the weather in X city" as an example, it only has one functional usage intent, which is weather information query. The target service interface corresponding to this functional usage intent can be WeatherAPI, which refers to the weather query function. Its specific interface parameter should be "X city", that is, the interface call instruction contained in the output result at this time should be: Weather(X city).

[0047] To facilitate understanding of the solution described in this step, the following will be explained through a specific example:

[0048] Assume that the obtained user query text is: "A's height is 7ft 6in, approximately how many meters", then the output result matching the user query text can be: "A is a famous basketball player, height Transform(7ft 6in, Meter), British system is 7 feet 6 inches, and he is one of the tallest basketball players". The reason for the corresponding output result is that the function call intention that the user wants to express can be determined based on the user query text. In addition to the base conversion of the length unit, the user may also want to further understand the relevant entity information of "A" (wherein the entity can refer to a person's name, a place name, an organization name, etc., which can be determined according to the context). If the relevant entity information of "A" is also obtained through the interface call instruction, the output result corresponding to the user query text can also be: Character(A), height Transform(7ft 6in, Meter), British system is 7 feet 6 inches. It can be seen that there is no execution dependency between the Character API used to query the entity information related to A and the Transform API used to convert the length unit. That is, in a serial execution environment, it does not matter which interface call instruction is executed first. In a parallel execution environment, the two interface call instructions can be executed in parallel.

[0049] It should be noted that the above-mentioned output results containing interface call instructions that match the user query text can be obtained by manual annotation based on one's own understanding of the user query text and knowledge of the relevant usage of the service interface, or can be obtained by non-artificial objects based on concentrated extraction of data samples that implicitly contain the corresponding relationship between the above two, so as to achieve efficient construction of sample pairs of "user query text-output results containing interface call instructions".

[0050] In some understandings, if the user query text is understood as a query, the output result containing the interface call instructions is actually an answer consisting of the interface call instructions consisting of the API and API parameters that can meet the corresponding needs.

[0051] Step 202: Perform supervised fine-tuning training on the pre-trained first generative large language model using the first training set to obtain a second generative large language model;

[0052] On the basis of step 201, this step aims to use the first training set as a fine-tuning training set by the above-mentioned execution subject to perform supervised fine-tuning training (Supervised Fine-Tuning, SFT) on the first pre-trained generative large language model, so as to further obtain a second generative large language model.

[0053] The SFT technology used in this step means that the training object is not the initial model that has not undergone any training, but the general generative large language model obtained through training with basic training samples, that is, the general generative large language model obtained through training with basic training samples usually only generates a text sequence as a result based on the predicted probability of the language unit (token) according to the knowledge contained in the text input and the large model parameters, and does not have the ability to rewrite it into an output result containing interface call instructions including the target API and API parameters. With the help of this SFT technology, the huge time-consuming effort required to train the model from scratch can be avoided. It only needs to construct a first training set containing a small amount of training samples (the small amount here is the order of magnitude relative to the basic training samples), and then the general generative large language model can be trained twice to enable it to have the ability to rewrite the user query text into an output result containing interface call instructions including the target API and API parameters.

[0054] Of course, in some application scenarios, the general generative large language model trained with basic training samples may not be suitable as the basic model for using SFT technology (for example, the knowledge learned by the general generative large language model conflicts with the knowledge implicit in the newly constructed training samples). The initial generative language model can also be trained based on the newly constructed training samples, in order to make the trained target generative large language model have the desired capabilities.

[0055] Step 203: constructing a second training set based on the user preference ranking between the same user query text and different candidate outputs and a preset template set;

[0056] On the basis of step 202, this step aims to construct a second training set by the above-mentioned execution subject based on the user preference ranking between the same user query text and different candidate outputs and the preset templates that record the corresponding relationship between the input text and the corresponding interface call instruction. The preset template can be specifically expressed as: "[String] How much is the US dollar equivalent to RMB - according to the current latest exchange rate, [String] US dollar is equal to Converter (String, from USD, to Yuan) RMB", "[Address] How is the weather - according to the latest weather forecast, today [Address] Weather (Loc (Address))", that is, the preset template is used to indicate what style of text fragment corresponds to what kind of output text containing interface call instructions, where "String" is used to refer to the corresponding part can be filled with any string. Specifically, the preset template can be extracted from each "user query text-output result containing interface call instructions" sample pair used to constitute the first training set, and can also be extracted from other data sets containing the above-mentioned corresponding relationships.

[0057] That is, first, for each user query text, a sample pair formed by the user query text and each candidate output is constructed, and these sample pairs are sorted according to the user preference ranking of the candidate output in each sample pair; then, the preset templates (the preset template set contains multiple preset templates) that record the correspondence between the input text and the corresponding interface call instructions are combined to jointly construct the second training set, in order to enable the model to learn which results are more in line with the actual needs of the user by using the second training set constructed in this way.

[0058] It should be noted that the training samples described above for constructing the second training set can be manually labeled and generated by humans based on their own subjective understanding, or they can be extracted by non-artificial objects based on a data sample set that implies the correspondence between the above two (for example, a retrieval log that reflects the search terms and retrieval results in the user's retrieval operation) to achieve efficient construction of corresponding sample pairs.

[0059] When the data sample set is a retrieval log, the user preference ranking can be specifically expressed as the cumulative number of clicks on each candidate output in the candidate output list returned for the same user query text recorded in the retrieval log within a period of time, that is, the more cumulative clicks, the more the candidate output meets the user's actual needs. The length of the time period can be set by yourself, such as one week, half a month or a whole month. When the data sample set is a database, the user preference ranking can also be expressed as other similar parameters that can express user preferences, such as the number of collections, the number of comments, etc., which will not be listed here one by one.

[0060] Step 204: Use the second training set to perform supervised training on the pre-trained third generative large language model to obtain a reward model.

[0061] On the basis of step 203, this step aims to use the second training set by the above-mentioned execution subject to perform supervised training on the pre-trained third generative large language model to obtain a reward model (Reward Model, RM). The reward model described here refers to learning how to give different rewards (generally returned in the form of high and low scores) to different alternative outputs under the same input by learning the user preference ranking between different sample pairs under each training sample in the second training set, so as to make the model learn in the direction of obtaining higher rewards, so as to be able to output results that better meet the actual needs of users.

[0062] Step 205: The second generative large language model is trained in a reinforcement learning manner based on the score returned by the reward model to obtain a target generative large language model.

[0063] On the basis of step 202 and step 204, this step aims to train the second generative large language model by the above-mentioned execution subject based on the score of the reward model by reinforcement learning (RL) to obtain a target generative large language model.

[0064] The brief process of training the target generative large language model based on RL can be referred to the following description:

[0065] 1) Initializing a new generative large language model M based on the parameters of the second generative large language model;

[0066] 2) Based on the new prompt (prompt words, usually natural language input from the user), let M generate a response for each prompt and then input the response to the reward model (RM);

[0067] 3) RM will calculate a score for each reply as a scalar reward, and the score indicates the quality of the reply;

[0068] 4) In the RL approach, the total reward score obtained based on model M is continuously used to update its generation policy until convergence. The M at this point of training is the target generative large language model that meets the requirements.

[0069] To facilitate the understanding of the "generative large language model" described and used in this disclosure, the working principle of the generative model corresponding to the prefix "generative" is briefly introduced here:

[0070] The reason it is called a generative model is that the working process of such a model is similar to "word chain", that is, based on the user input and the previous output of the model, it continuously predicts the next token (language unit), and then finally generates a text sequence. See the following example:

[0071] Assume that the target generative large language model has learned the ability to output the output result containing interface call instructions according to the above scheme for the user query text. Then, still taking "A's height is 7ft 6in, approximately how many meters" (referred to as "query" for the convenience of the following example) as an example, the process of the target generative model outputting the corresponding output result containing interface call instructions is carried out in the following steps in sequence:

[0072] query --> A;

[0073] query + A --> is;

[0074] query + A + is --> famous;

[0075] query + A + is + famous --> basketball;

[0076] query + A + is + famous + basketball --> player;

[0077] query + A + is + famous + basketball + player --> ;

[0078] query + A + is + famous + basketball + player +, --> height;

[0079] query + A + is + famous + basketball + player + height --> is;

[0080] query + A + is + famous + basketball + player + height + is --> 7ft;

[0081] query + A + is + famous + basketball + player + height + is + 7ft --> 6in;

[0082] query + A + is + famous + basketball + player + height + is + 7ft + 6in --> approximately;

[0083] query+A+is+a+famous+basketball+athlete+,+height-->height;

[0084] query+A+is+a+famous+basketball+athlete+,+height-->Transform;

[0085] query+A+is+a+famous+basketball+athlete+,+height+Transform-->(;

[0086] query+A+is+a+famous+basketball+athlete+,+height+Transform+(-->7;

[0087] query+A+is+a+famous+basketball+athlete+,+height+Transform+(+7-->ft;

[0088] query+A +is+a+famous+basketball+athlete+,+height+Transform+(+7+ft-->6;

[0089] query+A+is+a+famous+basketball+athlete+,+height+Transform+(+7+ft+6-->in;

[0090] query+A+is+a+famous+basketball+player+,+height+Transform+(+7+ft+6+in-->,;

[0091] query+A+is+a+famous+basketball+athlete+,+height+Transform+(+7+ft+6+in-->Meter;

[0092] query+A+is+a+famous+basketball+player+,+height+Transform+(+7+ft+6+in+,+Meter-->);

[0093] …

[0094] …

[0095] query+A+is+a+famous+basketball+player+,+height+Transform+(+7+ft+6+in+,+Meter+)+,+-->)-->,;

[0096] query+A+is+a+famous+basketball+player,+whose+height+Transform+(+7+ft+6+in-->,+which+is+7+feet+6+in+in+British+system,+and+is+one+of+the+tallest+basketball+players-->END.

[0097] That is, we can finally get the output result that A is a famous basketball player, his height is Transform(7ft 6in, Meter), which is 7 feet 6 inches in British system, and he is one of the tallest basketball players.

[0098] In Chinese, a token is usually a Chinese character; in English, a token usually refers to a sub-word (literally translated as "sub-word" in Chinese) rather than a word. The corresponding sub-word granularity is a form between word granularity and character granularity. Sub-words can retain the meaning of the language while effectively reducing the size of the vocabulary (i.e., the number of words in the vocabulary) and effectively solving the problem of out-of-vocabulary words. Taking the three English words "loved", "loving" and "loves" as examples, the following four sub-words can be obtained: "lov", "ed", "ing" and "es". That is, in this way, the meaning and tense of the word itself can be separated to obtain sub-words with smaller granularity. In the above example, "Transform" representing the API name will be used as an indivisible whole as a token, and "Meter" as a unit of length will also be used as a token.

[0099] The generative large language model training method provided by the embodiment of the present disclosure has a first training set constructed by user query text and an output result containing an interface call instruction that expresses the corresponding function usage intention, so that the pre-trained first generative large language model is fine-tuned in a supervised manner through the first training set, so that the trained second generative large language model has the ability to rewrite the user query text into a matching output result containing the interface call instruction, and the pre-trained third generative large language model is supervisedly trained with a second training set constructed by user preference ranking between the same user query text and different candidate outputs, so that the trained reward model has the ability to perform quality scoring for different candidates generated by the generative large language model for the user query text, so that under the training of reinforcement learning based on human feedback, the target generative large language model finally obtained not only has the ability to rewrite the user query text into a matching output result containing the interface call instruction, but also has the ability to output results that better meet user needs. That is, through the above training scheme, the trained target generative large language model has the ability to deeply understand user needs and construct corresponding interface call instructions to query and return accurate answers. It can not only generate natural language output based on natural language input and the knowledge contained in the large model parameters, but also call the corresponding functions with the help of application program interfaces that provide professional capabilities to more effectively solve user needs. Under the influence of the reward model, the returned results will be more in line with the actual needs and expectations of users.

[0100] On the basis of the above embodiment, in the supervised fine-tuning training process using SFT technology, for special API-related symbols that do not appear in the first generative large language model, it is necessary to expand the language unit (i.e., token), which can be called a new token. The initialization of the features of the new token can be performed by sampling the multivariate normal distribution parameters of the features of the existing language unit.

[0101] Specifically, since the inserted API and API format-related special symbols do not exist in the vocabulary of the first generative large language model, the vocabulary of the first generative large language model also needs to be expanded. Regarding the initialization problem of the embedding (usually translated as word vector or word embedding) corresponding to the new token after the vocabulary expansion, a parameter sampling initialization method can also be used: that is, for the embedding corresponding to the newly added token, if it is randomly initialized or initialized with 0, it will usually increase the difficulty of the model to predict the new token. This is because the initialization embedding of the new token is too different from the embedding distribution of the existing token obtained by the general generative large language model after a large amount of pre-training. In order to reduce this difference, the embedding of each new token can be sampled according to the multivariate Gaussian distribution of the embedding of the existing token (a multivariate multivariate normal distribution, which can also be referred to as a multivariate normal distribution). Formally, for each new token corresponding to the embedding—e n+i , sampling can be performed as follows:

[0102]

[0103] Among them, E∈R n×d It is the embedding [e1; ...; e n ] is a matrix composed of .

[0104] Please refer to Figure 3 , Figure 3 A flowchart of a method for constructing a first training set provided in an embodiment of the present disclosure, that is, for Figure 2 Step 201 in the process 200 shown provides a specific implementation method, and the other steps in the process 200 are not adjusted. The specific implementation method provided in this embodiment is replaced by step 201 to obtain a new complete embodiment. The process 300 includes the following steps:

[0105] Step 301: Obtain a search session and determine valid search results that successfully respond to a user query text in the search session;

[0106] This step aims to obtain the search session (corresponding to English: session, which records a series of search terms and search behaviors of the user in the process of completing a search task) that records the user's search session through the search engine, and determine the effective search results that successfully respond to the user's query text (or query text, search terms, query terms, etc.). Among them, the successful response may include: being clicked, selected, collected, saved, downloaded, etc. by the user.

[0107] Step 302: Determine a matching interface call instruction according to the valid search results;

[0108] On the basis of step 301, this step aims at enabling the execution subject to determine the matching interface calling instruction according to the effective search result.

[0109] Step 303: replace part or all of the result contents in the valid search results that can be returned by executing the interface call instruction with the corresponding interface call instruction to obtain an output result;

[0110] Based on step 302, this step aims to replace part or all of the result content in the effective search results that can be returned by executing the interface call instruction with the corresponding interface call instruction to obtain the output result.

[0111] For the output result given in the above example, "Character (A), height Transform (7ft 6in, Meter), British system is 7 feet 6 inches", most of the result content is replaced with corresponding interface call instructions; and for the output result given in the above example, "A is a famous basketball player, height Transform (7ft 6in, Meter), British system is 7 feet 6 inches, and he is one of the tallest basketball players", part of the result content is replaced with corresponding interface call instructions.

[0112] Step 304: construct a first training set based on sample pairs consisting of user query texts and matching output results.

[0113] Based on step 303, this step aims to construct the first training set from a plurality of sample pairs of “user query text—output result”.

[0114] Please refer to Figure 4 , Figure 4 A flowchart of a method for constructing a first training set based on sample pairs consisting of user query text and matching output results provided in an embodiment of the present disclosure, that is, for Figure 3 Step 304 in the process 300 shown provides a specific implementation method, and other steps in the process 300 are not adjusted. The specific implementation method provided in this embodiment is replaced by step 304 to obtain a new complete embodiment. The process 400 includes the following steps:

[0115] Step 401: Generate a new search session according to the user query text and the matching output results;

[0116] Step 402: taking the first user query text and the first output result in the new search session as a starting sample pair;

[0117] Step 403: taking all conversation contents before the non-first output result in the new search session and the non-first output result as non-starting sample pairs;

[0118] For a new search session that behaves like this:

[0119] User A: "User query text 1";

[0120] Search engine: "Contains output result 1 of interface call instruction";

[0121] User A: "User query text 2";

[0122] Search engine: "Contains output results 2 of interface call instructions";

[0123] User A: "User query text 3";

[0124] Search engine: "Contains output results 3 of interface call instructions".

[0125] Then the first sample pair consists of: "user query text 1" and "output result 1 containing interface call instructions";

[0126] Then the second sample pair is composed of "user query text 1 + output result 1 containing interface call instructions + user query text 2" and "output result 2 containing interface call instructions";

[0127] Then the third sample pair is composed of “user query text 1+output result 1 containing interface call instructions+user query text 2+output result 2 containing interface call instructions+user query text 3” and “output result 3 containing interface call instructions”.

[0128] That is, by constructing sample pairs in the above manner, the model trained thereby can fully combine the previous context of the conversation to generate subsequent conversations.

[0129] Step 404: construct a first training set based on the starting sample pairs and the non-starting samples.

[0130] That is, for the new search session shown above, a total of three training samples can be extracted, and the first training set is constructed based on them.

[0131] Please refer to Figure 5 , Figure 5 A flowchart of a method for constructing a second training set provided in an embodiment of the present disclosure, that is, for Figure 2Step 203 in the process 200 shown provides a specific implementation method, and the other steps in the process 200 are not adjusted. The specific implementation method provided in this embodiment is replaced by step 203 to obtain a new complete embodiment. The process 500 includes the following steps:

[0132] Step 501: Obtain search terms from the search log;

[0133] Step 502: confirm all search results returned for the same search term from the search log, and determine the cumulative number of clicks on each search result within a time window;

[0134] Step 503: Generate multiple sample pairs for the same search term and each search result, and determine the ranking information between the corresponding different sample pairs according to the accumulated number of clicks corresponding to the different search results;

[0135] Step 504: construct a second training set based on each sample pair sorted by user preference according to the sorting information and each preset template recording the corresponding relationship between the input text and the corresponding output text containing the interface call instruction.

[0136] To facilitate understanding of the solution provided by this embodiment, the following will be described in detail through another example:

[0137] Assume that there is a query (i.e. the user query text mentioned above) called "Phoenix". Aggregate the number of clicks on different results of this query within a period of time (for example, 30 days). Assume that the following results are obtained as shown in Table 1:

[0138] Table 1 Statistics of cumulative click counts

[0139] Result No. result Total number of clicks r1 The origin of Phoenix 100 r2 Phoenix Totem 10 r3 Phoenix Ancient Town 9 r4 Phoenix College 8

[0140] Then the paired samples that can be constructed according to the above table can be:

[0141] rel(q,r1)>rel(q,r2);

[0142] rel(q,r1)>rel(q,r3);

[0143] rel(q,r1)>rel(q,r4);

[0144] rel(q,r2)>rel(q,r3);

[0145] rel(q,r2)>rel(q,r4);

[0146] rel(q,r3)>rel(q,r4), rel is a function used to express the user preference between the two.

[0147] Based on the above information, the second training set is automatically constructed by combining the query-answer template consisting of the user query text and the matching output results containing the interface call instructions, as well as the pairwise relationship given above.

[0148] The query-answer template may include:

[0149] What is [String] - According to the query and summary, [String] is What(String);

[0150] [String]'s information - Based on the query and summary, [String] has the following information: Information (String);

[0151] [String] How much is the US dollar equivalent to RMB - According to the current exchange rate, [String] US dollars is Converter (String, fromUSD, toYuan) RMB;

[0152] What's the weather like at [Address]? - According to official weather forecast information, [Address] Weather (Loc (Address)), etc.

[0153] The following takes the template "What is [String1] - According to the query and summary, [String1] is What (String2)" as an example. It can be seen that "String1" in the template corresponds to the query (i.e. Phoenix) entered by the user, and "String2" corresponds to the text of the result clicked by the user:

[0154] rel(prompt=What is Phoenix, a1=According to the query and summary, Phoenix is ​​What (Origin of Phoenix))>rel(prompt=What is Phoenix, a2=According to the query and summary, Phoenix is ​​What (Phoenix Totem));

[0155] rel(prompt=What is Phoenix, a1=According to the query and summary, Phoenix is ​​What (Origin of Phoenix))>rel(prompt=What is Phoenix, a3=According to the query and summary, Phoenix is ​​What (Ancient Town of Phoenix));

[0156] rel(prompt=What is Phoenix, a1=According to the query and summary, Phoenix is ​​What(Origin of Phoenix))>rel(prompt=What is Phoenix, a4=According to the query and summary, Phoenix is ​​What(Phoenix Academy));

[0157] rel(prompt=What is Phoenix, a2=According to the query and summary, Phoenix is ​​What (Phoenix Totem))>rel(prompt=What is Phoenix, a3=According to the query and summary, Phoenix is ​​What (Phoenix Ancient Town));

[0158] rel(prompt=What is Phoenix, a2=According to the query and summary, Phoenix is ​​What(Phoenix Totem))>rel(prompt=What is Phoenix, a4=According to the query and summary, Phoenix is ​​What(Phoenix Academy));

[0159] rel(prompt=What is Phoenix, a3=According to the query and summary, Phoenix is ​​What(Phoenix Ancient Town))>rel(prompt=What is Phoenix, a4=According to the query and summary, Phoenix is ​​What(Phoenix College)).

[0160] In the above example, prompt is generated based on query and template, and ai is generated based on ri and template (that is, when i is 1, a1 is generated based on r1 and template).

[0161] The similar situation of "Phoenix Information" is similar to the above and will not be listed here one by one.

[0162] By automatically generating the second training set using the data recorded in the retrieval log, not only a lot of manual labeling costs are saved, but the massive click and skip (non-click) data in the retrieval log is a completely real reflection of user needs, and it truly reflects the distribution of user preferences for different results, thereby making the constructed second training set more in line with the actual needs of users.

[0163] The above embodiments explain how to train a target generative large language model from various aspects. In order to highlight the effect of the trained target generative large language model from the actual usage scenario as much as possible, the present disclosure also specifically provides a solution for using the trained target generative large language model to solve practical problems, such as Figure 6 The search method based on a generative large language model shown includes the following steps:

[0164] Step 601: Obtain the user query text entered by the user in the search bar;

[0165] This step is intended to be performed by an execution subject of the search method based on a generative large language model (for example, installed in Figure 1 The search application on the terminal devices 101, 102, 103 shown in the figure) obtains the user query text entered by the user in the provided search bar.

[0166] Specifically, the search bar includes: a search bar provided by a web version search engine, a search bar provided by an application version search engine, and the applications of the application version search engine include: a single search application (i.e., an application that only has a search function), and a composite function application that includes a search function (i.e., a multi-function application that includes other functions in addition to a search function).

[0167] Step 602: inputting the user query text as input data into a preset target generative large language model;

[0168] On the basis of step 601, this step aims to have the above-mentioned execution subject input the user query text as input data into a preset target generative large language model, so as to call the target generative large language model to process the user query text.

[0169] Step 603: receiving the query result text returned by the target generative large language model;

[0170] On the basis of step 602, this step is intended to receive the query result text returned by the target generative large language model by the above-mentioned execution subject. Among them, the query result text is generated based on the response information obtained after executing the interface call instruction. That is, the target generative large language model starts to generate a text sequence after receiving the input user query text. When there is no need to generate an interface call instruction, the corresponding reply text will be directly generated according to the knowledge contained in the large model parameters. When it is necessary to call the corresponding service interface, the interface call instruction is automatically generated and executed to obtain the returned call result, and the query result text generated based on the generated reply text and the call result is returned to the search engine. That is, the generation and execution of the interface call instruction (API and its parameters) are automatically completed in the process of generating the output text by the target generative large language model.

[0171] Taking the interface call instruction "Transform(7ft 6in,Meter)" as an example, after executing the interface call instruction, you can get the query result text such as: "7ft 6in is 7 feet 6 inches in the British system, corresponding to 2.26 meters"; taking the interface call instructions "Character(A)" and "Transform(7ft 6in,Meter)" as examples, after executing these two interface call instructions respectively, you can also reorganize to get the query result text such as: "A is a famous basketball player, his height is 2.26 meters, corresponding to 7 feet 6 inches in the British system, and he is one of the tallest basketball players." It should be noted that the above query result text is a plain text result generated based on the text response information returned after calling the corresponding API. Furthermore, if you want to include other formats (such as images, hypertext containing links, etc.) in addition to text information, you can also expand the format set of supported output results so that you can return multi-format output information including text format.

[0172] The search method based on the generative large language model provided in this embodiment is specifically aimed at the scenario where the search engine acts as the execution subject, and the target generative large language model trained according to the above training scheme is applied to the search scenario. After the search engine inputs the user query text into the target generative large language model, it generates corresponding results with the help of the capabilities of the target generative large language model, and automatically generates interface call instructions and executes them to obtain the returned call results when encountering the need to call the service interface, and returns the query result text generated based on the generated reply text and the call result to the search engine, so that the user can directly obtain the query result text that meets his search needs, thereby improving the accuracy of the search results and the search efficiency.

[0173] In order to prevent the target generative large language model from outputting the same format of output results for user query texts with different expressions, the generated query result texts may also be adjusted to different expressions that express the same meaning.

[0174] One expression method may be: adjusting the generated query result text to a random expression method expressing the same meaning, that is, randomly selecting an expression method from the expression library for expression adjustment each time output. The expression methods may be divided into: lively, ordinary, concise, comprehensive, etc.;

[0175] Another way of expression may be to adjust the generated query result text to express the same meaning and the same expression as the user query text, that is, to make the query result text use the same expression as the user query text to enhance the user's experience of the query result text.

[0176] To further deepen the understanding of the solution provided by the present disclosure, the following will also be Figure 7 A schematic diagram of a search interaction process for a specific example is shown below:

[0177] 1) The search engine receives the text entered by the user in the search bar: "How much is one thousand US dollars in RMB";

[0178] 2) The search engine inputs the text “How much is one thousand US dollars in RMB” into the pre-trained target generative language model;

[0179] 3) The target generative large language model first generates an interface call instruction of Number(Str) to return a value according to the text, specifically generating Number(one thousand) to obtain the return value: 1000;

[0180] 4) The target generative large language model then generates the interface call instruction of Trans(From, To, Number) to convert the exchange rate according to the source currency (corresponding to From), the destination currency (corresponding to To) and the value (corresponding to Number), and specifically generates Trans(US dollars, RMB, 1000) and obtains the return value: 6950;

[0181] 5) The search engine obtains the query result text generated based on the return value: "According to the real-time exchange rate, currently 1,000 US dollars can be converted into 6,950 RMB."

[0182] Further references Figure 8 and Fig. 9 As an implementation of the methods shown in the above figures, the present disclosure provides an embodiment of a generative large language model training device and an embodiment of a search device based on a generative large language model. Figure 2 Corresponding to the embodiment of the generative large language model training method shown in FIG, the search device embodiment based on the generative large language model is Figure 6 The above device can be applied to various electronic devices.

[0183] like Figure 8As shown, the generative large language model training device 800 of this embodiment may include: a first training set construction unit 801, a supervised fine-tuning training unit 802, a second training set construction unit 803, a reward model training unit 804, and a reinforcement learning training unit 805. Among them, the first training set construction unit 801 is configured to construct a first training set based on the user query text and the matched output result containing the interface call instruction; wherein the service interface called by the interface call instruction corresponds to the functional usage intention expressed by the user query text; the supervised fine-tuning training unit 802 is configured to use the first training set to perform supervised fine-tuning training on the pre-trained first generative large language model to obtain a second generative large language model; the second training set construction unit 803 is configured to construct a second training set based on the user preference ranking and preset template set between the same user query text and different candidate outputs; the reward model training unit 804 is configured to use the second training set to perform supervised training on the pre-trained third generative large language model to obtain a reward model; the reinforcement learning training unit 805 is configured to train the second generative large language model in a reinforcement learning manner based on the score returned by the reward model to obtain a target generative large language model.

[0184] In this embodiment, in the generative large language model training device 800, the specific processing of the first training set construction unit 801, the supervised fine-tuning training unit 802, the second training set construction unit 803, the reward model training unit 804, and the reinforcement learning training unit 805 and the technical effects thereof can be referred to respectively. Figure 2 The relevant descriptions of steps 201 - 205 in the corresponding embodiment are not repeated here.

[0185] In some optional implementations of this embodiment, the first training set construction unit 801 may include:

[0186] An effective search result determination subunit is configured to obtain a search session and determine effective search results that successfully respond to a user query text in the search session;

[0187] The interface call instruction determination subunit is configured to determine a matching interface call instruction according to the effective search results;

[0188] The output result generating subunit is configured to replace part or all of the result contents in the effective search results that can be returned by executing the interface calling instruction with the corresponding interface calling instruction to obtain the output result;

[0189] The first training set construction subunit is configured to construct a first training set based on sample pairs consisting of user query texts and matching output results.

[0190] In some optional implementations of this embodiment, the first training set construction subunit may be further configured to:

[0191] Generate a new search session based on the user query text and the matching output results;

[0192] The first user query text and the first output result in the new search session are taken as the starting sample pair;

[0193] All session contents and non-first output results in the new search session before the non-first output result are taken as non-starting sample pairs;

[0194] A first training set is constructed based on the starting sample pairs and non-starting samples.

[0195] In some optional implementations of the present embodiment, under a supervised fine-tuning training method, for new language units representing service interfaces that do not appear in the first generative large language model, parameter sampling of features of the new language units is initialized according to the multivariate normal distribution of features of existing language units.

[0196] In some optional implementations of this embodiment, the second training set construction unit 803 may be further configured to:

[0197] Get search terms from search logs;

[0198] Confirm all search results returned for the same search term from the search log, and determine the cumulative number of clicks on each search result within a time window;

[0199] Generate multiple sample pairs with the same search term and each search result, and determine the ranking information between the corresponding different sample pairs according to the accumulated number of clicks corresponding to the different search results;

[0200] A second training set is constructed based on each sample pair sorted by user preference according to the sorting information and each preset template recording the corresponding relationship between the input text and the corresponding output text containing the interface call instruction.

[0201] This embodiment exists as an apparatus embodiment corresponding to the above-mentioned method embodiment. The generative large language model training apparatus provided by this embodiment, since the first training set is constructed by the user query text and the output result containing the interface call instruction expressing the corresponding function usage intention, the pre-trained first generative large language model is fine-tuned in a supervised manner through the first training set, so that the trained second generative large language model has the ability to rewrite the user query text into a matching output result containing the interface call instruction, and the pre-trained third generative large language model is supervisedly trained by the second training set constructed by the user preference ranking between the same user query text and different candidate outputs, so that the trained reward model has the ability to perform quality scoring for different candidates generated by the generative large language model for the user query text, so that under the training of reinforcement learning based on human feedback, the target generative large language model finally obtained not only has the ability to rewrite the user query text into a matching output result containing the interface call instruction, but also has the ability to output results that better meet user needs. That is, through the above training scheme, the trained target generative large language model has the ability to deeply understand user needs and construct corresponding interface call instructions to query and return accurate answers. It can not only generate natural language output based on natural language input and the knowledge contained in the large model parameters, but also call the corresponding functions with the help of application program interfaces that provide professional capabilities to more effectively solve user needs. Under the influence of the reward model, the returned results will be more in line with the actual needs and expectations of users.

[0202] like Fig. 9 As shown, the search device 900 based on the generative large language model of this embodiment may include: a user query text acquisition unit 901, a model calling unit 902, and a query result text receiving unit 903. The user query text acquisition unit 901 is configured to acquire the user query text input by the user in the search bar; the model calling unit 902 is configured to input the user query text as input data into the preset target generative large language model; the query result text receiving unit 903 is configured to receive the query result text returned by the target generative large language model; wherein the query result text is generated based on the response information obtained after executing the interface calling instruction.

[0203] In this embodiment, in the search device 900 based on the generative large language model, the specific processing of the user query text acquisition unit 901, the model calling unit 902, and the query result text receiving unit 903 and the technical effects brought by them can correspond to Figure 6 The relevant descriptions in the illustrated method embodiment will not be repeated here.

[0204] In some optional implementations of this embodiment, the search device 900 based on the generative large language model may further include:

[0205] The expression adjustment unit is configured to adjust the query result text into different expressions that express the same meaning.

[0206] In some optional implementations of this embodiment, the expression adjustment unit may be further configured to:

[0207] Adjust the query result text to a random expression that expresses the same meaning.

[0208] In some optional implementations of this embodiment, the expression adjustment unit may be further configured to:

[0209] Adjust the query result text to express the same meaning and in the same way as the user query text.

[0210] In some optional implementations of this embodiment, the search bar includes: a search bar provided by a web version search engine, a search bar provided by an application version search engine, and the applications of the application version search engine include: a single search application, and a composite function application including a search function.

[0211] This embodiment exists as an apparatus embodiment corresponding to the above-mentioned method embodiment. The search scheme based on the generative large language model provided by this embodiment is specifically for the scenario where the search engine acts as the execution subject. The target generative large language model trained according to the above-mentioned training scheme is applied to the search scenario. After the search engine inputs the user query text into the target generative large language model, it generates corresponding results with the help of the capabilities of the target generative large language model, and automatically generates interface call instructions and executes them to obtain the returned call results when encountering the need to call the service interface, and returns the query result text generated based on the generated reply text and the call result to the search engine, so that the user can directly obtain the query result text that meets their search needs, thereby improving the accuracy of the search results and the search efficiency.

[0212] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can implement the generative large language model training method described in any of the above embodiments and / or the search method based on the generative large language model when executing.

[0213] According to an embodiment of the present disclosure, the present disclosure also provides a readable storage medium, which stores computer instructions, and the computer instructions are used to enable a computer to implement the generative large language model training method and / or the search method based on the generative large language model described in any of the above embodiments when executed.

[0214] The embodiments of the present disclosure provide a computer program product, which, when executed by a processor, can implement the generative large language model training method and / or the search method based on the generative large language model described in any of the above embodiments.

[0215] Fig.10 A schematic block diagram of an example electronic device 1000 that can be used to implement an embodiment of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.

[0216] like Fig.10 As shown, the device 1000 includes a computing unit 1001, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 1002 or a computer program loaded from a storage unit 1008 into a random access memory (RAM) 1003. In the RAM 1003, various programs and data required for the operation of the device 1000 can also be stored. The computing unit 1001, the ROM 1002, and the RAM 1003 are connected to each other via a bus 1004. An input / output (I / O) interface 1005 is also connected to the bus 1004.

[0217] A number of components in the device 1000 are connected to the I / O interface 1005, including: an input unit 1006, such as a keyboard, a mouse, etc.; an output unit 1007, such as various types of displays, speakers, etc.; a storage unit 1008, such as a disk, an optical disk, etc.; and a communication unit 1009, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 1009 allows the device 1000 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.

[0218] The computing unit 1001 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 1001 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 1001 performs the various methods and processes described above, such as a generative large language model training method and / or a search method based on a generative large language model. For example, in some embodiments, a generative large language model training method and / or a search method based on a generative large language model may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 1008. In some embodiments, part or all of the computer program may be loaded and / or installed on the device 1000 via ROM 1002 and / or communication unit 1009. When the computer program is loaded into RAM 1003 and executed by the computing unit 1001, one or more steps of the generative large language model training method and / or the search method based on the generative large language model described above may be performed. Alternatively, in other embodiments, the computing unit 1001 may be configured to execute the generative large language model training method and / or the search method based on the generative large language model by any other appropriate means (e.g., by means of firmware).

[0219] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0220] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.

[0221] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0222] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).

[0223] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.

[0224] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship between the client and the server is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and virtual private servers (VPS) services.

[0225] The generative large language model training scheme provided by the embodiment of the present disclosure has a first training set constructed by a user query text and an output result containing an interface call instruction that expresses the corresponding function usage intention, so that the pre-trained first generative large language model is fine-tuned in a supervised manner through the first training set, so that the trained second generative large language model has the ability to rewrite the user query text into a matching output result containing the interface call instruction, and the pre-trained third generative large language model is supervisedly trained with a second training set constructed by a user preference ranking and a preset template set between the same user query text and different candidate outputs, so that the trained reward model has the ability to perform quality scoring for different candidates generated by the generative large language model for the user query text, so that under the training of reinforcement learning based on human feedback, the target generative large language model finally obtained not only has the ability to rewrite the user query text into a matching output result containing the interface call instruction, but also has the ability to output results that better meet user needs. That is, through the above training scheme, the trained target generative large language model has the ability to deeply understand user needs and construct corresponding interface call instructions to query and return accurate answers. It can not only generate natural language output based on natural language input and the knowledge contained in the large model parameters, but also call the corresponding functions with the help of application program interfaces that provide professional capabilities to more effectively solve user needs. Under the influence of the reward model, the returned results will be more in line with the actual needs and expectations of users.

[0226] Based on the beneficial effects of the generative large language model training scheme provided in the above-mentioned embodiments, the search method based on the generative large language model provided in the embodiments of the present disclosure is specifically aimed at the scenario in which the search engine acts as the execution subject, and the target generative large language model trained according to the above-mentioned training scheme is applied to the search scenario. After the search engine inputs the user query text into the target generative large language model, it generates corresponding results with the help of the capabilities of the target generative large language model, and automatically generates interface call instructions and executes them to obtain the returned call results when encountering the need to call the service interface, and returns the query result text generated based on the generated reply text and the call result to the search engine, so that the user can directly obtain the query result text that meets their search needs, thereby improving the accuracy of the search results and the search efficiency.

[0227] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.

[0228] The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.

Claims

1. A generative large language model training method, comprising: Acquire a search session, and determine valid search results that successfully respond to a user query text in the search session, and determine an interface call instruction that matches the valid search results; replace part or all of the result content in the valid search results that can be returned by executing the interface call instruction with the corresponding interface call instruction to obtain an output result; generate a new search session according to the user query text and the matching output result; and use the first user query text and the first output result in the new search session as a starting sample pair; All the conversation contents before the non-first output result in the new search conversation and the non-first output result are used as non-starting sample pairs; a first training set is constructed based on the starting sample pairs and the non-starting samples, wherein the service interface called by the interface calling instruction corresponds to the functional usage intention expressed by the user query text; Using the first training set to perform supervised fine-tuning training on the pre-trained first generative large language model, a second generative large language model is obtained; in the supervised fine-tuning training mode, the features of the new language unit representing the service interface that does not appear in the first generative large language model are initialized by parameter sampling according to the multivariate normal distribution of the features of the existing language units; Constructing a second training set based on user preference rankings between the same user query text and different candidate outputs and a preset template set, wherein the candidate output is an output that matches the user query text, and the preset template set includes preset templates that record the corresponding relationship between the input text and the corresponding interface call instruction; The second training set is used to perform supervised training on the pre-trained third generative large language model to obtain a reward model; The second generative large language model is trained in a reinforcement learning manner based on the score returned by the reward model to obtain a target generative large language model.

2. The method according to claim 1, wherein: The second training set is constructed based on the user preference ranking between the same user query text and different candidate outputs and the preset template set, including: Get search terms from search logs; Confirming all search results returned for the same search term from the search log, and determining the cumulative number of clicks on each search result within a time window; Generate multiple sample pairs with the same search term and each search result, and determine the ranking information between the corresponding different sample pairs according to the accumulated number of clicks corresponding to the different search results; A second training set is constructed based on each sample pair sorted by user preference according to the sorting information and each preset template recording the correspondence between the input text and the corresponding output text containing the interface call instruction; wherein the preset template set is composed of the preset templates.

3. A search method based on a generative large language model, comprising: Get the user query text entered by the user in the search bar; Inputting the user query text as input data into a target generative large language model; wherein the target generative large language model is obtained based on the generative large language model training method according to claim 1 or 2; Receive the query result text returned by the target generative large language model; wherein the query result text is generated based on the response information obtained after executing the interface call instruction.

4. The method according to claim 3, further comprising: The query result text is adjusted to express different expressions with the same meaning.

5. The method according to claim 4, wherein: The adjusting the query result text to different expressions expressing the same meaning includes: The query result text is adjusted to a random expression that expresses the same meaning.

6. The method according to claim 4, wherein: The adjusting the query result text to different expressions expressing the same meaning includes: The query result text is adjusted to express the same meaning and in the same expression as the user query text.

7. The method according to any one of claims 3 to 6, wherein: The search bar includes: a search bar provided by a web version search engine, a search bar provided by an application version search engine, and the applications of the application version search engine include: a single search application, and a composite function application including a search function.

8. A generative large language model training device, comprising: The first training set construction unit is configured to obtain a search session, determine valid search results that successfully respond to a user query text in the search session, and determine an interface call instruction that matches the valid search result; replace part or all of the result content in the valid search result that can be returned by executing the interface call instruction with the corresponding interface call instruction to obtain an output result; generate a new search session according to the user query text and the matching output result; and use the first user query text and the first output result in the new search session as a starting sample pair; All the conversation contents before the non-first output result in the new search conversation and the non-first output result are used as non-starting sample pairs; a first training set is constructed based on the starting sample pairs and the non-starting samples, wherein the service interface called by the interface calling instruction corresponds to the functional usage intention expressed by the user query text; The supervised fine-tuning training unit is configured to perform supervised fine-tuning training on the pre-trained first generative large language model using the first training set to obtain a second generative large language model; in the supervised fine-tuning training mode, the features of the new language unit representing the service interface that does not appear in the first generative large language model are initialized by parameter sampling according to the multivariate normal distribution of the features of the existing language units; A second training set construction unit is configured to construct a second training set based on a user preference ranking between the same user query text and different candidate outputs and a preset template set, wherein the candidate output is an output matching the user query text, and the preset template set includes preset templates recording a corresponding relationship between an input text and a corresponding interface call instruction; A reward model training unit is configured to perform supervised training on the pre-trained third generative large language model using the second training set to obtain a reward model; The reinforcement learning training unit is configured to train the second generative large language model in a reinforcement learning manner based on the score returned by the reward model to obtain a target generative large language model.

9. The device according to claim 8, wherein: The second training set construction unit is further configured to: Get search terms from search logs; Confirming all search results returned for the same search term from the search log, and determining the cumulative number of clicks on each search result within a time window; Generate multiple sample pairs with the same search term and each search result, and determine the ranking information between the corresponding different sample pairs according to the accumulated number of clicks corresponding to the different search results; A second training set is constructed based on each sample pair sorted by user preference according to the sorting information and each preset template recording the correspondence between the input text and the corresponding interface call instruction; wherein the preset template set is composed of the preset templates.

10. A search device based on a generative large language model, comprising: A user query text acquisition unit is configured to acquire the user query text entered by the user in the search bar; A model calling unit is configured to input the user query text as input data into a preset target generative large language model; wherein the target generative large language model is obtained based on the generative large language model training device according to claim 8 or 9; The query result text receiving unit is configured to receive the query result text returned by the target generative large language model; wherein the query result text is generated based on the response information obtained after executing the interface call instruction.

11. The apparatus according to claim 10, further comprising: The expression adjustment unit is configured to adjust the query result text into different expressions that express the same meaning.

12. The device according to claim 11, wherein The expression adjustment unit is further configured to: The query result text is adjusted to a random expression that expresses the same meaning.

13. The device according to claim 11, wherein: The expression adjustment unit is further configured to: The query result text is adjusted to express the same meaning and in the same expression as the user query text.

14. The device according to any one of claims 10 to 13, wherein: The search bar includes: a search bar provided by a web version search engine, a search bar provided by an application version search engine, and the applications of the application version search engine include: a single search application, and a composite function application including a search function.

15. An electronic device, comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the generative large language model training method described in claim 1 or 2 and / or the search method based on the generative large language model described in any one of claims 3-7.

16. A non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to enable a computer to execute the generative large language model training method described in claim 1 or 2 and / or the search method based on the generative large language model described in any one of claims 3-7.

17. A computer program product, comprising a computer program, which, when executed by a processor, implements the steps of the generative large language model training method according to claim 1 or 2 and / or the steps of the search method based on the generative large language model according to any one of claims 3-7.

Citation Information

Patent Citations

  • Migration method and device for neural network training calculation

    CN111562988A

  • Machine translation using neural network models

    US20200034436A1

  • System and method for interactive dialogue

    US20230055991A1