A document retrieval query rewriting method and system based on a large language model
By adopting a document retrieval query rewriting method based on a large language model, the problems of inaccurate understanding and poor rewriting effect of long-tail queries are solved, achieving higher retrieval relevance and user satisfaction, and improving the processing capability of long-tail queries.
Patent Information
- Application Number
- CN202411939591.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-26
- Publication Date
- 2025-12-12
- Estimated Expiration
- 2044-12-26
AI Technical Summary
Existing document retrieval systems suffer from problems such as inaccurate query understanding, poor rewriting effects, and poor relevance of search results when processing long-tail queries, especially due to a lack of sufficient understanding and effective processing capabilities for long-tail queries.
We adopt a document retrieval query rewriting method based on a large language model. By collecting and filtering query rewriting datasets, we construct a multi-task SFT dataset, use GPT-2 for self-supervised fine-tuning, and combine reinforcement learning for target alignment to optimize the query rewriting strategy and improve relevance.
It effectively reduces noise in the search, improves search relevance and user satisfaction, and enhances the ability to understand and process long-tail queries.
Smart Images

Figure CN120011482B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to natural language processing, in particular to a method and system for improving query rewriting in a document retrieval system to enhance the understanding and processing capacity of long-tail queries. BACKGROUND
[0002] Query rewriting is an important tool to improve user search efficiency. Traditional query rewriting methods focus on queries with high frequency, but for long-tail queries with low frequency, it is difficult to produce good recommendation results due to the sparsity of information. Long-tail keywords are more specific and longer search phrases (usually three or more words) that can clearly convey the searcher's intent. Short-tail keywords are phrases with general meanings, such as "mobile phone" and "weight loss". In general, long-tail keyword phrases are longer and more specific search terms can better describe specific things or concepts, such as "2024 latest Android phone recommendations" and "fastest weight loss methods and recipes".
[0003] Due to the complex and diverse combination of word groups involved in long-tail queries, traditional methods rely on manually constructed dictionaries or rules, which cannot effectively handle a large number of long-tail queries. Existing document retrieval systems often face problems such as inaccurate query understanding, poor rewriting results, and poor relevance of retrieval results when processing long-tail queries. These problems mainly arise from the lack of sufficient understanding and effective processing capacity of existing query rewriting models for long-tail queries. Traditional methods, such as pseudo-relevance feedback mechanisms, expand queries by adding keywords to the original query, but these methods rely on the quality of the initial retrieval results. Query rewriting methods based on word replacement improve retrieval to some extent, but have limited effectiveness in handling document ranking tasks. Doc2Query and Query2Doc use neural models to predict queries related to documents to enhance document representation, but these methods are inefficient in reasoning and are prone to deviating from the original meaning, resulting in poor retrieval relevance. SUMMARY
[0004] The present application aims to provide a document retrieval query rewriting method and system based on large language models, which aims to solve the problem that existing document retrieval systems are prone to introduce inaccuracies and noise when processing long-tail queries, often leading to inaccurate query understanding, poor rewriting results, and poor relevance of retrieval results.
[0005] The technical solution to achieve the purpose of the present application is: a document retrieval query rewriting method based on a large language model, comprising:
[0006] Step 1, collect query rewriting data sets, perform relevance filtering and retrieval increment, and retain data samples highly relevant to the query rewriting task;
[0007] Step 2: Collect auxiliary task datasets that are highly relevant to the query rewrite task and construct a multi-task SFT dataset;
[0008] Step 3: Construct a self-supervised fine-tuning model based on GPT-2, using the query as input and query rewriting as output, and train the self-supervised fine-tuning model using the multi-task SFT dataset;
[0009] Step 4: Treat the self-supervised fine-tuning model as an intelligent agent and perform target alignment based on reinforcement learning to make it more in line with user intent when generating query rewrites;
[0010] Step 5: Use the beam search algorithm to generate multiple candidate rewrites for each query, input the target-aligned self-supervised fine-tuning model, and retrieve a set of relevant documents.
[0011] Further, in step 1, the query rewriting dataset is collected, relevance filtering and incremental retrieval are performed, and data samples highly relevant to the query rewriting task are retained. The specific method is as follows:
[0012] Step 1.1: Obtain the initial query rewrite dataset from the document retrieval system;
[0013] User initiated query x i When ∈X, the document retrieval system rewrites and generates a series of query rewrites Y = {y1, y2, y3, ..., y...} according to the rewriting strategy. n}, select the highest-ranked y1 as the first choice, and construct an initial query rewrite dataset D containing N samples:
[0014]
[0015] Where p(x) is the query distribution in the document search system, π origin and θ origin These represent the document retrieval system's rewriting strategy and its parameters, respectively.
[0016] Step 1.2: To ensure semantic relevance between the query and the rewritten document retrieval query, the initial query rewrite dataset D is subjected to relevance filtering.
[0017] The initial query rewrite dataset D is rejected according to formula (2) to obtain dataset D. rele :
[0018]
[0019] Among them, rele(·) and τ rele Representing the correlation method and its threshold respectively, the calculation rule for rele(·) is as follows:
[0020]
[0021] where, is an indicator function, f(·) is a function to evaluate the relevance between document title and query, τ' is a semantic relevance threshold for query-document title pair, is the offline retrieval document list of query rewriting y;
[0022] Step 1.3, in order to alleviate the problem of "small recall" caused by long tail queries, again use rejection sampling on the data set D rele relevance filtering, while considering retrieval increment, retrieve the document title recently interacted with query x as supplementary information, get the final query rewriting data set D final :
[0023]
[0024] where, ε x is the interactive document title list of query x, incr(·) and τ incr respectively represent the increment function and its threshold, the calculation formula of incr(·) is as follows:
[0025]
[0026] where, represents the offline retrieval text set of query, refers to the selected document set.
[0027] Further, step 2, collect auxiliary task data sets highly related to query rewriting task, build multi-task SFT data set, where auxiliary tasks include:
[0028] a) quality classification task: after extracting query pair from the initial query rewriting data set D, manual annotation is performed to evaluate the quality of query rewriting;
[0029] b) product title prediction task: select the document clicked by the user recently as reference, form (query, document title) pair;
[0030] c) thinking chain task: use the original query to build prompt, provide improved query rewriting and explain the thinking process.
[0031] Further, step 3, based on GPT-2, build self-supervised fine-tuning model, take query as input, take query rewriting as output, use multi-task SFT data set to train self-supervised fine-tuning model, the specific method is:
[0032] Given an original query x and its query rewriting y, the training target of self-supervised fine-tuning model is to minimize L SFT (θ SFT ), the calculation formula is as follows:
[0033]
[0034] where D multi is a multi-task SFT dataset, (x,y) ~ D multi denotes sampling from D multi , E denotes taking the average of the loss over all samples, i.e., computing the expected loss, π SFT (·) and θ SFT denote the GPT-2 model and its parameters.
[0035] Further, step 4, regarding the self-supervised fine-tuning model as an agent, based on reinforcement learning, align the target, so that it is more in line with the user's intention when generating query rewriting, the specific method is:
[0036] Define state s, action a, reward r, as follows:
[0037] s = {x, t} (7)
[0038] a = SFTModel(s) (8)
[0039]
[0040] where x is the original query rewriting, t is the rewriting times, rele(·) represents the relevance function, incr(·) and τ incr represent the incremental function; SFTModel represents the self-supervised fine-tuning model, β1 and β2 represent the weights of the relevance function and the incremental function, respectively;
[0041] The DQN algorithm is used to train the agent to update the parameters of the self-supervised fine-tuning model.
[0042] A document retrieval query rewriting system based on a large language model, implements the document retrieval query rewriting method based on a large language model, realizes document retrieval query rewriting based on a large language model, and five modules are used to execute steps 1-5.
[0043] A computer device includes a memory, a processor, and a computer program stored on the memory and executable on the processor, and when the processor executes the computer program, the document retrieval query rewriting method based on a large language model is implemented, and the document retrieval query rewriting based on a large language model is realized.
[0044] A computer readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the document retrieval query rewriting method based on a large language model is implemented, and the document retrieval query rewriting based on a large language model is realized.
[0045] Compared with the prior art, the present application has the following advantages: a document retrieval query rewriting method based on a large language model is adopted to understand and rewrite long-tail queries, which can effectively reduce the noise introduced in retrieval based on a large language model through fine-tuning and multi-task learning, and target alignment of query rewriting and retrieval results, and is beneficial to subsequent retrieval recall, improves retrieval relevance, and improves user satisfaction. BRIEF DESCRIPTION OF DRAWINGS
[0046] Figure 1 A flowchart of a document retrieval query rewriting process is shown in
[0047] Figure 2 A flowchart of a data set processing process is shown in
[0048] Figure 3 A flowchart of an interactive process of reinforcement learning environment is shown in DETAILED DESCRIPTION
[0049] In order to make the purpose, technical scheme and advantages of the present application clearer, the present application will be further described in detail below in combination with the drawings and examples. It should be understood that the specific examples described herein are only used to explain the present application and do not limit the present application.
[0050] The present application discloses a document retrieval query rewriting method based on a large language model, and the method flow is shown in Figure 1 , including the following steps:
[0051] Step 1: data set preparation and processing
[0052] The collected query rewriting data set is filtered for relevance and retrieval increment, and the data samples highly relevant to the query rewriting task are retained;
[0053] First, an initial query rewriting data set is obtained from an existing document retrieval system, as shown in Figure 2 When a user initiates a query x i ∈X, a series of query rewriting Y={y1,y2,y3,...,y n} is generated according to the rewriting strategy of the existing document retrieval system, and the highest ranked y1 is selected as the first choice, and an initial query rewriting data set D containing N samples is constructed:
[0054]
[0055] Where p(x) is the query distribution in the document search system, and origin and originrespectively, represent the document retrieval system rewriting strategy and its parameters. Then, in order to ensure the semantic relevance of the query and the rewriting in the document retrieval query rewriting, the relevance filtering of D is performed by rejection sampling according to formula (2), and the data set D rele :
[0056]
[0057] wherein rele(·) and τ rele respectively represent the relevance method and its threshold. The calculation rule of rele(·) is as follows:
[0058]
[0059] wherein, is an indicator function, f(·) is a function of evaluating the relevance between the document title and the query, τ' is the semantic relevance threshold of the query-document title pair, is the offline retrieval document list of query rewriting y. Finally, in order to alleviate the "small recall" problem caused by long-tail queries, D rele is filtered again by rejection sampling, and the retrieval increment is considered at the same time, and the document title recently interacted with the query x is taken as supplementary information to better solve the long-tail query problem, and the final query rewriting data set D final :
[0060]
[0061] wherein ε x is the list of interactive document titles of query x, incr(·) and τ incr respectively represent the increment function and its threshold. The calculation formula of incr(·) is as follows:
[0062]
[0063] wherein, represents the offline retrieval text set of the query, refers to the selected document set, and at the same time, rele(·) and incr(·) will also be used for the evaluation of the subsequent query rewriting results.
[0064] Step 2: Auxiliary task data set preparation
[0065] Collect auxiliary task data sets highly related to query rewriting tasks, and combine them to form a multi-task SFT data set;
[0066] In order to enhance the understanding ability of large language models (LLMs) for long-tail queries, three task data sets highly related to query rewriting are collected. The three auxiliary tasks are:
[0067] a) Mass classification task: extract query pairs from the initial query rewriting dataset D and manually annotate them to evaluate their quality;
[0068] b) Product title prediction task: select the documents clicked by the user's recent query as reference, form (query, document title) pairs;
[0069] c) Chain of thought task: use the original query to build prompts, provide improved query rewriting and explain the thought process;
[0070] The details of these auxiliary tasks will be described in the subsequent experimental section, and the collected data and query rewriting dataset D final Mixing, forming the final multi-task SFT dataset D multi , and randomly shuffled in the subsequent model training phase.
[0071] Step 3: Model training
[0072] Model training can be divided into two parts: fine-tuning and target alignment.
[0073] a) Self-supervised fine-tuning (SFT Model): First, select a base model, this invention uses a pre-trained GPT-2 model with 117M parameters and 12 layers. Then, the multi-task SFT dataset D multi is divided into training set, validation set and test set in the ratio of 8:1:1.
[0074] Given an original query x and its query rewriting y, assume the conditional probability p(y|x) = Π i=1 p(y i |y 0:i-1 ,x;θ SFT ), then the model training target is to minimize L SFT (θ SFT ), the calculation formula is as follows:
[0075]
[0076] Where D multi is the multi-task SFT dataset, (x,y) ~ D multi indicates sampling from D multi , E represents the average loss of all samples, i.e. calculate the expected loss, π SFT (·) and θ SFT represent the GPT-2 model and its parameters.
[0077] b) Target alignment: reinforcement learning (RL) based target alignment
[0078] In the fine-tuning process, SFTModel may learn the preference for the training dataset, which is not necessarily consistent with the goal of the document retrieval system. It can generate multiple query rewriting candidates, but the quality of these query rewrites and the impression on the retrieval results need to be further evaluated and optimized. Goal alignment can ensure that the generated query rewrite can effectively expand the semantics of the original query and output the results that match the user's intention or task goal by considering the relevance, increment, and other indicators of retrieval.
[0079] Goal alignment can force the model to learn the partial order relationship of the query rewrite results provided by the offline feedback. The partial order relationship means that in a set of query rewrite results, some rewrites are considered better or worse than others. For example, if the offline feedback tells the model that rewrite A is better than rewrite B, the goal alignment process will guide the model to prefer to select rewrites similar to A in the future generation. Reinforcement Learning (RL) is a machine learning method that learns the optimal strategy by constantly interacting with the environment. RL can explicitly define the goal by defining the reward function and optimize the strategy through multiple trials and errors.
[0080] As shown in Figure 3 , in the definition of this environment in the document retrieval system, SFTModel is regarded as an agent, the current state is s, the agent selects action a according to the current state, obtains reward r, and jumps to the next state s', which is defined as follows:
[0081] s={x,t} (7)
[0082] a=SFTModel(s) (8)
[0083]
[0084] Where x is the original query rewrite, t is the number of rewrites, and a is the query rewrite output by SFTModel, i.e. action. Each time a query rewrite is performed, it is input into the document retrieval system, and the retrieved documents are obtained. The reward is calculated according to formula (9), and after the cumulative reward reaches 10, the cycle ends, the original query rewrite is initialized, and a new cycle begins, with β1 and β2 both set to 0.5.
[0085] The classical DQN algorithm in reinforcement learning is used to train the agent to update the parameters of the SFTModel model. DQN is an algorithm that combines deep learning and reinforcement learning, which contains two networks, one is the current network Q used for prediction, i.e. SFTModel, and the other is the target network Q target , whose parameters are periodically copied from Q network. The parameter update formula of Q network is as follows:
[0086] LDQN (θ SFT )=E[(y i -Q target (s i ,a i ;θ target )) 2 ] (10)
[0087]
[0088] where θ target is the parameter of the target Q-network, α is the learning rate, the calculation formula of y i is shown in formula (11), and γ is the decay rate, which is generally 0.99:
[0089] y i =r i +γmax a Q target (s',a) (12)
[0090] Step 4: Query rewriting generation: Beam Search
[0091] Beam Search is a heuristic search algorithm commonly used in sequence generation problems, especially in the field of natural language processing, such as machine translation, text summarization and other tasks. Beam Search is used to generate multiple candidate rewrites for each query, and a set of relevant documents is retrieved using the trained SFTModel.
[0092] The query is input into the SFTModel to obtain query rewrite candidates, and these query rewrite candidates are input into the retrieval system to retrieve a set of relevant documents.
[0093] The present application also provides a document retrieval query rewriting system based on a large language model, which implements the document retrieval query rewriting method based on a large language model, and realizes document retrieval query rewriting based on a large language model, which is divided into five modules to perform steps 1-5.
[0094] A computer device includes a memory, a processor, and a computer program stored on the memory and executable on the processor, wherein when the processor executes the computer program, the document retrieval query rewriting method based on a large language model is implemented, and the document retrieval query rewriting based on a large language model is realized.
[0095] A computer readable storage medium has a computer program stored thereon, wherein when the computer program is executed by a processor, the document retrieval query rewriting method based on a large language model is implemented, and the document retrieval query rewriting based on a large language model is realized.
[0096] In summary, through reinforcement learning, the LLMs can dynamically optimize the query rewriting strategy, gradually adjust and adapt to the needs of different users, thereby realizing adaptive query rewriting. At the same time, reinforcement learning can continuously align the user's goal across multiple rounds of interaction through an optimization mechanism based on long-term returns, improving the global optimality of the rewriting strategy. Compared with traditional static methods, query rewriting can be continuously optimized through implicit feedback, further improving the relevance and response efficiency of query rewriting generation.
[0097] Embodiments
[0098] In order to verify the effectiveness of the scheme of the present application, the following experiments are performed.
[0099] Step 1: Training set preparation and processing
[0100] Step 1.1: Collect 10 million records from the online rewriting logs of existing document retrieval systems. Then perform two rounds of rejection sampling: relevance and increment, obtaining 342071 (query, query rewriting) pairs. In addition, 100032 manual query rewriting data is included in the dataset to ensure that the query rewriting of the SFTModel conforms to human preferences.
[0101] Step 1.2: Collect (query, query rewriting) pairs from online logs, construct the "prompt: Is this a qualified query rewriting?" Then manually label whether it is relevant to construct a (quality classification) instruction dataset;
[0102] Step 1.3: Construct (query, document title) pairs with query and the highest posterior document title, and organize them into "prompt: Does this document title match the query content?"
[0103] Step 1.4: Ask human annotators to generate rewritings for queries and supplement the thinking chain process, finally forming the following "prompt: Your task is to rewrite the input query into a query that is easier to search for related products, and you need to provide the thinking process and query rewriting result. Separate the thinking process and query rewriting result with a semicolon."
[0104] Step 1.5: Select 35000 samples for each task in quality classification, document title prediction, and thinking chain tasks, and combine them with D final , to build a D multi dataset.
[0105] Step 2: Model training
[0106] Step 2.1: SFT stage: The input data is preprocessed, and stop words and tokenization are removed. The hyperparameters are set as follows: learning rate is 1e-5, weight decay is 0.01, batch size is 16, training epochs is 5, and the optimizer is AdamW.
[0107] Next, the current original query is input to GPT-2, and the prompt: For an information-seeking dialog, please help reformulate the question into rewrite that can fully express the user's information needs without the need of context is given to GPT-2, and GPT-2 is asked to rewrite the original query based on these contents.
[0108] Step 2.2: Target alignment stage: Set a = 1 x 10 -6 , g = 0.99, maximum iteration number episode = 1 x 10 6 , batch size = 32, dataset D final
[0109] Step 2.2.1: Initialization: For any state s and a, Q(s, a) = 0, k = 0, t = 0
[0110] Step 2.2.2: Randomly extract batch B multi from D
[0111] Step 2.2.3: Input s to SFTModel to get action a
[0112] Step 2.2.4: Calculate r(s, a) according to formula (9); update Q(s, a)
[0113] Step 2.2.5: If the cumulative reward does not exceed 10, t <- t + 1, s <- (a, t), repeat step 2.2.3
[0114] Step 2.2.6: Every 20 steps, update the target network parameters according to formula (11)
[0115] Step 2.2.7: k <- k + 1, repeat step 2.2.2
[0116] Step 2.2.8: k > 1 x 10 6 , get the converged SFTModel
[0117] Step 3: Model Testing: According to the trained SFTModel, select an input query "please tell me the climate change impact on agriculture." from the test set.
[0118] Step 3.1: Preprocess the query, including tokenization and stop word removal, resulting in:
[0119] "climate / change / impact / agriculture"
[0120] Step 3.2: Use the trained SFTModel to generate query rewriting candidate probability distribution, resulting in the following list of query rewriting candidates:
[0121] "Cropyielddecline duetoclimate change":0.35
[0122] "Impactofclimate change onagriculturalwaterresources":0.25
[0123] "Impactofclimate change onagriculturalpests anddiseases":0.20
[0124] "effects ofglobalwarmingonagriculture":0.10
[0125] "climate change and its impact on farming":0.10
[0126] Step 4: Input the query rewriting candidate list into Beam Search, with the following specific steps:
[0127] Step 4.1: Select the top k query rewriting candidates from the probability distribution generated in step 1.2 as the beam width (the number of candidate sequences maintained at each step), choose k = 3;
[0128] Step 4.2: Use these query rewriting candidates as the initial state of Beam Search;
[0129] Step 4.3: For each candidate, generate the next possible rewrite using the SFTModel. Compute the probability for each newly generated rewrite and multiply it with the probability of the current candidate (probability propagation); then select the top several rewrites with the highest probability as the next step candidates, still with the number k (keep the beam width); repeat the above process until a pre-defined number of iterations is reached or a rewrite sequence that meets the condition is generated, and output the result as follows:
[0130] "Crop yield decline due to climate change"
[0131] "Impact of climate change on agricultural pests and diseases"
[0132] "Impact of climate change on agricultural water resources"
[0133] The technical features of the above embodiments can be combined in any manner. To make the description concise, not all possible combinations of the technical features in the above embodiments are described, but as long as the combinations of the technical features do not contradict, they should be considered within the scope of the present disclosure.
[0134] The above embodiments only express several implementation manners of the present application, and the description is specific and detailed, but it should not be understood as a limitation on the scope of the present application. It should be pointed out that for those skilled in the art, without departing from the concept of the present application, a number of modifications and improvements can be made, which are all within the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the appended claims.
Claims
1. A method for rewriting a document retrieval query based on a large language model, characterized in that, Comprising: Step 1, collect query rewriting data set, correlation filtering and retrieval increment, retain highly relevant data samples to query rewriting task, the specific method is: Step 1.1, user initiates query x i When x∈X, the document retrieval system generates a series of query reformulations Y = {y1, y2, y3,..., yn} according to the reformulation strategy, selects the highest ranked y1 as the first choice, and builds an initial query reformulation dataset D containing N samples; n} Step 1.
2. Rejection sampling on the initial query rewriting dataset D, resulting in dataset D rele ; Step 1.
3. Again, rejection sampling is used on the dataset D rele Relevance filtering, while considering the retrieval increment, retrieving the document titles that recently interacted with the query x as supplementary information, resulting in the final query rewriting dataset D final ; Step 2, collect auxiliary task data set highly relevant to query rewriting task, build multi-task SFT data set; Step 3, based on GPT-2, build self-supervised fine-tuning model, take query as input, take query rewriting as output, use multi-task SFT data set to train self-supervised fine-tuning model; Step 4, regarding self-supervised fine-tuning model as agent, based on reinforcement learning, align target, make it more consistent with user intent when generating query rewriting; Step 5, use beam search algorithm to generate multiple candidate rewritings for each query, input target aligned self-supervised fine-tuning model, retrieve a set of relevant documents. 2.The method of claim 1, wherein, Step 1, collect query rewriting data set, correlation filtering and retrieval increment, retain highly relevant data samples to query rewriting task, the specific method is: Step 1.1, obtain initial query rewriting data set from document retrieval system; User initiates query x i When x∈X, the document retrieval system rewrites x according to the rewriting strategy to generate a series of query rewrites Y = {y1, y2, y3,..., y n}, selects the highest ranked y1 as the first choice, and builds an initial query rewriting dataset D containing N samples: where p(x) is the query distribution in the document search system, π origin and θ origin denote the document retrieval system rewriting strategy and its parameters, respectively; Step 1.2, in order to ensure the semantic relevance of query and rewriting in document retrieval query rewriting, correlation filtering is performed on the initial query rewriting data set D; The initial query rewriting dataset D is rejected sampled according to formula (2) to obtain dataset D rele : where rele(·) and τ rele denote the relevance method and its threshold, respectively, and rele(·) is calculated as follows: wherein, is an indicator function, f(·) is a function that evaluates the relevance between a document title and a query, τ' is a semantic relevance threshold for a query—document title pair, is the list of offline retrieved documents for query rewrite y; Step 1.3, to alleviate the "little recall" problem caused by long-tail queries, again use rejection sampling on dataset D rele Relevance filtering, while considering retrieval increments, retrieve the document titles that recently interacted with query x as supplementary information, get the final query rewriting dataset D final : where ε x is the list of interactive document titles that query x, incr(·) and τ incr are the incremental function and its threshold, respectively, and the formula for incr(·) is given by wherein, represents an offline set of retrieved texts of queries, refers to a curated set of documents. 3.The method of claim 1, wherein, Step 2, collect auxiliary task data set highly relevant to query rewriting task, build multi-task SFT data set, wherein the auxiliary tasks include: a) quality classification task: after extracting query pairs from the initial query rewriting data set D, manually label and evaluate the quality of query rewriting; b) product title prediction task: select the documents clicked by the user's recent query as reference to form (query, document title) pairs; c) thinking chain task: use the original query to build prompts, provide improved query rewriting and explain the thinking process. 4.The method of claim 1, wherein, Step 3, based on GPT-2, build self-supervised fine-tuning model, take query as input, take query rewriting as output, use multi-task SFT data set to train self-supervised fine-tuning model, the specific method is: Given an original query x and its query rewriting y, the training objective of the self-supervised fine-tuning model is to minimize L SFT (θ SFT ), which is calculated as follows: where D multi is the multi-task SFT dataset, (x,y) ~ D multi denotes sampling from D multi , E denotes taking the average of the loss over all samples, i.e., computing the expected loss, and SFT denotes the GPT-2 model and its parameters. 5.The method of claim 1, wherein, Step 4, regarding self-supervised fine-tuning model as agent, based on reinforcement learning, align target, make it more consistent with user intent when generating query rewriting, the specific method is: Define state s, action a, reward r, as follows: s = {x, t} (7) a = SFTModel(s) (8) Where x is the original query rewriting, t is the rewriting times, rele(·) represents the correlation function, incr(·) represents the increment function; SFTModel represents the self-supervised fine-tuning model, β1 and β2 represent the weights of the correlation function and the increment function respectively; Use DQN algorithm to train the agent and update the parameters of the self-supervised fine-tuning model. 6.A document retrieval query rewriting system based on a large language model, characterized by, Implement the large language model based document retrieval query rewriting method according to any one of claims 1-5 to realize large language model based document retrieval query rewriting, which is divided into five modules to execute steps 1-5.
7. A computer device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, wherein when the processor executes the computer program, the large language model based document retrieval query rewriting method according to any one of claims 1-5 is implemented to realize large language model based document retrieval query rewriting.
8. A computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements the method of rewriting a document retrieval query based on a large language model according to any one of claims 1-5, to realize rewriting a document retrieval query based on a large language model.
Citation Information
Patent Citations
Query search method, query information processing method, equipment and storage medium
CN117520477A
Intelligent patent retrieval method and system based on Agent
CN118760761A