Man-machine conversation method, device and electronic equipment
By extracting objects from the current user input and analyzing historical dialogue records, a response statement that is more relevant to the dialogue topic is generated. This solves the problems of fixed content and low matching degree in traditional human-computer dialogue and improves the user experience.
Patent Information
- Application Number
- CN202310158899.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-13
- Publication Date
- 2025-12-05
- Estimated Expiration
- 2043-02-13
AI Technical Summary
Traditional human-computer dialogue is based on question-answering databases, which results in a limited number of questions that the machine can answer, fixed response content, low flexibility, low matching degree with the user's dialogue content, and poor user experience.
By extracting the object from the current statement entered by the user and combining it with historical dialogue records to expand knowledge and generate statements, more flexible and topic-appropriate response statements are produced.
It improves the continuity of human-computer dialogue and the matching degree with user dialogue content, and the generated response statements are more in line with the user's real needs, thus improving the user experience.
Smart Images

Figure CN116246629B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application belongs to the technical field of human-computer conversation, and particularly relates to a human-computer conversation method and device and electronic equipment. BACKGROUND
[0002] Artificial intelligence technology has been widely applied to people's daily life, for example, some artificial intelligence technology is used in electronic devices such as smart phones, tablet computers and smart speakers used in daily life. Human-computer conversation (HMC) technology is a branch of artificial intelligence technology in the field of natural language processing (NLP), which mainly studies how machines use natural language to communicate with humans to realize human-computer communication. Human-computer conversation technology is a widely used technology, and common human-computer conversation technology application products include voice assistants, smart speakers and intelligent chat robots.
[0003] Traditional human-computer conversation is generally realized based on a question and answer library, that is, content matched with a user's statement in the question and answer library is searched as a reply to realize conversation with the user. Human-computer conversation based on the question and answer library will make the questions that can be answered by the machine very limited, and the content of the reply is often fixed, flexible, and has low matching degree with the user's conversation content, which is difficult to meet the real needs of the user, thus resulting in poor user experience. SUMMARY
[0004] Therefore, the embodiments of the present application provide a human-computer conversation method, device and electronic equipment, which can solve the problem of low matching degree of conversation content with the user in the human-computer conversation process.
[0005] The first aspect of the embodiments of the present application provides a human-computer conversation method applied to an electronic device, comprising:
[0006] Performing object extraction on a current statement input by a user to obtain a target object. The target object includes a target entity and / or a target keyword.
[0007] Obtaining a historical conversation record in a current conversation, wherein the historical conversation record contains a statement generated by the electronic device.
[0008] Generating a reply statement for the current statement based on the target object and the historical conversation record.
[0009] In a first possible implementation manner of the first aspect, generating a reply statement for the current statement based on the target object and the historical conversation record comprises:
[0010] The target object is knowledge expanded to obtain target data containing the target object. The target data contains attribute data of the target object.
[0011] According to the target data and the historical dialogue record, a reply sentence for the current sentence is generated.
[0012] In a second possible implementation of the first aspect, the knowledge expansion of the target object comprises:
[0013] The meaning item corresponding to the target object is found.
[0014] When the target object corresponds to multiple meaning items, the historical dialogue record is subjectively analyzed to determine the theme of the current dialogue.
[0015] From the multiple meaning items, the actual meaning item with the highest theme relevance is filtered out, and the attribute data of the target object under the actual meaning item is obtained.
[0016] In a third possible implementation of the first aspect, the knowledge expansion of the target object comprises:
[0017] The triple information of the target object is extracted. The triple information contains the attribute data of the target object.
[0018] According to the triple information, a plurality of knowledge description segments of the target object are generated, and the plurality of knowledge description segments are the target data. The knowledge description segment is a sentence containing the target object and the attribute data of the target object.
[0019] In a fourth possible implementation of the first aspect, after the plurality of knowledge description segments of the target object are generated, the method further comprises:
[0020] When the number of generated knowledge description segments is greater than a preset number threshold, the semantic similarity of each knowledge description segment with the current sentence is calculated.
[0021] From the plurality of knowledge description segments, the number threshold of knowledge description segments with the highest similarity is filtered out, and the filtered knowledge description segments are taken as the target data.
[0022] In a fifth possible implementation of the first aspect, after the reply sentence for the current sentence is generated based on the target object and the historical dialogue record, the method further comprises:
[0023] The target sentence is object extracted to obtain a historical object. The target sentence is the reply sentence for the current sentence, and the historical object contains entities and / or keywords.
[0024] The historical object is knowledge expanded to obtain historical data containing the historical object. The historical data contains attribute data of the historical object.
[0025] In a sixth possible implementation manner of the first aspect, the reply sentence for the current sentence is generated according to the target data and the historical dialogue record, including:
[0026] The historical data is obtained, and the reply sentence for the current sentence is generated based on the historical data, the target data and the historical dialogue record. The historical data is data obtained after knowledge expansion is performed on entities and / or keywords in the sentences generated by the electronic device.
[0027] The second aspect of the embodiment of the present application provides a human-computer dialogue device, including:
[0028] The object extraction module is configured to perform object extraction on the current sentence input by the user to obtain a target object, the target object including a target entity and / or a target keyword.
[0029] The record obtaining module is configured to obtain historical dialogue records in the current dialogue, the historical dialogue records including sentences generated by the human-computer dialogue device.
[0030] The sentence generation module is configured to generate a reply sentence for the current sentence based on the target object and the historical dialogue records.
[0031] The third aspect of the embodiment of the present application provides an electronic device, including a memory and a processor, the memory storing a computer program executable on the processor, and the processor executes the computer program to enable the electronic device to implement the steps of the human-computer dialogue method in any one of the above first aspect.
[0032] The fourth aspect of the embodiment of the present application provides a computer readable storage medium, including a computer program stored therein, and the computer program is executed by a processor to enable an electronic device to implement the steps of the human-computer dialogue method in any one of the above first aspect.
[0033] The fifth aspect of the embodiment of the present application provides a computer program product, when the computer program product is executed on an electronic device, the electronic device executes the human-computer dialogue method in any one of the above first aspect.
[0034] The sixth aspect of the embodiment of the present application provides a chip system, including a processor, the processor is coupled with a memory, and the processor executes a computer program stored in the memory to implement the human-computer dialogue method in any one of the above first aspect.
[0035] The chip system can be a single chip or a chip module composed of multiple chips.
[0036] Compared with the prior art, the embodiments of the present application have the beneficial effects that:
[0037] In the reply sentence generation, the embodiments of the present application not only consider the current sentence, but also comprehensively consider the historical user input sentences and the electronic device reply sentences. Therefore, the existing information is considered more comprehensively, and the explicit or implicit demand information of the user in the historical dialogue process can be comprehensively obtained. Based on these information, the generation of the reply sentence can greatly improve the relevance and continuity of the reply content and the real demand of the user, thereby improving the matching degree of the dialogue content with the user.
[0038] It can be understood that the beneficial effects of the above-mentioned second aspect to the sixth aspect can be referred to the related description in the first aspect, which will not be repeated here. BRIEF DESCRIPTION OF DRAWINGS
[0039] Figure 1 is a flowchart of a human-computer dialogue method provided by an embodiment of the present application;
[0040] Figure 2 is a scene diagram of marking sentences in a corpus provided by an embodiment of the present application;
[0041] Figure 3 is a flowchart of an ambiguity elimination method in knowledge expansion provided by an embodiment of the present application;
[0042] Figure 4 is a flowchart of knowledge expansion for a target object provided by an embodiment of the present application;
[0043] Figure 5A is a scene diagram of implementing semantic matching based on a large-scale pre-training model provided by an embodiment of the present application;
[0044] Figure 5B is a scene diagram of implementing semantic matching based on a semantic matching algorithm of a word vector provided by an embodiment of the present application;
[0045] Figure 5C is a scene diagram of generating a reply sentence based on a language model provided by an embodiment of the present application;
[0046] Figure 6 is a flowchart of a human-computer dialogue method provided by an embodiment of the present application;
[0047] Figure 7 is a structure diagram of a human-computer dialogue device provided by an embodiment of the present application;
[0048] Figure 8 is a structure diagram of an electronic device provided by an embodiment of the present application. DETAILED DESCRIPTION
[0049] In the following description, for purposes of explanation and not limitation, specific details are set forth such as particular architectures, techniques, etc. in order to provide a thorough understanding of the embodiments of the present application. However, it will be apparent to those skilled in the art that the present application can be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known methods, devices, circuits, and
[0050] The man-machine conversation method provided by the embodiments of the present application can be applied to electronic devices such as robots, mobile phones, tablet computers and wearable devices, and at this time, the electronic device is the execution subject of the man-machine conversation method provided by the embodiments of the present application, and the embodiments of the present application do not limit the specific type of the electronic device.
[0051] Traditional man-machine conversation is generally implemented based on a question and answer library, that is, some sentences are set in advance in the question and answer library as alternatives. In the process of conversation with the user, the electronic device searches the content matched with the user's sentence in the question and answer library as a reply to realize the conversation with the user. The man-machine conversation based on the question and answer library makes the questions that can be answered by the electronic device very limited, and the content of the answer is often fixed, the flexibility is low, and the matching degree of the conversation content with the user is low. Among them, the man-machine conversation in actual application is a behavior with certain continuity, that is, the user generally has a conversation around one or more topics in the process of man-machine conversation. In the process of man-machine conversation based on the question and answer library, the electronic device can only reply to the current input sentence of the user. Therefore, the continuity of the conversation content of the electronic device in the whole man-machine conversation process is poor. Therefore, the man-machine conversation based on the question and answer library has poor effect, it is difficult to meet the real needs of the user, and the user experience is often poor.
[0052] In order to improve the matching degree of the conversation content with the user in the process of man-machine conversation, in the embodiments of the present application, the electronic device first extracts the object from the current sentence of the user, so as to obtain the target object. Then, the target object and the existing historical conversation record in the current conversation are used as objects to perform text generation processing, so as to obtain the reply sentence for the current sentence.
[0053] In the embodiments of the present application, the knowledge description segment and the historical conversation record are both used as objects for text generation. Therefore, the analysis of the current sentence is realized, and the analysis of the historical user sentence and the reply sentence of the electronic device is combined. Therefore, the final reply sentence is not only more flexible, but also can better meet the conversation theme in the current conversation, so that the continuity of the man-machine conversation is better, and the matching degree of the conversation content with the user is higher.
[0054] In order to illustrate the technical solutions described in the present application, the following will be described through specific embodiments.
[0055] Figure 1 An implementation flowchart of the human-computer conversation method provided by Embodiment One of the present application is shown, and is described in detail as follows:
[0056] S101, it is identified whether the current conversation is ended. If not, S102 is executed.
[0057] In the actual human-computer conversation (hereinafter referred to as conversation) process, the electronic device is in a passive response state. In order to better cope with the user conversation demand, the embodiment of the present application will continuously monitor whether the current conversation is ended in the process of the conversation. When it is identified that the current conversation has ended, the historical conversation record in the current conversation can be selected to be emptied, and the conversation is ended. When it is identified that the current conversation is not ended, the subsequent steps of the embodiment of the present application are entered to continue to provide conversation service for the user.
[0058] Among them, the embodiment of the present application does not make too many limitations on the identification method of whether the current conversation is ended, which can be set by the technical personnel. For example, in some optional embodiments, a timer can be started to time after the user inputs a sentence or after the electronic device replies to the user's sentence. If the new sentence input by the user is not obtained when the timing duration reaches the preset duration threshold, it is determined that the current conversation is ended.
[0059] S102, the current sentence input by the user is obtained, and object extraction is performed on the current sentence to obtain a target object. The target object includes a target entity and / or a target keyword.
[0060] In practical applications, the user can realize the conversation with the electronic device by inputting text, voice or video and the like. Therefore, in the embodiment of the present application, the original input sentence of the user can be a text format sentence or an audio format sentence. In the embodiment of the present application, the non-text format sentence can also be converted into a text format sentence for processing.
[0061] The entities and keywords in the sentence are the core information data of the sentence. Therefore, after obtaining the current input sentence (i.e., the current sentence) of the user, the embodiment of the present application first extracts the object from the current sentence. That is, the current sentence is subjected to entity recognition and keyword extraction, so as to obtain the corresponding target object. According to different actual recognition and extraction conditions, the target object can contain the recognized entity (i.e., the target entity) and / or the keyword (i.e., the target keyword). Among them, the method of object extraction is not limited too much in the embodiment of the present application, which can be set by the technician. For example, common recognition algorithms such as HMM, CRF, BiLSTM or BiLSTM plus CRF can be used, and recognition models based on BERT, ALBERT or BERT plus CRF with better effect can also be used. Taking an example for illustration, assuming that the current sentence is "I like to listen to the song of Chengdu", at this time, the target entity "Chengdu" can be extracted by object extraction.
[0062] As an optional embodiment of the present application, in order to realize object extraction, a pre-training model based on BERT, ALBERT or BERT plus CRF can be selected in the embodiment of the present application. On this basis, the technician can mark the entities and keywords in a large number of real dialogue corpus sentences. Then, the marked corpus is used as sample data to iteratively train the pre-training model, and finally an identification model capable of object extraction is obtained. When object extraction is needed, the current sentence is input into the identification model, and the target object extracted by the identification model can be obtained. Among them, the identification model can be referred to as Figure 2 is a scene schematic diagram provided by the embodiment of the present application for marking the sentences in the corpus. In the embodiment of the present application, BIO format is used for marking. Specifically, B represents the beginning of the entity or keyword, I represents the end of the entity or keyword, and O identifies other words that are not entities and keywords. Through the BIO format marking, the corresponding loss function condition can be effectively calculated through the marking condition in the process of iteratively training the pre-training model, to determine whether convergence is needed.
[0063] S103, knowledge expansion is performed on the target object to obtain target data, the target data containing the target object and related data obtained through knowledge expansion.
[0064] After obtaining the target object, the embodiment of the present application starts to expand the knowledge of the target object, so as to obtain more available related knowledge content on the basis of the target object, and realize the supplement and expansion of the content of the dialogue with the user. Specifically, the knowledge content related to the target object can be searched in the knowledge base, such as the attribute data under the meaning item of the target object, and the knowledge content is taken as related data. The knowledge base can be a knowledge graph or a concept graph, which is not limited here. Meanwhile, the target object and the related data are collectively referred to as target data.
[0065] As an embodiment of the present application, considering the case of polysemy in practical application, that is, a single word may have multiple different meanings. During the knowledge expansion process, if the target object has an entity or keyword with polysemy, it may cause a large amount of noise in the expanded related data. In order to determine the specific meaning of the target object in the current sentence and obtain reasonable and available related data, the embodiment of the present application can also perform disambiguation processing on the target object when the target object is extracted. For reference Figure 3 , which is a flowchart of a disambiguation method in the knowledge expansion provided by the embodiment of the present application. At this time, S103 can be replaced by S1031 to S1033, which are described as follows:
[0066] S1031, searching for the meaning item corresponding to the target object in the knowledge base.
[0067] S1032, if multiple meaning items corresponding to the target object are searched, performing topic analysis on the historical dialogue records in the current dialogue to determine the topic of the current dialogue.
[0068] In practical application, the knowledge base stores entities and keywords, meaning items corresponding to the entities and keywords, and attribute data corresponding to the meaning items. For example, for “Chengdu”, it contains two meaning items of “place name” and “song name”. The “place name” meaning item can have some regional attribute data, such as provincial capital city, tourist city and Sichuan province. The “song name” meaning item can have some song-related attribute data, such as style, folk song, author and release time.
[0069] When multiple meaning items of the target object are found, the actual meaning item of the target object in the current dialogue needs to be determined first. For this purpose, the embodiment of the present application performs topic analysis on the current dialogue, that is, analyzes the existing historical dialogue records to determine the topic of the current dialogue. The method of topic analysis is not limited by the embodiment of the present application, which can be set by the technical personnel.
[0070] S1033, from the multiple meaning items corresponding to the target object, determine a meaning item with the highest relevance to the theme of the current dialogue, take the meaning item as the actual meaning item of the target object, and obtain relevant data of the target object under the actual meaning item.
[0071] After determining the theme of the current dialogue, the embodiment of the application can match the theme with each meaning item respectively to determine the relevance of each meaning item to the theme. Then, the meaning item with the highest relevance, i.e., the most relevant meaning item to the theme, is selected as the actual meaning item of the target object. Finally, some relevant data under the actual meaning item is obtained as the relevant data of the knowledge expansion, such as attribute data. In the embodiment of the application, the method for calculating the relevance of the meaning item to the theme is not limited, and can be set by the technician.
[0072] In the embodiment of the application, for the case that the target object has multiple meaning items, the theme of the current dialogue is analyzed as a whole to determine the theme discussed by the user in the current dialogue. On this basis, the meaning item most relevant to the theme is selected. Therefore, the embodiment of the application can accurately determine the actual meaning item of the target object in the case of polysemy. On this basis, the knowledge expansion is performed, which can ensure that the expanded knowledge content is strongly related to the theme of the current dialogue, thereby effectively improving the rationality and accuracy of the expansion.
[0073] As an optional embodiment of the application, it is considered that there may be some cases in which the theme matching is difficult to apply in actual application. For example, the current sentence is the first sentence in the current dialogue, and there is no historical dialogue record at this time. For another example, due to the fact that the current dialogue has just started, the historical dialogue record content is very small, and the theme cannot be analyzed. For another example, the relevance of each meaning item to the theme is low (e.g., lower than a preset relevance threshold), which makes it difficult to match the appropriate meaning item. In order to cope with these cases in which the theme matching is difficult to apply, the embodiment of the application can query the number of times that the relevant words of each meaning item are edited in the preset word library when these cases occur. On this basis, the meaning item with the most edited times of the relevant words is taken as the actual meaning item. Figure 3
[0074] In the embodiment of the application, the target data obtained by the knowledge expansion is mainly used as background knowledge when replying to the current sentence of the user, so that the relevant background of the current sentence of the user can be fully understood when replying. As an optional embodiment of the application, the target object and the relevant data can be processed in the knowledge expansion process to generate a corresponding knowledge description segment (at this time, the target data is the knowledge description segment). Correspondingly, reference can be made to the description of the knowledge description segment in the embodiment of the application. Figure 4 This is a schematic flowchart illustrating knowledge expansion of a target object according to an embodiment of this application. In this case, S103 can be replaced by S1034 to S1035. Details are as follows:
[0075] S1034, Extract triplet information containing attribute data of the target object.
[0076] In the embodiments of this application, the relevant data includes the attribute data of the target object, and the target data is the knowledge description fragment corresponding to the target object.
[0077] In this embodiment, the attribute data of the target object must first be obtained. For example, for the entity "song name", some song-related attribute data can be obtained, such as: style, folk, author, and release date. For target objects with multiple meanings, a preliminary approach can be taken. Figure 3 The embodiments shown and other methods are used to determine the actual meaning of a target object, and then obtain the attribute data under the actual meaning. In this embodiment, attribute data can be obtained in the form of triples. For example, for entity A, which is a song title, the triple information may include: {entity A style: folk}, {entity A author: Zhang San}, and {entity A release date: 2013}, etc.
[0078] As an optional embodiment of this application, if too many triplet information is directly extracted, it may result in excessive computational demands on the electronic device. Therefore, an upper limit value for triplet information can be set. When the number of extracted triplet information exceeds this upper limit value, the upper limit value of triplet information can be filtered out.
[0079] S1035, Based on the triplet information, generate several knowledge description fragments of the target object. Each knowledge description fragment is a short sentence containing the target object and related data.
[0080] After obtaining the triple information, this embodiment of the application generates a knowledge description fragment (hereinafter referred to as a fragment) corresponding to each triple information. For example, for {entity A style folk song}, the fragment "entity A's style is folk song" can be generated; for {entity A author Zhang San}, the fragment "entity A's author is Zhang San" can be generated; for {entity A release date 2013}, the fragment "entity A's release date is 2013" can be generated. Each triple information can generate one or more fragments.
[0081] In the process of generating the segments, if the number of generated segments is large, it can bring a large amount of calculation to the electronic device. Therefore, in the embodiments of the present application, a number threshold can be set for the number of segments. If the number of generated segments is greater than the number threshold, these are respectively matched in semantics with the current sentence, and the number threshold of segments with the highest semantic similarity is screened out. With reference to Figure 4 At this time, S1035 is followed by:
[0082] S1036, if the number of generated knowledge description segments is greater than the number threshold N, the semantic similarity of each knowledge description segment with the current sentence is calculated, and the first N knowledge description segments with the highest similarity are screened out.
[0083] The number threshold N is any positive integer. For example, N can be any integer from 3 to 10. The embodiments of the present application do not make too many limitations on the specific semantic matching method, which can be set by the technical personnel. For example, it can be implemented based on a large-scale pre-training model, or it can be implemented by selecting a word vector-based semantic matching algorithm.
[0084] On the basis of the embodiments of the present application, when using the knowledge description segments, the N knowledge description segments screened out can be used.
[0085] Reference can be made to Figure 5A The scenario diagram for implementing semantic matching based on a large-scale pre-training model is provided in the embodiments of the present application. The pre-training model can be constructed based on BERT, ALBERT, etc., and the language rules can be learned based on the pre-training model to realize semantic matching. Figure 5A In the embodiments shown in the figure, the semantic recognition model is a pre-training model trained. When processing the sentence or segment, the start can be marked as [CLS], and the sentence or segment to be matched can be separated by [SEP]. For example Figure 5A In the figure, the semantic matching model is used to calculate the semantic similarity of the current sentence "I like Chengdu very much" with the two segments "Chengdu is a folk song" and "Chengdu is the capital of a province", and the similarity is 0.8 and 0.5 respectively.
[0086] Reference can be made to Figure 5B, the scenario schematic diagram of the semantic matching implemented based on the semantic matching algorithm of the word vector is provided in the embodiments of the present application. In the embodiments of the present application, the sentence to be matched is referred to as a question, and the knowledge description fragment is referred to as a candidate knowledge. When performing semantic matching, the following steps are included: 1. performing word segmentation processing on the question and the candidate knowledge. 2. removing stop words from the segmented words. That is, some high-frequency meaningless words are removed. 3. using Word2Vec and other technologies, performing word vector conversion on each word of the question and the candidate knowledge respectively, and representing the words as word vectors. 4. using average summation and other methods, converting the word vectors into sentence vectors to represent the corresponding sentences, to obtain a question vector and a candidate knowledge vector. 5. calculating the cosine similarity of the question vector and the candidate knowledge vector. 6. performing reverse sorting on the calculation result to obtain the similarity result of the question and the candidate knowledge.
[0087] An example is taken for illustration, and reference is continued to be made to Figure 5B , it is assumed that the question is: I like Chengdu very much. Candidate knowledge 1 is: Chengdu is a folk song, and candidate knowledge 2 is: Chengdu is a provincial capital. At this time, the embodiments of the present application can obtain the question segmentation result: I / like / Chengdu / this / song, the candidate knowledge 1 segmentation result: Chengdu / is / folk song, and the candidate knowledge 2 segmentation result: Chengdu / is / provincial capital through word segmentation processing and stop word removal. Then, the word vector and the sentence vector of the segmentation result are converted, so as to obtain the question vector, the candidate knowledge 1 vector, and the candidate knowledge 2 vector. Finally, the cosine similarity is calculated and reverse sorting is performed, so as to obtain the corresponding similarity results: 0.8 and 0.5.
[0088] As an optional embodiment of the present application, Figure 3 and Figure 4 The embodiments shown can be combined for implementation, and after S1033, the operation of S1034 in Figure 4 and the like can be performed. That is, after the actual meaning item of the target object is determined, the attribute data under the actual meaning item is obtained, and the corresponding triple information is generated.
[0089] S104, based on the target data and the historical dialogue record in the current dialogue, a reply sentence for the current sentence is generated.
[0090] After the target data is obtained, the information preliminary analysis and arrangement of the current sentence are completed. On this basis, the embodiments of the present application will take the target data as background knowledge, and combine the historical dialogue record in the current dialogue as reference data to generate a sentence, so as to obtain the final reply sentence for the current sentence. As an optional embodiment of the present application, when the target data is in the form of a knowledge description fragment, the knowledge description fragment can be combined first, and then the combined knowledge description fragment is taken as background knowledge processing. The use of the target data and the historical dialogue record is described as follows:
[0091] On the one hand, since the target data contains the main information of the current sentence and the related extended knowledge, the target data is used as background knowledge to participate in the analysis and generation of the reply sentence, so that the situation of the current sentence can be effectively considered when the reply sentence is generated, thereby fitting the actual needs of the user of the current sentence.
[0092] On the other hand, in actual applications, there are often multiple rounds of conversations in a single conversation, that is, the conversation between the user and the electronic device often contains more content. For example, before the user inputs the current sentence, the user and the electronic device may have input and replied multiple times, respectively. In these historical conversation records, there are a large amount of explicit or implicit actual demand content of the user. In traditional human-computer conversation, only the information content of the current conversation is considered for reply. In some optional processing manners, all the input sentences of the user in the current conversation are considered for reply. These processing manners miss the content (i.e., the generated sentences of the electronic device) of the historical replies of the electronic device in the current conversation. In actual applications, it is found that if the user wants to continue the human-computer conversation, it means that the content replied by the electronic device in the historical conversation can meet the needs of the user to a certain extent. Therefore, the content replied by the electronic device in the historical conversation records also has a high reference value for analyzing the real needs of the user and replying. Therefore, the embodiments of the present application use the target data, and also use all the historical conversation records (including the historical input sentences of the user and the historical reply sentences of the electronic device) of the current conversation as a reference dimension. Thus, the available information in the multiple rounds of conversation is obtained as much as possible, the real needs of the user are analyzed and replied, and the content interested by the user is proposed.
[0093] The embodiments of the present application do not make too many limitations on the specific reply sentence generation method used, which can be set by the technician. For example, in some embodiments, the background knowledge can be inserted into the historical conversation records to obtain serialized sentence data composed of the input sentences of the user, the reply sentences of the electronic device and the background knowledge. On this basis, some language models are used for prediction to obtain the reply sentence for the current sentence. The language model can use an RNN or a GPT language model, which is not limited here. As an optional embodiment of the present application, the insertion order of the background knowledge can be between the end of the previous round of conversation and the current sentence. For example, the background knowledge can be inserted in the following manner, in which the placeholders [CLS] and [SEP] are used to separate the conversation content:
[0094] [CLS] the reply sentence of the electronic device [SEP] the background knowledge [SEP] the input sentence of the user [SEP].
[0095] As a specific embodiment of generating a reply sentence in the present application, reference can be made to Figure 5C is a scenario schematic diagram for generating a reply sentence based on a language model provided by an embodiment of the present application. In the embodiment of the present application, the speech model adopted is a speech model based on the GPT series. Assuming that the background knowledge contains “Chengdu is a folk song”, and the current sentence is “I like listening to Chengdu”. At this time, after processing by the language model, the reply sentence “Chengdu is a good folk song” is obtained.
[0096] As an optional embodiment of the present application, considering that a large number of reply sentences may be generated, if all of them are used to reply to the user, it may lead to too much reply content and poor user experience. Therefore, when a large number of generated reply sentences appear (for example, the number of generated reply sentences is greater than a preset sentence number threshold), the embodiments of the present application can sort these reply sentences, and the reply sentence at the front of the sorting can be used as the reply sentence for the current sentence. As an optional embodiment of the present application, any one of the following sorting methods can be used to sort the generated multiple reply sentences:
[0097] Sorting method 1: use some sentence classifiers to score the generated reply sentences, and sort them in descending order of scores.
[0098] Sorting method 2: analyze the relevance or similarity of each reply sentence to the current sentence, and sort them in descending order of relevance or similarity.
[0099] Sorting method 3: randomly sort.
[0100] As an optional embodiment of the present application, in order to prevent some noise from appearing in the reply content, for example, some meaningless replies appear. In the embodiment of the present application, after a large number of generated reply sentences appear, the generated reply sentences can be first denoised to remove some noise sentences existing therein, and then the above sorting and selection operations are performed.
[0101] After the final used reply sentence (also referred to as target sentence) is determined, the reply sentence can be output to realize the reply to the current sentence. Meanwhile, the reply sentence can also be stored in the historical dialogue record. Among them, according to the different dialogue modes of the user and the electronic device, the output mode of the reply sentence can be different, for example, the reply sentence can be output in the form of text, voice or video.
[0102] As an optional embodiment of the present application, in order to enhance the matching degree of the reply content and the user dialogue content in the human-computer dialogue process. After obtaining the reply statement, the obtained reply statement can be subjected to object extraction, so as to obtain corresponding entities and / or keywords (which can be collectively referred to as historical objects). Then the historical objects are subjected to knowledge expansion, so as to obtain corresponding historical data, and the historical data is stored as one of the background knowledge when generating the reply statement next time. Therefore, in the embodiment of the present application, S104 can not only refer to the target data and the historical dialogue record when generating the reply statement of the current statement, but also refer to the target data of the existing historical objects. At this time, S104 can be replaced by S1041.
[0103] S1041, obtaining historical data, and generating the reply statement for the current statement based on the historical data, the target data and the historical dialogue record in the current dialogue. The historical data is the data obtained by knowledge expansion on the entities and / or keywords in the historical reply statement.
[0104] That is, in the embodiment of the present application, the background knowledge includes the target data obtained at this time and the target data obtained by knowledge expansion on the historical objects extracted from the historical reply statements.
[0105] As a specific embodiment of the present application, the following can be referred to Figure 6 is an implementation flowchart of human-computer dialogue provided by an embodiment of the present application. In the embodiment of the present application, the electronic device is a robot. Details are as follows:
[0106] 1, waiting for the user to input a statement.
[0107] 2, the timer judges whether the input is timed out.
[0108] 3, if the input is timed out, it is determined that the current dialogue is ended, the historical dialogue record of the current dialogue is emptied and the current dialogue is ended.
[0109] 4, if the input has not been timed out, it is judged whether the user starts the dialogue, that is, whether the user inputs a statement.
[0110] 5, when the user starts the dialogue, the object extraction is performed on the current statement input by the user, that is, the entity recognition and the keyword extraction.
[0111] 6, searching the target entity and the target keyword recognized in the knowledge graph. For example, searching “Chengdu” in the knowledge graph.
[0112] 7, judging whether the target entity and the target keyword exist in the knowledge graph in the case of polysemy. For example, Chengdu is not only a place name but also a song name.
[0113] 8. When a target entity or target keyword has multiple meanings in the knowledge graph, the topic of the current dialogue is determined by combining the historical dialogue records of the current dialogue, and the actual meaning item with the highest relevance to the topic is selected to eliminate ambiguity.
[0114] 9. Extract the triplet information of the attribute data of the target entity and target keywords under the actual meaning item.
[0115] 10. Generate corresponding knowledge description fragments based on the extracted triple information.
[0116] 11. Determine whether the number of generated knowledge description fragments exceeds N. Where N is a positive integer.
[0117] 12. If the number of generated knowledge description fragments exceeds N, calculate the semantic similarity between each knowledge description fragment and the current statement.
[0118] 13. Select the top N knowledge description fragments with semantic similarity greater than a preset threshold.
[0119] 14. Incorporate the selected knowledge description fragments as part of the background knowledge.
[0120] 15. Combine background knowledge with the historical dialogue records of the current conversation as input data for the text generation algorithm. If other background knowledge content is already stored, use it as input data as well.
[0121] 16. The text generation algorithm generates several response statements for the robot.
[0122] 17. Select the most appropriate response statement as the response statement for the current statement based on the sorting strategy.
[0123] 18. Perform entity recognition and keyword extraction on the response statements to generate corresponding knowledge description fragments, and store them as part of the background knowledge of the current dialogue for use when generating response statements later.
[0124] 19. Store the selected reply statements in the history of conversations.
[0125] 20. Reply to the user with the selected reply statement.
[0126] The implementation details, principles, and beneficial effects of each step in the embodiments of this application can be found in the other method embodiments described above, and will not be repeated here.
[0127] Compared with human-computer dialogue based on question-answer databases, the embodiments of this application have at least the following beneficial effects:
[0128] 1. In generating response statements, this application's embodiments consider not only the current statement but also historical user input and electronic device responses. Therefore, the consideration of existing information is more comprehensive, allowing for the acquisition of explicit or implicit user needs throughout historical conversations. Generating response statements based on this information greatly enhances the relevance and continuity of the response content to the user's actual needs, thereby improving the matching degree with the user's conversation content. Furthermore, the response statements in this application's embodiments are generated based on actual circumstances, rather than fixed content selection, thus making the response content more flexible.
[0129] 2. In this embodiment, when the target object is obtained, the knowledge of the target object can be expanded to obtain more usable related knowledge content, thereby supplementing and expanding the content of the dialogue with the user. The expanded target data is then used as part of the background knowledge to participate in the subsequent generation of response statements. Therefore, this embodiment has more relevant knowledge to refer to when generating response statements, thus improving the accuracy of the generated response statements.
[0130] 3. During the process of expanding the knowledge of the target object, in cases where a word has multiple meanings, disambiguation can be performed based on the current topic of the conversation to determine the true meaning of the target object, ensuring that the final expanded content revolves around the user's conversation topic. Therefore, the expanded content in this embodiment has strong rationality and reliability, which can help improve the fit between the response and the current conversation topic, making the response more consistent with the current conversation.
[0131] 4. When acquiring target data, the corresponding triplet information can be extracted based on the relevant attribute data of the target object, and descriptive short sentences (i.e., knowledge description fragments) can be generated. Finally, these knowledge description fragments are used as part of the background knowledge to generate response statements. Therefore, the description of important and extended information of the current statement is closer to natural language, which helps in the generation of response statements.
[0132] 5. When there are too many generated knowledge description fragments, semantic matching can be used for filtering to select the fragments that best match the current statement. This reduces computation and effectively improves the reliability of the knowledge description fragments, thereby increasing the match between the response and the current statement.
[0133] 6. After each response statement is generated, the object of that response statement can be extracted, and the extracted entities and keywords can be expanded with knowledge. The resulting target data is then stored as historical data in the background knowledge. Since background knowledge is needed when generating response statements, historical data can be dynamically incorporated into each round of statement generation. This ensures that each time a response statement needs to be generated, the topic discussed by the user during the current dialogue can be fully considered. Therefore, this embodiment of the application can better match the dialogue topic in the current dialogue, present content that is of interest to the user, improve the continuity of human-computer dialogue, and thus achieve a higher degree of matching with the user's dialogue content.
[0134] Corresponding to the human-computer dialogue method described in the above embodiments, Figure 7 A schematic diagram of the human-computer dialogue device provided in the embodiments of this application is shown. For ease of explanation, only the parts related to the embodiments of this application are shown.
[0135] Reference Figure 7 The human-computer interaction device includes:
[0136] The object extraction module 71 is used to extract objects from the current statement input by the user to obtain the target object; the target object includes: target entity and / or target keyword;
[0137] The record acquisition module 72 is used to acquire the historical dialogue records in the current dialogue, wherein the historical dialogue records contain the statements generated by the human-computer dialogue device;
[0138] The statement generation module 73 is used to generate a response statement for the current statement based on the target object and the historical dialogue record.
[0139] As an optional embodiment of this application, the human-computer dialogue device can also be used to implement the above. Figures 1 to 6 The embodiments shown and other related method embodiments are described, and the human-computer dialogue device is the execution subject of each method embodiment.
[0140] For details on how each module in the human-computer dialogue device provided in this application implements its respective function, please refer to the foregoing. Figures 1 to 6 The descriptions of the illustrated embodiments and other related method embodiments are not repeated here.
[0141] It should be noted that the information interaction and execution process between the above-mentioned devices / units are based on the same concept as the method embodiments of this application. For details on their specific functions and technical effects, please refer to the method embodiments section, and they will not be repeated here.
[0142] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.
[0143] It should be understood that, when used in this application specification and the appended claims, the term "comprising" indicates the presence of the described features, integrals, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or a collection thereof.
[0144] It should also be understood that the term “and / or” as used in this application specification and the appended claims means any combination of one or more of the associated listed items and all possible combinations, and includes such combinations.
[0145] In the embodiments of this application, unless otherwise specified, "multiple" refers to two or more.
[0146] As used in this application specification and the appended claims, the term "if" may be interpreted, depending on the context, as "when," "once," "in response to determination," or "in response to detection." Similarly, the phrase "if determined" or "if detected [the described condition or event]" may be interpreted, depending on the context, as meaning "once determined," "in response to determination," "once detected [the described condition or event]," or "in response to detection [the described condition or event]."
[0147] Furthermore, in the description of this application and the appended claims, the terms "first," "second," "third," etc., are used only for distinguishing descriptions and should not be construed as indicating or implying relative importance. It should also be understood that although the terms "first," "second," etc., are used in the text to describe various elements in some embodiments of this application, these elements should not be limited by these terms. These terms are merely used to distinguish one element from another. For example, a first table may be named a second table, and similarly, a second table may be named a first table, without departing from the scope of the various described embodiments. Both the first table and the second table are tables, but they are not the same table.
[0148] References to "one embodiment" or "some embodiments" as described in this specification mean that one or more embodiments of this application include a specific feature, structure, or characteristic described in connection with that embodiment. Therefore, the phrases "in one embodiment," "in some embodiments," "in other embodiments," "in still other embodiments," etc., appearing in different parts of this specification do not necessarily refer to the same embodiment, but rather mean "one or more, but not all, embodiments," unless otherwise specifically emphasized. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless otherwise specifically emphasized.
[0149] The human-computer dialogue method provided in this application can be applied to electronic devices such as mobile phones, tablets, wearable devices, in-vehicle devices, augmented reality (AR) / virtual reality (VR) devices, laptops, ultra-mobile personal computers (UMPCs), netbooks, and personal digital assistants (PDAs). This application does not impose any restrictions on the specific type of electronic device.
[0150] For example, the electronic device may be a station (STAION, ST) in a WLAN, a cellular phone, a cordless phone, a Session Initiation Protocol (SIP) phone, a Wireless Local Loop (WLL) station, a Personal Digital Assistant (PDA) device, a handheld device with wireless communication capabilities, a computing device or other processing device connected to a wireless modem, an in-vehicle device, a vehicle networking terminal, a computer, a laptop computer, a handheld communication device, a handheld computing device, a satellite wireless device, a wireless modem card, a set-top box (STB), customer premises equipment (CPE), and / or other devices for communication over a wireless system, as well as next-generation communication systems, such as electronic devices in 5G networks or electronic devices in future evolved Public Land Mobile Network (PLMN) networks.
[0151] As an example and not a limitation, when the electronic device is a wearable device, the term "wearable device" can also refer to any device that utilizes wearable technology to intelligently design and develop everyday wearables, such as glasses, gloves, watches, clothing, and shoes. Wearable devices are portable devices worn directly on the body or integrated into a user's clothing or accessories. Wearable devices are not merely hardware devices; they achieve powerful functions through software support, data interaction, and cloud interaction. Broadly defined, wearable smart devices include those with comprehensive functions, large sizes, and the ability to perform complete or partial functions without relying on a smartphone, such as smartwatches or smart glasses, as well as those focused on a specific application function that require interaction with other devices such as smartphones, such as various smart bracelets and smart jewelry for vital sign monitoring.
[0152] Figure 8 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. For example... Figure 8 As shown, the electronic device 8 of this embodiment includes: at least one processor 80 ( Figure 8 (Only one is shown in the image) A memory 81 stores a computer program 82 that can run on the processor 80. When the processor 80 executes the computer program 82, it implements the steps in the various human-computer dialogue method embodiments described above, for example... Figure 1 Steps 101 to 104 are shown. Alternatively, when the processor 80 executes the computer program 82, it implements the functions of each module / unit in the above-described device embodiments, for example... Figure 7 The functions of modules 71 to 73 are shown.
[0153] The electronic device 8 can be a desktop computer, laptop, handheld computer, cloud server, or other computing device. The electronic device may include, but is not limited to, a processor 80 and a memory 81. Those skilled in the art will understand that... Figure 8 This is merely an example of electronic device 8 and does not constitute a limitation on electronic device 8. It may include more or fewer components than shown, or combine certain components, or different components. For example, the electronic device may also include input transmitting devices, network access devices, buses, etc.
[0154] The processor 80 may be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor.
[0155] In some embodiments, the memory 81 may be an internal storage unit of the electronic device 8, such as a hard disk or memory of the electronic device 8. The memory 81 may also be an external storage device of the electronic device 8, such as a plug-in hard disk, smart media card (SMC), secure digital card (SD) card, flash card, etc., equipped on the electronic device 8. Furthermore, the memory 81 may include both internal and external storage units of the electronic device 8. The memory 81 is used to store the operating system, applications, bootloader, data, and other programs, such as the program code of the computer program. The memory 81 can also be used to temporarily store data that has been sent or will be sent.
[0156] Furthermore, those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is merely an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. In the various embodiments of this application, each functional unit 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.
[0157] This application also provides an electronic device, which includes at least one memory, at least one processor, and a computer program stored in the at least one memory and executable on the at least one processor. When the processor executes the computer program, it causes the electronic device to perform the steps in any of the above-described method embodiments.
[0158] This application also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps described in the various method embodiments above.
[0159] This application provides a computer program product that, when run on an electronic device, enables the electronic device to implement the steps described in the various method embodiments above.
[0160] This application also provides a chip system, which includes a processor coupled to a memory. The processor executes a computer program stored in the memory to implement the steps in the various method embodiments described above.
[0161] If the integrated module / 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, all or part of the processes in the methods of the above embodiments can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable storage medium can include: any entity or device capable of carrying the computer program code, a recording medium, a USB flash drive, a portable hard drive, a magnetic disk, an optical disk, a computer memory, a read-only memory (ROM), a random access memory (RAM), an electrical carrier signal, a telecommunication signal, and a software distribution medium, etc.
[0162] In the above embodiments, the descriptions of each embodiment have different focuses. For parts that are not described in detail or recorded in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0163] Those skilled in the art will recognize that the units and algorithm 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 this application.
[0164] The units described as separate components may or may not be physically separate. The 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 according to actual needs.
[0165] The above-described 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, and should all be included within the protection scope of this application.
Claims
1. A human-machine dialog method, characterized in that, Be applied to electronic equipment, including: Object extraction is carried out on the current sentence input by the user, and a target object is obtained; the target object includes a target entity and / or a target keyword; Obtain the historical dialogue record in the current dialogue, which contains the sentence generated by the electronic device; The target object is knowledge expanded to obtain target data containing the target object; the target data contains attribute data of the target object; According to the target data and the historical dialogue record, a reply sentence for the current sentence is generated; The target object is knowledge expanded, including: Find the meaning item corresponding to the target object; When the target object corresponds to multiple meaning items, the number of times of editing the related words in the preset word library is queried for each meaning item; The meaning item with the most number of times of editing related words is taken as the actual meaning item.
2. The human-to-computer dialog method of claim 1, wherein, The target object is knowledge expanded, including: Find the meaning item corresponding to the target object; When the target object corresponds to multiple meaning items, the theme of the current dialogue is determined by subject analysis on the historical dialogue record; From the multiple meaning items, the actual meaning item with the highest relevance to the theme is filtered out, and the attribute data of the target object under the actual meaning item is obtained.
3. The man-machine dialog method according to claim 1 or 2, characterized in that, The target object is knowledge expanded, including: Extract the triple information of the target object; the triple information contains the attribute data of the target object; According to the triple information, a plurality of knowledge description segments of the target object are generated, and the plurality of knowledge description segments are the target data; the knowledge description segment is a sentence containing the target object and the attribute data of the target object.
4. The human-to-computer dialog method of claim 3, wherein, After the plurality of knowledge description segments of the target object are generated, the following steps are further included: When the number of generated knowledge description segments is greater than a preset number threshold, the semantic similarity of each knowledge description segment and the current sentence is calculated; From the plurality of knowledge description segments, the number threshold knowledge description segments with the highest similarity are filtered out, and the filtered knowledge description segments are taken as the target data.
5. The human-to-computer dialog method of claim 1, wherein, After the reply sentence for the current sentence is generated according to the target data and the historical dialogue record, the following steps are further included: Object extraction is carried out on the target sentence to obtain a historical object; the target sentence is the reply sentence for the current sentence, and the historical object contains an entity and / or a keyword; The historical object is knowledge expanded to obtain historical data containing the historical object; the historical data contains attribute data of the historical object.
6. The human-to-computer dialog method of claim 1, wherein, The reply sentence for the current sentence is generated according to the target data and the historical dialogue record, including: Obtain historical data, and generate a reply sentence for the current sentence based on the historical data, the target data and the historical dialogue record; the historical data is the data obtained by knowledge expanding the entity and / or keyword in the sentence generated by the electronic device.
7. A man-machine dialog apparatus, characterized by Including: An object extraction module is configured to extract an object from a current sentence input by a user to obtain a target object; The target object includes a target entity and / or a target keyword; A record acquisition module is configured to acquire a historical dialogue record in a current dialogue, the historical dialogue record including a sentence generated by the human-computer dialogue device; A sentence generation module is configured to expand knowledge of the target object to obtain target data including the target object, the target data including attribute data of the target object, and generate a reply sentence for the current sentence according to the target data and the historical dialogue record; The knowledge expansion of the target object includes: Finding a meaning item corresponding to the target object; When the target object corresponds to multiple meaning items, querying a number of times that a word related to each meaning item in a preset word library is edited; Taking a meaning item with the largest number of times that the related word is edited as an actual meaning item.
8. An electronic device, comprising: The electronic device includes a memory and a processor, the memory stores a computer program capable of running on the processor, and the processor implements the steps of the method according to any one of claims 1 to 6 when executing the computer program.
9. A computer-readable storage medium storing a computer program, the computer program comprising instructions that, when executed by a computer, cause the computer to perform the method of any one of claims 1 to 8. The computer program is executed by the processor to implement the steps of the method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Apparatus, server, and method for providing conversation topic
CN105453578A
Voice interaction method and device and terminal equipment
CN111428483A
Service equipment applied to multi-round dialogues and multi-round dialogue method
CN112182196A