Method for rewriting query text based on large language model

Through the rewrite query text method based on the large language model, the problem of low recall of search engines on the travel service platform is solved. Through fine-tuning and introduction of knowledge of the entity library, the error correction recall rate is improved, and higher search accuracy and recall rate are achieved. .

CN118626686BActive Publication Date: 2025-01-07浙江飞猪网络技术有限公司
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202411097598.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-12
Publication Date
2025-01-07
Estimated Expiration
2044-08-12

AI Technical Summary

Technical Problem

The search engines of the travel service platform have low recall rates due to typo correction problems during the search process, and the existing technology is difficult to effectively solve.

Method used

Using a rewrite query text method based on a large language model, fine-tune the large language model by automatically generating and filtering training samples, using entity libraries and reinforcement learning to improve error correction recall, and rewrite the query text input by users to improve the recall rate of search engines. .

Benefits of technology

The search engine recall rate of the travel service platform is improved, especially in error correction, and the fine-tuning training of the large language model is achieved with few samples and low cost.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118626686B_ABST
    Figure CN118626686B_ABST
Patent Text Reader

Abstract

The present disclosure relates to a method for rewriting query text based on a large language model. The method comprises: automatically generating M training samples based on L training samples, wherein the L training samples are all related to the query text rewriting operation of a travel service platform; screening N training samples from a training set, wherein the training set at least includes the automatically generated M training samples; fine-tuning a first large language model using the N training samples to obtain a rewriting model, wherein L, M and N are all natural numbers, and N is greater than L; and inputting the query text input by the user on the travel service platform into the rewriting model to obtain the rewritten query text. Using this method, the recall rate of the search engine of the travel service platform can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of travel services, and in particular to a method for rewriting query text based on a large language model. Background Art

[0002] At present, the search engines of travel service platforms encounter a large number of typos and other problems in the query text (query) during the search process, resulting in the recall rate of existing search engines being not high enough.

[0003] It is therefore desirable to provide a method for rewriting query text, which can improve the recall rate of the search engine of the travel service platform. Summary of the invention

[0004] A technical problem to be solved by the present disclosure is to provide an improved method for rewriting query text, which can improve the recall rate of the search engine of the travel service platform.

[0005] According to a first aspect of the present disclosure, a method for rewriting query text based on a large language model is provided, comprising: automatically generating M training samples based on L training samples, wherein the L training samples are all related to a query text rewriting operation of a travel service platform; screening N training samples from a training set, wherein the training set at least includes the M training samples automatically generated; fine-tuning a first large language model using the N training samples to obtain a rewriting model, wherein L, M and N are all natural numbers, and N is greater than L; and inputting a query text input by a user on the travel service platform into the rewriting model to obtain a rewritten query text.

[0006] Optionally, the step of automatically generating M training samples according to the L training samples includes: using the second largest language model to automatically generate M training samples according to the L training samples.

[0007] Optionally, the L training samples include multiple training samples respectively used to correct at least one of multiple error types of the query text of the travel service platform.

[0008] Optionally, the M automatically generated training samples include a plurality of training samples each having a prompt in one of a plurality of expression modes.

[0009] Optionally, the M automatically generated training samples include multiple training samples respectively targeting one of the multiple tasks.

[0010] Optionally, the step of selecting N training samples from the training set includes: obtaining instruction following difficulty scores of all training samples in the training set, and selecting N training samples with top N instruction following difficulty scores.

[0011] Optionally, the step of fine-tuning the first large language model using the N training samples includes: performing supervised fine-tuning on the first large language model using the N training samples to obtain multiple candidate answers and their preferences corresponding to each of the N training samples, and performing reinforcement learning fine-tuning on the supervised fine-tuned first large language model using the multiple candidate answers and their preferences corresponding to each of the N training samples.

[0012] Optionally, the step of obtaining multiple candidate answers and their preferences corresponding to each of the N training samples includes: using the first largest language model after supervised fine-tuning to generate multiple candidate answers for each of the N training samples, and using the third largest language model to perform preference scoring on the multiple candidate answers for each of the N training samples to obtain their respective preferences.

[0013] Optionally, the step of obtaining the rewritten query text includes: obtaining an entity library related to the travel service platform, at least using the entity library to recall multiple candidate query texts as context information for the query text, and inputting the query text and the context information into the rewriting model to obtain the rewritten query text.

[0014] Optionally, the step of recalling multiple candidate query texts includes: at least using the entity library, using multiple recall methods to recall candidate query texts for the query text respectively, sorting the candidate query texts recalled using the multiple recall methods, and taking the top multiple candidate query texts as the multiple candidate query texts, wherein the multiple recall methods include one or more of vector recall, knowledge graph recall, confusing word recall, phonetic similar word recall, and visual similar word recall.

[0015] Optionally, the context information also includes at least one of the following: a historical rewriting record of the query text, a historical search result record of the query text on the travel service platform, a conversion rate or click-through rate record of the historical search results of the query text on the travel service platform, and information about products on the travel service platform corresponding to the entities involved in the query text.

[0016] According to a second aspect of the present disclosure, a computing device is provided, comprising: a processor; and a memory on which executable codes are stored, and when the executable codes are executed by the processor, the processor executes the method described in the first aspect above.

[0017] According to a third aspect of the present disclosure, a computer program product is provided, comprising an executable code, and when the executable code is executed by a processor of an electronic device, the processor is caused to execute the method as described in the first aspect above.

[0018] According to a fourth aspect of the present disclosure, a non-transitory machine-readable storage medium is provided, on which executable code is stored. When the executable code is executed by a processor of an electronic device, the processor executes the method described in the first aspect above.

[0019] Thus, by using the method according to the present disclosure, the large language model fine-tuned for the query text rewriting of the travel service platform can be used to better rewrite the query text input by the user, thereby improving the recall rate of the search engine of the travel service platform. In addition, the present disclosure can complete the fine-tuning training of the large language model with a small number of samples and at a low cost. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] The above and other objects, features and advantages of the present disclosure will become more apparent through a more detailed description of exemplary embodiments of the present disclosure in conjunction with the accompanying drawings, wherein like reference numerals generally represent like components in the exemplary embodiments of the present disclosure.

[0021] Figure 1 A schematic flowchart of a method for rewriting query text based on a large language model according to at least one embodiment of the present disclosure is shown.

[0022] Figure 2 A schematic flowchart of a method for rewriting query text based on a large language model according to at least one embodiment of the present disclosure is shown.

[0023] Figure 3 A schematic diagram of the structure of a computing device according to at least one embodiment of the present disclosure is shown. DETAILED DESCRIPTION

[0024] The exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided to make the present disclosure more thorough and complete, and to fully convey the scope of the present disclosure to those skilled in the art.

[0025] First, some explanations of terms involved in this disclosure are given:

[0026] Search engine of travel service platform: providing users with functions such as search and recommendation of travel service products on the travel service platform;

[0027] RAG: Retrieval Augmented Generation, retrieval enhanced generation;

[0028] Large models: neural network models with large number of parameters, such as models with billions or even tens of billions or more parameters;

[0029] Large Language Models: Large Language Models, or LLMs for short, are large models trained with large amounts of text data, designed to understand and generate natural language text;

[0030] Fine-tuning: training a pre-trained base language model on a specific task, thereby adjusting it to be more suitable for that specific task;

[0031] IFD: Instruction-Following Difficulty, instruction following difficulty;

[0032] Reinforcement learning: refers to the intelligent subject (Agent) learning knowledge through interaction with the environment. For example, it can adjust its behavior strategy according to the reward or punishment signal fed back by the environment. The goal is to find a strategy that maximizes the long-term cumulative reward.

[0033] Vertical category: In this disclosure, it refers to the various sub-fields obtained by classifying travel service products on the travel service platform, such as air tickets, hotels, etc.; the search engine of the travel service platform supports multiple vertical category searches.

[0034] The present disclosure has found that currently on travel service platforms, when users search, many products are missed or not recalled due to typos and other reasons, among which the rewriting of typos and other corrections is the most problematic link. However, the current recall rate of the error correction link is low. For example, some existing solutions find it difficult to judge the correct query candidates in the final sorting link based on prior knowledge. For example, some existing solutions can only correct general knowledge, but cannot understand some query errors specific to travel service platforms, such as the lack of common sense in correcting niche hotel names and scenic spot names in vertical categories.

[0035] Therefore, the present disclosure proposes a new method for rewriting query text based on a large language model, which uses a large language model that is fine-tuned for rewriting query texts for a travel service platform to better rewrite the query texts input by the user, which can at least improve the recall rate of the search engine of the travel service platform. The large language model has strong logical reasoning capabilities, and has been fine-tuned for rewriting query texts for the travel service platform, so it can better determine the rewritten query text. In addition, the present disclosure can also use a small number of training samples to automatically generate and screen a larger number of training samples required for fine-tuning, so it can use a small number of samples to complete the fine-tuning training of the large language model at a low cost.

[0036] In addition, in some embodiments, the solution of the present disclosure can also align the output style of the fine-tuned large language model through reinforcement learning, thereby further improving the recall rate of the search engine. In addition, in some embodiments, the solution of the present disclosure can also introduce knowledge in this field through the entity library related to the travel service platform during rewriting, improve the recall rate of the large language model rewriting, especially the recall rate of error correction, thereby further improving the recall rate and accuracy of the search engine.

[0037] It should be understood that the travel service platform mentioned in this disclosure can usually host multiple businesses to provide users with various travel-related services, such as booking hotels, purchasing train tickets, air tickets, attraction tickets, and applying for visas.

[0038] In addition, it should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.

[0039] At least some embodiments of the solutions of the present disclosure will be described in detail below in conjunction with the accompanying drawings. In the present disclosure, "multiple" and similar terms refer to two or more.

[0040] Figure 1 A schematic flowchart of a method for rewriting query text based on a large language model according to at least one embodiment of the present disclosure is shown.

[0041] It should be understood that in the present disclosure, "rewriting" generally refers to the preprocessing of the user's search query text by the search engine, which modifies or converts the query text entered by the user into one or more other query texts, aiming to better understand the user's intentions and return more relevant and accurate search results. Rewriting may include, for example, synonym replacement, text error correction, format transformation (such as structured processing), query expansion (such as adding other keywords related to the original query), personalized rewriting, etc.; the scheme of the present disclosure has no restrictions on the method of rewriting. Although the rewriting method of text error correction is mentioned below, those skilled in the art understand that the rewriting according to the scheme of the present disclosure is not limited to this, and it can include one or more of the above-mentioned methods as needed.

[0042] like Figure 1 As shown, in step S110, M training samples are automatically generated according to L training samples, wherein the L training samples are all related to the query text rewriting operation of the travel service platform. These training samples are prepared for the fine-tuning of the first language model described later, and the fine-tuned first language model will be used as a rewriting model to perform the rewriting operation of the query text of the travel service platform.

[0043] For example, L may be in the order of tens to hundreds, such as 50 to 100, and M may be in the order of tens of thousands to hundreds of thousands, such as M may be thousands of times greater than L. The number of M may be determined based on the number of samples usually required for fine-tuning, for example, it may be about ten times the required number, so as to subsequently screen out samples sufficient for fine-tuning.

[0044] In some embodiments, the L training samples are prepared manually, and since the number is small, the labor cost is low. The L training samples can be carefully prepared by the operator according to the application scenario, etc., to improve the training quality.

[0045] In some embodiments, the L training samples may include multiple training samples, wherein each training sample is used to correct at least one of multiple error types of the query text of the travel service platform.

[0046] The L training samples can be selected according to the query text error types specific to the travel service platform, which may include, for example, training samples for correcting one or more of high-frequency errors, typical errors, niche entity errors, specific spelling errors, disorder, handwriting errors, and multiple writing errors. It should be understood that the above-mentioned error types include types divided according to different standards, so there may be overlapping situations, that is, one error belongs to multiple error types, and its corresponding training samples may also belong to corresponding multiple categories. In some cases, one training sample can also correct multiple errors, and these multiple errors may belong to the same or different error types.

[0047] Various methods may be used to automatically generate M training samples based on L training samples.

[0048] For example, the expression of the prompt contained in the original training sample can be changed in various ways, the query text contained in the original training sample can be replaced with the same or similar type of query text, and / or the type of task targeted by the original training sample can be changed, etc., thereby automatically generating M training samples with diversified prompt expressions, diversified query texts of the same or similar type, and / or diversified targeted task types.

[0049] That is, in some embodiments, the M training samples automatically generated may include multiple training samples each having a prompt of one of multiple expression modes. In some embodiments, the M training samples automatically generated may include multiple training samples each for one of multiple tasks.

[0050] The types of tasks targeted by the training samples may include, for example, judgment tasks, generation tasks, scoring tasks, etc. These tasks may all be related to the query text rewriting operation (eg, error correction) of the travel service platform.

[0051] In addition, in some embodiments, the L training samples may also include training samples for multiple tasks respectively, and the multiple tasks are all related to the query text rewriting operation of the travel service platform, such as the judgment task of judging whether the query text needs to be corrected, the judgment task of judging whether there is a correct answer to correct the query text among the candidates, the generation task of generating the correct query text after correcting the query text, the scoring task of scoring the candidate correct query text, etc.

[0052] The M training samples can be automatically generated by utilizing the powerful natural language processing capability and the ability to master general knowledge of the large language model. That is, in some embodiments, the second largest language model can be used to automatically generate the M training samples based on the L training samples.

[0053] For example, corresponding prompts can be written as needed to allow the second largest language model to automatically generate more similar training samples based on the L training samples. For example, the second largest language model can be allowed to change or rewrite the original training samples in one or more ways, thereby automatically generating M training samples with, for example, diversified prompt expressions, diversified query texts of the same or similar types, and / or diversified targeted tasks.

[0054] The second largest language model may be a model different from the first largest language model as the base model. For example, the second largest language model may have a stronger natural language processing capability than the first largest language model, so that better training samples can be generated with the help of the powerful capabilities of the second largest language model. For example, the second largest language model may have a larger number of parameters than the first largest language model, and / or may be trained using more and / or better training materials, such as a GPT4 model.

[0055] Then, if Figure 1 As shown, in step S120, N training samples are screened out from a training set, wherein the training set at least includes the M training samples automatically generated.

[0056] In some embodiments, the training set may include only the M automatically generated training samples, or may include the original L training samples and the M automatically generated training samples.

[0057] This screening operation can be performed in various ways.

[0058] For example, one or more preset rules and / or machine learning models may be used to screen out better training samples and / or remove bad training samples.

[0059] For example, one or more indicators may be used to evaluate each training sample in the training set, and a screening operation may be performed based on the indicator.

[0060] In some embodiments, the instruction following difficulty (IFD) scores of all training samples in the training set can be obtained, and the N training samples with the top N instruction following difficulty scores can be screened out. Here, N can be a value preset according to needs, or a value determined according to a preset ratio, that is, the value of N can be obtained by multiplying the total number of training samples in the training set by the ratio.

[0061] In some embodiments, in step S130, which will be described in detail later, the first language model is fine-tuned by instruction tuning, so the training samples generated here are all instruction tuning samples, and each training sample can include an instruction and its corresponding answer (i.e., expected output). Thus, the M training samples mentioned above can be obtained by inputting the original L training samples into the instruction automatic generation (self-instruct) module in step S110, and then in the current step S120, the IFD indicator is used to filter out the N training samples mentioned above from the training set, which have higher potential for model tuning and can also be called "cherry data", thereby improving the efficiency and effect of model instruction fine-tuning. For example, cherry data with the top 5%-10% of IFD scores can be used as the N training samples mentioned above.

[0062] Then, if Figure 1 As shown, in step S130, the first large language model is fine-tuned using the N training samples to obtain a rewriting model, where L, M and N are all natural numbers, and N is greater than L. The rewriting model is the first large language model after fine-tuning.

[0063] Fine-tuning can be done in various ways.

[0064] For example, in order to align the output style of the fine-tuned large language model so that the rewritten text it outputs is more suitable for search engines, reinforcement learning can be introduced. Output style alignment can consider aspects such as parseable output structure and alignment of thinking styles. For example, output style alignment can include one or more of the following aspects: output in a specific format, output in a predetermined template, special considerations for specific fields, specific logical judgments, etc.

[0065] For example, the fine-tuning operation of the present disclosure may adopt two stages: supervised fine-tuning (SFT) plus reinforcement learning fine-tuning. Therefore, in some embodiments, step S130 may include:

[0066] Using the N training samples, fine-tuning the first language model in a supervised manner,

[0067] Obtain multiple candidate answers and their preferences corresponding to each of the N training samples, and

[0068] The first language model after supervised fine-tuning is fine-tuned through reinforcement learning using multiple candidate answers and their preferences corresponding to each of the N training samples.

[0069] The reinforcement learning may adopt various techniques, such as Direct Preference Optimization (DPO) technique, which consumes few resources.

[0070] Various methods may be used to obtain multiple candidate answers and their preferences corresponding to each of the N training samples. In addition, the execution order of the step of obtaining the multiple candidate answers and their preferences and the step of fine-tuning the first language model in a supervised manner is not limited, and the two steps may be performed simultaneously or one of them may be performed first.

[0071] In some embodiments, the first language model after supervised fine-tuning can be used to automatically obtain the multiple candidate answers. At this time, the first language model after supervised fine-tuning can be used to generate multiple candidate answers for each of the N training samples. For example, the model can be set to use multiple different temperature parameters to obtain multiple different output results as the multiple candidate answers. Then, the third language model can be used to perform preference scoring on the multiple candidate answers for each of the N training samples to obtain their respective preference levels. For example, the output preference can be told to the third language model by writing appropriate prompts, and it can score each answer accordingly based on the preference. The third language model can be different from the first language model. The third language model can be the same as the aforementioned second language model, for example, it can also be a GPT4 model.

[0072] Then, if Figure 1 As shown, in step S140, the query text input by the user on the travel service platform is input into the rewriting model to obtain the rewritten query text.

[0073] In some embodiments, in order to further improve the recall rate of rewriting, information related to the query text may be obtained as its context information, and the context information together with the query text may be input into the rewriting model for reference.

[0074] For example, when searching for travel service products, you will often encounter some niche entity names, such as niche hotel names or scenic spot names, and the rewriting model may lack common sense for error correction of these niche entity names. Therefore, you can introduce an external entity library to tell the rewriting model common sense in the travel service field, thereby improving the recall rate of rewriting, especially error correction.

[0075] Therefore, in some embodiments, step S140 may include: obtaining an entity library related to the travel service platform; using at least the entity library to recall multiple candidate query texts as context information for the query text; and inputting the query text and the context information into the rewriting model to obtain a rewritten query text.

[0076] For example, the entity library may include entities in all travel service products sold on the travel service platform, such as hotel names, scenic spot names, etc. The entity library may also include entities in travel service products sold on other travel service platforms obtained in various ways, and / or entities involved in the travel service field. When recalling candidate query texts, multiple candidate query texts may be recalled from the entity library in various ways (e.g., vector recall, etc.).

[0077] In some examples, the recognition and recall capabilities of various error corrections can be used to recall as many correct query text candidates as possible. In addition, the query texts can be standardized in terms of expression, format, and / or entity name in various ways. These recall results are then ranked, and the top few (e.g., top 5) candidate query texts are selected as context information.

[0078] Therefore, the aforementioned step of recalling multiple candidate query texts may include: at least using the entity library, using multiple recall methods to recall candidate query texts for the query text respectively; sorting the candidate query texts recalled using the multiple recall methods; and taking the top multiple candidate query texts as the multiple candidate query texts, wherein the multiple recall methods include one or more of vector recall, knowledge graph recall, confusing word recall, phonetic similar word recall, and semantic similar word recall.

[0079] Therefore, when obtaining the context information of the query text, at least the entity library related to the travel service platform is used, which can provide the rewriting model with common sense in this field and is particularly beneficial for correcting niche entity names (such as hotel names, attraction names, etc.).

[0080] In some embodiments, other information related to the query text can also be provided as its context information, such as historical records related to the query text, or information about products on the travel service platform that the query text may involve, etc., to assist the rewriting model in making judgments, etc., thereby further improving the recall rate of the rewriting.

[0081] Thus, the context information may further include at least one of the following:

[0082] The historical rewriting records of the query text, the historical search result records of the query text on the travel service platform, the conversion rate or click-through rate records of the historical search results of the query text on the travel service platform, and the product information on the travel service platform corresponding to the entity involved in the query text.

[0083] For example, the historical rewriting record of the query text may include the most recently obtained or several rewritten query texts, and / or the rewritten query texts that have appeared most frequently in history; the historical search result record of the query text on the travel service platform may include the most recently obtained or several search results, the products ranked first in the most recently obtained or several search results, and / or the products that appear most frequently in the historical search results; the conversion rate or click-through rate record of the historical search results of the query text on the travel service platform may include the conversion rate or click-through rate of each product in the most recently obtained or several search results, the conversion rate or click-through rate of the products ranked first in the most recently obtained or several search results, and / or the conversion rate or click-through rate of the products that appear most frequently in the historical search results; the information on the products on the travel service platform corresponding to the entity involved in the query text may include: information on the products with the highest purchase volume or view volume among the products on the travel service platform that contain the entity involved in the query text.

[0084] In addition, in some embodiments, the query text and its context information are input into the rewriting model by writing appropriate prompts and the rewriting model outputs the rewritten query text. At this time, prompt engineering can also be used to optimize the design of the prompt to further improve the recall rate and / or accuracy of the rewriting model.

[0085] The following will be combined Figure 2 An exemplary method of the present disclosure is described in more detail. It should be understood that Figure 2 The steps in the embodiment are merely exemplary and non-restrictive and are not intended to limit the scope of the present disclosure. Figure 2 The details of the steps or alternative methods can be referred to in conjunction with Figure 1 The contents described will not be repeated here.

[0086] Figure 2 A schematic flowchart of a method for rewriting a query text based on a large language model according to at least one embodiment of the present disclosure is exemplarily shown.

[0087] like Figure 2As shown, the method can be divided into two stages: a training stage and an inference stage. The training stage mainly includes steps S210 to S250, using a small number of samples to obtain a fine-tuned first language model as a rewriting model, and then deploying the rewriting model for inference, that is, entering the inference stage, which mainly includes steps S260 to S280, using the deployed rewriting model to rewrite the query text input by the user to obtain the rewritten query text.

[0088] Specifically, in step S210, the operator manually prepares L (for example, 50) training samples, and then in step S220, the L training samples are input into the self-instruct module, which uses the second largest language model (for example, GPT4) to automatically generate M similar training samples for fine-tuning instructions, and then in step S230, the IFD indicator is used to screen out the most potential N training samples in order to achieve the effect of precise fine-tuning with less data, and then the N training samples are used to perform supervised fine-tuning (SFT) on the first language model to obtain the first language model after SFT. Then, in step S240, the first language model after SFT is used to automatically generate multiple candidate answers for each of the N training samples. Then, in step S250, the second largest language model is used to score each candidate answer to obtain the preference of multiple candidate answers for each training sample, and then the multiple candidate answers and their preferences for each training sample are used to perform direct preference optimization (DPO) fine-tuning on the first largest language model after SFT to obtain the final rewriting model.

[0089] Then, in the reasoning stage, first obtain the entity library related to the travel service platform, and receive the query text input by the user. Then, in step S260, at least use the entity library to perform retrieval enhancement generation (RAG), such as multi-way recall, to obtain multiple candidate query texts, and other information related to the query text (such as the various historical records mentioned above) can also be obtained. Then, in step S270, construct a prompt for inputting the rewriting model to perform the rewriting operation, the prompt at least includes the query text input by the user and uses the information obtained in step S260 as the context information of the query text. Then the constructed prompt is input into the rewriting model, the rewriting model performs the final judgment and rewrite output, and the rewritten query text is output in step S280.

[0090] Therefore, the solution disclosed in the present invention can self-generate data through automatic instruction generation (self-instruct), and use IFD to effectively clean the data, so that the cost of fine-tuning training is very low. The operator only needs to provide a small number (such as 50) of example training samples, and the solution disclosed in the present invention can automatically fine-tune the large language model, greatly reducing the cost and time of fine-tuning training. In addition, the solution disclosed in the present invention introduces reinforcement learning to align the model output style, so that the output results are more in line with expectations. In addition, the solution disclosed in the present invention also solves the problem of lack of error correction common sense for niche entity names of vertical categories (such as hotel names and scenic spot names, etc.) by plugging in data entity libraries in related fields, so that the model can obtain knowledge of related vertical categories and improve the recall rate of error correction. Therefore, the query text can be better rewritten through the solution disclosed in the present invention, thereby improving the search accuracy and recall rate of the search engine.

[0091] Figure 3 A schematic diagram of the structure of a computing device that can be used to implement the above-mentioned method of rewriting query text based on a large language model according to at least one embodiment of the present disclosure is shown.

[0092] See also Figure 3 , the computing device 300 includes a memory 310 and a processor 320 .

[0093] The processor 320 may be a multi-core processor or may include multiple processors. In some embodiments, the processor 320 may include a general-purpose main processor and one or more special coprocessors, such as a graphics processing unit (GPU), a digital signal processor (DSP), etc. In some embodiments, the processor 320 may be implemented using a customized circuit, such as an application-specific integrated circuit (ASIC) or a field programmable gate array (FPGA).

[0094] The memory 310 may include various types of storage units, such as system memory, read-only memory (ROM), and permanent storage devices. Among them, ROM can store static data or instructions required by the processor 320 or other modules of the computer. The permanent storage device may be a readable and writable storage device. The permanent storage device may be a non-volatile storage device that does not lose the stored instructions and data even after the computer is powered off. In some embodiments, the permanent storage device uses a large-capacity storage device (such as a magnetic or optical disk, flash memory) as a permanent storage device. In some other embodiments, the permanent storage device may be a removable storage device (such as a floppy disk, optical drive). The system memory may be a readable and writable storage device or a volatile readable and writable storage device, such as a dynamic random access memory. The system memory may store some or all instructions and data required by the processor at runtime. In addition, the memory 310 may include any combination of computer-readable storage media, including various types of semiconductor memory chips (DRAM, SRAM, SDRAM, flash memory, programmable read-only memory), and disks and / or optical disks may also be used. In some embodiments, the memory 310 may include a readable and / or writable removable storage device, such as a laser disc (CD), a read-only digital versatile disc (such as a DVD-ROM, a double-layer DVD-ROM), a read-only Blu-ray disc, an ultra-density optical disc, a flash memory card (such as an SD card, a mini SD card, a Micro-SD card, etc.), a magnetic floppy disk, etc. The computer-readable storage medium does not contain carrier waves and transient electronic signals transmitted wirelessly or wired.

[0095] The memory 310 stores executable codes. When the executable codes are processed by the processor 320 , the processor 320 can execute the above-mentioned method of rewriting query text based on a large language model.

[0096] In addition, the method according to the present disclosure may also be implemented as a computer program or a computer program product, which includes computer program code instructions for executing the above steps defined in the above method of the present disclosure.

[0097] Alternatively, the present disclosure may also be implemented as a non-transitory machine-readable storage medium (or computer-readable storage medium, or machine-readable storage medium) on which executable code (or computer program, or computer instruction code) is stored. When the executable code (or computer program, or computer instruction code) is executed by a processor of an electronic device (or computing device, server, etc.), the processor executes the various steps of the above-mentioned method according to the present disclosure.

[0098] Those skilled in the art will further appreciate that the various illustrative logical blocks, modules, circuits, and algorithm steps described in connection with the disclosure herein may be implemented as electronic hardware, computer software, or a combination of both.

[0099] The flow charts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the system and method according to multiple embodiments of the present disclosure. In this regard, each box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flow chart, and the combination of the boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0100] The embodiments of the present disclosure have been described above, and the above description is exemplary, not exhaustive, and is not limited to the disclosed embodiments. Many modifications and changes will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the described embodiments. The selection of terms used herein is intended to best explain the principles of the embodiments, practical applications, or improvements to the technology in the market, or to enable other persons of ordinary skill in the art to understand the embodiments disclosed herein.

Claims

1. A method for rewriting a query text based on a large language model, comprising: Using the second largest language model, changing the expression of each prompt contained in the L training samples and / or changing the type of task for which the L training samples are respectively targeted, thereby automatically generating M training samples according to the L training samples, wherein the L training samples are all related to the query text rewriting operation of the travel service platform, and the L training samples include multiple training samples respectively used for correcting at least one of multiple error types of the query text of the travel service platform; Filtering N training samples from a training set, wherein the training set at least includes the M training samples automatically generated; Fine-tune the first language model using the N training samples to obtain a rewriting model, wherein L, M and N are all natural numbers, and N is greater than L; Obtaining an entity library related to the travel service platform, wherein the entity library includes entities in travel service products sold on the travel service platform; At least using the entity library, using multiple recall methods to respectively recall candidate query texts for query texts input by users on the travel service platform, sorting the candidate query texts recalled using the multiple recall methods, and taking the top multiple candidate query texts as context information; as well as Inputting the query text and the context information into the rewriting model to obtain a rewritten query text; The multiple recall methods include one or more of vector recall, knowledge graph recall, confusing word recall, similar-sounding word recall, and similar-shaped word recall. The context information further includes at least one of the following: a historical rewriting record of the query text, a historical search result record of the query text on the travel service platform, a conversion rate or click-through rate record of the historical search results of the query text on the travel service platform, and information about products on the travel service platform corresponding to entities involved in the query text. The M training samples automatically generated include multiple training samples each having a prompt in one of multiple expression modes, and / or the M training samples automatically generated include multiple training samples each for one of multiple tasks, The second largest language model is a model different from the first largest language model and has stronger natural language processing capability than the first largest language model.

2. The method according to claim 1, wherein: The steps of selecting N training samples from the training set include: Obtaining instruction following difficulty scores for all training samples in the training set, and Filter out N training samples with top N instruction following difficulty scores.

3. The method according to claim 1, wherein: The step of fine-tuning the first language model using the N training samples includes: Using the N training samples, fine-tuning the first language model in a supervised manner, Obtain multiple candidate answers and their preferences corresponding to each of the N training samples, and The first language model after supervised fine-tuning is fine-tuned through reinforcement learning using multiple candidate answers and their preferences corresponding to each of the N training samples.

4. The method according to claim 3, wherein: The step of obtaining multiple candidate answers and their preferences corresponding to each of the N training samples includes: Using the first language model after supervised fine-tuning, for each of the N training samples, generate multiple candidate answers, and The third language model is used to perform preference scoring on each of the N training samples to obtain respective preference degrees for the multiple candidate answers.

5. A computer program product, comprising executable codes, which, when executed by a processor of an electronic device, cause the processor to perform the method according to any one of claims 1 to 4.

Citation Information

Patent Citations

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

    CN116226334A

  • Query search method, query information processing method, equipment and storage medium

    CN117520477A

  • Information processing method and device based on large language model, equipment and storage medium

    CN117521675A