Interaction method and device based on retrieval enhancement, equipment and storage medium

By introducing a strategy selection model based on retrieval enhancement in human-computer interaction, combining information retrieval and language model, problem information and search strategies are optimized, and the problem of inaccuracy and efficiency of search results in the existing technology is solved, and efficient human-computer interaction is achieved.

CN119807333APending Publication Date: 2025-04-11KE COM (BEIJING) TECHNOLOGY CO LTD
View PDF 0 Cites 4 Cited by

Patent Information

Application Number
CN202411877491.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-18
Publication Date
2025-04-11

AI Technical Summary

Technical Problem

The prior art is difficult to improve the accuracy and efficiency of search results in human-computer interaction, especially in programming tasks, where the interaction efficiency of natural language processing is low.

Method used

By introducing a policy selection model based on search enhancement in the interactive method, combining information retrieval and language model, problem information and search strategies are optimized, and the accuracy and efficiency of search results are improved.

Benefits of technology

It realizes the accuracy and efficiency of search results in human-computer interaction, and improves the interaction efficiency based on natural language by optimizing problem information and search strategies.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119807333A_ABST
    Figure CN119807333A_ABST
Patent Text Reader

Abstract

The invention provides an interaction method and device based on retrieval enhancement, equipment and a storage medium, and after question information input by a user is detected, the question information and a retrieval prompt word are input into a strategy selection model. Obtaining a target retrieval strategy output by the strategy selection model, performing information retrieval according to the target retrieval strategy, inputting a retrieval result and question information into a language model, outputting reply information through the language model, and utilizing a retrieval prompt word for indicating a matching relationship between the retrieval strategy and a question type to retrieve the question. According to the method, the strategy selection model is guided to select the appropriate retrieval strategy for the question input by the user to obtain the retrieval result, the accuracy and the retrieval efficiency of the retrieval result can be improved, the reply information is generated based on the retrieval result and the question information, and therefore natural language-based interaction is assisted by utilizing the language model, and the man-machine interaction efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to artificial intelligence technology, natural language processing technology, and in particular to an interactive method, device, equipment and storage medium based on retrieval enhancement. Background Art

[0002] CodeLink is an Integrated Development Environment (IDE) plug-in designed to help programmers work more efficiently.

[0003] CodeLink mainly consists of two working modules: one is the code completion module, which helps programmers to automatically complete code writing; the other is the dialogue chat module, which allows programmers to interact using natural language to obtain programming information and help programmers solve various problems encountered in programming. Among them, the dialogue chat module needs to be assisted by the Large Language Model (LLM) to complete the interaction work. Summary of the invention

[0004] The embodiments of the present disclosure provide an interaction method, apparatus, device and storage medium based on retrieval enhancement, which can improve the efficiency of human-computer interaction.

[0005] One aspect of an embodiment of the present disclosure provides an interactive method based on retrieval enhancement, including:

[0006] In response to detecting a question input operation, obtaining question information input by the question input operation;

[0007] Input the question information and the search prompt word into the strategy selection model to obtain the target search strategy output by the strategy selection model, wherein the search prompt word includes at least one description information corresponding to the search strategy, the search strategy includes a search data source and a search method, and the description information is used to indicate the type of question matching the search strategy;

[0008] Perform information retrieval based on the target retrieval strategy to obtain retrieval results;

[0009] The search result and the question information are input into a language model, and answer information is output via the language model.

[0010] Optionally, the step of inputting the question information and the search prompt word into a strategy selection model to obtain a target search strategy output by the strategy selection model includes:

[0011] Inputting the question information, the search prompt words and the question optimization prompt words into the strategy selection model, wherein the question optimization prompt words include description information of the question optimization method, and the question optimization method includes at least one of keyword expansion, text error correction and redundant information elimination;

[0012] Through the strategy selection model, the question information is optimized using the question optimization prompt words to obtain optimized question information and search keywords;

[0013] The target search strategy is obtained by performing strategy selection based on the optimization problem information and the search prompt words through the strategy selection model.

[0014] Optionally, performing information retrieval based on the target retrieval strategy to obtain retrieval results includes:

[0015] Vectorizing the search keywords and the optimization question information to obtain a keyword vector and a question vector;

[0016] Based on the target search strategy, information search is performed using the keyword vector and the question vector to obtain the search result.

[0017] Optionally, the search result includes at least one text segment, and the inputting the search result and the question information into a language model, and outputting the answer information through the language model, comprises:

[0018] Inputting the search result and the question information into the language model, and calculating the correlation between each text segment in the search result and the question information through the language model;

[0019] Rearranging the text segments in descending order of relevance to obtain a text sequence;

[0020] Through the language model, text generation is performed based on the text sequence and the question information, and the answer information is output.

[0021] Optionally, the step of inputting the search result and the question information into a language model and outputting the answer information via the language model includes:

[0022] Acquire a question and answer prompt word template corresponding to the current question and answer scenario, and generate a question and answer prompt word corresponding to the current question and answer scenario based on the question and answer prompt word template, the search result, and the question information, wherein the question and answer prompt word includes task description information for guiding the language model to answer the question information based on the search result;

[0023] The question and answer prompt words are input into the language model, and the answer information is output through the language model.

[0024] Optionally, the current question and answer scenario includes a conversation scenario in an integrated development environment IDE.

[0025] Optionally, the method further includes:

[0026] Inputting sample question information and the search prompt word into the strategy selection model, and outputting the target search strategy through the strategy selection model;

[0027] Based on the target retrieval strategy, information retrieval is performed through a retriever to obtain sample retrieval results;

[0028] Inputting the sample search result and the sample question information into the language model, and outputting sample answer information through the language model;

[0029] The retriever and the language model are jointly trained based on a model loss value, and the parameters of the retriever and the language model are updated. The model loss value includes a first loss value and a second loss value. The first loss value is a loss value calculated based on the sample reply information and the standard reply information corresponding to the sample question information, and the second loss value is a loss value calculated based on the correlation between the sample retrieval result and the sample question information.

[0030] Another aspect of the disclosed embodiment provides an interactive device based on retrieval enhancement, including:

[0031] An acquisition module, configured to acquire question information input by the question input operation in response to detecting the question input operation;

[0032] A selection module, used for inputting the question information and the search prompt word into a strategy selection model, and obtaining a target search strategy output by the strategy selection model, wherein the search prompt word includes at least one description information corresponding to the search strategy, the search strategy includes a search data source and a search method, and the description information is used to indicate the type of question matching the search strategy;

[0033] A retrieval module, used to perform information retrieval based on the target retrieval strategy to obtain retrieval results;

[0034] The generation module is used to input the search result and the question information into a language model, and output the answer information through the language model.

[0035] Another aspect of the present disclosure provides an electronic device, including:

[0036] Memory for storing computer programs;

[0037] The processor is used to execute the computer program stored in the memory, and when the computer program is executed, the method described in the above aspects is implemented.

[0038] Another aspect of the embodiments of the present disclosure provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the method described in the above aspects is implemented.

[0039] Another aspect of the embodiments of the present disclosure provides a computer program, including computer program instructions, which implement the methods described in the above aspects when executed by a processor.

[0040] Based on the embodiments of the present disclosure, after detecting the question information input by the user, the question information and the search prompt words are input into the strategy selection model to obtain the target search strategy output by the strategy selection model, so as to perform information retrieval according to the target search strategy, and the search results and the question information are input into the language model, and the reply information is output through the language model. The search prompt words indicating the matching relationship between the search strategy and the question type are used to guide the strategy selection model to select a suitable search strategy for the question input by the user to obtain the search results, which can improve the accuracy and efficiency of the search results, and generate reply information based on the search results and the question information, thereby realizing the use of language models to assist in natural language-based interaction and improving the efficiency of human-computer interaction.

[0041] The technical solution of the present disclosure is further described in detail below through the accompanying drawings and embodiments. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] The accompanying drawings, which constitute a part of the specification, illustrate embodiments of the present disclosure and, together with the description, serve to explain the principles of the present disclosure.

[0043] The present disclosure may be more clearly understood from the following detailed description with reference to the accompanying drawings, in which:

[0044] Figure 1 A flowchart of an embodiment of the retrieval-enhanced interaction method disclosed herein;

[0045] Figure 2 A flowchart of another embodiment of the retrieval-enhanced interaction method disclosed herein;

[0046] Figure 3 A flowchart of another embodiment of the retrieval-enhanced interaction method disclosed herein;

[0047] Figure 4 It is a structural schematic diagram of an embodiment of an interactive device based on retrieval enhancement disclosed in the present invention;

[0048] Figure 5It is a structural schematic diagram of another embodiment of the interactive device based on retrieval enhancement disclosed in the present invention;

[0049] Figure 6 The figure is a schematic diagram of the structure of an application embodiment of the electronic device disclosed in the present invention. DETAILED DESCRIPTION

[0050] Various exemplary embodiments of the present disclosure will now be described in detail with reference to the accompanying drawings. It should be noted that the relative arrangement of components and steps, numerical expressions and numerical values ​​set forth in these embodiments do not limit the scope of the present disclosure unless otherwise specifically stated.

[0051] Those skilled in the art can understand that the terms "first" and "second" in the embodiments of the present disclosure are only used to distinguish different steps, devices or modules, etc., and neither represent any specific technical meaning nor indicate the necessary logical order between them.

[0052] It should also be understood that in the embodiments of the present disclosure, “plurality” may refer to two or more than two, and “at least one” may refer to one, two, or more than two.

[0053] It should also be understood that any component, data or structure mentioned in the embodiments of the present disclosure can generally be understood as one or more, unless explicitly limited or otherwise indicated in the context.

[0054] In addition, the term "and / or" in the present disclosure is only a description of the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in the present disclosure generally indicates that the associated objects before and after are in an "or" relationship.

[0055] It should also be understood that the description of the various embodiments in the present disclosure focuses on the differences between the various embodiments, and the same or similar aspects thereof can be referenced to each other, and for the sake of brevity, they will not be described one by one.

[0056] At the same time, it should be understood that for the convenience of description, the sizes of the various parts shown in the drawings are not drawn according to the actual proportional relationship.

[0057] The following description of at least one exemplary embodiment is merely illustrative in nature and is in no way intended to limit the present disclosure, its application, or uses.

[0058] Technologies, methods, and equipment known to ordinary technicians in the relevant art may not be discussed in detail, but where appropriate, the technologies, methods, and equipment should be considered as part of the specification.

[0059] It should be noted that like reference numerals and letters refer to similar items in the following figures, and therefore, once an item is defined in one figure, it need not be further discussed in subsequent figures.

[0060] Figure 1 A flowchart of an interactive method based on retrieval enhancement is provided for an exemplary embodiment of the present disclosure. The interactive method based on retrieval enhancement of the embodiment of the present disclosure can be implemented by an electronic device deployed with a language model.

[0061] like Figure 1 As shown, the method comprises the following steps:

[0062] Step 101, in response to detecting a question input operation, obtaining question information input by the question input operation.

[0063] In a possible implementation, a user's question input operation may be received through an intelligent question-answering dialog box in an application or webpage to obtain question information input by the question input operation. The question information may include at least one of the following information types: text information, image information, and video information.

[0064] Illustratively, a user inputs the text "What properties and methods are included in entity class A?" through the smart question and answer dialog box, and the text content can be determined as question information input for the question input operation.

[0065] Step 102, input the question information and the search prompt words into the strategy selection model to obtain the target search strategy output by the strategy selection model.

[0066] The search prompt word includes description information corresponding to at least one search strategy, the search strategy includes a search data source and a search method, and the description information is used to indicate the type of question matching the search strategy.

[0067] Retrieval-Augmented Generation (RAG) technology is a natural language processing (NLP) technology that combines information retrieval and generation models, aiming to improve the accuracy and richness of the generation results of the generation model. In traditional generation models (such as GPT-3), the generation process depends on the parameters of the model itself and the trained data, while the RAG model combines the generation task with the retrieval mechanism of the external knowledge base, and can dynamically retrieve relevant information from the external knowledge base and integrate the retrieved information into the generation results, thereby improving the accuracy and coverage of the generation results. RAG technology mainly involves two stages when applied, namely the retrieval stage and the generation stage. For the retrieval stage, given a user input (query), the retrieval module extracts information related to the user input from the external knowledge base (such as a search engine or a specific database); for the generation stage, the generation model combines the retrieved information, user input and context to generate the corresponding answer. The method of the embodiment of the present disclosure realizes human-computer interaction based on natural language by optimizing the RAG technology.

[0068] Optionally, the strategy selection model can be implemented using a large language model (LLM), such as a bidirectional encoder model (BERT), a generative pre-trained transformer (GPT), etc.; it can also be implemented using a pre-trained neural network model with classification function, such as a convolutional neural network, a recurrent neural network, etc. The embodiment of the present disclosure is described using a large language model as an example.

[0069] In one possible implementation, the RAG-based intelligent question-answering scenario may correspond to a variety of data sources for retrieval, such as search engines, databases for storing different types of data or using different index structures, and a variety of retrieval methods, such as similarity retrieval, full-text retrieval, hash retrieval, etc. Different data sources and retrieval methods have different characteristics. Retrieval prompts are prompts used to guide large language models to select target retrieval strategies that match the question information. Retrieval according to the retrieval data source and retrieval method of the target retrieval strategy can obtain retrieval results related to the question information more efficiently and comprehensively.

[0070] Optionally, the search prompt includes description information corresponding to each search strategy, and the description information is used to indicate the question type that matches the search strategy. The large language model can use the description information to determine the question type to which the question information input by the user belongs and determine the corresponding search strategy as the target search strategy. In order to improve the accuracy of strategy selection, the description information may also include examples of questions of the corresponding question type. Illustratively, the embodiment of the present disclosure provides a search prompt in a code writing question and answer scenario as follows:

[0071] Please determine which RAG strategy to use based on the question information entered by the user and the context information of this conversation to help you answer the question better. There are three strategies in total. You need to choose a strategy based on the question and information:

[0072] Notice:

[0073] 1. There are three strategies in total. You need to choose a strategy based on the problem and information.

[0074] 2. Strategy selection method

[0075] **${Strategy_NO_RAG}**: No search enhancement is performed. A common scenario is that the user greets or asks some basic programming questions that are not related to the current workspace.

[0076] **${Strategy_DETAIL}**: The returned granularity is finer, and the search results contain business logic. It is often used to answer questions about a specific business or method logic. If the user is not asking about the specific method implementation, please do not use this strategy.

[0077] **${Strategy_SUMMARIZE}**: Suitable for helping you answer questions related to the overview, classes, and properties of the current workspace, such as what properties and methods the entity class has, how to convert between entity classes, etc.

[0078] Step 103: perform information retrieval based on the target retrieval strategy to obtain retrieval results.

[0079] According to the search data source and search method indicated by the target search strategy, the question information is searched to obtain the search results, wherein the search results include information such as text, images, and videos obtained from the search data source.

[0080] Step 104, input the search results and question information into the language model, and output the answer information through the language model.

[0081] In a possible implementation, the language model can be implemented using a large language model, such as BERT, GPT, etc. Optionally, the strategy selection model in step 102 and the language model in step 104 can use the same large language model, or different models can be used. The large language model is converted into a decision model at zero cost using the search prompt words, thereby simplifying the optimization process of RAG search.

[0082] The reply information output by the language model may include, for example, at least one of reply text, reply image, reply video, etc. After the reply information output by the language model is obtained, the reply information may be displayed through a dialog interface of an application or web page.

[0083] Based on the disclosed embodiment, after detecting the question information input by the user, the question information and the search prompt word are input into the strategy selection model. The target search strategy output by the strategy selection model is obtained, so that information search is performed according to the target search strategy, the search results and the question information are input into the language model, and the language model outputs the reply information. The search prompt word indicating the matching relationship between the search strategy and the question type is used to guide the strategy selection model to select a suitable search strategy for the question input by the user to obtain the search results, which can improve the accuracy and search efficiency of the search results, and generate reply information based on the search results and question information, thereby realizing the use of the language model to assist in natural language-based interaction and improving the efficiency of human-computer interaction.

[0084] In a possible implementation, during the intelligent question-answering process, the natural language question information input by the user may have problems such as unclear question expression, unclear intention, or too much information. If the search strategy is selected directly based on the question information input by the user, the search results may be inaccurate. Therefore, before selecting the search strategy, it is necessary to optimize the question information first. Figure 2 As shown, the above step 102 may specifically include the following steps:

[0085] Step 201: input question information, search prompt words and question optimization prompt words into a strategy selection model.

[0086] The question optimization prompt includes description information of the question optimization method, which includes at least one of keyword expansion, text error correction, and redundant information elimination, and may also include the characteristics and examples corresponding to each optimization method. The question optimization prompt enables the language model to clarify the question information and appropriately expand the relevant keywords to improve the search effect.

[0087] Step 202, through the strategy selection model, the question information is optimized using the question optimization prompt words to obtain the optimized question information and the search keywords.

[0088] In a possible implementation, the strategy selection model may use a large language model, which may optimize question information based on the guidance of question optimization prompt words, obtain optimized question information, and screen out search keywords based on the optimized question information.

[0089] Illustratively, for the question information “What is the purpose of the userInfo parameter in the addUser method in ADemoController?”, the strategy selection model can perform problem optimization to obtain the optimized question information “What is the purpose of the `userInfo` parameter in the `addUser` method within the `ADemoController` class?”, and filter out the keywords “ADemoController, addUser method, userInfo parameter, parameter usage” based on the optimized question information.

[0090] Step 203: A strategy selection model is used to select a strategy based on the optimization problem information and the search prompt words to obtain a target search strategy.

[0091] Furthermore, when selecting a search strategy, the strategy selection model can select a strategy based on the optimization question information and the search prompt words, thereby making the search results more accurate.

[0092] based on Figure 2 In the illustrated embodiment, after optimizing the question information to obtain the optimized question information, the above step 103 may specifically include the following steps: Step 103a, vectorizing the search keywords and the optimized question information to obtain a keyword vector and a question vector.

[0093] Step 103b, based on the target search strategy, use the keyword vector and the question vector to perform information search and obtain the search results.

[0094] In a possible implementation, an embedding network is provided in the language model, through which the search keywords and optimization question information can be converted into keyword vectors and question vectors.

[0095] Based on the embodiments of the present disclosure, question information is optimized through at least one question optimization method to obtain clear and complete optimized question information and more comprehensive search keywords. A search strategy is selected based on the optimized question information to obtain a target search strategy. Information is retrieved using the optimized question information and search keywords according to the target search strategy, which can improve the accuracy of information retrieval and thus improve the accuracy of reply information.

[0096] In a possible implementation, the search result includes at least one text segment. Usually, when searching for question information, multiple text segments can be obtained from the data source. Different text segments have different specific text contents and may also have different relevance to the question information. Therefore, in order to improve the accuracy of the reply information, the language model can first reorder the text segments and then organize various types of information to generate reply information. Figure 1 Based on the examples shown, please refer to Figure 3 , the above step 104 may specifically include the following steps:

[0097] Step 301: input the search results and question information into a language model, and calculate the correlation between each text segment in the search results and the question information through the language model.

[0098] Step 302: reorder the text segments in descending order of relevance to obtain a text sequence.

[0099] Step 303: Generate text based on the text sequence and question information through a language model, and output reply information.

[0100] In one possible implementation, the language model includes a rerank module. After the retrieval results and question information are input into the language model, the rerank module is first used to calculate the correlation between each text segment in the retrieval results and the question information, and the text segments are reranked in descending order of correlation to obtain a text sequence.

[0101] Optionally, after reordering the text fragments in descending order of relevance, the first n text fragments with the highest relevance may be selected to form a text sequence, so as to eliminate text fragments with lower relevance and importance, so as to avoid affecting the accuracy of the reply information.

[0102] Schematically, the rerank module obtains the text feature vector of each text segment and the question feature vector of the question information, and obtains the correlation between the text segment and the question information by calculating the similarity between the text feature vector and the question feature vector of the question information.

[0103] Based on the embodiments of the present disclosure, the text segments are reordered based on the correlation between each text segment and the question information, and the reply information is generated based on the text sequence obtained by the reordering, so that the accuracy of the reply information can be improved.

[0104] In a possible implementation, the question-answer prompt words may be used to guide the language model to perform the task of answering questions and generate answer information. The above step 104 may also include the following steps:

[0105] Obtain a question and answer prompt word template corresponding to the current question and answer scenario, generate question and answer prompt words corresponding to the current question and answer scenario based on the question and answer prompt word template, retrieval results and question information, the question and answer prompt words include task description information for guiding the language model to answer the question information based on the retrieval results; input the question and answer prompt words into the language model, and output the answer information through the language model.

[0106] Optionally, the method provided by the embodiment of the present disclosure can be applied to a variety of question-answering scenarios, such as intelligent assistants for electronic products, intelligent customer service for shopping platforms, etc. The conversation topics and user requirements for reply information in different question-answering scenarios may be different, so the question-answering prompt word template corresponding to the current question-answering scenario can be designed, and the question-answering prompt word template, search results, and question information can be combined to generate the question-answering prompt word corresponding to the current question-answering scenario, thereby guiding the language model to complete the question-answering task in the current question-answering scenario.

[0107] Indicatively, the current question-and-answer scenario includes a conversation scenario in an IDE. For example, it can be applied to a conversation chat work module of an IDE, which can assist users in obtaining programming information through natural language interaction and help users solve various problems encountered in programming.

[0108] In a possible implementation, a retriever may be used for information retrieval. Before performing intelligent question answering, joint training may be performed on the retriever and the language model to optimize the parameters of the retriever and the language model. The method provided in the embodiment of the present disclosure may also include the following steps:

[0109] Step 1: Input sample question information and search prompt words into the strategy selection model, and output the target search strategy through the strategy selection model.

[0110] Step 2: Based on the target retrieval strategy, information retrieval is performed through the retriever to obtain sample retrieval results.

[0111] Step three: input the sample retrieval results and sample question information into the language model, and output the sample answer information through the language model.

[0112] Step 4: Jointly train the retriever and language model based on the model loss value and update the parameters of the retriever and language model.

[0113] Among them, the model loss value includes a first loss value and a second loss value. The first loss value is a loss value calculated based on the sample response information and the standard response information corresponding to the sample question information. The second loss value is a loss value calculated based on the correlation between the sample retrieval result and the sample question information.

[0114] Optionally, the retriever and language model can be trained separately first, and then fine-tuned through joint training.

[0115] Optionally, in the joint training stage, a training data set is first obtained, which includes sample question information and standard answer information (sample labels) corresponding to each sample question information. The sample question information and the search prompt word are input into the strategy selection model to obtain the target search strategy output by the strategy selection model, and then the retriever performs information retrieval according to the target retrieval strategy to obtain the sample retrieval result. At this time, the second loss value can be calculated based on the correlation between the sample retrieval result and the sample question information. For example, the second loss value can be determined by calculating the similarity between the vector of the sample retrieval result and the vector of the sample question information. The higher the similarity, the smaller the second loss value. The sample retrieval result and the sample question information are input into the language model to obtain the sample answer information output by the language model. At this time, the first loss value can be calculated based on the sample answer information and the standard answer information. The model loss value can be obtained by weighted summing the first loss value and the second loss value, so that the retriever and the language model are jointly trained based on the model loss value.

[0116] Figure 4 The structural block diagram of an interactive device based on retrieval enhancement provided by an exemplary embodiment of the present disclosure is shown. The interactive device based on retrieval enhancement includes:

[0117] The acquisition module 401 is used for acquiring question information input by the question input operation in response to detecting the question input operation;

[0118] A selection module 402 is used to input the question information and search prompt words obtained by the acquisition module 401 into a strategy selection model to obtain a target search strategy output by the strategy selection model, wherein the search prompt words include description information corresponding to at least one search strategy, the search strategy includes a search data source and a search method, and the description information is used to indicate the type of question matching the search strategy;

[0119] A retrieval module 403 is used to perform information retrieval based on the target retrieval strategy selected by the selection module 402 to obtain retrieval results;

[0120] The generation module 404 is used to input the search results retrieved by the search module 403 and the question information into the language model, and output the answer information through the language model.

[0121] Optionally, in a possible implementation manner, the selection module 402 may also be used to:

[0122] Inputting question information, search prompt words and question optimization prompt words into the strategy selection model, wherein the question optimization prompt words include description information of the question optimization method, and the question optimization method includes at least one of keyword expansion, text error correction, and redundant information elimination;

[0123] Through the strategy selection model, the question information is optimized using the question optimization prompt words to obtain the optimized question information and search keywords;

[0124] Through the strategy selection model, strategy selection is performed based on the optimization problem information and retrieval prompt words to obtain the target retrieval strategy.

[0125] Optionally, in a possible implementation manner, the retrieval module 403 may also be used to:

[0126] Vectorize the search keywords and optimization question information to obtain keyword vectors and question vectors;

[0127] Based on the target retrieval strategy, keyword vectors and question vectors are used to perform information retrieval and obtain retrieval results.

[0128] Optionally, in a possible implementation, the search result includes at least one text segment, and the generation module 404 may also be used to:

[0129] Input the search results and question information into the language model, and use the language model to calculate the correlation between each text segment in the search results and the question information;

[0130] Reorder the text fragments in descending order of relevance to obtain a text sequence;

[0131] Through the language model, text is generated based on the text sequence and question information, and the answer information is output.

[0132] Optionally, in a possible implementation, the search result includes at least one text segment, and the generation module 404 may also be used to:

[0133] Obtaining a question-answering prompt word template corresponding to the current question-answering scenario, and generating a question-answering prompt word corresponding to the current question-answering scenario based on the question-answering prompt word template, the retrieval results, and the question information, wherein the question-answering prompt word includes task description information for guiding the language model to answer the question information based on the retrieval results;

[0134] The question-answer prompt words are input into the language model, and the answer information is output through the language model.

[0135] Optionally, in a possible implementation, the current question-and-answer scenario includes a conversation scenario in an integrated development environment IDE.

[0136] Optionally, in a possible implementation manner, the selection module 402 is further configured to:

[0137] Input sample question information and search prompt words into the strategy selection model, and output the target search strategy through the strategy selection model;

[0138] like Figure 5 As shown, the interactive device based on retrieval enhancement also includes:

[0139] The sample retrieval module 501 is used to perform information retrieval through a retriever based on a target retrieval strategy to obtain a sample retrieval result;

[0140] The sample generation module 502 is used to input the sample search results and sample question information retrieved by the sample search module 501 into the language model, and output sample answer information through the language model;

[0141] The joint training module 503 is used to jointly train the retriever and the language model based on the model loss value, and update the parameters of the retriever and the language model, wherein the model loss value includes a first loss value and a second loss value, the first loss value is a loss value calculated based on the sample reply information and the standard reply information corresponding to the sample question information, and the second loss value is a loss value calculated based on the correlation between the sample retrieval result and the sample question information.

[0142] Each embodiment in this specification is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The parts of the same, similar or corresponding contents between the various embodiments can be referred to each other. Since the method, device, system, and equipment embodiments are basically corresponding, the relevant parts can be referred to the description of the corresponding parts. The methods, devices, systems, and equipment of the embodiments of the present disclosure also correspond to each other in specific implementation methods and beneficial technical effects. The relevant contents can be referred to each other and will not be repeated.

[0143] In addition, an embodiment of the present disclosure further provides an electronic device, including:

[0144] Memory for storing computer programs;

[0145] The processor is used to execute the computer program stored in the memory, and when the computer program is executed, the retrieval-enhanced interaction method described in any of the above embodiments of the present disclosure is implemented.

[0146] Figure 6 This is a schematic diagram of the structure of an application embodiment of the electronic device disclosed in the present invention. Figure 6 The electronic device according to the embodiment of the present disclosure is described. The electronic device may be any one or both of the first device and the second device, or a stand-alone device independent of them, and the stand-alone device may communicate with the first device and the second device to receive the collected input signals from them.

[0147] like Figure 6 As shown, the electronic device includes one or more processors and memory.

[0148] The processor may be a central processing unit (CPU) or other forms of processing units having data processing capabilities and / or instruction execution capabilities, and may control other components in the electronic device to perform desired functions.

[0149] The memory may include one or more computer program products, and the computer program product may include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. The volatile memory may include, for example, a random access memory (RAM) and / or a cache memory (cache), etc. The non-volatile memory may include, for example, a read-only memory (ROM), a hard disk, a flash memory, etc. One or more computer program instructions may be stored on the computer-readable storage medium, and the processor may execute the program instructions to implement the interactive method based on retrieval enhancement and / or other desired functions of the various embodiments of the present disclosure described above.

[0150] In one example, the electronic device may further include: an input device and an output device, and these components are interconnected via a bus system and / or other forms of connection mechanisms (not shown).

[0151] In addition, the input device may also include, for example, a keyboard, a mouse, and the like.

[0152] The output device can output various information to the outside, including the determined distance information, direction information, etc. The output device can include, for example, a display, a speaker, a printer, a communication network and a remote output device connected thereto, and the like.

[0153] Of course, to simplify, Figure 6 Only some of the components related to the present disclosure in the electronic device are shown, and components such as a bus, an input / output interface, etc. are omitted. In addition, according to specific application situations, the electronic device may further include any other appropriate components.

[0154] In addition to the above-mentioned methods and devices, an embodiment of the present disclosure may also be a computer program product, which includes computer program instructions, which, when executed by a processor, enable the processor to execute the steps of the retrieval-enhanced interaction method according to various embodiments of the present disclosure described in the above part of this specification.

[0155] The computer program product may be written in any combination of one or more programming languages ​​to write program code for performing the operations of the disclosed embodiments, including object-oriented programming languages ​​such as Java, C++, etc., and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server.

[0156] In addition, an embodiment of the present disclosure may also be a computer-readable storage medium having computer program instructions stored thereon, which, when executed by a processor, enable the processor to execute the steps of the retrieval-enhanced interaction method according to various embodiments of the present disclosure described in the above part of this specification.

[0157] The computer readable storage medium can adopt any combination of one or more readable media. The readable medium can be a readable signal medium or a readable storage medium. The readable storage medium can include, for example, but is not limited to, a system, device or device of electricity, magnetism, light, electromagnetic, infrared, or semiconductor, or any combination of the above. More specific examples (non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.

[0158] A person of ordinary skill in the art can understand that all or part of the steps of implementing the above method embodiment can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps of the above method embodiment; and the aforementioned storage medium includes: ROM, RAM, magnetic disk or optical disk, etc., various media that can store program codes.

[0159] The basic principles of the present disclosure are described above in conjunction with specific embodiments. However, it should be noted that the advantages, strengths, effects, etc. mentioned in the present disclosure are only examples and not limitations, and it cannot be considered that these advantages, strengths, effects, etc. are required by each embodiment of the present disclosure. In addition, the specific details disclosed above are only for the purpose of illustration and ease of understanding, and are not limitations. The above details do not limit the present disclosure to the necessity of adopting the above specific details to be implemented.

[0160] Each embodiment in this specification is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the system embodiment, since it basically corresponds to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0161] The block diagrams of the devices, apparatuses, equipment, and systems involved in this disclosure are only illustrative examples and are not intended to require or imply that they must be connected, arranged, and configured in the manner shown in the block diagrams. As will be appreciated by those skilled in the art, these devices, apparatuses, equipment, and systems can be connected, arranged, and configured in any manner. Words such as "including," "comprising," "having," and the like are open words, referring to "including but not limited to," and can be used interchangeably therewith. The words "or" and "and" used herein refer to the words "and / or," and can be used interchangeably therewith, unless the context clearly indicates otherwise. The word "such as" used herein refers to the phrase "such as but not limited to," and can be used interchangeably therewith.

[0162] The method and apparatus of the present disclosure may be implemented in many ways. For example, the method and apparatus of the present disclosure may be implemented by software, hardware, firmware, or any combination of software, hardware, and firmware. The above order of steps for the method is for illustration only, and the steps of the method of the present disclosure are not limited to the order specifically described above, unless otherwise specifically stated. In addition, in some embodiments, the present disclosure may also be implemented as a program recorded in a recording medium, which includes machine-readable instructions for implementing the method according to the present disclosure. Therefore, the present disclosure also covers a recording medium storing a program for executing the method according to the present disclosure.

[0163] It should also be noted that in the apparatus, device and method of the present disclosure, each component or each step can be decomposed and / or recombined. Such decomposition and / or recombination should be regarded as equivalent solutions of the present disclosure.

[0164] The above description of the disclosed aspects is provided to enable any person skilled in the art to make or use the present disclosure. Various modifications to these aspects will be readily apparent to those skilled in the art, and the general principles defined herein may be applied to other aspects without departing from the scope of the present disclosure. Therefore, the present disclosure is not intended to be limited to the aspects shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.

[0165] The above description has been given for the purpose of illustration and description. In addition, this description is not intended to limit the embodiments of the present disclosure to the forms disclosed herein. Although multiple example aspects and embodiments have been discussed above, those skilled in the art will recognize certain variations, modifications, changes, additions and sub-combinations thereof.

Claims

1. An interactive method based on retrieval enhancement, characterized in that: include: In response to detecting a question input operation, obtaining question information input by the question input operation; Input the question information and the search prompt word into the strategy selection model to obtain the target search strategy output by the strategy selection model, wherein the search prompt word includes at least one description information corresponding to the search strategy, the search strategy includes a search data source and a search method, and the description information is used to indicate the type of question matching the search strategy; Perform information retrieval based on the target retrieval strategy to obtain retrieval results; The search result and the question information are input into a language model, and answer information is output via the language model.

2. The method according to claim 1, characterized in that The step of inputting the question information and the search prompt word into a strategy selection model to obtain a target search strategy output by the strategy selection model includes: Inputting the question information, the search prompt words and the question optimization prompt words into the strategy selection model, wherein the question optimization prompt words include description information of the question optimization method, and the question optimization method includes at least one of keyword expansion, text error correction and redundant information elimination; Through the strategy selection model, the question information is optimized using the question optimization prompt words to obtain optimized question information and search keywords; The target search strategy is obtained by performing strategy selection based on the optimization problem information and the search prompt words through the strategy selection model.

3. The method according to claim 2, characterized in that The information retrieval is performed based on the target retrieval strategy to obtain retrieval results, including: Vectorizing the search keywords and the optimization question information to obtain a keyword vector and a question vector; Based on the target search strategy, information search is performed using the keyword vector and the question vector to obtain the search result.

4. The method according to any one of claims 1 to 3, characterized in that: The retrieval result includes at least one text segment, and the inputting the retrieval result and the question information into a language model, and outputting the answer information through the language model, comprises: Inputting the search result and the question information into the language model, and calculating the correlation between each text segment in the search result and the question information through the language model; Rearranging the text segments in descending order of relevance to obtain a text sequence; Through the language model, text generation is performed based on the text sequence and the question information, and the answer information is output.

5. The method according to any one of claims 1 to 3, characterized in that: The step of inputting the search result and the question information into a language model and outputting answer information via the language model comprises: Acquire a question and answer prompt word template corresponding to the current question and answer scenario, and generate a question and answer prompt word corresponding to the current question and answer scenario based on the question and answer prompt word template, the search result, and the question information, wherein the question and answer prompt word includes task description information for guiding the language model to answer the question information based on the search result; The question and answer prompt words are input into the language model, and the answer information is output through the language model.

6. The method according to claim 5, characterized in that The current question-and-answer scenario includes a dialogue scenario in an integrated development environment IDE.

7. The method according to any one of claims 1 to 3, characterized in that: The method further comprises: Inputting sample question information and the search prompt word into the strategy selection model, and outputting the target search strategy through the strategy selection model; Based on the target retrieval strategy, information retrieval is performed through a retriever to obtain sample retrieval results; Inputting the sample search result and the sample question information into the language model, and outputting sample answer information through the language model; The retriever and the language model are jointly trained based on a model loss value, and the parameters of the retriever and the language model are updated. The model loss value includes a first loss value and a second loss value. The first loss value is a loss value calculated based on the sample reply information and the standard reply information corresponding to the sample question information, and the second loss value is a loss value calculated based on the correlation between the sample retrieval result and the sample question information.

8. An interactive device based on retrieval enhancement, characterized in that: include: An acquisition module, configured to acquire question information input by the question input operation in response to detecting the question input operation; A selection module, used for inputting the question information and the search prompt word into a strategy selection model, and obtaining a target search strategy output by the strategy selection model, wherein the search prompt word includes at least one description information corresponding to the search strategy, the search strategy includes a search data source and a search method, and the description information is used to indicate the type of question matching the search strategy; A retrieval module, used to perform information retrieval based on the target retrieval strategy to obtain retrieval results; The generation module is used to input the search result and the question information into a language model, and output the answer information through the language model.

9. An electronic device, characterized in that: include: Memory for storing computer programs; A processor is used to execute the computer program stored in the memory, and when the computer program is executed, the method described in any one of claims 1 to 7 is implemented.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method described in any one of claims 1 to 7 is implemented.

11. A computer program comprising computer program instructions, characterized in that When the computer program instructions are executed by a processor, the method described in any one of claims 1 to 7 is implemented.

Citation Information

Cited By

  • Output result generation method and system, electronic equipment and storage medium

    CN120277131A

  • Output result generation method and system, electronic device, and storage medium

    CN120277131B

  • Orchestrable RAG retrieval system and retrieval method

    CN120541119A

  • Medical question and answer method, device, equipment and program product

    CN121011362A