WO2022252636A1 - 基于人工智能的回答生成方法、装置、设备及存储介质 - Google Patents

基于人工智能的回答生成方法、装置、设备及存储介质 Download PDF

Info

Publication number
WO2022252636A1
WO2022252636A1 PCT/CN2022/072187 CN2022072187W WO2022252636A1 WO 2022252636 A1 WO2022252636 A1 WO 2022252636A1 CN 2022072187 W CN2022072187 W CN 2022072187W WO 2022252636 A1 WO2022252636 A1 WO 2022252636A1
Authority
WO
WIPO (PCT)
Prior art keywords
sentence
similar
answer
replied
difference
Prior art date
Application number
PCT/CN2022/072187
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 WO2022252636A1 publication Critical patent/WO2022252636A1/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
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/279Recognition of textual entities
    • G06F40/289Phrasal analysis, e.g. finite state techniques or chunking
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/30Semantic analysis
    • G06F40/35Discourse or dialogue representation
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Definitions

  • the present application relates to the field of artificial intelligence, and in particular to an artificial intelligence-based answer generation method, device, equipment, and storage medium.
  • the present application provides an artificial intelligence-based answer generation method, device, device, and storage medium, which realizes giving more relevant and accurate answers in the case of limited user question information.
  • the present application provides a method for generating an answer based on artificial intelligence, the method for generating an answer includes:
  • the present application also provides an artificial intelligence-based answer generating device, the answer generating device comprising:
  • the sentence receiving module is used to receive the sentence to be replied, and input the sentence to be replied into the retrieval model
  • a similar sentence acquisition module used to obtain the retrieval model to filter similar sentences matching the sentences to be replied from the preset dialogue corpus, and obtain the answer sentences of the similar sentences in the dialogue corpus;
  • the difference keyword extraction module is used to extract the difference keywords between the similar sentence and the sentence to be replied based on the preset semantic alignment keyword extraction model, and obtain the difference keyword set;
  • a similar keyword extraction module is used to extract similar keywords of the answer sentence to obtain a similar keyword set
  • An answer generating module configured to input the difference keyword set and the similar keyword set into the trained generative question answering model, and output an answer.
  • the present application also provides a computer device, the computer device includes a memory and a processor; the memory is used to store a computer program; the processor is used to execute the computer program and execute the The computer program realizes the answer generation method as described above.
  • the present application further provides a storage medium, the storage medium stores a computer program, and when the computer program is executed by a processor, the processor implements the above answer generation method.
  • the answer generation method, device, computer equipment and storage medium disclosed in this application retrieve similar sentences from the user's sentences to be replied through the retrieval model, and obtain the answer sentences of similar sentences, further extract difference keywords for similar sentences, and extract Similar keywords, the difference keywords and similar keywords are used as the input of the generative model, which adds input information to the generative model. In this way, it is possible to overcome the generation model that gives safe and meaningless answers due to the limited information contained in the user's questions, and achieve more relevant and accurate answers in the case of limited information in the user's questions.
  • Fig. 1 is a schematic flowchart of an answer generation method provided by an embodiment of the present application
  • Fig. 2 is a network schematic diagram of the answer generation method provided by the embodiment of the present application.
  • FIG. 3 is a schematic block diagram of an answer generation device provided by an embodiment of the present application.
  • FIG. 4 is a schematic structural block diagram of a computer device involved in an embodiment of the present application.
  • Baidu’s Xiaodu artificial intelligence assistant and Microsoft’s dialogue system Xiaoice are all focused on realizing the business scenario of man-machine dialogue.
  • the former uses a retrieval method to recall the user’s expected answer, while the latter uses a deep learning model.
  • Automate answer generation based on user questions.
  • Question answering systems based on retrieval methods are mostly used in intelligent question answering systems in specific fields (such as Taobao platform robot customer service). Such methods usually maintain a dialogue data database that can be used for retrieval in advance, and use the user's input questions as questions. Then use the sentence similarity calculation to find the question sentence that is most similar to the user's question sentence, and then output the corresponding answer as a response.
  • the question-answer pairs in the database have passed strict screening, so the answers returned to users are fluent in language and clear in expression.
  • the final answer is often irrelevant to the subject and the words are not expressive.
  • Question answering systems based on generative methods mostly use standard question and answer pairs as training data, and use generative models in natural language processing (usually the Encoder-Decoder framework) to train question answering systems. This method can automatically generate questions of the same height as user questions. However, due to the limited information contained in the user's questions, the results of the generative question answering model may tend to be safe answers, such as "okay”, “um”, etc. It's pointless and a waste of time.
  • this application proposes an answer generation method that combines the retrieval method and the generative method.
  • the formula method can generate more relevant answers based on the user's sentence. Firstly, the user's sentence is retrieved based on the retrieval method, and the similar sentence matching the user's sentence and the corresponding answer are obtained. Then extract difference keywords for all similar sentences and user sentences, extract similar keywords for all replies, and use the obtained difference keywords and similar keywords as the input of the generative method, and the final answer is output by the generative model. In this way, it is possible to generate more accurate and relevant answers when the information provided by the user's statement is limited.
  • Embodiments of the present application provide an artificial intelligence-based answer generation method, device, device, and storage medium.
  • the method for generating an answer can be applied to a server, and can also be applied to a chip in a specific product, such as a chip in an artificial intelligence device.
  • the retrieval model is used to add input information to the generation model based on the sentences to be replied, so that the answer given by the user is more accurate and relevant when the information given by the user is limited.
  • the server may be an independent server or a server cluster.
  • FIG. 1 is a schematic flowchart of an artificial intelligence-based answer generation method provided by an embodiment of the present application.
  • the answer generation method can be applied to the server to obtain more relevant and accurate answers to the user's sentence.
  • the answer generation method specifically includes steps S101 to S105.
  • the sentences to be replied include question sentences or non-question sentences; they can be in the form of speech or text, and when the sentences to be replied are in speech form, they need to be converted into text form first to be input into the retrieval model.
  • the sentence to be replied and the sentence in the preset dialogue corpus are input into the retrieval model, and the Jaccard similarity coefficient for characterizing the similarity between the sentence in the preset dialogue corpus and the sentence to be replied is generated; Obtaining the similar sentences matched with the sentence to be replied based on the Jaccard similarity coefficient screened out from the preset dialogue corpus by the retrieval model; wherein, the similar sentence is similar to the Jaccard similarity coefficient of the sentence to be replied greater than the first preset threshold and less than the second preset threshold.
  • the retrieval model After the sentences to be replied and the sentences in the preset dialogue prediction library are input into the retrieval model, the retrieval model generates a text similarity between the sentences in the preset dialogue corpus and the sentences to be replied to represent the sentences Jaccard similarity coefficient (Jaccard Similarity coefficient), and then judge whether the sentence is a similar sentence of the sentence to be replied according to the Jaccard similarity coefficient.
  • Jaccard similarity coefficient Jaccard Similarity coefficient
  • the retrieval model screens out the sentences whose Jaccard similarity coefficient value is greater than the first preset threshold and smaller than the second preset threshold in the preset dialogue corpus and the sentence to be replied, and selects the Jaccard similarity from the filtered results according to the requirements.
  • the preset number with the highest coefficient value is used as the final output similar sentences, and then the corresponding answer sentences of these similar sentences in the preset dialogue prediction library are also obtained, and the similar sentences output by the retrieval model and the corresponding answer sentences are one by one Correspond to form a similar question and answer pair.
  • the retrieval model screens out sentences in the preset dialogue corpus that have a Jaccard similarity coefficient greater than 0.5 and smaller than 0.9 with the sentence to be replied, and selects 3 sentences with the highest Jaccard similarity coefficients as similar sentences to output.
  • first preset threshold, the second preset threshold, and the preset number can be set according to actual applications, which is not specifically limited in this application.
  • the retrieval model can also be used to evaluate the text similarity between sentences based on the cosine similarity, so as to match similar sentences similar to the sentence to be replied.
  • the cosine similarity is to evaluate the similarity of two sentence vectors by calculating the angle between the two sentence vectors.
  • the preset dialogue corpus is a pre-maintained database containing dialogue sentences, including both question and answer sentences and answer sentences corresponding to the question and answer sentences.
  • the dialogue corpus can be based on the requirements of the application scenario, and can be a dialogue corpus that collects general daily conversations, or a dialogue corpus that collects specific application scenarios.
  • This application proposes a Semantic Alignment Keyword Extraction (SAKE) model for keyword extraction.
  • the semantic alignment keyword extraction model is based on the use of cross-attention (Cross-Attention) to calculate the attention matrix representing deep semantics, and extract keywords based on the attention matrix.
  • Cross-attention Cross-attention
  • the sentence to be replied is converted into the first vector
  • the similar sentence is converted into the second vector
  • the attention matrix is calculated according to the first vector and the second vector; the minimum value of the attention matrix is obtained to obtain the similar sentence and the waiting vector
  • the difference keywords of the reply sentence; the difference keywords are combined to obtain the difference keyword set.
  • the text sentence is firstly one-hot encoded to become a sparse matrix, and then the embedding layer is randomly initialized, the sparse matrix is transformed into a dense matrix through linear transformation, and the mutually independent one-hot vectors become A relational vector that considers the internal connection between words is proposed.
  • the sentence vector can also be generated based on a neural network language model (Nerual Network Language Model, NNLM).
  • NNLM Neural Network Language Model
  • ⁇ A is the sentence to be replied converted into the first vector
  • ⁇ B is the similar sentence converted into the second vector
  • d k is the normalization coefficient
  • the difference keyword formula is as follows:
  • i represents the row
  • j represents the column
  • L is a predetermined hyperparameter
  • the sentence to be replied is: Which is better, wine or white wine? Assume that the similar sentences obtained through the retrieval model are: Similar sentence 1: Is liquor better than wine? Similar sentence 2: Is there any wine that tastes better than liquor?
  • the difference keywords between similar statement 1 and the statement to be replied are: “more”, “and” and "which”.
  • the difference keywords between the similar statement 2 and the statement to be replied are: "wine”, "and", "which”. Take the union of the difference keywords to get the difference keyword set: ["more", “and”, "which", “wine”].
  • the first answer sentence in the answer sentences is converted into a first answer vector
  • the other answer sentences in the answer sentences are converted into a second answer vector
  • an attention matrix is calculated according to the first answer vector and the second answer vector.
  • the first answer sentence is the answer sentence corresponding to the similar sentence with the highest matching degree with the sentence to be replied.
  • the answer sentence corresponding to the similar sentence that best matches the sentence to be replied is used as a reference answer sentence, and other answer sentences need to be aligned with the reference answer sentence. Therefore, the reference answer sentence is converted into the first answer vector, other answer sentences in the answer sentence are converted into the second answer vector, and the attention matrix between other answer sentences and the reference answer sentence is calculated in sequence. Calculate the maximum value of the attention matrix to obtain similar keywords between the first answer sentence and other answer sentences in the answer sentence.
  • the similar keyword formula is as follows:
  • i represents the row
  • j represents the column
  • L is a predetermined hyperparameter, which represents the row and the largest L rows, corresponding to the extracted similar keywords.
  • the answer statement 1 is “I personally don't like drinking alcohol”
  • the answer statement 2 is “depending on personal taste, I prefer white wine”.
  • the similar keywords of answer statement 2 and answer statement 1 are: “personal”, “like” and “wine”. Therefore, the similar keyword set is: ["individual”, “like” and “wine”].
  • the keyword extraction model based on semantic alignment proposed in this application uses the attention matrix for normalized accumulation, realizing the consideration of deep semantic correlation and cumulative semantic characteristics in keyword extraction, so that the extracted keywords are more accurate.
  • the generation model includes a trained first generation model and a trained second generation model.
  • both the first generation model and the second generation model are based on the pre-trained language model BERT (Bidirectional Encoder Representation from Transformers), but they are trained based on different model parameters and training strategies.
  • the BERT model no longer uses the traditional one-way language model or the method of shallow splicing two one-way language models for pre-training, but uses a new masked language model (masked language model, MLM) to generate a deep two-way language characterization.
  • MLM masked language model
  • the BERT model uses MLM to pre-train bidirectional Transformers to generate deep bidirectional language representations. After pre-training, only need to add an additional output layer for fine-tuning (fine-tune), can achieve high-level performance in a variety of downstream tasks, and does not require task-specific structural modifications to the BERT model.
  • the network structure of the first generation model is: the first BERT model followed by the first fully connected layer and Softmax.
  • the training objective of the first generation model is to output a predicted ordered word set based on a given unordered word set. Specifically, input the unordered keyword set into the first BERT model, output the enhanced semantic vector of the word through the transformer encoder, connect the first fully connected layer and Softmax layer after the first BERT model, and output the predicted ordered keywords set. It should be noted that during the training process of the first generative model, the parameters of the first BERT model are not fine-tuned, but the parameters of the first fully connected layer are adjusted to obtain the trained first generative model.
  • the network structure of the second generation model is: the second BERT model followed by the second fully connected layer and Softmax.
  • the training objective of the second generation model is to output a predicted complete sentence based on the ordered keyword set.
  • the second generative model is based on contextual information and semantic understanding. In the output sentence, words not included in the keyword set can be obtained through prediction, and some words included in the keyword set can also be ignored. It should be noted that during the training process of the second generation model, the parameters of the second BERT model and the second fully connected layer need to be fine-tuned to obtain a trained second generation model.
  • the unordered keyword set obtained by taking the union of the difference keyword set and the similar keyword set is input into the trained first generative model to generate an ordered keyword set, where the ordered keyword set is equivalent to Combine discrete words into an incomplete sentence.
  • the ordered keyword set is input into the trained second generation model, and the second generation model outputs a complete sentence based on the ordered keyword set.
  • the predicted answer is output through a two-stage generative model, in which the first generative model predicts the location information to obtain an ordered discrete word set, and the second stage predicts the final generated answer sentence based on the ordered discrete word set, making the generated result more fluent.
  • an embodiment of the present application provides a schematic block diagram of an answer generation device, and the answer generation device may be configured in a server.
  • the answer generation device 400 includes: a sentence receiving module 401 , a similar sentence obtaining module 402 , a difference keyword extraction module 403 , a similar keyword extraction module 404 , and an answer generation module 405 .
  • the sentence receiving module 401 is used to receive the sentence to be replied, and input the sentence to be replied into the retrieval model;
  • the similar sentence obtaining module 402 is configured to obtain the similar sentence matched with the sentence to be replied selected from the preset dialogue corpus by the retrieval model, and obtain the answer sentence of the similar sentence in the dialogue corpus.
  • the difference keyword extraction module 403 is configured to extract the difference keywords between the similar sentence and the sentence to be replied based on a preset semantic alignment keyword extraction model to obtain a difference keyword set.
  • the similar keyword extraction module 404 is configured to extract similar keywords of the answer sentence to obtain a similar keyword set.
  • the answer generation module 405 is configured to input the difference keyword set and the similar keyword set into the trained generation model, and output an answer.
  • the above-mentioned apparatus can be realized in the form of a computer program, and the computer program can be run on the computer device as shown in FIG. 4 .
  • FIG. 4 is a schematic structural block diagram of a computer device provided by an embodiment of the present application.
  • the computer device may be a server.
  • the computer device includes a processor, a memory, and a network interface connected through a system bus, wherein the memory may include a storage medium and an internal memory.
  • the storage medium may store operating systems and computer programs.
  • the computer program includes program instructions which, when executed, cause a processor to perform any one of the answer generation methods.
  • the processor is used to provide computing and control capabilities and support the operation of the entire computer equipment.
  • the internal memory provides an environment for running the computer program in the storage medium.
  • the processor can execute any answer generating method.
  • This network interface is used for network communication, such as sending assigned tasks, etc.
  • Those skilled in the art can understand that the structure shown in Figure 4 is only a block diagram of a part of the structure related to the solution of this application, and does not constitute a limitation on the computer equipment to which the solution of this application is applied.
  • the specific computer equipment can be More or fewer components than shown in the figures may be included, or some components may be combined, or have a different arrangement of components.
  • the processor may be a central processing unit (Central Processing Unit, CPU), and the processor may also be other general processors, digital signal processors (Digital Signal Processor, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), Field-Programmable Gate Array (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
  • the general-purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
  • the processor is used to run a computer program stored in the memory to implement the following steps:
  • the processor when the processor acquires similar sentences that match the sentences to be replied and is screened out by the retrieval model from a preset dialogue corpus, it is used to realize:
  • the sentence to be replied and the sentence in the preset dialogue corpus are input into the retrieval model, and the Jaccard similarity coefficient for characterizing the similarity between the sentence in the preset dialogue corpus and the sentence to be replied is generated;
  • the processor when the processor realizes the keyword extraction model based on the preset semantic alignment, extracts the difference keywords between the similar sentence and the sentence to be replied, and obtains the difference keyword set, it is used to realize:
  • the difference keywords are combined to obtain a difference keyword set.
  • the processor when used to calculate the attention matrix, it is used to realize:
  • ⁇ A is that the sentence to be replied is converted into the first vector, and ⁇ B is converted into the second vector for the similar sentence, and d k is a normalization coefficient;
  • the difference keyword formula is as follows:
  • i represents the row
  • j represents the column
  • L is a predetermined hyperparameter, which means seeking row and the smallest L rows, corresponding to the extracted difference keywords.
  • the processor when used to extract similar keywords of the answer sentence to obtain a similar keyword set, it is used to realize:
  • the first answer sentence is the answer sentence corresponding to the similar sentence with the highest matching degree with the sentence to be replied;
  • i represents the row
  • j represents the column
  • L is a predetermined hyperparameter, which means seeking the row and the largest L rows, corresponding to the extracted similar keywords.
  • the trained generative model includes a trained first generative model and a trained second generative model
  • the processor is used to implement the difference keyword set and the similar key
  • the word set is input to the trained generation model, and when outputting the answer, it is used to realize:
  • the trained generation model is obtained based on the pre-trained language model BERT.
  • Embodiments of the present application also provide a storage medium, the storage medium stores a computer program, the computer program includes program instructions, and the processor executes the program instructions to implement any Item answer generation method.
  • the storage medium may be an internal storage unit of the computer device described in the foregoing embodiments, such as a hard disk or a memory of the computer device.
  • the storage medium may also be an external storage device of the computer device, such as a plug-in hard disk equipped on the computer device, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, Flash card (Flash Card), etc.
  • the storage medium may be non-volatile or volatile.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Artificial Intelligence (AREA)
  • Computational Linguistics (AREA)
  • General Physics & Mathematics (AREA)
  • Mathematical Physics (AREA)
  • Health & Medical Sciences (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • General Health & Medical Sciences (AREA)
  • Databases & Information Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Human Computer Interaction (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Machine Translation (AREA)

Abstract

本申请涉及人工智能领域,尤其涉及一种基于人工智能的回答生成方法、装置、设备及存储介质,实现了在用户的待回复语句信息有限的情况下,生成模型生成了更相关更准确的回答。其中基于人工智能的回答生成方法包括:接收待回复语句,将待回复语句输入检索模型;获取检索模型从预设的对话语料库中筛选出的与待回复语句匹配的相似语句,并获取相似语句在对话语料库中的回答语句。基于预设的语义对齐关键词提取模型,提取相似语句与待回复语句的差异关键词,得到差异关键词集;提取回答语句的相似关键词,得到相似关键词集。将差异关键词集和相似关键词集输入训练好的生成模型,输出回答。通过基于人工智能的自然语言处理,实现了在智能对话中,当用户问句信息有限的情况下,给出更相关更准确的回答。

Description

基于人工智能的回答生成方法、装置、设备及存储介质
本申请要求于2021年6月1日提交中国专利局、申请号为202110609412.5、发明名称为“基于人工智能的回答生成方法、装置、设备及存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及人工智能领域,尤其涉及一种基于人工智能的回答生成方法、装置、设备及存储介质。
背景技术
随着社交媒体的不断发展和人工智能技术的不断进步,智能对话***在当前社会扮演了越来越重要的角色。以生成式方法为基础的问答***多以标准的问答对作为训练数据,使用自然语言处理中的生成式模型(通常是Encoder-Decoder框架)训练得到回答结果。基于生成式模型的方法能自动化生成同用户问题高度相关的回答,发明人意识到由于用户的问句所含信息有限,因此生成式模型的结果可能倾向于安全回答,如“好的”、“嗯”等,这对使用人机对话***的用户来说是没有意义且浪费时间的。
发明内容
本申请提供了一种基于人工智能的回答生成方法、装置、设备及存储介质,将,实现了在用户问句信息有限的情况下,给出更相关更准确的回答。
第一方面,本申请提供了一种基于人工智能的回答生成方法,所述回答生成方法包括:
接收待回复语句,将所述待回复语句输入检索模型;
获取所述检索模型从预设的对话语料库中筛选出的与所述待回复语句匹配的相似语句,并获取所述相似语句在所述对话语料库中的回答语句;
基于预设的语义对齐关键词提取模型,提取所述相似语句与所述待回复语句的差异关键词,得到差异关键词集集;
提取所述回答语句的相似关键词,得到相似关键词集;
将所述差异关键词集和所述相似关键词集输入训练好的生成模型,输出回答。
第二方面,本申请还提供了一种基于人工智能的回答生成装置,所述回答生成装置包括:
语句接收模块,用于接收待回复语句,并将所述待回复语句输入检索式模型;
相似语句获取模块,用于获取所述检索式模型从预设的对话语料库中筛选出与待回复语句匹配的相似语句,并获取所述相似语句在所述对话语料库中的回答语句;
差异关键词提取模块,用于基于预设的语义对齐关键词提取模型,提取所述相似语句与待回复语句的差异关键词,得到差异关键词集;
相似关键词提取模块,用于提取所述回答语句的相似关键词,得到相似关键词集;
回答生成模块,用于将所述差异关键词集和所述相似关键词集输入训练好的生成式问答模型,输出回答。
第三方面,本申请还提供了一种计算机设备,所述计算机设备包括存储器和处理器;所述存储器用于存储计算机程序;所述处理器,用于执行所述计算机程序并在执行所述计算机程序时实现如上述的回答生成方法。
第四方面,本申请还提供了一种存储介质,所述存储介质存储有计算机程序,所述计算机程序被处理器执行时使所述处理器实现如上述的回答生成方法。
本申请公开的回答生成方法、装置、计算机设备及存储介质,通过检索模型对用户的待回复语句检索相似语句,并获取相似语句的回答语句,进一步对相似语句提取差异关键词,对回答语句提取相似关键词,将差异关键词与相似关键词作为生成模型的输入,为生成模型增加了输入的信息。从而能够克服因用户的问句所含信息有限而导致的生成模型给出安全且没有意义的回答,实现了在用户问句信息有限的情况下,给出更相关更准确的回答。
附图说明
为了更清楚地说明本申请实施例技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1是本申请的实施例提供的回答生成方法的示意流程图;
图2是本申请的实施例提供的回答生成方法的网络示意图;
图3为本申请的实施例提供的回答生成装置的示意性框图;
图4为本申请的实施例涉及的一种计算机设备的结构示意性框图。
具体实施方式
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。
附图中所示的流程图仅是示例说明,不是必须包括所有的内容和操作/步骤,也不是必须按所描述的顺序执行。例如,有的操作/步骤还可以分解、组合或部分合并,因此实际执行的顺序有可能根据实际情况改变。
应当理解,在此本申请说明书中所使用的术语仅仅是出于描述特定实施例的目的而并不意在限制本申请。如在本申请说明书和所附权利要求书中所使用的那样,除非上下文清楚地指明其它情况,否则单数形式的“一”、“一个”及“该”意在包括复数形式。
还应当进理解,在本申请说明书和所附权利要求书中使用的术语“和/或”是指相关联 列出的项中的一个或多个的任何组合以及所有可能组合,并且包括这些组合。
随着社交媒体的不断发展和人工智能技术的不断进步,智能对话***在当前社会扮演了越来越重要的角色。如百度推出的小度人工智能助手、微软公司的对话***小冰都是着力于实现人机对话这一业务场景,前者使用检索式的方法来召回用户期望的回答,而后者是通过深度学习模型根据用户的问题实现自动化的回答生成。
以检索式方法为基础的问答***多应用于特定领域的智能问答***(如淘宝平台机器人客服),此类方法通常预先维护一个可用于检索的对话语料数据库,将用户的输入问题作为问句,随后利用句子相似性计算找到与用户问句最相似的问句,随后将其对应的回答作为响应输出。数据库中的问答对通过了严格的筛选,因此返还给用户的回答是语言流畅、表达清晰。但是由于数据库规模以及语句相似性匹配方法的限制,最终的回答常常是主题无关、词不达意的。
以生成式方法为基础的问答***多以标准的问答对作为训练数据,使用自然语言处理中的生成式模型(通常是Encoder-Decoder框架)训练得到问答***,此方法能自动化生成同用户问题高度相关的回答,但是由于用户的问句所含信息有限,因此生成式问答模型的结果可能会倾向于安全回答,如“好的”、“嗯”等,这对使用人机对话***的消费者来说是没有意义且浪费时间的。
基于现有智能对话***存在的缺陷和不足,本申请提出了将检索式方法和生成式方法相结合的回答生成方法,通过检索式方法基于用户的语句增加生成式模型的输入信息,从而使生成式方法能够基于用户的语句生成更相关的回答。首先基于检索式方法对用户的语句进行检索,得到与用户的语句匹配的相似语句和相似语句所对应的答复。然后对所有相似语句和用户的语句提取差异关键词,对所有答复提取相似关键词,并将得到的差异关键词和相似关键词作为生成式方法的输入,由生成式模型输出最终的回答。从而实现在用户的语句所提供的信息有限的情况下,生成更准确更相关的回答。
本申请的实施例提供了一种基于人工智能的回答生成方法、装置、设备及存储介质。其中,该回答生成方法可以应用于服务器中,也可以应用于具体产品中的芯片,例如应用于人工智能设备中的芯片。利用检索模型基于待回复语句给生成模型增加输入的信息,实现了在用户给出的信息有限的情况下给出的回答更准确更相关。其中,该服务器可以为独立的服务器,也可以为服务器集群。
下面结合附图,对本申请的一些实施方式作详细说明。在不冲突的情况下,下述的实施例及实施例中的特征可以相互组合。
请参阅图1,图1是本申请的实施例提供的一种基于人工智能的回答生成方法示意流程图。该回答生成方法可应用于服务器中,以获得与用户的语句更相关更准确的回答。
如图1所示,该回答生成方法具体包括步骤S101至步骤S105。
S101、接收待回复语句,将所述待回复语句输入检索模型。
其中待回复语句包括问句或非问句;可以为语音形式或文本形式,当待回复语句为语音形式时,需先将其转换为文本形式,以输入检索模型。
S102、获取所述检索模型从预设的对话语料库中筛选出的与所述待回复语句匹配的相似语句,并获取所述相似语句在所述对话语料库中的回答语句。
将所述待回复语句和所述预设的对话语料库中的语句输入至所述检索模型中,生成用于表征所述预设的对话语料库中的语句与待回复语句相似度的Jaccard相似系数;获取所述检索模型基于所述Jaccard相似系数从所述预设的对话语料库中筛选出的与所述待回复语句匹配的相似语句;其中,所述相似语句与所述待回复语句的Jaccard相似系数大于第一预设阈值,且小于第二预设阈值。
在一些实施例中,将待回复语句和预设的对话预料库中的语句输入检索模型后,检索模型对预设的对话语料库中的语句和该待回复语句生成表征语句之间的文本相似度的Jaccard相似系数(Jaccard Similarity coefficient),进而根据该Jaccard相似系数来判断语句是否为待回复语句的相似语句。语句之间的Jaccard相似系数值越高,代表语句之间具有更高的相似度,匹配度更高。检索模型将预设的对话语料库中与待回复语句的Jaccard相似系数值大于第一预设阈值,且小于第二预设阈值的语句筛选出来,并根据需求从这个筛选出来的结果中选取Jaccard相似系数值最高的预设数量个作为最终输出的相似语句,进而将这些相似语句在预设的对话预料库中对应的回答语句也获取出来,将检索模型输出的相似语句和对应的回答语句一一对应起来,组成相似问答对。
示例性的,检索模型将预设的对话语料库中与待回复语句Jaccard相似系数大于0.5小于0.9的语句筛选出来,并从中选择3个Jaccard相似系数最高的语句作为相似语句输出。
需要说明的是,第一预设阈值和第二预设阈值、以及预设数量可根据实际应用进行设置,本申请对此不做具体限定。
在另一些实施例中,检索模型还可以用于基于cosine相似度来评价语句之间的文本相似度,从而匹配出与待回复语句相似的相似语句。cosine相似度是通过计算两个语句向量之间的夹角,来评价两个语句向量的相似度。
需要说明的是,预设的对话语料库为预先维护的包含对话语句的数据库,既包括问答语句,也包括与问答语句相应的回答语句。该对话语料库可以根据应用场景的需求,可以为收录通用日常对话的对话语料,也可以为收录特定应用场景相关的对话语料。
S103、基于预设的语义对齐关键词提取模型,提取所述相似语句与所述待回复语句的差异关键词,得到差异关键词集。
本申请提出了语义对齐关键词提取模型(Semantic Alignment Keyword Extraction,SAKE)用于关键词的提取。该语义对齐关键词提取模型,基于利用跨越注意力(Cross-Attention)计算表征深层语义的注意力矩阵,并基于注意力矩阵来提取关键词。
具体的,将待回复语句转化为第一向量,将相似语句转化为第二向量,并根据第一向量和第二向量计算注意力矩阵;对注意力矩阵求极小值,得到相似语句与待回复语句的差异关键词;将差异关键词取并集,得到差异关键词集。
首先,需要将文本语句转化为向量形式,语句向量化的方法有很多种。
在一些实施例中,首先将文本语句进行one-hot编码,成为稀疏矩阵,然后通过随机初 始化embedding层,通过线性变换将该稀疏矩阵变成密集矩阵,并且让相互独立的one-hot向量变成了考虑词与词之间的内在联系的关系向量。
在另一些实施例中,还可以基于神经网络语言模型(Nerual Network Language Model,NNLM)生成语句向量。
需要说明的是:所有相似语句均需向待回复语句对齐,因此将待回复语句转化为第一向量,其他相似语句转化为第二向量,依次计算每个相似语句与待回复语句之间的注意力矩阵。其中,注意力矩阵表示为:
Figure PCTCN2022072187-appb-000001
其中,ν A为所述待回复语句转化为第一向量,ν B为所述相似语句转化为第二向量,d k为归一化系数。
通过对注意力矩阵求极小值,可得到在待回复语句中存在但在相似语句中不存在的词,为两者之间的差异关键词。其中,所述差异关键词公式如下:
Figure PCTCN2022072187-appb-000002
其中,i表示所在行,j表示所在列,L为预先确定的超参数,
Figure PCTCN2022072187-appb-000003
表示求行和最小的L个行,对应提取出的差异关键词。
对所有相似语句与待回复语句的差异关键词取并集,即得到差异关键词集。
示例性的,例如,待回复语句为:葡萄酒和白酒哪个更好喝?假设通过检索模型得到的相似语句为:相似语句1:白酒是不是比葡萄酒好喝呢?相似语句2:有比白酒更好喝的酒吗?相似语句1与待回复语句的差异关键词为:“更”“和”“哪个”。相似语句2与待回复语句的差异关键词为:“葡萄酒”“和”,“哪个”。将差异关键词取并集,得到差异关键词集为:【“更”“和”“哪个”“葡萄酒”】。
S104、提取所述回答语句的相似关键词,得到相似关键词集。
具体的,将回答语句中的第一回答语句转化为第一回答向量,将回答语句中的其他回答语句转化为第二回答向量,并根据第一回答向量和第二回答向量计算注意力矩阵。其中,第一回答语句为与待回复语句匹配度最高的相似语句所对应的回答语句。
需要说明的是:将与待回复语句最匹配的相似语句对应的回答语句作为参照回答语句,其他回答语句均需向该参照回答语句对齐。因此将该参照回答语句转化为第一回答向量,将回答语句中的其他回答语句转化为第二回答向量,依次计算其他回答语句与该参照回答语句之间的注意力矩阵。对注意力矩阵求极大值,得到第一回答语句与回答语句中的其他回答语句的相似关键词。其中,所述相似关键词公式如下:
其中,所述相似关键词公式如下:
Figure PCTCN2022072187-appb-000004
其中,i表示所在行,j表示所在列,L为预先确定的超参数,表示求行和最大的L个行,对应提取出的相似关键词。
将参照回答语句之外的所有其他回答语句和参照回答语句取相似关键词,并对所有相似关键词取并集,得到相似关键词集。
示例性的,例如,回答语句1为“我个人是不喜欢喝酒的”,回答语句2为“看个人品味,我更喜欢白酒”。回答语句2与回答语句1的相似关键词为:“个人”“喜欢”“酒”。因此相似关键词集为:【“个人”“喜欢”“酒”】。
本申请提出的基于语义对齐关键词提取模型,利用注意力矩阵进行规范化累加,实现了在关键词提取中考虑深层次的语义相关性和累积的语义特性,从而使提取的关键词更加准确。
S105、将所述差异关键词集和所述相似关键词集输入训练好的生成模型,输出回答。生成模型包括训练好的第一生成模型和训练好的第二生成模型。
具体的,将差异关键词集和相似关键词集输入训练好的第一生成模型,通过预测差异关键词集和相似关键词集中的词语在语句中的位置,输出有序的关键词序列;将有序的关键词序列输入训练好的第二生成模型,输出回答。
在本申请提供的实施例中,第一生成模型和第二生成模型都基于预训练语言模型BERT(Bidirectional Encoder Representation from Transformers),但基于不同的模型参数及训练策略对两者进行训练。BERT模型不再采用传统的单向语言模型或者把两个单向语言模型进行浅层拼接的方法进行预训练,而是采用新的掩码语言模型(masked language model,MLM)生成深度的双向语言表征。BERT模型采用MLM对双向的Transformers进行预训练,以生成深层的双向语言表征。预训练后,只需要添加一个额外的输出层进行微调(fine-tune),就可以在各种各样的下游任务中取得高水准的表现,而且不需要对BERT模型进行特定任务的结构修改。
在本申请提供的实施例中,第一生成模型的网络结构为:第一BERT模型后接第一全连接层和Softmax。第一生成模型的训练目标是基于给定的无序词集,输出预测的有序词集。具体的,将无序的关键词集输入第一BERT模型,通过transformer encoder输出词语的增强语义向量,在第一BERT模型后接第一全连接层和Softmax层,输出预测的有序的关键词集。需要说明的是,在第一生成模型的训练过程中,不对第一BERT模型的参数进行微调,而是通过调整第一全连接层的参数来得到训练好的第一生成模型。
在本申请提供的实施例中,第二生成模型的网络结构为:第二BERT模型后接第二全连接层和Softmax。第二生成模型的训练目标是基于有序的关键词集,输出预测的完整语句。第二生成模型基于上下文信息和语义的理解,在输出的语句中,可以通过预测得到关键词集中不包含的词语,也可以忽略一部分关键词集中包含的词语。需要说明的是,在第二生成模型的训练过程中,需对第二BERT模型的和第二全连接层的参数进行微调,来得到训练好的第二生成模型。
首先,将差异关键词集和相似关键词集取并集得到的无序的关键词集输入训练好的第一生成模型,生成有序的关键词集,这里的有序的关键词集相当于将离散的词语组合成了一个 不完整的语句。其次,将该有序的关键词集输入训练好的第二生成模型,第二生成模型基于该有序的关键词集输出完整的语句。
通过两级生成模型输出预测的回答,其中第一生成模型预测位置信息得到有序的离散词集,第二阶段根据有序的离散词集预测最终生成的回答语句,使得生成的结果更加流畅。
本申请提供的回答生成方法,首先基于检索模型对用户的待回复语句检索相似语句,并获取相似语句的回答语句,进一步对相似语句提取差异关键词,对回答语句提取相似关键词,将差异关键词与相似关键词作为生成模型的输入,为生成模型增加了输入的信息。从而能够克服因用户的问句所含信息有限而导致的生成模型给出安全且没有意义的回答,实现了在用户问句信息有限的情况下,给出更相关更准确回答的结果。
请参阅图3,本申请的实施例提供一种回答生成装置的示意性框图,该回答生成装置可以配置于服务器。
如图3所示,该回答生成装置400包括:语句接收模块401、相似语句获取模块402、差异关键词提取模块403、相似关键词提取模块404、回答生成模块405。
语句接收模块401,用于接收待回复语句,将所述待回复语句输入检索模型;
相似语句获取模块402,用于获取所述检索模型从预设的对话语料库中筛选出的与所述待回复语句匹配的相似语句,并获取所述相似语句在所述对话语料库中的回答语句。
差异关键词提取模块403,用于基于预设的语义对齐关键词提取模型,提取所述相似语句与所述待回复语句的差异关键词,得到差异关键词集。
相似关键词提取模块404,用于提取所述回答语句的相似关键词,得到相似关键词集。
回答生成模块405,用于将所述差异关键词集和所述相似关键词集输入训练好的生成模型,输出回答。
需要说明的是,所属领域的技术人员可以清楚地了解到,为了描述的方便和简洁,上述描述的装置和各模块的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。
上述的装置可以实现为一种计算机程序的形式,该计算机程序可以在如图4所示的计算机设备上运行。
请参阅图4,图4是本申请的实施例提供的一种计算机设备的结构示意性框图。该计算机设备可以是服务器。
参阅图4,该计算机设备包括通过***总线连接的处理器、存储器和网络接口,其中,存储器可以包括存储介质和内存储器。
存储介质可存储操作***和计算机程序。该计算机程序包括程序指令,该程序指令被执行时,可使得处理器执行任意一种回答生成方法。
处理器用于提供计算和控制能力,支撑整个计算机设备的运行。
内存储器为存储介质中的计算机程序的运行提供环境,该计算机程序被处理器执行时,可使得处理器执行任意一种回答生成方法。
该网络接口用于进行网络通信,如发送分配的任务等。本领域技术人员可以理解,图4 中示出的结构,仅仅是与本申请方案相关的部分结构的框图,并不构成对本申请方案所应用于其上的计算机设备的限定,具体的计算机设备可以包括比图中所示更多或更少的部件,或者组合某些部件,或者具有不同的部件布置。
应当理解的是,处理器可以是中央处理单元(Central Processing Unit,CPU),该处理器还可以是其他通用处理器、数字信号处理器(Digital Signal Processor,DSP)、专用集成电路(Application Specific Integrated Circuit,ASIC)、现场可编程门阵列(Field-Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。其中,通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。
其中,在一个实施例中,所述处理器用于运行存储在存储器中的计算机程序,以实现如下步骤:
接收待回复语句,将所述待回复语句输入检索模型;
获取所述检索模型从预设的对话语料库中筛选出的与所述待回复语句匹配的相似语句,并获取所述相似语句在所述对话语料库中的回答语句;
基于预设的语义对齐关键词提取模型对所述相似语句与所述待回复语句提取差异关键词,得到差异关键词集;
对所述回答语句提取相似关键词,得到相似关键词集;
将所述差异关键词集和所述相似关键词集输入训练好的生成模型,输出回答。
在一个实施例中,所述处理器在实现获取所述检索模型从预设的对话语料库中筛选出的与所述待回复语句匹配的相似语句时,用于实现:
将所述待回复语句和所述预设的对话语料库中的语句输入至所述检索模型中,生成用于表征所述预设的对话语料库中的语句与待回复语句相似度的Jaccard相似系数;
获取所述检索模型基于所述Jaccard相似系数从所述预设的对话语料库中筛选出的与所述待回复语句匹配的相似语句;其中,所述相似语句与所述待回复语句的Jaccard相似系数大于第一预设阈值,且小于第二预设阈值。
在一个实施例中,所述处理器在实现基于预设的语义对齐关键词提取模型,提取所述相似语句与所述待回复语句的差异关键词,得到差异关键词集时,用于实现:
将所述待回复语句转化为第一向量,将相似语句转化为第二向量,并根据所述第一向量和第二向量计算注意力矩阵;
对所述注意力矩阵求极小值,得到相似语句与待回复语句的差异关键词;
将所述差异关键词取并集,得到差异关键词集。
在一个实施例中,所述处理器在用于计算注意力矩阵时,用于实现:
Figure PCTCN2022072187-appb-000005
其中,ν A为所述待回复语句转化为第一向量,ν B为所述相似语句转化为第二向量,d k为归一化系数;
所述差异关键词公式如下:
Figure PCTCN2022072187-appb-000006
其中,i表示所在行,j表示所在列,L为预先确定的超参数,表示求
Figure PCTCN2022072187-appb-000007
行和最小的L个行,对应提取出的差异关键词。
在一个实施例中,所述处理器在用于提取所述回答语句的相似关键词,得到相似关键词集时,用于实现:
将所述回答语句的第一回答语句转化为第一回答向量,将所述回答语句中的其他回答语句转化为第二回答向量,并根据所述第一回答向量和第二回答向量计算注意力矩阵;其中,所述第一回答语句为与所述待回复语句匹配度最高的相似语句所对应的回答语句;
对所述注意力矩阵求极大值,得到所述第一回答语句与所述回答语句中的其他回答语句的相似关键词;
将所有相似关键词取并集,得到相似关键词集;
其中,所述相似关键词公式如下:
Figure PCTCN2022072187-appb-000008
其中,i表示所在行,j表示所在列,L为预先确定的超参数,表示求行
Figure PCTCN2022072187-appb-000009
和最大的L个行,对应提取出的相似关键词。
在一个实施例中,所述训练好的生成模型包括训练好的第一生成模型和训练好的第二生成模型,所述处理器在用于实现将所述差异关键词集和所述相似关键词集输入训练好的生成模型,输出回答时,用于实现:
将所述差异关键词集和所述相似关键词集输入所述训练好的第一生成模型,通过预测所述差异关键词集和相似关键词集中的词语在语句中的位置,输出有序的关键词序列;
将所述有序的关键词序列输入所述训练好的第二生成模型,输出回答。
所述训练好的生成模型基于预训练语言模型BERT得到的。
本申请的实施例中还提供一种存储介质,所述存储介质存储有计算机程序,所述计算机程序中包括程序指令,所述处理器执行所述程序指令,实现本申请实施例提供的任一项回答生成方法。
其中,所述存储介质可以是前述实施例所述的计算机设备的内部存储单元,例如所述计算机设备的硬盘或内存。所述存储介质也可以是所述计算机设备的外部存储设备,例如所述计算机设备上配备的插接式硬盘,智能存储卡(Smart Media Card,SMC),安全数字(Secure Digital,SD)卡,闪存卡(Flash Card)等。所述存储介质可以是非易失性,也可以是易失性。
以上所述,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何熟悉 本技术领域的技术人员在本申请揭露的技术范围内,可轻易想到各种等效的修改或替换,这些修改或替换都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以权利要求的保护范围为准。

Claims (20)

  1. 一种基于人工智能的回答生成方法,其中,包括:
    接收待回复语句,将所述待回复语句输入检索模型;
    获取所述检索模型从预设的对话语料库中筛选出的与所述待回复语句匹配的相似语句,并获取所述相似语句在所述对话语料库中的回答语句;
    基于预设的语义对齐关键词提取模型,提取所述相似语句与所述待回复语句的差异关键词,得到差异关键词集;
    提取所述回答语句的相似关键词,得到相似关键词集;
    将所述差异关键词集和所述相似关键词集输入训练好的生成模型,输出回答。
  2. 根据权利要求1所述的回答生成方法,其中,所述获取所述检索模型从预设的对话语料库中筛选出的与所述待回复语句匹配的相似语句,包括:
    将所述待回复语句和所述预设的对话语料库中的语句输入至所述检索模型中,生成用于表征所述预设的对话语料库中的语句与待回复语句相似度的Jaccard相似系数;
    获取所述检索模型基于所述Jaccard相似系数从所述预设的对话语料库中筛选出的与所述待回复语句匹配的相似语句;
    其中,所述相似语句与所述待回复语句的Jaccard相似系数大于第一预设阈值,且小于第二预设阈值。
  3. 根据权利要求1所述的回答生成方法,其中,所述基于预设的语义对齐关键词提取模型,提取所述相似语句与所述待回复语句的差异关键词,得到差异关键词集包括:
    将所述待回复语句转化为第一向量,将相似语句转化为第二向量,并根据所述第一向量和第二向量计算注意力矩阵;
    对所述注意力矩阵求极小值,得到相似语句与待回复语句的差异关键词;
    将所述差异关键词取并集,得到差异关键词集。
  4. 根据权利要求3所述的回答生成方法,其中,所述注意力矩阵表示为:
    Figure PCTCN2022072187-appb-100001
    其中,ν A为所述待回复语句转化的第一向量,ν B为所述相似语句转化的第二向量,d k为归一化系数;
    所述差异关键词公式如下:
    Figure PCTCN2022072187-appb-100002
    其中,i表示所在行,j表示所在列,L为预先确定的超参数,
    Figure PCTCN2022072187-appb-100003
    表示求行和最小的L个行,对应提取出的差异关键词。
  5. 根据权利要求4所述的回答生成方法,其中,所述提取所述回答语句的相似关键词, 得到相似关键词集包括:
    将所述回答语句的第一回答语句转化为第一回答向量,将所述回答语句中的其他回答语句转化为第二回答向量,并根据所述第一回答向量和第二回答向量计算注意力矩阵;其中,所述第一回答语句为与所述待回复语句匹配度最高的相似语句所对应的回答语句;
    对所述注意力矩阵求极大值,得到所述第一回答语句与所述回答语句中的其他回答语句的相似关键词;
    将所有相似关键词取并集,得到相似关键词集;
    其中,所述相似关键词公式如下:
    Figure PCTCN2022072187-appb-100004
    其中,i表示所在行,j表示所在列,L为预先确定的超参数,
    Figure PCTCN2022072187-appb-100005
    表示求行和最大的L个行,对应提取出的相似关键词。
  6. 根据权利要求1所述的回答生成方法,其中,所述训练好的生成模型包括训练好的第一生成模型和训练好的第二生成模型;
    所述将所述差异关键词集和所述相似关键词集输入训练好的生成模型,输出回答,包括:
    将所述差异关键词集和所述相似关键词集输入所述训练好的第一生成模型,通过预测所述差异关键词集和相似关键词集中的词语在语句中的位置,输出有序的关键词序列;
    将所述有序的关键词序列输入所述训练好的第二生成模型,输出回答。
  7. 根据权利要求6所述的回答生成方法,其中,所述训练好的生成模型是基于预训练语言模型BERT得到的。
  8. 一种基于人工智能的回答生成装置,其中,所述装置包括:
    语句接收模块,用于接收待回复语句,将所述待回复语句输入检索模型;
    相似语句获取模块,用于获取所述检索模型从预设的对话语料库中筛选出的与所述待回复语句匹配的相似语句,并获取所述相似语句在所述对话语料库中的回答语句;
    差异关键词提取模块,用于基于预设的语义对齐关键词提取模型,提取所述相似语句与所述待回复语句的差异关键词,得到差异关键词集;
    相似关键词提取模块,用于提取所述回答语句的相似关键词,得到相似关键词集;
    回答生成模块,用于将所述差异关键词集和所述相似关键词集输入训练好的生成模型,输出回答。
  9. 一种计算机设备,其中,所述计算机设备包括存储器和处理器;
    所述存储器用于存储计算机程序;
    所述处理器,用于执行所述计算机程序并在执行所述计算机程序时实现如下步骤:接收待回复语句,将所述待回复语句输入检索模型;
    获取所述检索模型从预设的对话语料库中筛选出的与所述待回复语句匹配的相似语句,并获取所述相似语句在所述对话语料库中的回答语句;
    基于预设的语义对齐关键词提取模型,提取所述相似语句与所述待回复语句的差异关键词,得到差异关键词集;
    提取所述回答语句的相似关键词,得到相似关键词集;
    将所述差异关键词集和所述相似关键词集输入训练好的生成模型,输出回答。
  10. 根据权利要求9所述的计算机设备,其中,所述处理器实现获取所述检索模型从预设的对话语料库中筛选出的与所述待回复语句匹配的相似语句的步骤,包括:
    将所述待回复语句和所述预设的对话语料库中的语句输入至所述检索模型中,生成用于表征所述预设的对话语料库中的语句与待回复语句相似度的Jaccard相似系数;
    获取所述检索模型基于所述Jaccard相似系数从所述预设的对话语料库中筛选出的与所述待回复语句匹配的相似语句;
    其中,所述相似语句与所述待回复语句的Jaccard相似系数大于第一预设阈值,且小于第二预设阈值。
  11. 根据权利要求9所述的计算机设备,其中,所述处理器实现基于预设的语义对齐关键词提取模型,提取所述相似语句与所述待回复语句的差异关键词,得到差异关键词集的步骤,包括:
    将所述待回复语句转化为第一向量,将相似语句转化为第二向量,并根据所述第一向量和第二向量计算注意力矩阵;
    对所述注意力矩阵求极小值,得到相似语句与待回复语句的差异关键词;
    将所述差异关键词取并集,得到差异关键词集。
  12. 根据权利要求9所述的计算机设备,其中,所述处理器实现计算注意力矩阵的步骤,包括:
    所述注意力矩阵表示为:
    Figure PCTCN2022072187-appb-100006
    其中,ν A为所述待回复语句转化的第一向量,ν B为所述相似语句转化的第二向量,d k为归一化系数;
    所述差异关键词公式如下:
    Figure PCTCN2022072187-appb-100007
    其中,i表示所在行,j表示所在列,L为预先确定的超参数,
    Figure PCTCN2022072187-appb-100008
    表示求行和最小的L个行,对应提取出的差异关键词。
  13. 根据权利要求9所述的计算机设备,其中,所述处理器实现提取所述回答语句的相似关键词,得到相似关键词集的步骤,包括:
    将所述回答语句的第一回答语句转化为第一回答向量,将所述回答语句中的其他回答语句转化为第二回答向量,并根据所述第一回答向量和第二回答向量计算注意力矩阵;其中, 所述第一回答语句为与所述待回复语句匹配度最高的相似语句所对应的回答语句;
    对所述注意力矩阵求极大值,得到所述第一回答语句与所述回答语句中的其他回答语句的相似关键词;
    将所有相似关键词取并集,得到相似关键词集;
    其中,所述相似关键词公式如下:
    Figure PCTCN2022072187-appb-100009
    其中,i表示所在行,j表示所在列,L为预先确定的超参数,
    Figure PCTCN2022072187-appb-100010
    表示求行和最大的L个行,对应提取出的相似关键词。
  14. 根据权利要求9所述的计算机设备,其中,所述训练好的生成模型包括训练好的第一生成模型和训练好的第二生成模型,所述处理器实现将所述差异关键词集和所述相似关键词集输入训练好的生成模型,输出回答的步骤,包括:
    将所述差异关键词集和所述相似关键词集输入所述训练好的第一生成模型,通过预测所述差异关键词集和相似关键词集中的词语在语句中的位置,输出有序的关键词序列;
    将所述有序的关键词序列输入所述训练好的第二生成模型,输出回答;
    其中,所述训练好的生成模型是基于预训练语言模型BERT得到的。
  15. 一种存储介质,其中,所述存储介质存储有计算机程序,所述存储介质存储有计算机程序,所述计算机程序被处理器执行时使所述处理器实现如下步骤:
    接收待回复语句,将所述待回复语句输入检索模型;
    获取所述检索模型从预设的对话语料库中筛选出的与所述待回复语句匹配的相似语句,并获取所述相似语句在所述对话语料库中的回答语句;
    基于预设的语义对齐关键词提取模型,提取所述相似语句与所述待回复语句的差异关键词,得到差异关键词集;
    提取所述回答语句的相似关键词,得到相似关键词集;
    将所述差异关键词集和所述相似关键词集输入训练好的生成模型,输出回答。
  16. 根据权利要求15所述的存储介质,其中,所述处理器实现获取所述检索模型从预设的对话语料库中筛选出的与所述待回复语句匹配的相似语句的步骤,包括:
    将所述待回复语句和所述预设的对话语料库中的语句输入至所述检索模型中,生成用于表征所述预设的对话语料库中的语句与待回复语句相似度的Jaccard相似系数;
    获取所述检索模型基于所述Jaccard相似系数从所述预设的对话语料库中筛选出的与所述待回复语句匹配的相似语句;
    其中,所述相似语句与所述待回复语句的Jaccard相似系数大于第一预设阈值,且小于第二预设阈值。
  17. 根据权利要求15所述的计算机设备,其中,所述处理器实现基于预设的语义对齐关键词提取模型,提取所述相似语句与所述待回复语句的差异关键词,得到差异关键词集的步 骤,包括:
    将所述待回复语句转化为第一向量,将相似语句转化为第二向量,并根据所述第一向量和第二向量计算注意力矩阵;
    对所述注意力矩阵求极小值,得到相似语句与待回复语句的差异关键词;
    将所述差异关键词取并集,得到差异关键词集。
  18. 根据权利要求15所述的计算机设备,其中,所述处理器实现计算注意力矩阵的步骤,包括:
    所述注意力矩阵表示为:
    Figure PCTCN2022072187-appb-100011
    其中,ν A为所述待回复语句转化的第一向量,ν B为所述相似语句转化的第二向量,d k为归一化系数;
    所述差异关键词公式如下:
    Figure PCTCN2022072187-appb-100012
    其中,i表示所在行,j表示所在列,L为预先确定的超参数,
    Figure PCTCN2022072187-appb-100013
    表示求行和最小的L个行,对应提取出的差异关键词。
  19. 根据权利要求15所述的计算机设备,其中,所述处理器实现提取所述回答语句的相似关键词,得到相似关键词集的步骤,包括:
    将所述回答语句的第一回答语句转化为第一回答向量,将所述回答语句中的其他回答语句转化为第二回答向量,并根据所述第一回答向量和第二回答向量计算注意力矩阵;其中,所述第一回答语句为与所述待回复语句匹配度最高的相似语句所对应的回答语句;
    对所述注意力矩阵求极大值,得到所述第一回答语句与所述回答语句中的其他回答语句的相似关键词;
    将所有相似关键词取并集,得到相似关键词集;
    其中,所述相似关键词公式如下:
    Figure PCTCN2022072187-appb-100014
    其中,i表示所在行,j表示所在列,L为预先确定的超参数,
    Figure PCTCN2022072187-appb-100015
    表示求行和最大的L个行,对应提取出的相似关键词。
  20. 根据权利要求15所述的计算机设备,其中,所述训练好的生成模型包括训练好的第一生成模型和训练好的第二生成模型,所述处理器实现将所述差异关键词集和所述相似关键词集输入训练好的生成模型,输出回答的步骤,包括:
    将所述差异关键词集和所述相似关键词集输入所述训练好的第一生成模型,通过预测所 述差异关键词集和相似关键词集中的词语在语句中的位置,输出有序的关键词序列;
    将所述有序的关键词序列输入所述训练好的第二生成模型,输出回答;
    其中,所述训练好的生成模型是基于预训练语言模型BERT得到的。
PCT/CN2022/072187 2021-06-01 2022-01-14 基于人工智能的回答生成方法、装置、设备及存储介质 WO2022252636A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202110609412.5A CN113239169B (zh) 2021-06-01 2021-06-01 基于人工智能的回答生成方法、装置、设备及存储介质
CN202110609412.5 2021-06-01

Publications (1)

Publication Number Publication Date
WO2022252636A1 true WO2022252636A1 (zh) 2022-12-08

Family

ID=77136270

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/072187 WO2022252636A1 (zh) 2021-06-01 2022-01-14 基于人工智能的回答生成方法、装置、设备及存储介质

Country Status (2)

Country Link
CN (1) CN113239169B (zh)
WO (1) WO2022252636A1 (zh)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116843149A (zh) * 2023-07-11 2023-10-03 深圳市深水水务咨询有限公司 一种基于生成式学习的水库防洪调度方法
CN116860950A (zh) * 2023-09-04 2023-10-10 北京市电通电话技术开发有限公司 一种术语对话机器人语料更新方法及***
CN117474043A (zh) * 2023-12-27 2024-01-30 湖南三湘银行股份有限公司 一种基于训练模型的智能问答***
CN118093796A (zh) * 2024-04-29 2024-05-28 浪潮云信息技术股份公司 一种多轮对话方法、装置、设备及存储介质

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113239169B (zh) * 2021-06-01 2023-12-05 平安科技(深圳)有限公司 基于人工智能的回答生成方法、装置、设备及存储介质
CN113609275B (zh) * 2021-08-24 2024-03-26 腾讯科技(深圳)有限公司 信息处理方法、装置、设备及存储介质
CN113868398A (zh) * 2021-10-14 2021-12-31 北京倍倾心智能科技中心(有限合伙) 对话数据集、安全检测模型的构建方法、对话***的安全评估方法、介质及计算设备

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111368042A (zh) * 2020-02-13 2020-07-03 平安科技(深圳)有限公司 智能问答方法、装置、计算机设备及计算机存储介质
US20210034678A1 (en) * 2018-04-23 2021-02-04 Ntt Docomo, Inc. Dialogue server
CN112632252A (zh) * 2020-12-25 2021-04-09 中电金信软件有限公司 对话应答方法、装置、计算机设备和存储介质
CN112765306A (zh) * 2020-12-30 2021-05-07 金蝶软件(中国)有限公司 智能问答方法、装置、计算机设备和存储介质
CN113239169A (zh) * 2021-06-01 2021-08-10 平安科技(深圳)有限公司 基于人工智能的回答生成方法、装置、设备及存储介质

Family Cites Families (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9384678B2 (en) * 2010-04-14 2016-07-05 Thinkmap, Inc. System and method for generating questions and multiple choice answers to adaptively aid in word comprehension
JP2014021535A (ja) * 2012-07-12 2014-02-03 Mitsubishi Electric Corp 関連キーワード列抽出装置及び関連キーワード列抽出方法ならびに相互関係文の検索装置
CN107679225B (zh) * 2017-10-20 2021-03-09 哈尔滨工业大学 一种基于关键词的回复生成方法
CN109033221A (zh) * 2018-06-29 2018-12-18 上海银赛计算机科技有限公司 答案生成方法、装置及服务器
KR102137809B1 (ko) * 2018-09-19 2020-07-24 네이버 주식회사 자동 답변 제공 방법
CN111128135B (zh) * 2018-10-15 2022-09-27 珠海格力电器股份有限公司 语音交流方法及装置
CN110362651A (zh) * 2019-06-11 2019-10-22 华南师范大学 检索和生成相结合的对话方法、***、装置和存储介质
CN110457459B (zh) * 2019-08-16 2022-04-08 达闼机器人有限公司 基于人工智能的对话生成方法、装置、设备及存储介质
CN111177339B (zh) * 2019-12-06 2023-07-25 百度在线网络技术(北京)有限公司 对话生成方法、装置、电子设备及存储介质
CN111460081B (zh) * 2020-03-30 2023-04-07 招商局金融科技有限公司 基于深度学习的答案生成方法、电子装置及可读存储介质
CN111782767A (zh) * 2020-06-30 2020-10-16 北京三快在线科技有限公司 问答方法、装置、设备及存储介质

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20210034678A1 (en) * 2018-04-23 2021-02-04 Ntt Docomo, Inc. Dialogue server
CN111368042A (zh) * 2020-02-13 2020-07-03 平安科技(深圳)有限公司 智能问答方法、装置、计算机设备及计算机存储介质
CN112632252A (zh) * 2020-12-25 2021-04-09 中电金信软件有限公司 对话应答方法、装置、计算机设备和存储介质
CN112765306A (zh) * 2020-12-30 2021-05-07 金蝶软件(中国)有限公司 智能问答方法、装置、计算机设备和存储介质
CN113239169A (zh) * 2021-06-01 2021-08-10 平安科技(深圳)有限公司 基于人工智能的回答生成方法、装置、设备及存储介质

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116843149A (zh) * 2023-07-11 2023-10-03 深圳市深水水务咨询有限公司 一种基于生成式学习的水库防洪调度方法
CN116860950A (zh) * 2023-09-04 2023-10-10 北京市电通电话技术开发有限公司 一种术语对话机器人语料更新方法及***
CN116860950B (zh) * 2023-09-04 2023-11-14 北京市电通电话技术开发有限公司 一种术语对话机器人语料更新方法及***
CN117474043A (zh) * 2023-12-27 2024-01-30 湖南三湘银行股份有限公司 一种基于训练模型的智能问答***
CN117474043B (zh) * 2023-12-27 2024-04-02 湖南三湘银行股份有限公司 一种基于训练模型的智能问答***
CN118093796A (zh) * 2024-04-29 2024-05-28 浪潮云信息技术股份公司 一种多轮对话方法、装置、设备及存储介质

Also Published As

Publication number Publication date
CN113239169B (zh) 2023-12-05
CN113239169A (zh) 2021-08-10

Similar Documents

Publication Publication Date Title
WO2022252636A1 (zh) 基于人工智能的回答生成方法、装置、设备及存储介质
US11740863B2 (en) Search and knowledge base question answering for a voice user interface
WO2020177282A1 (zh) 一种机器对话方法、装置、计算机设备及存储介质
US20210142794A1 (en) Speech processing dialog management
WO2020147428A1 (zh) 交互内容生成方法、装置、计算机设备及存储介质
US20190272269A1 (en) Method and system of classification in a natural language user interface
WO2019153522A1 (zh) 智能交互方法、电子装置及存储介质
KR20210158344A (ko) 디지털 어시스턴트를 위한 머신 러닝 시스템
US10755177B1 (en) Voice user interface knowledge acquisition system
CN110741364A (zh) 确定自动化助理对话的状态
WO2021190259A1 (zh) 一种槽位识别方法及电子设备
CN110928994A (zh) 相似案例检索方法、相似案例检索装置和电子设备
WO2021114841A1 (zh) 一种用户报告的生成方法及终端设备
US20220261545A1 (en) Systems and methods for producing a semantic representation of a document
WO2021204017A1 (zh) 文本意图识别方法、装置以及相关设备
EP3620994A1 (en) Methods, apparatuses, devices, and computer-readable storage media for determining category of entity
WO2021063089A1 (zh) 规则匹配方法、规则匹配装置、存储介质及电子设备
US11170765B2 (en) Contextual multi-channel speech to text
CN116955561A (zh) 问答方法、装置、电子设备以及存储介质
WO2022022049A1 (zh) 文本长难句的压缩方法、装置、计算机设备及存储介质
Aattouri et al. Modeling of an artificial intelligence based enterprise callbot with natural language processing and machine learning algorithms
CN113111658B (zh) 校验信息的方法、装置、设备和存储介质
CN112307738A (zh) 用于处理文本的方法和装置
CN116775873A (zh) 一种多模态对话情感识别方法
US20240095445A1 (en) Systems and methods for language modeling with textual clincal data

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: 22814689

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: 22814689

Country of ref document: EP

Kind code of ref document: A1