Retrieval enhancement generation method, system, device and medium, and question-answering method and system
By using the recommended model and Bi-LSTM network optimization search process in the RAG method, the problem of uncatched user preferences and usage habits is solved, and the accuracy of RAG results and large-scale customized deployment are achieved.
Patent Information
- Application Number
- CN202411063791.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-05
- Publication Date
- 2024-12-03
- Estimated Expiration
- 2044-08-05
AI Technical Summary
The existing RAG methods cannot capture user preferences and usage habits, resulting in the search results that do not meet user needs and it is difficult to achieve large-scale customized deployment.
By obtaining the query statement to be retrieved, converting it into knowledge slices based on the trained coding model, and inputting it into the recommended model for sorting, building the training set and test set, using the Bi-LSTM network to build the recommended model, and optimizing the search of RAG The process is to meet user preferences and usage habits.
It achieves the accuracy of RAG results, conforms to user preferences and usage habits, and supports large-scale customized deployment.
Smart Images

Figure CN118586504B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of data processing technology and relates to a retrieval enhancement generation method, system, device and medium and a question-answering method and system. Background Art
[0002] The current mainstream RAG method is to directly slice any document by force, that is, to slice directly by a fixed number of words or to first slice into sentences based on obvious sentence symbols, and then integrate the sentences into slices according to the maximum degree of repetition. Then, after the slices are vectorized, they are matched with the vectorized vectors of the user query for similarity. After finding the knowledge slice that is most similar to the query sentence, the slice combination is loaded into the prompt word and input into the large language model to answer the user's question.
[0003] The problem with this approach is that the vectorization of knowledge slices is based on the same encoding model (such as BAAI-M3, BERT-base-uncased, etc.). These models are pre-trained based on massive public corpus data. Their input is the text in the knowledge slice, and their output is a semantic vector of fixed dimension, such as 1024 dimensions. This process is called encoding. The parameters of the pre-trained model that the encoding process relies on are fixed. Therefore, for each query, when the input query statement remains unchanged, the closest knowledge slice obtained is always the same. However, users may have their own preferences for a query question. For example, for the question "Information of the main managers of xx unit", RAG gives similar knowledge slices, such as 6. User A may prefer to use 1, 2, and 3 of them, while user B may prefer to use 2, 3, and 4 of them; even due to the limitations of the model itself, there may be no slices in the first 6 slices that meet the user's query requirements, and the user needs to manually enter the correct slice path. The current RAG cannot capture this kind of interactive data that is closely related to user preferences and usage habits, making it difficult to optimize its own accuracy based on the usage process and unable to achieve large-scale customized deployment. Summary of the invention
[0004] The purpose of the present invention is to overcome the shortcomings of the above-mentioned prior art and provide a retrieval enhancement generation method, system, device and medium and a question-answering method and system, which can interact with data based on user preferences and usage habits.
[0005] In order to achieve the above object, the present invention adopts the following technical scheme:
[0006] In one aspect of the present invention, the search enhancement generation method of the present invention comprises:
[0007] Get the query statement to be retrieved;
[0008] Converting the query statement to be retrieved into K knowledge slices to be enhanced based on the trained encoding model;
[0009] The K knowledge slices to be enhanced are input into the trained recommendation model to obtain a number of enhanced knowledge slices and their ranking.
[0010] The retrieval enhancement generation method of the present invention is further improved in that:
[0011] Furthermore, the process of converting the query statement to be retrieved into K knowledge slices to be enhanced based on the trained encoding model is as follows:
[0012] The query statement to be retrieved is converted into a dense semantic vector through the encoding model;
[0013] In the RAG knowledge base, K knowledge slices with the smallest semantic vector cosine distance from the dense semantic vector are queried, and the queried K knowledge slices are used as K knowledge slices to be enhanced.
[0014] Furthermore, before inputting the K knowledge slices to be enhanced into the trained recommendation model, the step further includes:
[0015] Construct training sets and test sets;
[0016] Build a recommendation model;
[0017] The recommendation model is trained and tested using the training set and the test set to obtain a trained recommendation model.
[0018] Furthermore, the process of constructing the training set and the test set is:
[0019] Obtain several query statement samples;
[0020] Convert query sentence samples into dense semantic vector samples through the encoding model;
[0021] In the RAG knowledge base, the K knowledge slice samples with the smallest semantic vector cosine distance between the dense semantic vector sample and the K knowledge slice samples are queried, and the user selects K’ A sample of knowledge slices;
[0022] The K knowledge slice samples and their order are used as input, and the user selects K’ The knowledge slice samples and the order selected by the user are used as output to construct the training set and the test set.
[0023] Furthermore, the process of building the recommendation model is as follows:
[0024] Build a recommendation model based on Bi-LSTM network.
[0025] In a second aspect of the present invention, the search enhancement generation system of the present invention comprises:
[0026] A first acquisition module, used to acquire a query statement to be retrieved;
[0027] A first conversion module, used for converting the query statement to be retrieved into K knowledge slices to be enhanced based on the trained encoding model;
[0028] The first enhancement module is used to input the K knowledge slices to be enhanced into the trained recommendation model to obtain a number of enhanced knowledge slices and their ranking.
[0029] In a third aspect of the present invention, the computer device of the present invention comprises a memory, a processor and a computer program stored in the memory and executable on the processor, and the processor implements the steps of the retrieval enhancement generation method when executing the computer program.
[0030] In a fourth aspect of the present invention, the computer-readable storage medium of the present invention stores a computer program, and when the computer program is executed by a processor, the steps of the retrieval enhancement generation method are implemented.
[0031] In a fifth aspect of the present invention, the question-answering method of the present invention comprises:
[0032] Get the query question;
[0033] Convert the query question into K knowledge slices to be enhanced based on the trained encoding model;
[0034] Inputting the K knowledge slices to be enhanced into the trained recommendation model to obtain a number of enhanced knowledge slices and their ranking;
[0035] The enhanced knowledge slices are spliced according to their order, embedded into a prompt word template, and then input into a large language model to obtain answers to questions preferred by users.
[0036] In a sixth aspect of the present invention, the question-answering system of the present invention comprises:
[0037] The second acquisition module is used to acquire the query question;
[0038] A second conversion module, used for converting the query question into K knowledge slices to be enhanced based on the trained encoding model;
[0039] A second enhancement module is used to input the K knowledge slices to be enhanced into the trained recommendation model to obtain a plurality of enhanced knowledge slices and their ranking;
[0040] The question-answering module is used to splice the enhanced knowledge slices according to their order, embed them into a prompt word template, and then input them into a large language model to obtain answers to questions preferred by users.
[0041] The present invention has the following beneficial effects:
[0042] During specific operation, the retrieval enhancement generation method, system, device and medium and the question-answering method and system described in the present invention optimize the RAG retrieval process based on the trained coding model to make the information more accurate, and then further screen and sort the retrieved results through the trained recommendation model, so that the RAG results can gradually meet the user's preferences and usage habits during use, thereby realizing large-scale customized deployment. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] The accompanying drawings constituting a part of the present invention are used to provide a further understanding of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the accompanying drawings:
[0044] Figure 1 A flowchart of the retrieval enhancement generation method of the present invention;
[0045] Figure 2 This is a training flow chart of the recommended model in the present invention;
[0046] Figure 3 is a flow chart of the question-answering method of the present invention;
[0047] Figure 4 A structural diagram of a search enhancement generation system in the present invention;
[0048] Figure 5 is a structural diagram of the question-answering system of the present invention;
[0049] Figure 6 is a structural diagram of the first conversion module in the present invention;
[0050] Figure 7 This is a structural diagram of the first building block in the present invention. DETAILED DESCRIPTION
[0051] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiment of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiment of the present invention. Obviously, the described embodiment is only an embodiment of a part of the present invention, not all embodiments, and is not intended to limit the scope of the present invention. In addition, in the following description, the description of well-known structures and technologies is omitted to avoid unnecessary confusion of the concepts disclosed in the present invention. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work should fall within the scope of protection of the present invention.
[0052] The accompanying drawings show schematic diagrams of structures according to embodiments disclosed in the present invention. These figures are not drawn to scale, and some details are magnified and some details may be omitted for the purpose of clear expression. The shapes of various regions and layers shown in the figures and the relative sizes and positional relationships therebetween are only exemplary, and may deviate in practice due to manufacturing tolerances or technical limitations, and those skilled in the art may additionally design regions / layers with different shapes, sizes, and relative positions according to actual needs.
[0053] The present invention is aimed at the retrieval enhancement method (RAG) scenario and proposes a method that can perform continuous learning based on the preferences expressed during the user interaction process. Preference learning is performed in two aspects: the encoding process and the recommendation ranking process for the initial retrieval results. This makes the RAG algorithm more in line with usage habits during use and realizes large-scale customized deployment.
[0054] Embodiment 1
[0055] refer to Figure 1 The search enhancement generation method of the present invention comprises the following steps:
[0056] 11) Obtain the query statement to be retrieved;
[0057] 12) The query to be retrieved is based on the trained encoding model M , converted to the enhanced K knowledge slices;
[0058] refer to Figure 2 , the process of step 12) is:
[0059] 121) RAG knowledge base;
[0060] The process of step 21) is:
[0061] Use the RAG method to process input data and obtain knowledge slices p , slicing the knowledge p Input into the trained encoding model to slice the knowledgep Convert to dense semantic vector , according to the knowledge slice p and its corresponding dense semantic vector Build the RAG knowledge base.
[0062] As an implementation mode of the present invention, the RAG method is used to process the input data to obtain knowledge slices. p The process is:
[0063] Slice the input data based on a fixed length, set the cross-repetition range of 50-100 words between slices, and obtain several knowledge slices p , wherein the fixed length can be 500-700 words.
[0064] As an implementation mode of the present invention, the coding model M Including but not limited to BERT and its variant encoding models, Sentence-Transformer and BAAI-BGE.
[0065] As an implementation mode of the present invention, the knowledge slice in the RAG knowledge base p With dense semantic vector One to one correspondence.
[0066] As an implementation manner of the present invention, this embodiment also includes: online training of the encoding model.
[0067] During the online training of the coding model, a coding model training trigger threshold is set. T As the number of interactions between users and the system increases, the data available for model training will also increase. When the amount of trainable data exceeds T , the training of the encoding model will be triggered. The present invention performs fine-tuning training of all parameters of the encoding model by default. However, when the user uses a model with a Transformer architecture, the user is allowed to specify a frozen attention mechanism layer, and the parameters of the frozen model layer will not participate in the training process, which can reduce the load of encoding model training. The fine-tuning training of the encoding model will affect its encoding of all knowledge slices in the knowledge base and user query questions, and is therefore a global optimization of the entire RAG process.
[0068] 122) Convert the query sentence entered by the user into a query vector using the trained encoding model l , then search the RAG knowledge base for the query vector based on the semantic cosine distance l The shortest distance K knowledge slices, and the K knowledge slices to be enhanced K A slice of knowledge.
[0069] 13) Obtain the trained recommendation model and K The knowledge slices are input into the trained recommendation model to obtain several enhanced knowledge slices and their ranking.
[0070] The process of step 13) is:
[0071] 131) Construct training set and test set;
[0072] 131) Obtain several query statement samples;
[0073] 132 Convert the query sentence sample into a dense semantic vector sample through the encoding model;
[0074] 133) In the RAG knowledge base, query the K knowledge slice samples with the smallest semantic vector cosine distance between the dense semantic vector sample and the K knowledge slice samples. During the interaction process, the user selects from the K knowledge slice samples. K’ A sample of knowledge slices;
[0075] 134) Taking the K knowledge slice samples and their order as input, the user selected K’ The knowledge slice samples and the order selected by the user are used as output to construct the training set and the test set;
[0076] 135) Build a recommendation model based on Bi-LSTM network (based on bidirectional long short-term memory deep learning network);
[0077] 136) The recommendation model is trained and tested using the training set and the test set to obtain a trained recommendation model.
[0078] It should be noted that the system address and content of the knowledge slice selected by the user are recorded, and the knowledge slices are sorted in the order in which the user selects the knowledge slices. The system address represents the absolute path of the knowledge slice in the local computer file system, and the content is the actual content of the knowledge slice. K’ knowledge slices that the user did not select as positive samples K - K’ knowledge slices as negative samples.
[0079] In addition, it should be noted that the present invention trains a recommendation model based on the knowledge slice samples selected by the user and their selection order, that is, the knowledge slice samples preferred by the user, so that the recommendation model can meet the user's preferences and data interaction habits. At the same time, the present invention optimizes the retrieval process of RAG based on the fine-tuning training vector coding model to make it more accurate in finding information, and then further screens and sorts the retrieved results by training the recommendation model, so that the results of RAG can gradually meet the user's preferences and usage habits during use, and realize large-scale customized deployment.
[0080] Embodiment 2
[0081] Accordingly, reference Figure 4 , the search enhancement generation system of the present invention comprises:
[0082] A first acquisition module, used to acquire a query statement to be retrieved;
[0083] A first conversion module, used for converting the query statement to be retrieved into K knowledge slices to be enhanced based on the trained encoding model;
[0084] The first enhancement module is used to input the K knowledge slices to be enhanced into the trained recommendation model to obtain a number of enhanced knowledge slices and their ranking.
[0085] As an embodiment of the present invention, reference Figure 6 , the first conversion module includes:
[0086] A first encoding module, used for converting the query sentence to be retrieved into a dense semantic vector through a trained encoding model;
[0087] The first query module is used to query the RAG knowledge base for K knowledge slices whose semantic vector cosine distance with the dense semantic vector is the smallest, and use the queried K knowledge slices as K knowledge slices to be enhanced.
[0088] As an implementation mode of the present invention, this embodiment also includes:
[0089] The first construction module is used to construct a training set and a test set;
[0090] The second building module is used to build a recommendation model;
[0091] The training module is used to train and test the recommendation model using the training set and the test set to obtain a trained recommendation model.
[0092] As an embodiment of the present invention, reference Figure 7 , the first building block includes:
[0093] The third acquisition module is used to acquire several query statement samples;
[0094] The second encoding module is used to convert the query sentence sample into a dense semantic vector sample through the encoding model;
[0095] The second query module is used to query the RAG knowledge base for K knowledge slice samples with the smallest semantic vector cosine distance between the dense semantic vector sample and the user to select from the K knowledge slice samples K’ A sample of knowledge slices;
[0096] The third building module is used to take the K knowledge slice samples and their order as input, and select the user K’ The knowledge slice samples and the order selected by the user are used as output to construct the training set and the test set.
[0097] As an implementation mode of the present invention, the process of constructing the recommendation model is as follows:
[0098] Build a recommendation model based on Bi-LSTM network.
[0099] The division of modules in the embodiments of the present invention is schematic and is only a logical function division. There may be other division methods in actual implementation. In addition, each functional module in each embodiment of the present invention may be integrated into one processor, or may exist physically separately, or two or more modules may be integrated into one module. The above-mentioned integrated modules may be implemented in the form of hardware or in the form of software functional modules.
[0100] Embodiment 3
[0101] A computer device includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the retrieval enhancement generation method are implemented, for example, including: obtaining a query statement to be retrieved; converting the query statement to be retrieved into K knowledge slices to be enhanced based on a trained encoding model; inputting the K knowledge slices to be enhanced into a trained recommendation model to obtain a number of enhanced knowledge slices and their ordering. The memory may include a memory, such as a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk memory, etc. The processor, the network interface, and the memory are interconnected through an internal bus, which may be an industrial standard architecture bus, a peripheral component interconnection standard bus, an extended industrial standard architecture bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. The memory is used to store programs. Specifically, the program may include a program code, and the program code includes computer operation instructions. The memory may include a memory and a non-volatile memory, and provide instructions and data to the processor.
[0102] Embodiment 4
[0103] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the retrieval enhancement generation method, for example, including: obtaining a query statement to be retrieved; converting the query statement to be retrieved into K knowledge slices to be enhanced based on a trained encoding model; inputting the K knowledge slices to be enhanced into a trained recommendation model to obtain several enhanced knowledge slices and their ordering. Specifically, the computer-readable storage medium includes, but is not limited to, for example, volatile memory and / or non-volatile memory. The volatile memory may include a random access memory (RAM) and / or a cache memory (cache), etc. The non-volatile memory may include a read-only memory (ROM), a hard disk, a flash memory, an optical disk, a magnetic disk, etc.
[0104] Embodiment 5
[0105] refer to Figure 3 , the question-answering method of the present invention comprises:
[0106] 21) Get the query question;
[0107] 22) Converting the query question into K knowledge slices to be enhanced based on the trained encoding model;
[0108] The process of step 22) is:
[0109] The query question is input into the encoding model, the query question is converted into a vector, and then the shortest distance between the query question and the vector is searched in the RAG knowledge base based on the semantic cosine distance. K knowledge slices, and the K knowledge slices to be enhanced K A slice of knowledge.
[0110] 23) Inputting the K knowledge slices to be enhanced into the trained recommendation model to obtain a number of enhanced knowledge slices and their ranking;
[0111] In step 23), the training process of the recommendation model is as shown in step 131) to step 137) in embodiment 1.
[0112] 24) The enhanced knowledge slices are spliced according to their order, embedded into a prompt word template, and then input into a large language model to obtain the answer to the question preferred by the user.
[0113] As an implementation mode of the present invention, the large language model includes but is not limited to closed source large models such as Tongyi Qianwen, Wenxin Yiyan, Baichuan, Zidong Taichu and open source large models such as Llama.
[0114] Embodiment 6
[0115] refer to Figure 5 , the question-answering system of the present invention comprises:
[0116] The second acquisition module is used to acquire the query question;
[0117] A second conversion module, used for converting the query question into K knowledge slices to be enhanced based on the trained encoding model;
[0118] A second enhancement module is used to input the K knowledge slices to be enhanced into the trained recommendation model to obtain a plurality of enhanced knowledge slices and their ranking;
[0119] The question-answering module is used to splice the enhanced knowledge slices according to their order, embed them into a prompt word template, and then input them into a large language model to obtain answers to questions preferred by users.
[0120] As an implementation of the present invention, a query question is input into a trained encoding model, the query question is converted into a vector, and then the shortest distance between the query question and the vector is searched in the RAG knowledge base based on the semantic cosine distance. K knowledge slices, and the K knowledge slices to be enhanced K A slice of knowledge.
[0121] As an implementation manner of the present invention, the training process of the recommendation model is as shown in step 131) to step 137) in Example 1.
[0122] As an implementation mode of the present invention, the large language model includes but is not limited to closed source large models such as Tongyi Qianwen, Wenxin Yiyan, Baichuan, Zidong Taichu and open source large models such as Llama.
[0123] The division of modules in this embodiment is schematic and is only a logical function division. There may be other division methods in actual implementation. In addition, each functional module in each embodiment of the present invention may be integrated into one processor, or may exist physically separately, or two or more modules may be integrated into one module. The above integrated modules may be implemented in the form of hardware or in the form of software functional modules.
[0124] Embodiment 7
[0125] A computer device includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the question-answering method are implemented, for example, including: obtaining a query question; converting the query question into K knowledge slices to be enhanced based on a trained encoding model; inputting the K knowledge slices to be enhanced into a trained recommendation model to obtain a plurality of enhanced knowledge slices and their order; splicing the enhanced knowledge slices according to their order, embedding them into a prompt word template, and then inputting them into a large language model to obtain the answer to the question preferred by the user. The memory may include a memory, such as a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk memory, etc. The processor, the network interface, and the memory are interconnected through an internal bus, which may be an industrial standard architecture bus, a peripheral component interconnection standard bus, an extended industrial standard architecture bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. The memory is used to store a program. Specifically, the program may include a program code, and the program code includes a computer operation instruction. The memory may include a memory and a non-volatile memory, and provide instructions and data to the processor.
[0126] Embodiment 8
[0127] A computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of implementing the question-answering method include: obtaining a query question; converting the query question into K knowledge slices to be enhanced based on a trained encoding model; inputting the K knowledge slices to be enhanced into a trained recommendation model to obtain a number of enhanced knowledge slices and their ranking; splicing the enhanced knowledge slices according to their ranking, embedding them into a prompt word template, and then inputting them into a large language model to obtain the answer to the question preferred by the user. Specifically, the computer-readable storage medium includes, but is not limited to, for example, volatile memory and / or non-volatile memory. The volatile memory may include a random access memory (RAM) and / or a cache memory (cache), etc. The non-volatile memory may include a read-only memory (ROM), a hard disk, a flash memory, an optical disk, a magnetic disk, etc.
[0128] It will be appreciated by those skilled in the art that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Furthermore, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0129] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0130] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0131] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0132] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the above embodiments, ordinary technicians in the relevant field should understand that the specific implementation methods of the present invention can still be modified or replaced by equivalents. Any modification or equivalent replacement that does not depart from the spirit and scope of the present invention should be covered within the scope of protection of the claims of the present invention.
Claims
1. A search enhancement generation method, characterized in that: include: Get the query statement to be retrieved; Converting the query statement to be retrieved into K knowledge slices to be enhanced based on the trained encoding model; Inputting the K knowledge slices to be enhanced into the trained recommendation model to obtain a number of enhanced knowledge slices and their ranking; Before inputting the K knowledge slices to be enhanced into the trained recommendation model, the method further includes: Construct training sets and test sets; Build a recommendation model; Using the training set and the test set to train and test the recommendation model to obtain a trained recommendation model; The process of constructing the training set and the test set is as follows: Obtain several query statement samples; Convert query sentence samples into dense semantic vector samples through the encoding model; In the RAG knowledge base, the K knowledge slice samples with the smallest semantic vector cosine distance between the dense semantic vector sample and the K knowledge slice samples are queried, and the user selects K’ A sample of knowledge slices; The K knowledge slice samples and their order are used as input, and the user selects K’ The knowledge slice samples and the order selected by the user are used as output to construct the training set and the test set.
2. The search enhancement generation method according to claim 1, characterized in that: The process of converting the query statement to be retrieved into K knowledge slices to be enhanced based on the trained encoding model is as follows: The query sentence to be retrieved is converted into a dense semantic vector through the trained encoding model; In the RAG knowledge base, K knowledge slices with the smallest semantic vector cosine distance from the dense semantic vector are queried, and the queried K knowledge slices are used as K knowledge slices to be enhanced.
3. The search enhancement generation method according to claim 1, characterized in that: The process of building the recommendation model is as follows: Build a recommendation model based on Bi-LSTM network.
4. A search enhancement generation system, characterized in that: include: A first acquisition module, used to acquire a query statement to be retrieved; A first conversion module, used for converting the query statement to be retrieved into K knowledge slices to be enhanced based on the trained encoding model; A first enhancement module is used to input the K knowledge slices to be enhanced into the trained recommendation model to obtain a plurality of enhanced knowledge slices and their ranking; Before inputting the K knowledge slices to be enhanced into the trained recommendation model, the method further includes: Construct training sets and test sets; Build a recommendation model; Using the training set and the test set to train and test the recommendation model to obtain a trained recommendation model; The process of constructing the training set and the test set is as follows: Obtain several query statement samples; Convert query sentence samples into dense semantic vector samples through the encoding model; In the RAG knowledge base, the K knowledge slice samples with the smallest semantic vector cosine distance between the dense semantic vector sample and the K knowledge slice samples are queried, and the user selects K’ A sample of knowledge slices; The K knowledge slice samples and their order are used as input, and the user selects K’ The knowledge slice samples and the order selected by the user are used as output to construct the training set and the test set.
5. A computer 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 computer program, the steps of the retrieval enhancement generation method according to any one of claims 1 to 3 are implemented.
6. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the retrieval enhancement generation method according to any one of claims 1 to 3 are implemented.
7. A question-answering method, characterized in that: include: Get the query question; Convert the query question into K knowledge slices to be enhanced based on the trained encoding model; Inputting the K knowledge slices to be enhanced into the trained recommendation model to obtain a number of enhanced knowledge slices and their ranking; The enhanced knowledge slices are spliced according to their order, embedded into a prompt word template, and then input into a large language model to obtain the answer to the question preferred by the user; Before inputting the K knowledge slices to be enhanced into the trained recommendation model, the method further includes: Construct training sets and test sets; Build a recommendation model; Using the training set and the test set to train and test the recommendation model to obtain a trained recommendation model; The process of constructing the training set and the test set is as follows: Obtain several query statement samples; Convert query sentence samples into dense semantic vector samples through the encoding model; In the RAG knowledge base, the K knowledge slice samples with the smallest semantic vector cosine distance between the dense semantic vector sample and the K knowledge slice samples are queried, and the user selects K’ A sample of knowledge slices; The K knowledge slice samples and their order are used as input, and the user selects K’ The knowledge slice samples and the order selected by the user are used as output to construct the training set and the test set.
8. A question-answering system, characterized in that: include: The second acquisition module is used to acquire the query question; A second conversion module, used for converting the query question into K knowledge slices to be enhanced based on the trained encoding model; A second enhancement module is used to input the K knowledge slices to be enhanced into the trained recommendation model to obtain a plurality of enhanced knowledge slices and their ranking; A question-answering module is used to splice the enhanced knowledge slices according to their order, embed them into a prompt word template, and then input them into a large language model to obtain answers to questions preferred by users; Before inputting the K knowledge slices to be enhanced into the trained recommendation model, the method further includes: Construct training sets and test sets; Build a recommendation model; Using the training set and the test set to train and test the recommendation model to obtain a trained recommendation model; The process of constructing the training set and the test set is as follows: Obtain several query statement samples; Convert query sentence samples into dense semantic vector samples through the encoding model; In the RAG knowledge base, the K knowledge slice samples with the smallest semantic vector cosine distance between the dense semantic vector sample and the K knowledge slice samples are queried, and the user selects K’ A sample of knowledge slices; The K knowledge slice samples and their order are used as input, and the user selects K’ The knowledge slice samples and the order selected by the user are used as output to construct the training set and the test set.
