Method for constructing intelligent reply model based on deep learning and related devices
By preprocessing and multi-round training of the sample data of the intelligent reply model, the problem of insufficient training data of the existing model is solved, and the scope of application of the model and the rationality of the reply are improved.
Patent Information
- Application Number
- CN202010156698.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-03-09
- Publication Date
- 2025-07-22
- Estimated Expiration
- 2040-03-09
AI Technical Summary
The existing intelligent reply model is not sufficiently processed in the training data, resulting in a high syntax error rate and a small scope of application, which cannot meet user needs.
By preprocessing the first sample data and setting the attribute tag, the word part of the word is extracted, and inputting it into the first deep learning model for training to obtain the training model; preprocessing the second sample data and filtering similarity and fluency to generate candidate training data sets; mixing the first and third training data, inputting them to a small-scale deep learning model for training, and obtaining an intelligent reply model.
It improves the diversity and pertinence of training data, reduces the syntax error rate of reply statements, makes the reply more reasonable and has a wider scope of application.
Smart Images

Figure CN111428013B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of artificial intelligence, and particularly to a method for constructing an intelligent reply model based on deep learning and related devices. Background Art
[0002] With the rapid development of artificial intelligence technology, intelligent conversation has become one of the most challenging problems in the field of artificial intelligence. The dialogue system based on deep learning is a current popular development direction, which aims to obtain the to-be-replied statement input by the user and automatically give a reasonable reply statement.
[0003] Existing dialogue systems or intelligent reply models give grammar errors, irrelevant, unreasonable, and general replies to the to-be-replied statements of users. Further, in some platforms, the dialogue is restricted by the scenario and needs to generate positive, coherent, and reasonable replies, such as AI interviews, etc. However, the current intelligent reply system or intelligent reply model cannot effectively reply to the input statements, and the grammar error rate is high. The reason for the above problems is that the existing intelligent reply model does not effectively process the training data during training, the sample data is single and contains a large amount of useless data, resulting in low training efficiency. As a result, the applicable range of the trained intelligent reply model is small and cannot meet the requirements. Therefore, it is necessary to invent an effective method for constructing an intelligent reply model to solve the existing deficiencies. Summary of the Invention
[0004] The purpose of this application is to provide a method for constructing an intelligent reply model based on deep learning and related devices in view of the deficiencies of the prior art. By preprocessing the first sample data and then training to obtain a training model, training the second sample data in the training model to obtain a training data set, and mixing the first sample data with the training data set and then training again to obtain an intelligent reply model, the training data can be effectively screened, the pertinence of the sample data can be improved, and the initial sample data and the trained data can be mixed and trained again, which can improve the diversity of the training data, expand the applicable range of the intelligent reply model, reduce the grammar error rate of the reply statements, and make the replied statements more reasonable.
[0005] To achieve the above object, the technical solution of this application provides a method for constructing an intelligent reply model based on deep learning and related devices.
[0006] This application discloses a method for constructing an intelligent reply model based on deep learning, including the following steps:
[0007] Preprocess the response statements in the first sample dataset to obtain preprocessed response statements, and input the preprocessed response statements and the statements to be replied in the first sample dataset into a preset first deep learning model for training to obtain a training model;
[0008] Input the statements to be replied in the second sample dataset into the training model, output a first reply sample statement through the training model, combine the first reply sample data with the statements to be replied in the second sample dataset to obtain a candidate training dataset, preprocess the response statements in the candidate training dataset to obtain second reply sample statements, and combine the second reply sample statements with the statements to be replied in the candidate training dataset to obtain third training data;
[0009] Mix the first sample dataset and the third training data to obtain mixed training data, and input the mixed training data into a preset second deep learning model for training to obtain an intelligent reply model.
[0010] Preferably, the preprocessing of the response statements in the first sample dataset includes:
[0011] Obtain first sample data, clean the first sample data to obtain a first sample dataset;
[0012] Perform attribute setting on the response statements in the first sample dataset according to preset attribute tags;
[0013] Extract words from the response statements in the first sample dataset according to the word part of speech.
[0014] Preferably, the extracting words from the response statements in the first sample dataset according to the word part of speech includes:
[0015] Segment the response statements in the first sample dataset to obtain each word in the response statements;
[0016] Classify the part of speech of the words to obtain the part of speech of each word;
[0017] Compare the part of speech of each word with a preset part of speech. If the part of speech of the word is within the preset part of speech range, extract the word.
[0018] Preferably, the inputting the statements to be replied in the second sample dataset into the training model, outputting a first reply sample statement through the training model, and combining the first reply sample data with the statements to be replied in the second sample dataset to obtain a candidate training dataset includes:
[0019] Obtain the second sample data, preprocess the second sample data to obtain a second sample data set;
[0020] Input the reply statements to be replied in the second sample data set into the training model for processing to obtain multiple reply statements corresponding to the reply statements to be replied;
[0021] Correspond each reply statement to be replied with each reply statement one by one to form dialogues respectively, and form all the dialogues into a candidate training data set.
[0022] Preferably, the preprocessing of the reply statements in the candidate training set to obtain second reply sample statements includes:
[0023] Screen the reply statements in the candidate training set according to preset keywords to obtain screened reply statements;
[0024] Calculate the similarity, length incentive and fluency of the screened reply statements respectively, obtain the probability distribution of each screened reply statement according to the similarity, length incentive and fluency, and sort the screened reply statements according to the probability distribution to obtain ordered reply statements;
[0025] Perform diversity screening on the ordered reply statements to obtain second reply sample statements.
[0026] Preferably, the calculating the similarity, length incentive and fluency of the screened reply statements respectively includes:
[0027] Perform similarity matching between the screened reply statements and the reply statements to be replied in the candidate training set to obtain the similarity of each screened reply statement;
[0028] Obtain the length of each screened reply statement, and obtain the length incentive of each screened reply statement according to the length;
[0029] Perform fluency detection on the screened reply statements, and obtain the fluency of each screened reply statement according to the detection result.
[0030] Preferably, the performing diversity screening on the ordered reply statements includes:
[0031] Cumulatively count the word frequency of the same words in the first word of each ordered reply statement in turn to obtain the total word frequency. When the total word frequency is greater than the preset word frequency threshold, delete the currently accumulated reply statement;
[0032] Create a queue, sequentially obtain new ordered reply statements, compare the similarity between the new ordered reply statements and the old ordered reply statements in the queue, obtain the similarity between the new ordered reply statements and all old ordered reply statements. If any similarity is less than the preset similarity threshold, store the new ordered reply statement in the queue. If the similarity is greater than or equal to the preset similarity threshold, store the ordered reply statement corresponding to the highest probability distribution value in the queue.
[0033] This application also discloses an intelligent reply model construction device based on deep learning. The device includes:
[0034] A first training module, configured to preprocess the reply statements in the first sample dataset to obtain preprocessed reply statements, and input the preprocessed reply statements and the reply-to statements in the first sample dataset into a preset first deep learning model for training to obtain a training model.
[0035] A second training module, configured to input the reply-to statements in the second sample dataset into the training model, output a first reply sample statement through the training model, combine the first reply sample data with the reply-to statements in the second sample dataset to obtain a candidate training dataset, preprocess the reply statements in the candidate training dataset to obtain second reply sample statements, and combine the second reply sample statements with the reply-to statements in the candidate training dataset to obtain third training data.
[0036] A generation module, configured to mix the first sample dataset and the third training data to obtain mixed training data, and input the mixed training data into a preset second deep learning model for training to obtain an intelligent reply model.
[0037] This application also discloses an intelligent reply model construction device based on deep learning. The intelligent reply model construction device based on deep learning includes a memory and a processor. Computer-readable instructions are stored in the memory. When the computer-readable instructions are executed by one or more of the processors, one or more of the processors are caused to execute the steps of the above-mentioned intelligent reply model construction method based on deep learning.
[0038] This application also discloses a computer-readable storage medium. The storage medium can be read and written by a processor. The storage medium stores computer instructions. When the computer-readable instructions are executed by one or more processors, one or more of the processors are caused to execute the steps of the above-mentioned intelligent reply model construction method based on deep learning.
[0039] The beneficial effects of this application are as follows: By preprocessing the first sample data and then training to obtain a training model, training the second sample data in the training model to obtain a training data set, and mixing the first sample data with the training data set and then training again to obtain an intelligent reply model, it is possible to effectively screen the training data, improve the pertinence of the sample data, and mix the initial sample data and the trained data and then train again, which can improve the diversity of the training data, expand the applicable range of the intelligent reply model, reduce the grammar error rate of the reply sentences, and make the reply sentences more reasonable. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] Figure 1 It is a schematic flowchart of a method for constructing an intelligent reply model based on deep learning according to the first embodiment of this application;
[0041] Figure 2 It is a schematic flowchart of a method for constructing an intelligent reply model based on deep learning according to the second embodiment of this application;
[0042] Figure 3 It is a schematic flowchart of a method for constructing an intelligent reply model based on deep learning according to the third embodiment of this application;
[0043] Figure 4 It is a schematic flowchart of a method for constructing an intelligent reply model based on deep learning according to the fourth embodiment of this application;
[0044] Figure 5 It is a schematic flowchart of a method for constructing an intelligent reply model based on deep learning according to the fifth embodiment of this application;
[0045] Figure 6 It is a schematic flowchart of a method for constructing an intelligent reply model based on deep learning according to the sixth embodiment of this application;
[0046] Figure 7 It is a schematic flowchart of a method for constructing an intelligent reply model based on deep learning according to the seventh embodiment of this application;
[0047] Figure 8 It is a schematic structural diagram of an apparatus for constructing an intelligent reply model based on deep learning according to an embodiment of this application. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0048] In order to make the objectives, technical solutions and advantages of this application clearer, the following further elaborates on this application in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain this application and are not used to limit this application.
[0049] Those skilled in the art can understand that, unless specifically stated otherwise, the singular forms "a", "an", "the" and "said" used herein may also include the plural forms. It should be further understood that the term "comprising" used in the specification of this application means the presence of the stated features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or their groups.
[0050] The process of a method for constructing an intelligent reply model based on deep learning in the first embodiment of this application is as Figure 1 shown, and this embodiment includes the following steps:
[0051] Step S101: Preprocess the reply statements in the first sample dataset to obtain preprocessed reply statements, and input the preprocessed reply statements and the to-be-replied statements in the first sample dataset into a preset first deep learning model for training to obtain a training model;
[0052] Specifically, after obtaining the sample dataset, the reply statements in the sample dataset can be preprocessed to obtain preprocessed reply statements. The preprocessing includes attribute label setting and word extraction. Then, the preprocessed reply statements and the to-be-replied statements in the first sample dataset can be input into a preset first deep learning model for training to obtain a training model. The deep learning models include models such as Seq2Seq and Transformer. Input the preprocessed data into the deep learning model for training to obtain a training model. Among them, the way of inputting the preprocessed data into the deep learning model includes: inputting the to-be-replied statement and the reply statement into the deep learning model.
[0053] Step S102: Input the to-be-replied statements in the second sample dataset into the training model, output the first reply sample statements through the training model, combine the first reply sample data with the to-be-replied statements in the second sample dataset to obtain a candidate training dataset, preprocess the reply statements in the candidate training dataset to obtain second reply sample statements, and combine the second reply sample statements with the to-be-replied statements in the candidate training dataset to obtain third training data;
[0054] Specifically, after obtaining the second sample data set, the sentence to be replied in the second sample data set can be input into the training model obtained in step s101. After being processed by the training model, a first reply sample sentence corresponding to the sentence to be replied can be obtained. For example, if the sentence to be replied is "What sport do you like?", then the reply sentence may be "I like playing basketball". After obtaining the reply sentence, the first reply sample sentence can be combined with the sentence to be replied in the second sample data set to obtain a candidate training data set, and the reply sentence in the candidate training set can be further preprocessed to obtain a second reply sample sentence, and the second reply sample sentence can be combined with the sentence to be replied in the candidate training data set to obtain a third training data.
[0055] Step s103: mix the first sample data set and the third training data to obtain mixed training data, and input the mixed training data into a preset second deep learning model for training to obtain an intelligent response model.
[0056] Specifically, after obtaining the first sample data set and the third training data, the first sample data set and the third training data can be mixed, and then a small-scale deep learning model is selected, and the deep learning model includes: Seq2Seq, Transformer and other models; the deep learning model in this step has the same function as the deep learning model in step s101, but is smaller in scale, because the model in this step is aimed at a specific scenario, so in order to improve the training performance, it is more appropriate to select a small-scale model; after the deep learning model is selected, the mixed first sample data set and the third training data are input into the small-scale deep learning model, and training is performed. During the training process, a goal can be preset. When the training result reaches the predetermined goal, the training can be stopped. At this time, the small-scale deep learning model obtained through training is the intelligent reply model.
[0057] In this embodiment, by preprocessing the first training data before training, training the preprocessed data, and training after preprocessing the second training data, candidate training data is obtained, and then the candidate training data is preprocessed and trained to obtain an intelligent reply model, thereby automatically generating reasonable sentences based on the user's questions, meeting user needs and improving user experience.
[0058] Figure 2 This is a flow chart of a method for building an intelligent reply model based on deep learning according to the second embodiment of the present application. As shown in the figure, step s101 pre-processes the reply sentences in the first sample data set, including:
[0059] Step 201, obtain the first sample data, clean the first sample data, and obtain the first sample data set;
[0060] Specifically, the first sample data can be obtained by data crawling from popular websites on the Internet. The sample data includes the sentence to be replied and the reply sentence. When doing data crawling, the comment data of users on a certain topic on each social platform is crawled. The follow-up comments of different users under the comment are considered as a group of conversations. For example:
[0061] User A: The movie "AAA" is not as good as the first one.
[0062] User B: I think it's okay. mainly for the sake of Principal Gu.
[0063] The conversations of the above User A and User B are considered as a group of conversations. Among them, when crawling data, keywords can be preset in advance. The keywords can be distinguished by theme, such as: movies, food, etc. After obtaining the first sample data, the first sample data can be cleaned. The data cleaning includes screening out the useless data in the sample data. For example, some of the conversations are sensitive information, and the sensitive information includes political, criminal, swearing and other information. Therefore, the sensitive information can be set as the keyword, and all the first sample data can be queried according to the keyword, and all the conversations containing the keyword can be deleted. After cleaning the first sample data, the cleaned data can be composed into a sample data set. The sample data set includes a set of conversations. Among them, each conversation includes a sentence to be replied (question) and a reply sentence (answer). Since the sample data set has been cleaned, each conversation can be regarded as a sample data; after obtaining the sample data set, the sample data set can also be split. For example, 90% of the data in the sample data set is used as the training data set, and the remaining 10% of the data is used as the validation data set; the training data set is used for the training of the deep learning model, and the validation data set is used for the verification and evaluation of the effect of the trained model.
[0064] Step s202, perform attribute setting on the reply sentences in the first sample data set according to the preset attribute tags;
[0065] Specifically, first, attribute tags can be set for the response sentences. The attribute tags include length, sentence pattern, and sentiment. When setting the length attribute of the response sentences, they can be divided into three attributes: short, medium, and long according to the length of the characters in the response sentences. Suppose the lengths of the response sentences in all conversations in the training dataset are statistically distributed as [3, 20]. Then the length intervals covered by the attributes are divided as follows: the short-attribute interval is [3, 5], the medium-attribute interval is [6, 11], and the long-attribute interval is [12, 20], thus constituting three length attributes: short sentences, medium sentences, and long sentences.
[0066] Specifically, when setting the sentence pattern and sentiment attributes of the response sentences, since the sentence pattern and sentiment attributes are non-intuitive and non-quantifiable attributes, the entire sentence needs to be analyzed. A text attribute classifier can be trained based on the TextCNN model, and then the sentence pattern and sentiment of the response sentences can be classified and labeled. Among them, the sentence patterns include interrogative sentences, declarative sentences, and imperative sentences; the sentiments include like, sad, disgust, angry, happy, and others.
[0067] Through the setting of attributes, the sample data will contain data with various tags. In this way, after training through the model, the model can reply with data of various tags according to the input sentence. For example, for a trained model, if we preset to reply with a happy sentence, then when a sentence is input, the model will automatically reply with a happy sentence.
[0068] Step S203: Extract words from the response sentences in the first sample dataset according to the part of speech.
[0069] Specifically, words can also be extracted from the response sentences. The word extraction can be performed by comparing the part of speech. The parts of speech include nouns, verbs, adjectives, and adverbs. After determining the part of speech, the words in the data of the first training dataset can be extracted according to the preset part of speech.
[0070] In this embodiment, by setting attributes and extracting words for the response sentences, the recognition degree of the response sentences can be improved, and further the accuracy of the sentence reply of the training model can be improved.
[0071] Figure 3 As shown in the figure, it is a schematic flowchart of a method for constructing an intelligent reply model based on deep learning according to the third embodiment of the present application. The step S203: Extract words from the response sentences in the first sample dataset according to the part of speech, includes:
[0072] Step S301: Segment the words in the response sentences in the first sample dataset to obtain each word in the response sentences;
[0073] Specifically, all response sentences in the training data to be processed can be segmented into words using the Jieba tool to obtain each word in the response sentences.
[0074] Step S302: Perform part-of-speech tagging on the words to obtain the part of speech of each word.
[0075] Specifically, after obtaining each word in the response sentence, the part of speech of each word can be identified. For example, the identified part of speech of the word is not limited to the predefined parts of speech. For example, the predefined parts of speech are nouns, verbs, adjectives, and adverbs, and the identified part of speech may be numerals, pronouns, or quantifiers, etc.
[0076] Step S303: Compare the part of speech of each word with the predefined part of speech. If the part of speech of the word is within the predefined range of parts of speech, extract the word.
[0077] Specifically, after identifying the part of speech of each word, the part of speech of each word can be compared with the predefined part of speech. If the part of speech of the word is within the predefined range of parts of speech, extract the currently compared word. The extraction includes retaining the current word. If the part of speech of the current word is not within the predefined range of parts of speech, delete the currently compared word.
[0078] In this embodiment, by segmenting the response sentence, then comparing the part of speech of each word and extracting the word, the required words can be retained, improving the interpretation of the response sentence, thereby improving the accuracy and efficiency of training.
[0079] Figure 4 As shown in the figure, it is a schematic flowchart of a method for constructing an intelligent response model based on deep learning according to the fourth embodiment of the present application. In step S102, the response sentence to be replied in the second sample dataset is input into the training model, and the first response sample sentence is output through the training model. The first response sample data is combined with the response sentence to be replied in the second sample dataset to obtain a candidate training dataset, including:
[0080] Step S401: Obtain the second sample data, and preprocess the second sample data to obtain the second sample dataset.
[0081] Specifically, the second sample data can also be obtained by data crawling. First, obtain the original comment data. For example, the comment data of users on a certain topic on various social platforms on the Internet; the second sample data can also be obtained from the input of users in the user logs pulled from the technology implementation platform. For example, on an AI interview platform, the virtual interviewer asks a question, and the user's answer to this question:
[0082] Virtual interviewer: What are your hobbies?
[0083] User's answer: Usually like running and playing basketball.
[0084] Among them, the questions and answers of the user are the data that need to be collected. Then, the original comment data and user log data are cleaned. The cleaning can be performed through step s201 to delete the sentences containing sensitive words. Finally, scene keywords are set, and the cleaned data is filtered according to the scene keywords to obtain a second sample data set. The scene keywords include hobbies, work content, etc. The hobbies are for daily life scenes, and the work content is for interview scenes.
[0085] Step s402, input the to-be-replied sentences in the second sample data set into the training model for processing to obtain multiple replied sentences corresponding to the to-be-replied sentences;
[0086] Specifically, the to-be-replied sentences in the second sample data set can be input into the training model to obtain the corresponding replied sentences. Among them, when inputting the to-be-replied sentences, the beam search method can be combined to generate diverse replied sentences, that is, when a to-be-replied sentence is input into the training model, multiple replied sentences are output, and each set of replied sentences will have a corresponding probability distribution among all the replied sentences.
[0087] Step s403, pair each to-be-replied sentence with each replied sentence one by one to form conversations respectively, and form all the conversations into a candidate training data set.
[0088] Specifically, after obtaining the replied sentences, each to-be-replied sentence can be paired with each replied sentence one by one to form conversations respectively, and form all the conversations into a candidate training data set. Taking the to-be-replied sentence A as an example, three replied sentences B, C, and D are generated, then three groups of conversations (A, B), (A, C), and (A, D) can be formed, and these three groups of conversations are formed into a candidate training data set.
[0089] In this embodiment, by inputting the second training data set into the training model to obtain replied sentences and forming a candidate training data set, sample data can be provided for the next step of training, thereby improving the accuracy and efficiency of training.
[0090] Figure 5 It is a schematic flowchart of a method for constructing an intelligent reply model based on deep learning according to the fifth embodiment of the present application. As shown in the figure, in step s102, the replied sentences in the candidate training set are preprocessed to obtain second replied sample sentences, including:
[0091] Step s501: Screen the response sentences in the candidate training set according to preset keywords to obtain screened response sentences;
[0092] Specifically, the first step of preprocessing is to screen the response sentences in the candidate training set. The screening can be done by keywords to delete the response sentences that match the keywords. For example, responses irrelevant to the current theme can be deleted.
[0093] Step s502: Calculate the similarity, length incentive, and fluency of the screened response sentences respectively, obtain the probability distribution of each screened response sentence according to the similarity, length incentive, and fluency, and sort the screened response sentences according to the probability distribution to obtain ordered response sentences;
[0094] Specifically, after the screening, the similarity, length incentive, and fluency of the screened response sentences can also be calculated, and the probability distribution of each screened response sentence is obtained according to the similarity, length incentive, and fluency. The probability distribution value is the cumulative value of the similarity, length incentive, and fluency. Then, the screened response sentences are sorted according to the probability distribution to obtain ordered response sentences. The sorting is from high to low according to the level of the probability distribution; that is, the response sentences are sorted from large to small according to the new probability distribution value. In this way, good response sentences can obtain higher scores as much as possible. After sorting, the more forward ones have more relevant, smoother, and better response effects.
[0095] Step s503: Conduct diversity screening on the ordered response sentences to obtain the second response sample sentences.
[0096] Specifically, after obtaining the probability distribution of the response sentences and sorting them, diversity screening can also be performed on each response sentence to obtain the second response sample sentences. The diversity screening can include word frequency screening and similarity screening.
[0097] In this embodiment, by performing keyword screening and diversity screening on the response sentences in the candidate training set and sorting according to the probability distribution, more accurate response sentences can be obtained, improving the accuracy of the model.
[0098] Figure 6 This is a schematic flowchart of a method for constructing an intelligent response model based on deep learning according to the sixth embodiment of the present application. As shown in the figure, in step s502, calculating the similarity, length incentive, and fluency of the screened response sentences respectively includes:
[0099] Step s601: Perform similarity matching between the screened response sentences and the to-be-replied sentences in the candidate training set to obtain the similarity of each screened response sentence;
[0100] Specifically, after screening the keywords of the reply statement, similarity calculation can be performed on the screened reply statement. The similarity calculation includes matching the similarity between the screened reply statement and the reply statement to be replied in the candidate training set, thereby obtaining the similarity of each screened reply statement. First, the reply statement to be replied and the reply statement can be tokenized using the jieba tokenization tool to obtain the word sets post = {word1, word2,... wordm}, ri = {word1, word2,... wordn}; where post is the reply statement to be replied, ri is the reply statement, and word is each word in the statement. Then, post and ri are screened according to the part-of-speech configuration to obtain the new word sets postN = {word1, word2,... wordp}, riN = {word1, word2,... wordq}, where 0 <= p <= m, 0 <= q <= n. The similarity can be calculated by the cosine similarity method, and the formula is as follows:
[0101] Among them, vector_post is the vector of the reply statement to be replied, and the formula is:
[0102] Among them, vector_r is the vector of the reply statement, and the formula is:
[0103] If p or q is not 0, then select p or q, otherwise select m and n.
[0104] Step S602, obtain the length of each screened reply statement, and obtain the length incentive of each screened reply statement according to the length.
[0105] Specifically, when calculating the length incentive of the reply statement, the length of each screened reply statement can be obtained first. Let the length of each screened reply statement be len_i, and a preset length incentive value can be set, and the length incentive value is associated with the length of the reply statement. For example, when len_i is less than or equal to 7, S_len = α; if len_i is greater than 7, S_len = β; where α and β are both empirical values, and the reply statement length 7 is a threshold that can be preset in advance.
[0106] Step S603, perform fluency detection on the screened reply statement, and obtain the fluency of each screened reply statement according to the detection result.
[0107] Specifically, when calculating the fluency of the response sentence, the sentence can be judged according to Chinese grammar, and the detection methods include: n-gram method, rule matching method, etc. If the sentence is not fluent, then S_flue = γ; otherwise, S_flue = 0, where γ is an empirical value.
[0108] In this embodiment, by performing similarity detection, length incentive, and fluency detection on the response sentence, the probability distribution of the response sentence can be accurately obtained, thereby improving the response accuracy of the response sentence.
[0109] Figure 7 It is a schematic flowchart of a method for constructing an intelligent response model based on deep learning according to the seventh embodiment of the present application. As shown in the figure, in step s503, the diversity screening of the ordered response sentences includes:
[0110] Step s701: Cumulatively calculate the word frequency of the same words of the first word in each ordered response sentence in sequence to obtain the total word frequency. When the total word frequency is greater than the preset word frequency threshold, the currently accumulated response sentence is deleted;
[0111] Specifically, a word frequency threshold T_count can be preset first, and then the word frequency of the first word in each response sentence is counted. When the word frequency of the first word exceeds the threshold T_count, the current sentence is deleted; for example: if the first word in the first response sentence is A, then the word A is recorded once. If the first word in the second response sentence is still A, then A is recorded as 2 times. If the word frequency threshold is 2, then the second response sentence is deleted, and so on.
[0112] Step s702: Create a queue, and sequentially obtain new ordered response sentences. Compare the similarity of the new ordered response sentences with the old ordered response sentences in the queue to obtain the similarity between the new ordered response sentences and all the old ordered response sentences. If any similarity is less than the preset similarity threshold, the new ordered response sentence is stored in the queue. If the similarity is greater than or equal to the preset similarity threshold, the ordered response sentence corresponding to the highest probability distribution value is stored in the queue.
[0113] Specifically, a similarity threshold T_sim can be preset first, and then a queue is created. The reply statements are obtained in sequence. The reply statements include new ordered reply statements, and similarity judgment is performed. The similarity judgment includes comparing the similarity between the new ordered reply statements and the old ordered reply statements in the queue, and caching the reply statements after similarity judgment in the queue. During the similarity judgment process, whenever a reply statement is compared with all cached reply statements, if any similarity is less than the preset similarity threshold, the new ordered reply statement is stored in the queue; if the similarity is greater than or equal to the preset similarity threshold, only the ordered reply statement corresponding to the highest probability distribution value is stored in the queue.
[0114] In this embodiment, by screening the reply statements according to word frequency and similarity, the accuracy of the reply statements can be further improved, and the accuracy of the model can be improved.
[0115] The structure of an intelligent reply model construction device based on deep learning according to an embodiment of the present application is as Figure 8 shown, including:
[0116] A first training module 801, a second training module 802, and a generation module 803; wherein, the first training module 801 is connected to the second training module 802, and the second training module 802 is connected to the generation module 803; the first training module 801 is used to preprocess the reply statements in the first sample dataset to obtain preprocessed reply statements, and input the preprocessed reply statements and the reply-to statements in the first sample dataset into a preset first deep learning model for training to obtain a training model; the second training module 802 is used to input the reply-to statements in the second sample dataset into the training model, output a first reply sample statement through the training model, combine the first reply sample data with the reply-to statements in the second sample dataset to obtain a candidate training dataset, preprocess the reply statements in the candidate training dataset to obtain a second reply sample statement, and combine the second reply sample statement with the reply-to statements in the candidate training dataset to obtain a third training data; the generation module 803 is used to mix the first sample dataset and the third training data to obtain mixed training data, and input the mixed training data into a preset second deep learning model for training to obtain an intelligent reply model.
[0117] The embodiments of the present application also disclose a device for constructing an intelligent reply model based on deep learning. The device for constructing an intelligent reply model based on deep learning includes a memory and a processor. Computer-readable instructions are stored in the memory. When the computer-readable instructions are executed by one or more of the processors, the one or more processors are caused to execute the steps in the method for constructing an intelligent reply model based on deep learning in the above-mentioned respective embodiments.
[0118] The embodiments of the present application also disclose a computer-readable storage medium. The storage medium can be read and written by a processor. The memory stores computer-readable instructions. When the computer-readable instructions are executed by one or more processors, the one or more processors are caused to execute the steps in the method for constructing an intelligent reply model based on deep learning in the above-mentioned respective embodiments.
[0119] Those of ordinary skill in the art can understand that all or part of the processes of implementing the methods in the above embodiments can be completed by instructing relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above methods. Among them, the aforementioned storage medium can be a non-volatile storage medium such as a magnetic disk, an optical disc, a read-only memory (ROM), etc., or a random access memory (RAM), etc.
[0120] The technical features of the above embodiments can be combined arbitrarily. For the sake of concise description, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, it should be considered as the scope described in this specification.
[0121] The above embodiments only represent several implementation manners of the present application. Their descriptions are relatively specific and detailed, but they should not be construed as limiting the patent scope of the present application. It should be noted that for those of ordinary skill in the art, without departing from the concept of the present application, several modifications and improvements can still be made, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application should be subject to the appended claims.
Claims
1. A method for constructing an intelligent reply model based on deep learning, characterized in that The method for constructing an intelligent reply model based on deep learning includes: Preprocess the reply statements in the first sample dataset to obtain preprocessed reply statements, and input the preprocessed reply statements and the statements to be replied in the first sample dataset into a preset first deep learning model for training to obtain a trained model; Input the statements to be replied in the second sample dataset into the trained model, output a first reply sample statement through the trained model, combine the first reply sample statement with the statements to be replied in the second sample dataset to obtain a candidate training dataset, preprocess the reply statements in the candidate training dataset to obtain second reply sample statements, and combine the second reply sample statements with the statements to be replied in the candidate training dataset to obtain third training data; Mix the first sample dataset and the third training data to obtain mixed training data, and input the mixed training data into a preset second deep learning model for training to obtain an intelligent reply model; The preprocessing of the reply statements in the candidate training dataset to obtain second reply sample statements includes: Screen the reply statements in the candidate training dataset according to preset keywords to obtain screened reply statements; Calculate the similarity, length incentive, and fluency of each screened reply statement respectively, obtain the probability distribution of each screened reply statement according to the similarity, length incentive, and fluency, and sort the screened reply statements according to the probability distribution to obtain ordered reply statements; Perform diversity screening on the ordered reply statements to obtain second reply sample statements; The diversity screening of the ordered reply statements includes: Cumulatively calculate the word frequency of the same words of the first word in each ordered reply statement in sequence to obtain the total word frequency. When the total word frequency is greater than a preset word frequency threshold, delete the currently accumulated reply statement; Create a queue, obtain new ordered reply statements in sequence, compare the similarity of the new ordered reply statements with the old ordered reply statements in the queue to obtain the similarity of the new ordered reply statements with all old ordered reply statements. If any similarity is less than a preset similarity threshold, store the new ordered reply statement in the queue. If the similarity is greater than or equal to the preset similarity threshold, store the ordered reply statement corresponding to the highest probability distribution value in the queue.
2. The method for constructing an intelligent reply model based on deep learning according to claim 1, wherein The preprocessing of the reply statements in the first sample dataset includes: Obtain the first sample data, clean the first sample data to obtain the first sample dataset; Perform attribute setting on the reply statements in the first sample dataset according to preset attribute tags; Extract words from the reply statements in the first sample dataset according to part of speech.
3. The method for constructing an intelligent reply model based on deep learning according to claim 2, wherein, The extraction of words from the reply statements in the first sample dataset according to part of speech includes: Segment the reply statements in the first sample dataset to obtain each word in the reply statements; Classify the part of speech of the words to obtain the part of speech of each word; Compare the part-of-speech of each word with a preset part-of-speech range. If the part-of-speech of the word is within the preset part-of-speech range, extract the word.
4. The method for constructing an intelligent reply model based on deep learning according to claim 3, wherein, Input the to-be-replied statement in the second sample dataset into the training model, output a first reply sample statement through the training model, and combine the first reply sample statement with the to-be-replied statement in the second sample dataset to obtain a candidate training dataset, including: Obtain second sample data, perform preprocessing on the second sample data to obtain a second sample dataset; Input the to-be-replied statement in the second sample dataset into the training model for processing to obtain multiple reply statements corresponding to the to-be-replied statement; Correspond each to-be-replied statement with each reply statement one by one to form dialogues respectively, and combine all the dialogues to form a candidate training dataset.
5. The method for constructing an intelligent reply model based on deep learning according to claim 1, characterized in that, The calculating the similarity, length incentive, and fluency of the filtered reply statements respectively includes: Perform similarity matching between the filtered reply statements and the to-be-replied statements in the candidate training dataset to obtain the similarity of each filtered reply statement; Obtain the length of each filtered reply statement, and obtain the length incentive of each filtered reply statement according to the length; Perform fluency detection on the filtered reply statements, and obtain the fluency of each filtered reply statement according to the detection results.
6. An intelligent reply model construction device based on deep learning, characterized in that The intelligent reply model construction device based on deep learning includes: A first training module, configured to perform preprocessing on the reply statements in the first sample dataset to obtain preprocessed reply statements, and input the preprocessed reply statements and the to-be-replied statements in the first sample dataset into a preset first deep learning model for training to obtain a training model; A second training module, configured to input the to-be-replied statements in the second sample dataset into the training model, output a first reply sample statement through the training model, combine the first reply sample statement with the to-be-replied statements in the second sample dataset to obtain a candidate training dataset, perform preprocessing on the reply statements in the candidate training dataset to obtain second reply sample statements, and combine the second reply sample statements with the to-be-replied statements in the candidate training dataset to obtain third training data; A generation module, configured to mix the first sample dataset and the third training data to obtain mixed training data, and input the mixed training data into a preset second deep learning model for training to obtain an intelligent reply model; A second training module, configured to screen the reply statements in the candidate training dataset according to preset keywords to obtain filtered reply statements; calculate the similarity, length incentive, and fluency of the filtered reply statements respectively, obtain the probability distribution of each filtered reply statement according to the similarity, length incentive, and fluency, and sort the filtered reply statements according to the probability distribution to obtain ordered reply statements; perform diversity screening on the ordered reply statements to obtain second reply sample statements; The second training module is used to sequentially accumulate the word frequencies of the same words in the first word of each ordered reply statement to obtain the total word frequency. When the total word frequency is greater than a preset word frequency threshold, the currently accumulated reply statement is deleted; create a queue, sequentially obtain new ordered reply statements, compare the similarity between the new ordered reply statements and the old ordered reply statements in the queue to obtain the similarity between the new ordered reply statements and all old ordered reply statements. If any similarity is less than the preset similarity threshold, the new ordered reply statement is stored in the queue. If the similarity is greater than or equal to the preset similarity threshold, the ordered reply statement corresponding to the highest probability distribution value is stored in the queue.
7. An intelligent reply model construction device based on deep learning, characterized in that, The device for constructing the intelligent reply model based on deep learning includes a memory and a processor. Computer-readable instructions are stored in the memory. When the computer-readable instructions are executed by one or more of the processors, the steps of the method for constructing the intelligent reply model based on deep learning according to any one of claims 1 to 5 are implemented.
8. A computer-readable storage medium, characterized in that, The storage medium can be read and written by the processor. The storage medium stores computer instructions. When the computer-readable instructions are executed by one or more processors, the steps of the method for constructing the intelligent reply model based on deep learning according to any one of claims 1 to 5 are implemented.
Citation Information
Patent Citations
Deep learning neural network, training method, prediction method, system, equipment and medium
CN110188176A