Large language model training method, correlation discrimination method and related device
By combining correlation tasks and general language tasks in large language models, the limitations of existing search correlation discrimination techniques in terms of accuracy and interpretability are solved, and more efficient and interpretable search results sorting is achieved.
Patent Information
- Application Number
- CN202411775093.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-04
- Publication Date
- 2025-04-08
- Estimated Expiration
- 2044-12-04
AI Technical Summary
Existing search correlation discrimination techniques have limitations in application scenarios and interpretability, and it is difficult to provide high accuracy and interpretable search results sorting.
Through the training method of the large language model, combined with correlation tasks and general language tasks, the ability of the large language model in content understanding, generalization, reasoning, etc. is improved, thereby improving the accuracy and interpretability of search correlation judgments.
It realizes a more accurate understanding and explanation of the relationship between user query and search results, and improves the accuracy of search correlation judgment and the interpretability of recommendation engines.
Smart Images

Figure CN119782524A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of artificial intelligence technology, and in particular to technical fields such as intelligent search, intelligent recommendation, deep learning, and large models, and can be used in application scenarios such as generative search, intelligent document editing, intelligent assistants, virtual assistants, and intelligent e-commerce. Background Art
[0002] Search relevance refers to the degree of relevance between user queries and search results in the field of information retrieval, thereby providing search results that best match user intent. The search relevance model aims to quantify the degree of match between search results and user intent, and to filter and sort search results based on the relevance probability score.
[0003] Search relevance determination is a crucial part of search engines, which can directly affect the quality of search results and user experience. Summary of the invention
[0004] The present disclosure provides a large language model training method, a relevance determination method and related devices.
[0005] According to one aspect of the present disclosure, a method for training a large language model is provided, comprising:
[0006] Obtaining a first type of task sample and a second type of task sample, wherein the task type of the first type of task sample is a relevance task, and the relevance task is used to determine search relevance; and the task type of the second type of task sample is a general language task;
[0007] The task type that the large language model needs to perform is prompted based on the task instructions, so that the large language model can be trained based on samples of different task types.
[0008] According to one aspect of the present disclosure, a correlation determination method is provided, comprising:
[0009] Get user queries and search results;
[0010] Constructing a prompt word based on the user query and the search result; the prompt word includes a task instruction that prompts the large language model to perform a correlation task;
[0011] The prompt word is input into the large language model to obtain a prediction result of the large language model for the search relevance between the user query and the search result, and a reason for generating the result.
[0012] According to another aspect of the present disclosure, a large language model training device is provided, comprising:
[0013] A first acquisition module is used to acquire a first type of task sample and a second type of task sample, wherein the task type of the first type of task sample is a correlation task, and the correlation task is used to determine search correlation; and the task type of the second type of task sample is a general language task;
[0014] The training module is used to prompt the large language model with the task type to be performed based on the task instructions, so as to train the large language model based on samples of different task types.
[0015] According to another aspect of the present disclosure, there is provided a correlation determination device, comprising:
[0016] The second acquisition module is used to obtain user queries and search results;
[0017] A construction module, configured to construct a prompt word based on the user query and the search result; the prompt word includes a task instruction prompting the large language model to perform a relevance task;
[0018] A processing module is used to input the prompt word into the large language model, obtain the prediction result of the large language model for the search relevance between the user query and the search result, and generate a reason.
[0019] According to another aspect of the present disclosure, there is provided an electronic device, comprising:
[0020] at least one processor; and
[0021] a memory communicatively connected to the at least one processor; wherein,
[0022] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute any method in the embodiments of the present disclosure.
[0023] According to another aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to enable the computer to execute any method according to the embodiments of the present disclosure.
[0024] According to another aspect of the present disclosure, a computer program product is provided, including a computer program, which implements any method according to the embodiments of the present disclosure when executed by a processor.
[0025] In the disclosed embodiment, by learning general language tasks, it is possible to fully tap the general capabilities of the large language model in content understanding, generalization, reasoning, etc., and then transfer these general capabilities to the search relevance judgment task, which can improve the accuracy of search relevance judgment.
[0026] 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
[0027] The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present disclosure.
[0028] Figure 1 is a flowchart of a method for training a large language model provided according to an embodiment of the present disclosure;
[0029] Figure 2 is a schematic diagram of a process of determining dirty samples in a first sample set according to an embodiment of the present disclosure;
[0030] Figure 3 is a schematic diagram of search results provided according to an embodiment of the present disclosure;
[0031] Figure 4 is a schematic diagram of a process for determining a clean sample in a second sample set according to an embodiment of the present disclosure;
[0032] Figure 5 is a schematic diagram of a process for training a large language model according to an embodiment of the present disclosure;
[0033] Figure 6 is a schematic diagram of the architecture of a large language model provided according to an embodiment of the present disclosure;
[0034] Figure 7 is a schematic diagram of prompt information of a large language model provided according to an embodiment of the present disclosure;
[0035] Figure 8 is a flowchart of a correlation determination method provided according to an embodiment of the present disclosure;
[0036] Fig. 9 is a schematic diagram of a training device for a large language model provided according to an embodiment of the present disclosure;
[0037] Fig.10 is a schematic diagram of the structure of a correlation determination device provided according to an embodiment of the present disclosure;
[0038] Fig.11 The present invention is a block diagram of an electronic device used to implement the large language model training method and / or relevance determination method of the embodiments of the present disclosure. DETAILED DESCRIPTION
[0039] 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 of the present disclosure. Similarly, for the sake of clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0040] The terms "first", "second", etc. in this disclosure are used to distinguish similar objects, and are not necessarily used to describe a specific order or precedence. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, including a series of steps or units. The method, system, product or device is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0041] In search engines, information relevance discrimination networks can be used to identify the search relevance between user queries and search results. For example, the bidirectional encoder representation from transformers (BERT) model can be used to map query terms and documents into vectors, and then calculate the inner product to obtain the relevance score.
[0042] However, the search relevance obtained based on the traditional information relevance discrimination network has limited application scenarios and is not interpretable. Therefore, the correlation between information can be analyzed based on a large language model and reasons can be provided to increase interpretability.
[0043] Large Language Models (LLMs) refer to a specific type of large model that is specifically designed to process text data. This type of model is a natural language processing model based on neural networks that can be used to generate, understand, and process text data. Large language models can have tens of billions of parameters, can generate high-quality text, and can be used for a variety of natural language processing tasks, such as question answering, text generation, and dialogue systems.
[0044] The large language model has good reasoning ability and small sample learning ability. The large language model can understand the model on a large scale or can be trained on a large number of samples. Based on the large language model, accurate semantic understanding can be achieved.
[0045] However, if only the correlation task used to determine the search correlation is used to train and optimize the large language model, the accuracy of its discrimination still needs to be improved. Therefore, a method for training a large language model is proposed in the embodiment of the present disclosure. By adding training of general language tasks, the method can fully tap the ability of the large language model in general language tasks to increase the discrimination accuracy of correlation tasks. Figure 1 As shown, it is a flowchart of the training method of the large language model provided by the embodiment of the present disclosure, including the following contents:
[0046] S101, obtaining a first type of task sample and a second type of task sample, wherein the task type of the first type of task sample is a relevance task, which is used to determine search relevance; and the task type of the second type of task sample is a general language task;
[0047] Among them, in the field of information retrieval, relevance tasks are used to measure the degree of relevance between user queries and search results, aiming to provide search results that match user intentions.
[0048] General language tasks refer to natural language processing tasks that are not specific to a certain field or industry. They usually involve a broad understanding and generation of language. For example, general language tasks can include natural language generation tasks such as semantic understanding, paragraph summarization, information reasoning, and text rewriting.
[0049] S102, prompting the large language model with the type of task to be performed based on the task instruction, so as to train the large language model based on samples of different task types.
[0050] Among them, by learning the correlation task and the general language task, the model capabilities learned by the large language model based on the general language task are transferred to the correlation task, so as to make full use of the general language task analysis capabilities of the large language model to improve the processing accuracy of the correlation task.
[0051] The task instruction may be an instruction instruction, which is used to distinguish different tasks.
[0052] In the disclosed embodiment, based on different task instructions, the large language model can learn the ability of general language tasks while learning to distinguish search relevance. Through the learning of general language tasks, the general capabilities of the large language model in content understanding, generalization, reasoning, etc. can be fully explored, and then these general capabilities can be transferred to the intent understanding, key point extraction, and cause induction capabilities of the search relevance discrimination task. Ultimately, the accuracy of search relevance discrimination can be further improved. At the same time, using general language tasks to train the large language model can enable the large language model to have the ability to handle different tasks, so as to achieve the ability transfer between multiple tasks.
[0053] In some embodiments, the first type of task samples includes a first sample set and a second sample set; the sample quality of the first sample set is lower than the sample quality of the second sample set, and the first sample set includes dirty samples.
[0054] The samples of the first sample set may be samples of lower quality, such as dirty samples. Dirty samples generally refer to data that does not meet the requirements and cannot be directly analyzed. In common data mining work, dirty samples refer to data examples that are incorrectly labeled.
[0055] The samples of the second sample set may be samples of higher quality, exemplarily clean samples, where clean samples refer to data instances that are not mislabeled in the data set, and they are crucial for model training, because the accuracy and robustness of the model largely depend on the quality of the training data.
[0056] During specific training, the first sample set and the second sample set may be used to alternately train the large language model. For example, the first sample set may be used in the i-th batch, and the second sample set may be used in the i+1-th batch. In addition, the first sample set and the second sample set may also be included in the same batch, which is not limited in the embodiments of the present disclosure.
[0057] In the disclosed embodiment, samples of different qualities are used to train a large language model, so that the large language model can learn the patterns of clean samples and dirty samples. Even in a low-quality sample environment, inference learning can be performed to obtain accurate search relevance discrimination results. Better knowledge can also be learned from low-quality samples to further improve the robustness of the large language model.
[0058] In some embodiments, dirty samples in the first sample set may be determined based on the following method: Figure 2 As shown, including:
[0059] S201, obtaining a first sample search request, a first sample search result recommended for the first sample search request, and a network address of the first sample search result.
[0060] Among them, the search request is the user query, which usually refers to the query entered by the user in the search engine, database, directory or other information retrieval system to find specific information or data. This request can be a simple keyword or a complex query statement, depending on the user's needs and the capabilities of the search system.
[0061] During implementation, the first sample search request is a search request used as a training sample. For the first sample search request, the recommendation engine can filter out search results for feedback to the first sample search request as first sample search results. Usually, the first sample search results will correspond to a network address, such as a landing page, which is required when constructing a dirty sample.
[0062] S202: Compress the effective information of the first sample search result to obtain the first core content of the first sample search result.
[0063] Among them, effective information compression refers to reducing data through specific algorithms and techniques while retaining the core information and value of the data.
[0064] The first core content is used to represent the important and core content of the first sample search result.
[0065] During implementation, when the first sample search result is text, a large language model can be used to extract keywords to obtain the first core content.
[0066] When the first sample search results include images, OCR (Optical Character Recognition) can be used to recognize the images to obtain text information, and the large language model can extract keywords from the text information to obtain the first core content. In addition, a multimodal large model can be used to understand the content of the image to generate text content that can describe the image, and then the first core content can be extracted from the text content.
[0067] It is understandable that corresponding core content can be extracted from information of different modalities to construct the first core content of the first sample search results. The embodiment of the present disclosure does not limit how to obtain the first core content.
[0068] S203: If labeling is required, obtain the second sample search result from the network address of the first sample search result.
[0069] The first sample search result and the second sample search result may be the same or different. For example, in a search advertising scenario, Figure 3 As shown, the first sample search request recommends the first sample search result at time point A. When constructing the training sample, while obtaining the first sample search result, the first core content is generated based on the first sample search result of its network address at time point A. Then it is stored for subsequent annotation.
[0070] There is a time difference between time point B and time point A that need to be annotated. During this period of time, the content in the network address may or may not change. At this time, the annotator obtains the second sample search result by clicking on the network address. Then there may or may not be a difference between the second sample search result and the first sample search result.
[0071] For example, for web pages affected by current events, the content update cycle is short, which may cause the content of the same network address to change. In this case, the first sample search result and the second sample search result may be different. At this time, the annotator will compare the second sample search result with the first sample search request to determine the search relevance and obtain the first label.
[0072] S204: perform labeling based on the first sample search request and the second sample search result to obtain a dirty sample consisting of the first sample search request, the first core content and the first label.
[0073] Continuing with the above example, the label obtained by annotating the second sample search result may be different from the first core content. Therefore, in this case, the labeling may not be reasonable, thereby obtaining dirty data.
[0074] In the disclosed embodiment, dirty data obtained in this manner is used to make differences in the quality of samples, thereby providing powerful sample data for subsequent large language models to learn.
[0075] In some embodiments, the clean samples in the second sample set may be determined based on the following method: Figure 4 As shown, including:
[0076] S401, obtaining a second sample search request and a snapshot of a third sample search result recommended for the second sample search request.
[0077] A snapshot is a state record of data storage at a certain moment.
[0078] During implementation, the snapshot of the third sample search result is the third sample search result obtained by searching based on the second sample search request, and the third sample search result and the current time point are stored in the form of a snapshot.
[0079] S402: Compress the effective information of the third sample search results to obtain the second core content of the third sample search results.
[0080] The specific method of performing effective information compression has been described above, and the embodiments of the present disclosure will not be repeated here.
[0081] S403: If labeling is required, labeling is performed based on the snapshot of the second sample search request and the third sample search result to obtain a clean sample consisting of the second sample search request, the second core content and the second label.
[0082] During implementation, since the snapshot of the third sample search results is stored, the annotator can annotate the snapshot of the third sample search results to obtain a label. Based on this method, the problem of the aforementioned time difference causing the label and the core content to be different can be avoided, so as to improve the quality of the training sample and obtain a clean sample.
[0083] In some embodiments, when the first type of task samples includes a first sample set and a second sample set, in order to improve the learning quality, different sample sets use different task instructions. In implementation, the task instructions of the first sample set not only prompt the large language model to learn the related task, but also prompt the large language model that the sample learned is a dirty sample;
[0084] Similarly, the task instructions of the second sample set are used to prompt the large language model to learn the relevant tasks and to prompt the large language model that the samples learned are clean samples.
[0085] Exemplarily, the task instruction of the first sample set can be a, and the task instruction of the second sample set can be b. During training, they are trained with sample instructions corresponding to other common second-category task samples for learning of the large language model.
[0086] Specifically, the task instruction of the correlation task can be set to R, then the task instruction of the first sample set can be Ra, the task instruction of the second sample set can be Rb, the task instruction of the general language task can be set to P, the task instruction of the general language task 1 can be P1, the task instruction of the general language task 2 can be P2... It should be noted that the specific form of the task instruction corresponding to each task is not limited in the embodiments of the present disclosure, and the task instructions that can be recognized by the large language model can be applicable to the embodiments of the present disclosure.
[0087] In the disclosed embodiment, task instructions are used to distinguish low-quality samples from high-quality samples, so that the large language model can learn the patterns and knowledge of samples of different qualities during the reasoning process, so as to improve the adaptability of the large language model and further improve the accuracy of search relevance.
[0088] After obtaining the samples, the large language model can be trained. In some embodiments, the large language model is trained based on the first type of task samples, such as Figure 5 As shown, it can be implemented as:
[0089] S501, constructing a first type of prompt information based on the first type of task samples; the first type of prompt information includes the third sample search request in the first type of task samples, the third core content corresponding to the third sample search request, the search intent of the third sample search request, and the task instructions corresponding to the related tasks.
[0090] The third sample search request, the third core content, the search intent, and the task instructions of the related tasks can be spliced in a preset format to obtain the first type of prompt information. The embodiment of the present disclosure does not limit the form of the first type of prompt information, as long as it meets the construction requirements of the prompt project of the large language model.
[0091] S502: training a large language model based on the first type of prompt information.
[0092] During implementation, the first type of prompt information is input into the large language model to obtain the probability score and the reason for generation. Then, it is compared with the label in the input information to obtain the loss value. If the convergence condition is met, the training of the large language model is completed. If the convergence condition is not met, the model parameters are adjusted until the convergence condition is met.
[0093] In the disclosed embodiments, a search intent that can explain the user's intention is introduced into the relevance task, so that the large language model can more accurately understand the user's search intent, thereby optimizing the quality of search relevance discrimination. For example, in search scenarios (such as advertising), the user's query terms are often affected by current hot topics, and the use of a large language model as a discrimination method is subject to the influence of the training corpus and has a certain lag constraint, which makes it difficult for the model to understand new words and hot words that have not appeared, thereby affecting the discrimination. Therefore, by introducing a sub-domain that can explain the user's intention, the large language model can more accurately understand the user's search intent, thereby optimizing the quality of search relevance discrimination.
[0094] Similarly, for general language tasks, it can be implemented as:
[0095] Step A1, constructing a second type of prompt information based on the second type of task samples; the second type of prompt information includes the second type of task samples and task instructions corresponding to the general language task.
[0096] During implementation, the second type of prompt information is input into the large language model to obtain the result generated by the generative network of the large language model, and can be compared with the generated label to optimize the model parameters.
[0097] In summary, the large language model provided by the embodiments of the present disclosure is exemplarily as follows: Figure 6The method may include a large language processing module (constructed by LLM), which performs reasoning analysis on the input prompt information and outputs a discriminant vector and a generated vector. The discriminant vector is input to the discriminant network to obtain a discriminant result of the search relevance. The generated vector is input to the generated network to output a generation reason for improving interpretability.
[0098] During implementation, in order to better learn the correlation between user queries and search results, it is necessary to fully integrate the features of the two to obtain a high-quality discriminant vector. Therefore, in the disclosed embodiment, for the first type of task samples, the prompt information of the first type of task samples also includes a first target character; the first target character is inferred by the large language model to obtain a discriminant vector; the discriminant vector is used to input the discriminant network of the large language model to discriminate the search relevance between the user query and the search results.
[0099] Among them, the first target character can be exemplarily "[CLS]", which can be understood as a special token. The character obtains a discriminant vector through reasoning of the large language model, and the discriminant vector can be used to prompt the output of the search relevance score of the third sample search request and the corresponding third core content.
[0100] In addition, the first prompt information may also include a generation reason, which can be marked in the form of "[gMASK]", which can be understood as a special token. The generation reason is used to prompt the output of the descriptive information of the correlation reason between the third sample search request and the corresponding third core content.
[0101] In the disclosed embodiment, using the target character as the content of the first category of prompt information can enable the user query and the search results to be fully integrated and reflected in the discriminant vector corresponding to the target character, so as to provide high-quality feature information for the discriminant network, thereby improving the accuracy of the search relevance score output by the discriminant network.
[0102] For example, for the relevance task, it is necessary to output the relevance score and the reason for the score. The first type of prompt information of the clean data in the first type of task sample can be:
[0103] Input: Task instruction: Relevance task-clean data, third sample search request: ```cough and phlegm```, search intent: ```users may want to find out what medicine can effectively treat cough and phlegm```. Third core content: ```Wuji Bufei Pills, Xifeng Pharmaceutical, Bufei Yiqi Zhike```. The first target character of the third sample search request and the corresponding search result: [CLS], generation reason: [gMASK].
[0104] -Output-Probability score: 0~1
[0105] -Output-Generation reason: The third sample search request: "cough and phlegm" is a respiratory disease. The network address of the search result corresponding to the third sample search request is displayed as [***] Bufei Pills product page, which can cure cough and phlegm and meet general needs.
[0106] For general language tasks, such as text summarization, it is necessary to output summary results. For example, the second type of prompt information can be:
[0107] Input: "Ma Liang, the Magic Brush" is a story in Chinese folklore. Ma Liang is a poor but kind little boy who dreams of owning a magic brush that can draw life pictures. One day, he really got such a brush, and no matter what he drew, the things in the picture would become reality. When the greedy emperor learned about it, he wanted to use Ma Liang's magic brush to satisfy his own desires. But Ma Liang was resourceful and brave. He used his wisdom and magic brush to fight against the emperor, and finally protected the people and became a folk hero." Task instructions for the general language task: Please generate a summary for the above content.
[0108] Output - Generate Summary: Ma Liang, a kind-hearted poor boy, gets a magic brush and his drawings come true. He uses his wisdom to fight against the greedy emperor, protect the people, and become a hero.
[0109] In some embodiments, for the first type of task samples, the loss used to train the large language model includes a first sub-loss and a second sub-loss;
[0110] The first sub-loss is a discriminant loss determined based on the first type of task samples; the discriminant loss is used to measure the gap between the search relevance prediction value output by the discriminant network of the large language model and the search relevance true value;
[0111] The second sub-loss is a first generation loss determined based on the first type of task samples; the first generation loss is used to measure the gap between the first generation result and the first generation label output by the generation network of the large language model for the first type of task samples.
[0112] Among them, the expression of the loss L(U) of the large language model is shown in formula (1)
[0113] L(U)=mask*αL cls (U)+(1-α)L gen (U) (1)
[0114] Wherein, when mask is 1, it is the loss corresponding to the first type of task samples; α is a hyperparameter, which can be set based on actual conditions and is not limited in the present disclosure embodiment; L cls (U) is the first sub-loss; L gen (U) is the second sub-loss, i.e., the generation loss.
[0115] L cls The specific expression of (U) is shown in formula (2):
[0116] L cls (U) = -log(softmax(F cls W cls )) (2)
[0117] Among them, F cls represents the discriminant vector, W cls Represents the parameters of the discriminant network.
[0118] The first type of task samples can be exemplarily U = {u1, ...u n ,u n+1 ,...u m}, where u1-u n is the input information, u n+1 -u m is the generated result, L gen The specific expression of (U) is shown in (3):
[0119]
[0120] Where θ is the model parameter, n and m are positive integers greater than 1, where n is less than m, and u i Generate the result for the i-th one.
[0121] In the disclosed embodiment, since the correlation tasks include generation tasks and discrimination tasks, appropriate loss functions are designed for the loss functions of the first type of task samples to determine the corresponding generation task loss and discrimination task loss, and the two loss relationships are combined to obtain the target loss relationship for training the preset large language model, which can effectively improve the model training efficiency and training effect.
[0122] In some embodiments, for the second type of task samples, the loss used to train the large language model is a second generation loss;
[0123] The second generation loss is used to measure the gap between the second generation result output by the generation network of the large language model for the second type of task samples and the second generation label.
[0124] In the implementation, in the case of the second type of task samples, the mask is 0, that is, the second generation loss is obtained, and the specific expression is shown in formula (4)
[0125] L(U)′=(1-α)L gen (U) (4)
[0126] Among them, when mask is 0, it is the loss corresponding to the second type of task samples. The meanings of other parameters are similar to the above, and the embodiments of the present disclosure will not be repeated here.
[0127] In the embodiment of the present disclosure, a corresponding loss function calculation method is provided for the second type of task samples, and a mask is used at the same time. The corresponding loss function calculation can be quickly performed based on different task instructions. Based on this method, the model training efficiency and training effect can be effectively improved.
[0128] In summary, the architecture diagram of the large language model in the embodiment of the present disclosure is as follows: Figure 7 As shown, corresponding prompt information is constructed based on the first type of task sample and / or the second type of task sample. For the first type of task sample, the prompt information includes a search request, the core content corresponding to the search request, the search intent, and the task instruction corresponding to the related task, and the task instruction is also divided into a task for indicating whether the sample is a dirty sample or a clean sample.
[0129] For the second type of task samples, the prompt information may include the text content to be processed and the task instructions corresponding to the general language task, which are used to indicate the tasks to be performed, and exemplary examples may include semantic understanding, paragraph summarization, information reasoning, etc. After the above construction is completed, the large language model is input to obtain the generated result, the discriminant vector is obtained from the vector corresponding to the generated result, and the discriminant network is input to obtain the final result.
[0130] Based on the same technical concept, a relevance discrimination method is also proposed in the embodiment of the present disclosure, which uses the large language model obtained by the aforementioned training process, such as Figure 8 As shown, including:
[0131] S801, obtaining user query and search results.
[0132] The user query and the search result are two pieces of information for which the search relevance needs to be calculated. The search result is the search result obtained by the recommendation engine for the user query.
[0133] S802, constructing prompt words based on the user query and the search results; the prompt words include task instructions that prompt the large language model to perform a related task;
[0134] The specific method of constructing the prompt words is similar to the training process, and will not be described in detail in the embodiment of the present disclosure.
[0135] S803: Input the prompt word into the large language model to obtain the prediction result of the large language model for the search relevance between the user query and the search result, and the generation reason.
[0136] For the same user query, multiple search results can be obtained, and each search result can obtain the search relevance between it and the user query based on the method provided by the embodiment of the present disclosure. Then, the multiple search results can be sorted based on the search relevance to obtain high-quality search results to recommend to the user.
[0137] The generated reason, i.e., the training result is generated based on the generated network, can be used to introduce the reason for the provided search relevance. For example, in the aforementioned example, the reason for providing Bufei Pills in AI medical treatment.
[0138] In the disclosed embodiment, search relevance is provided based on a large language model, and reasons are generated, so that the decision principle of the large language model can be more easily understood, and the accuracy and rationality of the recommendation of the recommendation engine can be improved.
[0139] In the embodiment of the present disclosure, when the first type of task samples for training the large language model include a first sample set and a second sample set, the task instruction is an instruction corresponding to the second sample set;
[0140] The sample quality of the first sample set is lower than the sample quality of the second sample set, and the first sample set includes dirty samples; the second sample set includes clean samples.
[0141] In the disclosed embodiment, different types of first sample sets and second sample sets are used for training. In the inference stage, the task instructions of the second sample set can be used for inference, so that the large language model can accurately understand the relationship between the input user query and the search results, and output accurate generation reasons and search relevance scores.
[0142] Based on the same technical concept, the present disclosure also proposes a large language model training device 900, such as Fig. 9 As shown, including:
[0143] The first acquisition module 901 is used to acquire a first type of task sample and a second type of task sample, wherein the task type of the first type of task sample is a correlation task, and the correlation task is used to determine search correlation; and the task type of the second type of task sample is a general language task;
[0144] The training module 902 is used to prompt the large language model with the task type to be performed based on the task instruction, so as to train the large language model based on samples of different task types.
[0145] In some embodiments, the first type of task samples includes a first sample set and a second sample set;
[0146] The sample quality of the first sample set is lower than the sample quality of the second sample set, and the first sample set includes dirty samples.
[0147] In some embodiments, the system further includes a first determining module configured to:
[0148] Obtaining a first sample search request, a first sample search result recommended for the first sample search request, and a network address of the first sample search result;
[0149] Compressing effective information of the first sample search results to obtain a first core content of the first sample search results;
[0150] If labeling is required, obtaining a second sample search result from the network address of the first sample search result;
[0151] The dirty sample consisting of the first sample search request, the first core content and the first label is obtained by labeling based on the first sample search request and the second sample search result.
[0152] In some embodiments, the system further includes a second determining module for:
[0153] Obtaining a second sample search request and a snapshot of a third sample search result recommended for the second sample search request;
[0154] Compressing the effective information of the third sample search result to obtain the second core content of the third sample search result;
[0155] When labeling is required, labeling is performed based on the snapshot of the second sample search request and the third sample search result to obtain the clean sample consisting of the second sample search request, the second core content and the second label.
[0156] In some embodiments, the task instruction of the first sample set is further used to prompt that the sample learned by the large language model is a dirty sample;
[0157] The task instructions of the second sample set are also used to prompt that the samples learned by the large language model are clean samples.
[0158] In some embodiments, the training module includes:
[0159] A construction unit, configured to construct a first type of prompt information based on the first type of task samples; the first type of prompt information includes a third sample search request in the first type of task samples, a third core content corresponding to the third sample search request, a search intent of the third sample search request, and a task instruction corresponding to the related task;
[0160] A training unit is used to train the large language model based on the first type of prompt information.
[0161] In some embodiments, for the first type of task samples, the loss used to train the large language model includes a first sub-loss and a second sub-loss;
[0162] The first sub-loss is a discriminant loss determined based on the first type of task samples; the discriminant loss is used to measure the gap between the search relevance prediction value output by the discriminant network of the large language model and the search relevance true value;
[0163] The second sub-loss is a first generation loss determined based on the first type of task samples; the first generation loss is used to measure the gap between the first generation result and the first generation label output by the generation network of the large language model for the first type of task samples.
[0164] In some embodiments, for the second type of task samples, the loss used to train the large language model is a second generation loss;
[0165] The second generation loss is used to measure the gap between the second generation result output by the generation network of the large language model for the second type of task samples and the second generation label.
[0166] In some embodiments, for the first type of task samples, the prompt information of the first type of task samples also includes a first target character;
[0167] The first target character is inferred by the large language model to obtain a discriminant vector;
[0168] The discriminant vector is used to input into the discriminant network of the large language model to discriminate the search relevance between the user query and the search results.
[0169] Based on the same technical concept, the embodiment of the present disclosure also proposes a correlation determination device 1000, such as Fig.10 As shown, the large language model obtained based on the above-mentioned device is applied, including:
[0170] The second acquisition module 1001 is used to acquire user query and search results;
[0171] A construction module 1002 is used to construct a prompt word based on the user query and the search result; the prompt word includes a task instruction prompting the large language model to perform a correlation task;
[0172] The processing module 1003 is used to input the prompt word into the large language model to obtain the prediction result of the large language model for the search relevance between the user query and the search result, and generate a reason.
[0173] In some embodiments, when the first type of task samples for training the large language model includes a first sample set and a second sample set, the task instruction is an instruction corresponding to the second sample set;
[0174] The sample quality of the first sample set is lower than the sample quality of the second sample set, and the first sample set includes dirty samples; the second sample set includes clean samples.
[0175] For the description of specific functions and examples of each module and submodule of the device in the embodiment of the present disclosure, reference can be made to the relevant description of the corresponding steps in the above method embodiment, which will not be repeated here.
[0176] In the technical solution disclosed herein, the acquisition, storage and application 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.
[0177] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium and a computer program product.
[0178] Fig.11 A schematic block diagram of an example electronic device 1100 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 assistants, 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.
[0179] like Fig.11 As shown, the device 1100 includes a computing unit 1101, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 1102 or a computer program loaded from a storage unit 1108 into a random access memory (RAM) 1103. In the RAM 1103, various programs and data required for the operation of the device 1100 can also be stored. The computing unit 1101, the ROM 1102, and the RAM 1103 are connected to each other via a bus 1104. An input / output (I / O) interface 1105 is also connected to the bus 1104.
[0180] A number of components in the device 1100 are connected to the I / O interface 1105, including: an input unit 1106, such as a keyboard, a mouse, etc.; an output unit 1107, such as various types of displays, speakers, etc.; a storage unit 1108, such as a disk, an optical disk, etc.; and a communication unit 1109, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 1109 allows the device 1100 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0181] The computing unit 1101 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 1101 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 1101 performs the various methods and processes described above, such as the training method and / or the relevance discrimination method of the large language model. For example, in some embodiments, the training method and / or the relevance discrimination method of the large language model may be implemented as a computer software program, which is tangibly included in a machine-readable medium, such as a storage unit 1108. In some embodiments, part or all of the computer program may be loaded and / or installed on the device 1100 via the ROM 1102 and / or the communication unit 1109. When the computer program is loaded into the RAM 1103 and executed by the computing unit 1101, one or more steps of the training method and / or the relevance discrimination method of the large language model described above may be executed. Alternatively, in other embodiments, the computing unit 1101 may be configured to execute the large language model training method and / or the relevance determination method in any other appropriate manner (for example, by means of firmware).
[0182] 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.
[0183] 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.
[0184] 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.
[0185] 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).
[0186] 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.
[0187] 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 of client and server is generated by computer programs running on respective computers and having a client-server relationship with each other. The server may be a cloud server, a server of a distributed system, or a server combined with a blockchain.
[0188] 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.
[0189] 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 principles of the present disclosure shall be included in the protection scope of the present disclosure.
Claims
1. A method for training a large language model, comprising: Acquire a first type of task sample and a second type of task sample, wherein the task type of the first type of task sample is a correlation task, and the correlation task is used to determine search correlation; The task type of the second type of task samples is general language task; The task type that the large language model needs to perform is prompted based on the task instructions, so that the large language model can be trained based on samples of different task types.
2. The method according to claim 1, wherein: The first type of task samples includes a first sample set and a second sample set; The sample quality of the first sample set is lower than the sample quality of the second sample set, and the first sample set includes dirty samples.
3. The method according to claim 2, wherein: Determine the dirty samples in the first sample set based on the following method: Obtaining a first sample search request, a first sample search result recommended for the first sample search request, and a network address of the first sample search result; Compressing effective information of the first sample search results to obtain a first core content of the first sample search results; If labeling is required, obtaining a second sample search result from the network address of the first sample search result; The dirty sample consisting of the first sample search request, the first core content and the first label is obtained by labeling based on the first sample search request and the second sample search result.
4. The method according to claim 2, wherein: Determine the clean samples in the second sample set based on the following method: Obtaining a second sample search request and a snapshot of a third sample search result recommended for the second sample search request; Compressing the effective information of the third sample search result to obtain the second core content of the third sample search result; When labeling is required, labeling is performed based on the snapshot of the second sample search request and the third sample search result to obtain the clean sample consisting of the second sample search request, the second core content and the second label.
5. The method according to claim 2, wherein: The task instruction of the first sample set is also used to prompt that the samples learned by the large language model are dirty samples; The task instructions of the second sample set are also used to prompt that the samples learned by the large language model are clean samples.
6. The method according to any one of claims 1 to 5, wherein: Training the large language model based on the first type of task samples includes: Constructing a first type of prompt information based on the first type of task samples; the first type of prompt information includes a third sample search request in the first type of task samples, a third core content corresponding to the third sample search request, a search intent of the third sample search request, and a task instruction corresponding to the related task; The large language model is trained based on the first type of prompt information.
7. The method according to any one of claims 1 to 6, wherein: For the first type of task samples, the loss used for training the large language model includes a first sub-loss and a second sub-loss; The first sub-loss is a discriminant loss determined based on the first type of task samples; the discriminant loss is used to measure the gap between the search relevance prediction value output by the discriminant network of the large language model and the search relevance true value; The second sub-loss is a first generation loss determined based on the first type of task samples; the first generation loss is used to measure the gap between the first generation result and the first generation label output by the generation network of the large language model for the first type of task samples.
8. The method according to any one of claims 1 to 7, wherein: For the second type of task samples, the loss used for training the large language model is a second generation loss; The second generation loss is used to measure the gap between the second generation result output by the generation network of the large language model for the second type of task samples and the second generation label.
9. The method according to any one of claims 1 to 8, wherein: For the first type of task samples, the prompt information of the first type of task samples also includes a first target character; The first target character is inferred by the large language model to obtain a discriminant vector; The discriminant vector is used to input into the discriminant network of the large language model to discriminate the search relevance between the user query and the search results.
10. A method for determining relevance, using a large language model obtained by the method according to any one of claims 1 to 9, comprising: Get user queries and search results; Constructing prompt words based on the user query and the search results; The prompt words include task instructions that prompt the large language model to perform a related task; The prompt word is input into the large language model to obtain a prediction result of the large language model for the search relevance between the user query and the search result, and a reason for generating the result.
11. The method according to claim 10, wherein, when the first type of task samples for training the large language model includes a first sample set and a second sample set, the task instructions are instructions corresponding to the second sample set; in, The sample quality of the first sample set is lower than that of the second sample set, and the first sample set includes dirty samples; the second sample set includes clean samples.
12. A large language model training device, comprising: A first acquisition module is used to acquire a first type of task sample and a second type of task sample, wherein the task type of the first type of task sample is a correlation task, and the correlation task is used to determine search correlation; The task type of the second type of task samples is general language task; The training module is used to prompt the large language model with the task type to be performed based on the task instructions, so as to train the large language model based on samples of different task types.
13. The device according to claim 12, wherein: The first type of task samples includes a first sample set and a second sample set; The sample quality of the first sample set is lower than the sample quality of the second sample set, and the first sample set includes dirty samples.
14. The apparatus according to claim 13, further comprising a first determining module, configured to: Obtaining a first sample search request, a first sample search result recommended for the first sample search request, and a network address of the first sample search result; Compressing effective information of the first sample search results to obtain a first core content of the first sample search results; If labeling is required, obtaining a second sample search result from the network address of the first sample search result; The dirty sample consisting of the first sample search request, the first core content and the first label is obtained by labeling based on the first sample search request and the second sample search result.
15. The apparatus according to claim 14, further comprising a second determining module, configured to: Obtaining a second sample search request and a snapshot of a third sample search result recommended for the second sample search request; Compressing the effective information of the third sample search result to obtain the second core content of the third sample search result; When labeling is required, labeling is performed based on the snapshot of the second sample search request and the third sample search result to obtain a clean sample consisting of the second sample search request, the second core content and the second label.
16. The device according to claim 13, wherein: The task instruction of the first sample set is also used to prompt that the samples learned by the large language model are dirty samples; The task instructions of the second sample set are also used to prompt that the samples learned by the large language model are clean samples.
17. The device according to any one of claims 12 to 16, wherein: The training module comprises: A construction unit, configured to construct a first type of prompt information based on the first type of task samples; the first type of prompt information includes a third sample search request in the first type of task samples, a third core content corresponding to the third sample search request, a search intent of the third sample search request, and a task instruction corresponding to the related task; A training unit is used to train the large language model based on the first type of prompt information.
18. The device according to any one of claims 12 to 17, wherein: For the first type of task samples, the loss used for training the large language model includes a first sub-loss and a second sub-loss; The first sub-loss is a discriminant loss determined based on the first type of task samples; the discriminant loss is used to measure the gap between the search relevance prediction value output by the discriminant network of the large language model and the search relevance true value; The second sub-loss is a first generation loss determined based on the first type of task samples; the first generation loss is used to measure the gap between the first generation result and the first generation label output by the generation network of the large language model for the first type of task samples.
19. The device according to any one of claims 12 to 18, wherein: For the second type of task samples, the loss used for training the large language model is a second generation loss; The second generation loss is used to measure the gap between the second generation result output by the generation network of the large language model for the second type of task samples and the second generation label.
20. The device according to any one of claims 12 to 19, wherein: For the first type of task samples, the prompt information of the first type of task samples also includes a first target character; The first target character is inferred by the large language model to obtain a discriminant vector; The discriminant vector is used to input into the discriminant network of the large language model to discriminate the search relevance between the user query and the search results.
21. A relevance determination device, using a large language model obtained by the device according to any one of claims 12 to 20, comprising: The second acquisition module is used to obtain user queries and search results; A construction module, used to construct prompt words based on the user query and the search results; The prompt words include task instructions that prompt the large language model to perform a related task; A processing module is used to input the prompt word into the large language model, obtain the prediction result of the large language model for the search relevance between the user query and the search result, and generate a reason.
22. The apparatus according to claim 21, wherein, when the first type of task samples for training the large language model include a first sample set and a second sample set, the task instruction is an instruction corresponding to the second sample set; in, The sample quality of the first sample set is lower than that of the second sample set, and the first sample set includes dirty samples; the second sample set includes clean samples.
23. 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 that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 11.
24. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to cause the computer to execute the method according to any one of claims 1-11.
25. A computer program product comprising a computer program, which, when executed by a processor, implements the method according to any one of claims 1 to 11.
Citation Information
Patent Citations
Information search method and search engine
CN103729374A
Search request recommendation method and device, electronic equipment and storage medium
CN116628253A
Model training method and device, correlation determination method and device, equipment and storage medium
CN117573817A
Vertical domain large language model training method and related equipment
CN117828401A
Search method and apparatus, model training method and apparatus, and storage medium
WO2024087202A1