Dialogue management method and device, equipment, medium and product
Through the vector database retrieval classification method, the target topic is selected based on the similarity score of the conversation input content for forward reasoning, which solves the problem of increasing memory and computing overhead in multiple rounds of conversations, and realizes efficient and accurate dialogue management.
Patent Information
- Application Number
- CN202411695119.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-25
- Publication Date
- 2025-03-18
AI Technical Summary
Large language models use context window management in multiple rounds of dialogue inference, resulting in increased non-essential memory and computational overhead and difficulty in capturing long-distance dependency.
Through the vector database search classification method, the conversation is classified into topics, and based on the conversation input content and the topic similarity scores in the preset vector database, the target topic is selected for forward reasoning, reducing the participation and repeated calculations of irrelevant topics.
It effectively reduces non-essential memory and computing overhead during multiple rounds of conversations, while improving the accuracy of reply content and the response quality of the conversation system.
Smart Images

Figure CN119647590A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and in particular to a dialogue management method, device, equipment, medium and product. Background Art
[0002] Large language models perform multi-round dialogue reasoning, which means being able to understand and participate in continuous dialogues and generate appropriate responses based on previous context. This ability is crucial for building more natural and coherent human-computer interaction systems.
[0003] Currently, large language models usually use context window management for multi-round dialogue reasoning. In multi-round dialogues, historical dialogues are used as part of the input for self-attention calculation, which easily leads to unnecessary increase in memory and computing overhead.
[0004] The above contents are only used to assist in understanding the technical solution of the present application and do not constitute an admission that the above contents are prior art. Summary of the invention
[0005] The main purpose of this application is to provide a dialogue management method, device, equipment, medium and product, aiming to reduce unnecessary memory and computing overhead during multi-round dialogues.
[0006] To achieve the above object, the present application provides a dialogue management method, the method comprising:
[0007] Get the dialogue input content;
[0008] Determining a similarity score between each topic in a preset vector database and the conversation input content based on the conversation input content, and selecting or determining a target topic from the topics according to the similarity score;
[0009] The dialogue input content is predicted according to the target topic to obtain reply content corresponding to the dialogue input content.
[0010] In one embodiment, the step of obtaining the dialogue input content includes:
[0011] Receive user conversation information;
[0012] Vectorization is performed on the user dialogue information to obtain the dialogue input content.
[0013] In one embodiment, before the step of determining the similarity score corresponding to each topic in the preset vector database and the dialogue input content based on the dialogue input content, the step further includes:
[0014] Create an initial vector database and obtain historical conversation content;
[0015] Obtaining the topics based on the historical conversation content;
[0016] Selecting or determining the middle value of the self-attention calculation corresponding to each topic;
[0017] The initial vector database is updated according to the topics and the intermediate values of the self-attention calculations corresponding to the topics to obtain the preset vector database.
[0018] In one embodiment, the step of determining, based on the conversation input content, a similarity score between each topic in a preset vector database and the conversation input content, and selecting or determining a target topic from the topics according to the similarity score comprises:
[0019] Calculating the similarity between the conversation input content and each topic in the preset vector database respectively, and obtaining a similarity score corresponding to each topic;
[0020] Determine whether the similarity score corresponding to each topic is greater than or equal to a preset score threshold;
[0021] Among the topics, the topic whose similarity score is greater than or equal to a preset score threshold is taken as the target topic.
[0022] In one embodiment, the step of predicting the dialogue input content according to the target topic to obtain reply content corresponding to the dialogue input content includes:
[0023] splicing the target topic with the dialogue input content to obtain an input sequence;
[0024] Inputting the intermediate value of the self-attention calculation corresponding to the input sequence and the target topic into the large language model, and calculating the intermediate value of the self-attention calculation corresponding to the dialogue input content through the large language model;
[0025] Performing a dot product operation on the intermediate value of the self-attention calculation corresponding to the target topic and the intermediate value of the self-attention calculation corresponding to the dialogue input content to obtain an operation result;
[0026] Prediction is performed based on the calculation result to obtain reply content corresponding to the dialogue input content.
[0027] In one embodiment, after the step of determining whether the similarity score corresponding to each topic is greater than or equal to a preset score threshold, the step further includes:
[0028] If there is no corresponding topic among the topics whose similarity score is greater than or equal to the preset score threshold, the conversation input content is used as a new topic to update the preset vector database, and the intermediate value of the self-attention calculation corresponding to the conversation input content is stored in the preset vector database.
[0029] In addition, to achieve the above purpose, the present application also proposes a dialogue management device, the dialogue management device comprising:
[0030] The acquisition module is used to obtain the dialogue input content;
[0031] A scoring module, configured to determine, based on the conversation input content, a similarity score between each topic in a preset vector database and the conversation input content, and select or determine a target topic from the topics according to the similarity score;
[0032] The prediction module is used to predict the dialogue input content according to the target topic to obtain the reply content corresponding to the dialogue input content.
[0033] In addition, to achieve the above-mentioned purpose, the present application also proposes a dialogue management device, which includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, and the computer program is configured to implement the steps of the dialogue management method described above.
[0034] In addition, to achieve the above-mentioned purpose, the present application also proposes a storage medium, which is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the dialogue management method described above are implemented.
[0035] In addition, to achieve the above-mentioned purpose, the present application also provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, the steps of the dialogue management method described above are implemented.
[0036] One or more technical solutions proposed in this application have at least the following technical effects:
[0037] By obtaining the dialogue input content; determining the similarity scores corresponding to each topic in the preset vector database and the dialogue input content based on the dialogue input content, and selecting or determining the target topic from the topics according to the similarity scores; predicting the dialogue input content according to the target topic to obtain the reply content corresponding to the dialogue input content, by determining the similarity scores corresponding to each topic in the preset vector database according to the dialogue input content, the target topic with a high correlation with the dialogue input content can be screened out from the topics in the preset database, and then the screened out target topic is used to perform forward reasoning of the dialogue input content, and more accurate reply content can be generated without using all historical dialogues for the reasoning process, thereby reducing unnecessary memory and computing overhead in multiple rounds of dialogue while ensuring the accuracy of the reply content. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0039] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0040] Figure 1 A flowchart of the first embodiment of the conversation management method of the present application is provided;
[0041] Figure 2 A flowchart of the second embodiment of the conversation management method of this application is provided;
[0042] Figure 3 is a schematic diagram of a vector database according to the second embodiment of the present application;
[0043] Figure 4 A flowchart of the third embodiment of the conversation management method of this application is provided;
[0044] Figure 5 A flowchart of the fourth embodiment of the conversation management method of the present application is provided;
[0045] Figure 6 It is a schematic diagram of the overall principle according to the fourth embodiment of the present application;
[0046] Figure 7 This is a schematic diagram of the module structure of the dialogue management device according to an embodiment of the present application;
[0047] Figure 8Schematic diagram of the device structure of the hardware operating environment involved in the dialogue management method in the embodiment of the present application.
[0048] The purpose, features and advantages of this application will be further described in conjunction with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0049] It should be understood that the specific embodiments described herein are only used to explain the technical solutions of the present application and are not used to limit the present application.
[0050] In order to better understand the technical solution of the present application, a detailed description will be given below in conjunction with the accompanying drawings and specific implementation methods.
[0051] The main solution of the embodiment of the present application is: by obtaining the dialogue input content; determining the similarity score corresponding to each topic in the preset vector database and the dialogue input content based on the dialogue input content, and selecting or determining the target topic from the topics according to the similarity score; predicting the dialogue input content according to the target topic to obtain the reply content corresponding to the dialogue input content, by determining the similarity score corresponding to each topic in the preset vector database according to the dialogue input content, it is possible to screen out the target topic with a high correlation with the dialogue input content from the topics in the preset database, and then use the screened target topic to perform forward reasoning on the dialogue input content, so that more accurate reply content can be generated without using all historical dialogues for the reasoning process, thereby reducing unnecessary memory and computing overhead in multiple rounds of dialogue while ensuring the accuracy of the reply content.
[0052] In this embodiment, for ease of description, the following description is made with the dialogue management device as the execution entity.
[0053] Large language models face several major challenges when processing long sequences of text in multi-round conversations: First, in terms of computational complexity, the computational complexity of the self-attention mechanism in the traditional Transformer model increases quadratically with the increase in sequence length, which limits the model's ability to process long texts. Second, in terms of memory consumption, long sequences need to store a large number of attention weights and intermediate states, which places high demands on memory and increases the consumption of computing resources. Finally, in terms of long-distance dependencies, as the sequence length increases, it becomes more difficult for the model to capture long-distance dependencies, affecting the model's ability to understand the text.
[0054] Existing technologies usually use context window management, and in multi-round dialogues, historical dialogues are used as part of the input for self-attention calculation. Currently, there are two problems when performing multi-round dialogue reasoning:
[0055] (1) It increases unnecessary memory and computational overhead;
[0056] (2) In multi-round conversations, as the length of the input sequence increases, the problem of long-distance text invalidation is prone to occur.
[0057] The present application provides a solution, using a method of retrieving and classifying through a vector database, and classifying the conversation into topics and storing them in a vector database. When a new conversation occurs, the question is converted into a vector and the topics in the vector database are searched and scored for similarity in turn, and the scoring rules are set to find the most relevant topic as a historical conversation as part of this input. It is possible to reduce irrelevant topics as part of the input to participate in this reasoning to reduce invalid memory overhead. At the same time, the intermediate values (Q, K, V, dot product operations) calculated by self-attention during forward reasoning are saved in the vector database, and the intermediate values in the vector database are taken out in a new conversation, so only the incremental part of the operation needs to be performed, reducing computing power overhead. In addition, irrelevant topics will take up space in the context window, exacerbating the failure problem of long-distance text, which can be effectively improved by classifying conversations through the conversation management method of the present application.
[0058] It should be noted that the execution subject of this embodiment may be a computing service device with data processing, network communication and program running functions, such as a tablet computer, a personal computer, a mobile phone, etc., or an electronic device capable of realizing the above functions, a dialogue management device, etc. The following takes the dialogue management device as an example to illustrate this embodiment and the following embodiments.
[0059] Based on this, the present application embodiment provides a dialogue management method, referring to Figure 1 , Figure 1 This is a flowchart of the first embodiment of the conversation management method of the present application.
[0060] In this embodiment, the dialogue management method includes steps S10 to S30:
[0061] Step S10, obtaining the dialogue input content;
[0062] Specifically, multi-round dialogue reasoning by large language models (such as the GPT series, BERT, etc.) means that these models can understand and participate in continuous dialogues and generate appropriate responses based on previous contexts. This ability is crucial to building a more natural and coherent human-computer interaction system. In order to achieve effective multi-round dialogues, the model needs to be able to remember the content of previous rounds of dialogue to ensure that the response is consistent and relevant with previous exchanges. This is usually achieved by taking the dialogue history of previous rounds as the input sequence. Therefore, the computational complexity of the self-attention mechanism increases quadratically with the increase in sequence length, which limits the model's ability to process long texts. Secondly, in terms of memory consumption, long sequences need to store a large number of attention weights and intermediate states, which places high demands on memory and increases the consumption of computing resources. Finally, in terms of long-distance dependencies, as the sequence length increases, it becomes more difficult for the model to capture long-distance dependencies, affecting the model's ability to understand text.
[0063] For example, in the embodiment of the present application, a method of retrieving and classifying through a vector database is used to classify the conversation into topics and store them in the vector database. When a new conversation occurs, the question is converted into a vector and the topics in the vector database are searched and scored for similarity in turn. The scoring rules are set to find the most relevant topic as part of the historical conversation as part of this input.
[0064] Exemplarily, the step of obtaining the dialogue input content includes:
[0065] Receive user conversation information;
[0066] Vectorization is performed on the user dialogue information to obtain the dialogue input content.
[0067] Exemplarily, the user can input questions by voice input and text input, and the dialogue management device converts the received user questions into text format, i.e., user dialogue information. The text is converted into a form that can be processed by the model, usually by converting each word or subword into a corresponding vector representation through word embeddings or Byte Pair Encoding (BPE) and other methods. By further vectorizing the user dialogue information, the user dialogue information can be converted into a vector format, i.e., dialogue input content, and then the dialogue input content is used to calculate similarity with the vectors stored in the preset vector database, and further used to input the large language model to perform reasoning.
[0068] Step S20, determining a similarity score between each topic in a preset vector database and the conversation input content based on the conversation input content, and selecting or determining a target topic from the topics according to the similarity score;
[0069] Furthermore, after obtaining the dialogue input content, the similarity scores corresponding to each topic in the preset vector database and the dialogue input content can be determined based on the dialogue input content, and the target topic can be selected or determined from the topics according to the similarity scores.
[0070] Exemplarily, in an embodiment of the present application, a vector database is pre-constructed for classifying and storing vectorized historical conversation content, and storing intermediate values of self-attention calculations during forward reasoning of historical conversation content. When a new conversation occurs, the question can be directly converted into a vector and the topics in the vector database can be searched and scored for similarity in turn. The scoring rules are set to find the most relevant topic as part of the historical conversation as part of this input.
[0071] For example, for new dialogue input content, after converting it into a vector, it is compared with each topic vector in the database to calculate the similarity score. Similarity calculation methods include cosine similarity calculation, Euclidean distance calculation, and dot product calculation, among which cosine similarity measures the angle between two non-zero vectors, with a value range between -1 and 1, and the closer to 1, the more similar; Euclidean distance measures the straight-line distance between two points, and the smaller the value, the more similar; dot product calculation directly calculates the inner product of two vectors, which can also reflect the similarity of vectors.
[0072] For example, after calculating the similarity between each topic in the preset vector database and the dialogue input content, the most matching topic can be selected from the preset vector database. This can be done by setting a preset score threshold to decide whether to accept a topic as a target topic, or by selecting a topic with a score ranking within a preset range as a target topic, or simply selecting the topic with the highest score as the target topic.
[0073] Step S30, predicting the dialogue input content according to the target topic to obtain reply content corresponding to the dialogue input content.
[0074] Furthermore, based on the conversation input content, a similarity score corresponding to each topic in a preset vector database and the conversation input content is determined, and after a target topic is selected or determined from the topics according to the similarity score, the conversation input content can be predicted according to the target topic to obtain a reply content corresponding to the conversation input content.
[0075] For example, by concatenating the target topic and the dialogue input content, an input sequence can be obtained. According to the maximum input length limit of the large language model, if the sequence is too long, it needs to be properly truncated; if it is too short, it may need to be padded to a certain length. The constructed input sequence is sent to the pre-trained large language model. The large language model will process information through a multi-layer self-attention mechanism and a feedforward neural network.
[0076] For example, the self-attention mechanism is a core component in the Transformer architecture, which allows the model to pay attention to information at different positions in the sequence when processing sequence data. In the self-attention mechanism, the input vector is first converted into three different vectors: query vector (Query, Q), key vector (Key, K) and value vector (Value, V), which are obtained by multiplying the input vector with the corresponding weight matrix.
[0077] For example, the target topic is passed as an input sequence to the large language model for forward reasoning, and the intermediate value (Q, K, V cache) of the self-attention calculation corresponding to the target topic in the preset vector database is retrieved. Therefore, when performing forward reasoning for a new dialogue, it is only necessary to calculate the intermediate value (Q, K, V) of the self-attention calculation corresponding to the newly added dialogue token (word), and then combine it with the intermediate value of the self-attention calculation corresponding to the target topic to perform dot product operations and the final attention output, thereby reducing repeated calculations by reusing the cache.
[0078] This embodiment adopts the above scheme, specifically by obtaining the dialogue input content; determining the similarity score corresponding to each topic in the preset vector database and the dialogue input content based on the dialogue input content, and selecting or determining the target topic from the topics according to the similarity score; predicting the dialogue input content according to the target topic to obtain the reply content corresponding to the dialogue input content, by determining the similarity score corresponding to each topic in the preset vector database according to the dialogue input content, it is possible to screen out the target topic with a high correlation with the dialogue input content from each topic in the preset database, and then use the screened target topic to perform forward reasoning of the dialogue input content, without using all historical dialogues for the reasoning process, to generate more accurate reply content, thereby ensuring the accuracy of the reply content while reducing unnecessary memory and computing overhead in multiple rounds of dialogue.
[0079] Based on the first embodiment of the present application, the second embodiment of the present application is proposed. In the second embodiment of the present application, the same or similar contents as those of the above-mentioned embodiment 1 can be referred to the above introduction and will not be repeated later. Figure 2Before step S20, the dialogue management method further includes steps S01 to S04:
[0080] S01: Create an initial vector database and obtain historical conversation content;
[0081] S02: Obtaining the topics based on the historical conversation content;
[0082] S03: Select or determine the middle value of the self-attention calculation corresponding to each topic;
[0083] S04: Update the initial vector database according to the topics and the intermediate values of the self-attention calculations corresponding to the topics to obtain the preset vector database.
[0084] Reference Figure 3 , Figure 3 FIG. 1 is a schematic diagram of a vector database according to the second embodiment of the present application. Figure 3 As shown, in the embodiment of the present application, a vector database is created in the memory for storing historical conversation records. When a new conversation is requested, memory is dynamically requested for vector similarity scoring. After the scoring is completed, the memory is released and does not occupy the memory for subsequent forward reasoning.
[0085] For example, after collecting enough historical conversation data, if there are ready-made topic classification labels, they can be used directly. If not, it is necessary to manually or semi-automatically classify the conversation data into topics. Select a suitable text embedding method according to the task requirements. For example, pre-trained language models such as BERT, RoBERTa, etc. can be used to generate high-quality sentence or paragraph-level vectors. Convert each historical conversation into a vector form through the selected model. This step usually includes word segmentation, constructing input sequences, forward propagation, etc.
[0086] Exemplarily, an efficient vector search engine such as Faiss, Annoy or Elasticsearch is used to establish a vector index to support fast similarity search, and a vector database structure is designed. In addition to storing vectors, the corresponding topic tags and the intermediate values of the self-attention calculation corresponding to each topic need to be saved.
[0087] Exemplarily, in the process of topic classification of historical conversation content, irrelevant characters, stop words, etc. can be removed, and operations such as capitalization can be performed. Long conversations can be divided into smaller units by sentence or segmentation for subsequent processing. Features that are helpful for classification, such as TF-IDF, word frequency statistics, etc., are extracted through feature engineering. For each classified topic-related conversation segment, Q (query), K (key), and V (value) vectors are obtained, and the relevant information is stored in the database according to the designed structure. You can consider using SQL or NoSQL databases, depending on the data scale and query requirements. Establish appropriate indexes for vector fields in the database for fast retrieval. As new conversation data is continuously added, the database is updated regularly to maintain its timeliness and accuracy.
[0088] This embodiment adopts the above scheme, specifically by creating an initial vector database, and obtaining historical conversation content; obtaining the topics based on the historical conversation content; selecting or determining the intermediate value of the self-attention calculation corresponding to the topics; updating the initial vector database according to the topics and the intermediate value of the self-attention calculation corresponding to the topics to obtain the preset vector database, and can create a preset vector database containing rich topic information and its corresponding intermediate value of self-attention calculation. The preset vector database not only supports efficient vector retrieval based on text content, but also provides additional context understanding capabilities, thereby improving the response quality of subsequent dialogue systems.
[0089] Based on any of the foregoing embodiments of the present application, a third embodiment of the present application is proposed. In the third embodiment of the present application, the same or similar contents as any of the foregoing embodiments can be referred to the above introduction and will not be described in detail later. Figure 4 , the step S20 further includes steps S201 to S203:
[0090] S201: Calculating the similarity between the conversation input content and each topic in the preset vector database respectively, and obtaining a similarity score corresponding to each topic;
[0091] S202: Determine whether the similarity score corresponding to each topic is greater than or equal to a preset score threshold;
[0092] S203: taking the topic whose similarity score is greater than or equal to a preset score threshold among the topics as the target topic.
[0093] For example, for new dialogue input content, after converting it into a vector, it is compared with each topic vector in the database to calculate the similarity score. Similarity calculation methods include cosine similarity calculation, Euclidean distance calculation, and dot product calculation, among which cosine similarity measures the angle between two non-zero vectors, with a value range between -1 and 1, and the closer to 1, the more similar; Euclidean distance measures the straight-line distance between two points, and the smaller the value, the more similar; dot product calculation directly calculates the inner product of two vectors, which can also reflect the similarity of vectors.
[0094] Exemplarily, all topics and their corresponding vectors are loaded from the created preset vector database, and for each topic vector, a suitable similarity measurement method (such as cosine similarity) is used to calculate the similarity between it and the dialogue input vector. This step will generate a numerical value, namely a similarity score, which indicates the degree of similarity between the two. The similarity score threshold set in the embodiment of the present application is 0.5. In other embodiments, a reasonable similarity score threshold can be set according to actual needs and test results. This threshold can be an empirical value, or it can be optimized by methods such as cross-validation, which is not specifically limited in this embodiment.
[0095] Exemplarily, the similarity scores of all topics are traversed to find all topics whose scores are greater than or equal to the preset threshold. If only one topic meets the conditions, it is directly used as the target topic. If multiple topics meet the conditions, different strategies can be adopted according to the specific application scenario. For example, the topic with the highest score can be selected, or other factors (such as user preferences, context, etc.) can be considered to determine the final target topic. Another method is to return all topics that meet the conditions and further refine the selection in subsequent processing.
[0096] For example, after calculating the similarity between each topic in the preset vector database and the dialogue input content, the most matching topic can be selected from the preset vector database. This can be done by setting a preset score threshold to decide whether to accept a topic as a target topic, or by selecting a topic with a score ranking within a preset range as a target topic, or simply selecting the topic with the highest score as the target topic.
[0097] Exemplarily, after the step of determining whether the similarity score corresponding to each topic is greater than or equal to a preset score threshold, the step further includes:
[0098] If there is no corresponding topic among the topics whose similarity score is greater than or equal to the preset score threshold, the conversation input content is used as a new topic to update the preset vector database, and the intermediate value of the self-attention calculation corresponding to the conversation input content is stored in the preset vector database.
[0099] For example, if the similarity scores of all topics in the vector database are lower than a preset score threshold (e.g., 0.5 points), it is considered that this is a new topic that is unrelated to all stored topics, and the vector of the new dialogue conversion is added as a new topic and inserted into the preset vector database. During the forward reasoning of the large language model, the Q (query), K (key), and V (value) of the calculation process are stored in the corresponding topic in the preset vector database.
[0100] This embodiment adopts the above scheme, specifically by respectively calculating the similarity between the conversation input content and each topic in the preset vector database, to obtain the similarity score corresponding to each topic; judging whether the similarity score corresponding to each topic is greater than or equal to a preset score threshold; taking the topic whose similarity score is greater than or equal to the preset score threshold as the target topic, using each topic in the preset vector database and the intermediate value in the self-attention mechanism, combined with the conversation input content to determine the most relevant target topic, which can improve the accuracy of topic matching and provide more personalized and contextualized responses.
[0101] Based on any of the foregoing embodiments of the present application, a fourth embodiment of the present application is proposed. In the fourth embodiment of the present application, the same or similar contents as any of the foregoing embodiments can be referred to the above introduction and will not be described in detail later. Figure 5 , the step S30 further includes steps S301 to S304:
[0102] S301: concatenating the target topic with the dialogue input content to obtain an input sequence;
[0103] S302: inputting the intermediate value of the self-attention calculation corresponding to the input sequence and the target topic into the large language model, and calculating the intermediate value of the self-attention calculation corresponding to the dialogue input content through the large language model;
[0104] S303: performing a dot product operation on the intermediate value of the self-attention calculation corresponding to the target topic and the intermediate value of the self-attention calculation corresponding to the dialogue input content to obtain an operation result;
[0105] S304: Execute prediction according to the calculation result to obtain reply content corresponding to the dialogue input content.
[0106] Reference Figure 6 , Figure 6 FIG. 4 is a schematic diagram showing the overall principle according to the fourth embodiment of the present application. Figure 6As shown in the figure, after determining the target topic through the preset vector database, the target topic and the dialogue input content can be spliced together in a certain format to form a continuous text sequence. Special delimiters can be used to distinguish different parts and convert the spliced input sequence into a form that the model can process, usually a token ID sequence. Use a pre-trained language model (such as BERT, GPT-3, etc.) to convert the token ID sequence into a vector representation. Load the self-attention calculation intermediate values Q (query), K (key), and V (value) corresponding to the target topic from the preset vector database. These intermediate values can be fed into the model together with the new input sequence so that the model can use this additional information when reasoning.
[0107] For example, by concatenating the target topic and the dialogue input content, an input sequence can be obtained. According to the maximum input length limit of the large language model, if the sequence is too long, it needs to be properly truncated; if it is too short, it may need to be padded to a certain length. The constructed input sequence is sent to the pre-trained large language model. The large language model will process information through a multi-layer self-attention mechanism and a feedforward neural network.
[0108] Exemplarily, the target topic is passed as an input sequence to the large language model for forward reasoning, and the intermediate values Q (query), K (key), and V (value) of the self-attention calculation corresponding to the target topic in the preset vector database are retrieved. Therefore, when performing forward reasoning for a new dialogue, it is only necessary to calculate the intermediate values Q (query), K (key), and V (value) of the self-attention calculation corresponding to the newly added dialogue token (word), and then combine the intermediate values of the self-attention calculation corresponding to the target topic to perform dot product operations and the final attention output, and reuse the cache to reduce repeated calculations.
[0109] Exemplarily, a large language model is used for prediction to obtain the intermediate value of the self-attention calculation corresponding to the dialogue input content. The dot product result in the self-attention mechanism between the target topic and the dialogue input content is calculated. This step can help the model better understand the relationship between the two. According to the result of the dot product operation, the value vectors of the target topic and the dialogue input content are weighted summed, and the result of the weighted summation is used as context information to generate the final reply content through the large language model.
[0110] This embodiment adopts the above scheme, specifically by splicing the target topic and the dialogue input content to obtain an input sequence; inputting the input sequence and the intermediate value of the self-attention calculation corresponding to the target topic into the large language model, and calculating the intermediate value of the self-attention calculation corresponding to the dialogue input content through the large language model; performing a dot product operation on the intermediate value of the self-attention calculation corresponding to the target topic and the intermediate value of the self-attention calculation corresponding to the dialogue input content to obtain an operation result; performing a prediction based on the operation result to obtain a reply content corresponding to the dialogue input content, and by combining the target topic and the dialogue input content, using the self-attention mechanism of the large language model to generate a more relevant and coherent reply. This process not only takes into account the current input content, but also integrates the intermediate value of the self-attention calculation corresponding to the target topic to perform a dot product operation and the final attention output, and reduces repeated calculations by reusing the cache, thereby reducing unnecessary memory and computing overhead during multiple rounds of dialogue.
[0111] It should be noted that the above examples are only used to understand the present application and do not constitute a limitation on the dialogue management method of the present application. More simple transformations based on this technical concept are all within the scope of protection of the present application.
[0112] This application also provides a dialogue management device, please refer to Figure 7 , the dialogue management device comprises:
[0113] The acquisition module is used to obtain the dialogue input content;
[0114] A scoring module, configured to determine, based on the conversation input content, a similarity score between each topic in a preset vector database and the conversation input content, and select or determine a target topic from the topics according to the similarity score;
[0115] The prediction module is used to predict the dialogue input content according to the target topic to obtain the reply content corresponding to the dialogue input content.
[0116] The dialogue management device provided by the present application adopts the dialogue management method in the above embodiment to solve the technical problem of dialogue management. Compared with the prior art, the beneficial effects of the dialogue management device provided by the present application are the same as the beneficial effects of the dialogue management method provided by the above embodiment, and other technical features in the dialogue management device are the same as the features disclosed in the above embodiment method, which will not be repeated here.
[0117] The present application provides a dialogue management device, which includes: at least one processor; and a memory that is communicatively connected to the at least one processor; wherein the memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the dialogue management method in the above-mentioned embodiment one.
[0118] Reference below Figure 8 , which shows a schematic diagram of the structure of a conversation management device suitable for implementing the embodiment of the present application. The conversation management device in the embodiment of the present application may include but is not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions), PMPs (Portable Media Players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 8 The dialogue management device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0119] like Figure 8 As shown, the dialog management device may include a processing device 1001 (e.g., a central processing unit, a graphics processor, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM: Read Only Memory) 1002 or a program loaded from a storage device 1003 to a random access memory (RAM: Random Access Memory) 1004. In RAM1004, various programs and data required for the operation of the dialog management device are also stored. The processing device 1001, ROM1002, and RAM1004 are connected to each other through a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Generally, the following systems can be connected to the I / O interface 1006: an input device 1007 including, for example, a touch screen, a touch pad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; an output device 1008 including, for example, a liquid crystal display (LCD: Liquid Crystal Display), a speaker, a vibrator, etc.; a storage device 1003 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 1009. The communication device 1009 can allow the conversation management device to communicate with other devices wirelessly or by wire to exchange data. Although the figure shows a conversation management device with various systems, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems can be implemented or have alternatively.
[0120] In particular, according to the embodiments disclosed in the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device, or installed from a storage device 1003, or installed from a ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment disclosed in the present application are executed.
[0121] The dialogue management device provided by the present application adopts the dialogue management method in the above embodiment to solve the technical problem of dialogue management. Compared with the prior art, the beneficial effects of the dialogue management device provided by the present application are the same as the beneficial effects of the dialogue management method provided by the above embodiment, and the other technical features in the dialogue management device are the same as the features disclosed in the method of the previous embodiment, which will not be repeated here.
[0122] It should be understood that the various parts disclosed in this application can be implemented by hardware, software, firmware or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in a suitable manner.
[0123] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
[0124] The present application provides a computer-readable storage medium having computer-readable program instructions (ie, computer programs) stored thereon, and the computer-readable program instructions are used to execute the dialog management method in the above-mentioned embodiment.
[0125] The computer-readable storage medium provided in the present application may be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, systems or devices, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer 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. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, system or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination of the above.
[0126] The computer-readable storage medium may be included in the dialog management device; or it may exist independently without being assembled into the dialog management device.
[0127] The computer-readable storage medium carries one or more programs. When the one or more programs are executed by the dialogue management device, the dialogue management device: obtains the dialogue input content; determines the similarity scores corresponding to the dialogue input content and each topic in the preset vector database based on the dialogue input content, and selects or determines the target topic from the topics according to the similarity scores; predicts the dialogue input content according to the target topic to obtain the reply content corresponding to the dialogue input content. By determining the similarity scores corresponding to each topic in the preset vector database according to the dialogue input content, the target topic with a high correlation with the dialogue input content can be screened out from the topics in the preset database, and then the screened target topic is used to perform forward reasoning of the dialogue input content. Without using all historical dialogues for the reasoning process, more accurate reply content can be generated, thereby reducing unnecessary memory and computing overhead in multiple rounds of dialogue while ensuring the accuracy of the reply content.
[0128] Computer program code for performing the operations of the present application may be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0129] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0130] The modules involved in the embodiments described in this application may be implemented by software or hardware, wherein the name of the module does not constitute a limitation on the unit itself in some cases.
[0131] The readable storage medium provided in this application is a computer-readable storage medium, which stores computer-readable program instructions (i.e., computer programs) for executing the above-mentioned dialogue management method, and can solve the technical problems of dialogue management. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in this application are the same as the beneficial effects of the dialogue management method provided in the above-mentioned embodiment, and will not be repeated here.
[0132] The present application also provides a computer program product, including a computer program, which implements the steps of the above-mentioned dialogue management method when executed by a processor.
[0133] The computer program product provided by this application can solve the technical problem of dialogue management. Compared with the prior art, the beneficial effects of the computer program product provided by this application are the same as the beneficial effects of the dialogue management method provided by the above embodiment, which will not be repeated here.
[0134] The above descriptions are only some embodiments of the present application, and are not intended to limit the patent scope of the present application. All equivalent structural changes made using the contents of the present application specification and drawings under the technical concept of the present application, or direct / indirect applications in other related technical fields are included in the patent protection scope of the present application.
Claims
1. A dialogue management method, characterized in that: The method comprises: Get the dialogue input content; Determining a similarity score between each topic in a preset vector database and the conversation input content based on the conversation input content, and selecting or determining a target topic from the topics according to the similarity score; The dialogue input content is predicted according to the target topic to obtain reply content corresponding to the dialogue input content.
2. The method according to claim 1, characterized in that The step of obtaining the dialogue input content comprises: Receive user conversation information; Vectorization is performed on the user dialogue information to obtain the dialogue input content.
3. The method according to claim 1, characterized in that Before the step of determining the similarity score corresponding to each topic in the preset vector database and the dialogue input content based on the dialogue input content, the step further includes: Create an initial vector database and obtain historical conversation content; Obtaining the topics based on the historical conversation content; Selecting or determining the middle value of the self-attention calculation corresponding to each topic; The initial vector database is updated according to the topics and the intermediate values of the self-attention calculations corresponding to the topics to obtain the preset vector database.
4. The method according to claim 3, characterized in that The step of determining the similarity scores corresponding to the topics in the preset vector database and the conversation input content based on the conversation input content, and selecting or determining the target topic from the topics according to the similarity scores includes: Calculating the similarity between the conversation input content and each topic in the preset vector database respectively, and obtaining a similarity score corresponding to each topic; Determine whether the similarity score corresponding to each topic is greater than or equal to a preset score threshold; Among the topics, the topic whose similarity score is greater than or equal to a preset score threshold is taken as the target topic.
5. The method according to claim 4, characterized in that The step of predicting the dialogue input content according to the target topic to obtain the reply content corresponding to the dialogue input content includes: splicing the target topic with the dialogue input content to obtain an input sequence; Inputting the intermediate value of the self-attention calculation corresponding to the input sequence and the target topic into the large language model, and calculating the intermediate value of the self-attention calculation corresponding to the dialogue input content through the large language model; Performing a dot product operation on the intermediate value of the self-attention calculation corresponding to the target topic and the intermediate value of the self-attention calculation corresponding to the dialogue input content to obtain an operation result; Prediction is performed based on the calculation result to obtain reply content corresponding to the dialogue input content.
6. The method according to claim 5, characterized in that After the step of determining whether the similarity scores corresponding to the topics are greater than or equal to the preset score threshold, the following step further includes: If there is no corresponding topic among the topics whose similarity score is greater than or equal to the preset score threshold, the conversation input content is used as a new topic to update the preset vector database, and the intermediate value of the self-attention calculation corresponding to the conversation input content is stored in the preset vector database.
7. A dialogue management device, characterized in that: The device comprises: The acquisition module is used to obtain the dialogue input content; A scoring module, configured to determine, based on the conversation input content, a similarity score between each topic in a preset vector database and the conversation input content, and select or determine a target topic from the topics according to the similarity score; The prediction module is used to predict the dialogue input content according to the target topic to obtain the reply content corresponding to the dialogue input content.
8. A conversation management device, characterized in that: The device comprises: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the dialog management method according to any one of claims 1 to 6.
9. A storage medium, characterized in that: The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the dialogue management method according to any one of claims 1 to 6 are implemented.
10. A computer program product, characterized in that The computer program product comprises a computer program, and when the computer program is executed by a processor, the steps of the dialog management method according to any one of claims 1 to 6 are implemented.