Search enhancement method and apparatus for non-knowledge intensive tasks

By employing a two-stage retrieval method that combines task-general and task-specific modules, the problem of balancing training resources and accuracy in non-knowledge-intensive tasks is solved, achieving efficient retrieval enhancement.

CN116501835BActive Publication Date: 2026-04-07TSINGHUA UNIVERSITY
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-04-11
Publication Date
2026-04-07

AI Technical Summary

Technical Problem

Existing technologies cannot simultaneously achieve a balance between limited training resources, good applicability, and high accuracy in non-knowledge-intensive tasks.

Method used

A two-stage retrieval method is adopted. First, a task-general first retrieval module is used to build a shared index to obtain candidate samples. Then, a task-specific second retrieval module is used to sort and rearrange the candidate samples according to the task prompts. Finally, the answer generation module generates the retrieval answer.

Benefits of technology

With relatively low training resource consumption, it achieves high applicability and accuracy, improving the retrieval performance of non-knowledge-intensive tasks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116501835B_ABST
    Figure CN116501835B_ABST
Patent Text Reader

Abstract

The application provides a retrieval enhancement method and device for non-knowledge-intensive tasks, comprising: obtaining a task to be retrieved; inputting the task to be retrieved into a first retrieval module to retrieve in a pre-stored database to obtain a first preset number of candidate samples; inputting the candidate samples and the task to be retrieved into a second retrieval module, sorting the candidate samples in response to a task prompt, and obtaining a second preset number of retrieval samples; and inputting the retrieval samples into a pre-stored answer generation module to obtain a retrieval answer. The application divides retrieval into two stages, uses a first retrieval module to obtain candidate samples in the first stage, uses a second retrieval module to rearrange the candidate samples according to a task prompt in the second stage to obtain retrieval samples, and obtains a retrieval answer according to the retrieval samples. Since the retrieval module does not need to be trained, the application can have good applicability and high accuracy while consuming small training resources.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of data processing, and in particular to a retrieval enhancement method and device for non-knowledge-intensive tasks. BACKGROUND

[0002] Knowledge-intensive tasks (KI tasks) refer to tasks that a human cannot reasonably complete without accessing external knowledge sources, such as question-answering tasks and the like. Correspondingly, non-knowledge-intensive tasks (NKI tasks) refer to other tasks that do not require explicit external knowledge sources, such as sentiment analysis, text classification, language acceptability, and the like. The distribution of generated words in knowledge-intensive tasks is a general, well-studied measure, while non-knowledge-intensive tasks have different requirements for the criteria for retrieval in the retrieval process. That is, non-knowledge-intensive tasks have diverse requirements for the relevance score function in the retrieval process. For example, a text classification task may require similar semantics, while a language acceptability task requires linguistically similar evidence samples. This results in a dilemma in the balance between training cost and task performance for retrieval methods for non-knowledge-intensive tasks: training and updating of indexes can bring better retrieval performance, but greatly increase the consumption of training resources; keeping the index unchanged reduces the overhead, but cannot adapt to the diverse needs of non-knowledge-intensive tasks.

[0003] In summary, the retrieval method for non-knowledge-intensive tasks in the prior art cannot simultaneously consider small training resources, good applicability, and high accuracy. SUMMARY

[0004] The present application provides a retrieval enhancement method and device for non-knowledge-intensive tasks to solve the defect that the prior art cannot simultaneously consider small training resources, good applicability, and high accuracy, and to achieve the effect of simultaneously considering small training resources, good applicability, and high accuracy.

[0005] The present application provides a retrieval enhancement method for non-knowledge-intensive tasks, comprising:

[0006] Obtaining a task to be retrieved;

[0007] Inputting the task to be retrieved into a first retrieval module to perform retrieval in a pre-stored database to obtain a first preset number of candidate samples;

[0008] Inputting the candidate samples and the task to be retrieved into a second retrieval module, sorting the candidate samples in response to a task prompt, and obtaining a second preset number of retrieval samples;

[0009] Inputting the retrieval samples into a pre-stored answer generation module to obtain a retrieval answer.

[0010] According to the retrieval enhancement method for non-knowledge-intensive tasks provided by the application, the candidate samples and the to-be-retrieved task are input into a second retrieval module, the candidate samples are sorted in response to a task prompt, and a second preset number of retrieval samples are obtained, specifically including:

[0011] Obtaining a task prompt;

[0012] In response to the task prompt, based on the candidate samples and the to-be-retrieved task, the candidate samples are labeled by using a pre-constructed language model to obtain prompt-labeled candidate samples;

[0013] The prompt-labeled candidate samples are encoded by using a first preset formula to obtain first representation encoding and second representation encoding of the prompt-labeled candidate samples;

[0014] Based on the first representation encoding, the second representation encoding and the task prompt, the sample similarity of the prompt-labeled candidate samples is calculated by using a second preset formula;

[0015] The prompt-labeled candidate samples are rearranged in a preset order according to the sample similarity;

[0016] The first second preset number of prompt-labeled candidate samples are selected as retrieval samples.

[0017] According to the retrieval enhancement method for non-knowledge-intensive tasks provided by the application, the first preset formula includes:

[0018]

[0019] Wherein, h q represents the first representation encoding, represents the second representation encoding, prefix represents the task prompt, LLM() represents the large language model, [a;b] represents the connection of a and b in the string, q represents the to-be-retrieved task, and e i represents the i-th prompt-labeled candidate sample.

[0020] According to the retrieval enhancement method for non-knowledge-intensive tasks provided by the application, the second preset formula includes:

[0021]

[0022] Wherein, Sim task-specif (q,e i ) represents the sample similarity, h q represents the first representation encoding, represents the second representation encoding, q represents the to-be-retrieved task, and e iThe i-th prompt annotation candidate sample is represented as e j The j-th prompt annotation candidate sample is represented as k, and the second preset number is represented.

[0023] According to the retrieval enhancement method for non-knowledge-intensive tasks provided by the application, the task to be retrieved is input into a first retrieval module, and retrieval is performed in a pre-stored database to obtain a first preset number of candidate samples, specifically including:

[0024] Based on the task to be retrieved, a first retriever constructed in advance is used to construct a shared index in the pre-stored database;

[0025] Based on the shared index, a first preset number of candidate samples are retrieved from the pre-stored database.

[0026] According to the retrieval enhancement method for non-knowledge-intensive tasks provided by the application, the retrieval sample is input into a pre-stored answer generation module to obtain a retrieval answer, specifically including:

[0027] The retrieval sample is input into the answer generation module to obtain a reading result;

[0028] According to the reading result, a retrieval answer is generated.

[0029] The application also provides a retrieval enhancement device for non-knowledge-intensive tasks, comprising:

[0030] The acquisition unit is configured to acquire a task to be retrieved;

[0031] The first retrieval unit is configured to input the task to be retrieved into a first retrieval module, perform retrieval in a pre-stored database, and obtain a first preset number of candidate samples;

[0032] The second retrieval enhancement unit is configured to input the candidate samples and the task to be retrieved into a second retrieval module, sort the candidate samples in response to a task prompt, and obtain a second preset number of retrieval samples;

[0033] The answer generation unit is configured to input the retrieval sample into a pre-stored answer generation module to obtain a retrieval answer.

[0034] The application also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the retrieval enhancement method for non-knowledge-intensive tasks as described above.

[0035] The application further provides a non-transitory computer-readable storage medium, which stores a computer program, and the computer program is executed by a processor to implement the retrieval enhancement method for non-knowledge-intensive tasks.

[0036] The application further provides a computer program product, which comprises a computer program, and the computer program is executed by a processor to implement the retrieval enhancement method for non-knowledge-intensive tasks.

[0037] The retrieval enhancement method and device for non-knowledge-intensive tasks provided by the application obtain a to-be-retrieved task, input the to-be-retrieved task into a first retrieval module, perform retrieval in a pre-stored database to obtain a first preset number of to-be-selected samples, input the to-be-selected samples and the to-be-retrieved task into a second retrieval module, sort the to-be-selected samples in response to a task prompt, and obtain a second preset number of retrieval samples, and input the retrieval samples into a pre-stored answer generation module to obtain a retrieval answer. The application divides retrieval into two stages, uses the first retrieval module to obtain to-be-selected samples in the first stage, uses the second retrieval module to rearrange the to-be-selected samples according to a task prompt in the second stage to obtain retrieval samples, and obtains a retrieval answer according to the retrieval samples. Since the retrieval module does not need to be trained, the application can have good applicability and high accuracy while consuming small training resources. BRIEF DESCRIPTION OF DRAWINGS

[0038] In order to more clearly illustrate the technical solutions in the application or the prior art, the following will briefly introduce the drawings needed in the embodiments or the prior art description. Obviously, the drawings in the following description are some embodiments of the application, and other drawings can be obtained by those skilled in the art without creative effort.

[0039] Figure 1 is one of the flowcharts of the retrieval enhancement method for non-knowledge-intensive tasks provided by the application;

[0040] Figure 2 is another flowchart of the retrieval enhancement method for non-knowledge-intensive tasks provided by the application;

[0041] Figure 3 is a structural schematic diagram of the retrieval enhancement device for non-knowledge-intensive tasks provided by the application;

[0042] Figure 4 is a structural schematic diagram of the electronic device provided by the application.

[0043] Reference signs:

[0044] 310: acquisition unit; 320: first retrieval unit; 330: second retrieval enhancement unit; 340: ;

[0045] 410: processor; 420: communication interface; 430: memory; 440: communication bus. DETAILED DESCRIPTION

[0046] To make the objectives, technical solutions and advantages of the present application clearer, the technical solutions in the present application will be described clearly and completely below with reference to the drawings in the present application. Obviously, the described embodiments are some embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative work fall within the protection scope of the present application.

[0047] Retrieval enhancement aims to enhance the ability of dense models using external non-parametric indexes containing a large amount of knowledge. Such methods have achieved performances equivalent to or even better than large-scale pre-training models on language models, question answering and other tasks. At the same time, such models can be easily updated by replacing external indexes. However, few previous works have explored the performance of retrieval enhancement models on non-knowledge-intensive tasks. Knowledge-intensive tasks (KI tasks) refer to tasks that humans cannot reasonably complete without accessing external knowledge sources, such as question answering tasks; correspondingly, non-knowledge-intensive tasks (NKI tasks) refer to other tasks that do not require explicit external knowledge sources, such as sentiment analysis, text classification, language acceptability, etc. On a large number of KI tasks, a large number of works have revealed the good performance of retrieval enhancement methods, such as language models, text generation, machine translation. Based on this, the present application applies retrieval enhancement to a wide range of NKI tasks and proposes a retrieval enhancement method for non-knowledge-intensive tasks.

[0048] The present application will be described below in conjunction with Figures 1-2 the retrieval enhancement method for non-knowledge-intensive tasks of the present application, Figure 1 a flowchart of the retrieval enhancement method for non-knowledge-intensive tasks provided by the present application, as shown in Figure 1 the figure, comprising the following steps:

[0049] Step 110: acquiring a task to be retrieved. The retrieval task can be any non-knowledge-intensive task, including sentiment analysis tasks, text classification tasks, language acceptability tasks (whether a sentence is reasonable and the grammar is smooth), etc. For example, retrieving content related to "This title not only describes its main character, but also describes the lazy people in the production team".

[0050] Step 120: input the to-be-retrieved task into the first retrieval module, and retrieve in the pre-stored database to obtain a first preset number of candidate samples.

[0051] After obtaining the to-be-retrieved task, based on the to-be-retrieved task, a first retriever is used to construct a shared index in the pre-stored database, and based on the shared index, a first preset number of candidate samples are retrieved from the pre-stored database, such as Figure 2 In some embodiments, the first preset number can be 100 or 150. In this stage, the first retriever needs to retrieve k candidate samples from a large-scale external dataset. In the specific implementation process, some embodiments use the classic BM25, BERT or SimCSE retriever, use the Faiss open source framework to build a large-scale index, and use MIPS for retrieval. It should be noted that the first retriever is shared on all tasks. Since the size of the first retriever used in this stage is small, higher efficiency can be achieved.

[0052] Step 130: input the candidate samples and the to-be-retrieved task into the second retrieval module, sort the candidate samples in response to the task prompt, and obtain a second preset number of retrieval samples.

[0053] After obtaining the first preset number of candidate samples, a second retriever is used to rearrange the k samples retrieved in the previous stage, and d of them are taken out as the final retrieval samples. This stage uses task-specific prompts and pre-built language models (LLM) such as OPT13b for task-specific retrieval.

[0054] Specifically, after obtaining the first preset number of candidate samples, the task prompt is first obtained. For the k candidate samples and the query in the to-be-retrieved task, the prompt method is first used for transformation.

[0055] The prompt method has recently made a lot of breakthroughs. Through the prompt, a variety of tasks can be converted into language model tasks. Therefore, the prompt method can unify different forms of NKI tasks and obtain task-specific representations. For example, in the sentiment classification task, for the sentence to be classified: “a long string of clichés” (label: negative), make a prompt: Does this sentence have positive or negative sentiment? Then the pre-built language model will first convert it into an input-output task that needs to be completed, and the output prompt annotation answer is negative.

[0056] At the same time, training samples can be added as demonstrations in this prompt annotation process to enhance the understanding of the pre-built language model for the task and enhance the model performance. For example:

[0057] Input example:

[0058] Is this sentence positive or negative? - A long list of clichés.

[0059] The answer is negative.

[0060] Input test task:

[0061] Is this sentence positive or negative? - These performances take the movie to a higher level.

[0062] The answer is ___ (wait for the pre-built language model to output the answer).

[0063] In response to the task prompt, input the candidate samples and the to-be-searched task into a pre-built language model, and perform prompt labeling on the candidate samples to obtain prompt-labeled candidate samples. Each prompt-labeled candidate sample includes a candidate sample and an answer output by the pre-built language model on the candidate sample according to the task prompt.

[0064] After the prompt labeling is completed, the pre-built language model encodes each prompt-labeled candidate sample using a first preset formula to obtain a first representation code and a second representation code of the prompt-labeled candidate sample, such as Figure 2 In some embodiments, the pre-built language model is a large language model (LLM).

[0065] The first preset formula includes:

[0066]

[0067] wherein h q represents the first representation code, represents the second representation code, prefix represents the task prompt, LLM() represents the large language model, [a;b] represents the connection of a and b in a string, q represents the to-be-searched task, and e i represents the i-th prompt-labeled candidate sample.

[0068] Finally, the task-specific sample similarity of the sample similarity of the prompt-labeled candidate samples is calculated using the method of maximum dot product, and the second preset formula includes:

[0069]

[0070] wherein Sim task-specific (q,ei) represents the sample similarity, h q represents the first representation code, represents the second representation code, q represents the to-be-searched task, and ei represents the i-th prompt-labeled candidate sample, e j represents the j-th prompt-labeled candidate sample, and k represents the second preset number.

[0071] After the sample similarity of each prompt-labeled candidate sample is calculated, the prompt-labeled candidate samples are rearranged according to the sample similarity in a preset order, and the first second preset number of prompt-labeled candidate samples are selected as retrieval samples. In some embodiments, the preset order can be a descending order. The second preset number can be 8 or 16.

[0072] Step 140: inputting the retrieval samples into a pre-stored answer generation module to obtain retrieval answers.

[0073] After the retrieval samples are obtained, the retrieval samples are input into a pre-stored answer generation module to read the retrieval samples, obtain a reading result, and generate retrieval answers according to the reading result. In some embodiments, the answer generation module includes a reader / generator, specifically, a FiD (Fusion-in-Decoder) can be used as the generator; in the FiD, a T5 model is used as a Seq2seq base model.

[0074] In a specific implementation process, the retrieval enhancement method for non-knowledge-intensive tasks provided by the present application only has a trainable answer generation module, and the rest does not participate in training, so the retrieval enhancement method for non-knowledge-intensive tasks provided by the present application can save considerable computing overhead compared with the prior art. Further, in one embodiment in which the FiD is used as the answer generation module and the T5 model is used as the Seq2seq base model in the FiD, only the T5 model is trained in the entire system.

[0075] In summary, the retrieval enhancement method for non-knowledge-intensive tasks provided by the present application uses a first retriever common to tasks to construct a shared index and take out candidate samples in the first stage, uses a prompt-guided pre-trained language model to rearrange the candidate samples and select retrieval samples in the second stage, and finally the retrieval samples will be input into an answer generation module and generate answers by the answer generation module. This two-stage method can achieve better performance in various NKI tasks while spending acceptable overhead.

[0076] Based on the above embodiment, in the method, the candidate samples and the task to be retrieved are input into a second retrieval module, the candidate samples are sorted in response to a task prompt, and the second preset number of retrieval samples are obtained, specifically including:

[0077] Obtaining a task prompt;

[0078] In response to the task prompt, based on the candidate samples and the task to be retrieved, the candidate samples are prompted and labeled using a pre-constructed language model to obtain prompt-labeled candidate samples;

[0079] The prompt-labeled candidate samples are encoded using a first preset formula to obtain first representation encoding and second representation encoding of the prompt-labeled candidate samples;

[0080] Based on the first representation encoding, the second representation encoding and the task prompt, the sample similarity of the prompt-labeled candidate samples is calculated using a second preset formula;

[0081] According to the sample similarity, the prompt-labeled candidate samples are rearranged in a preset order;

[0082] The first second preset number of prompt-labeled candidate samples are selected as retrieval samples.

[0083] Specifically, after obtaining the first preset number of candidate samples, the k samples retrieved in the previous stage are rearranged using the second retriever, and d samples are taken out as the final retrieval samples. This stage uses task-specific prompts and pre-constructed language models (LLM) such as OPT13b for task-specific retrieval.

[0084] Specifically, after obtaining the first preset number of candidate samples, the task prompt is obtained first. For the k candidate samples and the query in the task to be retrieved, first, the prompt method is used for transformation. In response to the task prompt, the candidate samples and the task to be retrieved are input into a pre-constructed language model, and the candidate samples are prompted and labeled to obtain prompt-labeled candidate samples. Each prompt-labeled candidate sample includes a candidate sample and an answer output of the candidate sample by the pre-constructed language model according to the task prompt.

[0085] After the prompt labeling is completed, each prompt-labeled candidate sample is encoded using a pre-constructed language model using a first preset formula to obtain first representation encoding and second representation encoding of the prompt-labeled candidate samples, wherein the first representation encoding represents the representation of the question, and the second representation encoding is the representation of the prompt-labeled candidate sample, such as Figure 2 In some embodiments, the pre-constructed language model uses a large language model (LLM, Large Language Model).

[0086] Finally, the second preset formula is used to calculate the task-specific sample similarity of the sample similarity of the prompt-labeled candidate sample using the maximum dot product method. After calculating the sample similarity of each prompt-labeled candidate sample, the prompt-labeled candidate samples are rearranged according to the sample similarity in a preset order, and the first second preset number of prompt-labeled candidate samples are selected as retrieval samples. In some embodiments, the preset order can be from large to small. The second preset number can be 8 or 16.

[0087] Based on the above embodiment, in the method, the first preset formula includes:

[0088]

[0089] wherein h q represents the first representation code, represents the second representation code, prefix represents the task prompt, LLM() represents the large language model, [a;b] represents the connection of a and b in the string, q represents the to-be-retrieved task, and e i represents the i-th prompt-labeled candidate sample.

[0090] Specifically, each prompt-labeled candidate sample is encoded using a pre-constructed language model using the first preset formula to obtain the first representation code and the second representation code of the prompt-labeled candidate sample, as Figure 2 In some embodiments, the pre-constructed language model uses a large language model (LLM, Large Language Model).

[0091] The first preset formula includes:

[0092]

[0093] wherein h q represents the first representation code, represents the second representation code, prefix represents the task prompt, LLM() represents the large language model, [a;b] represents the connection of a and b in the string, q represents the to-be-retrieved task, and e i represents the i-th prompt-labeled candidate sample.

[0094] Based on the above embodiment, in the method, the second preset formula includes:

[0095]

[0096] wherein Sim task-specific (q,ei) represents the sample similarity, h q represents the first representation code, represents the second representation code, q represents the to-be-retrieved task, and ei represents the i-th prompt-labeled candidate sample, e j represents the j-th prompt-labeled candidate sample, and k represents the second preset number.

[0097] Specifically, the task-specific sample similarity of the sample similarity of the prompt-labeled candidate sample is calculated using the maximum dot product method by using a second preset formula, and the second preset formula includes:

[0098]

[0099] wherein Sim task-specific (q,ei) represents the sample similarity, h q represents the first representation encoding, represents the second representation encoding, q represents the to-be-retrieved task, and e i represents the i-th prompt-labeled candidate sample, e j represents the j-th prompt-labeled candidate sample, and k represents the second preset number.

[0100] Based on the above embodiment, in the method, the to-be-retrieved task is input to the first retrieval module, and retrieval is performed in the pre-stored database to obtain a first preset number of candidate samples, and specifically includes:

[0101] Based on the to-be-retrieved task, a first retriever constructed in advance is used to construct a shared index in the pre-stored database;

[0102] Based on the shared index, a first preset number of candidate samples are retrieved from the pre-stored database.

[0103] Specifically, after obtaining the to-be-retrieved task, based on the to-be-retrieved task, a first retriever constructed in advance is used to construct a shared index in the pre-stored database, and based on the shared index, a first preset number of candidate samples are retrieved from the pre-stored database, such as Figure 2 In some embodiments, the first preset number can be 100 or 150. In this stage, the first retriever needs to retrieve k candidate samples from a large-scale external dataset. In the specific implementation process, some embodiments use a classic BM25, BERT or SimCSE retriever, use the Faiss open source framework to construct a large-scale index, and use MIPS for retrieval. It should be noted that the first retriever is shared on all tasks. Since the size of the first retriever used in this stage is small, higher efficiency can be achieved.

[0104] Based on the above embodiment, in the method, the retrieval sample is input to the pre-stored answer generation module to obtain a retrieval answer, and specifically includes:

[0105] The search sample is input into a birthdate generator of the answer generation module to obtain a reading result.

[0106] A search answer is generated according to the reading result.

[0107] In one embodiment, the present application also includes: selecting eight task data sets to compare the search method in the prior art and the search enhancement method provided by the present application for non-knowledge-intensive tasks, and the comparison results are shown in Table 2.

[0108] As shown in Table 1, the task data sets include SST-2, SST-5, CoLA, TREC, CR, MR, MPQA, and Subj. The above data sets use the division of LM-BFF (Gao et al., 2021) instead of the original division, as shown in Table 1.

[0109] Table 1 Division of task data sets of LM-BFF

[0110]

[0111] |y| represents the number of classes of the classification task. L represents the average number of words in the input sub. It should be noted that the present application only extracts data from the original training set. The training set and the validation set are divided according to 9:1, and the prompt label is marked on the selected sample by using the label included in the database.

[0112] Specifically, SST (The Stanford Sentiment Treebank, Stanford Sentiment Treebank) is a single sentence classification task, which contains sentences in movie reviews and their human-annotated sentiment. This task is given the sentiment of a sentence, and the category is divided into two categories: positive sentiment (positive, sample label corresponds to 1) and negative sentiment (negative, sample label corresponds to 0), and only uses sentence-level labels. There are two versions available, one with fine-grained labels (five categories) and the other with binary labels, called SST-5 and SST-2, respectively.

[0113] CoLA (The Corpus of Linguistic Acceptability, Corpus of Linguistic Acceptability) is a single sentence classification task, and the corpus comes from books and journals of language theory, and each sentence is labeled as a grammatically correct word sequence. This task is a binary classification task, and the labels are 0 and 1, where 0 represents ungrammatical and 1 represents grammatical.

[0114] TREC (TREC-QA) is one of the most popular and most studied datasets for question answering research. There are two versions of this dataset, and the present invention adopts TREC-6. TREC-6 is divided into 6 categories of questions.

[0115] CR is a dataset of customer reviews on Amazon website. The purpose is to determine whether the sentiment is positive or negative.

[0116] MR (Movie Review). The Movie Review (MR) dataset is a collection of movie reviews, and the purpose is to detect the sentiment related to a particular review and determine whether it is negative or positive.

[0117] MPQA (Multi-Perspective Question Answering) is a corpus of opinion with two category labels. MPQA contains sentences extracted from news articles related to various news sources.

[0118] Subj is a subjectivity dataset, including subjective predictions of sentences in movie reviews and plot summaries, where the task is to classify sentences as subjective or objective.

[0119] k-NN, LM-BFF, RAG, FiD are all existing retrieval models. T5-base is one of the comparison benchmark models.

[0120] Table 2 Multi-task retrieval results

[0121]

[0122] Table 2 shows the results of the benchmark model in the prior art and the retrieval enhancement method (PGRA) provided by the present invention for non-knowledge-intensive tasks for retrieval. For the model using the T5-base backbone network, the present invention uses d = 16. For the model using the T5-large backbone network, due to the GPU memory limit, the present invention uses d = 8 in the second retrieval module. The best result is shown in bold, the second best result is shown in underlined, and the retrieval column indicates whether the method is a retrieval enhancement method. The results show that the retrieval applicability and accuracy of the retrieval enhancement method (PGRA) for non-knowledge-intensive tasks provided by the present invention are higher than those of other models.

[0123] In another embodiment, the present invention also retrieves using different retrieval methods for the same input, as shown in Table 3:

[0124] Table 3 Retrieval of the same input

[0125]

[0126]

[0127] As shown in Table 3, it is obvious that the retrieval sample obtained by the retrieval enhancement method for non-knowledge-intensive tasks provided by the present application has higher relevance to the task to be retrieved (i.e. the input in the table), while the retrieval samples obtained by FiD and RAG in the prior art are weaker in relevance than the present application, involving too many samples with low relevance to the task to be retrieved, and even the predicted labels are wrong. It can be seen that the retrieval enhancement method for non-knowledge-intensive tasks provided by the present application has high accuracy.

[0128] The retrieval enhancement method for non-knowledge-intensive tasks provided by the present application obtains a task to be retrieved; inputs the task to be retrieved into a first retrieval module to perform retrieval in a pre-stored database to obtain a first preset number of candidate samples; inputs the candidate samples and the task to be retrieved into a second retrieval module, sorts the candidate samples in response to a task prompt, and obtains a second preset number of retrieval samples; and inputs the retrieval samples into a pre-stored answer generation module to obtain a retrieval answer. The present application divides retrieval into two stages, uses a first retrieval module to obtain candidate samples in the first stage, and uses a second retrieval module to rearrange the candidate samples according to a task prompt in the second stage to obtain retrieval samples, and obtains a retrieval answer according to the retrieval samples. Since the retrieval module does not need to be trained, the present application can have good applicability and high accuracy while consuming less training resources.

[0129] The retrieval enhancement device for non-knowledge-intensive tasks provided by the present application is described below, and the retrieval enhancement device for non-knowledge-intensive tasks described below can be mutually corresponding to the retrieval enhancement method for non-knowledge-intensive tasks described above. Figure 3 is a structure diagram of the retrieval enhancement device for non-knowledge-intensive tasks provided by the present application, as Figure 3 shown, comprising an acquisition unit 310, a first retrieval unit 320, a second retrieval enhancement unit 330, and an answer generation unit 340, wherein,

[0130] The acquisition unit 310 is configured to acquire a task to be retrieved.

[0131] The first retrieval unit 320 is configured to input the task to be retrieved into a first retrieval module to perform retrieval in a pre-stored database to obtain a first preset number of candidate samples.

[0132] The second retrieval enhancement unit 330 is configured to input the candidate samples and the task to be retrieved into a second retrieval module, sort the candidate samples in response to a task prompt, and obtain a second preset number of retrieval samples.

[0133] The answer generation unit 340 is configured to input the retrieval samples into a pre-stored answer generation module to obtain a retrieval answer.

[0134] Based on the above embodiment, in the device, the candidate samples and the to-be-retrieved task are input to a second retrieval module, the candidate samples are sorted in response to a task prompt, and a second preset number of retrieval samples are obtained, specifically including:

[0135] Obtaining a task prompt;

[0136] In response to the task prompt, based on the candidate samples and the to-be-retrieved task, a pre-constructed language model is used to prompt and label the candidate samples to obtain prompt and label candidate samples;

[0137] The prompt and label candidate samples are encoded using a first preset formula to obtain first and second representation encodings of the prompt and label candidate samples;

[0138] Based on the first and second representation encodings and the task prompt, a second preset formula is used to calculate the sample similarity of the prompt and label candidate samples;

[0139] The prompt and label candidate samples are rearranged according to the sample similarity in a preset order;

[0140] The first second preset number of prompt and label candidate samples are selected as retrieval samples.

[0141] Based on the above embodiment, in the device, the first preset formula includes:

[0142]

[0143] wherein h q represents the first representation encoding, represents the second representation encoding, prefix represents the task prompt, LLM() represents a large language model, [a;b] represents the connection of a and b in a string, q represents the to-be-retrieved task, and e i represents the i-th prompt and label candidate sample.

[0144] Based on the above embodiment, in the device, the second preset formula includes:

[0145]

[0146] wherein Sim task-specific (q,ei) represents the sample similarity, h q represents the first representation encoding, represents the second representation encoding, q represents the to-be-retrieved task, and e i represents the i-th prompt and label candidate sample, e j represents the j-th prompt and label candidate sample, and k represents the second preset number.

[0147] Based on the above embodiment, in the device, the task to be retrieved is input to the first retrieval module, and retrieval is performed in the pre-stored database to obtain a first preset number of candidate samples, specifically including:

[0148] Based on the task to be retrieved, a pre-constructed first retriever is used to construct a shared index in the pre-stored database;

[0149] Based on the shared index, a first preset number of candidate samples are retrieved from the pre-stored database.

[0150] Based on the above embodiment, in the device, the retrieval sample is input to the pre-stored answer generation module to obtain a retrieval answer, specifically including:

[0151] The retrieval sample is input to the answer generator of the answer generation module to obtain a reading result;

[0152] According to the reading result, a retrieval answer is generated.

[0153] The retrieval enhancement device for non-knowledge-intensive tasks provided by the application obtains a task to be retrieved; inputs the task to be retrieved to a first retrieval module, performs retrieval in a pre-stored database, and obtains a first preset number of candidate samples; inputs the candidate samples and the task to be retrieved to a second retrieval module, sorts the candidate samples in response to a task prompt, and obtains a second preset number of retrieval samples; inputs the retrieval sample to a pre-stored answer generation module to obtain a retrieval answer. The application divides retrieval into two stages, uses a first retrieval module to obtain candidate samples in the first stage, uses a second retrieval module to rearrange the candidate samples according to a task prompt in the second stage, obtains retrieval samples, and obtains a retrieval answer according to the retrieval samples. Since the retrieval module does not need to be trained, the application can consume less training resources while having good applicability and high accuracy.

[0154] Figure 4 An example of an entity structure diagram of an electronic device is shown in FIG. Figure 4As shown, the electronic device can include a processor 410, a communications interface 420, a memory 430, and a communications bus 440, wherein the processor 410, the communications interface 420, and the memory 430 complete mutual communication through the communications bus 440. The processor 410 can invoke a logical instruction in the memory 430 to execute a retrieval enhancement method for a non-knowledge-intensive task, which includes: obtaining a to-be-retrieved task; inputting the to-be-retrieved task into a first retrieval module to perform retrieval in a pre-stored database to obtain a first preset number of candidate samples; inputting the candidate samples and the to-be-retrieved task into a second retrieval module, sorting the candidate samples in response to a task prompt, and obtaining a second preset number of retrieval samples; and inputting the retrieval samples into a pre-stored answer generation module to obtain a retrieval answer.

[0155] In addition, the logical instruction in the memory 430 described above can be implemented in the form of a software functional unit and sold or used as an independent product, and can be stored in a computer-readable storage medium. Based on such understanding, the technical solutions of the present application essentially or the part that contributes to the prior art or part of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium, and includes a plurality of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present application. The aforementioned storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a magnetic disk or an optical disk, and various media that can store program codes.

[0156] On the other hand, the present application also provides a computer program product, which includes a computer program, the computer program can be stored on a non-transitory computer readable storage medium, and the computer program can be executed by a processor to enable a computer to execute the retrieval enhancement method for a non-knowledge-intensive task provided by the above-mentioned methods, which includes: obtaining a to-be-retrieved task; inputting the to-be-retrieved task into a first retrieval module to perform retrieval in a pre-stored database to obtain a first preset number of candidate samples; inputting the candidate samples and the to-be-retrieved task into a second retrieval module, sorting the candidate samples in response to a task prompt, and obtaining a second preset number of retrieval samples; and inputting the retrieval samples into a pre-stored answer generation module to obtain a retrieval answer.

[0157] In yet another aspect, the present application also provides a non-transitory computer readable storage medium having stored thereon a computer program, which, when executed by a processor, implements the retrieval enhancement method for non-knowledge-intensive tasks provided by the above method, the method comprising: obtaining a task to be retrieved; inputting the task to be retrieved into a first retrieval module to perform retrieval in a pre-stored database to obtain a first preset number of candidate samples; inputting the candidate samples and the task to be retrieved into a second retrieval module, sorting the candidate samples in response to a task prompt, and obtaining a second preset number of retrieval samples; and inputting the retrieval samples into a pre-stored answer generation module to obtain a retrieval answer.

[0158] The device embodiments described above are merely illustrative, wherein the units described as separate components can or can not be physically separated, and the components displayed as units can or can not be physical units, i.e., can be located in one place or distributed on multiple network units. Part or all of the modules can be selected to achieve the purpose of the present embodiment scheme according to actual needs. Those skilled in the art can understand and implement without creative labor.

[0159] From the above description of the embodiments, those skilled in the art can clearly understand that the embodiments can be realized by means of software plus the necessary general hardware platform, and of course can also be realized by hardware. Based on such understanding, the above technical solutions, essentially or in other words, the part that contributes to the prior art, can be embodied in the form of a software product, which can be stored in a computer readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes a number of instructions to make a computer device (which can be a personal computer, a server, or a network device, etc.) execute the methods described in each embodiment or some part of the embodiments.

[0160] Finally, it should be noted that: the above embodiments are only used to illustrate the technical solutions of the present application, and not to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that they can still modify the technical solutions recorded in the foregoing embodiments, or make equivalent replacements to some technical features; and these modifications or replacements do not make the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims

1. A retrieval enhancement method for non-knowledge-intensive tasks, characterized in that, include: Retrieve the task to be searched; The task to be searched is input into the first search module, and a search is performed in the pre-stored database to obtain a first preset number of candidate samples; The candidate samples and the search task are input into the second search module. In response to the task prompt, the candidate samples are sorted and a second preset number of search samples are obtained. The search sample is input into the pre-stored answer generation module to obtain the search answer; Specifically, the candidate samples and the retrieval task are input into the second retrieval module, and the candidate samples are sorted in response to the task prompts to obtain a second preset number of retrieval samples, including: Get task prompts; In response to the task prompt, based on the candidate samples and the retrieval task, the candidate samples are labeled with prompts using a pre-built language model to obtain the candidate samples with prompts and annotations. The candidate samples for prompt annotation are encoded using a first preset formula to obtain a first characterization code and a second characterization code for the candidate samples for prompt annotation. Based on the first representation encoding, the second representation encoding, and the task prompt, the sample similarity of the prompt-annotated candidate samples is calculated using a second preset formula; The candidate samples with suggested labels are rearranged according to the sample similarity using a preset order; Select the first second preset number of marked samples as search samples; The first preset formula includes: ; in, Indicates the first representation code, This represents the second characterization encoding. This indicates a task prompt. Representing a large language model, [a;b] indicates that a and b are concatenated on the string. Indicates the task to be retrieved. This indicates that the i-th suggestion is labeled as a candidate sample; The second preset formula includes: ; in, Indicates sample similarity. Indicates the first representation code, This represents the second characterization encoding. Indicates the task to be retrieved. This indicates that the i-th prompt is labeled as a candidate sample. This indicates that the j-th suggestion is labeled as a candidate sample. This indicates the second preset quantity.

2. The retrieval enhancement method for non-knowledge-intensive tasks according to claim 1, characterized in that, The task to be searched is input into the first search module, and a search is performed in the pre-stored database to obtain a first preset number of candidate samples, specifically including: Based on the task to be retrieved, a shared index is built in a pre-stored database using a pre-built first retrieval tool; Based on the shared index, a first preset number of candidate samples are retrieved from the pre-stored database.

3. The retrieval enhancement method for non-knowledge-intensive tasks according to claim 1, characterized in that, The search sample is input into the pre-stored answer generation module to obtain the search answer, specifically including: The retrieved sample is input into the generator of the answer generation module to obtain the reading result; The search answer is generated based on the reading results.

4. A retrieval enhancement device for non-knowledge-intensive tasks, characterized in that, include: The acquisition unit is used to acquire the task to be retrieved; The first retrieval unit is used to input the task to be retrieved into the first retrieval module and perform a retrieval in a pre-stored database to obtain a first preset number of candidate samples; The second retrieval enhancement unit is used to input the candidate samples and the retrieval task into the second retrieval module, sort the candidate samples in response to the task prompt, and obtain a second preset number of retrieval samples; the second retrieval enhancement unit is specifically used to: obtain task prompts; in response to the task prompts, based on the candidate samples and the retrieval task, use a pre-built language model to mark the candidate samples with prompts, so as to obtain marked candidate samples; The candidate samples for prompt annotation are encoded using a first preset formula to obtain a first characterization code and a second characterization code for the candidate samples for prompt annotation. Based on the first representation encoding, the second representation encoding, and the task prompt, the sample similarity of the prompt-annotated candidate samples is calculated using a second preset formula; The candidate samples with suggested labels are rearranged according to the sample similarity using a preset order; Select the first second preset number of marked samples as search samples; The first preset formula includes: ; in, Indicates the first representation code, This represents the second characterization encoding. This indicates a task prompt. Representing a large language model, [a;b] indicates that a and b are concatenated on the string. Indicates the task to be retrieved. This indicates that the i-th suggestion is labeled as a candidate sample; The second preset formula includes: ; in, Indicates sample similarity. Indicates the first representation code, This represents the second characterization encoding. Indicates the task to be retrieved. This indicates that the i-th prompt is labeled as a candidate sample. This indicates that the j-th suggestion is labeled as a candidate sample. Indicates the second preset quantity; The answer generation unit is used to input the search sample into the pre-stored answer generation module to obtain the search answer.

5. An electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the retrieval enhancement method for non-knowledge-intensive tasks as described in any one of claims 1 to 3.

6. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the retrieval enhancement method for non-knowledge-intensive tasks as described in any one of claims 1 to 3.

7. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the retrieval enhancement method for non-knowledge-intensive tasks as described in any one of claims 1 to 3.

Citation Information

Patent Citations

  • Providing answers to questions using hypothesis pruning

    CN103229120A

  • Context answer generation method and device, computer equipment and storage medium

    CN119322838A