Multi-round question and answer method and device, electronic equipment and computer readable storage medium
By coordinating and weighting the input information of the current round and the historical round in the RAG system, the search difficulty caused by context omission in multiple rounds of dialogue is solved, and the search accuracy and response quality in multiple rounds of dialogue scenarios are improved.
Patent Information
- Application Number
- CN202412000089.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-31
- Publication Date
- 2025-04-18
AI Technical Summary
The existing search enhanced generation (RAG) system is difficult to retrieve the required text in multiple rounds of dialogue scenarios due to context omission, and the number of parameters of the semantic embedding vector model is small, and it lacks the ability to multiple rounds of complex semantic mapping.
By cohering the input information of the current round with the input information of multiple historical rounds, multiple correlation search score matrices are obtained, and weighted with the search score matrix of the current round, the target search score matrix is obtained to improve the search accuracy.
Effectively utilize context information, improve the semantic understanding and mapping capabilities of the search module, and improve the search effect and response quality of the RAG system in multiple rounds of dialogue scenarios.
Smart Images

Figure CN119848176A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of artificial intelligence technology, and in particular to a multi-round question-answering method, device, electronic device, and computer-readable storage medium. Background Art
[0002] Retrieval Augmented Generation (RAG) is a content generation technology that combines search technology and large language model (LLM). It uses the information retrieved from the data source as the basis for LLM to generate answers, thereby enhancing the accuracy and relevance of the generated content.
[0003] The RAG system in the related art includes a vector library, a retrieval module, a sorting module and an LLM module. Among them, the retrieval module uses the semantic embedding vector model of the text to vector technology to encode the input information to obtain a query vector, and compares it with the text vector in the vector library to obtain a vector index with close similarity, and then retrieves the relevant knowledge text. However, the semantic embedding vector model used by the retrieval module in the RAG system has a small number of parameters and usually does not have the ability to perform multi-round complex semantic mapping. Therefore, it usually processes the content of a single round of dialogue, and in a multi-round scenario, it is difficult to retrieve the required text due to context omission. Summary of the invention
[0004] The embodiments of the present disclosure provide a multi-round question-answering method, device, electronic device, and computer-readable storage medium, which can improve the mapping capability of multi-round complex semantics, thereby improving the accuracy of retrieval.
[0005] According to one aspect of the present disclosure, a multi-round question-answering method is provided, the method comprising:
[0006] Perform correlation matching on the input information of the current round and the input information of multiple historical rounds respectively to obtain multiple correlation retrieval score matrices between the current round and the historical rounds;
[0007] The query information of the current round is obtained by concatenating the input information of the current round with the input information of multiple historical rounds;
[0008] Searching the database according to the query information to obtain a search score matrix for the current round;
[0009] Performing weighted processing on the current round retrieval score matrix and multiple correlation retrieval score matrices to obtain the current round target retrieval score matrix;
[0010] The multiple texts in the database are sorted according to the target retrieval score matrix to obtain retrieval results, and the retrieval results are used as knowledge prompts in the answer generation stage.
[0011] Optionally, obtaining the retrieval score matrix of the current round includes: encoding the query information of the current round to obtain the query vector of the current round; obtaining the similarity between the query vector of the current round and the text vectors corresponding to multiple texts to obtain the retrieval score of the current round corresponding to each text vector; and forming a retrieval score matrix with the retrieval score of the current round corresponding to each text vector in the database.
[0012] Optionally, weighting the current round retrieval score matrix and multiple correlation retrieval score matrices to obtain the current round target retrieval score matrix includes:
[0013] Adding the current round retrieval score corresponding to each text in the database and a plurality of related retrieval scores to obtain a first retrieval score;
[0014] Adding multiple relevance search scores corresponding to each text in the database to 1 to obtain a second search score;
[0015] Dividing the first search score by the second search score to obtain a target search score for the current round corresponding to each text in the database;
[0016] The target retrieval score of the current round corresponding to each text in the database is formed into a target retrieval score matrix of the current round.
[0017] Optionally, obtaining multiple correlation retrieval score matrices corresponding to the input information of the current round and the input information of multiple historical rounds includes:
[0018] Obtain multiple semantic similarities between the input information of the current round and the input information of multiple historical rounds;
[0019] The retrieval score matrices of the input information of multiple historical rounds are multiplied by the corresponding multiple semantic similarities to obtain multiple correlation retrieval score matrices of the input information of the current round and the input information of multiple historical rounds.
[0020] Optionally, the multi-round question-answering method further includes:
[0021] When the current round is the first round, the input information of the current round is used as the query information of the current round;
[0022] When the current round is not the first round, the input information of the current round is concatenated with the input information of multiple historical rounds as the query information of the current round.
[0023] Optionally, sorting multiple texts in the database according to the target search score matrix to obtain search results, and using the search results as knowledge prompts in the answer generation stage includes:
[0024] Sorting the multiple texts according to the target search scores corresponding to the multiple texts to obtain a first number of texts that are ranked first;
[0025] A first number of texts is used as knowledge prompts in an answer generation phase, where the first number is a positive integer and is smaller than the number of texts in the database.
[0026] Optionally, the multi-round question-and-answer method further includes: generating a question-and-answer result based on the retrieval result.
[0027] According to one aspect of the present disclosure, a multi-round question-answering device is provided, comprising:
[0028] A first processing module is used to perform correlation matching on the input information of the current round and the input information of multiple historical rounds respectively to obtain multiple correlation retrieval score matrices between the current round and the historical rounds;
[0029] The second processing module is used to obtain the query information of the current round by combining the input information of the current round with the input information of multiple historical rounds;
[0030] A retrieval module, used to search the database according to the query information to obtain a retrieval score matrix for the current round;
[0031] A third processing module, configured to perform weighted processing on the current round retrieval score matrix and a plurality of correlation retrieval score matrices to obtain the current round target retrieval score matrix;
[0032] A sorting module is used to sort multiple texts in the database according to the target retrieval score matrix of the current round, and use the retrieval results as knowledge prompts in the answer generation stage to obtain retrieval results, and use the retrieval results as knowledge prompts in the answer generation stage;
[0033] A generation module is used to generate question and answer results according to the retrieval results.
[0034] According to one aspect of the present disclosure, an electronic device is proposed, which includes a memory, a processor, a program stored in the memory and executable on the processor, and a data bus for realizing connection and communication between the processor and the memory, wherein the program implements the multi-round question-and-answer method as described above when executed by the processor.
[0035] According to one aspect of the present disclosure, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the multi-round question-answering method as described above.
[0036] The present disclosure proposes a multi-round question-answering method, device, electronic device and computer-readable storage medium. The method performs similarity matching between input information of a current round and input information of multiple historical rounds to obtain multiple relevance retrieval score matrices, and performs weighted processing on the retrieval score matrix of the current round according to the multiple relevance retrieval score matrices to obtain a target retrieval score matrix of the current round. The method can effectively utilize context information, improve the semantic understanding and mapping capabilities of the retrieval module, and improve the retrieval effect and response quality of the RAG system in multi-round dialogue scenarios.
[0037] Furthermore, by performing weighted processing on multiple correlation retrieval score matrices and the retrieval score matrix of the current round, the importance of different historical input information can be dynamically adjusted.
[0038] Furthermore, the calculation process of correlation matching and weighted processing is simple and can be implemented using lightweight modules, which has low demand for computing resources and is suitable for scenarios with limited computing power or high real-time performance.
[0039] Other features and advantages of the present disclosure will be described in the following description, and partly become apparent from the description, or understood by practicing the present disclosure. The purpose and other advantages of the present disclosure can be realized and obtained by the structures particularly pointed out in the description, claims and drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] The accompanying drawings are used to provide further understanding of the technical solution of the present disclosure and constitute a part of the specification. Together with the embodiments of the present disclosure, they are used to explain the technical solution of the present disclosure and do not constitute a limitation on the technical solution of the present disclosure.
[0041] Figure 1 is a system architecture diagram of a multi-round question-answering method using an embodiment of the present disclosure;
[0042] Figure 2 is a main flow chart of a multi-round question-answering method according to an embodiment of the present disclosure;
[0043] Figure 3 yes Figure 2 A sub-flow chart of step S201;
[0044] Figure 4 yes Figure 2 A sub-flow chart of step S203;
[0045] Figure 5 yes Figure 2 A sub-flow chart of step S204;
[0046] Figure 6 yes Figure 2 A sub-flowchart of step S205;
[0047] Figure 7 is a schematic diagram of the structure of a multi-round question-answering device proposed in an embodiment of the present disclosure;
[0048] Figure 8 It is a schematic diagram of the structure of an electronic device proposed in one embodiment of the present disclosure. DETAILED DESCRIPTION
[0049] In order to make the purpose, technical solution and advantages of the present disclosure more clear, the present disclosure is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present disclosure and are not used to limit the present disclosure.
[0050] Before further describing the embodiments of the present disclosure in detail, the nouns and terms involved in the embodiments of the present disclosure are described. The nouns and terms involved in the embodiments of the present disclosure are subject to the following interpretations:
[0051] Retrieval Augmented Generation (RAG): A content generation technology that combines search technology and large language model (LLM). It uses the information retrieved from the data source as the basis for LLM to generate answers, thereby enhancing the accuracy and relevance of the generated content.
[0052] Large language models (LLMs): an artificial intelligence model trained with large-scale corpus data. Through the attention mechanism, large language models can capture the complex structure and semantics of language, thereby achieving text generation. Large language models are mainly used in scenarios such as text summarization, question answering, and machine translation.
[0053] In the related art, the RAG system includes a vector library, a retrieval module, a sorting module and an LLM module. Among them, the retrieval module uses the semantic embedding vector model of the text to vector technology to encode the input information to obtain the query vector, and compares it with the text vector in the vector library to obtain the vector index with close similarity, and then retrieves the relevant knowledge text. However, the semantic embedding vector model used by the retrieval module in the RAG system has a small number of parameters and usually does not have the ability of multi-round complex semantic mapping. Therefore, it usually processes the content of a single round of dialogue, and it is difficult to retrieve the required text in a multi-round scenario due to the omission of context.
[0054] For example, if the query information input in the previous round is: "How do I uninstall XX software?", the query information input in the current round is: "How do I install it?".
[0055] If only the query information input in the current round is used, the relevance and accuracy of the retrieval results will be insufficient due to the lack of complete semantic information.
[0056] If the query information input in the previous round is directly spliced with the query information input in the current round, the query information in the current round will be "How do I uninstall XX software and how do I install it?" During the search, not only installation-related content will be retrieved, but also uninstall-related content. Although this method provides more context, it also introduces a lot of irrelevant redundant information, affecting the accuracy and efficiency of the search.
[0057] If the LLM rewriting model is used to rewrite the query information of multiple rounds of input into the query information of the current round, although the retrieval effect can be enhanced, it consumes a lot of computing resources due to the need to frequently call the LLM model, which makes it difficult to apply to scenarios with limited computing power or high requirements for real-time performance.
[0058] Based on this, the present disclosure proposes a multi-round question and answer method, device, electronic device and storage medium. The method obtains multiple relevance retrieval score matrices by performing similarity matching between the input information of the current round and the input information of multiple historical rounds, and weights the retrieval score matrix of the current round according to the multiple relevance retrieval score matrices to obtain the target retrieval score matrix of the current round. This can effectively utilize context information, improve the semantic understanding and mapping capabilities of the retrieval module, and improve the retrieval effect and response quality of the RAG system in multi-round dialogue scenarios.
[0059] Description of the system architecture of the present disclosure embodiment
[0060] Figure 1 1 is a system architecture diagram used in the multi-round question-answering method of the embodiment of the present disclosure, which includes: an object terminal 110, the Internet 120, a gateway 130, and a server 140.
[0061] The object terminal 110 is a device used by the object to input query information (Query). It includes various forms such as desktop computers, laptops, PDAs (personal digital assistants), mobile phones, vehicle-mounted terminals, home theater terminals, and dedicated terminals. In addition, it can be a single device or a collection of multiple devices. For example, multiple devices are connected through a local area network and share a display device to work together, forming a terminal. The object terminal 110 can also communicate with the Internet 120 in a wired or wireless manner to exchange data.
[0062] The gateway 130 is also called an internetwork connector or a protocol converter. The gateway 130 realizes network interconnection at the transport layer and is a computer system or device that acts as a converter. The gateway 130 is a translator between two systems that use different communication protocols, data formats or languages, or even completely different architectures. At the same time, the gateway 130 can also provide filtering and security functions. The message sent by the object terminal 110 to the server 140 is sent to the corresponding server 140 through the gateway 130. The message sent by the server 140 to the object terminal 110 is also sent to the corresponding object terminal 110 through the gateway 130.
[0063] The server 140 refers to a computer system that can provide services to the target terminal 110. Compared with the target terminal 110, the server 140 has higher requirements in terms of stability, security, performance, etc. The server 140 can be a high-performance computer in a network platform, a cluster of multiple high-performance computers, a part of a high-performance computer (such as a virtual machine), a combination of parts of multiple high-performance computers (such as virtual machines), etc. The server 140 can also communicate with the Internet 120 in a wired or wireless manner to exchange data.
[0064] Overall implementation of the multi-round question-answering method of the disclosed embodiment
[0065] The present disclosure provides a multi-round question-answering method, which is applied to a multi-round question-answering device. Figure 2 , the multi-round question-answering method includes:
[0066] Step S201, performing correlation matching on the input information of the current round and the input information of multiple historical rounds respectively to obtain multiple correlation retrieval score matrices between the current round and the historical rounds;
[0067] Step S202, concatenating the input information of the current round with the input information of multiple historical rounds to obtain the query information of the current round;
[0068] Step S203, searching the database according to the query information to obtain a search score matrix for the current round;
[0069] Step S204, performing weighted processing on the current round retrieval score matrix and multiple correlation retrieval score matrices to obtain the current round target retrieval score matrix;
[0070] Step S205, sorting multiple texts in the database according to the target retrieval score matrix of the current round, and using them as knowledge prompts in the answer generation stage.
[0071] In step S201, the input information refers to the content inputted through the object terminal 110, and the input information may be a piece of information in a text format. In the current round, the input information is a brief description, and the correlation between the input information of the current round and the input information of multiple historical rounds is used to adjust the search score of the current round to improve the accuracy of the search results of this round.
[0072] Specifically, see Figure 3 In one embodiment, step S201 includes the following steps.
[0073] Step S301, obtaining multiple semantic similarities between the input information of the current round and the input information of multiple historical rounds;
[0074] Step S302 : multiplying the retrieval score matrices of the input information of multiple historical rounds by the corresponding multiple semantic similarities to obtain multiple correlation retrieval score matrices of the input information of the current round and the input information of multiple historical rounds.
[0075] In step S301, the input information of the current round and the input information of multiple historical rounds are encoded to obtain the current input vector and the historical input vector, and the similarity between the current input vector and each historical input vector is calculated to obtain the semantic similarity between the current round and the historical round. Exemplarily, the current round is the i-th round, i is a positive integer greater than 1, and the historical round is the j-th round (1≤j≤i-1), then the semantic similarity calculation formula between the current round and the historical round is: Cj=(Vectori*Vectorj) / (||Vectori||*||Vectorj||).
[0076] In step S302, in multiple rounds of dialogue, the query information of each round will be retrieved to obtain the corresponding retrieval score matrix of each round. The query information is encoded to obtain a query vector. Each text in the database corresponds to a text vector stored in the vector library. The query vector and each text vector in the vector library are similarly calculated to obtain a corresponding retrieval score. Each text vector corresponds to a retrieval score, and the retrieval scores of all text vectors form a retrieval score matrix. Exemplarily, the database includes N texts, and the corresponding vector library includes N text vectors, where N is a positive integer. Each historical input information has a corresponding retrieval score matrix RMj, RMj=(Vectorj*Vector_basek) / (||Vectorj||*||Vector_basek||), k is a positive integer, 1≤k≤N, and the corresponding relevance retrieval score matrix Sj=Cj*RMj.
[0077] Exemplarily, if the current round is the 4th round, there are 3 historical rounds, the semantic similarity between the current input vector Vector4 and the first round input vector Vector1 is C1, and the retrieval score matrix of the first round is RM1, then the correlation retrieval score matrix between the current round and the historical round is S1=C1*RM1; the semantic similarity between the current input vector Vector4 and the second round input vector Vector2 is C2, and the retrieval score matrix of the second round is RM2, then the correlation retrieval score matrix between the current round and the historical round is S2=C2*RM2; the semantic similarity between the current input vector Vector4 and the third round input vector Vector3 is C3, and the retrieval score matrix of the third round is RM3, then the correlation retrieval score matrix between the current round and the historical round is S3=C3*RM3.
[0078] In step S202, the input information of the current round and the input information of all historical rounds are concatenated to obtain the query information of the current round. When the current round is the first round, the input information of the current round is used as the query information of the current round. When the current round is not the first round, the input information of the current round is concatenated with the input information of multiple historical rounds as the query information of the current round. Exemplarily, if the current round is the first round, the input information of the current round is the query information of the current round; if the current round is the third round, the input information of the current round and the input information of the first and second rounds are concatenated together as the query information of the third round.
[0079] In step S203, a search is performed from the database according to the query information of the current round to obtain a search score matrix of the current round.
[0080] Specifically, see Figure 4 , step S203 includes the following steps.
[0081] Step S401, encoding the query information to obtain a query vector for the current round;
[0082] Step S402, obtaining the similarity between the query vector of the current round and the text vectors corresponding to the plurality of texts to obtain the search score of the current round corresponding to each text vector;
[0083] Step S403, forming a retrieval score matrix with the retrieval score of the current round corresponding to each text vector in the database.
[0084] In step S401, the query information of each round can be converted into a query vector through natural language processing technology, and the text can be converted into a vector representation in a high-dimensional space by using a pre-trained language model (such as BERT, Word2Vec, etc.) to capture semantic relationships. The query information of the current round is encoded to obtain the query vector Vectorsi of the current round.
[0085] In step S402, each text in the database corresponds to a text vector, and these text vectors are stored in the vector library. The query vector and each text vector in the vector library are similarly calculated to obtain a corresponding search score. The similarity can be calculated by cosine similarity, Jaccard similarity, Euclidean distance, and edit distance (Levenshtein distance). Each text vector Vector_base corresponds to a search score.
[0086] In step S403, the search scores of all text vectors form a search score matrix, which is used for subsequent sorting and selection. The search score matrix corresponding to the query information of the current round is RMsi=(Vectorsi*Vector_basek) / (||Vectorsi||*||Vector_basek||), k is a positive integer, 1≤k≤N, and N is a positive integer.
[0087] In step S204, since the input information of all rounds is spliced together to form the query information of the current round, texts that are not related to the input information of this round will appear in the search results obtained by sorting according to the search score matrix of the current round. Afterwards, the target search score matrix of the current round can be obtained by weighting the search score matrix of the correlation between the current round and the historical rounds and the search score matrix of the current round, which can increase the search score of texts that are more relevant to the current round and reduce the search score of texts that are not relevant to the current round. In this way, context information can be effectively utilized, the semantic understanding and mapping capabilities of the search module can be improved, and the search effect and response quality of the RAG system in multi-round dialogue scenarios can be improved.
[0088] In addition, by using multiple relevance retrieval score matrices and the current round of retrieval score matrix for weighted processing, the importance of different historical input information can be dynamically adjusted. The calculation process of relevance matching and weighted processing is simple and can be implemented using lightweight modules. It has low demand for computing resources and is suitable for scenarios with limited computing power or high real-time performance.
[0089] The calculation formula of the target retrieval score matrix RMi is: RMi=(RMsi+S1+S2+…+Si-1) / (1+S1+S2+…+Si-1).
[0090] Specifically, see Figure 5 In one embodiment, step S204 includes the following steps.
[0091] Step S501, adding the current round retrieval score matrix to a plurality of correlation retrieval score matrices to obtain a first retrieval score matrix;
[0092] Step S502, adding multiple correlation retrieval scores and the all-one matrix to obtain a second retrieval score matrix;
[0093] Step S503: Divide the first search score matrix by the second search score matrix to obtain a target search score matrix.
[0094] In step S501, the current round retrieval score matrix RMsi and multiple correlation retrieval score matrices (S1-Si-1) are added to obtain a first retrieval score matrix R1i, and the first retrieval score matrix R1i is: (RMsi+S1+S2+…+Si-1). The first retrieval score matrix can be obtained by adding the elements in the same position in the current round retrieval score matrix and multiple correlation retrieval score matrices.
[0095] In step S502, multiple correlation retrieval score matrices (S1-Si-1) and the all-1 matrix are added to obtain a second retrieval score matrix R2i, and the second retrieval score matrix R2i is: (RMsi+S1+S2+…+Si-1). The second retrieval score matrix can be obtained by adding the elements in the same position in multiple correlation retrieval score matrices and then adding 1.
[0096] In step S502, the first search score matrix R1i and the second search score matrix R2i are divided to obtain the target search score matrix RMi, that is, RMi=R1i / R2i=(RMsi+S1+S2+…+Si-1) / (1+S1+S2+…+Si-1). For example, i=4, then RM4=(RMs4+S1+S2+S3) / (1+S1+S2+S3).
[0097] In step S205, the target retrieval score matrix represents the relevance of each text to the input information of the current round. The higher the target retrieval score, the higher the relevance to the input information of the current round. Sort each text in the database from large to small according to the target retrieval score corresponding to each text, and use the top-ranked texts as retrieval results. Exemplarily, the database includes 1000 texts, and the 1000 texts are sorted according to the target retrieval score corresponding to each text, and the top 10 texts are used as the retrieval results of the current round. The retrieval results of the current round serve as knowledge prompts in the answer generation stage.
[0098] Specifically, see Figure 6 In one embodiment, step S205 includes the following steps.
[0099] Step S601, sorting multiple texts according to target search scores corresponding to the multiple texts to obtain a first number of texts as search results, where the first number is a positive integer and is smaller than the number of texts in the database;
[0100] Step S602: Using the search results as knowledge hints in the answer generation stage.
[0101] In step S601, the target search score matrix includes the target search score corresponding to each text, which is the similarity score between each text and the input information of the current round. The texts with high scores can be sorted in descending order, and the first number of texts in the front can be used as the search results; the texts with high scores can also be sorted in ascending order, and the texts with high scores can be sorted in the back, and the last first number of texts can be used as the search results. The first number can be preset, or it can be obtained according to a preset ratio of the number of texts in the database.
[0102] In step S602, the search results may be input into the LLM model as knowledge hints, thereby generating question-answer results corresponding to the input information.
[0103] In one embodiment, the multi-round question-answering method further includes step S206.
[0104] Step S206: generating a question-and-answer result based on the search result.
[0105] Specifically, the generative model can be used to generate the final answer based on the provided knowledge prompts and the user's input information.
[0106] Description of the apparatus and device of the present disclosure
[0107] See also Figure 7The embodiment of the present disclosure also provides a multi-round question-answering device 700, including a first processing module 701, a second processing module 702, a retrieval module 703, a third processing module 704, a sorting module 705 and a generating module 706.
[0108] The first processing module 701 is used to perform correlation matching on the input information of the current round and the input information of multiple historical rounds respectively to obtain multiple correlation retrieval score matrices between the current round and the historical rounds;
[0109] The second processing module 702 is used to obtain the query information of the current round by combining the input information of the current round with the input information of multiple historical rounds;
[0110] The retrieval module 703 is used to search the database according to the query information to obtain the retrieval score matrix of the current round;
[0111] The third processing module 704 is used to perform weighted processing on the current round of retrieval score matrix and multiple correlation retrieval score matrices to obtain the current round of target retrieval score matrix;
[0112] The sorting module 705 is used to sort the multiple texts in the database according to the target search score matrix of the current round to obtain search results, and use the search results as knowledge prompts in the answer generation stage;
[0113] The generating module 706 is used to generate a question-answering result according to the search result.
[0114] The multi-round question-answering device 700 disclosed in the present invention is used to execute the multi-round question-answering method as in the above embodiment. Its specific processing process is the same as the multi-round question-answering method in the above embodiment, and will not be repeated here.
[0115] The present disclosure also provides an electronic device 800, including:
[0116] at least one processor, and
[0117] a memory communicatively connected to at least one processor; wherein,
[0118] The memory stores instructions, and the instructions are executed by at least one processor so that when the at least one processor executes the instructions, a method as described in any one of the above embodiments of the present application is implemented.
[0119] Combine the following Figure 8 The hardware structure of the electronic device is described in detail. The electronic device includes: a processor 810 , a memory 820 , an input / output interface 830 , a communication interface 840 and a bus 850 .
[0120] The processor 810 may be implemented by a general-purpose central processing unit (CPU), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of the present disclosure;
[0121] The memory 820 may be implemented in the form of a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 820 may store an operating system and other application programs. When the technical solution provided in the embodiments of this specification is implemented by software or firmware, the relevant program code is stored in the memory 820, and the processor 810 calls and executes the multi-round question-answering method of the embodiments of the present disclosure;
[0122] Input / output interface 830, used to implement information input and output;
[0123] Communication interface 840, used to realize communication interaction between the device and other devices, which can be realized through wired means (such as USB, network cable, etc.) or wireless means (such as mobile network, WIFI, Bluetooth, etc.); and
[0124] A bus 850 that transmits information between various components of the device (e.g., the processor 810, the memory 820, the input / output interface 830, and the communication interface 840);
[0125] The processor 810 , the memory 820 , the input / output interface 830 and the communication interface 840 are connected to each other in communication within the device via a bus 850 .
[0126] An embodiment of the present application also provides a computer-readable storage medium, which stores one or more programs. The one or more programs can be executed by one or more processors to implement the multi-round question-and-answer method of the above embodiment, which will not be repeated here.
[0127] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present disclosure described herein can, for example, be implemented in an order other than those illustrated or described herein. In addition, the terms "comprises" and "comprising" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0128] It should be understood that in the present disclosure, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.
[0129] It should be understood that in the description of the embodiments of the present disclosure, the meaning of multiple (or multiple items) is more than two, greater than, less than, exceed, etc. are understood as not including the number, and above, below, within, etc. are understood as including the number.
[0130] In the several embodiments provided in the present disclosure, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0131] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0132] In addition, each functional unit in each embodiment of the present disclosure may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0133] It should also be understood that the various implementations provided in the embodiments of the present disclosure can be combined arbitrarily to achieve different technical effects.
[0134] The above is a specific description of the implementation methods of the present disclosure, but the present disclosure is not limited to the above implementation methods. Technical personnel familiar with the art can also make various equivalent modifications or substitutions without violating the spirit of the present disclosure. These equivalent modifications or substitutions are all included in the scope defined by the claims of the present disclosure.
Claims
1. A multi-round question-answering method, characterized in that: include: Perform correlation matching on the input information of the current round and the input information of multiple historical rounds respectively to obtain multiple correlation retrieval score matrices between the current round and the historical rounds; The query information of the current round is obtained by concatenating the input information of the current round with the input information of multiple historical rounds; Searching the database according to the query information to obtain a search score matrix for the current round; Performing weighted processing on the current round retrieval score matrix and multiple correlation retrieval score matrices to obtain the current round target retrieval score matrix; The multiple texts in the database are sorted according to the target retrieval score matrix to obtain retrieval results, and the retrieval results are used as knowledge prompts in the answer generation stage.
2. The multi-round question-answering method according to claim 1, characterized in that: Obtaining the retrieval score matrix for the current round includes: Encode the query information of the current round to obtain the query vector of the current round; Obtaining the similarity between the query vector of the current round and the text vectors corresponding to the plurality of texts to obtain the retrieval score of the current round corresponding to each text vector; The retrieval scores of the current round corresponding to each text vector in the database are formed into a retrieval score matrix.
3. The multi-round question-answering method according to claim 1, characterized in that: The target retrieval score matrix of the current round is obtained by weighting the retrieval score matrix of the current round and multiple correlation retrieval score matrices, including: Adding the current round of retrieval score matrix to a plurality of correlation retrieval score matrices to obtain a first retrieval score matrix; Adding multiple relevance search scores and the all-one matrix to obtain a second search score matrix; The first search score matrix and the second search score matrix are divided to obtain a target search score matrix.
4. The multi-round question-answering method according to claim 1, characterized in that: Obtaining multiple correlation retrieval score matrices corresponding to the current round of input information and multiple historical rounds of input information includes: Obtain multiple semantic similarities between the input information of the current round and the input information of multiple historical rounds; The retrieval score matrices of the input information of multiple historical rounds are multiplied by the corresponding multiple semantic similarities to obtain multiple correlation retrieval score matrices of the input information of the current round and the input information of multiple historical rounds.
5. The multi-round question-answering method according to claim 1, characterized in that: Also includes: When the current round is the first round, the input information of the current round is used as the query information of the current round; When the current round is not the first round, the input information of the current round is concatenated with the input information of multiple historical rounds as the query information of the current round.
6. The multi-round question-answering method according to claim 1, characterized in that: Sorting multiple texts in the database according to the target search score matrix to obtain search results, and using the search results as knowledge prompts in the answer generation stage includes: Sort the multiple texts according to the target search scores corresponding to the multiple texts to obtain a first number of texts as search results, where the first number is a positive integer and is less than the number of texts in the database; The retrieval results are used as knowledge hints in the answer generation stage.
7. The multi-round question-answering method according to claim 1, characterized in that: Also includes: A question-and-answer result is generated according to the search result.
8. A multi-round question-answering device, characterized in that: include: A first processing module is used to perform correlation matching on the input information of the current round and the input information of multiple historical rounds respectively to obtain multiple correlation retrieval score matrices between the current round and the historical rounds; The second processing module is used to obtain the query information of the current round by combining the input information of the current round with the input information of multiple historical rounds; A retrieval module, used to search the database according to the query information to obtain a retrieval score matrix for the current round; A third processing module, configured to perform weighted processing on the current round retrieval score matrix and a plurality of correlation retrieval score matrices to obtain the current round target retrieval score matrix; A sorting module is used to sort multiple texts in the database according to the target retrieval score matrix of the current round to obtain retrieval results, and use the retrieval results as knowledge prompts in the answer generation stage; A generation module is used to generate question and answer results according to the retrieval results.
9. An electronic device, characterized in that: The electronic device includes a memory, a processor, a program stored in the memory and executable on the processor, and a data bus for realizing connection and communication between the processor and the memory. When the program is executed by the processor, the multi-round question-and-answer method according to any one of claims 1 to 7 is realized.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the multi-round question-answering method as described in any one of claims 1 to 7.