CN113239169B - Answer generation method, device, equipment and storage medium based on artificial intelligence - Google Patents
Answer generation method, device, equipment and storage medium based on artificial intelligence Download PDFInfo
- Publication number
- CN113239169B CN113239169B CN202110609412.5A CN202110609412A CN113239169B CN 113239169 B CN113239169 B CN 113239169B CN 202110609412 A CN202110609412 A CN 202110609412A CN 113239169 B CN113239169 B CN 113239169B
- Authority
- CN
- China
- Prior art keywords
- answer
- sentences
- similar
- sentence
- replied
- Prior art date
- Legal status (The legal status 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 status listed.)
- Active
Links
- 238000000034 method Methods 0.000 title claims abstract description 51
- 238000013473 artificial intelligence Methods 0.000 title claims abstract description 20
- 238000000605 extraction Methods 0.000 claims abstract description 22
- 239000013598 vector Substances 0.000 claims description 41
- 239000011159 matrix material Substances 0.000 claims description 24
- 238000004590 computer program Methods 0.000 claims description 15
- 238000012549 training Methods 0.000 description 9
- 238000010586 diagram Methods 0.000 description 7
- 230000002457 bidirectional effect Effects 0.000 description 2
- 238000011161 development Methods 0.000 description 2
- 238000005516 engineering process Methods 0.000 description 2
- 238000003058 natural language processing Methods 0.000 description 2
- 238000012545 processing Methods 0.000 description 2
- 238000012216 screening Methods 0.000 description 2
- 238000009825 accumulation Methods 0.000 description 1
- 238000003491 array Methods 0.000 description 1
- 238000013528 artificial neural network Methods 0.000 description 1
- 238000004364 calculation method Methods 0.000 description 1
- 238000012512 characterization method Methods 0.000 description 1
- 238000004891 communication Methods 0.000 description 1
- 238000013136 deep learning model Methods 0.000 description 1
- 230000007547 defect Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000004044 response Effects 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
- 230000009466 transformation Effects 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/30—Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
- G06F16/33—Querying
- G06F16/332—Query formulation
- G06F16/3329—Natural language query formulation or dialogue systems
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F40/00—Handling natural language data
- G06F40/20—Natural language analysis
- G06F40/279—Recognition of textual entities
- G06F40/289—Phrasal analysis, e.g. finite state techniques or chunking
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F40/00—Handling natural language data
- G06F40/30—Semantic analysis
- G06F40/35—Discourse or dialogue representation
-
- Y—GENERAL 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
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE 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/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Abstract
The application relates to the field of artificial intelligence, in particular to an answer generation method, device, equipment and storage medium based on artificial intelligence, which realize that a generation model generates more relevant and more accurate answers under the condition that the statement information to be replied of a user is limited. The answer generation method based on artificial intelligence comprises the following steps: receiving a sentence to be replied, and inputting the sentence to be replied into a retrieval model; and obtaining similar sentences which are screened from a preset dialogue corpus by the retrieval model and are matched with the sentences to be replied, and obtaining answer sentences of the similar sentences in the dialogue corpus. Based on a preset semantic alignment keyword extraction model, extracting difference keywords of similar sentences and sentences to be replied to obtain a difference keyword set; and extracting similar keywords of the answer sentence to obtain a similar keyword set. And inputting the difference keyword set and the similar keyword set into a trained generation model, and outputting an answer.
Description
Technical Field
The present application relates to the field of artificial intelligence, and in particular, to an answer generation method, apparatus, device and storage medium based on artificial intelligence.
Background
With the continuous development of social media and the continuous progress of artificial intelligence technology, intelligent dialogue systems play an increasingly important role in the current society. The question-answering system based on the generated method uses standard question-answering pairs as training data, and uses a generated model (usually an Encoder-Decoder framework) in natural language processing to train and obtain answer results. The method based on the generated model can automatically generate answers highly related to user questions, but because of the limited information contained in the questions of the user, the results of the generated model may tend to be safe answers, such as "good", "people", etc., which are meaningless and time consuming for users using an ergonomic dialog system.
Disclosure of Invention
The application provides an answer generation method, device, equipment and storage medium based on artificial intelligence, which can realize that more relevant and more accurate answers are given under the condition that user question information is limited.
In a first aspect, the present application provides an artificial intelligence based answer generation method, the answer generation method comprising:
receiving a sentence to be replied, and inputting the sentence to be replied into a retrieval model;
obtaining similar sentences which are screened from a preset dialogue corpus by the retrieval model and are matched with the sentences to be replied, and obtaining answer sentences of the similar sentences in the dialogue corpus;
extracting the difference keywords of the similar sentences and the sentences to be replied on the basis of a preset semantic alignment keyword extraction model to obtain a difference keyword set;
extracting similar keywords of the answer sentence to obtain a similar keyword set;
and inputting the difference keyword set and the similar keyword set into a trained generation model, and outputting an answer.
In a second aspect, the present application also provides an artificial intelligence based answer generation device, the answer generation device comprising:
the sentence receiving module is used for receiving the sentence to be replied and inputting the sentence to be replied into the search model;
the similar sentence acquisition module is used for acquiring the search model, screening similar sentences matched with sentences to be replied from a preset dialogue corpus, and acquiring answer sentences of the similar sentences in the dialogue corpus;
the difference keyword extraction module is used for extracting difference keywords of the similar sentences and the sentences to be replied based on a preset semantic alignment keyword extraction model to obtain a difference keyword set;
the similar keyword extraction module is used for extracting similar keywords of the answer sentence to obtain a similar keyword set;
and the answer generation module is used for inputting the difference keyword set and the similar keyword set into a trained generated question-answer model and outputting an answer.
In a third aspect, the present application also provides a computer device comprising a memory and a processor; the memory is used for storing a computer program; the processor is configured to execute the computer program and implement the answer generation method as described above when the computer program is executed.
In a fourth aspect, the present application also provides a storage medium storing a computer program which, when executed by a processor, causes the processor to implement an answer generation method as described above.
The answer generation method, the answer generation device, the computer equipment and the storage medium disclosed by the application are used for searching similar sentences for sentences to be replied of a user through a search model, obtaining answer sentences of the similar sentences, further extracting difference keywords for the similar sentences, extracting the similar keywords for the answer sentences, taking the difference keywords and the similar keywords as input of a generation model, and adding input information for the generation model. Therefore, the method and the device can overcome the problem that the generation model gives safe and meaningless answers due to the fact that the information contained in the question of the user is limited, and achieve the purpose that more relevant and accurate answers are given under the condition that the information of the question of the user is limited.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for the description of the embodiments will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present application, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a schematic flow chart of an answer generation method provided by an embodiment of the application;
FIG. 2 is a network schematic diagram of an answer generation method provided by an embodiment of the application;
FIG. 3 is a schematic block diagram of an answer generation device provided by an embodiment of the application;
fig. 4 is a schematic block diagram of a computer device according to an embodiment of the present application.
Detailed Description
The following description of the embodiments of the present application will be made clearly and fully with reference to the accompanying drawings, in which it is evident that the embodiments described are some, but not all embodiments of the application. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application.
The flow diagrams depicted in the figures are merely illustrative and not necessarily all of the elements and operations/steps are included or performed in the order described. For example, some operations/steps may be further divided, combined, or partially combined, so that the order of actual execution may be changed according to actual situations.
It is to be understood that the terminology used in the description of the application herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. As used in this specification and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise.
It should also be understood that the term "and/or" as used in the present specification and the appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes such combinations.
With the continuous development of social media and the continuous progress of artificial intelligence technology, intelligent dialogue systems play an increasingly important role in the current society. The small artificial intelligence assistant such as hundred degrees and the dialog system ice of Microsoft corporation are all focused on the service scene of realizing man-machine dialog, the former uses a search method to recall the answer expected by the user, and the latter realizes automatic answer generation according to the questions of the user through a deep learning model.
The search-based question-answering system is mainly applied to intelligent question-answering systems (such as a Taobao platform robot customer service) in a specific field, and the method usually maintains a dialogue corpus database which can be used for searching in advance, takes input questions of a user as question sentences, then utilizes sentence similarity calculation to find out the question sentences which are most similar to the question sentences of the user, and then outputs answers corresponding to the question sentences as responses. The question-answer pairs in the database pass the strict screening, so that the answers returned to the user are smooth in language and clear in expression. But due to limitations in database size and sentence similarity matching methods, the final answer is often subject-independent, unknowingly.
The question-answering system based on the generated method is mostly trained by using a generated model (usually an Encoder-Decoder framework) in natural language processing as training data, and the method can automatically generate answers highly related to user questions, but because the user questions contain limited information, the results of the generated question-answering model may tend to be safe answers, such as 'good', 'people' and the like, which is meaningless and time-consuming for consumers using the human dialogue system.
Based on the defects and shortcomings of the existing intelligent dialogue system, the application provides an answer generation method combining a search method and a generation method, and input information of a generation model is increased based on sentences of a user through the search method, so that the generation method can generate more relevant answers based on sentences of the user. Firstly, searching the sentences of the user based on a search method to obtain similar sentences matched with the sentences of the user and answers corresponding to the similar sentences. And extracting difference keywords from all similar sentences and sentences of the user, extracting similar keywords from all answers, taking the obtained difference keywords and the obtained similar keywords as inputs of a generating method, and outputting a final answer by a generating model. Thus, more accurate and relevant answers are generated under the condition that information provided by sentences of a user is limited.
The embodiment of the application provides an artificial intelligence-based answer generation method, an artificial intelligence-based answer generation device, an artificial intelligence-based answer generation equipment and a storage medium. The answer generation method can be applied to a server, a chip in a specific product, for example, a chip in an artificial intelligent device. The input information is added to the generation model based on the sentences to be replied by using the retrieval model, so that the more accurate and more relevant answer given by the user under the condition that the information given by the user is limited is realized. The server may be an independent server or a server cluster.
Some embodiments of the present application are described in detail below with reference to the accompanying drawings. The following embodiments and features of the embodiments may be combined with each other without conflict.
Referring to fig. 1, fig. 1 is a schematic flow chart of an answer generation method based on artificial intelligence according to an embodiment of the application. The answer generation method can be applied to a server to obtain more accurate answers more relevant to the user's sentences.
As shown in fig. 1, the answer generation method specifically includes steps S101 to S105.
S101, receiving a statement to be replied, and inputting the statement to be replied into a retrieval model.
Wherein the sentence to be replied comprises a question sentence or a non-question sentence; the sentence to be replied can be in a voice form or a text form, and when the sentence to be replied is in the voice form, the sentence to be replied needs to be converted into the text form so as to be input into a retrieval model.
S102, obtaining similar sentences which are screened from a preset dialogue corpus by the retrieval model and are matched with the sentences to be replied, and obtaining answer sentences of the similar sentences in the dialogue corpus.
Inputting the sentences to be replied and the sentences in the preset dialogue corpus into the retrieval model, and generating Jaccard similarity coefficients for representing the similarity between the sentences in the preset dialogue corpus and the sentences to be replied; acquiring a similar sentence which is screened from the preset dialogue corpus based on the Jaccard similarity coefficient and is matched with the sentence to be replied by the retrieval model; and the Jaccard similarity coefficient of the similar sentence and the sentence to be replied is larger than a first preset threshold value and smaller than a second preset threshold value.
In some embodiments, after inputting the sentence to be replied and the sentence in the preset dialogue prediction library into the retrieval model, the retrieval model generates a Jaccard similarity coefficient (Jaccard Similarity coefficient) representing the text similarity between the sentence and the sentence to be replied for the sentence in the preset dialogue corpus, and further judges whether the sentence is a similar sentence of the sentence to be replied according to the Jaccard similarity coefficient. The higher the Jaccard similarity coefficient value between the sentences, the higher the similarity between the representing sentences, and the higher the matching degree. The search model screens out sentences with Jaccard similarity coefficient values larger than a first preset threshold and smaller than a second preset threshold in a preset dialogue corpus and sentences with sentences to be replied, selects a preset number of the Jaccard similarity coefficient values highest from the screened results as the finally output similar sentences according to requirements, further obtains corresponding answer sentences of the similar sentences in a preset dialogue prediction library, and corresponds the similar sentences output by the search model with the corresponding answer sentences one by one to form similar question-answer pairs.
The retrieval model screens out sentences with the similarity coefficient greater than 0.5 and less than 0.9 with the sentences to be replied in the preset dialogue corpus, and selects the sentences with the highest similarity coefficient of 3 Jaccard from the sentences as similar sentences to be output.
It should be noted that the first preset threshold, the second preset threshold, and the preset number may be set according to practical applications, which is not particularly limited in the present application.
In other embodiments, the retrieval model may also be used to evaluate text similarity between sentences based on cosine similarity, thereby matching similar sentences that are similar to the sentence to be replied to. The similarity is to evaluate the similarity of two sentence vectors by calculating the included angle between the two sentence vectors.
It should be noted that, the preset dialogue corpus is a pre-maintained database containing dialogue sentences, which includes both question-answer sentences and answer sentences corresponding to the question-answer sentences. The dialogue corpus can be the dialogue corpus for recording general daily dialogues according to the requirements of application scenes, and can also be the dialogue corpus for recording the related specific application scenes.
S103, extracting the difference keywords of the similar sentences and the sentences to be replied based on a preset semantic alignment keyword extraction model to obtain a difference keyword set.
The application proposes a semantic alignment keyword extraction model (Semantic Alignment Keyword Extraction, SAKE) for keyword extraction. The semantic alignment keyword extraction model is based on calculating an Attention matrix characterizing deep semantics using Cross-Attention (Cross-Attention), and extracting keywords based on the Attention matrix.
Specifically, converting a sentence to be replied into a first vector, converting a similar sentence into a second vector, and calculating an attention matrix according to the first vector and the second vector; obtaining minimum values of the attention matrix to obtain difference keywords of similar sentences and sentences to be replied; and taking the difference keywords as a union set to obtain a difference keyword set.
First, there are many ways in which a text sentence needs to be converted into a vector form, and the sentence is vectorized.
In some embodiments, the text sentence is first one-hot coded into a sparse matrix, then the sparse matrix is changed into a dense matrix by linear transformation by randomly initializing the emmbedding layer, and the mutually independent one-hot vectors are changed into relationship vectors that take into account the inherent relations between words.
In other embodiments, statement vectors may also be generated based on a neural network language model (Nerual Network Language Model, NNLM).
It should be noted that: all similar sentences are aligned to the sentences to be replied, so that the sentences to be replied are converted into first vectors, other similar sentences are converted into second vectors, and the attention matrix between each similar sentence and the sentences to be replied is calculated in sequence. Wherein the attention matrix is expressed as:
wherein v A For the statement to be replied to be converted into a first vector v B For the similar statement to be converted into a second vector, d k Is a normalized coefficient.
By minimisation of the attention matrix, words that are present in the sentence to be replied but not in the similar sentence can be obtained as the difference keywords between the two. Wherein, the difference keyword formula is as follows:
where i denotes the row, j denotes the column, L is a predetermined hyper-parameter,representing the row and the minimum L rows, corresponding to the extracted difference keywords.
And merging all the difference keywords of the similar sentences and the sentences to be replied to obtain a difference keyword set.
For example, the statement to be replied to is: which is better for wine and white spirit? Assume that the similar sentence obtained by the search model is: similar statement 1: is the spirit better to drink than wine? Similar statement 2: is there a better wine to drink than white spirit? The difference keywords of the similar sentence 1 and the sentence to be replied are as follows: "more", "and" which ". The difference keywords of the similar sentence 2 and the sentence to be replied are as follows: "wine", "and", "which". The difference keywords are taken as a union set, and the obtained difference keyword set is as follows: "more" and "which" wine "is used.
S104, extracting similar keywords of the answer sentence, and obtaining a similar keyword set.
Specifically, a first answer sentence in the answer sentences is converted into a first answer vector, other answer sentences in the answer sentences are converted into a second answer vector, and an attention matrix is calculated according to the first answer vector and the second answer vector. The first answer sentence is an answer sentence corresponding to a similar sentence with the highest matching degree with the sentence to be replied.
It should be noted that: and taking the answer sentence corresponding to the similar sentence which is most matched with the sentence to be replied as a reference answer sentence, and aligning other answer sentences to the reference answer sentence. Therefore, the reference answer sentence is converted into a first answer vector, other answer sentences in the answer sentences are converted into a second answer vector, and the attention matrix between the other answer sentences and the reference answer sentence is sequentially calculated. And maximizing the attention matrix to obtain similar keywords of the first answer sentence and other answer sentences in the answer sentences. Wherein, the formula of the similar keywords is as follows:
wherein, the formula of the similar keywords is as follows:
where i denotes the row, j denotes the column, L is a predetermined hyper-parameter,representing the row and the maximum L rows, corresponding to the extracted similar keywords.
And taking similar keywords from all other answer sentences except the reference answer sentences and the reference answer sentences, and taking a union set from all the similar keywords to obtain a similar keyword set.
Illustratively, answer sentence 1 is "I'm person is dislike to drink", and answer sentence 2 is "see person taste, I prefer white spirit", for example. The similar keywords of answer sentence 2 and answer sentence 1 are: "personal", "like", "wine". The set of similar keywords is therefore: "person" "" like "" "wine" ".
The keyword extraction model based on semantic alignment provided by the application utilizes the attention matrix to perform normalized accumulation, so that deep semantic relevance and accumulated semantic characteristics are considered in keyword extraction, and the extracted keywords are more accurate.
S105, inputting the difference keyword set and the similar keyword set into a trained generation model, and outputting an answer. The generative model comprises a trained first generative model and a trained second generative model.
Specifically, the difference keyword set and the similar keyword set are input into a trained first generation model, and an ordered keyword sequence is output by predicting the positions of words in the difference keyword set and the similar keyword set in sentences; and inputting the ordered keyword sequence into a trained second generation model, and outputting an answer.
In the embodiment provided by the application, both the first and second generative models are based on the pre-trained language model BERT (Bidirectional Encoder Representation from Transformers), but are trained based on different model parameters and training strategies. The BERT model is not pre-trained by adopting a traditional unidirectional language model or a method for shallow splicing of two unidirectional language models, but adopts a new mask language model (masked language model, MLM) to generate a deep bidirectional language representation. The BERT model adopts MLM to pretrain bi-directional converters to generate deep bi-directional language characterization. After pre-training, only one extra output layer is needed to be added for fine-tuning, so that high-level performance can be obtained in various downstream tasks, and structural modification of a BERT model for specific tasks is not needed.
In the embodiment provided by the application, the network structure of the first generation model is as follows: the first BERT model is followed by a first full connectivity layer and Softmax. The training goal of the first generative model is to output a predicted ordered set of words based on a given unordered set of words. Specifically, the unordered keyword set is input into a first BERT model, the enhanced semantic vector of the word is output through transformer encoder, a first full-connection layer and a Softmax layer are connected behind the first BERT model, and the predicted ordered keyword set is output. It should be noted that, in the training process of the first generation model, the parameters of the first BERT model are not finely adjusted, but the trained first generation model is obtained by adjusting the parameters of the first full connection layer.
In an embodiment of the present application, the network structure of the second generative model is: the second BERT model is followed by a second full connectivity layer and Softmax. The training goal of the second generative model is to output predicted complete sentences based on the ordered keyword sets. The second generation model is based on the context information and the understanding of the semantics, and in the output sentence, the words which are not contained in the keyword set can be obtained through prediction, and the words which are contained in a part of the keyword set can be ignored. In the training process of the second generation model, the parameters of the second BERT model and the second full connection layer need to be fine-tuned to obtain a trained second generation model.
Firstly, an unordered keyword set obtained by taking a union set of a difference keyword set and a similar keyword set is input into a trained first generation model to generate an ordered keyword set, wherein the ordered keyword set is equivalent to combining discrete words into an incomplete sentence. And secondly, inputting the ordered keyword set into a trained second generation model, and outputting a complete sentence by the second generation model based on the ordered keyword set.
And outputting predicted answers through a two-stage generation model, wherein the first generation model predicts position information to obtain an ordered discrete word set, and the second stage predicts finally generated answer sentences according to the ordered discrete word set, so that the generated results are smoother.
According to the answer generation method provided by the application, firstly, similar sentences are searched for to-be-replied sentences of a user based on a search model, answer sentences of the similar sentences are obtained, further difference keywords are extracted for the similar sentences, the similar keywords are extracted for the answer sentences, the difference keywords and the similar keywords are used as input of a generation model, and input information is added for the generation model. Therefore, the problem that the generation model gives safe and meaningless answers due to the fact that the information contained in the question of the user is limited can be solved, and the result of more relevant and accurate answers is given under the condition that the information of the question of the user is limited.
Referring to fig. 3, an embodiment of the present application provides a schematic block diagram of an answer generation device that may be configured in a server.
As shown in fig. 3, the answer generation device 400 includes: a sentence receiving module 401, a similar sentence obtaining module 402, a difference keyword extracting module 403, a similar keyword extracting module 404, and an answer generating module 405.
The sentence receiving module 401 is configured to receive a sentence to be replied, and input the sentence to be replied into a retrieval model;
the similar sentence obtaining module 402 is configured to obtain similar sentences that are screened by the search model from a preset dialogue corpus and that are matched with the sentences to be replied, and obtain answer sentences of the similar sentences in the dialogue corpus.
The difference keyword extraction module 403 is configured to extract a difference keyword of the similar sentence and the sentence to be replied based on a preset semantic alignment keyword extraction model, so as to obtain a difference keyword set.
And a similar keyword extraction module 404, configured to extract similar keywords of the answer sentence, so as to obtain a similar keyword set.
And the answer generation module 405 is configured to input the difference keyword set and the similar keyword set into a trained generation model, and output an answer.
It should be noted that, for convenience and brevity of description, the specific working process of the apparatus and each module described above may refer to the corresponding process in the foregoing method embodiment, which is not described herein again.
The apparatus described above may be implemented in the form of a computer program which is executable on a computer device as shown in fig. 4.
Referring to fig. 4, fig. 4 is a schematic block diagram of a computer device according to an embodiment of the present application. The computer device may be a server.
With reference to FIG. 4, the computer device includes a processor, a memory, and a network interface connected by a system bus, where the memory may include storage media and internal memory.
The storage medium may store an operating system and a computer program. The computer program comprises program instructions which, when executed, cause the processor to perform any of a number of answer generation methods.
The processor is used to provide computing and control capabilities to support the operation of the entire computer device.
The internal memory provides an environment for the execution of a computer program in a storage medium that, when executed by a processor, causes the processor to perform any of a number of answer generation methods.
The network interface is used for network communication such as transmitting assigned tasks and the like. It will be appreciated by persons skilled in the art that the architecture shown in fig. 4 is merely a block diagram of some of the architecture relevant to the present inventive arrangements and is not limiting as to the computer device to which the present inventive arrangements are applicable, and that a particular computer device may include more or fewer components than shown, or may combine some of the components, or have a different arrangement of components.
It should be appreciated that the processor may be a central processing unit (Central Processing Unit, CPU), but may also be other general purpose processors, digital signal processors (Digital Signal Processor, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), field-programmable gate arrays (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or the like. Wherein the general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
Wherein in one embodiment the processor is configured to run a computer program stored in the memory to implement the steps of:
receiving a sentence to be replied, and inputting the sentence to be replied into a retrieval model;
obtaining similar sentences which are screened from a preset dialogue corpus by the retrieval model and are matched with the sentences to be replied, and obtaining answer sentences of the similar sentences in the dialogue corpus;
extracting difference keywords from the similar sentences and the sentences to be replied on the basis of a preset semantic alignment keyword extraction model to obtain a difference keyword set;
extracting similar keywords from the answer sentences to obtain a similar keyword set;
and inputting the difference keyword set and the similar keyword set into a trained generation model, and outputting an answer.
In one embodiment, when the processor is configured to obtain similar sentences that are screened from a preset dialogue corpus by the search model and match the sentences to be replied, the processor is configured to:
inputting the sentences to be replied and the sentences in the preset dialogue corpus into the retrieval model, and generating Jaccard similarity coefficients for representing the similarity between the sentences in the preset dialogue corpus and the sentences to be replied;
acquiring a similar sentence which is screened from the preset dialogue corpus based on the Jaccard similarity coefficient and is matched with the sentence to be replied by the retrieval model; and the Jaccard similarity coefficient of the similar sentence and the sentence to be replied is larger than a first preset threshold value and smaller than a second preset threshold value.
In one embodiment, when implementing a keyword extraction model based on preset semantic alignment, the processor is configured to extract a difference keyword between the similar sentence and the sentence to be replied to obtain a difference keyword set, so as to implement:
converting the statement to be replied into a first vector, converting a similar statement into a second vector, and calculating an attention matrix according to the first vector and the second vector;
obtaining minimum values of the attention matrix to obtain difference keywords of similar sentences and sentences to be replied;
and taking the difference keywords as a union set to obtain a difference keyword set.
In one embodiment, the processor, when used to calculate the attention matrix, is configured to implement:
wherein v A For the statement to be replied to be converted into a first vector v B For the similar statement to be converted into a second vector, d k Is a normalized coefficient;
the difference keyword formula is as follows:
where i denotes the row, j denotes the column, L is a predetermined hyper-parameter,representing the row and the minimum L rows, corresponding to the extracted difference keywords.
In one embodiment, the processor is configured to, when configured to extract similar keywords of the answer sentence, obtain a set of similar keywords, implement:
converting a first answer sentence of the answer sentences into a first answer vector, converting other answer sentences in the answer sentences into a second answer vector, and calculating an attention matrix according to the first answer vector and the second answer vector; the first answer sentence is an answer sentence corresponding to a similar sentence with the highest matching degree with the sentence to be replied;
solving maximum values for the attention matrix to obtain similar keywords of the first answer sentence and other answer sentences in the answer sentences;
all similar keywords are collected to obtain a similar keyword set;
wherein, the formula of the similar keywords is as follows:
where i denotes the row, j denotes the column, L is a predetermined hyper-parameter,representing the row and the maximum L rows, corresponding to the extracted similar keywords.
In one embodiment, the trained generating model includes a trained first generating model and a trained second generating model, and the processor, when configured to implement inputting the differential keyword set and the similar keyword set into the trained generating model, is configured to implement:
inputting the difference keyword set and the similar keyword set into the trained first generation model, and outputting an ordered keyword sequence by predicting the positions of words in the sentence of the difference keyword set and the similar keyword set;
inputting the ordered keyword sequence into the trained second generation model, and outputting an answer.
The trained generation model is obtained based on a pre-training language model BERT.
The embodiment of the application also provides a storage medium, wherein the storage medium stores a computer program, the computer program comprises program instructions, and the processor executes the program instructions to realize any answer generation method provided by the embodiment of the application.
The storage medium may be an internal storage unit of the computer device according to the foregoing embodiment, for example, 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, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card) or the like, which are provided on the computer device.
While the application has been described with reference to certain preferred embodiments, it will be understood by those skilled in the art that various changes and substitutions of equivalents may be made and equivalents will be apparent to those skilled in the art without departing from the scope of the application. Therefore, the protection scope of the application is subject to the protection scope of the claims.
Claims (7)
1. An artificial intelligence based answer generation method, comprising:
receiving a sentence to be replied, and inputting the sentence to be replied into a retrieval model;
obtaining similar sentences which are screened from a preset dialogue corpus by the retrieval model and are matched with the sentences to be replied, and obtaining answer sentences of the similar sentences in the dialogue corpus;
extracting the difference keywords of the similar sentences and the sentences to be replied on the basis of a preset semantic alignment keyword extraction model to obtain a difference keyword set;
extracting similar keywords of the answer sentence to obtain a similar keyword set;
inputting the difference keyword set and the similar keyword set into a trained generation model, and outputting an answer;
the extracting the difference keywords of the similar sentences and the sentences to be replied based on the preset semantic alignment keyword extraction model, and obtaining a difference keyword set comprises:
converting the statement to be replied into a first vector, converting a similar statement into a second vector, and calculating an attention matrix according to the first vector and the second vector;
obtaining minimum values of the attention matrix to obtain difference keywords of similar sentences and sentences to be replied;
the difference keywords are collected in a union mode, and a difference keyword set is obtained;
wherein the attention matrix is expressed as:
wherein,a first vector translated for the statement to be replied to,/->A second vector translated for said similar sentence, < >>Is a normalized coefficient;
the difference keyword formula is as follows:
wherein,representing the line of the place,/->Representing the column in->For a predetermined superparameter ++>Representing the sum of rows and minimaA plurality of rows corresponding to the extracted difference keywords;
the trained generation model comprises a trained first generation model and a trained second generation model;
inputting the difference keyword set and the similar keyword set into a trained generation model, and outputting an answer, wherein the method comprises the following steps:
inputting the difference keyword set and the similar keyword set into the trained first generation model, and outputting an ordered keyword sequence by predicting the positions of words in the sentence of the difference keyword set and the similar keyword set;
inputting the ordered keyword sequence into the trained second generation model, and outputting an answer.
2. The answer generation method according to claim 1, wherein the obtaining similar sentences which are screened by the search model from a preset dialogue corpus and are matched with the sentences to be replied comprises:
inputting the sentences to be replied and the sentences in the preset dialogue corpus into the retrieval model, and generating Jaccard similarity coefficients for representing the similarity between the sentences in the preset dialogue corpus and the sentences to be replied;
acquiring a similar sentence which is screened from the preset dialogue corpus based on the Jaccard similarity coefficient and is matched with the sentence to be replied by the retrieval model;
and the Jaccard similarity coefficient of the similar sentence and the sentence to be replied is larger than a first preset threshold value and smaller than a second preset threshold value.
3. The answer generation method according to claim 1, wherein the extracting similar keywords of the answer sentence, obtaining a set of similar keywords, comprises:
converting a first answer sentence of the answer sentences into a first answer vector, converting other answer sentences in the answer sentences into a second answer vector, and calculating an attention matrix according to the first answer vector and the second answer vector; the first answer sentence is an answer sentence corresponding to a similar sentence with the highest matching degree with the sentence to be replied;
solving maximum values for the attention matrix to obtain similar keywords of the first answer sentence and other answer sentences in the answer sentences;
all similar keywords are collected to obtain a similar keyword set;
wherein, the formula of the similar keywords is as follows:
wherein,representing the line of the place,/->Representing the column in->For a predetermined superparameter, this means that the sum of the lines is maximized +.>And the lines correspond to the extracted similar keywords.
4. The answer generation method according to claim 1, characterized in that the trained generation model is derived based on a pre-trained language model BERT.
5. An artificial intelligence based answer generation apparatus for implementing an artificial intelligence based answer generation method according to claim 1, the apparatus comprising:
the sentence receiving module is used for receiving the sentence to be replied and inputting the sentence to be replied into the retrieval model;
the similar sentence acquisition module is used for acquiring similar sentences which are screened from a preset dialogue corpus by the retrieval model and are matched with the sentences to be replied, and acquiring answer sentences of the similar sentences in the dialogue corpus;
the difference keyword extraction module is used for extracting the difference keywords of the similar sentences and the sentences to be replied on the basis of a preset semantic alignment keyword extraction model to obtain a difference keyword set;
the similar keyword extraction module is used for extracting similar keywords of the answer sentence to obtain a similar keyword set;
and the answer generation module is used for inputting the difference keyword set and the similar keyword set into a trained generation model and outputting an answer.
6. A computer device, the computer device comprising a memory and a processor;
the memory is used for storing a computer program;
the processor being adapted to execute the computer program and to implement the answer generation method according to any one of claims 1-4 when the computer program is executed.
7. A storage medium storing a computer program which, when executed by a processor, causes the processor to implement the answer generation method of any one of claims 1 to 4.
Priority Applications (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110609412.5A CN113239169B (en) | 2021-06-01 | 2021-06-01 | Answer generation method, device, equipment and storage medium based on artificial intelligence |
PCT/CN2022/072187 WO2022252636A1 (en) | 2021-06-01 | 2022-01-14 | Artificial intelligence-based answer generation method and apparatus, device, and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110609412.5A CN113239169B (en) | 2021-06-01 | 2021-06-01 | Answer generation method, device, equipment and storage medium based on artificial intelligence |
Publications (2)
Publication Number | Publication Date |
---|---|
CN113239169A CN113239169A (en) | 2021-08-10 |
CN113239169B true CN113239169B (en) | 2023-12-05 |
Family
ID=77136270
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202110609412.5A Active CN113239169B (en) | 2021-06-01 | 2021-06-01 | Answer generation method, device, equipment and storage medium based on artificial intelligence |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN113239169B (en) |
WO (1) | WO2022252636A1 (en) |
Families Citing this family (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113239169B (en) * | 2021-06-01 | 2023-12-05 | 平安科技(深圳)有限公司 | Answer generation method, device, equipment and storage medium based on artificial intelligence |
CN113609275B (en) * | 2021-08-24 | 2024-03-26 | 腾讯科技(深圳)有限公司 | Information processing method, device, equipment and storage medium |
CN113868398A (en) * | 2021-10-14 | 2021-12-31 | 北京倍倾心智能科技中心(有限合伙) | Dialogue data set, method for constructing security detection model, method for evaluating security of dialogue system, medium, and computing device |
CN116843149A (en) * | 2023-07-11 | 2023-10-03 | 深圳市深水水务咨询有限公司 | Reservoir flood control scheduling method based on generation type learning |
CN116860950B (en) * | 2023-09-04 | 2023-11-14 | 北京市电通电话技术开发有限公司 | Method and system for updating corpus of term conversation robot |
CN117474043B (en) * | 2023-12-27 | 2024-04-02 | 湖南三湘银行股份有限公司 | Intelligent question-answering system based on training model |
Citations (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109033221A (en) * | 2018-06-29 | 2018-12-18 | 上海银赛计算机科技有限公司 | Answer generation method, device and server |
CN110362651A (en) * | 2019-06-11 | 2019-10-22 | 华南师范大学 | Dialogue method, system, device and the storage medium that retrieval and generation combine |
CN110457459A (en) * | 2019-08-16 | 2019-11-15 | 深圳前海达闼云端智能科技有限公司 | Dialog generation method, device, equipment and storage medium based on artificial intelligence |
KR20200033009A (en) * | 2018-09-19 | 2020-03-27 | 네이버 주식회사 | Method of providing automatic answer |
CN111128135A (en) * | 2018-10-15 | 2020-05-08 | 珠海格力电器股份有限公司 | Voice communication method and device |
CN111177339A (en) * | 2019-12-06 | 2020-05-19 | 百度在线网络技术(北京)有限公司 | Dialog generation method and device, electronic equipment and storage medium |
CN111460081A (en) * | 2020-03-30 | 2020-07-28 | 招商局金融科技有限公司 | Answer generation method based on deep learning, electronic device and readable storage medium |
CN111782767A (en) * | 2020-06-30 | 2020-10-16 | 北京三快在线科技有限公司 | Question answering method, device, equipment and storage medium |
CN112765306A (en) * | 2020-12-30 | 2021-05-07 | 金蝶软件(中国)有限公司 | Intelligent question answering method and device, computer equipment and storage medium |
Family Cites Families (7)
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 (en) * | 2012-07-12 | 2014-02-03 | Mitsubishi Electric Corp | Related keyword string extraction device, related keyword string extraction method and device for searching interrelated sentence |
CN107679225B (en) * | 2017-10-20 | 2021-03-09 | 哈尔滨工业大学 | Reply generation method based on keywords |
JP7043593B2 (en) * | 2018-04-23 | 2022-03-29 | 株式会社Nttドコモ | Dialogue server |
CN111368042A (en) * | 2020-02-13 | 2020-07-03 | 平安科技(深圳)有限公司 | Intelligent question and answer method and device, computer equipment and computer storage medium |
CN112632252B (en) * | 2020-12-25 | 2021-09-17 | 中电金信软件有限公司 | Dialogue response method, dialogue response device, computer equipment and storage medium |
CN113239169B (en) * | 2021-06-01 | 2023-12-05 | 平安科技(深圳)有限公司 | Answer generation method, device, equipment and storage medium based on artificial intelligence |
-
2021
- 2021-06-01 CN CN202110609412.5A patent/CN113239169B/en active Active
-
2022
- 2022-01-14 WO PCT/CN2022/072187 patent/WO2022252636A1/en unknown
Patent Citations (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109033221A (en) * | 2018-06-29 | 2018-12-18 | 上海银赛计算机科技有限公司 | Answer generation method, device and server |
KR20200033009A (en) * | 2018-09-19 | 2020-03-27 | 네이버 주식회사 | Method of providing automatic answer |
CN111128135A (en) * | 2018-10-15 | 2020-05-08 | 珠海格力电器股份有限公司 | Voice communication method and device |
CN110362651A (en) * | 2019-06-11 | 2019-10-22 | 华南师范大学 | Dialogue method, system, device and the storage medium that retrieval and generation combine |
CN110457459A (en) * | 2019-08-16 | 2019-11-15 | 深圳前海达闼云端智能科技有限公司 | Dialog generation method, device, equipment and storage medium based on artificial intelligence |
CN111177339A (en) * | 2019-12-06 | 2020-05-19 | 百度在线网络技术(北京)有限公司 | Dialog generation method and device, electronic equipment and storage medium |
CN111460081A (en) * | 2020-03-30 | 2020-07-28 | 招商局金融科技有限公司 | Answer generation method based on deep learning, electronic device and readable storage medium |
CN111782767A (en) * | 2020-06-30 | 2020-10-16 | 北京三快在线科技有限公司 | Question answering method, device, equipment and storage medium |
CN112765306A (en) * | 2020-12-30 | 2021-05-07 | 金蝶软件(中国)有限公司 | Intelligent question answering method and device, computer equipment and storage medium |
Non-Patent Citations (1)
Title |
---|
Diverse and Specific Clarification Question Generation with Keywords;Zhiling Zhang et al;《arXiv:2104.10317v1 [cs.CL]》;第1-11页 * |
Also Published As
Publication number | Publication date |
---|---|
WO2022252636A1 (en) | 2022-12-08 |
CN113239169A (en) | 2021-08-10 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN113239169B (en) | Answer generation method, device, equipment and storage medium based on artificial intelligence | |
CN112164391B (en) | Statement processing method, device, electronic equipment and storage medium | |
CN113255755B (en) | Multi-modal emotion classification method based on heterogeneous fusion network | |
CN111241237B (en) | Intelligent question-answer data processing method and device based on operation and maintenance service | |
CN109918487A (en) | Intelligent answer method and system based on network encyclopedia | |
Xie et al. | Attention-based dense LSTM for speech emotion recognition | |
CN112989212B (en) | Media content recommendation method, device and equipment and computer storage medium | |
CN113268609A (en) | Dialog content recommendation method, device, equipment and medium based on knowledge graph | |
CN113392265A (en) | Multimedia processing method, device and equipment | |
CN114691864A (en) | Text classification model training method and device and text classification method and device | |
CN114003682A (en) | Text classification method, device, equipment and storage medium | |
CN113705315A (en) | Video processing method, device, equipment and storage medium | |
CN116541493A (en) | Interactive response method, device, equipment and storage medium based on intention recognition | |
Duan et al. | Multimodal matching transformer for live commenting | |
CN117437317A (en) | Image generation method, apparatus, electronic device, storage medium, and program product | |
CN112307738A (en) | Method and device for processing text | |
CN117056474A (en) | Session response method and device, electronic equipment and storage medium | |
CN116662502A (en) | Method, equipment and storage medium for generating financial question-answer text based on retrieval enhancement | |
CN116977701A (en) | Video classification model training method, video classification method and device | |
CN114611529B (en) | Intention recognition method and device, electronic equipment and storage medium | |
US11810598B2 (en) | Apparatus and method for automated video record generation | |
CN115273856A (en) | Voice recognition method and device, electronic equipment and storage medium | |
CN113792550A (en) | Method and device for determining predicted answer and method and device for reading and understanding | |
CN112131350B (en) | Text label determining method, device, terminal and readable storage medium | |
CN117493608B (en) | Text video retrieval method, system and computer storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
REG | Reference to a national code |
Ref country code: HK Ref legal event code: DE Ref document number: 40055458 Country of ref document: HK |
|
GR01 | Patent grant | ||
GR01 | Patent grant |