[go: up one dir, main page]

CN111104493A - Intelligent response method and device based on data processing and computer equipment - Google Patents

Intelligent response method and device based on data processing and computer equipment Download PDF

Info

Publication number
CN111104493A
CN111104493A CN201910965267.7A CN201910965267A CN111104493A CN 111104493 A CN111104493 A CN 111104493A CN 201910965267 A CN201910965267 A CN 201910965267A CN 111104493 A CN111104493 A CN 111104493A
Authority
CN
China
Prior art keywords
reply
sentence
subset
candidate
score
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.)
Granted
Application number
CN201910965267.7A
Other languages
Chinese (zh)
Other versions
CN111104493B (en
Inventor
祝大伟
李炫�
姚晓远
汤智尧
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ping An Life Insurance Company of China Ltd
Original Assignee
Ping An Life Insurance Company of China Ltd
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 Ping An Life Insurance Company of China Ltd filed Critical Ping An Life Insurance Company of China Ltd
Priority to CN201910965267.7A priority Critical patent/CN111104493B/en
Publication of CN111104493A publication Critical patent/CN111104493A/en
Application granted granted Critical
Publication of CN111104493B publication Critical patent/CN111104493B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

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
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/22Matching criteria, e.g. proximity measures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/045Combinations of networks
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods
    • G06N3/084Backpropagation, e.g. using gradient descent
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q10/00Administration; Management
    • G06Q10/06Resources, workflows, human or project management; Enterprise or organisation planning; Enterprise or organisation modelling
    • G06Q10/063Operations research, analysis or management
    • G06Q10/0639Performance analysis of employees; Performance analysis of enterprise or organisation operations
    • G06Q10/06393Score-carding, benchmarking or key performance indicator [KPI] analysis

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Business, Economics & Management (AREA)
  • Data Mining & Analysis (AREA)
  • General Physics & Mathematics (AREA)
  • Human Resources & Organizations (AREA)
  • Artificial Intelligence (AREA)
  • Mathematical Physics (AREA)
  • General Engineering & Computer Science (AREA)
  • Evolutionary Computation (AREA)
  • Computational Linguistics (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Molecular Biology (AREA)
  • Educational Administration (AREA)
  • Biophysics (AREA)
  • Health & Medical Sciences (AREA)
  • General Health & Medical Sciences (AREA)
  • Strategic Management (AREA)
  • Computing Systems (AREA)
  • Biomedical Technology (AREA)
  • Software Systems (AREA)
  • Entrepreneurship & Innovation (AREA)
  • Economics (AREA)
  • Development Economics (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • Game Theory and Decision Science (AREA)
  • Evolutionary Biology (AREA)
  • Marketing (AREA)
  • Operations Research (AREA)
  • Quality & Reliability (AREA)
  • Tourism & Hospitality (AREA)
  • General Business, Economics & Management (AREA)
  • Human Computer Interaction (AREA)
  • Databases & Information Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention provides a method, a device, computer equipment and a storage medium for intelligent response based on data processing, wherein the method comprises the following steps: receiving a request sentence; inputting the request sentence into a reply model for operation to generate a plurality of reply candidate sentences and first scores corresponding to the reply candidate sentences one by one to obtain a reply candidate set; matching the reply candidate set with the blacklist to remove reply candidate sentences matched with the blacklist to obtain a first reply subset; processing each reply candidate sentence in the first reply subset through a similarity matching module and/or a length excitation module and/or a fluency detection module so as to change the first score of each reply candidate sentence into a second score to obtain a second reply subset; processing the second reply subset by a diversity detection module to obtain a third reply subset; and extracting a reply candidate sentence from the third reply subset as a reply sentence of the reply request sentence and outputting the reply sentence, thereby improving the accuracy of intelligent reply.

Description

Intelligent response method and device based on data processing and computer equipment
Technical Field
The present invention relates to the field of data processing technologies, and in particular, to a method and an apparatus for intelligent response based on data processing, a computer device, and a storage medium.
Background
With the rapid development of artificial intelligence technology, application scenarios of human-computer conversation are more and more extensive, such as interview scenarios, human-computer interaction scenarios and the like, the human-computer conversation refers to people talking or questioning an intelligent machine, then the intelligent machine simulates human beings to respond, an intelligent machine system usually comprises a conversation model obtained through deep learning training, but the current human-computer conversation cannot meet actual requirements, and when the current response system is used for responding to users, the content is single and hard, the accuracy is not high, and the user experience is poor.
Disclosure of Invention
The invention mainly aims to provide an intelligent response method, an intelligent response device, computer equipment and a storage medium based on data processing, and aims to solve the technical problem of low intelligent response accuracy rate in man-machine conversation in the prior art.
Based on the above object, the present invention provides an intelligent response method based on data processing, which includes:
receiving a request sentence;
inputting the request sentence into a reply model for operation, generating a plurality of reply candidate sentences and first scores corresponding to the reply candidate sentences one by one, and obtaining a reply candidate set, wherein the reply model is a model obtained based on deep machine learning training;
matching the reply candidate set with a blacklist to remove reply candidate sentences matched with the blacklist from the reply candidate set to obtain a first reply subset, wherein the blacklist is a preset reply sentence;
processing each reply candidate sentence in the first reply subset through a similarity matching module and/or a length excitation module and/or a fluency detection module so that the first score of each reply candidate sentence becomes a second score to obtain a second reply subset; the similarity matching module is used for calculating a score according to the similarity between the reply candidate sentence and the request sentence, the length excitation module is used for calculating a corresponding excitation score according to the length of the reply candidate sentence, and the fluency detection module is used for calculating a score according to the fluency of the reply candidate sentence;
processing the second reply subset by a diversity detection module to obtain a third reply subset, wherein the diversity detection module is used for screening the second reply subset according to the second score and a preset rule;
extracting one of the reply candidate sentences from the third reply subset as a reply sentence to the request sentence, and outputting the reply sentence.
The invention also provides an intelligent response device based on data processing, which comprises:
a receiving sentence unit for receiving a request sentence;
the operation sentence unit is used for inputting the request sentence into a reply model for operation, generating a plurality of reply candidate sentences and first scores which are in one-to-one correspondence with the reply candidate sentences to obtain a reply candidate set, wherein the reply model is a model obtained based on deep machine learning training;
a matching list unit, configured to match the reply candidate set with a blacklist, so as to remove a reply candidate sentence matched with the blacklist from the reply candidate set, so as to obtain a first reply subset, where the blacklist is a preset reply sentence;
a sentence processing unit, configured to process each reply candidate sentence in the first reply subset through a similarity matching module and/or a length excitation module and/or a fluency detection module, so that the first score of each reply candidate sentence becomes a second score, and a second reply subset is obtained; the similarity matching module is used for calculating a score according to the similarity between the reply candidate sentence and the request sentence, the length excitation module is used for calculating a corresponding excitation score according to the length of the reply candidate sentence, and the fluency detection module is used for calculating a score according to the fluency of the reply candidate sentence;
the detection reply unit is used for processing the second reply subset through a diversity detection module to obtain a third reply subset, and the diversity detection module is used for screening the second reply subset according to the second score and a preset rule;
and a sentence extracting unit configured to extract one of the reply candidate sentences from the third reply subset as a reply sentence to reply to the request sentence, and output the reply sentence.
The invention also provides a computer device comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the method when executing the computer program.
The invention also provides a computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the steps of the above-mentioned method.
The invention has the beneficial effects that: the reply candidate sentences obtained by calculating the reply model are processed by the similarity matching module and/or the length excitation module and/or the fluency detection module and processed by the diversity detection module to obtain more anthropomorphic and accurate reply sentences, so that the accuracy of intelligent reply is improved, the continuity of intelligent conversation is improved, the anthropomorphic effect is further improved, the user experience is improved, and the short reply with high quality meeting the requirements is intelligently generated aiming at different conversation scenes.
Drawings
FIG. 1 is a schematic diagram illustrating steps of a method for intelligent response based on data processing according to an embodiment of the present invention;
FIG. 2 is a block diagram illustrating an exemplary structure of an apparatus for intelligent response based on data processing according to an embodiment of the present invention;
fig. 3 is a block diagram schematically illustrating a structure of a computer apparatus according to an embodiment of the present invention.
The implementation, functional features and advantages of the objects of the present invention will be further explained with reference to the accompanying drawings.
Detailed Description
It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
Referring to fig. 1, the method for intelligent response based on data processing in this embodiment includes:
step S1: receiving a request sentence;
step S2: inputting the request sentence into a reply model for operation, generating a plurality of reply candidate sentences and first scores corresponding to the reply candidate sentences one by one, and obtaining a reply candidate set, wherein the reply model is a model obtained based on deep machine learning training;
step S3: matching the reply candidate set with a blacklist to remove reply candidate sentences matched with the blacklist from the reply candidate set to obtain a first reply subset, wherein the blacklist is a preset reply sentence;
step S4: processing each reply candidate sentence in the first reply subset through a similarity matching module and/or a length excitation module and/or a fluency detection module so that the first score of each reply candidate sentence becomes a second score to obtain a second reply subset; the similarity matching module is used for calculating a score according to the similarity between the reply candidate sentence and the request sentence, the length excitation module is used for calculating a corresponding excitation score according to the length of the reply candidate sentence, and the fluency detection module is used for calculating a score according to the fluency of the reply candidate sentence;
step S5: processing the second reply subset by a diversity detection module to obtain a third reply subset, wherein the diversity detection module is used for screening the second reply subset according to the second score and a preset rule;
step S6: extracting one of the reply candidate sentences from the third reply subset as a reply sentence to the request sentence, and outputting the reply sentence.
The intelligent responding method is used for replying the input sentence, as described in the steps S1 and S2, the request sentence may be a sentence with any meaning sentence pattern, such as "really good weather today", "i like running", and the like. The reply model is formed based on deep machine learning training, the reply model is correspondingly provided with a configuration file, the configuration file comprises attributes of a plurality of reply sentences, when a request sentence is received, the request sentence is input into the reply model, at the moment, the reply model randomly obtains a reply attribute from the configuration file according to the request sentence, the reply model is configured, the reply model generates a plurality of reply candidate sentences and corresponding first scores through one-time forward propagation and combining with the beacon search method operation, and the plurality of reply candidate sentences form the reply candidate set.
The reply attribute is used for limiting the sentence for replying the request sentence, and can be specifically divided into three types of attributes: sentences, emotions, and lengths, wherein sentences include questions (interactive), statements (descriptive), and prays (interactive), emotions include likes (like), hats (sad), dislikes (disgust), angers (angry), happy (happy), and others (other), and lengths include short (short), medium (medium), and (long). And randomly acquiring a reply attribute from the configuration file while inputting the request sentence, and configuring an attribute controller of the reply model, wherein the reply attribute can be marked as { sentence pattern, emotion and length } mode, such as { following, like, medium }, so that the attribute of the reply candidate sentence output by the model is the reply attribute, and the request sentence can be obtained by user input.
Specifically, in the reply model, the request sentence is first encoded by the encoder to generate a corresponding text encoding vector, and then the text encoding vector is input to the decoder and the attribute controller for calculation to obtain a plurality of reply candidate sentences each having a corresponding score, and further, the decoder includes a beam search algorithm, and outputs 20 reply candidate sentences having the highest scores among the plurality of reply candidate sentences according to the input number, such as 20, set by the user to form the reply candidate set.
In order to further obtain a reply sentence meeting the scene requirement, the reply candidate set may be optimized, as described in step S3, where the blacklist is a preset reply sentence list, the reply sentences in the list may be set by the user according to actual conditions, for example, may be set as sentences or key words violating laws and regulations, the reply candidate set is matched with the blacklist, and when the reply candidate sentences in the reply candidate set are matched with the sentences in the blacklist, that is, the reply candidate sentences are consistent with the sentences in the blacklist, the reply candidate sentences are rejected until the reply candidate sentences in the reply candidate set are traversed to obtain the first reply subset, and preferably, in order to reduce the blacklist and expand the matching range, the list of the blacklist may be key words, for example, the key words are "birthday", and then there may be "happy birthday, lovely", "happy birthday", or "both of them that are matched, "happy birthday", etc., can be realized by regular expressions.
As described in the above step S4, each reply candidate sentence in the first reply subset is processed by the similarity matching module and/or the length excitation module and/or the fluency detection module, in this embodiment, an optimal solution is selected, that is, the reply candidate sentence is processed by the similarity matching module, the length excitation module and the fluency detection module, respectively, to obtain a reply candidate sentence with a corresponding score, if the reply candidate sentence is calculated by the similarity matching module to obtain a similarity with the request sentence, a preset similarity score corresponding to the similarity is obtained, and the length excitation module calculates whether the length of the reply candidate sentence meets the length requirement, then a preset corresponding length score is obtained, and the fluency detection is performed to obtain whether the sentence of the reply candidate sentence is fluent or not, so as to obtain a corresponding fluency score, and combining the three scores and the first score of the reply candidate sentence to obtain a second score corresponding to the reply candidate sentence, traversing the reply candidate sentences of the first reply subset according to the method to obtain a set of reply candidate sentences with corresponding scores, and marking the set as a second reply subset for convenience of distinction.
In one embodiment, the reply candidate sentences of the first reply subset are obtained by only processing through the similarity matching module, and the similarity score of each reply candidate sentence is added to the first score to obtain the second score. Or, each reply candidate sentence of the first reply subset is obtained by processing only through a length excitation module, and the length fraction of each reply candidate sentence is added to the first fraction to obtain the second fraction. Or each reply candidate sentence of the first reply subset can be obtained by processing only through the fluency detection module, and the fluency score of each reply candidate sentence is added with the first score to obtain the second score. Or, only two of the three modules are used for processing, and the finally obtained second score is the sum of the scores obtained by the two modules and the first score.
In one embodiment, in the step S4, the step of subjecting each reply candidate sentence in the first reply subset to the similarity matching module includes:
step S41: performing word segmentation processing on the request sentence and each reply candidate sentence respectively to obtain a request sentence divided into m words and reply candidate sentences divided into n words;
step S42: screening each word in the request sentences and the reply candidate sentences after word segmentation according to preset parts of speech to obtain the request sentences of p words and the reply candidate sentences of q words left after screening;
step S43: judging whether p or q is equal to 0;
step S44: if so, carrying out similarity score calculation on the request sentence divided into m words and the reply candidate sentence divided into n words to obtain a first similarity score between the request sentence and the reply candidate sentence, otherwise, carrying out similarity score calculation on the request sentence with p words and the reply candidate sentence with q words after screening to obtain a second similarity score between the request sentence and the reply candidate sentence;
wherein p is more than or equal to 0 and less than or equal to m, q is more than or equal to 0 and less than or equal to n, p and q are both non-negative integers, and m and n are both positive integers.
In this embodiment, the similarity matching module is configured to calculate a similarity score between the reply candidate sentence and the reply sentence. Firstly, a jieba word segmentation tool is utilized to respectively carry out word segmentation processing on a request sentence and each reply candidate sentence to obtain the request sentence divided into m words and the reply candidate sentences divided into n words, namely, post ═ word1,word2,…,wordm},ri={word1,word2,…,wordnWhere post is the request sentence, word is the word, riIs the ith reply candidate sentence in the first reply subset.
Screening out words meeting preset conditions according to the part of speech of the result of the word segmentation, namely screening each word according to the set part of speech, wherein the part of speech can be verb part of speech, noun part of speech, adjective part of speech and the like, and obtaining request sentences of p words and reply candidate sentences of q words which are left after screening, namely post ═ word1,word2,…,wordp},ri={word1,word2,…,wordqP is more than or equal to 0 and less than or equal to m, and q is more than or equal to 0 and less than or equal to n.
And then judging whether p or q is equal to 0, if p or q is equal to 0, indicating that the request sentence and the reply candidate sentence do not meet the preset condition, so that the similarity calculation can be directly carried out on the request sentence divided into m words and the reply candidate sentence divided into n words, and if p and q are not equal to 0, carrying out the similarity calculation on the request sentence with p words and the reply candidate sentence with q words which are left after screening.
The formula for calculating the similarity of the request sentence divided into m words and the reply candidate sentence divided into n words is as follows:
Figure BDA0002230279110000071
Figure BDA0002230279110000072
Figure BDA0002230279110000073
and the formula for calculating the similarity of the request sentences of the remaining p words and the reply candidate sentences of the q words after screening is as follows:
Figure BDA0002230279110000074
Figure BDA0002230279110000075
Figure BDA0002230279110000076
wherein s issimE is a preset word vector, word, similarity score of the request sentence and the reply candidate sentenceiThe word vector is a word after word segmentation processing, the preset word vector is a pre-trained word vector, and the meaning of the word vector is represented by a feature vector of the word and is an N-dimensional vector.
In one embodiment, in the step S4, the step of subjecting each reply candidate sentence in the first reply subset to the length excitation module includes:
step S45: calculating a sentence length of each of the reply candidate sentences;
step S46: and judging whether the reply candidate sentence with the corresponding sentence length larger than the preset length obtains a preset first length score, or judging to obtain a preset second length score.
In this embodiment, the sentence length of each reply candidate sentence is calculated and recorded as leniIf the byte size of each reply candidate sentence is counted as the sentence length, then it is determined whether the sentence length is larger than the predetermined length, and the score of the reply candidate sentence is determined according to the determination result, for example, the predetermined length is 7, i.e., the predetermined byte length is 7, the first length score is α, the second score length is β, if yes, the score is determined to be a score of the reply candidate sentence, and the second score length is determined to be a score of the reply candidate sentenceleni≤7,slenα, if leni>7,slen=β。
In one embodiment, in the step S4, the step of subjecting each reply candidate sentence in the first reply subset to the fluency detection module includes:
step S47: performing fluency detection on each reply candidate sentence;
step S48: and if the reply candidate sentence is detected to be a fluent sentence, judging that the reply candidate sentence has a preset first fluent score, and otherwise, judging that the reply candidate sentence has a preset second fluent score.
In this embodiment, the candidate reply sentences are detected by a fluency detection module, which determines the candidate reply sentences according to the chinese grammar, and the detection method includes: n-gram method, rule matching method, etc., if the sentence is fluent, sflue0, otherwise, sflue=γ(γ<0) Wherein s isflueIn order to recover the score of the candidate sentence, in this example, the first fluent score is 0 when the sentence is fluent, and the second fluent score is gamma when the sentence is not fluent, i.e., a negative score is obtained.
As described in the above steps S5-S6, when the reply candidate sentences are processed by the above three modules, the scores and the first scores are combined to obtain a new second score, further, the reply candidate sentences in the second reply subset may be sorted according to the scores from high to low, and then the reply candidate sentences in the second reply subset are processed by the diversity detection module one by one according to the above sorted order to obtain a third reply subset, and then a reply candidate sentence is randomly extracted from the subset as a reply sentence for replying to the request sentence.
In one embodiment, the step S5 includes:
step S51: taking out one reply candidate sentence from the second reply subset, calculating the similarity between the reply candidate sentence and all sentences in the third reply subset, and sequentially judging whether the similarity is greater than a preset threshold value or not;
step S52: if the similarity is greater than a preset threshold value, adding the sentence with the highest second score in the two sentences used for calculating the similarity into the third reply subset, and removing the other sentence with the lower second score, if the similarity is not greater than the preset threshold value, judging whether the number of the first words of all sentences in the third reply subset is greater than the preset number and the number of the first words of the reply candidate sentences is consistent;
step S53: if the number of the candidate sentences is larger than the preset number, rejecting the reply candidate sentences; and if the number of the reply candidate sentences is not more than the preset number, adding the reply candidate sentences into the third reply subset, and repeating the steps until all the reply candidate sentences in the second reply subset are traversed to obtain a third reply subset of which all the reply candidate sentences are subjected to similarity and first word screening.
In this embodiment, the second reply subset is processed by the diversity detection module to obtain a third reply subset, and the specific process is as described in the above steps S51-S53, first, all the reply candidate sentences in the second reply subset are sorted according to the second score from high to low to obtain the sorted second reply subset, then, the second reply subset sequentially takes out all the reply candidate sentences according to the order corresponding to the second score from high to low, and then, the similarity between the retrieved reply candidate sentences and all the sentences in the third reply subset is calculated and judged to be greater than the preset threshold, at this time, if the third reply subset is an empty set, the reply candidate sentences can be directly added into the third reply subset, then, one reply candidate sentence is taken out from the second reply subset, and whether the similarity between the reply candidate sentence and the sentences in the third reply subset is greater than the preset threshold is judged, if yes, adding the two with high scores into a third reply subset, and deleting the other reply subset; the above-mentioned calculation method of similarity refers to the calculation method of the above-mentioned similarity matching module, which is not described herein again, if not greater than the preset threshold, then it is determined whether the first words of the reply candidate sentences and the sentences in the third reply subset are consistent, if both are "i" as the first words, it is determined whether the number of the first words of the reply candidate sentences in the third reply subset consistent with the reply candidate sentences is greater than the preset number, if the preset number is 2, then it is not greater than the preset number at this time, the reply candidate sentences may be added into the third reply subset, and this is repeated, and all the reply candidate sentences in the second reply subset are traversed according to the above-mentioned method, so as to obtain the final third reply subset in which each reply candidate sentence is subjected to similarity and first word screening.
For example, the third reply subset includes { "i also likes fitness", "i also likes running", "runs well", where the preset number is T ═ 2, and when a next reply candidate sentence taken out from the second reply subset is "runs well, the similarity between the reply and each sentence in the third reply subset may be determined first, and when it is determined that the similarity is not greater than the preset threshold, it is determined that the first word" runs "is not greater than the preset number T ═ 2, at this time, the reply is added to the third reply subset {" i also likes fitness "," i also likes running "," runs well "}; when the next reply candidate sentence extracted from the second reply subset is "i like playing baseball", although the similarity is not greater than the preset threshold, the number of the first word "i" in the third reply subset exceeds the preset number, and the reply is deleted.
In another example, if the next reply candidate sentence is "run not wrong", although the initial word "run" does not exceed the preset number, the similarity between "run not wrong" and "run not wrong" in the third reply subset is greater than the preset threshold, and the score ratio of "run not wrong" is higher, the "run not wrong" is added to the third reply subset, and the "run not wrong" is deleted, that is, the third reply subset includes { "i also likes fitness", "i also likes running" and "run not wrong" }.
In an embodiment, the method for training the reply model includes:
step S01: collecting and preprocessing training data to obtain a training data set, wherein each training data set comprises a request and a reply with an attribute label;
step S02: constructing a text generation model based on deep learning, and respectively calculating the request in the training data set and the reply with the attribute tag through the text generation model to obtain the probability distribution of characters or words at each moment in the predicted sentence;
step S03: calculating the cross entropy error of the probability distribution of each time word or phrase and the sparse vector of the word or phrase at each time in the reply, and calculating the mean value of the error at each time to obtain the loss error of the text generation model;
step S04: and performing error back propagation by using a deep learning optimization algorithm according to the loss error, updating parameters of the text generation model to obtain a trained attribute control text generation model, and recording the model as a reply model.
As described in step S01, before training the model, training data is acquired and preprocessed, where the training data is corresponding data, i.e. a request and a reply corresponding to the request, and the reply has an attribute tag, i.e. the attribute tag can refer to the reply attribute, specifically, the dialog data acquisition method includes: obtaining comment data from hot sites such as microblogs, bean cotyledons, tiger pouts, bar stickers and the like by using a crawler program; obtaining from an open source conversation database; and obtaining conversation data of the chat robot.
And then performing data cleaning on the data, wherein the data cleaning comprises the following steps: duplicate removal processing, denoising processing and clustering processing. The dialog data is normalized to a < post, response > pair, where post represents a request in a dialog turn and response represents a reply in a dialog turn, such as: < post, today's weather is really good, response is quiet, sunny woolen >. Meanwhile, each sentence in < post, response > is participled, and the processed < post, response > is stored in the file.
Furthermore, the attribute labeling is carried out on the training data through a classification model, and the attribute labeling of response in < post, response > is mainly carried out, wherein the classification model comprises two types of classification models, namely a sentence pattern model, an emotion attribute classification model and a length attribute classification model.
In this embodiment, a corresponding classification model is obtained through training and then put into use, and the sentence pattern and emotion attribute classification model is constructed as follows: adopting a CNN model, wherein the CNN model comprises 1 Embedding layer, 2 Convolition layers, 1 Maxbonding layer, 1 Flattern layer, 1 Dense layer, 1 Dropout layer and 1 Dense layer, the activation functions of all the Convolition layers and the first Dense layer use 'relu', and the activation function of the last Dense layer uses 'softmax'.
Then training is carried out: collecting open-source text data with sentence pattern attributes, and respectively constructing a training set and a verification set; training the model by using a training set to construct a sentence pattern classification model, and verifying the trained data by using a verification set; when the trained model passes on the validation set, the sentence classification model is saved. The emotion classification model is trained, verified and stored in the same way as above, but the difference is that the hyper-parameter settings of the two models are different. Wherein, the sentence pattern label has 3 types: questions (interactive), statements (descriptive), and imperatives (empirical); affective tags share 6 classes: like (like), hard (sad), dislike (distust), angry (angry), happy (happy), other (other).
The above-mentioned length attribute classification model: for cleaned dialogue data<post,response>All responses in the sentence are counted, and the sentence length range is [ L ]min,Lmax]In this embodiment, Lmin=2,Lmax20. For length range according to interval [2,4],[5,10],[11,20]Dividing and endowing 3 types of different labels of short, medium and long.
Of course, for the convenience of modeling, each type of attribute is quantized into numbers, i.e. the sentence label is {0,1,2}, where 0 represents iterative, 1 represents progressive, and 2 represents objective; the emotion label is {0,1,2,3,4,5}, wherein 0 represents other, 1 represents like, 2 represents sad, 3 represents distust, 4 represents angry, and 5 represents happy; the length label is {0,1,2}, where 0 represents short, 1 represents medium, and 2 represents long. And the output of the specified model is an attribute triple { sentence pattern, emotion and length }. Aiming at the description, the attribute combinations are 54 in total, so that abundant samples are provided for subsequent learning of the depth model, and the trained model can be adapted to various scenes and requirements.
For example, a dialog data < post: true weather of today, response: yes, sunny woolen > is input into a classification model, and a corresponding attribute triple {1,1,1} is output end to end, namely { circulated, like, medium }.
As described in the foregoing steps S02-S04, the reply model is a model obtained by deep machine learning training, and in one embodiment, the deep learning model may be an end-to-end attribute-controlled text generation model, the text generation model is first constructed, the model includes an encoder and a decoder, when performing training, the request in the training data set and the reply with attribute tags are respectively passed through the encoder to generate corresponding text encoding vectors, the text encoding vectors are input into the decoder and the attribute controller to be calculated to obtain probability distribution of each time word or word in the predicted sentence, wherein each time word and the reply correspond one to one, then the text generation model is subjected to error calculation, that is, the probability distribution of each time word or word and the sparse vector of each time word or word in the reply are calculated to calculate cross entropy error, the error is an error between the generation reply and the actual reply of the model, then the error at each moment is averaged to obtain a final error, namely the loss error, finally the error is propagated reversely by using a deep learning optimization algorithm, the parameters of the text generation model are updated, and a trained attribute control text generation model is obtained, wherein the deep learning optimization algorithm can be SGD, Momentum, RMSProp, Adam and the like. It is known that the process of training the text generation model based on deep machine learning can be implemented by various prior arts, and a detailed description thereof will not be provided herein.
And finally, verifying the model generated by the trained attribute control text corresponding to the test data, inputting the known test data into the model for prediction, and if the obtained result is consistent with the expected result, judging that the model training is finished, and marking the model as the reply model.
Referring to fig. 2, in this embodiment, an apparatus for intelligent response based on data processing is provided, where the apparatus corresponds to the method for intelligent response based on data processing, and the apparatus includes:
a receiving sentence unit 100 for receiving a request sentence;
an operation sentence unit 200, configured to input the request sentence into a reply model for operation, generate a plurality of reply candidate sentences and first scores corresponding to the reply candidate sentences one to one, and obtain a reply candidate set, where the reply model is a model obtained based on deep machine learning training;
a matching list unit 300, configured to match the reply candidate set with a blacklist, so as to remove a reply candidate sentence matched with the blacklist from the reply candidate set, so as to obtain a first reply subset, where the blacklist is a preset reply sentence;
a sentence processing unit 400, configured to process each reply candidate sentence in the first reply subset through a similarity matching module and/or a length excitation module and/or a fluency detection module, so that the first score of each reply candidate sentence becomes a second score, resulting in a second reply subset; the similarity matching module is used for calculating a score according to the similarity between the reply candidate sentence and the request sentence, the length excitation module is used for calculating a corresponding excitation score according to the length of the reply candidate sentence, and the fluency detection module is used for calculating a score according to the fluency of the reply candidate sentence;
a detection reply unit 500, configured to process the second reply subset through a diversity detection module to obtain a third reply subset, where the diversity detection module is configured to screen the second reply subset according to the second score and according to a preset rule;
an extract sentence unit 600, configured to extract one reply candidate sentence from the third reply subset as a reply sentence to reply to the request sentence, and output the reply sentence.
In one embodiment, the sentence processing unit 400 includes:
a word segmentation processing subunit, configured to perform word segmentation processing on the request sentence and each of the reply candidate sentences, respectively, to obtain a request sentence divided into m words and a reply candidate sentence divided into n words;
a sentence screening subunit, configured to screen each word in the request sentence and the reply candidate sentence after the word segmentation processing according to a preset part of speech to obtain a request sentence with p words and a reply candidate sentence with q words remaining after the screening;
a word judgment subunit, configured to judge whether p or q is equal to 0;
a calculating and obtaining unit, configured to perform similarity score calculation on a request sentence divided into m words and a reply candidate sentence divided into n words when p or q is equal to 0, to obtain a first similarity score between the request sentence and the reply candidate sentence, otherwise, perform similarity score calculation on the request sentence with p words and the reply candidate sentence with q words after being filtered, to obtain a second similarity score between the request sentence and the reply candidate sentence;
wherein p is more than or equal to 0 and less than or equal to m, q is more than or equal to 0 and less than or equal to n, p and q are both non-negative integers, and m and n are both positive integers.
The formula for calculating the similarity of the request sentence divided into m words and the reply candidate sentence divided into n words is as follows:
Figure BDA0002230279110000131
Figure BDA0002230279110000132
Figure BDA0002230279110000133
and the formula for calculating the similarity of the request sentences of the remaining p words and the reply candidate sentences of the q words after screening is as follows:
Figure BDA0002230279110000134
Figure BDA0002230279110000135
Figure BDA0002230279110000136
wherein s issimE is a preset word vector, word, similarity score of the request sentence and the reply candidate sentenceiThe word vector is a word after word segmentation processing, the preset word vector is a pre-trained word vector, and the meaning of the word vector is represented by a feature vector of the word and is an N-dimensional vector.
In an embodiment, the sentence processing unit 400 further includes:
a calculate length subunit configured to calculate a sentence length of each of the reply candidate sentences;
and the first scoring subunit is used for judging the reply candidate sentence of which the corresponding sentence length is greater than the preset length to obtain a preset first length score, and otherwise, judging to obtain a preset second length score.
In an embodiment, the sentence processing unit 400 further includes:
a fluency detection subunit, configured to perform fluency detection on each of the reply candidate sentences;
and the second scoring subunit is used for judging that the reply candidate sentence has a preset first fluent score if the reply candidate sentence is detected to be a fluent sentence, and otherwise, judging that the reply candidate sentence has a preset second fluent score.
In one embodiment, the detection reply unit 500 includes:
a similarity calculating subunit, configured to take out one reply candidate sentence from the second reply subset, calculate similarities between the reply candidate sentence and all sentences in the third reply subset, and sequentially determine whether the similarities are greater than a preset threshold;
a first adding subunit, configured to add, when the similarity is greater than a preset threshold, a sentence with the highest second score among two sentences used for calculating the similarity to the third reply subset, and remove another sentence with the lower second score, and if the similarity is not greater than the preset threshold, determine whether the number of first words of all sentences in the third reply subset, which are consistent with the first words of the reply candidate sentences, is greater than a preset number;
the second adding subunit is used for removing the reply candidate sentences when the number of the reply candidate sentences is larger than the preset number; and if the number of the reply candidate sentences is not more than the preset number, adding the reply candidate sentences into the third reply subset, and repeating the steps until all the reply candidate sentences in the second reply subset are traversed to obtain a third reply subset of which all the reply candidate sentences are subjected to similarity and first word screening.
In one embodiment, a training apparatus corresponding to the above training method for a reply model includes:
the system comprises a data collecting unit, a data preprocessing unit and a data processing unit, wherein the data collecting unit is used for collecting and preprocessing training data to obtain a training data set, and each training data comprises a request and a reply with an attribute label;
the model building unit is used for building a text generation model based on deep learning, and calculating the request in the training data set and the reply with the attribute tag through the text generation model respectively to obtain the probability distribution of each time word or word in the predicted sentence;
the loss calculation unit is used for calculating cross entropy errors of the probability distribution of each time word or phrase and sparse vectors of the words or phrases at each time in the reply, and calculating a mean value of the errors at each time to obtain a loss error of the text generation model;
and the parameter updating unit is used for performing error back propagation by using a deep learning optimization algorithm according to the loss error, updating the parameters of the text generation model to obtain a trained attribute control text generation model, and recording the model as a reply model.
Referring to fig. 3, an embodiment of the present invention further provides a computer device, where the computer device may be a server, and an internal structure of the computer device may be as shown in fig. 3. The computer device includes a processor, a memory, a network interface, and a database connected by a system bus. Wherein the computer designed processor is used to provide computational and control capabilities. The memory of the computer device comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store all data required for generating the reply sentence. The network interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to implement a method for intelligent response based on data processing.
The processor executes the steps of the intelligent response method based on data processing: receiving a request sentence; inputting the request sentence into a reply model for operation, generating a plurality of reply candidate sentences and first scores corresponding to the reply candidate sentences one by one, and obtaining a reply candidate set, wherein the reply model is a model obtained based on deep machine learning training; matching the reply candidate set with a blacklist to remove reply candidate sentences matched with the blacklist from the reply candidate set to obtain a first reply subset, wherein the blacklist is a preset reply sentence; processing each reply candidate sentence in the first reply subset through a similarity matching module and/or a length excitation module and/or a fluency detection module so that the first score of each reply candidate sentence becomes a second score to obtain a second reply subset; the similarity matching module is used for calculating a score according to the similarity between the reply candidate sentence and the request sentence, the length excitation module is used for calculating a corresponding excitation score according to the length of the reply candidate sentence, and the fluency detection module is used for calculating a score according to the fluency of the reply candidate sentence; processing the second reply subset by a diversity detection module to obtain a third reply subset, wherein the diversity detection module is used for screening the second reply subset according to the second score and a preset rule; extracting one of the reply candidate sentences from the third reply subset as a reply sentence to the request sentence, and outputting the reply sentence.
The computer device, wherein the step of processing each reply candidate sentence in the first reply subset by the similarity matching module, includes: performing word segmentation processing on the request sentence and each reply candidate sentence respectively to obtain a request sentence divided into m words and reply candidate sentences divided into n words; screening each word in the request sentences and the reply candidate sentences after word segmentation according to preset parts of speech to obtain the request sentences of p words and the reply candidate sentences of q words left after screening; judging whether p or q is equal to 0; if so, carrying out similarity score calculation on the request sentence divided into m words and the reply candidate sentence divided into n words to obtain a first similarity score between the request sentence and the reply candidate sentence, otherwise, carrying out similarity score calculation on the request sentence with p words and the reply candidate sentence with q words after screening to obtain a second similarity score between the request sentence and the reply candidate sentence; wherein p is more than or equal to 0 and less than or equal to m, q is more than or equal to 0 and less than or equal to n, p and q are both non-negative integers, and m and n are both positive integers.
In one embodiment, the step of calculating the similarity score for the request sentence divided into m words and the reply candidate sentence divided into n words includes: the similarity score calculation is performed by the following formula:
Figure BDA0002230279110000161
Figure BDA0002230279110000162
Figure BDA0002230279110000163
and a step of calculating similarity scores of the request sentences of the remaining p words and the reply candidate sentences of the q words after the screening, comprising: the similarity score calculation is performed by the following formula:
Figure BDA0002230279110000164
Figure BDA0002230279110000165
Figure BDA0002230279110000166
wherein s issimE is a preset word vector, word, similarity score of the request sentence and the reply candidate sentenceiThe words of the sentence after word segmentation processing.
In one embodiment, the step of processing each reply candidate sentence in the first reply subset by the length excitation module includes: calculating a sentence length of each of the reply candidate sentences; and judging whether the reply candidate sentence with the corresponding sentence length larger than the preset length obtains a preset first length score, or judging to obtain a preset second length score.
In one embodiment, the step of processing each reply candidate sentence in the first reply subset by the fluency detection module comprises: performing fluency detection on each reply candidate sentence; and if the reply candidate sentence is detected to be a fluent sentence, judging that the reply candidate sentence has a preset first fluent score, and otherwise, judging that the reply candidate sentence has a preset second fluent score.
In an embodiment, the step of processing the second subset of replies by the diversity detection module to obtain a third subset of replies includes: taking out one reply candidate sentence from the second reply subset, calculating the similarity between the reply candidate sentence and all sentences in the third reply subset, and sequentially judging whether the similarity is greater than a preset threshold value or not; if the similarity is greater than a preset threshold value, adding the sentence with the highest second score in the two sentences used for calculating the similarity into the third reply subset, and removing the other sentence with the lower second score, if the similarity is not greater than the preset threshold value, judging whether the number of the first words of all sentences in the third reply subset is greater than the preset number and the number of the first words of the reply candidate sentences is consistent; if the number of the candidate sentences is larger than the preset number, rejecting the reply candidate sentences; and if the number of the reply candidate sentences is not more than the preset number, adding the reply candidate sentences into the third reply subset, and repeating the steps until all the reply candidate sentences in the second reply subset are traversed to obtain a third reply subset of which all the reply candidate sentences are subjected to similarity and first word screening.
In an embodiment, the method for training the reply model includes: collecting and preprocessing training data to obtain a training data set, wherein each training data set comprises a request and a reply with an attribute label; constructing a text generation model based on deep learning, and respectively calculating the request in the training data set and the reply with the attribute tag through the text generation model to obtain the probability distribution of characters or words at each moment in the predicted sentence; calculating the cross entropy error of the probability distribution of each time word or phrase and the sparse vector of the word or phrase at each time in the reply, and calculating the mean value of the error at each time to obtain the loss error of the text generation model; and performing error back propagation by using a deep learning optimization algorithm according to the loss error, updating parameters of the text generation model to obtain a trained attribute control text generation model, and recording the model as a reply model.
Those skilled in the art will appreciate that the architecture shown in fig. 3 is only a block diagram of some of the structures associated with the disclosed aspects and is not intended to limit the computing devices to which the disclosed aspects may be applied.
An embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements a method for intelligent response based on data processing, and specifically includes: receiving a request sentence; inputting the request sentence into a reply model for operation, generating a plurality of reply candidate sentences and first scores corresponding to the reply candidate sentences one by one, and obtaining a reply candidate set, wherein the reply model is a model obtained based on deep machine learning training; matching the reply candidate set with a blacklist to remove reply candidate sentences matched with the blacklist from the reply candidate set to obtain a first reply subset, wherein the blacklist is a preset reply sentence; processing each reply candidate sentence in the first reply subset through a similarity matching module and/or a length excitation module and/or a fluency detection module so that the first score of each reply candidate sentence becomes a second score to obtain a second reply subset; the similarity matching module is used for calculating a score according to the similarity between the reply candidate sentence and the request sentence, the length excitation module is used for calculating a corresponding excitation score according to the length of the reply candidate sentence, and the fluency detection module is used for calculating a score according to the fluency of the reply candidate sentence; processing the second reply subset by a diversity detection module to obtain a third reply subset, wherein the diversity detection module is used for screening the second reply subset according to the second score and a preset rule; extracting one of the reply candidate sentences from the third reply subset as a reply sentence to the request sentence, and outputting the reply sentence.
In the computer-readable storage medium, the step of processing each reply candidate sentence in the first reply subset by the similarity matching module includes: performing word segmentation processing on the request sentence and each reply candidate sentence respectively to obtain a request sentence divided into m words and reply candidate sentences divided into n words; screening each word in the request sentences and the reply candidate sentences after word segmentation according to preset parts of speech to obtain the request sentences of p words and the reply candidate sentences of q words left after screening; judging whether p or q is equal to 0; if so, carrying out similarity score calculation on the request sentence divided into m words and the reply candidate sentence divided into n words to obtain a first similarity score between the request sentence and the reply candidate sentence, otherwise, carrying out similarity score calculation on the request sentence with p words and the reply candidate sentence with q words after screening to obtain a second similarity score between the request sentence and the reply candidate sentence; wherein p is more than or equal to 0 and less than or equal to m, q is more than or equal to 0 and less than or equal to n, p and q are both non-negative integers, and m and n are both positive integers.
In one embodiment, the step of calculating the similarity score for the request sentence divided into m words and the reply candidate sentence divided into n words includes: the similarity score calculation is performed by the following formula:
Figure BDA0002230279110000181
Figure BDA0002230279110000182
Figure BDA0002230279110000183
and a step of calculating similarity scores of the request sentences of the remaining p words and the reply candidate sentences of the q words after the screening, comprising: the similarity score calculation is performed by the following formula:
Figure BDA0002230279110000184
Figure BDA0002230279110000185
Figure BDA0002230279110000186
wherein s issimE is a preset word vector, word, similarity score of the request sentence and the reply candidate sentenceiThe words of the sentence after word segmentation processing.
In one embodiment, the step of processing each reply candidate sentence in the first reply subset by the length excitation module includes: calculating a sentence length of each of the reply candidate sentences; and judging whether the reply candidate sentence with the corresponding sentence length larger than the preset length obtains a preset first length score, or judging to obtain a preset second length score.
In one embodiment, the step of processing each reply candidate sentence in the first reply subset by the fluency detection module comprises: performing fluency detection on each reply candidate sentence; and if the reply candidate sentence is detected to be a fluent sentence, judging that the reply candidate sentence has a preset first fluent score, and otherwise, judging that the reply candidate sentence has a preset second fluent score.
In an embodiment, the step of processing the second subset of replies by the diversity detection module to obtain a third subset of replies includes: taking out one reply candidate sentence from the second reply subset, calculating the similarity between the reply candidate sentence and all sentences in the third reply subset, and sequentially judging whether the similarity is greater than a preset threshold value or not; if the similarity is greater than a preset threshold value, adding the sentence with the highest second score in the two sentences used for calculating the similarity into the third reply subset, and removing the other sentence with the lower second score, if the similarity is not greater than the preset threshold value, judging whether the number of the first words of all sentences in the third reply subset is greater than the preset number and the number of the first words of the reply candidate sentences is consistent; if the number of the candidate sentences is larger than the preset number, rejecting the reply candidate sentences; and if the number of the reply candidate sentences is not more than the preset number, adding the reply candidate sentences into the third reply subset, and repeating the steps until all the reply candidate sentences in the second reply subset are traversed to obtain a third reply subset of which all the reply candidate sentences are subjected to similarity and first word screening.
In an embodiment, the method for training the reply model includes: collecting and preprocessing training data to obtain a training data set, wherein each training data set comprises a request and a reply with an attribute label; constructing a text generation model based on deep learning, and respectively calculating the request in the training data set and the reply with the attribute tag through the text generation model to obtain the probability distribution of characters or words at each moment in the predicted sentence; calculating the cross entropy error of the probability distribution of each time word or phrase and the sparse vector of the word or phrase at each time in the reply, and calculating the mean value of the error at each time to obtain the loss error of the text generation model; and performing error back propagation by using a deep learning optimization algorithm according to the loss error, updating parameters of the text generation model to obtain a trained attribute control text generation model, and recording the model as a reply model.
It will be understood by those skilled in the art that all or part of the processes of the methods of the above embodiments may be implemented by hardware associated with instructions of a computer program, which may be stored on a non-volatile computer-readable storage medium, and when executed, may include processes of the above embodiments of the methods. Any reference to memory, storage, database, or other medium provided herein and used in the examples may include non-volatile and/or volatile memory. Non-volatile memory can include read-only memory (ROM), Programmable ROM (PROM), Electrically Programmable ROM (EPROM), Electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms, such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), double-rate SDRAM (SSRSDRAM), Enhanced SDRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), Rambus Direct RAM (RDRAM), direct bus dynamic RAM (DRDRAM), and bus dynamic RAM (RDRAM).
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, apparatus, article, or method that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, apparatus, article, or method. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, apparatus, article, or method that includes the element.
The above description is only a preferred embodiment of the present invention, and not intended to limit the scope of the present invention, and all modifications of equivalent structures and equivalent processes, which are made by using the contents of the present specification and the accompanying drawings, or directly or indirectly applied to other related technical fields, are included in the scope of the present invention.

Claims (10)

1. An intelligent response method based on data processing is characterized by comprising the following steps:
receiving a request sentence;
inputting the request sentence into a reply model for operation, generating a plurality of reply candidate sentences and first scores corresponding to the reply candidate sentences one by one, and obtaining a reply candidate set, wherein the reply model is a model obtained based on deep machine learning training;
matching the reply candidate set with a blacklist to remove reply candidate sentences matched with the blacklist from the reply candidate set to obtain a first reply subset, wherein the blacklist is a preset reply sentence;
processing each reply candidate sentence in the first reply subset through a similarity matching module and/or a length excitation module and/or a fluency detection module so that the first score of each reply candidate sentence becomes a second score to obtain a second reply subset; the similarity matching module is used for calculating a score according to the similarity between the reply candidate sentence and the request sentence, the length excitation module is used for calculating a corresponding excitation score according to the length of the reply candidate sentence, and the fluency detection module is used for calculating a score according to the fluency of the reply candidate sentence;
processing the second reply subset by a diversity detection module to obtain a third reply subset, wherein the diversity detection module is used for screening the second reply subset according to the second score and a preset rule;
extracting one of the reply candidate sentences from the third reply subset as a reply sentence to the request sentence, and outputting the reply sentence.
2. The intelligent data processing-based response method of claim 1, wherein the step of subjecting each of the reply candidate sentences in the first reply subset to the similarity matching module comprises:
performing word segmentation processing on the request sentence and each reply candidate sentence respectively to obtain a request sentence divided into m words and reply candidate sentences divided into n words;
screening each word in the request sentences and the reply candidate sentences after word segmentation according to preset parts of speech to obtain the request sentences of p words and the reply candidate sentences of q words left after screening;
judging whether p or q is equal to 0;
if so, carrying out similarity score calculation on the request sentence divided into m words and the reply candidate sentence divided into n words to obtain a first similarity score between the request sentence and the reply candidate sentence, otherwise, carrying out similarity score calculation on the request sentence with p words and the reply candidate sentence with q words after screening to obtain a second similarity score between the request sentence and the reply candidate sentence;
wherein p is more than or equal to 0 and less than or equal to m, q is more than or equal to 0 and less than or equal to n, p and q are both non-negative integers, and m and n are both positive integers.
3. The intelligent response method based on data processing as claimed in claim 2, wherein the step of calculating the similarity score of the request sentence divided into m words and the reply candidate sentence divided into n words comprises:
the similarity score calculation is performed by the following formula:
Figure FDA0002230279100000021
Figure FDA0002230279100000022
Figure FDA0002230279100000023
and a step of calculating similarity scores of the request sentences of the remaining p words and the reply candidate sentences of the q words after the screening, comprising:
the similarity score calculation is performed by the following formula:
Figure FDA0002230279100000024
Figure FDA0002230279100000025
Figure FDA0002230279100000026
wherein s issimE is a preset word vector, word, similarity score of the request sentence and the reply candidate sentenceiThe words of the sentence after word segmentation processing.
4. The intelligent data processing-based response method of claim 1, wherein the step of subjecting each of the reply candidate sentences in the first reply subset to a length excitation module comprises:
calculating a sentence length of each of the reply candidate sentences;
and judging whether the reply candidate sentence with the corresponding sentence length larger than the preset length obtains a preset first length score, or judging to obtain a preset second length score.
5. The intelligent data processing-based response method of claim 1, wherein the step of subjecting each of the reply candidate sentences in the first reply subset to fluency detection module processing comprises:
performing fluency detection on each reply candidate sentence;
and if the reply candidate sentence is detected to be a fluent sentence, judging that the reply candidate sentence has a preset first fluent score, and otherwise, judging that the reply candidate sentence has a preset second fluent score.
6. The intelligent response method based on data processing of claim 1, wherein the step of processing the second subset of responses by the diversity detection module to obtain a third subset of responses comprises:
taking out one reply candidate sentence from the second reply subset, calculating the similarity between the reply candidate sentence and all sentences in the third reply subset, and sequentially judging whether the similarity is greater than a preset threshold value or not;
if the similarity is greater than a preset threshold value, adding the sentence with the highest second score in the two sentences used for calculating the similarity into the third reply subset, and removing the other sentence with the lower second score, if the similarity is not greater than the preset threshold value, judging whether the number of the first words of all sentences in the third reply subset is greater than the preset number and the number of the first words of the reply candidate sentences is consistent;
if the number of the candidate sentences is larger than the preset number, rejecting the reply candidate sentences; and if the number of the reply candidate sentences is not more than the preset number, adding the reply candidate sentences into the third reply subset, and repeating the steps until all the reply candidate sentences in the second reply subset are traversed to obtain a third reply subset of which all the reply candidate sentences are subjected to similarity and first word screening.
7. The intelligent response method based on data processing as claimed in claim 1, wherein the training method of the reply model comprises:
collecting and preprocessing training data to obtain a training data set, wherein each training data set comprises a request and a reply with an attribute label;
constructing a text generation model based on deep learning, and respectively calculating the request in the training data set and the reply with the attribute tag through the text generation model to obtain the probability distribution of characters or words at each moment in the predicted sentence;
calculating the cross entropy error of the probability distribution of each time word or phrase and the sparse vector of the word or phrase at each time in the reply, and calculating the mean value of the error at each time to obtain the loss error of the text generation model;
and performing error back propagation by using a deep learning optimization algorithm according to the loss error, updating parameters of the text generation model to obtain a trained attribute control text generation model, and recording the model as a reply model.
8. An apparatus for intelligent response based on data processing, comprising:
a receiving sentence unit for receiving a request sentence;
the operation sentence unit is used for inputting the request sentence into a reply model for operation, generating a plurality of reply candidate sentences and first scores which are in one-to-one correspondence with the reply candidate sentences to obtain a reply candidate set, wherein the reply model is a model obtained based on deep machine learning training;
a matching list unit, configured to match the reply candidate set with a blacklist, so as to remove a reply candidate sentence matched with the blacklist from the reply candidate set, so as to obtain a first reply subset, where the blacklist is a preset reply sentence;
a sentence processing unit, configured to process each reply candidate sentence in the first reply subset through a similarity matching module and/or a length excitation module and/or a fluency detection module, so that the first score of each reply candidate sentence becomes a second score, and a second reply subset is obtained; the similarity matching module is used for calculating a score according to the similarity between the reply candidate sentence and the request sentence, the length excitation module is used for calculating a corresponding excitation score according to the length of the reply candidate sentence, and the fluency detection module is used for calculating a score according to the fluency of the reply candidate sentence;
the detection reply unit is used for processing the second reply subset through a diversity detection module to obtain a third reply subset, and the diversity detection module is used for screening the second reply subset according to the second score and a preset rule;
and a sentence extracting unit configured to extract one of the reply candidate sentences from the third reply subset as a reply sentence to reply to the request sentence, and output the reply sentence.
9. A computer device comprising a memory and a processor, the memory storing a computer program, wherein the processor implements the steps of the method of any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the method of any one of claims 1 to 7.
CN201910965267.7A 2019-10-11 2019-10-11 Intelligent response method and device based on data processing and computer equipment Active CN111104493B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910965267.7A CN111104493B (en) 2019-10-11 2019-10-11 Intelligent response method and device based on data processing and computer equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910965267.7A CN111104493B (en) 2019-10-11 2019-10-11 Intelligent response method and device based on data processing and computer equipment

Publications (2)

Publication Number Publication Date
CN111104493A true CN111104493A (en) 2020-05-05
CN111104493B CN111104493B (en) 2023-02-07

Family

ID=70421376

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910965267.7A Active CN111104493B (en) 2019-10-11 2019-10-11 Intelligent response method and device based on data processing and computer equipment

Country Status (1)

Country Link
CN (1) CN111104493B (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100191686A1 (en) * 2009-01-23 2010-07-29 Microsoft Corporation Answer Ranking In Community Question-Answering Sites
CN103229223A (en) * 2010-09-28 2013-07-31 国际商业机器公司 Providing answers to questions using multiple models to score candidate answers
CN104753765A (en) * 2013-12-31 2015-07-01 华为技术有限公司 Automatic short message reply method and device
CN105095182A (en) * 2014-05-22 2015-11-25 华为技术有限公司 Reply information recommendation method and apparatus
CN109344240A (en) * 2018-09-21 2019-02-15 联想(北京)有限公司 A kind of data processing method, server and electronic equipment

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100191686A1 (en) * 2009-01-23 2010-07-29 Microsoft Corporation Answer Ranking In Community Question-Answering Sites
CN103229223A (en) * 2010-09-28 2013-07-31 国际商业机器公司 Providing answers to questions using multiple models to score candidate answers
CN104753765A (en) * 2013-12-31 2015-07-01 华为技术有限公司 Automatic short message reply method and device
CN105095182A (en) * 2014-05-22 2015-11-25 华为技术有限公司 Reply information recommendation method and apparatus
CN109344240A (en) * 2018-09-21 2019-02-15 联想(北京)有限公司 A kind of data processing method, server and electronic equipment

Also Published As

Publication number Publication date
CN111104493B (en) 2023-02-07

Similar Documents

Publication Publication Date Title
CN110096570B (en) Intention identification method and device applied to intelligent customer service robot
CN106328147B (en) Speech recognition method and device
CN108711421B (en) Speech recognition acoustic model establishing method and device and electronic equipment
CN110347787B (en) Interview method and device based on AI auxiliary interview scene and terminal equipment
CN107844481B (en) Recognition text error detection method and device
KR20190085098A (en) Keyword extraction method, computer device, and storage medium
CN108710704B (en) Method, device, electronic device and storage medium for determining dialog state
CN111177359A (en) Multi-turn dialogue method and device
CN109344242B (en) A dialogue question answering method, device, equipment and storage medium
CN111554276B (en) Speech recognition method, device, equipment and computer readable storage medium
CN111223476B (en) Method and device for extracting voice feature vector, computer equipment and storage medium
CN114428852B (en) Chinese text summarization method and device based on BERT pre-training model
CN111046178A (en) Text sequence generation method and system
CN110399454B (en) Text coding representation method based on transformer model and multiple reference systems
CN118551004B (en) A Chinese dialogue knowledge retrieval method and system based on knowledge retrieval graph
CN110597968A (en) Reply selection method and device
CN116881470A (en) Method and device for generating question-answer pairs
CN114330319A (en) Entity processing method, entity processing device, electronic equipment and storage medium
CN111914560B (en) Text inclusion relation recognition method, device, equipment and storage medium
CN115617974B (en) Dialogue processing method, device, equipment and storage medium
CN111177381A (en) Slot filling and intention detection joint modeling method based on context vector feedback
CN112669836B (en) Command recognition method and device and computer readable storage medium
CN112863518B (en) Method and device for recognizing voice data subject
CN111104493B (en) Intelligent response method and device based on data processing and computer equipment
Li et al. 3M: Multi-style image caption generation using Multi-modality features under Multi-UPDOWN model

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
GR01 Patent grant
GR01 Patent grant