Generating dialogue content, apparatus, device and computer storage medium
By filtering keywords in the current dialogue and combining them with the candidate word weights from historical dialogues, the system predicts the content to be generated, thus solving the problem of poor dialogue accuracy caused by noise in historical dialogues and improving the quality and efficiency of dialogue.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- ALIBABA INNOVATION PRIVATE LIMITED
- Filing Date
- 2021-07-12
- Publication Date
- 2026-05-15
AI Technical Summary
In existing technologies, the presence of a large amount of noise in historical dialogues leads to poor accuracy, low efficiency, and difficulty in generating high-quality responses.
By filtering keywords in the current conversation and determining their weights, and combining the weights of candidate words in historical conversations, the system predicts the content to be generated, taking into account the context of both the current and historical conversations.
It improved the accuracy and quality of the dialogue, reduced the impact of noise, and enhanced the overall effectiveness of the dialogue.
Smart Images

Figure CN115617958B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of electronic information technology, and in particular to the generation of dialogue content, apparatus, devices, and computer storage media. Background Technology
[0002] With the development of electronic information technology, more and more tasks can be accomplished using neural network models. For example, in intelligent dialogue scenarios, neural network models can be used to engage in intelligent conversations with users and answer their questions. In related technologies, historical dialogues are often used as a reference to generate responses. However, because historical dialogues contain a lot of noise, high-quality responses cannot be generated, resulting in poor dialogue accuracy and low efficiency. Summary of the Invention
[0003] In view of the above, embodiments of this application provide a dialog content generation apparatus, device, and computer storage medium to solve some or all of the above problems.
[0004] According to a first aspect of the embodiments of this application, a method for generating dialogue content is provided, comprising: obtaining historical dialogues related to the dialogue content based on the dialogue content of the current dialogue; obtaining at least one keyword in the historical dialogues and determining the weight corresponding to each keyword; obtaining at least one candidate word based on the dialogue content of the current dialogue and determining the weight corresponding to each candidate word; and predicting the content to be generated in the current dialogue based on at least one keyword and its corresponding weight, and at least one candidate word and its corresponding weight.
[0005] According to a second aspect of the embodiments of this application, a dialogue content generation apparatus is provided, comprising: an acquisition module, configured to acquire historical dialogues related to the dialogue content of the current dialogue; a first weighting module, configured to acquire at least one keyword in the historical dialogues and determine the weight corresponding to each keyword; a second weighting module, configured to acquire at least one candidate word according to the dialogue content of the current dialogue and determine the weight corresponding to each candidate word; and a prediction module, configured to predict the content to be generated in the current dialogue according to at least one keyword and its corresponding weight, and at least one candidate word and its corresponding weight.
[0006] According to a third aspect of the embodiments of this application, an electronic device is provided, including: a processor, a memory, a communication interface, and a communication bus, wherein the processor, the memory, and the communication interface communicate with each other through the communication bus; the memory is used to store at least one executable instruction, which causes the processor to perform an operation corresponding to the generation of dialogue content as described in the first aspect.
[0007] According to a fourth aspect of the embodiments of this application, a computer storage medium is provided, on which a computer program is stored, which, when executed by a processor, implements the generation of dialogue content as described in the first aspect.
[0008] The dialogue content generation apparatus, device, and computer storage medium provided in this application embodiment obtain historical dialogues related to the current dialogue content; obtain at least one keyword from the historical dialogues and determine the weight corresponding to each keyword; obtain at least one candidate word based on the current dialogue content and determine the weight corresponding to each candidate word; and predict the content to be generated for the current dialogue based on the at least one keyword and its corresponding weight, and the at least one candidate word and its corresponding weight. By filtering keywords from historical dialogues, the influence of noise is reduced. Furthermore, by predicting the content to be generated for the current dialogue based on the weights of candidate words determined from the current dialogue and keywords determined from historical dialogues, the context of both the current and historical dialogues is comprehensively considered, thus improving the accuracy and quality of the dialogue. Attached Figure Description
[0009] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings.
[0010] Figure 1 A schematic diagram illustrating a scenario for generating dialogue content, provided in Embodiment 1 of this application;
[0011] Figure 2 A flowchart illustrating the generation of dialogue content provided in Embodiment 1 of this application;
[0012] Figure 3 An architecture diagram of a dialogue model provided in Embodiment 1 of this application;
[0013] Figure 4 This is a structural block diagram of a dialog content generation device provided in Embodiment 2 of this application;
[0014] Figure 5 This is a schematic diagram of the structure of an electronic device provided in Embodiment 3 of this application. Detailed Implementation
[0015] To enable those skilled in the art to better understand the technical solutions in the embodiments of this application, the technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art should fall within the protection scope of the embodiments of this application.
[0016] The specific implementation of the embodiments of this application will be further described below with reference to the accompanying drawings.
[0017] Example 1
[0018] This application provides a method for generating dialogue content, applied to electronic devices. For ease of understanding, the application scenario of the dialogue content generation method provided in this application is described below, with reference to... Figure 1 As shown, Figure 1 This is a schematic diagram of a scenario for generating dialogue content, provided in Embodiment 1 of this application. Figure 1 The scenario shown includes an electronic device 101, a user 102, and a cloud 103. The electronic device 101 may be a device that generates the dialogue content provided in Embodiment 1 of this application.
[0019] Electronic device 101 can be a terminal device such as a smartphone, tablet computer, or laptop computer, or a network device such as a server. This application does not limit the scope of the application.
[0020] Electronic device 101 can access a network, connect to the cloud 103 via the network, and exchange data. In this application, the network includes a local area network (LAN), a wide area network (WAN), and mobile communication networks, such as the World Wide Web (WWW), Long Term Evolution (LTE) networks, 2G networks, 3G networks, and 5G networks. Of course, this is only an illustrative example and does not mean that this application is limited to this.
[0021] The electronic device 101 can be equipped with a neural network model for dialogue (referred to as a dialogue model). Since the electronic device 101 can be a terminal device or a network device, the dialogue model can be located on the terminal or in the cloud. Users can engage in dialogue through human-computer interaction with the electronic device 101, or users can interact with other devices, which transmit the user's current dialogue to the electronic device 101. The electronic device 101 can input the current dialogue into the dialogue model, use the dialogue model to predict the next statement in response to the user, and in predicting the next statement, it can predict words and connect the predicted words to form the response statement. Figure 1 Predicted word 1, predicted word 2, up to predicted word N are shown. In the process of predicting words, electronic device 101 can determine at least one candidate word and its weight based on the current dialogue. Electronic device 101 can obtain historical dialogues from cloud 103, determine at least one keyword and its weight based on the historical dialogues, and determine the current predicted word from at least one candidate word and at least one keyword based on the weight of each word.
[0022] Combination Figure 1 The scenario shown illustrates in detail the generation of dialogue content provided in Embodiment 1 of this application. It should be noted that... Figure 1 This is merely one application scenario for generating dialogue content provided in Embodiment 1 of this application, and does not imply that the generation of such dialogue content must be applied to... Figure 1 Optionally, the dialogue content generation provided in this application embodiment can be applied to electronic devices, that is, the electronic device is the executing entity for generating the dialogue content provided in this application embodiment. The electronic device can be a terminal device such as a smartphone, tablet, or laptop, or a network device such as a server. (Refer to...) Figure 2 As shown, Figure 2 The flowchart for generating dialogue content provided in Embodiment 1 of this application includes the following steps:
[0023] Step 201: Based on the content of the current dialogue, obtain the historical dialogues related to the dialogue content.
[0024] The current dialogue can include the conversation between the user and the dialogue model (i.e., the neural network model used for the dialogue) within the current time period. The current time period can include the period from the moment the user and the dialogue model begin their conversation to the current moment. Here, the moment the conversation begins refers to the moment the conversation starts within a short period, such as the moment the user begins their conversation within a preset time period. Conversations that begin before the preset time period are not considered part of the current dialogue. Alternatively, the current time period can include the period from the current moment backwards by a preset time period, or the period from the moment before the preset time period to the current moment. For example, the preset time period could be 1 hour, in which case conversations from 1 hour ago would not be considered part of the current dialogue. Of course, this is just an example.
[0025] The current dialogue can include data from the user's current conversation with the dialogue model. Historical dialogues include historical data from the user's conversations with the dialogue model, which can include historical data from multiple conversations between users and the dialogue model. For example, in one application scenario, the current dialogue can be a feature representation of the current dialogue obtained by encoding the current dialogue. This feature representation can be a set of feature vectors. Encoding a single statement in the current dialogue yields a feature vector. Since the current dialogue contains multiple statements, encoding these multiple statements yields a set or feature matrix based on multiple feature vectors, which serves as the feature representation of the current dialogue. Similarly, historical dialogues can also be feature representations of historical dialogues obtained by encoding historical dialogues. Here, two examples illustrate how to encode the current dialogue and historical dialogues respectively:
[0026] Optionally, in the first example, encoding the dialogue content of the current dialogue to obtain a feature representation of the current dialogue includes: acquiring the current dialogue; encoding each statement in the dialogue content of the current dialogue to obtain a feature representation of at least one statement; and encoding the feature representation of the at least one statement to obtain a feature representation of the current dialogue. The feature representation of a statement may include its feature vector, and the feature representation of the current dialogue may include its feature matrix. In this example, the encoding method is a two-layer encoding: first, each statement is encoded to obtain its feature vector, and then the feature vectors of all statements in the current dialogue are encoded to obtain the feature matrix of the current dialogue. For example, a Gated Recurrent Unit (GRU) can be used to encode each statement in the current dialogue to obtain at least one corresponding feature vector, and then a Transformer model can be used to encode the at least one feature vector to obtain the feature matrix of the current dialogue. By using two-layer encoding to first encode each statement and extract its feature representation, reflecting the characteristics of each statement, and then encoding the features of each statement to obtain the feature representation of the current dialogue, the resulting feature representation of the current dialogue can more accurately reflect the characteristics of the current dialogue, improving the precision and accuracy of the encoding.
[0027] Optionally, in the second example, encoding the historical dialogue to obtain a feature representation of the historical dialogue includes: pairing at least two statements in the historical dialogue to form at least one question-and-answer pair, where each question-and-answer pair includes a question statement and an answer statement; encoding at least one question statement to obtain a feature representation of at least one question statement, and encoding at least one answer statement to obtain a feature representation of at least one answer statement. The feature representation of the historical dialogue includes the feature representation of at least one question statement and the feature representation of at least one answer statement. It should be noted that the feature representation of a question statement may include a feature vector of the question statement; similarly, the feature representation of an answer statement may include a feature vector of the answer statement. The feature representation of the historical dialogue may include a set formed based on the feature vectors of at least one question statement and the feature vectors of at least one answer statement; or, the feature representation of the historical dialogue may include: a feature matrix of at least one question statement formed based on the feature vectors of at least one question statement, and a feature matrix of at least one answer statement formed based on the feature vectors of at least one answer statement.
[0028] Furthermore, relevant statements can be filtered from historical dialogues based on the current dialogue, and the feature representation of the historical dialogue can be determined based on the feature representation of the relevant statements. Therefore, the feature representation of the historical dialogue includes a combination of feature representations of statements related to the current dialogue or a feature matrix, and relevant statements can be determined based on attention algorithms or cosine similarity. In this application, filtering relevant statements from historical dialogues can be done by extracting relevant statements and discarding irrelevant statements (other statements besides relevant statements) in the historical dialogue, or by setting the weight of irrelevant statements to 0. Optionally, the last statement of the current dialogue can be matched with at least one question statement in the historical dialogue, and the question statement that matches the last statement of the current dialogue and the answer statement corresponding to the question statement are taken as relevant statements; or the question statement that matches the last statement of the current dialogue can be determined, and the answer statement corresponding to the question statement is taken as relevant statements. In a specific implementation, the feature representation of the last statement of the current dialogue can be used to match the feature representation of at least one question statement to determine the relevant statements that match the last statement.
[0029] Of course, the above is just an example of how to obtain the current dialogue and the historical dialogue. The current dialogue and the historical dialogue can also be processed in other ways to obtain the current dialogue that can represent the characteristics of the current dialogue and the historical dialogue that can represent the characteristics of the historical dialogue.
[0030] Step 202: Obtain at least one keyword from the historical dialogues and determine the weight of each keyword.
[0031] Keywords are words selected from historical dialogues that match the current dialogue. Keywords also serve as candidates for predicting the content to be generated in the current dialogue. In this application, selecting keywords from historical dialogues can be done by extracting keywords. Optionally, in one embodiment, obtaining at least one keyword in historical dialogues and determining the weight corresponding to each keyword includes: determining at least one keyword and its probability value in historical dialogues; determining the probability value of at least one statement in historical dialogues based on the current dialogue; and calculating the weight of at least one keyword based on the probability values of at least one keyword and at least one statement. For example, for a target keyword, which can be any keyword, the probability value of the target keyword can be multiplied by the probability value of at least one statement to which it belongs, resulting in at least one product. The weight of the target keyword is then calculated based on this product. For instance, if statements A, B, and C in the historical dialogue all contain keyword a, the probability value of keyword a can be multiplied by the probability values of the three statements, resulting in three products. These three products are then summed or averaged to obtain the weight of keyword a. Of course, this is merely an illustrative example.
[0032] Further, in a specific example, determining the probability value of at least one statement in a historical dialogue based on the current dialogue includes: matching the last statement of the current dialogue with at least one question-and-answer pair in the historical dialogue; and determining the probability value of at least one statement in the historical dialogue based on the matching result. It should be noted that the probability value of each statement can be determined based on the matching degree between each question-and-answer pair in the historical dialogue and the last statement of the current dialogue; the higher the matching degree, the higher the probability value. It should also be noted that a question-and-answer pair can contain two statements: a question statement and an answer statement. The probability value of the two statements in the question-and-answer pair can be determined by matching the question statement with the last statement of the current dialogue and then using the matching degree; or, the probability value of the answer statement in the question-and-answer pair can be determined based on the matching degree. Of course, it is also possible to match both the question statement and the answer statement with the last statement of the current dialogue and then use the matching degree to determine the probability value of the two statements in the question-and-answer pair; this is merely an illustrative example.
[0033] Step 203: Obtain at least one candidate word based on the dialogue content of the current dialogue, and determine the weight corresponding to each candidate word.
[0034] It should be noted that the preset vocabulary contains multiple words, and candidate words are words selected from the preset vocabulary that can be used to predict the content to be generated in the current dialogue. For example, candidate words can be words used for the current prediction with a probability exceeding a preset probability, or words in the preset vocabulary with a high probability of being used for the current prediction. Optionally, in one embodiment, obtaining at least one candidate word based on the dialogue content of the current dialogue and determining the weight corresponding to each candidate word includes: determining at least one candidate word in the preset vocabulary based on the feature representation of the current dialogue and the feature representation of the predicted content of the current dialogue, and determining the weight of at least one candidate word. It should be noted that the predicted content includes the content predicted when predicting the current response statement. For example, when generating the response statement using the dialogue model, one word is predicted each time, and the predicted words are then concatenated to form the response statement. The content to be generated in the current dialogue includes the currently predicted word. When determining the currently predicted word, it needs to be based on previously predicted content, which may include at least one word that has already been predicted. If the currently predicted word is the first word of the response statement, prediction is performed based on the initial (Start) value. Optionally, the Transformer model can be used to calculate the weights of each word in a pre-defined vocabulary based on the feature representations of the current dialogue and the predicted content. Words with weights greater than or equal to a pre-defined probability are then identified as candidate words. For example, the predicted content may include "initial value, y1, y2...y..." m-1 ” y m-1If the word is the previous predicted word, then when determining the candidate word for the m-th predicted word, it can be based on the already predicted "initial value, y1, y2...y". m-1 "These word feature representations, along with the current feature representation of the current dialogue, determine candidate words. Of course, this is just an example."
[0035] It should be noted that steps 202 and 203 do not have a necessary order; they can be executed one after the other or simultaneously.
[0036] Step 204: Based on at least one keyword and its corresponding weight, and at least one candidate word and its corresponding weight, predict the content to be generated in the current dialogue.
[0037] It should be noted that the content to be generated in the current dialogue may include the current predicted word. After determining the current predicted word, it is used as the predicted content in the next sentence of the current dialogue, and the prediction of the next word continues until a complete next sentence to reply to the user is generated. The predicted content includes multiple predicted words in the next sentence of the current dialogue. Here, two examples are given to illustrate the two methods of determining the current predicted word. Of course, these are just illustrative examples.
[0038] Optionally, in the first approach, the word with the highest weight among at least one candidate word and at least one keyword can be determined as the current predicted word. Since candidate words are determined based on the current dialogue and keywords are determined based on historical dialogue, determining the current predicted word from at least one candidate word and at least one keyword comprehensively considers the real-time nature of the current dialogue as well as the comprehensiveness and flexibility of historical dialogue, thus improving the quality of the dialogue.
[0039] Optionally, in the second approach, the method further includes: determining a probability vector based on the dialogue content of the current dialogue, historical dialogues, and the predicted content of the current dialogue, wherein the probability vector indicates the weight of a candidate word relative to a keyword when predicting the content to be generated in the current dialogue. Further optionally, predicting the content to be generated in the current dialogue based on at least one keyword and its corresponding weight, and at least one candidate word and its corresponding weight, includes: calculating the predicted probability of at least one candidate word based on the probability vector and the weight of at least one candidate word; calculating the predicted probability of at least one keyword based on the probability vector and the weight of at least one keyword; and predicting the content to be generated in the current dialogue based on at least one candidate word and its corresponding predicted probability, and at least one keyword and its corresponding predicted probability.
[0040] A probability vector is used to weight at least one candidate word and at least one keyword. In one implementation, the content to be generated in the current dialogue is predicted based on at least one candidate word and its corresponding predicted probability, and at least one keyword and its corresponding predicted probability. This includes determining the word with the highest predicted probability among at least one candidate word and at least one keyword as the current predicted word. Using a probability vector to weight each word (including candidate words and keywords) further improves the accuracy of the prediction. Here, a specific example illustrates how the probability vector is determined.
[0041] Alternatively, in one example,
[0042] Based on the content of the current dialogue, historical dialogues, and the predicted content of the current dialogue, a probability vector is determined, including: encoding the content of the current dialogue to obtain a feature representation of the current dialogue; encoding historical dialogues to obtain a feature representation of the historical dialogues; encoding the predicted content of the current dialogue to obtain a feature representation of the predicted content; performing a weighted operation on the feature representation of the current dialogue based on the feature representation of the predicted content to obtain a first matrix; performing a weighted operation on the feature representation of the predicted content to obtain a second matrix; and performing a weighted operation on the first matrix, the second matrix, and the feature representation of historical dialogues to obtain a probability vector.
[0043] Based on the description of steps 201-204 above, a specific scenario is given here to illustrate the generation of dialogue content. (Refer to...) Figure 3 As shown, Figure 3 This is a diagram of a dialogue model architecture provided in Embodiment 1 of this application. Figure 3 The dialogue model shown includes a current dialogue encoding module, a historical dialogue encoding module, a response statement encoding module, and a context-based decoding module. The user's dialogue statement is input into the dialogue model, and based on the data processing of each module, the model can generate the next statement to be replied to by the user in the current dialogue. When generating the next statement to be replied to by the dialogue model, one word in the next statement is predicted each time. Finally, the predicted words are concatenated according to the time sequence to obtain the next statement. Here, the architecture of the dialogue model is explained using the current predicted word for the next statement as an example.
[0044] The current dialogue encoding module is used to encode the current dialogue to obtain its feature representation. Specifically, the current dialogue encoding module includes a GRU and a Transformer model, using GRU to encode at least one statement "w" in the current dialogue. i1 w i2 ...w iL Encoding yields feature vectors "u1, u2, ... u" for at least one statement. LThe feature matrix O of the current dialogue is obtained by encoding the feature vector of at least one statement using the Transformer model. D .
[0045] The historical dialogue encoding module is used to encode historical dialogues to obtain feature representations of the historical dialogues. Specifically, the historical dialogue encoding module includes two GRUs, which are used to encode question statements and answer statements respectively. The first GRU is used to encode question statements to obtain feature vectors "uc1, uc2...uc1" for at least one question statement. N The second GRU is used to encode the response statement to obtain the feature vector "us1, us2...us" of at least one response statement. N "Based on the feature vector U of the last statement in the current dialogue" L Matching the feature vectors of at least one question statement and at least one answer statement, and filtering out the feature vector U that matches the last statement in the current dialogue. L The feature vectors of the matched relevant statements are used to obtain the feature matrix O of the query statement. C and the feature matrix O of the answer statement S The feature representation of historical dialogues includes the feature matrix of question statements and the feature matrix of answer statements.
[0046] The response statement encoding module is used to encode the predicted content "y1, y2...y" in the current response statement. M Encode the predicted content to obtain feature vectors, and form a feature matrix O. R .
[0047] The context-based decoding module utilizes the Transformer model to process the feature matrix O of the current dialogue. D and the feature matrix O of the predicted content R A weighted operation is performed to determine at least one candidate word and its weight, resulting in a first matrix O. t G Furthermore, the copy module can extract at least one keyword from historical dialogues and determine its probability value. The probability value of the keyword is then calculated by combining it with the probability value of at least one statement in the historical dialogue to obtain the weight of that keyword. The context-based decoding module can also calculate a probability vector; specifically, it can process the feature matrix O of the predicted content. R The second matrix O is obtained by performing weighted operations. t R According to the first matrix O t G Second matrix O t R And the feature matrix O of the question statementC and the feature matrix O of the answer statement S A weighted operation is performed to obtain a probability vector g. The probability vector g is then operated on with the weights of at least one candidate word to obtain the predicted probability of at least one candidate word. The vector (1-g) is then operated on with the weights of at least one keyword to obtain the predicted probability of at least one keyword. The word with the highest predicted probability among at least one candidate word and at least one keyword is determined as the current predicted word. Then, the prediction of the next word continues until a complete response statement is obtained.
[0048] The dialogue content generation provided in this application embodiment filters keywords from historical dialogues based on the current dialogue, reducing the impact of noise. Furthermore, it determines the current predicted word based on weights among candidate words determined based on the current dialogue and keywords determined based on historical dialogues, comprehensively considering the context of the current and historical dialogues, thereby improving the accuracy and quality of the dialogue.
[0049] Example 2
[0050] Based on the method described in Embodiment 1 above, Embodiment 2 of this application provides a dialog content generation apparatus for executing the method described in Embodiment 1 above, referring to... Figure 4 As shown, the dialogue content generation device 40 includes:
[0051] The acquisition module 401 is used to obtain historical dialogues related to the dialogue content of the current dialogue.
[0052] The first weighting module 402 is used to obtain at least one keyword in the historical dialogue and determine the weight corresponding to each keyword;
[0053] The second weighting module 403 is used to obtain at least one candidate word based on the dialogue content of the current dialogue and to determine the weight corresponding to each candidate word.
[0054] The prediction module 404 is used to predict the content to be generated in the current dialogue based on at least one keyword and its corresponding weight, and at least one candidate word and its corresponding weight.
[0055] Optionally, in one embodiment of this application, the prediction module 404 is further configured to determine a probability vector based on the dialogue content of the current dialogue, historical dialogues, and the predicted content of the current dialogue. The probability vector is used to indicate the weight of candidate words relative to keywords when predicting the content to be generated in the current dialogue.
[0056] Optionally, in one embodiment of this application, the prediction module 404 is configured to calculate the predicted probability of at least one candidate word based on the probability vector and the weight of at least one candidate word; calculate the predicted probability of at least one keyword based on the probability vector and the weight of at least one keyword; and predict the content to be generated in the current dialogue based on at least one candidate word and its corresponding predicted probability, and at least one keyword and its corresponding predicted probability.
[0057] Optionally, in one embodiment of this application, the prediction module 404 is used to encode the dialogue content of the current dialogue to obtain a feature representation of the current dialogue; encode the historical dialogue to obtain a feature representation of the historical dialogue; encode the predicted content of the current dialogue to obtain a feature representation of the predicted content; perform a weighted operation on the feature representation of the current dialogue based on the feature representation of the predicted content to obtain a first matrix; perform a weighted operation on the feature representation of the predicted content to obtain a second matrix; and perform a weighted operation on the first matrix, the second matrix, and the feature representation of the historical dialogue to obtain a probability vector.
[0058] Optionally, in one embodiment of this application, the prediction module 404 is used to encode each statement in the dialogue content of the current dialogue to obtain a feature representation of at least one statement; and to encode the feature representation of at least one statement to obtain a feature representation of the current dialogue.
[0059] Optionally, in one embodiment of this application, the second weighting module 403 is used to determine at least one candidate word in a preset word library based on the feature representation of the current dialogue and the feature representation of the predicted content of the current dialogue, and to determine the weight of the at least one candidate word.
[0060] Optionally, in one embodiment of this application, the prediction module 404 is used to pair at least two statements contained in the historical dialogue to form at least one question-answer pair, wherein a question-answer pair includes a question statement and an answer statement; to encode at least one question statement to obtain a feature representation of at least one question statement, and to encode at least one answer statement to obtain a feature representation of at least one answer statement, wherein the feature representation of the historical dialogue includes the feature representation of at least one question statement and the feature representation of at least one answer statement.
[0061] Optionally, in one embodiment of this application, the first weighting module 402 is configured to determine at least one keyword and the probability value of at least one keyword in the historical dialogue; determine the probability value of at least one statement in the historical dialogue based on the current dialogue; and calculate the weight of at least one keyword based on the probability values of at least one keyword and at least one statement.
[0062] Optionally, in one embodiment of this application, the first weighting module 402 is used to match the last statement of the current dialogue with at least one question-answer pair in the historical dialogue; and determine the probability value of at least one statement in the historical dialogue based on the matching result.
[0063] The dialogue content generation device provided in this application provides that filters out keywords from historical dialogues, reducing the impact of noise. Furthermore, it predicts the content to be generated for the current dialogue based on the weights of candidate words determined based on the current dialogue and keywords determined based on historical dialogues. This comprehensively considers the context of the current dialogue and historical dialogues, thereby improving the accuracy and quality of the dialogue.
[0064] Example 3
[0065] Based on the method described in Embodiment 1 above, Embodiment 3 of this application provides an electronic device for executing the method described in Embodiment 1 above, with reference to... Figure 5 As shown, Figure 5 This is a schematic diagram of the structure of an electronic device provided in Embodiment 3 of this application. The specific embodiments of this application do not limit the specific implementation of the electronic device.
[0066] like Figure 5 As shown, the electronic device may include: a processor 502, a communications interface 504, a memory 506, and a communications bus 508.
[0067] in:
[0068] The processor 502, communication interface 504, and memory 506 communicate with each other via communication bus 508.
[0069] Communication interface 504 is used to communicate with other electronic devices such as terminal devices or servers.
[0070] The processor 502 is used to execute program 510, specifically the relevant steps in the above method embodiments.
[0071] Specifically, program 510 may include program code that includes computer operation instructions.
[0072] Processor 502 may be a central processing unit (CPU), an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of this application. The electronic device includes one or more processors, which may be processors of the same type, such as one or more CPUs; or they may be processors of different types, such as one or more CPUs and one or more ASICs.
[0073] Memory 506 is used to store program 510. Memory 506 may include high-speed RAM memory, and may also include non-volatile memory, such as at least one disk storage device.
[0074] Specifically, program 510 can be used to cause processor 502 to execute any of the methods in the aforementioned embodiment 1.
[0075] The specific implementation of each step in program 510 can be found in the corresponding steps and units described in the above-mentioned embodiment of generating dialogue content, and will not be repeated here. Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working process of the devices and modules described above can be referred to the corresponding process descriptions in the foregoing method embodiments, and will not be repeated here.
[0076] The electronic device provided in this application provides that filters keywords from historical dialogues, reducing the impact of noise. Furthermore, it predicts the content to be generated in the current dialogue based on the weights of candidate words determined from the current dialogue and keywords determined from historical dialogues, comprehensively considering the context of the current and historical dialogues, thereby improving the accuracy and quality of the dialogue.
[0077] Example 4
[0078] Based on the method described in Embodiment 1 above, Embodiment 4 of this application provides a computer storage medium storing a computer program thereon, which, when executed by a processor, implements the method described in Embodiment 1.
[0079] It should be noted that, depending on the implementation needs, the various components / steps described in the embodiments of this application can be broken down into more components / steps, or two or more components / steps or parts of the operation of components / steps can be combined into new components / steps to achieve the purpose of the embodiments of this application.
[0080] The methods described in the embodiments of this application can be implemented in hardware, firmware, or as software or computer code that can be stored in a recording medium (such as a CD-ROM, RAM, floppy disk, hard disk, or magneto-optical disk), or as computer code downloaded over a network that is originally stored in a remote recording medium or a non-transitory machine-readable medium and will be stored in a local recording medium. Thus, the methods described herein can be stored as software processing on a recording medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware (such as an ASIC or FPGA). It is understood that the computer, processor, microprocessor controller, or programmable hardware includes storage components (e.g., RAM, ROM, flash memory, etc.) capable of storing or receiving software or computer code. When the software or computer code is accessed and executed by the computer, processor, or hardware, the generation of the dialogue content described herein is implemented. Furthermore, when a general-purpose computer accesses the code used to implement the generation of the dialogue content shown herein, the execution of the code transforms the general-purpose computer into a dedicated computer for performing the generation of the dialogue content shown herein.
[0081] Those skilled in the art will recognize that the units and method steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the embodiments of this application.
[0082] The above embodiments are only used to illustrate the embodiments of this application, and are not intended to limit the embodiments of this application. Those skilled in the art can make various changes and modifications without departing from the spirit and scope of the embodiments of this application. Therefore, all equivalent technical solutions also fall within the scope of the embodiments of this application, and the patent protection scope of the embodiments of this application should be defined by the claims.
Claims
1. A method for generating dialogue content, comprising: Based on the content of the current conversation, obtain the historical conversations related to the current conversation content; Obtain at least one keyword from the historical dialogue and determine the weight corresponding to each keyword; At least one candidate word is obtained based on the content of the current dialogue, and the weight corresponding to each candidate word is determined. Based on the probability vector, the at least one keyword and its corresponding weight, and the at least one candidate word and its corresponding weight, the content to be generated in the current dialogue is predicted, wherein the probability vector is used to indicate the weight of the candidate word relative to the keyword when predicting the content to be generated in the current dialogue.
2. The method according to claim 1, further comprising: The probability vector is determined based on the content of the current dialogue, the historical dialogues, and the predicted content of the current dialogue.
3. The method according to claim 2, wherein, The step of predicting the content to be generated in the current dialogue based on the probability vector, the at least one keyword and its corresponding weight, and the at least one candidate word and its corresponding weight includes: The predicted probability of the at least one candidate word is calculated based on the probability vector and the weight of the at least one candidate word. The predicted probability of the at least one keyword is calculated based on the probability vector and the weight of the at least one keyword. Based on the at least one candidate word and its corresponding prediction probability, and the at least one keyword and its corresponding prediction probability, predict the content to be generated in the current dialogue.
4. The method according to claim 2, wherein, Based on the content of the current dialogue, the historical dialogues, and the predicted content of the current dialogue, a probability vector is determined, including: The content of the current dialogue is encoded to obtain a feature representation of the current dialogue; The historical dialogue is encoded to obtain a feature representation of the historical dialogue; The predicted content of the current dialogue is encoded to obtain a feature representation of the predicted content; a first matrix is obtained by weighting the feature representation of the current dialogue based on the feature representation of the predicted content. The second matrix is obtained by weighting the feature representations of the predicted content; The probability vector is obtained by weighting the first matrix, the second matrix, and the feature representation of the historical dialogue.
5. The method according to claim 4, wherein, The process of encoding the dialogue content of the current dialogue to obtain a feature representation of the current dialogue includes: Each statement in the current dialogue is encoded to obtain a feature representation of at least one statement; the feature representation of the at least one statement is then encoded to obtain a feature representation of the current dialogue.
6. The method according to claim 5, wherein, The step of obtaining at least one candidate word based on the dialogue content of the current dialogue and determining the weight corresponding to each candidate word includes: determining the at least one candidate word in a preset word library based on the feature representation of the current dialogue and the feature representation of the predicted content of the current dialogue, and determining the weight of the at least one candidate word.
7. The method according to claim 4, wherein, The process of encoding the historical dialogue to obtain a feature representation of the historical dialogue includes: The historical dialogue contains at least two statements that are paired together to form at least one question-and-answer pair, and a question-and-answer pair includes a question statement and an answer statement; The feature representation of the at least one question statement is obtained by encoding the at least one question statement, and the feature representation of the at least one answer statement is obtained by encoding the at least one answer statement. The feature representation of the historical dialogue includes the feature representation of the at least one question statement and the feature representation of the at least one answer statement.
8. The method according to claim 7, wherein, The process of obtaining at least one keyword from the historical dialogue and determining the weight corresponding to each keyword includes: Identify at least one keyword in the historical dialogue, and the probability value of the at least one keyword; Determine the probability value of at least one statement in the historical dialogue based on the current dialogue; The weight of the at least one keyword is calculated based on the probability value of the at least one keyword and the probability value of the at least one statement.
9. The method according to claim 8, wherein, Determining the probability value of at least one statement in the historical dialogue based on the current dialogue includes: Match the last statement of the current conversation with at least one question-and-answer pair in the historical conversation; The probability value of at least one statement in the historical dialogue is determined based on the matching results.
10. A device for generating dialogue content, comprising: The acquisition module is used to obtain historical dialogues related to the current dialogue content. The first weighting module is used to obtain at least one keyword in the historical dialogue and determine the weight corresponding to each keyword; The second weighting module is used to obtain at least one candidate word based on the dialogue content of the current dialogue, and to determine the weight corresponding to each candidate word. A prediction module is configured to predict the content to be generated in the current dialogue based on a probability vector, the at least one keyword and its corresponding weight, and the at least one candidate word and its corresponding weight, wherein the probability vector is used to indicate the weight of the candidate word relative to the keyword when predicting the content to be generated in the current dialogue.
11. An electronic device, comprising: The processor, memory, communication interface, and communication bus are provided, wherein the processor, memory, and communication interface communicate with each other via the communication bus. The memory is used to store at least one executable instruction that causes the processor to perform an operation corresponding to the generation of dialogue content as described in any one of claims 1-9.
12. A computer storage medium having a computer program stored thereon, which, when executed by a processor, implements the generation of dialogue content as described in any one of claims 1-9.