WO2022121161A1 - 多轮对话文本生成方法、装置、设备及存储介质 - Google Patents

多轮对话文本生成方法、装置、设备及存储介质 Download PDF

Info

Publication number
WO2022121161A1
WO2022121161A1 PCT/CN2021/083336 CN2021083336W WO2022121161A1 WO 2022121161 A1 WO2022121161 A1 WO 2022121161A1 CN 2021083336 W CN2021083336 W CN 2021083336W WO 2022121161 A1 WO2022121161 A1 WO 2022121161A1
Authority
WO
WIPO (PCT)
Prior art keywords
historical
dialogue
information
topic
round
Prior art date
Application number
PCT/CN2021/083336
Other languages
English (en)
French (fr)
Inventor
回艳菲
王健宗
吴天博
Original Assignee
平安科技(深圳)有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 平安科技(深圳)有限公司 filed Critical 平安科技(深圳)有限公司
Publication of WO2022121161A1 publication Critical patent/WO2022121161A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/33Querying
    • G06F16/332Query formulation
    • G06F16/3329Natural language query formulation or dialogue systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F17/00Digital computing or data processing equipment or methods, specially adapted for specific functions
    • G06F17/10Complex mathematical operations
    • G06F17/18Complex mathematical operations for evaluating statistical data, e.g. average values, frequency distributions, probability functions, regression analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/279Recognition of textual entities
    • G06F40/284Lexical analysis, e.g. tokenisation or collocates
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/045Combinations of networks

Definitions

  • the present application relates to the field of artificial intelligence, and in particular, to a method, apparatus, device and storage medium for generating multi-round dialogue texts.
  • the subsequent texts need to be generated according to the previous dialogues.
  • the inventor realized that when the topics in the previous dialogues are migrated, the generated texts are often unable to respond flexibly to changes in topics. resulting in errors.
  • the main purpose of this application is to solve the problem that the texts generated by existing multi-round dialogues have poor effect when faced with topic transfer.
  • a first aspect of the present application provides a method for generating a multi-round dialogue text, wherein the multi-round dialogue text generation includes:
  • the first word vector is input into the preset HRED model for information extraction to obtain the correlation between the historical dialogue sentences, and the first word vector is input into the preset BTM model for topic extraction, and the preset Attention algorithm is used to perform topic extraction.
  • the extracted historical topics are assigned weights to obtain the distribution weights of historical topics;
  • the present application also provides a multi-round dialogue text generation device, the multi-round dialogue text generation device includes:
  • the acquisition module is used to acquire the historical multi-round dialogue text and perform word vector conversion to obtain the first word vector, and to acquire the current dialogue text and perform word vector conversion to obtain the second word vector;
  • the extraction module is used to input the first word vector into the preset HRED model for information extraction to obtain the correlation between the historical dialogue sentences, and input the first word vector into the preset BTM model for topic extraction, and obtain multiple a historical topic;
  • the processing module is used to assign weights to the extracted historical topics by using the preset Attention algorithm, obtain the distribution weights of historical topics, and call the preset normalization function to determine the correlation between the historical dialogue sentences and the historical topics.
  • the distribution weights are normalized to obtain historical multi-round dialogue information
  • the capture module is used to input the second word vector into the BTM model for topic extraction in the current dialogue context, and call a preset capture function to capture information on the extracted current topic to obtain the topic in the current context distribution information;
  • the generating module is used for splicing the topic distribution information in the current context and the historical multi-round dialogue information to obtain multi-round dialogue fusion information, and inputting the multi-round dialogue fusion information into a preset dialogue text generator for decoding, and generating A new round of dialogue text formed with the current dialogue text.
  • the present application also provides a multi-round dialogue text generation device, comprising: a memory and at least one processor, wherein instructions are stored in the memory; the at least one processor calls a The instruction, so that the multi-round dialogue text generation device executes the steps of the above-mentioned multi-round dialogue text generation method, includes:
  • the present application also provides a computer-readable storage medium
  • the computer-readable storage medium may be non-volatile or volatile
  • the computer-readable storage medium stores The instruction, when it runs on the computer, causes the computer to execute the steps of the above-mentioned multi-round dialogue text generation method, including:
  • FIG. 1 is a schematic diagram of a first embodiment of a method for generating multi-round dialogue texts in an embodiment of the present application
  • FIG. 2 is a schematic diagram of a second embodiment of a method for generating multi-round dialogue texts in an embodiment of the present application
  • FIG. 3 is a schematic diagram of an embodiment of an apparatus for generating multi-round dialogue texts in an embodiment of the present application
  • FIG. 4 is a schematic diagram of an embodiment of a multi-round dialogue text generating device in an embodiment of the present application.
  • Embodiments of the present application provide a method, apparatus, device, and storage medium for generating multi-round dialogue text.
  • the terms “first”, “second”, “third”, “fourth”, etc. (if any) in the description and claims of the present application and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It is to be understood that data so used may be interchanged under appropriate circumstances so that the embodiments described herein can be practiced in sequences other than those illustrated or described herein.
  • the first embodiment of the method for generating multi-round dialogue text in the embodiment of the present application includes:
  • the execution body of the present application may be a multi-round dialogue text generating device, or may be a terminal or a server, which is not specifically limited here.
  • the embodiments of the present application take the server as an execution subject as an example for description.
  • the historical multi-round dialogue text includes the text of all historical dialogues before the last round of dialogue
  • the current dialogue text includes the text of the last round of dialogue
  • the word vector is to represent the words in the text as vectors, and each word is represented as a long vector by one-hot representation.
  • the dimension of this vector is the size of the vocabulary. Only one dimension in the vector has a value of 1, and the other dimensions are 0. This dimension represents the current word.
  • apple [0, 0, 0, 1, 0, 0, 0, 0, 0, ...].
  • the HRED model includes a Word RNN network and a Sentence RNN network.
  • the Word RNN network is used to extract multiple sentence information
  • the Sentence RNN network is used to extract relevant information between sentences in multiple rounds of dialogue to obtain each historical dialogue sentence. correlation between.
  • the BTM model includes ⁇ , ⁇ , ⁇ , w 1 , w 2 , where ⁇ and ⁇ are given hyperparameters, ⁇ is the topic distribution, is the word distribution, w 1 represents word 1, w 2 represents word 2, and z represents topic z.
  • the BTM model is a topic model based on word pairs, which achieves the subject distribution prediction of short texts by maximizing the probability of extracting word pairs in different topics.
  • the HRED model includes a Word RNN network and a Sentence RNN network, and the first word vector is input into a preset HRED model for information extraction to obtain the correlation between each historical dialogue sentence.
  • the Word RNN network is mainly used to encode the input sentence, and encodes information on the dialogue level such as the state and intention of the entire dialogue.
  • the hidden layer vector of the RNN can remember the previous dialogue information, and the Word RNN network adopts a two-way RNN. Additional short-term dependencies can be effectively introduced.
  • the vector encoding the previous dialogue information is used as the input vector of the Sentence RNN network, so that in the decoding process, in addition to using the information of the answer sentence itself, the dialogue context information is also used.
  • the first word vector is input into a preset BTM model for topic extraction, and the obtained multiple historical topics include:
  • topic-Biterm probability distribution calculation is performed on the first word vector to obtain first topic distribution information, where the first topic distribution information includes a plurality of historical topics.
  • firstly Extract all bigrams from the word vector that is, extract Biterm pairs. For example: "I visit apple store", after removing the I stop word, the extracted bigrams include ⁇ visit apple ⁇ , ⁇ visit store ⁇ , ⁇ apple store ⁇ . Extract topic-word distribution for each topic z Obtain the topic distribution ⁇ from the Dirichlet prior. For each bigram b in the bigram set B: extract a topic z, extract two words w 1 and w 2 , and finally obtain the first topic distribution information including multiple a historical topic.
  • the Attention algorithm is:
  • ⁇ ′ i is the weight of historical topic distribution
  • ⁇ i is the similarity
  • ⁇ j is the sum of the similarity
  • the normalization function is:
  • S N is the historical multi-round dialogue information
  • N is the total number of N sentences
  • ⁇ ′ i is the distribution weight of the historical topic
  • si is the correlation between the historical dialogue sentences.
  • the historical topic distribution weight including:
  • a Softmax operation is performed on the similarity to obtain the distribution weight of historical topics.
  • the Attention mechanism is applied to the topic distribution extracted by the BTM model and the sentence information extracted by the HRED model, so as to obtain the proportion of the topic in it, and obtain the information of the topic transfer, so as to generate the following text more accurately and make the text more accurate. In line with the logic of multiple rounds of dialogue.
  • the preset normalization function is called to perform a normalization operation on the correlation between the historical dialogue sentences and the historical topic distribution weight to obtain historical multi-round dialogue information.
  • a preset normalization function is called to perform a summation operation on the historical information of each round of dialogue in the historical multi-round dialogue text to obtain historical multi-round dialogue information.
  • S N since S N includes the vocabulary information of the i-th sentence and covers the topic distribution of the i-th sentence, the information of the i-th sentence can be obtained by combining the two. Can get information about all sentences in previous rounds of conversations.
  • the topic in the current dialogue context is extracted by using the BTM model. Since the input is only the dialogue text in the current context, the output is the topic in the current context.
  • the capture function is E(t N , c N ), which represents a comprehensive distribution value of the Nth sentence. Because the comprehensive distribution value is obtained for the current dialogue context, the topic distribution information in the current context is obtained.
  • the second word vector is input into the BTM model for topic extraction in the context of the current conversation, and a preset capture function is called to capture information on the extracted current topic,
  • Obtaining topic distribution information in the current context includes:
  • the second topic distribution information is captured by a preset capturing function, and the topic distribution information in the current context is obtained.
  • topic-Biterm probability distribution calculation is performed on the second word vector to obtain second topic distribution information, wherein the second topic distribution information includes a plurality of historical topics.
  • the topic-Biterm probability distribution firstly Extract all bigrams from the word vector, that is, extract Biterm pairs. For example: “I love Beijing”, after removing the stop word "I”, the extracted bigrams include ⁇ , ⁇ Beijing ⁇ , ⁇ .
  • the topic-word distribution get the topic distribution from the Dirichlet prior, for each bigram b in the bigram set B: extract a topic z, extract two words w 1 and w 2 , and finally get the second topic distribution information.
  • the capture function calculates E(t N , c N ) to obtain a comprehensive distribution value of the Nth sentence, which is topic distribution information in the current context.
  • the topic distribution information in the current context and the historical multi-round dialogue information are spliced to obtain multi-round dialogue fusion information.
  • the dialogue text generator includes a Self-attention layer, an Encoder-decoder attention layer, and an FNN layer.
  • the text generator uses the word with the largest probability value in the word probability distribution as the generated word. words, and splicing the generated words to obtain a new round of dialogue texts formed with the current dialogue texts.
  • multiple machine learning models are used to capture the topic, and the HRED model is first used to extract the history
  • the context information in the multi-round dialogue texts is used to obtain the correlation between the historical dialogue sentences, and then the BTM model and the Attention algorithm are used to extract and strengthen the topics to obtain the historical topic distribution weight and topic distribution information in the current context.
  • the present application can more accurately find out which topics the text should be generated from, so as to generate the following text more accurately, making the text more in line with the logic of multiple rounds of dialogue.
  • the fourth embodiment of the method for generating multi-round dialogue texts in the embodiment of the present application includes:
  • the Self-attention layer is to perform an attention calculation on each word in the sentence and all the words in the sentence, and its function is to learn the word dependency inside the sentence and obtain the internal structure of the word. Therefore, the information source of Self-attention calculation is derived from the sentence itself.
  • Mask makes the value of the completion position a very large negative number through the operation of Mask. This operation is equivalent to masking the useless information of the completion position, thereby obtaining the query vector. .
  • the Encoders in the Encoder-decoder attention layer are stacked together by 6 identical layers, and each layer has two branches.
  • the first branch is a multi-head self-attention mechanism, and the second branch
  • the layer is a simple fully connected feedforward network, a residual connection is added outside the two branches, and then layer nomalization is performed.
  • the decoder also stacks six identical layers. However, in addition to the two branches in the Encoder, the decoder also adds a third branch to each layer.
  • the decoder uses residual and layer normalization.
  • the Encoder-decoder attention layer is used for text generation tasks, performs extremely well, is parallelizable, and greatly reduces training time. Feature extraction is performed on the query vector through the Encoder-decoder to obtain a feature vector.
  • the FNN layer performs multiple linear transformations and performs nonlinear transformations through activation functions.
  • the activation function mainly plays the role of nonlinear transformation here.
  • the nonlinear transformation of each layer of the network is relatively simple, the nonlinear decision surface generated after multiple transformations will become very complex, so that it can be competent for complex classification and regression problems.
  • the vector is subjected to probability distribution operation to obtain the word probability distribution.
  • the word with the highest probability in the word probability distribution is used as the generated word, and then these words are spliced together to obtain the final generated text.
  • the words with the highest probability in the word probability distribution are: me, also, love, beijing, beijing. That is, a new round of dialogue texts composed of the current dialogue texts is generated as: I love Beijing too.
  • the function of the text generator is to decode the historical multi-round dialogue information and topic distribution information in the current context, so as to generate a new round of dialogue text composed of the current dialogue text.
  • the topic distribution information in the current context is used to generate text, which increases the accuracy of the generated text.
  • the obtaining module 301 is used to obtain historical multi-round dialogue texts and perform word vector conversion to obtain a first word vector, and obtain current dialogue text and perform word vector conversion to obtain a second word vector;
  • the extraction module 302 is used for inputting the first word vector into a preset HRED model for information extraction to obtain the correlation between each historical dialogue sentence, and inputting the first word vector into the preset BTM model for topic extraction to obtain Multiple historical topics;
  • the processing module 303 is used to assign weights to the extracted historical topics by using the preset Attention algorithm, obtain the distribution weights of historical topics, and call the preset normalization function to determine the correlation between the historical dialogue sentences and the historical topics.
  • the topic distribution weights are normalized to obtain historical multi-round dialogue information;
  • the capture module 304 is configured to input the second word vector into the BTM model for topic extraction in the current dialogue context, and call a preset capture function to capture information on the extracted current topic to obtain the current topic in the current context. topic distribution information;
  • the generating module 305 is used for splicing the topic distribution information in the current context and the historical multi-round dialogue information to obtain multi-round dialogue fusion information, and inputting the multi-round dialogue fusion information into a preset dialogue text generator for decoding, Generate a new round of dialogue text composed of the current dialogue text.
  • the HRED model includes a Word RNN network and a Sentence RNN network
  • the extraction module 302 includes a first extraction unit 3021
  • the first extraction unit 3021 is specifically used for:
  • the extraction module 302 includes a second extraction unit 3022, and the second extraction unit 3022 is specifically configured to:
  • the processing module 303 includes a first processing unit 3031, and the first processing unit 3031 is specifically configured to:
  • the preset Attention algorithm is used to calculate the similarity between each historical topic and the historical context in the first topic distribution information; Softmax operation is performed on the similarity to obtain the distribution weight of the historical topic.
  • the processing module 303 includes a second processing unit 3032, and the second processing unit 3032 is specifically used for
  • a preset normalization function is called to perform a summation operation on the historical information of each round of dialogue in the historical multi-round dialogue text to obtain historical multi-round dialogue information.
  • the capturing module 304 is specifically configured to:
  • the second topic distribution information is captured by a preset capturing function to obtain topic distribution information in the current context.
  • the dialogue text generator includes a Self-attention layer, an Encoder-decoder attention layer and an FNN layer
  • the generation module 305 includes:
  • the splicing unit 3051 is used for splicing the topic distribution information in the current context and the historical multi-round dialogue information to obtain multi-round dialogue fusion information;
  • Generation unit 3052 for inputting the multi-round dialogue fusion information into the Self-attention layer to perform Mask conversion to obtain a query vector; Input the query vector into the Encoder-decoder attention layer for feature extraction to obtain a feature vector; Input the feature vector into the FNN layer to perform probability distribution operation to obtain word probability distribution; use the word with the largest probability value in the word probability distribution as a generated word, and splicing the generated word to obtain a composition with the current dialogue text 's new round of dialogue text.
  • multiple machine learning models are used to capture the topic, and the HRED model is first used to extract the history
  • the context information in the multi-round dialogue texts is used to obtain the correlation between the historical dialogue sentences, and then the BTM model and the Attention algorithm are used to extract and strengthen the topics to obtain the historical topic distribution weight and topic distribution information in the current context.
  • the present application can more accurately find out which topics the text should be generated from, so as to generate the following text more accurately, making the text more in line with the logic of multiple rounds of dialogue.
  • FIG. 3 above describes the device for generating multi-round dialogue text in the embodiment of the present application in detail from the perspective of modular functional entities, and the following describes the device for generating multi-round dialogue text in the embodiment of the present application in detail from the perspective of hardware processing.
  • FIG. 4 is a schematic structural diagram of a multi-round dialogue text generation device provided by an embodiment of the present application.
  • the multi-round dialogue text generation device 400 may have relatively large differences due to different configurations or performance, and may include one or more processors. (central processing units, CPU) 410 (eg, one or more processors) and memory 420, one or more storage media 430 (eg, one or more mass storage devices) that store application programs 433 or data 432.
  • the memory 420 and the storage medium 430 may be short-term storage or persistent storage.
  • the program stored in the storage medium 430 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations on the multi-round dialogue text generating apparatus 400 .
  • the processor 410 may be configured to communicate with the storage medium 430 to execute a series of instruction operations in the storage medium 430 on the multi-turn dialogue text generating device 400 .
  • the multi-turn dialogue text generation device 400 may also include one or more power supplies 440, one or more wired or wireless network interfaces 450, one or more input and output interfaces 460, and/or, one or more operating systems 431, such as Windows Server, Mac OS X, Unix, Linux, FreeBSD, and more.
  • operating systems 431, such as Windows Server, Mac OS X, Unix, Linux, FreeBSD, and more such as Windows Server, Mac OS X, Unix, Linux, FreeBSD, and more.
  • the present application also provides a multi-round dialogue text generation device, the multi-round dialogue text generation device includes a memory and a processor, the memory stores computer-readable instructions, and when the computer-readable instructions are executed by the processor, causes the processor to execute The steps of the multi-round dialogue text generation method in the above embodiments.
  • the present application also provides a computer-readable storage medium.
  • the computer-readable storage medium may be a non-volatile computer-readable storage medium.
  • the computer-readable storage medium may also be a volatile computer-readable storage medium.
  • the computer-readable storage medium stores instructions that, when executed on a computer, cause the computer to execute the steps of the multi-round dialogue text generation method.
  • the integrated unit if implemented in the form of a software functional unit and sold or used as an independent product, may be stored in a computer-readable storage medium.
  • the technical solutions of the present application can be embodied in the form of software products in essence, or the parts that contribute to the prior art, or all or part of the technical solutions, and the computer software products are stored in a storage medium , including several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present application.
  • the aforementioned storage medium includes: U disk, removable hard disk, read-only memory (ROM), random access memory (RAM), magnetic disk or optical disk and other media that can store program codes .

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Mathematical Physics (AREA)
  • Data Mining & Analysis (AREA)
  • General Engineering & Computer Science (AREA)
  • Artificial Intelligence (AREA)
  • Computational Linguistics (AREA)
  • Software Systems (AREA)
  • Computational Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • Pure & Applied Mathematics (AREA)
  • Mathematical Optimization (AREA)
  • Mathematical Analysis (AREA)
  • General Health & Medical Sciences (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Health & Medical Sciences (AREA)
  • Biomedical Technology (AREA)
  • Probability & Statistics with Applications (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Evolutionary Biology (AREA)
  • Biophysics (AREA)
  • Evolutionary Computation (AREA)
  • Operations Research (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • Computing Systems (AREA)
  • Algebra (AREA)
  • Molecular Biology (AREA)
  • Human Computer Interaction (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Machine Translation (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

一种多轮对话文本生成方法、装置、设备及存储介质,涉及人工智能领域。该方法包括:获取历史多轮对话文本和当前对话文本并分别进行词向量转换,得到第一词向量和第二词向量;将第一词向量输入预置HRED模型进行处理,得到相关度,将第一词向量输入BTM模型进行处理并采用Attention算法对提取的历史话题进行权重赋值,得到历史话题分布权重并和相关度进行归一化,得到历史多轮对话信息;将第二词向量输入BTM模型对提取到的话题进行捕捉,得到当前语境下的话题分布信息;拼接话题分布信息和历史多轮对话信息并输入对话文本生成器,以生成与当前对话文本构成的新一轮对话文本。该方法将历史话题的上下文关系引入下一轮对话生成,生成的文本更准确。

Description

多轮对话文本生成方法、装置、设备及存储介质
本申请要求于2020年12月10日提交中国专利局、申请号为202011432574.8、发明名称为“多轮对话文本生成方法、装置、设备及存储介质”的中国专利申请的优先权,其全部内容通过引用结合在申请中。
技术领域
本申请涉及人工智能领域,尤其涉及一种多轮对话文本生成方法、装置、设备及存储介质。
背景技术
随着人工智能技术的发展,利用机器人与用户在对话中直接完成业务流程处理,可以大大减少人工成本,提高问题处理的效率。例如客服聊天的对话系统,从过去的对话均由人工问答完成,到如今先由智能客服解答常见问题再由人工解决复杂问题。人机对话中关键的核心技术是多轮对话生成,这是人工智能发展水平的标志,也是目前自然语言处理领域的研究热点,受到越来越多科研人员的关注。
多轮对话生成文本时需要根据前面多个对话来进行后文生成,但是,发明人意识到当前面多个对话中的话题发生迁移时,生成的文本往往会因为不能灵活的应对话题的变化,而导致错误的产生。
发明内容
本申请的主要目的在于解决现有多轮对话生成文本在面对话题迁移时生成的文本效果不佳的问题。
本申请第一方面提供了一种多轮对话文本生成方法,所述多轮对话文本生成包括:
获取历史多轮对话文本并进行词向量转换,得到第一词向量,以及获取当前对话文本并进行词向量转换,得到第二词向量;
将所述第一词向量输入预置HRED模型进行信息提取,得到各历史对话语句之间相关度,以及将所述第一词向量输入预置BTM模型进行话题提取,并采用预置Attention算法对提取的历史话题进行权重赋值,得到历史话题分布权重;
调用预置归一化函数,对所述各历史对话语句之间相关度和所述历史话题分布权重进行归一化运算,得到历史多轮对话信息;
将所述第二词向量输入所述BTM模型进行当前对话语境下的话题提取,并调用预置捕捉函数对提取到的当前话题进行信息捕捉,得到当前语境下的话题分布信息;
拼接当前语境下的话题分布信息和所述历史多轮对话信息,得到多轮对话融合信息,并将所述多轮对话融合信息输入预置对话文本生成器进行解码,生成与当前对话文本构成 的新一轮对话文本。
进一步地,为实现上述目的,本申请还提供一种多轮对话文本生成装置,所述多轮对话文本生成装置包括:
获取模块,用于获取历史多轮对话文本并进行词向量转换,得到第一词向量,以及获取当前对话文本并进行词向量转换,得到第二词向量;
提取模块,用于将所述第一词向量输入预置HRED模型进行信息提取,得到各历史对话语句之间相关度,以及将所述第一词向量输入预置BTM模型进行话题提取,得到多个历史话题;
处理模块,用于采用预置Attention算法对提取的历史话题进行权重赋值,得到历史话题分布权重,并调用预置归一化函数,对所述各历史对话语句之间相关度和所述历史话题分布权重进行归一化运算,得到历史多轮对话信息;
捕捉模块,用于将所述第二词向量输入所述BTM模型进行当前对话语境下的话题提取,并调用预置捕捉函数对提取到的当前话题进行信息捕捉,得到当前语境下的话题分布信息;
生成模块,用于拼接当前语境下的话题分布信息和所述历史多轮对话信息,得到多轮对话融合信息,并将所述多轮对话融合信息输入预置对话文本生成器进行解码,生成与当前对话文本构成的新一轮对话文本。
进一步地,为实现上述目的,本申请还提供一种多轮对话文本生成设备,包括:存储器和至少一个处理器,所述存储器中存储有指令;所述至少一个处理器调用所述存储器中的所述指令,以使得所述多轮对话文本生成设备执行上述的多轮对话文本生成方法的步骤,包括:
获取历史多轮对话文本并进行词向量转换,得到第一词向量,以及获取当前对话文本并进行词向量转换,得到第二词向量;
将所述第一词向量输入预置HRED模型进行信息提取,得到各历史对话语句之间相关度,以及将所述第一词向量输入预置BTM模型进行话题提取,得到多个历史话题;
采用预置Attention算法对提取的历史话题进行权重赋值,得到历史话题分布权重,并调用预置归一化函数,对所述各历史对话语句之间相关度和所述历史话题分布权重进行归一化运算,得到历史多轮对话信息;
将所述第二词向量输入所述BTM模型进行当前对话语境下的话题提取,并调用预置捕捉函数对提取到的当前话题进行信息捕捉,得到当前语境下的话题分布信息;
拼接当前语境下的话题分布信息和所述历史多轮对话信息,得到多轮对话融合信息,并将所述多轮对话融合信息输入预置对话文本生成器进行解码,生成与当前对话文本构成的新一轮对话文本。
进一步地,为实现上述目的,本申请还提供一种计算机可读存储介质,所述计算机可读存储介质可以是非易失性,也可以是易失性,所述计算机可读存储介质中存储有指令,当其在计算机上运行时,使得计算机执行上述的多轮对话文本生成方法的步骤,包括:
获取历史多轮对话文本并进行词向量转换,得到第一词向量,以及获取当前对话文本并进行词向量转换,得到第二词向量;
将所述第一词向量输入预置HRED模型进行信息提取,得到各历史对话语句之间相关度,以及将所述第一词向量输入预置BTM模型进行话题提取,得到多个历史话题;
采用预置Attention算法对提取的历史话题进行权重赋值,得到历史话题分布权重,并调用预置归一化函数,对所述各历史对话语句之间相关度和所述历史话题分布权重进行归一化运算,得到历史多轮对话信息;
将所述第二词向量输入所述BTM模型进行当前对话语境下的话题提取,并调用预置捕捉函数对提取到的当前话题进行信息捕捉,得到当前语境下的话题分布信息;
拼接当前语境下的话题分布信息和所述历史多轮对话信息,得到多轮对话融合信息,并将所述多轮对话融合信息输入预置对话文本生成器进行解码,生成与当前对话文本构成的新一轮对话文本。
本申请提供的技术方案中,鉴于现有多轮对话文本生成模型在面对多轮对话话题发生迁移时的表现效果不佳,因此采用多个机器学习模型对话题进行捕捉,首先利用HRED模型来提取历史多轮对话文本中的上下文信息,得到各历史对话语句之间相关度,再利用BTM模型与Attention算法来对话题进行提取与强化,得到历史话题分布权重和当前语境下的话题分布信息,并将相关度、历史话题分布权重和当前语境下的话题分布信息输入文本生成器中生成下文。本申请能更精准的找到文本应该由哪些话题来生成,从而更精确地生成后文,使得文本更符合多轮对话的逻辑。
附图说明
图1为本申请实施例中多轮对话文本生成方法的第一个实施例示意图;
图2为本申请实施例中多轮对话文本生成方法的第二个实施例示意图;
图3为本申请实施例中多轮对话文本生成装置的一个实施例示意图;
图4为本申请实施例中多轮对话文本生成设备的一个实施例示意图。
具体实施方式
本申请实施例提供了一种多轮对话文本生成方法、装置、设备及存储介质。本申请的说明书和权利要求书及上述附图中的术语“第一”、“第二”、“第三”、“第四”等(如果存在)是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。应该理解这样使用的数据在适当情况下可以互换,以便这里描述的实施例能够以除了在这里图示或描述 的内容以外的顺序实施。此外,术语“包括”或“具有”及其任何变形,意图在于覆盖不排他的包含,例如,包含了一系列步骤或单元的过程、方法、系统、产品或设备不必限于清楚地列出的那些步骤或单元,而是可包括没有清楚地列出的或对于这些过程、方法、产品或设备固有的其它步骤或单元。
为便于理解,下面对本申请实施例的具体流程进行描述,请参阅图1,本申请实施例中多轮对话文本生成方法的第一个实施例包括:
101、获取历史多轮对话文本并进行词向量转换,得到第一词向量,以及获取当前对话文本并进行词向量转换,得到第二词向量;
可以理解的是,本申请的执行主体可以为多轮对话文本生成装置,还可以是终端或者服务器,具体此处不做限定。本申请实施例以服务器为执行主体为例进行说明。
本实施例中,历史多轮对话文本包括最后一轮对话之前的所有历史对话的文本,当前对话文本包括最后一轮对话的文本。
例如:我爱篮球。我爱祖国。我爱北京。历史多轮对话文本为:我爱篮球。我爱祖国。当前对话文本为:我爱北京。
本实施例中,词向量是将文本中的词语表示为向量,利用one-hot representation把每个词表示为一个长向量。这个向量的维度是词表大小,向量中只有一个维度的值为1,其余维度为0,这个维度就代表了当前的词。
例如:苹果[0,0,0,1,0,0,0,0,0,……]。
102、将所述第一词向量输入预置HRED模型进行信息提取,得到各历史对话语句之间相关度,以及将所述第一词向量输入预置BTM模型进行话题提取,得到多个历史话题;
本实施例中,HRED模型包括Word RNN网络和Sentence RNN网络,Word RNN网络用于提取多个句子信息,Sentence RNN网络用于提取多轮对话中句子与句子之间的相关信息得到各历史对话语句之间相关度。
本实施例中,BTM模型包括α,β,θ,
Figure PCTCN2021083336-appb-000001
w 1,w 2,其中,α和β是给定的超参数,θ为主题分布,
Figure PCTCN2021083336-appb-000002
为词分布,w 1代表单词1,w 2代表单词2,z表示主题z。BTM模型是基于词对的主题模型,通过最大化在不同的话题中提取词对的概率,实现对短文本的主体分布预测。
可选的,在一实施例中,所述HRED模型包括Word RNN网络和Sentence RNN网络,所述将所述第一词向量输入预置HRED模型进行信息提取,得到各历史对话语句之间相关度包括:
将所述第一词向量输入所述Word RNN网络,通过所述Word RNN网络对所述第一词向量进行语句信息提取,得到各历史对话语句信息;
将所述各历史对话语句信息输入所述Sentence RNN网络,通过所述Sentence RNN网络对所述各历史对话语句信息进行相关度计算,得到各历史对话语句之间相关度。
本实施例中,Word RNN网络主要用于对输入句子进行编码,编码整个对话的状态、 意图等对话层面的信息,RNN的隐藏层向量就可以记住之前的对话信息,Word RNN网络采用双向RNN可以有效地引入额外的短期依赖性。然后,将该编码了之前对话信息的向量作为Sentence RNN网络的输入向量,使得在解码过程中除了使用回答句子本身信息还会结合对话上下文信息。
可选的,在一实施例中,所述将所述第一词向量输入预置BTM模型进行话题提取,得到多个历史话题包括:
将所述第一词向量输入预置BTM模型,通过所述BTM模型对所述第一词向量进行topic-Biterm概率分布计算,得到第一话题分布信息,其中,所述第一话题分布信息包括多个历史话题。
本实施例中,对所述第一词向量进行topic-Biterm概率分布计算,得到第一话题分布信息,其中,所述第一话题分布信息包括多个历史话题,topic-Biterm概率分布计算,首先从词向量中抽取所有的二元词组,即抽取Biterm对。例如:“I visit apple store”,去除I停用词后,抽取的二元词组包括{visit apple},{visit store},{apple store}。对于每个话题z抽取话题-词分布
Figure PCTCN2021083336-appb-000003
从Dirichlet先验中获取话题的分布θ,对于二元词组集合B中的每个二元词b:抽取一个主题z,抽取两个单词w 1和w 2,最后得到第一话题分布信息包括多个历史话题。
103、采用预置Attention算法对提取的历史话题进行权重赋值,得到历史话题分布权重,并调用预置归一化函数,对所述各历史对话语句之间相关度和所述历史话题分布权重进行归一化运算,得到历史多轮对话信息;
本实施例中,Attention算法为:
Figure PCTCN2021083336-appb-000004
其中,α i表示相似度,c i表示语境数据,t i表示句子i的主题,E(t i,c i)表示对于主题t i的词分布和投影到语境c i的词分布之和。将求得的多个相似度进行softmax运算,得到历史话题分布权重,softmax运算为:
Figure PCTCN2021083336-appb-000005
其中,α′ i为历史话题分布权重,α i为相似度,α j为相似度的和。
本实施例中,归一化函数为:
Figure PCTCN2021083336-appb-000006
其中,S N为历史多轮对话信息,N为共有N句话,α′ i为历史话题分布权重,s i为各历史对话语句之间相关度。
可选的,在一实施例中,所述采用预置Attention算法对提取的历史话题进行权重赋 值,得到历史话题分布权重包括:
采用预置Attention算法,计算所述第一话题分布信息中各历史话题与历史语境的相似度;
对所述相似度进行Softmax运算,得到历史话题分布权重。
本实施例中,将Attention机制运用在BTM模型提取的话题分布和HRED模型提取的句信息上,从而获取话题在其中的比重,得到话题转移的信息,从而更精确地生成后文,使得文本更符合多轮对话的逻辑。
可选的,在一实施例中,所述调用预置归一化函数,对所述各历史对话语句之间相关度和所述历史话题分布权重进行归一化运算,得到历史多轮对话信息包括:
对所述各历史对话语句之间相关度和所述历史话题分布权重进行乘积运算,得到历史多轮对话文本中各轮对话的历史信息;
调用预置归一化函数对所述历史多轮对话文本中各轮对话的历史信息进行求和运算,得到历史多轮对话信息。
本实施例中,S N因为含括了第i句的词汇信息,涵盖了第i句话的主题分布情况,将两者结合就能得到第i句的信息,而对所有句子进行求和就能得到之前多轮对话的所有语句的信息。
104、将所述第二词向量输入所述BTM模型进行当前对话语境下的话题提取,并调用预置捕捉函数对提取到的当前话题进行信息捕捉,得到当前语境下的话题分布信息;
本实施例中,利用BTM模型提取当前对话语境下的话题,因为输入只有当前语境下的对话文本,所以输出为当前语境下的话题。捕捉函数为E(t N,c N),表示第N个句子的一个综合分布值,因为是对当前对话语境求得综合分布值,所以得到当前语境下的话题分布信息。
可选的,在一实施例中,所述将所述第二词向量输入所述BTM模型进行当前对话语境下的话题提取,并调用预置捕捉函数对提取到的当前话题进行信息捕捉,得到当前语境下的话题分布信息包括:
将所述第二词向量输入预置BTM模型,通过所述BTM模型对所述第二词向量进行topic-Biterm概率分布计算,得到第二话题分布信息;
采用预置捕捉函数对所述第二话题分布信息进行信息捕捉,得到当前语境下的话题分布信息。
本实施例中,对所述第二词向量进行topic-Biterm概率分布计算,得到第二话题分布信息,其中,所述第二话题分布信息包括多个历史话题,topic-Biterm概率分布计算,首先从词向量中抽取所有的二元词组,即抽取Biterm对。例如:“我爱北京”,去除“我”停用词后,抽取的二元词组包括{爱北},{北京},{爱京}。对于每个话题z抽取话题-词分布,从Dirichlet先验中获取话题的分布,对于二元词组集合B中的每个二元词b:抽取一个主题z,抽取两个单词w 1和w 2,最后得到第二话题分布信息。
本实施例中,捕捉函数计算出E(t N,c N),得到第N个句子的一个综合分布值,即为当前语境下的话题分布信息。
105、拼接当前语境下的话题分布信息和所述历史多轮对话信息,得到多轮对话融合信息,并将所述多轮对话融合信息输入预置对话文本生成器进行解码,生成与当前对话文本构成的新一轮对话文本。
本实施例中,拼接当前语境下的话题分布信息和所述历史多轮对话信息,得到多轮对话融合信息。
例如:将两个分离的信息拼接成一整个。如:[[1,3,4],[1,1,1]]和[2,1,3]拼接为[[1,3,4],[1,1,1],[2,1,3]]。
本实施例中,对话文本生成器包括Self-attention层、Encoder-decoder attention层和FNN层,文本生成器根据FNN层输出的词概率分布,将所述词概率分布中概率值最大的词作为生成词,并对所述生成词进行拼接得到与当前对话文本构成的新一轮对话文本。
本申请实施例中,鉴于现有多轮对话文本生成模型在面对多轮对话话题发生迁移时的表现效果不佳,因此采用多个机器学习模型对话题进行捕捉,首先利用HRED模型来提取历史多轮对话文本中的上下文信息,得到各历史对话语句之间相关度,再利用BTM模型与Attention算法来对话题进行提取与强化,得到历史话题分布权重和当前语境下的话题分布信息,并将相关度、历史话题分布权重和当前语境下的话题分布信息输入文本生成器中生成下文。本申请能更精准的找到文本应该由哪些话题来生成,从而更精确地生成后文,使得文本更符合多轮对话的逻辑。
请参阅图2,本申请实施例中多轮对话文本生成方法的第四个实施例包括:
201、获取历史多轮对话文本并进行词向量转换,得到第一词向量,以及获取当前对话文本并进行词向量转换,得到第二词向量;
202、将所述第一词向量输入预置HRED模型进行信息提取,得到各历史对话语句之间相关度,以及将所述第一词向量输入预置BTM模型进行话题提取,得到多个历史话题;
203、采用预置Attention算法对提取的历史话题进行权重赋值,得到历史话题分布权重,并调用预置归一化函数,对所述各历史对话语句之间相关度和所述历史话题分布权重进行归一化运算,得到历史多轮对话信息;
204、将所述第二词向量输入所述BTM模型进行当前对话语境下的话题提取,并调用预置捕捉函数对提取到的当前话题进行信息捕捉,得到当前语境下的话题分布信息;
205、拼接当前语境下的话题分布信息和所述历史多轮对话信息,得到多轮对话融合信息;
206、将所述多轮对话融合信息输入所述Self-attention层进行Mask转换,得到query向量;
本实施例中,Self-attention层是将句子中的每一个词都和该句子当中的所有词进 行一个attention计算,其作用是学习句子内部的词依赖关系,获取词的内部结构。因此,Self-attention计算的信息来源都是来源于其句子本身。Mask在进行attention的计算过程中,通过Mask的操作,使得补全位置上的值成为一个非常大的负数,以此操作就相当于把补全位置的无用信息给遮蔽掉了,从而得到query向量。
207、将所述query向量输入所述Encoder-decoder attention层进行特征提取,得到特征向量;
本实施例中,Encoder-decoder attention层中的Encoder由6个相同的层堆叠在一起,每一层又有两个支层,第一个支层是一个多头的自注意机制,第二个支层是一个简单的全连接前馈网络,在两个支层外面都添加了一个residual的连接,然后进行了layer nomalization的操作。decoder也是堆叠了六个相同的层。不过每层除了Encoder中那两个支层,解码器还加入了第三个支层,decoder用了residual以及layer normalization。Encoder-decoder attention层用于文本生成任务,表现极好,可并行化,并且大大减少训练时间。通过Encoder-decoder对query向量进行特征提取,得到特征向量。
208、将所述特征向量输入所述FNN层进行概率分布运算,得到词概率分布;
本实施例中,FNN层为多次线性变换并通过激活函数进行非线性变换。激活函数在这里主要起到非线性变换的作用。虽然每一层网络的进行的非线性变换相对简单,但是经过多次变换后产生的非线性决策曲面将变得非常复杂,从而可以胜任复杂的分类和回归问题,本实施例FNN层通过对特征向量进行概率分布运算,得到词概率分布。
209、将所述词概率分布中概率值最大的词作为生成词,并对所述生成词进行拼接得到与当前对话文本构成的新一轮对话文本。
本实施例中,根据词概率分布中概率最大的词作为生成词,随后将这些词进行拼接就是最后生成的文本。例如:词概率分布中概率最大的词分别是:我,也,爱,北,京。即生成当前对话文本构成的新一轮对话文本为:我也爱北京。
本申请实施例中,文本生成器的作用是将历史多轮对话信息和当前语境下的话题分布信息进行解码操作,从而生成当前对话文本构成的新一轮对话文本,依据历史多轮对话信息和当前语境下的话题分布信息来进行文本生成,增加了生成文本的准确度。
上面对本申请实施例中多轮对话文本生成方法进行了描述,下面对本申请实施例中多轮对话文本生成装置进行描述,请参阅图3,本申请实施例中多轮对话文本生成装置一个实施例包括:
获取模块301,用于获取历史多轮对话文本并进行词向量转换,得到第一词向量,以及获取当前对话文本并进行词向量转换,得到第二词向量;
提取模块302,用于将所述第一词向量输入预置HRED模型进行信息提取,得到各历史对话语句之间相关度,以及将所述第一词向量输入预置BTM模型进行话题提取,得到多个历史话题;
处理模块303,用于采用预置Attention算法对提取的历史话题进行权重赋值,得到历史话题分布权重,并调用预置归一化函数,对所述各历史对话语句之间相关度和所述历史话题分布权重进行归一化运算,得到历史多轮对话信息;
捕捉模块304,用于将所述第二词向量输入所述BTM模型进行当前对话语境下的话题提取,并调用预置捕捉函数对提取到的当前话题进行信息捕捉,得到当前语境下的话题分布信息;
生成模块305,用于拼接当前语境下的话题分布信息和所述历史多轮对话信息,得到多轮对话融合信息,并将所述多轮对话融合信息输入预置对话文本生成器进行解码,生成与当前对话文本构成的新一轮对话文本。
可选的,在一实施例中,所述HRED模型包括Word RNN网络和Sentence RNN网络,所述提取模块302包括第一提取单元3021,所述第一提取单元3021具体用于:
将所述第一词向量输入所述Word RNN网络,通过所述Word RNN网络对所述第一词向量进行语句信息提取,得到各历史对话语句信息;
将所述各历史对话语句信息输入所述Sentence RNN网络,通过所述Sentence RNN网络对所述各历史对话语句信息进行相关度计算,得到各历史对话语句之间相关度。
可选的,在一实施例中,所述提取模块302包括第二提取单元3022,所述第二提取单元3022具体用于:
将所述第一词向量输入预置BTM模型,通过所述BTM模型对所述第一词向量进行topic-Biterm概率分布计算,得到第一话题分布信息,其中,所述第一话题分布信息包括多个历史话题。
可选的,在一实施例中,所述处理模块303包括第一处理单元3031,所述第一处理单元3031具体用于:
采用预置Attention算法,计算所述第一话题分布信息中各历史话题与历史语境的相似度;对所述相似度进行Softmax运算,得到历史话题分布权重。
可选的,在一实施例中,所述处理模块303包括第二处理单元3032,所述第二处理单元3032具体用于
对所述各历史对话语句之间相关度和所述历史话题分布权重进行乘积运算,得到历史多轮对话文本中各轮对话的历史信息;
调用预置归一化函数对所述历史多轮对话文本中各轮对话的历史信息进行求和运算,得到历史多轮对话信息。
可选的,在一实施例中,所述捕捉模块304具体用于:
将所述第二词向量输入预置BTM模型,通过所述BTM模型对所述第二词向量进行topic-Biterm概率分布计算,得到第二话题分布信息;
采用预置捕捉函数对所述第二话题分布信息进行信息捕捉,得到当前语境下的话题分布信息。
可选的,在一实施例中,所述对话文本生成器包括Self-attention层、Encoder-decoder attention层和FNN层,所述生成模块305包括:
拼接单元3051,用于拼接当前语境下的话题分布信息和所述历史多轮对话信息,得到多轮对话融合信息;
生成单元3052,用于将所述多轮对话融合信息输入所述Self-attention层进行Mask转换,得到query向量;将所述query向量输入所述Encoder-decoder attention层进行特征提取,得到特征向量;将所述特征向量输入所述FNN层进行概率分布运算,得到词概率分布;将所述词概率分布中概率值最大的词作为生成词,并对所述生成词进行拼接得到与当前对话文本构成的新一轮对话文本。
本申请实施例中,鉴于现有多轮对话文本生成模型在面对多轮对话话题发生迁移时的表现效果不佳,因此采用多个机器学习模型对话题进行捕捉,首先利用HRED模型来提取历史多轮对话文本中的上下文信息,得到各历史对话语句之间相关度,再利用BTM模型与Attention算法来对话题进行提取与强化,得到历史话题分布权重和当前语境下的话题分布信息,并将相关度、历史话题分布权重和当前语境下的话题分布信息输入文本生成器中生成下文。本申请能更精准的找到文本应该由哪些话题来生成,从而更精确地生成后文,使得文本更符合多轮对话的逻辑。
上面图3从模块化功能实体的角度对本申请实施例中的多轮对话文本生成装置进行详细描述,下面从硬件处理的角度对本申请实施例中多轮对话文本生成设备进行详细描述。
图4是本申请实施例提供的一种多轮对话文本生成设备的结构示意图,该多轮对话文本生成设备400可因配置或性能不同而产生比较大的差异,可以包括一个或一个以上处理器(central processing units,CPU)410(例如,一个或一个以上处理器)和存储器420,一个或一个以上存储应用程序433或数据432的存储介质430(例如一个或一个以上海量存储设备)。其中,存储器420和存储介质430可以是短暂存储或持久存储。存储在存储介质430的程序可以包括一个或一个以上模块(图示没标出),每个模块可以包括对多轮对话文本生成设备400中的一系列指令操作。更进一步地,处理器410可以设置为与存储介质430通信,在多轮对话文本生成设备400上执行存储介质430中的一系列指令操作。
多轮对话文本生成设备400还可以包括一个或一个以上电源440,一个或一个以上有线或无线网络接口450,一个或一个以上输入输出接口460,和/或,一个或一个以上操作系统431,例如Windows Serve,Mac OS X,Unix,Linux,FreeBSD等等。本领域技术人员可以理解,图4示出的多轮对话文本生成设备结构并不构成对多轮对话文本生成设备的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置。
本申请还提供一种多轮对话文本生成设备,所述多轮对话文本生成设备包括存储器和处理器,存储器中存储有计算机可读指令,计算机可读指令被处理器执行时,使得处理器 执行上述各实施例中的所述多轮对话文本生成方法的步骤。
本申请还提供一种计算机可读存储介质,该计算机可读存储介质可以为非易失性计算机可读存储介质,该计算机可读存储介质也可以为易失性计算机可读存储介质,所述计算机可读存储介质中存储有指令,当所述指令在计算机上运行时,使得计算机执行所述多轮对话文本生成方法的步骤。
所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述的系统,装置和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。
所述集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本申请各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(read-only memory,ROM)、随机存取存储器(random access memory,RAM)、磁碟或者光盘等各种可以存储程序代码的介质。
以上所述,以上实施例仅用以说明本申请的技术方案,而非对其限制;尽管参照前述实施例对本申请进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本申请各实施例技术方案的精神和范围。

Claims (20)

  1. 一种多轮对话文本生成方法,其中,所述多轮对话文本生成方法包括:
    获取历史多轮对话文本并进行词向量转换,得到第一词向量,以及获取当前对话文本并进行词向量转换,得到第二词向量;
    将所述第一词向量输入预置HRED模型进行信息提取,得到各历史对话语句之间相关度,以及将所述第一词向量输入预置BTM模型进行话题提取,得到多个历史话题;
    采用预置Attention算法对提取的历史话题进行权重赋值,得到历史话题分布权重,并调用预置归一化函数,对所述各历史对话语句之间相关度和所述历史话题分布权重进行归一化运算,得到历史多轮对话信息;
    将所述第二词向量输入所述BTM模型进行当前对话语境下的话题提取,并调用预置捕捉函数对提取到的当前话题进行信息捕捉,得到当前语境下的话题分布信息;
    拼接当前语境下的话题分布信息和所述历史多轮对话信息,得到多轮对话融合信息,并将所述多轮对话融合信息输入预置对话文本生成器进行解码,生成与当前对话文本构成的新一轮对话文本。
  2. 根据权利要求1所述的多轮对话文本生成方法,其中,所述HRED模型包括Word RNN网络和Sentence RNN网络,所述将所述第一词向量输入预置HRED模型进行信息提取,得到各历史对话语句之间相关度包括:
    将所述第一词向量输入所述Word RNN网络,通过所述Word RNN网络对所述第一词向量进行语句信息提取,得到各历史对话语句信息;
    将所述各历史对话语句信息输入所述Sentence RNN网络,通过所述Sentence RNN网络对所述各历史对话语句信息进行相关度计算,得到各历史对话语句之间相关度。
  3. 根据权利要求1所述的多轮对话文本生成方法,其中,所述将所述第一词向量输入预置BTM模型进行话题提取,得到多个历史话题包括:
    将所述第一词向量输入预置BTM模型,通过所述BTM模型对所述第一词向量进行topic-Biterm概率分布计算,得到第一话题分布信息,其中,所述第一话题分布信息包括多个历史话题。
  4. 根据权利要求3所述的多轮对话文本生成方法,其中,所述采用预置Attention算法对提取的历史话题进行权重赋值,得到历史话题分布权重包括:
    采用预置Attention算法,计算所述第一话题分布信息中各历史话题与历史语境的相似度;
    对所述相似度进行Softmax运算,得到历史话题分布权重。
  5. 根据权利要求1或3所述的多轮对话文本生成方法,其中,所述调用预置归一化函数,对所述各历史对话语句之间相关度和所述历史话题分布权重进行归一化运算,得到历史多轮对话信息包括:
    对所述各历史对话语句之间相关度和所述历史话题分布权重进行乘积运算,得到历史多轮对话文本中各轮对话的历史信息;
    调用预置归一化函数对所述历史多轮对话文本中各轮对话的历史信息进行求和运算,得到历史多轮对话信息。
  6. 根据权利要求1所述的多轮对话文本生成方法,其中,所述将所述第二词向量输入所述BTM模型进行当前对话语境下的话题提取,并调用预置捕捉函数对提取到的当前话题进行信息捕捉,得到当前语境下的话题分布信息包括:
    将所述第二词向量输入预置BTM模型,通过所述BTM模型对所述第二词向量进行topic-Biterm概率分布计算,得到第二话题分布信息;
    采用预置捕捉函数对所述第二话题分布信息进行信息捕捉,得到当前语境下的话题分布信息。
  7. 根据权利要求1或6所述的多轮对话文本生成方法,其中,所述对话文本生成器包括Self-attention层、Encoder-decoder attention层和FNN层,所述将所述多轮对话融合信息输入预置对话文本生成器进行解码,生成与当前对话文本构成的新一轮对话文本包括:
    将所述多轮对话融合信息输入所述Self-attention层进行Mask转换,得到query向量;
    将所述query向量输入所述Encoder-decoder attention层进行特征提取,得到特征向量;
    将所述特征向量输入所述FNN层进行概率分布运算,得到词概率分布;
    将所述词概率分布中概率值最大的词作为生成词,并对所述生成词进行拼接得到与当前对话文本构成的新一轮对话文本。
  8. 一种多轮对话文本生成设备,其中,所述多轮对话文本生成设备包括:存储器和至少一个处理器,所述存储器中存储有指令;
    所述至少一个处理器调用所述存储器中的所述指令,以使得所述多轮对话文本生成设备执行如下所述的多轮对话文本生成方法的步骤:
    获取历史多轮对话文本并进行词向量转换,得到第一词向量,以及获取当前对话文本并进行词向量转换,得到第二词向量;
    将所述第一词向量输入预置HRED模型进行信息提取,得到各历史对话语句之间相关度,以及将所述第一词向量输入预置BTM模型进行话题提取,得到多个历史话题;
    采用预置Attention算法对提取的历史话题进行权重赋值,得到历史话题分布权重,并调用预置归一化函数,对所述各历史对话语句之间相关度和所述历史话题分布权重进行归一化运算,得到历史多轮对话信息;
    将所述第二词向量输入所述BTM模型进行当前对话语境下的话题提取,并调用预置捕捉函数对提取到的当前话题进行信息捕捉,得到当前语境下的话题分布信息;
    拼接当前语境下的话题分布信息和所述历史多轮对话信息,得到多轮对话融合信息,并将所述多轮对话融合信息输入预置对话文本生成器进行解码,生成与当前对话文本构成的新一轮对话文本。
  9. 根据权利要求8所述的多轮对话文本生成设备,其中,所述多轮对话文本生成程序被所述处理器执行所述HRED模型包括Word RNN网络和Sentence RNN网络,所述将所述第一词向量输入预置HRED模型进行信息提取,得到各历史对话语句之间相关度的步骤时,还执行以下步骤:
    将所述第一词向量输入所述Word RNN网络,通过所述Word RNN网络对所述第一词向量进行语句信息提取,得到各历史对话语句信息;
    将所述各历史对话语句信息输入所述Sentence RNN网络,通过所述Sentence RNN网络对所述各历史对话语句信息进行相关度计算,得到各历史对话语句之间相关度。
  10. 根据权利要求8所述的多轮对话文本生成设备,其中,所述多轮对话文本生成程序被所述处理器执行所述将所述第一词向量输入预置BTM模型进行话题提取,得到多个历史话题的步骤时,还执行以下步骤:
    将所述第一词向量输入预置BTM模型,通过所述BTM模型对所述第一词向量进行topic-Biterm概率分布计算,得到第一话题分布信息,其中,所述第一话题分布信息包括多个历史话题。
  11. 根据权利要求10所述的多轮对话文本生成设备,其中,所述多轮对话文本生成程序被所述处理器执行所述采用预置Attention算法对提取的历史话题进行权重赋值,得到历史话题分布权重的步骤时,还执行以下步骤:
    采用预置Attention算法,计算所述第一话题分布信息中各历史话题与历史语境的相似度;
    对所述相似度进行Softmax运算,得到历史话题分布权重。
  12. 根据权利要求8或10所述的多轮对话文本生成设备,其中,所述多轮对话文本生成程序被所述处理器执行所述调用预置归一化函数,对所述各历史对话语句之间相关度和所述历史话题分布权重进行归一化运算,得到历史多轮对话信息的步骤时,还执行以下步骤:
    对所述各历史对话语句之间相关度和所述历史话题分布权重进行乘积运算,得到历史多轮对话文本中各轮对话的历史信息;
    调用预置归一化函数对所述历史多轮对话文本中各轮对话的历史信息进行求和运算,得到历史多轮对话信息。
  13. 根据权利要求8所述的多轮对话文本生成设备,其中,所述多轮对话文本生成程序被所述处理器执行所述将所述第二词向量输入所述BTM模型进行当前对话语境下的话题提取,并调用预置捕捉函数对提取到的当前话题进行信息捕捉,得到当前语境下的话题分布信息的步骤时,还执行以下步骤:
    将所述第二词向量输入预置BTM模型,通过所述BTM模型对所述第二词向量进行topic-Biterm概率分布计算,得到第二话题分布信息;
    采用预置捕捉函数对所述第二话题分布信息进行信息捕捉,得到当前语境下的话题分布信息。
  14. 一种计算机可读存储介质,所述计算机可读存储介质上存储有指令,其中,所述指令被处理器执行时实现如下所述的多轮对话文本生成方法的步骤:
    获取历史多轮对话文本并进行词向量转换,得到第一词向量,以及获取当前对话文本并进行词向量转换,得到第二词向量;
    将所述第一词向量输入预置HRED模型进行信息提取,得到各历史对话语句之间相关度,以及将所述第一词向量输入预置BTM模型进行话题提取,得到多个历史话题;
    采用预置Attention算法对提取的历史话题进行权重赋值,得到历史话题分布权重,并调用预置归一化函数,对所述各历史对话语句之间相关度和所述历史话题分布权重进行归一化运算,得到历史多轮对话信息;
    将所述第二词向量输入所述BTM模型进行当前对话语境下的话题提取,并调用预置捕捉函数对提取到的当前话题进行信息捕捉,得到当前语境下的话题分布信息;
    拼接当前语境下的话题分布信息和所述历史多轮对话信息,得到多轮对话融合信息,并将所述多轮对话融合信息输入预置对话文本生成器进行解码,生成与当前对话文本构成的新一轮对话文本。
  15. 根据权利要求14所述的计算机可读存储介质,其中,所述多轮对话文本生成程序被处理器执行所述HRED模型包括Word RNN网络和Sentence RNN网络,所述将所述第一词向量输入预置HRED模型进行信息提取,得到各历史对话语句之间相关度的步骤时,还执行如下步骤:
    将所述第一词向量输入所述Word RNN网络,通过所述Word RNN网络对所述第一词向量进行语句信息提取,得到各历史对话语句信息;
    将所述各历史对话语句信息输入所述Sentence RNN网络,通过所述Sentence RNN网络对所述各历史对话语句信息进行相关度计算,得到各历史对话语句之间相关度。
  16. 根据权利要求14所述的计算机可读存储介质,其中,所述多轮对话文本生成程序被处理器执行所述将所述第一词向量输入预置BTM模型进行话题提取,得到多个历史话题的步骤时,还执行如下步骤:
    将所述第一词向量输入预置BTM模型,通过所述BTM模型对所述第一词向量进行topic-Biterm概率分布计算,得到第一话题分布信息,其中,所述第一话题分布信息包括多个历史话题。
  17. 根据权利要求16所述的计算机可读存储介质,其中,所述多轮对话文本生成程序被处理器执行所述采用预置Attention算法对提取的历史话题进行权重赋值,得到历史话题分布权重的步骤时,还执行如下步骤:
    采用预置Attention算法,计算所述第一话题分布信息中各历史话题与历史语境的相似度;
    对所述相似度进行Softmax运算,得到历史话题分布权重。
  18. 根据权利要求14或16所述的计算机可读存储介质,其中,所述多轮对话文本生成程序被处理器执行所述调用预置归一化函数,对所述各历史对话语句之间相关度和所述历史话题分布权重进行归一化运算,得到历史多轮对话信息的步骤时,还执行如下步骤:
    对所述各历史对话语句之间相关度和所述历史话题分布权重进行乘积运算,得到历史多轮对话文本中各轮对话的历史信息;
    调用预置归一化函数对所述历史多轮对话文本中各轮对话的历史信息进行求和运算,得到历史多轮对话信息。
  19. 根据权利要求14所述的计算机可读存储介质,其中,所述多轮对话文本生成程序被处理器执行所述将所述第二词向量输入所述BTM模型进行当前对话语境下的话题提取,并调用预置捕捉函数对提取到的当前话题进行信息捕捉,得到当前语境下的话题分布信息的步骤时,还执行如下步骤:
    将所述第二词向量输入预置BTM模型,通过所述BTM模型对所述第二词向量进行topic-Biterm概率分布计算,得到第二话题分布信息;
    采用预置捕捉函数对所述第二话题分布信息进行信息捕捉,得到当前语境下的话题分布信息。
  20. 一种多轮对话文本生成装置,其中,所述多轮对话文本生成装置包括:
    获取模块,用于获取历史多轮对话文本并进行词向量转换,得到第一词向量,以及获取当前对话文本并进行词向量转换,得到第二词向量;
    提取模块,用于将所述第一词向量输入预置HRED模型进行信息提取,得到各历史对话语句之间相关度,以及将所述第一词向量输入预置BTM模型进行话题提取,得到多个历史话题;
    处理模块,用于采用预置Attention算法对提取的历史话题进行权重赋值,得到历史话题分布权重,并调用预置归一化函数,对所述各历史对话语句之间相关度和所述历史话题分布权重进行归一化运算,得到历史多轮对话信息;
    捕捉模块,用于将所述第二词向量输入所述BTM模型进行当前对话语境下的话题提取,并调用预置捕捉函数对提取到的当前话题进行信息捕捉,得到当前语境下的话题分布信息;
    生成模块,用于拼接当前语境下的话题分布信息和所述历史多轮对话信息,得到多轮对话融合信息,并将所述多轮对话融合信息输入预置对话文本生成器进行解码,生成与当前对话文本构成的新一轮对话文本。
PCT/CN2021/083336 2020-12-10 2021-03-26 多轮对话文本生成方法、装置、设备及存储介质 WO2022121161A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202011432574.8A CN112527986A (zh) 2020-12-10 2020-12-10 多轮对话文本生成方法、装置、设备及存储介质
CN202011432574.8 2020-12-10

Publications (1)

Publication Number Publication Date
WO2022121161A1 true WO2022121161A1 (zh) 2022-06-16

Family

ID=74998773

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/083336 WO2022121161A1 (zh) 2020-12-10 2021-03-26 多轮对话文本生成方法、装置、设备及存储介质

Country Status (2)

Country Link
CN (1) CN112527986A (zh)
WO (1) WO2022121161A1 (zh)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115169367A (zh) * 2022-09-06 2022-10-11 杭州远传新业科技股份有限公司 对话生成方法及装置、存储介质
CN116628179A (zh) * 2023-05-30 2023-08-22 道有道科技集团股份公司 一种用户操作数据的可视化与人机交互推荐方法

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112527986A (zh) * 2020-12-10 2021-03-19 平安科技(深圳)有限公司 多轮对话文本生成方法、装置、设备及存储介质
CN113761157B (zh) * 2021-05-28 2024-05-24 腾讯科技(深圳)有限公司 应答语句生成方法和装置
CN113672714A (zh) * 2021-08-20 2021-11-19 上海大参林医疗健康科技有限公司 一种多轮对话装置及方法

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106776578A (zh) * 2017-01-03 2017-05-31 竹间智能科技(上海)有限公司 用于提升对话系统对话性能的方法及装置
CN107480143A (zh) * 2017-09-12 2017-12-15 山东师范大学 基于上下文相关性的对话话题分割方法和系统
CN110032633A (zh) * 2019-04-17 2019-07-19 腾讯科技(深圳)有限公司 多轮对话处理方法、装置和设备
CN110222155A (zh) * 2019-06-13 2019-09-10 北京百度网讯科技有限公司 知识选择策略的对话生成方法、装置以及终端
US20200090651A1 (en) * 2018-09-17 2020-03-19 Adobe Inc. Generating dialogue responses in end-to-end dialogue systems utilizing a context-dependent additive recurrent neural network
CN112527986A (zh) * 2020-12-10 2021-03-19 平安科技(深圳)有限公司 多轮对话文本生成方法、装置、设备及存储介质

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106776578A (zh) * 2017-01-03 2017-05-31 竹间智能科技(上海)有限公司 用于提升对话系统对话性能的方法及装置
CN107480143A (zh) * 2017-09-12 2017-12-15 山东师范大学 基于上下文相关性的对话话题分割方法和系统
US20200090651A1 (en) * 2018-09-17 2020-03-19 Adobe Inc. Generating dialogue responses in end-to-end dialogue systems utilizing a context-dependent additive recurrent neural network
CN110032633A (zh) * 2019-04-17 2019-07-19 腾讯科技(深圳)有限公司 多轮对话处理方法、装置和设备
CN110222155A (zh) * 2019-06-13 2019-09-10 北京百度网讯科技有限公司 知识选择策略的对话生成方法、装置以及终端
CN112527986A (zh) * 2020-12-10 2021-03-19 平安科技(深圳)有限公司 多轮对话文本生成方法、装置、设备及存储介质

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115169367A (zh) * 2022-09-06 2022-10-11 杭州远传新业科技股份有限公司 对话生成方法及装置、存储介质
CN115169367B (zh) * 2022-09-06 2022-12-09 杭州远传新业科技股份有限公司 对话生成方法及装置、存储介质
CN116628179A (zh) * 2023-05-30 2023-08-22 道有道科技集团股份公司 一种用户操作数据的可视化与人机交互推荐方法
CN116628179B (zh) * 2023-05-30 2023-12-22 道有道科技集团股份公司 一种用户操作数据的可视化与人机交互推荐方法

Also Published As

Publication number Publication date
CN112527986A (zh) 2021-03-19

Similar Documents

Publication Publication Date Title
WO2022121161A1 (zh) 多轮对话文本生成方法、装置、设备及存储介质
CN112000791B (zh) 一种电机故障知识抽取系统及方法
WO2021164199A1 (zh) 基于多粒度融合模型的中文句子语义智能匹配方法及装置
Rastogi et al. Scalable multi-domain dialogue state tracking
US10437929B2 (en) Method and system for processing an input query using a forward and a backward neural network specific to unigrams
Mikolov et al. Efficient estimation of word representations in vector space
Minaee et al. Automatic question-answering using a deep similarity neural network
WO2023024412A1 (zh) 基于深度学习模型的视觉问答方法及装置、介质、设备
TW201917602A (zh) 文本語義編碼方法及裝置
CN112818105B (zh) 一种融合上下文信息的多轮对话方法及系统
CN108170848B (zh) 一种面向中国移动智能客服的对话场景分类方法
CN111400461B (zh) 智能客服问题匹配方法及装置
CN111460132A (zh) 一种基于图卷积神经网络的生成式会议摘要方法
CN114722839A (zh) 人机协同对话交互系统及方法
CN113704437A (zh) 一种融合多头注意力机制和相对位置编码的知识库问答方法
CN115688879A (zh) 一种基于知识图谱的智能客服语音处理系统及方法
CN116049387A (zh) 一种基于图卷积的短文本分类方法、装置、介质
CN112417155B (zh) 基于指针-生成Seq2Seq模型的庭审询问生成方法、装置、介质
CN111723583B (zh) 基于意图角色的语句处理方法、装置、设备及存储介质
Assem et al. QASAR: self-supervised learning framework for extractive question answering
CN113342964B (zh) 一种基于移动业务的推荐类型确定方法及系统
CN115510230A (zh) 一种基于多维特征融合与比较增强学习机制的蒙古语情感分析方法
Dereje et al. Sentence Level Amharic Word Sense Disambiguation
CN114579714A (zh) 一种机器阅读理解方法、装置、设备及存储介质
Zhang et al. A character-level sequence-to-sequence method for subtitle learning

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21901878

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 21901878

Country of ref document: EP

Kind code of ref document: A1