A method for responding to a dialogue based on a related theme and related products
By using topic association technology, which combines the user's current input with historical dialogue content, more accurate and coherent response text is generated, solving the problem of low response quality in traditional dialogue responses and improving the user experience.
Patent Information
- Application Number
- CN202510223768.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-25
- Publication Date
- 2026-08-25
AI Technical Summary
In traditional dialogue response methods, the current input content of the user is not sufficiently relevant to the previous interaction content, resulting in low response quality and affecting user experience.
By using topic association technology, the system obtains the user's input text to be answered, determines its target topic, and searches for related topics and related dialogue texts from historical dialogue texts. The system then uses a question-and-answer model to generate the response text and combines it with preset prompt texts to improve the coherence and accuracy of the response.
It improves the accuracy and quality of dialogue responses, making the reply text more coherent and personalized, and enhancing the user experience.
Smart Images

Figure CN122633802A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of natural language processing technology, and in particular to a dialogue response method and related products based on related topics. Background Technology
[0002] With the rapid development of technology, question-and-answer systems such as virtual voice assistants and chatbots have become increasingly mature. They can answer users' questions, provide information, perform specific tasks, or engage in entertainment and interaction, greatly satisfying users' needs for convenience.
[0003] Traditional dialogue response methods are typically question-and-answer based, where the system generates a response solely based on the user's current input. Another approach involves saving preceding and following questions—that is, saving dialogues from around the time the user's current input—and combining them with the current input to generate a response. However, during user interaction, the current input may contain related content from previous interactions. The question-and-answer method only considers the current input, while the other approach only considers the current input and dialogues from similar times, which may be unrelated. This can lower the quality of the generated response and negatively impact the user experience. Summary of the Invention
[0004] This application provides a dialogue response method and related products based on associated topics. The purpose is to associate the user's current input content with related content that the user has previously interacted with by associating them with associated topics, thereby improving the accuracy of dialogue responses and enhancing the user experience.
[0005] The first aspect of this application provides a dialogue response method based on related topics, including:
[0006] Obtain the text to be answered from the target object;
[0007] The target topic of the text to be responded to is determined;
[0008] If a related topic is identified from the historical topics of the historical dialogue text that is related to the target topic, then the related dialogue text corresponding to the related topic is obtained.
[0009] Using a question-and-answer model, a response text is generated based on the text to be answered, the associated dialogue text, and a preset prompt text. The preset prompt text is used to indicate that the text to be answered is the current text to be answered, and to indicate that the associated dialogue text is a historical dialogue text associated with the text to be answered.
[0010] A second aspect of this application provides a dialogue response apparatus based on related topics, comprising:
[0011] The module for obtaining the text to be answered is used to obtain the text to be answered input by the target object;
[0012] The topic determination module is used to determine the target topic of the text to be responded to;
[0013] The associated dialogue text acquisition module is used to acquire the associated dialogue text corresponding to the associated topic if an associated topic related to the target topic is determined from the historical topics of historical dialogue texts.
[0014] The response text generation module is used to generate a response text corresponding to the text to be responded to based on the text to be responded to, the associated dialogue text, and the preset prompt text using a question-and-answer model. The preset prompt text is used to indicate that the text to be responded to is the current text to be responded to, and to indicate that the associated dialogue text is a historical dialogue text associated with the text to be responded to.
[0015] A third aspect of this application provides a topic-based dialogue response device, the device comprising a processor and a memory:
[0016] The memory is used to store computer programs and to transfer the computer programs to the processor;
[0017] The processor is configured to execute, according to instructions in the computer program, the steps of the topic-based dialogue response method provided in the first aspect.
[0018] A fourth aspect of this application provides a computer-readable storage medium for storing a computer program that, when executed by a topic-based dialogue response device, implements the steps of the topic-based dialogue response method provided in the first aspect.
[0019] The fifth aspect of this application provides a computer program product, including a computer program that, when executed by a topic-based dialogue response device, implements the steps of the topic-based dialogue response method provided in the first aspect.
[0020] As can be seen from the above technical solutions, the embodiments of this application have the following advantages:
[0021] The technical solution of this application first obtains the text to be answered input by the target object, such as the text of the target object's current input. Then, it determines the target topic of the text to be answered. Subsequently, from the historical topics of historical dialogue texts, if a related topic is found that is related to the target topic, it indicates that the target object has mentioned related content that was previously interacted with, and the related dialogue text corresponding to the related topic is obtained. Finally, through a question-and-answer model, based on the text to be answered, the related dialogue text, and the preset prompt text, the answer text corresponding to the text to be answered is generated. The preset prompt text is used to indicate that the text to be answered is the current text to be answered, and to indicate that the related dialogue text is a historical dialogue text related to the text to be answered. In this way, by identifying the relationship between the target topic and the related topics, the related dialogue text that is related to the text to be answered input by the target object is determined. When answering the text to be answered, combining the previous related dialogue text makes the generated answer text of higher quality, more coherent, and more personalized to meet user needs, which helps to improve the accuracy of dialogue responses and thus improves the user experience. Attached Figure Description
[0022] Figure 1 A scenario architecture diagram of a dialogue response method based on related topics provided in an embodiment of this application;
[0023] Figure 2 A flowchart illustrating a dialogue response method based on related topics, provided for an embodiment of this application;
[0024] Figure 3 A schematic diagram of a chat window for a virtual voice assistant provided in an embodiment of this application;
[0025] Figure 4 A flowchart illustrating the training steps of a topic recognition model provided in this application embodiment;
[0026] Figure 5 A flowchart illustrating the process of determining associated topics and associated dialogue text, provided for embodiments of this application;
[0027] Figure 6 A flowchart illustrating a specific topic-based dialogue response method provided in this application embodiment;
[0028] Figure 7 A schematic diagram of the structure of a dialogue response device based on related topics provided in an embodiment of this application;
[0029] Figure 8 This is a schematic diagram of the server structure in an embodiment of this application;
[0030] Figure 9 This is a schematic diagram of the structure of a terminal device in an embodiment of this application. Detailed Implementation
[0031] Currently, one common dialogue response method is a question-and-answer format. The system receives the user's current input, performs intent recognition, and retrieves a response from a knowledge base based on the identified intent. However, this method can be problematic because the user's current input may be related to previously entered information, making it difficult for the system to generate an accurate response. For example, in a game scenario, a user might have entered "I got equipment A today, I'm so happy!" the previous day, and now enter "Which equipment did I get yesterday, and what are its functions?" This dialogue response method, based solely on the user's current input, cannot determine the equipment obtained, and may only output information about popular equipment, failing to meet the user's needs.
[0032] Another dialogue response method: Building upon the question-and-answer format, the question-and-answer system can save the preceding and following questions, that is, save dialogues from around the time the user's current input. The system then combines these with the user's current input to generate a response. However, situations may still arise where the user's current input is related to previous inputs (not from adjacent times), making it difficult for the system to generate an accurate answer. In the game scenario example described above, dialogues from around the time the user's current input might involve inquiries about game modes or other content, making it difficult for the system to generate an accurate response. Furthermore, these dialogues from around the time differ significantly from the user's current input, creating input noise that can reduce response quality and fail to meet user needs.
[0033] In view of the above problems, this application provides a dialogue response method and related products based on related topics. The purpose is to improve the accuracy of dialogue responses and thus enhance the user experience by associating the user's current input with related content that the user has previously interacted with through related topics. In the technical solution provided in this application, the following steps are taken: 1. Obtain the text to be responded to input by the target object; 2. Determine the target topic of the text to be responded to; 3. From the historical topics of historical dialogue texts, if a related topic related to the target topic is determined, obtain the related dialogue text corresponding to the related topic; 4. Through a question-and-answer model, generate the response text corresponding to the text to be responded to based on the text to be responded to, the related dialogue text, and a preset prompt text. The preset prompt text is used to indicate that the text to be responded to is the current text to be responded to, and to indicate that the related dialogue text is a historical dialogue text associated with the text to be responded to.
[0034] After obtaining the text to be answered from the target user, the system traces back through historical dialogue texts to identify related topics. By identifying these related topics, it further determines the relevant dialogue texts that are connected to the text to be answered. In other words, by associating the user's current input with previously interacted content through related topics, it restores the previous related topics. This allows for a comprehensive consideration of both factors when generating the response text, resulting in a more coherent and personalized response that better meets the user's needs. It also ensures consistency of information exchanged with the user. For example, for two highly relevant texts to be answered, it avoids situations where the response texts are significantly different, thus improving the quality and accuracy of the generated response text and ultimately enhancing the user experience.
[0035] Next, the execution subject of the topic-based dialogue response method provided in this application will be described in detail.
[0036] The execution entity of the topic-based dialogue response method provided in this application can be a terminal device. For example, the terminal device obtains the text to be responded to input by the target object. As an example, the terminal device may include, but is not limited to, mobile phones, desktop computers, tablet computers, laptops, PDAs, smart voice interaction devices, smart home appliances, vehicle terminals, aircraft, etc. The execution entity of the topic-based dialogue response method provided in this application can also be a server, that is, the server may obtain the text to be responded to input by the target object. As an example, the server may be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, etc. This application does not limit the type of server.
[0037] Furthermore, the topic-based dialogue response method provided in this application can also be executed collaboratively by a terminal device and a server. For example, the terminal device obtains the text to be responded to input by the target object and sends the text to the server. Then, the server determines the target topic of the text to be responded to, and if the server determines a related topic from the historical topics of historical dialogue texts, it obtains the related dialogue text corresponding to the related topic. Subsequently, the server generates a response text corresponding to the text to be responded to based on the text to be responded to, the related dialogue text, and a preset prompt text using a question-and-answer model. Finally, the server sends the response text to the terminal device so that the terminal device can display it to the user. The terminal and the server can be directly or indirectly connected via wired or wireless communication, which is not limited in this application. Therefore, the implementation entity of the technical solution of this application is not limited in this application embodiment. See also Figure 1 This diagram exemplifies a scenario architecture for a topic-based dialogue response method. It includes a server and various types of terminal devices.
[0038] Next, taking the terminal device as the execution subject, the dialogue response method based on related topics provided in the embodiments of this application will be described in detail.
[0039] See Figure 2 The figure is a flowchart of a dialogue response method based on related topics provided in an embodiment of this application.
[0040] like Figure 2 The dialogue response method based on related topics, as shown, includes the following steps:
[0041] S201: Obtain the text to be answered input by the target object.
[0042] The target object refers to the object that the terminal device needs to interact with, such as the user of the terminal device. For ease of understanding, the following text will use the user of the terminal device as the target object for illustrative purposes.
[0043] The text to be responded to refers to the text entered by the user into the terminal device, awaiting a response from the terminal device. It reflects the user's needs. Taking a game scenario as an example, the text to be responded to can be related to game content, game characters, or game equipment. For example, the text to be responded to could be: "Where is the tutorial for this game?" or "How to quickly level up my game character?" The text to be responded to could also be: "My game character has reached level xxx, I'm so happy!", or, "I finally got this equipment, praise me!", or, "Do you remember what equipment I got yesterday?" etc. This application does not limit the content of the text to be responded to.
[0044] Furthermore, in shopping scenarios, the text to be responded to can also be related to products, stores, or members; this application does not limit the application scenario. For ease of understanding, a game scenario will be used as an example for illustration below.
[0045] As an example, a question-and-answer system may be configured on the terminal device. For instance, the question-and-answer system may be a chatbot, which may be an application or chatbot mini-program on the terminal device. Alternatively, the question-and-answer system may be a virtual voice assistant of an application (such as a game application) installed on the terminal device.
[0046] Accordingly, the method for obtaining the text to be answered can be: the terminal device displays an interactive page through the question-and-answer system, such as displaying a chat window including an input box. As an example, taking a virtual voice assistant in a game application as an example, the user can input the voice to be answered, and then the terminal device receives the voice and converts it into text to be answered, thus obtaining the text input by the user. See also... Figure 3The figure is a schematic diagram of a chat window of a virtual voice assistant provided in an embodiment of this application. The user can trigger the voice input control and input the voice to be answered: "Do you remember what equipment I got yesterday?" The terminal device can output the reply text through the virtual voice assistant: "Warrior, you got a piece of equipment yesterday - the Moonlight Gun, you have become stronger!" The reply text can be displayed in the chat window or as an output reply voice.
[0047] It should be noted that this application does not limit the form of user input content, which can be text to be answered, voice to be answered, or other forms such as images and videos; this application also does not limit the form of the response output by the terminal device, which can be at least one of response text and response voice, or other forms such as images and videos.
[0048] S202: Determine the target topic of the text to be responded to.
[0049] It is understandable that the text to be responded to will have a corresponding target topic, and the content expressed in the text to be responded to will revolve around the target topic. The target topic can reflect the core content and key information of the text to be responded to.
[0050] For example, if the text to be answered is: "Do you remember what equipment I got yesterday?", the target topic could be "equipment query".
[0051] In one possible implementation of this application, the target topic can be obtained by performing topic recognition on the text to be answered using a topic recognition model. That is, S202 can be: generating the target topic corresponding to the text to be answered based on the text to be answered using a topic recognition model.
[0052] Accordingly, see Figure 4 The figure is a flowchart of the training steps of a topic recognition model provided in an embodiment of this application, as shown below. Figure 4 As shown, this topic recognition model can be trained through the following steps:
[0053] A1: Obtain the training text to be answered and the training topic corresponding to the training text to be answered.
[0054] Training response text refers to training samples used to train the topic recognition model. For example, training response text can be obtained from historical dialogue texts of user interactions with the terminal device; the historical response texts input by the user are extracted from these historical dialogue texts and used as training response texts. Training topics refer to training labels used to train the topic recognition model. In some embodiments, training topics can be obtained by manually labeling the training response texts.
[0055] For example, the training text to be answered can be short text related to the question-answering domain of the question-answering system. For instance, if the question-answering domain is the game scenario mentioned above, then the short text can be text introducing game equipment, game characters, and other related game content. Accordingly, the training topic can be the title of the short text or manually annotated text, and this application does not limit this.
[0056] In some embodiments, the training topic can be at least one keyword in the training response text; that is, the training topic is the keyword text in the training response text, which can represent the core content of the training response text. For example, the training response text could be: "What skills is most useful for game character A in battle mode?", and the corresponding training topic could be: game character A and battle mode. Accordingly, the trained topic recognition model can also be called a keyword recognition model, which can identify keywords as target topics for the response text.
[0057] In other embodiments, the training topic can also be a word or short passage that indicates the core content of the training response text; that is, the training topic may not exist in the training response text (although it is also possible that the training topic exists in the training response text). For example, the training response text could be: "I got the Moonlight Gun, I'm so happy!", and its corresponding training topic could be: equipment acquisition. Accordingly, the trained topic recognition model can also identify the target topic for the response text, and the target topic can be text that does not exist in the response text.
[0058] A2: Using the second training model, generate the predicted topic corresponding to the training response text based on the training response text.
[0059] The training text to be answered is input into the second training model, which can then identify the topic of the training text to obtain its corresponding predicted topic.
[0060] In some embodiments, the second model to be trained may be a large model such as a large language model, a convolutional neural network, a recurrent neural network, or a word embedding model, etc. This application does not limit the type of the second model to be trained.
[0061] The large model may also include multimodal models, etc., but this application does not limit this.
[0062] Taking a large language model as an example, the second model to be trained can be input together with a prompt word and the training text to be answered. The prompt word is used to guide the second model to identify the topic of the training text. For example, the prompt word could be: "Please read the following text in the xx domain (e.g., the gaming domain), and then analyze the key information in the text to determine the topic of the text." The prompt word mentions the domain of the training text to be answered, making it more targeted and helping to improve the accuracy of the output predicted topic.
[0063] It should be noted that in the example where the second model to be trained is a large language model, the input of the trained topic recognition model can include the text to be answered and prompt words.
[0064] In the embodiments of this application, multiple prompt words can be preset, and the prompt word with the best effect can be determined as the final prompt word during model training. This application does not limit the method of determining the prompt words.
[0065] A3: Based on the predicted topic corresponding to the training text to be answered and the training topic, construct a second loss function, and train the second training model based on the second loss function to obtain the topic recognition model.
[0066] The constructed second loss function can be used to measure the gap between the predicted topic and the training topic.
[0067] In some embodiments, the training steps are repeatedly performed using multiple training texts to be answered and training topics corresponding to each training text to be answered, and the value of the second loss function is minimized during the training process, so that the predicted topic gets closer and closer to the training topic, until the preset training termination condition is met, and a trained topic recognition model can be obtained.
[0068] For example, the preset training termination condition could be that the number of training iterations for the second model to be trained reaches a preset number; or it could be that the model performance of the second model to be trained meets a preset requirement, such as the difference between the predicted topic and the training topic meeting a preset difference condition. This application does not limit this.
[0069] In this way, the trained topic recognition model can effectively identify the target topic of the text to be answered, which can represent the core content of the text to be answered and help to identify related dialogue texts.
[0070] To further improve the performance of the topic recognition model, it can be corrected and trained based on application data after being applied for a period of time. Therefore, in one possible implementation of this application, the topic-based dialogue response method may further include the following steps:
[0071] B1: Obtain the text input when applying the topic recognition model as the text sample to be answered, and obtain the text output when applying the topic recognition model as the topic tag.
[0072] After the topic-based dialogue response method provided in this application embodiment has been executed on the terminal device for a period of time, the online log of the topic recognition model can be retrieved. The text to be responded to, input into the topic recognition model, is taken as the text sample to be responded to, and the topic output by the topic recognition model for the text sample to be responded to is taken as the topic tag. It should be noted that this application does not limit the number of text samples to be responded to and their corresponding topic tags.
[0073] B2: If the topic tag corresponding to the text sample to be answered does not match, then obtain the correct topic tag corresponding to the text sample to be answered.
[0074] The fact that the text sample to be answered does not match its corresponding topic tag indicates that the topic recognition model has misidentified the topic of the text sample to be answered, and the topic tag cannot represent the core content of the text sample to be answered. Therefore, the correct topic tag corresponding to the text sample to be answered can be obtained, and the correct topic tag can accurately represent the core content of the text sample to be answered.
[0075] For example, the text sample to be answered is: "How to increase the skill damage output of a game character". The topic recognition model outputs the topic tag for it as: "Equipment upgrade". However, the text sample to be answered does not mention game equipment, and the topic tag cannot represent its core content. The two do not match, so the correct topic tag can be obtained, such as: "Character skill upgrade".
[0076] B3: Using the topic recognition model, generate a predicted topic corresponding to the text sample to be answered based on the text sample to be answered.
[0077] It should be noted that the specific implementation of B3 can be found in A2 described above, and will not be repeated here.
[0078] The training samples of this topic recognition model may include not only response text samples that do not match the topic tags, but also response text samples that match the topic tags, as well as the training response texts described above. This application does not limit this.
[0079] B4: Based on the predicted topic corresponding to the text sample to be answered and the correct topic label, construct a third loss function, and train the topic recognition model based on the third loss function to obtain the latest topic recognition model.
[0080] It should be noted that the specific implementation of B4 can be found in the relevant content of A3 above when training the second model to be trained, and will not be repeated here.
[0081] The third loss function can be the same as or different from the second loss function. For example, if the second loss function is the cross-entropy loss function, the third loss function can also be the cross-entropy loss function, or the third loss function can be the root mean square error loss function, etc.
[0082] In some embodiments, the topic recognition model can be subjected to the correction training described above according to a preset period, which can be 15 days or 30 days, and this application does not limit it.
[0083] The state-of-the-art topic recognition model, once trained, can be used to identify topics in newly input texts to be answered by target objects, thereby continuously improving the accuracy of topic recognition.
[0084] It should be noted that B1-B4 are only used to distinguish the different training steps of the latest topic recognition model and are not shown in the figure.
[0085] In this way, by using response text samples that do not match the topic tags, the topic recognition model can be specifically corrected and trained, enabling the topic recognition model to learn more accurate topic recognition rules, thereby improving the topic recognition accuracy of the latest topic recognition model and laying the foundation for subsequently determining accurate related dialogue samples.
[0086] S203: If a related topic is identified from the historical topics of the historical dialogue text that is related to the target topic, then the related dialogue text corresponding to the related topic is obtained.
[0087] Historical dialogue text can be the dialogue text between the target object and the terminal device during past interactions. Taking the interaction between a user and a virtual voice assistant in a game application as an example, historical dialogue text can be the historical pending response text and historical reply text between the user and the virtual voice assistant before the terminal device obtains the pending response text input by the user. Historical topics are obtained by identifying the topics of the historical pending response text in the historical dialogue text (for example, using the topic recognition model described above).
[0088] First, related topics can be identified from historical topics. These topics indicate that the text to be answered and the historical texts to be answered under related topics are related. Therefore, related dialogue texts with a relationship can be further identified. The related texts to be answered and the related response texts included in these dialogue texts are of reference value and help to generate higher quality response texts.
[0089] Taking the text to be answered as: User: "Do you remember what equipment I got yesterday?" as an example, the target topic can be "equipment query". The identified related topics can be: "equipment acquisition" and "equipment query", and the identified related dialogue text can be: User: "I got a piece of equipment - Moonlight Gun, I'm so happy!", Virtual voice assistant: "Congratulations, warrior, I'm happy for you!"
[0090] Furthermore, in some embodiments, if a related topic cannot be determined from the historical topics of the historical dialogue text, the corresponding response text can be directly generated based on the text to be responded to, without having to execute the subsequent S204.
[0091] Next, we will introduce how to determine related topics and related dialogue text.
[0092] In one possible implementation of this application, see [link to relevant documentation]. Figure 5 The figure is a flowchart illustrating a process for determining associated topics and associated dialogue text according to an embodiment of this application. Figure 5 As shown, S203: "If a related topic is determined from the historical topics of historical dialogue texts that is related to the target topic, then the related dialogue text corresponding to the related topic is obtained," which may specifically include the following steps:
[0093] C1: Calculate the first similarity between the historical topic and the target topic.
[0094] In some embodiments, the terminal device may store historical topic text vectors containing historical topics, and historical dialogue text vectors containing historical dialogue texts under historical topics.
[0095] After identifying the target topic, it can be converted into a target topic text vector, and the text to be answered can also be converted into a text vector. Then, the vector similarity between the historical topic text vectors and the target topic text vector can be calculated, and the obtained similarity value is used as the first similarity score. For example, cosine similarity, Euclidean distance, etc., can be used to calculate the first similarity score.
[0096] For example, taking historical topics including historical topic 1 to historical topic 10 as an example, each corresponds to historical topic text vector 1 to historical text topic vector 10. The first similarity between each historical text topic vector in historical topic text vector 1 to historical text topic vector 10 and the target topic text vector can be calculated to obtain similarity value 1 to similarity value 10.
[0097] Vector transformation models that convert target topics, text to be answered, historical topics, and historical dialogue text into vectors can be word vector models (Word2Vec), bidirectional encoder representations from transformers (BERT), or vector embedding models, etc., and this application does not limit them.
[0098] One approach is to fine-tune a vector transformation model on a large language model using domain data (such as the game domain). For example, the vector output from the last transform layer of the BERT model can be used as the final output vector. The vector can be a two-dimensional array, including the text length and the model dimension.
[0099] C2: Historical topics whose first similarity exceeds the second threshold are considered as the associated topics.
[0100] If the first similarity exceeds the second threshold, it indicates that the corresponding historical topic is highly relevant to the target topic, and therefore it can be regarded as a related topic.
[0101] In the example where the historical topics include historical topics 1 through 10, the first similarity for each historical topic is similarity value 1 through similarity value 10. If the similarity value 8 through similarity value 10 is greater than the second threshold, then historical topics 8 through 10 can be considered as related topics.
[0102] Furthermore, in some embodiments, based on this, that is, after determining the corresponding historical topics whose first similarity exceeds the second threshold, further filtering can be performed to determine the historical topics with the first similarity in the top K as related topics, where K is an integer greater than 0, such as K can be 1 or 3, etc. This application does not limit the value of K.
[0103] In the example described above, assuming K is 1, the similarity value 8 - similarity value 10 is greater than the second threshold, and the similarity value 8 is the highest, then historical topic 8 can be regarded as the associated topic.
[0104] C3: Calculate the second similarity between the historical dialogue text corresponding to the associated topic and the text to be answered.
[0105] In some embodiments, based on the above description, the terminal device may store historical dialogue text vectors containing historical dialogue text. After determining the associated topic, the corresponding historical dialogue text vector can be obtained, and the vector similarity between the text vector to be responded to and the corresponding historical dialogue text vector can be calculated. The obtained similarity value is used as the second similarity. The calculation method can refer to the calculation method of the first similarity, and will not be repeated here.
[0106] Historical dialogue text can include dialogue text from multiple rounds. Therefore, a related topic corresponds to at least one round of dialogue text; that is, the historical dialogue text corresponding to a related topic is the dialogue text from that corresponding at least one round. The related topic can be identified by using a topic recognition model to analyze the historical unanswered text within each round of dialogue text. A single round of dialogue text can include both historical unanswered text and historical response text.
[0107] It should be noted that this application does not limit the number of historical pending response texts and historical response texts in a single round of dialogue. For example, a single round of dialogue may include one historical pending response text and one historical response text, i.e., a question and answer, or it may include multiple historical pending response texts that are consecutive in time or highly related, as well as their corresponding historical response texts. For ease of understanding, the following text will use a single question and answer format as an example for a single round of dialogue.
[0108] Accordingly, when calculating the second similarity, the vector similarity between the text vector of the dialogue text in each round and the text vector of the text to be answered can be calculated, or the vector similarity between the text vector of the historical text to be answered and the text vector of the text to be answered can be calculated.
[0109] For example, taking the related topic as historical topic 8, it includes dialogue texts from two rounds, namely dialogue text 1 and dialogue text 2. Dialogue text 1 includes historical text to be answered 1 and historical text to be answered 1, and dialogue text 2 includes historical text to be answered 2 and historical text to be answered 2. The vector similarity between the text vector of historical text to be answered 1 (or the text vector of dialogue text 1 that can be calculated) and the text vector of text to be answered can be calculated to obtain a similarity value 11, and the vector similarity between the text vector of historical text to be answered 2 (or the text vector of dialogue text 2 that can be calculated) and the text vector of text to be answered can be calculated to obtain a similarity value 12. The similarity values 11 and 12 are the second similarity.
[0110] C4: Use historical dialogue texts with a second similarity exceeding the third threshold as the associated dialogue texts.
[0111] If the second similarity exceeds the third threshold, it indicates that the corresponding historical dialogue text is highly relevant to the text to be answered, and therefore it can be used as the associated dialogue text.
[0112] In the example where the second similarity includes similarity values 11 to 12, assuming that the similarity value 11 is greater than the third threshold, then dialogue text 1 can be considered as associated dialogue text.
[0113] Furthermore, in some embodiments, based on this, that is, after determining the historical dialogue texts whose second similarity exceeds the third threshold, further filtering can be performed to determine the historical dialogue texts with the second similarity in the top N as associated dialogue texts, where N is an integer greater than 0, such as N can be 1 or 2, etc. This application does not limit the value of N.
[0114] In the example described above, assuming N is 1, both similarity values 11 and 12 are greater than the third threshold, and similarity value 11 is the highest, then dialogue text 1 can be regarded as the associated dialogue text.
[0115] In this way, by using the vector similarity of texts, we can identify related topics that are relevant to the target topic, and then identify related dialogue texts that are relevant to the text to be answered, enabling the terminal device to combine the two and output a higher quality response text.
[0116] S204: Using a question-and-answer model, generate the response text corresponding to the text to be answered, the associated dialogue text, and the preset prompt text.
[0117] A question-answering model is a model used to respond to text input by a user, generating response text that meets the user's needs.
[0118] The preset prompt text is used to indicate that the text to be answered is the current text to be answered, and to indicate that the associated dialogue text is a historical dialogue text associated with the text to be answered. For example, the preset prompt text could be: Found memory: Associated historical dialogue record - xxxxxx, User input: xxxxxxxxx. Here, "Associated historical dialogue record" indicates that the associated dialogue text is a historical dialogue text associated with the text to be answered, and "User input" indicates that the text to be answered is the current text to be answered.
[0119] Taking the associated dialogue text as: "User: I got a piece of equipment - the Moonlight Gun, I'm so happy! Virtual voice assistant: Congratulations, warrior, I'm so happy for you!", and the text to be answered as: "Do you remember what equipment I got yesterday?", we can input "Found memory: associated historical dialogue record - 'User: I got a piece of equipment - the Moonlight Gun, I'm so happy! Virtual voice assistant: Congratulations, warrior, I'm so happy for you!', User input: 'Do you remember what equipment I got yesterday?'" into the question-answering model, so that the question-answering model outputs the answer text, such as: "Warrior, you got a piece of equipment - the Moonlight Gun yesterday, you've become stronger!".
[0120] Next, we will continue to introduce the training steps of the question-answering model.
[0121] In one possible implementation of this application, the question-answering model can be trained through the following steps:
[0122] D1: Obtain the training sample to be answered, the associated dialogue training sample of the training sample to be answered, the prompt training sample, and the response training sample corresponding to the training sample to be answered.
[0123] Training samples awaiting response refer to training text samples that require a response. Related dialogue training samples refer to training text samples that are associated with the training samples awaiting response. Response training samples refer to training text samples that provide a response to the training samples awaiting response. For example, this data can be obtained from historical dialogue texts between the user and the terminal device.
[0124] The prompt training sample refers to the prompt text training sample, which is used to prompt that the training sample to be responded to is the current text to be responded to, and to prompt that the associated dialogue training sample is the historical dialogue text associated with the training sample to be responded to.
[0125] D2: Using the third training model, based on the training sample to be answered, the associated dialogue training sample of the training sample to be answered, and the prompt training sample, generate the predicted response text of the training sample to be answered.
[0126] It should be noted that the specific implementation of D2 can be found in A2 described above, and will not be repeated here.
[0127] D3: Based on the predicted response text and the response training samples, construct a fourth loss function, and train the third model to be trained based on the fourth loss function to obtain the question-answering model.
[0128] The constructed fourth loss function can be used to measure the gap between the predicted response text and the response training samples.
[0129] It should be noted that the specific implementation of D3 can be found in the relevant content of training the second model to be trained in A3 above, and will not be repeated here.
[0130] It should be noted that D1-D3 are only used to distinguish different training steps of the question-answering model and are not shown in the figure.
[0131] Next, we will introduce how to store the target topic and the text to be answered.
[0132] In one possible implementation of this application, historical topics can be stored in a historical topic database, historical dialogue texts can be stored in a historical dialogue text database, and historical topics and historical dialogue texts have a corresponding relationship. Therefore, the dialogue response method based on related topics may further include steps 1 and 2, which can be executed selectively:
[0133] Step 1: If the target topic is different from the associated topic, that is, the two texts are different, the target topic can be stored as a new topic in the historical topic database; then the target dialogue text composed of the text to be answered and the text to be answered is stored in the historical dialogue text database; and in order to find the target dialogue text by the target topic, a correspondence is added between the target topic and the target dialogue text.
[0134] For example, if the target topic is "equipment query" and the identified related topic is "equipment acquisition", then "equipment query" can be stored in the historical topic database, and the target dialogue text can be stored in the historical dialogue text database, and a correspondence between "equipment query" and the target dialogue text can be added.
[0135] Step 2: If there is a topic in the associated topics that is the same as the target topic, that is, there is a topic with the same text, it indicates that the target topic is an old topic, and the target dialogue text can be directly stored in the historical dialogue text database; and a correspondence relationship is added between the target topic that is an old topic and the target dialogue text.
[0136] For example, if the target topic is "equipment query" and the identified related topics are "equipment acquisition" and "equipment query", then the target dialogue text can be stored in the historical dialogue text database, and a correspondence between "equipment query" and the target dialogue text can be added.
[0137] Similarly, historical topics and historical dialogue texts are also stored in the manner described above, resulting in the contents stored in the historical topic database and the historical dialogue text database, respectively.
[0138] In this way, by storing the user-input text to be answered, the target topic, and the reply text in real time, the comprehensiveness of the historical topic database and the historical dialogue text database can be continuously improved. This helps to find more relevant related dialogue texts, thereby improving the quality of the generated reply text and enhancing the user experience.
[0139] As described above, it is possible to store the user's input text to be answered, the target topic, and the reply text in real time. However, as time goes on, the amount of stored content increases, which can easily increase the time required to find and determine related topics and related dialogue texts, thereby increasing the time required to generate reply texts and affecting the user experience.
[0140] To address this issue, historical dialogue texts can be summarized. In this application's embodiments, there are several possible implementations for summarizing historical dialogue texts, which are described below. It should be noted that the implementations described below are merely illustrative examples and do not represent all implementations of this application's embodiments.
[0141] The first possible approach to summarizing historical dialogue texts includes the following steps:
[0142] The historical dialogue text can include dialogue texts from multiple rounds, as described in the relevant section of step C3 above, and the historical topic can include at least one historical topic.
[0143] E1: For each historical topic, if the sum of the text lengths of the historical dialogue texts corresponding to that historical topic exceeds the length threshold, then the text summary model is used to generate the summary text corresponding to the dialogue text of that round based on the dialogue text of each round under that historical topic.
[0144] The summary text is shorter than the dialogue text of that round, and the summary text is used to indicate the core content of the dialogue text of that round.
[0145] For example, the length threshold can be a character length threshold of 4098, but this application does not limit it to this.
[0146] For example, if there are 8 historical topics, and the sum of the text lengths (i.e. the sum of the number of text characters) of the historical dialogue texts corresponding to 4 of these historical topics exceeds 4098, then E1 will be executed for each of these 4 historical topics.
[0147] Taking historical theme x with four historical themes as an example, which includes dialogue texts in three rounds (dialogue texts 3-5), then using dialogue text 3 as an example, a summary text corresponding to dialogue text 3 can be generated through the text summary model. The length of the summary text is shorter than that of dialogue text 3, and the summary text is used to indicate the core content of dialogue text 3. The same applies to dialogue texts 4 and 5, and will not be elaborated further.
[0148] For example, dialogue text 3 includes: "User: I got a piece of equipment - the Moonlight Gun, I'm so happy! Virtual voice assistant: "Congratulations, warrior, I'm happy for you!" and "User: I still don't know how to use the Moonlight Gun? Virtual voice assistant: "I have a guide here, in detail...". Through the text summary model, the corresponding summary text can be output as: "The user obtained the Moonlight Gun on a certain date, and I have provided a relevant guide," which greatly reduces the text length and can represent the core content of dialogue text 3.
[0149] E2: For each round of dialogue text under this historical theme, replace the dialogue text of that round with the corresponding summary text.
[0150] For example, in the case where historical dialogue text is stored in a historical dialogue text database, dialogue text 3 is stored in the historical dialogue text database, and dialogue text 3 can be replaced with summary text.
[0151] In addition, in some embodiments, a correspondence can be added between the dialogue text 3 and its corresponding summary text, so that when determining the associated dialogue text, it can be determined based on its summary text.
[0152] Thus, the text summarization model can effectively reduce the length of the text without changing the core content of the historical dialogue text, which means that it can improve the generation speed of the response text while ensuring the accuracy of the response text.
[0153] Next, we will continue to introduce the training process of the text summary model.
[0154] In one possible implementation of this application, the text summarization model can be trained through the following steps:
[0155] F1: Obtain the training dialogue text and the corresponding training summary text.
[0156] In some embodiments, the training dialogue text may include the body text of an article, and the training summary text may include the summary text of the article, which may reflect the core content of the body text.
[0157] In addition, training dialogue texts can also be obtained from historical dialogue texts of user interactions with terminal devices, with corresponding training summary texts manually annotated.
[0158] F2: Using the first model to be trained, generate the predicted summary text corresponding to the training dialogue text based on the training dialogue text.
[0159] It should be noted that the specific implementation methods of F2 and F3 below can be found in the introduction of A2-A3 above, and will not be repeated here.
[0160] In the example where the first model to be trained is a large language model, the corresponding prompt words can be used to indicate the summary of historical dialogue text, as well as to indicate the text length limit of the output summary text. Other training dialogue texts and their corresponding training summary texts can also be included as examples.
[0161] For example, the prompt could be: "Analyze the following text, summarize its core content and output a summary text, and the number of characters (i.e., the text length) of the output summary text is less than the number of characters of the following text, and cannot exceed 20 characters. For details, please refer to the example: xxxxxxx, the text is: xxxxxx". This application does not impose any restrictions on this.
[0162] It should be noted that in this example where the first model to be trained is a large language model, prompt words are also required when the text summary model is applied.
[0163] F3: Based on the predicted summary text and the training summary text, construct a first loss function, and based on the first loss function, train the first model to be trained to obtain the text summary model.
[0164] It should be noted that F1-F3 are only used to distinguish different training steps of the text summary model and are not shown in the figure.
[0165] Thus, a well-trained text summarization model can generate shorter summary texts for longer historical dialogue texts, reducing memory usage. Shorter summary texts also help improve the computational speed of similarity calculations. Furthermore, when a single round of dialogue text includes multiple historical texts to be answered and their corresponding response texts, it can reduce the number of similarity comparisons, thereby reducing the consumption of computational resources. Therefore, it can significantly improve the speed of response text generation, thereby enhancing the user experience.
[0166] Next, we will introduce a second optional approach to summarizing historical dialogue text, which may include the following steps:
[0167] The historical dialogue text includes dialogue texts from multiple rounds. Each round of dialogue text includes historical texts to be answered and historical texts to be replied to. Please refer to the relevant content in step C3 above. The historical topics include at least one historical topic.
[0168] E3: For each historical topic, if the sum of the text lengths of the historical dialogue texts corresponding to that historical topic exceeds the length threshold, then duplicate texts among multiple historical unanswered texts under that historical topic are identified.
[0169] Among them, duplicate texts are at least two historical texts to be answered that have a similarity exceeding the first threshold. Duplicate texts may include two or more historical texts to be answered.
[0170] For example, given a historical topic with eight rounds of dialogue text, each round containing one historical text to be answered, we can identify duplicate texts among these eight historical texts. Let's say these eight historical texts are a1 to a8. Assuming the similarity between historical text a1 and historical text a2 exceeds a first threshold, and the similarity between historical text a2 and historical text a5 also exceeds a first threshold, then historical texts a1, a2, and a5 are considered duplicate texts.
[0171] It should be noted that the similarity calculation method between historical texts awaiting response can be found in the similarity calculation method introduced above in the sections on determining related topics and determining related dialogue texts, and will not be repeated here.
[0172] E4: Delete the duplicate text and the historical response text corresponding to each historical unanswered text in the duplicate text.
[0173] Subsequently, duplicate text is removed, which can reduce highly similar duplicate content stored on terminal devices.
[0174] It should be noted that E1-E4 are only used to distinguish the different steps in summarizing historical dialogue texts and are not shown in the diagram.
[0175] In this way, reducing the amount of highly similar duplicate content stored on terminal devices will not affect the process of determining related dialogue text, and can improve the generation speed of response text while ensuring the quality of response text.
[0176] In one possible implementation of this application, E4 may specifically include: first obtaining the response time corresponding to each historical text awaiting response in the repeated text; then retaining the historical text awaiting response with the latest response time, and retaining the historical response text corresponding to the historical text awaiting response with the latest response time.
[0177] For example, duplicate text can include: historical pending response text b1 and historical pending response text b2. Historical pending response text b1 is: "User: I got a piece of equipment - the Moonlight Gun, I'm so happy!", and its corresponding historical response text is: "Virtual Voice Assistant: Congratulations, warrior, I'm so happy for you!"; historical pending response text b2 is: "User: Yes, I'm so happy, I've always wanted a Moonlight Gun, and now I finally got it!", and its corresponding historical response text is: "Virtual Voice Assistant: Envious, hurry up and take this gun to the battlefield!". The corresponding response times for the two are 10:05 AM and 10:06 AM of the previous day, respectively. Therefore, only historical pending response text b2 and its corresponding historical response text, i.e., the latter, can be retained.
[0178] Thus, considering that the historical text to be answered closest to the current time and its corresponding historical text to be answered are generated based on richer content (e.g., the knowledge base has been updated, or the related dialogue content is more comprehensive), it indicates that the most recently generated historical text to be answered is of higher quality. Retaining higher quality historical text to be answered can effectively improve the generation speed of the text to be answered without affecting the accuracy of the text to be answered.
[0179] In addition, in some embodiments, the user's satisfaction with the historical response texts corresponding to each historical unanswered text in the repeated text can also be determined. For example, the user's satisfaction is collected and recorded when the historical response text is generated; then the historical unanswered text with higher satisfaction is retained, as well as the historical response text corresponding to the historical unanswered text with higher satisfaction is retained.
[0180] It should be noted that for the two optional implementation methods for summarizing historical dialogue texts mentioned above, the terminal device can choose one or combine multiple methods to implement them. For example, the terminal device can first execute E3 and E4. After deleting duplicate text, if the sum of the text lengths of the historical dialogue texts corresponding to the historical topics still exceeds the length threshold, then E1 and E2 can be executed until the sum of the text lengths of the historical dialogue texts corresponding to the historical topics is less than or equal to the length threshold. This application does not impose any restrictions on this.
[0181] In one possible implementation of this application, the text to be responded to may be related to the game application, that is, the text to be responded to mentioned above may be related to game content, game characters or game equipment, etc.
[0182] Accordingly, the topic-based dialogue response method may further include: acquiring the voice to be responded to input by the target object through the virtual voice assistant of the game application. For example, the terminal device has a game application installed, which includes a virtual voice assistant that can display, for example... Figure 3 As shown in the page diagram, users can trigger the voice input control, and the terminal device will collect the voice data emitted by the user to obtain the voice to be answered.
[0183] Accordingly, S201 "obtaining the text to be answered input by the target object" can be: converting the speech to be answered into the text to be answered. For example, the terminal device can use Automatic Speech Recognition (ASR) technology to convert the speech to be answered into the text to be answered. For instance, an ASR model can be trained, and the start and end points of the speech to be answered can be determined by Voice Activity Detection (VAD) technology, and then input into the ASR model to obtain the text to be answered.
[0184] The topic-based dialogue response method can further include outputting the response speech through the virtual voice assistant of the game application. For example, the terminal device can use Text-to-Speech (TTS) technology to enable the terminal device to output the response speech through the virtual voice assistant, realizing voice interaction between the user and the virtual voice assistant. For instance, a TTS model can be trained to convert the response text into the corresponding response speech.
[0185] In this way, users can interact with virtual voice assistants in game scenarios, and the output voice responses are generated based on higher quality text responses, which can further meet users' actual needs and improve their user experience.
[0186] As an example, see Figure 6This figure is a flowchart illustrating a specific topic-based dialogue response method provided in this application embodiment. The method involves: collecting user-input voice data to obtain the voice to be responded to; detecting the activity of the voice to be responded to using VAD technology; and then converting the voice to be responded to into the text to be responded to using ASR technology (i.e., S201 described above); identifying the target topic using a topic recognition model to identify the topic of the text to be responded to (i.e., S202 described above); subsequently, performing a memory lookup based on the target topic to obtain the related topic and related dialogue text (i.e., S203 described above); merging the text to be responded to, the related dialogue text, and the preset prompt text into a question-and-answer model (e.g., a large language model); and outputting the response text corresponding to the text to be responded to (i.e., S204 described above); finally, converting the response text into a response voice using TTS technology and outputting it.
[0187] In addition, historical dialogue texts can be summarized to compress them (see the above description of the two optional implementation methods for summarizing historical dialogue texts).
[0188] It should be noted that the above-mentioned Figure 6 The relevant content refers to the content executed by the terminal device when the virtual voice assistant of the game application is running, which is the online part.
[0189] Next, we will continue to introduce Figure 6 The offline portion shown refers to the steps that can be pre-executed when the virtual voice assistant in the game application is not running. For example, various models can be trained, including training the ASR model, training the topic recognition model, corrective training for the topic recognition model, training the question answering model, and training the text summarization model (when it is a large model, corresponding prompt words can be set).
[0190] In some embodiments, the models described above can be different models trained separately.
[0191] In addition, in some embodiments, the models described above can also be a large language model, which is trained on a large language model through multi-task training so that it can realize the functions of the models described above.
[0192] For example, a large language model may include an ASR module, a topic recognition module, a memory module, a question-answering module, a TTS module, and a summary module. The ASR module, topic recognition module, question-answering module, TTS module, and summary module are respectively used to perform the tasks of the ASR model, topic recognition model, question-answering model, TTS model, and text summary model described above. The memory module can be used to perform steps S203, 1, and 2 described above, and the summary module can also be used to perform steps E1-E4 described above.
[0193] Based on the topic-based dialogue response method provided in the preceding embodiments, this application also provides a topic-based dialogue response device. The topic-based dialogue response device provided in this application will be described in detail below.
[0194] See Figure 7 This figure is a schematic diagram of the structure of a topic-based dialogue response device provided in an embodiment of this application. Figure 7 As shown, the topic-based dialogue response device 700 may specifically include:
[0195] The response text acquisition module 710 is used to acquire the response text input by the target object;
[0196] The topic determination module 720 is used to determine the target topic of the text to be responded to;
[0197] The associated dialogue text acquisition module 730 is used to acquire the associated dialogue text corresponding to the associated topic if an associated topic related to the target topic is determined from the historical topics of historical dialogue texts.
[0198] The response text generation module 740 is used to generate a response text corresponding to the text to be responded to based on the text to be responded to, the associated dialogue text, and the preset prompt text using a question-and-answer model; the preset prompt text is used to indicate that the text to be responded to is the current text to be responded to, and to indicate that the associated dialogue text is a historical dialogue text associated with the text to be responded to.
[0199] In one implementation, the historical dialogue text includes dialogue text from multiple rounds; the historical topics include at least one historical topic; the dialogue response device 700 based on related topics may further include:
[0200] The text summary module is used to generate a summary text for each historical topic if the sum of the text lengths of the historical dialogue texts corresponding to that topic exceeds a length threshold. The summary text is generated based on the dialogue texts of each round under that historical topic. The text length of the summary text is less than the text length of the dialogue texts of that round. The summary text is used to indicate the core content of the dialogue texts of that round.
[0201] The text replacement module is used to replace the dialogue text of each round under this historical topic with the corresponding summary text.
[0202] As one implementation method, the text summarization model is trained using the following units:
[0203] The first sample acquisition unit is used to acquire training dialogue text and training summary text corresponding to the training dialogue text; the training dialogue text includes the main text of the article text, and the training summary text includes the summary text of the article text.
[0204] The summary text generation unit is used to generate a predicted summary text corresponding to the training dialogue text based on the training dialogue text using the first model to be trained.
[0205] The first model training unit is used to construct a first loss function based on the predicted summary text and the training summary text, and to train the first model to be trained based on the first loss function to obtain the text summary model.
[0206] In one implementation, the historical dialogue text includes dialogue text from multiple rounds, each round including historical pending response text and historical reply text; the historical topics include at least one historical topic; the dialogue response device 700 based on related topics may further include:
[0207] The duplicate text determination module is used to determine duplicate texts among multiple historical unanswered texts under each historical topic if the sum of the text lengths of the historical dialogue texts corresponding to that historical topic exceeds a length threshold; the duplicate texts are at least two historical unanswered texts with a similarity exceeding a first threshold.
[0208] The text deletion module is used to delete the duplicate text and the historical reply text corresponding to each historical unanswered text in the duplicate text.
[0209] As one implementation method, the text deletion module may specifically include:
[0210] The time acquisition unit is used to acquire the response time corresponding to each historical unanswered text in the repeated text;
[0211] The text retention unit is used to retain the historical text awaiting response with the latest response time, and to retain the historical response text corresponding to the historical text awaiting response with the latest response time.
[0212] In one implementation, the target topic is obtained by performing topic recognition on the text to be answered using a topic recognition model; the topic recognition model is trained using the following units:
[0213] The second sample acquisition unit is used to acquire the training text to be answered and the training topic corresponding to the training text to be answered.
[0214] The first topic generation unit is used to generate a predicted topic corresponding to the training response text based on the training response text using the second training model.
[0215] The second model training unit is used to construct a second loss function based on the predicted topic corresponding to the training response text and the training topic, and to train the second training model based on the second loss function to obtain the topic recognition model.
[0216] As one implementation, the topic-based dialogue response device 700 may further include:
[0217] The third sample acquisition unit is used to acquire the text input when applying the topic recognition model as the text sample to be answered, and to acquire the text output when applying the topic recognition model as the topic tag;
[0218] The tag acquisition unit is used to acquire the correct topic tag corresponding to the text sample to be answered if the topic tag corresponding to the text sample to be answered does not match.
[0219] The second topic generation unit is used to generate a predicted topic corresponding to the text sample to be answered based on the text sample to be answered using the topic recognition model.
[0220] The third model training unit is used to construct a third loss function based on the predicted topic and the correct topic label corresponding to the text sample to be answered, and to train the topic recognition model based on the third loss function to obtain the latest topic recognition model, so as to perform topic recognition on the newly acquired text to be answered.
[0221] As one implementation method, the associated dialogue text acquisition module 730 may specifically include:
[0222] The first similarity calculation unit is used to calculate the first similarity between the historical topic and the target topic;
[0223] The associated topic determination unit is used to identify historical topics whose first similarity exceeds a second threshold as the associated topics.
[0224] The second similarity calculation unit is used to calculate the second similarity between the historical dialogue text corresponding to the associated topic and the text to be answered;
[0225] The associated dialogue text determination unit is used to identify historical dialogue texts whose second similarity exceeds a third threshold as the associated dialogue texts.
[0226] In one implementation, the historical topics are stored in a historical topic database; the historical dialogue texts are stored in a historical dialogue text database; the historical topics and the historical dialogue texts have a corresponding relationship; the dialogue response device 700 based on associated topics may further include:
[0227] The first storage and correspondence addition module is used to store the target topic in the historical topic database if the target topic is different from the associated topic; store the target dialogue text composed of the text to be answered and the text to be answered in the historical dialogue text database; and add a correspondence between the target topic and the target dialogue text.
[0228] The second storage and correspondence addition module is used to store the target dialogue text in the historical dialogue text database if there is a topic in the associated topics that is the same as the target topic; and to add a correspondence between the target topic and the target dialogue text.
[0229] As one implementation method, the question-answering model is trained using the following units:
[0230] The fourth sample acquisition unit is used to acquire the training sample to be answered, the associated dialogue training sample of the training sample to be answered, the prompt training sample, and the response training sample corresponding to the training sample to be answered.
[0231] The response text generation unit is used to generate a predicted response text for the training sample to be responded to based on the training sample to be responded to, the associated dialogue training sample of the training sample to be responded to, and the prompt training sample through a third training model to be trained; the prompt training sample is used to indicate that the training sample to be responded to is the current text to be responded to, and to indicate that the associated dialogue training sample is the historical dialogue text associated with the training sample to be responded to.
[0232] The fourth model training unit is used to construct a fourth loss function based on the predicted response text and the response training samples, and to train the third model to be trained based on the fourth loss function to obtain the question-answering model.
[0233] In one implementation, the text to be answered is related to the game application; the topic-based dialogue response device 700 may further include:
[0234] The voice acquisition module is used to acquire the voice to be answered input by the target object through the virtual voice assistant of the game application;
[0235] Accordingly, the unanswered text acquisition module 710 can be specifically used for:
[0236] Convert the voice to be answered into the text to be answered;
[0237] Accordingly, the topic-based dialogue response device 700 may further include:
[0238] A speech conversion module is used to convert the response text into a response speech;
[0239] The voice output module is used to output the response voice through the virtual voice assistant of the game application.
[0240] The topic-based dialogue response device provided in this application has the same beneficial effects as the topic-based dialogue response method provided in the above embodiments, and therefore will not be described again.
[0241] This application provides a topic-based dialogue response device, which can be a server. Figure 8 This is a schematic diagram of a server structure provided in an embodiment of this application. The server 900 can vary significantly due to different configurations or performance. It may include one or more central processing units (CPUs) 922 (e.g., one or more processors) and memory 932, and one or more storage media 930 (e.g., one or more mass storage devices) for storing application programs 942 or data 944. The memory 932 and storage media 930 can be temporary or persistent storage. The program stored in the storage media 930 may include one or more modules (not shown in the diagram), each module may include a series of instruction operations on the server. Furthermore, the CPU 922 may be configured to communicate with the storage media 930 and execute the series of instruction operations in the storage media 930 on the server 900.
[0242] Server 900 may also include one or more power supplies 926, one or more wired or wireless network interfaces 950, one or more input / output interfaces 958, and / or one or more operating systems 941, such as Windows Server. TM Mac OS X TM Unix TM Linux TM FreeBSD TM etc.
[0243] CPU 922 is used to perform the following steps:
[0244] Obtain the text to be answered from the target object;
[0245] The target topic of the text to be responded to is determined;
[0246] If a related topic is identified from the historical topics of the historical dialogue text that is related to the target topic, then the related dialogue text corresponding to the related topic is obtained.
[0247] Using a question-and-answer model, a response text is generated based on the text to be answered, the associated dialogue text, and a preset prompt text. The preset prompt text is used to indicate that the text to be answered is the current text to be answered, and to indicate that the associated dialogue text is a historical dialogue text associated with the text to be answered.
[0248] This application also provides another topic-based dialogue response device, which can be a terminal device. For example... Figure 9 As shown, for ease of explanation, only the parts related to the embodiments of this application are shown. For specific technical details not disclosed, please refer to the method section of the embodiments of this application. Taking a mobile phone as an example:
[0249] Figure 9 The diagram shown is a block diagram of a portion of the structure of a mobile phone provided in an embodiment of this application. (Reference) Figure 9 The mobile phone includes: a radio frequency (RF) circuit 1010, a memory 1020, an input unit 1030, a display unit 1040, a sensor 1050, an audio circuit 1060, a wireless fidelity (WiFi) module 1070, a processor 1080, and a power supply 1090, etc. Those skilled in the art will understand that... Figure 9 The mobile phone structure shown does not constitute a limitation on the mobile phone and may include more or fewer components than shown, or combine certain components, or have different component arrangements.
[0250] The following is combined Figure 9 A detailed introduction to each component of a mobile phone:
[0251] The RF circuit 1010 can be used for receiving and transmitting signals during information transmission or calls. Specifically, it receives downlink information from the base station and processes it with the processor 1080; additionally, it transmits uplink data to the base station. Typically, the RF circuit 1010 includes, but is not limited to, an antenna, at least one amplifier, a transceiver, a coupler, a low-noise amplifier (LNA), a duplexer, etc. Furthermore, the RF circuit 1010 can also communicate wirelessly with networks and other devices. The aforementioned wireless communications may use any communication standard or protocol, including but not limited to Global System for Mobile Communications (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Long Term Evolution (LTE), email, and Short Messaging Service (SMS).
[0252] The memory 1020 can be used to store software programs and modules. The processor 1080 executes various mobile phone functions and data processing by running the software programs and modules stored in the memory 1020. The memory 1020 may mainly include a program storage area and a data storage area. The program storage area may store the operating system, applications required for at least one function (such as sound playback function, image playback function, etc.), etc.; the data storage area may store data created according to the use of the mobile phone (such as audio data, phonebook, etc.). In addition, the memory 1020 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device.
[0253] The input unit 1030 can be used to receive input numerical or character information, and to generate key signal inputs related to user settings and function control of the mobile phone. Specifically, the input unit 1030 may include a touch panel 1031 and other input devices 1032. The touch panel 1031, also known as a touch screen, can collect touch operations performed by the user on or near it (such as operations performed by the user using a finger, stylus, or any suitable object or accessory on or near the touch panel 1031), and drive the corresponding connection devices according to a pre-set program. Optionally, the touch panel 1031 may include two parts: a touch detection device and a touch controller. The touch detection device detects the user's touch position and the signal generated by the touch operation, and transmits the signal to the touch controller; the touch controller receives touch information from the touch detection device, converts it into touch point coordinates, and sends it to the processor 1080, and can also receive and execute commands sent by the processor 1080. In addition, the touch panel 1031 can be implemented using various types such as resistive, capacitive, infrared, and surface acoustic wave. In addition to the touch panel 1031, the input unit 1030 may also include other input devices 1032. Specifically, other input devices 1032 may include, but are not limited to, one or more of the following: physical keyboard, function keys (such as volume control buttons, power buttons, etc.), trackball, mouse, joystick, etc.
[0254] The display unit 1040 can be used to display information input by the user or information provided to the user, as well as various menus of the mobile phone. The display unit 1040 may include a display panel 1041, which may optionally be configured as a Liquid Crystal Display (LCD), Organic Light-Emitting Diode (OLED), or similar display panel 1041. Further, a touch panel 1031 may cover the display panel 1041. When the touch panel 1031 detects a touch operation on or near it, it transmits the information to the processor 1080 to determine the type of touch event. Subsequently, the processor 1080 provides corresponding visual output on the display panel 1041 according to the type of touch event. Although in Figure 9 In this embodiment, the touch panel 1031 and the display panel 1041 are two separate components to realize the input and output functions of the mobile phone. However, in some embodiments, the touch panel 1031 and the display panel 1041 can be integrated to realize the input and output functions of the mobile phone.
[0255] The mobile phone may also include at least one sensor 1050, such as a light sensor, a motion sensor, and other sensors. Specifically, the light sensor may include an ambient light sensor and a proximity sensor. The ambient light sensor can adjust the brightness of the display panel 1041 according to the ambient light level, and the proximity sensor can turn off the display panel 1041 and / or the backlight when the phone is moved to the ear. As a type of motion sensor, an accelerometer sensor can detect the magnitude of acceleration in various directions (generally three axes). When stationary, it can detect the magnitude and direction of gravity and can be used for applications that recognize the phone's posture (such as landscape / portrait switching, related games, magnetometer posture calibration), vibration recognition-related functions (such as pedometer, taps), etc. Other sensors that may be configured in the mobile phone, such as gyroscopes, barometers, hygrometers, thermometers, and infrared sensors, will not be described in detail here.
[0256] The audio circuit 1060, speaker 1061, and microphone 1062 provide an audio interface between the user and the mobile phone. The audio circuit 1060 converts the received audio data into electrical signals and transmits them to the speaker 1061, where the speaker 1061 converts them into sound signals for output. On the other hand, the microphone 1062 converts the collected sound signals into electrical signals, which are then received by the audio circuit 1060, converted into audio data, and then processed by the processor 1080 before being transmitted via the RF circuit 1010 to, for example, another mobile phone, or the audio data can be output to the memory 1020 for further processing.
[0257] WiFi is a short-range wireless transmission technology. Through the WiFi module 1070, mobile phones can help users send and receive emails, browse web pages, and access streaming media, providing users with wireless broadband internet access. Although Figure 9 The WiFi module 1070 is shown, but it is understood that it is not an essential component of a mobile phone and can be omitted as needed without changing the essence of the invention.
[0258] The processor 1080 is the control center of the mobile phone, connecting various parts of the phone through various interfaces and lines. It executes software programs and / or modules stored in the memory 1020 and calls data stored in the memory 1020 to perform various functions and process data, thereby collecting overall data and information from the phone. Optionally, the processor 1080 may include one or more processing units; preferably, the processor 1080 may integrate an application processor and a modem processor, wherein the application processor mainly handles the operating system, user interface, and applications, and the modem processor mainly handles wireless communication. It is understood that the modem processor may not be integrated into the processor 1080.
[0259] The mobile phone also includes a power supply 1090 (such as a battery) that supplies power to various components. Preferably, the power supply can be logically connected to the processor 1080 through a power management system, thereby enabling functions such as charging, discharging, and power consumption management through the power management system.
[0260] Although not shown, mobile phones may also include a camera, Bluetooth module, etc., which will not be described in detail here.
[0261] In this embodiment of the application, the processor 1080 included in the mobile phone also has the following functions:
[0262] Obtain the text to be answered from the target object;
[0263] The target topic of the text to be responded to is determined;
[0264] If a related topic is identified from the historical topics of the historical dialogue texts that is related to the target topic, then the related dialogue text corresponding to the related topic is obtained.
[0265] Using a question-and-answer model, a response text is generated based on the text to be answered, the associated dialogue text, and a preset prompt text. The preset prompt text is used to indicate that the text to be answered is the current text to be answered, and to indicate that the associated dialogue text is a historical dialogue text associated with the text to be answered.
[0266] This application also provides a computer-readable storage medium for storing a computer program that, when run on a topic-based dialogue response device, causes the topic-based dialogue response device to perform any one of the implementation methods of the topic-based dialogue response method described in the foregoing embodiments.
[0267] This application also provides a computer program product including a computer program, which, when run on a topic-based dialogue response device, causes the topic-based dialogue response device to perform any one of the implementation methods of a topic-based dialogue response method described in the foregoing embodiments.
[0268] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working process of the system and equipment described above can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0269] In the several embodiments provided in this application, it should be understood that the disclosed systems and methods can be implemented in other ways. For example, the system embodiments described above are merely illustrative. For instance, the division of the system is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple systems may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interfaces, devices, or units, and may be electrical, mechanical, or other forms.
[0270] The system described as separate components may or may not be physically separate. Components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment, depending on actual needs.
[0271] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0272] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes: USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, optical disks, and other media capable of storing computer programs.
[0273] In this application embodiment, the terms "module" or "unit" refer to a computer program or part of a computer program that has a predetermined function and works with other related parts to achieve a predetermined goal, and can be implemented wholly or partially using software, hardware (such as processing circuitry or memory), or a combination thereof. Similarly, a processor (or multiple processors or memory) can be used to implement one or more modules or units. Furthermore, each module or unit can be part of an overall module or unit that includes the functionality of that module or unit.
[0274] The above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application.
Claims
1. A dialogue response method based on related topics, characterized in that, include: Obtain the text to be answered from the target object; The target topic of the text to be responded to is determined; If a related topic is identified from the historical topics of the historical dialogue text that is related to the target topic, then the related dialogue text corresponding to the related topic is obtained. Using a question-and-answer model, a response text is generated based on the text to be answered, the associated dialogue text, and a preset prompt text. The preset prompt text is used to indicate that the text to be answered is the current text to be answered, and to indicate that the associated dialogue text is a historical dialogue text associated with the text to be answered.
2. The method according to claim 1, characterized in that, The historical dialogue text includes dialogue text from multiple rounds; the historical topic includes at least one historical topic; the method further includes: For each historical topic, if the sum of the text lengths of the historical dialogue texts corresponding to that historical topic exceeds a length threshold, a summary text corresponding to the dialogue text of that round is generated based on the dialogue text of each round under that historical topic using a text summary model; the text length of the summary text is less than the text length of the dialogue text of that round; the summary text is used to indicate the core content of the dialogue text of that round. For each round of dialogue text under this historical theme, replace the dialogue text of that round with the corresponding summary text.
3. The method according to claim 2, characterized in that, The text summarization model is trained through the following steps: Obtain the training dialogue text and the corresponding training summary text; the training dialogue text includes the main text of the article text, and the training summary text includes the abstract text of the article text. Using the first model to be trained, a predicted summary text corresponding to the training dialogue text is generated based on the training dialogue text. Based on the predicted summary text and the training summary text, a first loss function is constructed, and based on the first loss function, the first model to be trained is trained to obtain the text summary model.
4. The method according to claim 1, characterized in that, The historical dialogue text includes dialogue text from multiple rounds, and each round's dialogue text includes historical pending response text and historical reply text; the historical topics include at least one historical topic; the method further includes: For each historical topic, if the sum of the text lengths of the historical dialogue texts corresponding to that historical topic exceeds a length threshold, then duplicate texts among multiple historical texts awaiting response under that historical topic are identified; the duplicate texts are at least two historical texts awaiting response whose similarity exceeds a first threshold. The duplicate text and the corresponding historical response texts for each historical unanswered text in the duplicate text are deleted.
5. The method according to claim 4, characterized in that, The step of deleting the duplicate text and the corresponding historical response texts for each historical unanswered text in the duplicate text includes: Obtain the response time corresponding to each historical unanswered text in the repeated text; The text of the pending response with the latest response time is retained, as well as the text of the historical response corresponding to the pending response with the latest response time.
6. The method according to claim 1, characterized in that, The target topic is obtained by performing topic recognition on the text to be answered using a topic recognition model; the topic recognition model is trained through the following steps: Obtain the training response text and the training topic corresponding to the training response text; Using the second model to be trained, a predicted topic corresponding to the training text to be answered is generated based on the training text to be answered. Based on the predicted topic corresponding to the training text to be answered and the training topic, a second loss function is constructed, and based on the second loss function, the second training model is trained to obtain the topic recognition model.
7. The method according to claim 6, characterized in that, The method further includes: The text input when applying the topic recognition model is obtained as the text sample to be answered, and the text output when applying the topic recognition model is obtained as the topic tag; If the topic tag corresponding to the text sample to be answered does not match, then the correct topic tag corresponding to the text sample to be answered is obtained; Based on the text sample to be answered, the topic recognition model generates a predicted topic corresponding to the text sample to be answered. Based on the predicted topic corresponding to the text sample to be answered and the correct topic label, a third loss function is constructed, and the topic recognition model is trained based on the third loss function to obtain the latest topic recognition model, so as to perform topic recognition on the newly acquired text to be answered.
8. The method according to any one of claims 1-7, characterized in that, The step of determining, from the historical topics of historical dialogue texts, a related topic related to the target topic, and then obtaining the related dialogue text corresponding to the related topic, includes: Calculate the first similarity between the historical topic and the target topic; Historical topics whose first similarity exceeds the second threshold are considered as the associated topics; Calculate the second similarity between the historical dialogue text corresponding to the associated topic and the text to be answered; Historical dialogue texts whose second similarity exceeds the third threshold are considered as the associated dialogue texts.
9. The method according to any one of claims 1-7, characterized in that, The historical topics are stored in a historical topic database; the historical dialogue texts are stored in a historical dialogue text database; the historical topics and the historical dialogue texts have a corresponding relationship; the method further includes: If the target topic is different from the associated topic, then the target topic is stored in the historical topic database; the target dialogue text consisting of the text to be answered and the text to be answered is stored in the historical dialogue text database; a correspondence is added between the target topic and the target dialogue text. If a topic identical to the target topic exists in the associated topics, the target dialogue text is stored in the historical dialogue text database; a correspondence is added between the target topic and the target dialogue text.
10. The method according to any one of claims 1-7, characterized in that, The question-answering model is trained through the following steps: Obtain the training sample to be answered, the associated dialogue training sample of the training sample to be answered, the prompt training sample, and the response training sample corresponding to the training sample to be answered; Using the third training model, a predicted response text for the training sample to be responded to is generated based on the training sample to be responded to, the associated dialogue training sample to be responded to, and the prompt training sample. The prompt training sample is used to prompt that the training sample to be responded to is the current text to be responded to, and to prompt that the associated dialogue training sample is the historical dialogue text associated with the training sample to be responded to; Based on the predicted response text and the response training samples, a fourth loss function is constructed, and based on the fourth loss function, the third model to be trained is trained to obtain the question-answering model.
11. The method according to any one of claims 1-7, characterized in that, The text to be answered is related to the game application; the method further includes: The virtual voice assistant of the game application is used to obtain the voice input to be answered by the target object; The step of obtaining the text to be answered input by the target object includes: Convert the voice to be answered into the text to be answered; The method further includes: Convert the reply text into a reply voice; The response voice is output through the virtual voice assistant of the game application.
12. A dialogue response device based on related topics, characterized in that, include: The module for obtaining the text to be answered is used to obtain the text to be answered input by the target object; The topic determination module is used to determine the target topic of the text to be responded to; The associated dialogue text acquisition module is used to acquire the associated dialogue text corresponding to the associated topic if an associated topic related to the target topic is determined from the historical topics of historical dialogue texts. The response text generation module is used to generate a response text corresponding to the text to be responded to based on the text to be responded to, the associated dialogue text, and the preset prompt text using a question-and-answer model. The preset prompt text is used to indicate that the text to be responded to is the current text to be responded to, and to indicate that the associated dialogue text is a historical dialogue text associated with the text to be responded to.
13. A dialogue response device based on related topics, characterized in that, The device includes a processor and a memory: The memory is used to store computer programs and to transfer the computer programs to the processor; The processor is configured to execute the steps of the topic-based dialogue response method according to any one of claims 1 to 11, as specified in the computer program.
14. A computer-readable storage medium, characterized in that, The computer-readable storage medium is used to store a computer program that, when executed by a topic-based dialogue response device, implements the steps of the topic-based dialogue response method according to any one of claims 1 to 11.
15. A computer program product, characterized in that, It includes a computer program that, when executed by a topic-based dialogue response device, implements the steps of the topic-based dialogue response method according to any one of claims 1 to 11.