WO2023108994A1 - 一种语句生成方法及电子设备、存储介质 - Google Patents

一种语句生成方法及电子设备、存储介质 Download PDF

Info

Publication number
WO2023108994A1
WO2023108994A1 PCT/CN2022/090744 CN2022090744W WO2023108994A1 WO 2023108994 A1 WO2023108994 A1 WO 2023108994A1 CN 2022090744 W CN2022090744 W CN 2022090744W WO 2023108994 A1 WO2023108994 A1 WO 2023108994A1
Authority
WO
WIPO (PCT)
Prior art keywords
sentence
emotional
information
dialogue
feature
Prior art date
Application number
PCT/CN2022/090744
Other languages
English (en)
French (fr)
Inventor
舒畅
陈又新
Original Assignee
平安科技(深圳)有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 平安科技(深圳)有限公司 filed Critical 平安科技(深圳)有限公司
Publication of WO2023108994A1 publication Critical patent/WO2023108994A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/30Semantic analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/33Querying
    • G06F16/332Query formulation
    • G06F16/3329Natural language query formulation or dialogue systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • 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/3331Query processing
    • G06F16/334Query execution
    • G06F16/3344Query execution using natural language analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/21Design or setup of recognition systems or techniques; Extraction of features in feature space; Blind source separation
    • G06F18/214Generating training patterns; Bootstrap methods, e.g. bagging or boosting
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/205Parsing
    • G06F40/211Syntactic parsing, e.g. based on context-free grammar [CFG] or unification grammars
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks

Definitions

  • the present application relates to the technical field of artificial intelligence, in particular to a method for generating sentences, electronic equipment, and storage media.
  • the present application provides a storage medium for computer-readable storage, the storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to A method for generating a sentence is realized, wherein the method for generating a sentence includes: acquiring current dialog information, the current dialog information including at least two dialog sentences, the at least two dialog sentences including the first sentence to be replied; The current dialogue information is input into the first prediction model for emotional analysis to obtain the first emotional feature information; the first emotional feature information is input into the memory model for emotional clue analysis to obtain the first emotional clue feature; Performing semantic analysis on the first sentence to obtain first semantic information of the first sentence; inputting the first emotional clue features and the first semantic information into a second prediction model for vocabulary prediction to obtain multiple predicted words; generate a reply sentence for the first sentence according to a plurality of predicted words.
  • the sentence generation method, electronic equipment, and storage medium proposed by the present application can obtain current dialogue information, wherein, the current dialogue information has at least two dialogue sentences, and the two dialogue sentences include the first sentence to be replied, and the current dialogue information Input it into the first prediction model for sentiment analysis to obtain the first emotion feature information, and then input the first emotion feature information into the memory model for emotional clue analysis to obtain the first emotional clue feature, which can reflect the emotional changes in the interactive dialogue process .
  • the first semantic information obtained from the analysis of the first sentence and the above-mentioned first emotional clue features are input into the second prediction model for vocabulary prediction, and a plurality of predicted words can be obtained to generate a reply to the first sentence statement. It can be seen that this application can integrate the emotional changes in the interactive dialogue scene into the dialogue semantics, thereby generating more anthropomorphic dialogue replies with more accurate emotional expression, and further optimizing the interaction effect of the man-machine dialogue.
  • FIG. 1 is a structural block diagram of an electronic device applied in an embodiment of the present application
  • FIG. 2 is a flow chart of a sentence generation method provided in Embodiment 1 of the present application.
  • Fig. 3 is a schematic diagram of the principle of generating first emotional feature information and first emotional clue features in an embodiment of the present application
  • FIG. 5 is a flow chart of a sentence generation method provided in Embodiment 2 of the present application.
  • the electronic device may be a server, a smart phone, a tablet computer, a portable computer, a desktop computer, and other terminal devices with computing functions.
  • the server can be an independent server, or it can provide cloud service, cloud database, cloud computing, cloud function, cloud storage, network service, cloud communication, middleware service, domain name service, security service, content distribution network (Content Delivery Network) Network, CDN), and cloud servers for basic cloud computing services such as big data and artificial intelligence platforms.
  • the electronic device includes: a memory 11 , a processor 12 , a network interface 13 and a data bus 14 .
  • Processor 12 can be a central processing unit (Central Processing Unit, CPU) in some embodiments, microprocessor or other data processing chip, is used for running the program code stored in memory 11 or processing data, for example executes the statement generating program wait.
  • CPU Central Processing Unit
  • the network interface 13 may optionally include a standard wired interface or wireless interface (such as a WI-FI interface), which is generally used to establish a communication connection between the electronic device and other electronic devices.
  • a standard wired interface or wireless interface such as a WI-FI interface
  • the data bus 14 is used to realize connection communication between these components.
  • FIG. 1 only shows the electronic device with components 11-14, but it should be understood that implementation of all of the illustrated components is not required and that more or fewer components may instead be implemented.
  • FIG. 2 is a flow chart of the sentence generating method provided in Embodiment 1 of the present application.
  • the processor 12 Based on the electronic equipment shown in Figure 1, the processor 12 implements the following steps when executing the statement generation program stored in the memory 11:
  • Step S200 Obtain current dialog information, wherein the current dialog information includes at least two dialog sentences, and the at least two dialog sentences include the first sentence to be replied.
  • the ways for electronic devices to obtain original dialogue data may include but are not limited to: 1.
  • Software or plug-ins with dialogue communication functions (such as customer service robots, outbound call robots, voice assistants and other third-party social communication software, etc.) are installed on electronic devices; ), the electronic device can obtain the dialog data input by the user manually or by voice through the front end of the above software (or plug-in), and receive the dialog data sent by other terminals.
  • the electronic device responds to the statement generating instruction, and directly obtains the information content corresponding to the statement generating instruction as the original dialogue data.
  • the triggering method of the statement generation instruction may include but not limited to text operation or picture operation.
  • the electronic device pops up a function option box. If the statement generation item in the function option box (for example, if the icon of the above-mentioned software or plug-in) is selected, the electronic device generates a sentence generation instruction, and determines the selected text as the information content corresponding to the sentence generation instruction. Therefore, the triggering scenarios of the statement generation instruction can be more diversified, so that the data source of the dialogue data is not limited to the front-end interaction of the specified software. 3.
  • the electronic device acquires the dialogue record file input by the user, and parses out the original dialogue data from the dialogue record file.
  • the dialog recording file may be a file exported from a third-party social communication software, and is used to record dialog information in a specified format (such as a text format or a database file, etc.).
  • dialogue content is text content
  • sentence segmentation is performed on the text content to obtain dialogue sentences.
  • a dialogue sentence can be generated directly according to the label or file name of the image. For example, if the image is named "stunned.jpg", then the dialogue sentence is determined to be "stunned”. Or, use image recognition technology to analyze the features of the image (such as object, background, text, composition, color features, facial expressions, etc.), and determine the text information related to the image according to the image analysis results as dialogue sentences. Or, image search technology is used to search for images (for example, image search) to obtain associated images, and then the dialog sentences are determined by obtaining description information related to the associated images.
  • the voice content is converted into text by using automatic speech recognition technology (automatic speech recognition, ASR) to obtain dialogue sentences.
  • ASR automatic speech recognition
  • the interactive dialog can be an intelligent dialog between a user and an electronic device, for example, the electronic device interacts with the user through a software front end with a dialog communication function.
  • the interactive dialogue can also be a scene dialogue between multiple users. For example, when the current user of the electronic device uses social software to communicate with users of other terminals, the electronic device can call a plug-in on the social software to provide the current user Automatically generate conversation replies.
  • Step S210 Input the current dialogue information into the first prediction model for sentiment analysis to obtain the first sentiment characteristic information.
  • the first emotional feature information may include sentence emotional features of each dialogue sentence.
  • the first prediction model may adopt a neural network model (such as a convolutional neural network model and a recurrent neural network model), a Bayesian model, or an attention model, etc., which is not limited.
  • the first prediction model includes a bidirectional neural network, a fully connected layer and a first classification layer, the first classification layer can use a softmax function, and the bidirectional neural network can use a bidirectional recurrent neural network (recurrent neural network, RNN), bidirectional gate recurrent unit (gate recurrent unit, GRU) or bidirectional long short term memory network (long short term memory, LSTM), etc., which are not specifically limited.
  • step S210 may specifically be: for each dialog sentence, perform word segmentation processing on the dialog sentence to obtain a plurality of target vocabulary corresponding to the dialog sentence.
  • word segmentation processing methods may include but are not limited to: use word segmentation tools, such as hanlp and Baidu NLP, etc.; use dictionary-based word segmentation methods, such as forward maximum matching method and shortest path method, etc.; use statistics-based word segmentation methods, such as implicit Markov model and N-gram etc.
  • a plurality of target words are input into the first predictive model.
  • the first vector and the second vector corresponding to each target vocabulary are generated through a bidirectional neural network, and the first vector and the second vector corresponding to each target vocabulary are subjected to feature classification processing through the fully connected layer and the classification layer to obtain the sentence sentiment of the dialogue sentence feature. It can be seen that the use of bidirectional neural networks can deeply mine the timing information and semantic information in dialogue sentences, which is conducive to improving the accuracy of emotion classification.
  • FIG. 3 is a schematic diagram of a principle of generating first emotional feature information and first emotional clue features in an embodiment of the present application.
  • the bidirectional neural network employs multiple bidirectionally connected GRU units. Input the 4 target words w1, w2, w3 and w4 into different GRU units respectively, and obtain the expression vectors output by each GRU unit, which are [the first vector second vector ], [third vector fourth vector ], [fifth vector sixth vector ] and [the seventh vector eighth vector ].
  • the expression vector of each GRU unit passes through the fully connected layer and the classification layer in turn, so that each expression vector is mapped to different emotional categories, and the weight vectors of the dialogue sentences belonging to different emotional categories are obtained, so that the above weight vectors are determined as Sentence sentiment features.
  • the weight vector is a vector representation of the probability values that the dialogue sentence belongs to different emotion categories, and the emotion categories include but not limited to joy, anger, worry, thought, sadness, fear and surprise. It can be understood that FIG. 3 is only an example, and does not constitute a specific limitation on the number of GRU units included in the bidirectional neural network.
  • Step S220 Input the first emotional feature information into the memory model to analyze the emotional clues to obtain the first emotional clue features.
  • Step S230 Perform semantic analysis on the first sentence to obtain first semantic information of the first sentence.
  • the electronic device may input the first sentence into a predetermined semantic analysis model to obtain the first semantic information.
  • the semantic analysis model can use the BERT model, which is not specifically limited.
  • the training steps of the semantic analysis model include: preparing a second training set including a certain number of sentence samples, and adding the embedding vectors of each vocabulary in the sentence samples to the corresponding second verification set.
  • the embedding vectors can be combined with the context of words in the sentence A fixed-length vector representation obtained by semantic-to-vocabulary conversion.
  • the neural network may adopt a convolutional neural network (convolutional neural networks, CNN), RNN, LSTM or GRU network, and is not specifically limited.
  • the electronic device may construct a processing sequence for the first sentence, where the processing sequence includes text initializers and multiple target words included in the first sentence.
  • word tokenization Tokenization
  • the word tokenization algorithm can use a conditional random field (CRF) word segmentation algorithm or a word segmentation algorithm based on a hidden Markov model (Hidden Markov Model, referred to as HMM), etc., which is not limited.
  • FIG. 4 is a schematic diagram of a principle of generating first semantic information in an embodiment of the present application.
  • the generated processing sequence may be ⁇ [CLS], X1, [SEP] ⁇ , where [CLS] is a text initializer used to identify the beginning of a sentence.
  • the processing sequence may also include a text end character [SEP], which is used to mark the end of a sentence.
  • the first sentence can be at least two sentences, such as sentence A and sentence B shown in FIG.
  • Sequence X2 ⁇ vocabulary Tok4, vocabulary Tok5, vocabulary Tok6 ⁇ , and then generate a processing sequence ⁇ [CLS], X1, [SEP], X2, [SEP] ⁇ according to the word segmentation sequence X1 and word segmentation sequence X2 to realize the question answering task.
  • the first semantic information of the first sentence is determined according to the eigenvector corresponding to the text initializer, so as to integrate the dependency relationship between words in the first sentence for semantic analysis, which is beneficial to improve the accuracy of semantic analysis.
  • Step S240 Input the first emotional clue feature and the first semantic information into the second prediction model for vocabulary prediction, and obtain a plurality of predicted vocabulary.
  • the electronic device can analyze the part of speech of each predicted vocabulary, and determine the sentence position of the predicted vocabulary according to the part of speech of the predicted vocabulary, so that based on the sentence positions of the predicted vocabulary, multiple predicted words can be formed into a complete reply sentence, wherein, Parts of speech include, but are not limited to, nouns, verbs, pronouns, adjectives, adverbs, numerals, articles, prepositions, conjunctions, and interjections.
  • the generative model can be pre-trained.
  • the generative model can include the first generative model and the second generative model. Both the first generative model and the second generative model can include sequentially connected BERT models and fully connected layers.
  • the first generative model and the second generative model adopt different model parameters and training strategies.
  • a plurality of predicted words are input into the first generative model, and sentence positions of the plurality of predicted words can be predicted by the first generative model, and a sequence of words in which the plurality of predicted words are ordered is obtained.
  • the vocabulary sequence is input into the second generation model, and the context analysis and semantic understanding of the orderly arranged vocabulary sequence can be performed through the second generation model to obtain a complete reply sentence. It can be understood that the prediction process of the second generation model can add information other than the vocabulary sequence or ignore some words in the vocabulary sequence, so as to improve the fluency of the reply sentence.
  • the implementation of the above method embodiment can integrate the emotional changes in the interactive dialogue scene into the dialogue semantics, thereby generating more anthropomorphic dialogue replies with more accurate emotional expression, and further optimizing the interaction effect of human-computer dialogue.
  • Step S500 Obtain current dialog information, wherein the current dialog information includes at least two dialog sentences, and the at least two dialog sentences include the first sentence to be replied.
  • Step S520 Sorting the emotional features of each sentence to obtain the order of the emotional features of the sentence.
  • step S520 may be: the electronic device obtains the utterance sequence of each dialogue sentence. According to the utterance sequence of each dialogue sentence, the emotional features of each sentence are sorted to obtain the order of the emotional features of the sentence. Specifically, the electronic device may determine the speaking sequence of the dialogue statements according to the time stamps recorded for each dialogue statement. For example, the earlier the time indicated by the time stamp is, the earlier the speaking sequence is.
  • step S520 may also be: the electronic device obtains the speaking sequence and speaking object of each dialogue statement, and sorts the emotional characteristics of the statements belonging to the same speaking object according to the speaking sequence of each dialogue statement processing to obtain the sequence of emotional features of sentences under different speaking objects. Based on this, the electronic device can first separately obtain the order of the emotional features of the sentences under the target object, or perform secondary sorting on the emotional features of the sentences under the target object according to the order in which the target object takes precedence over other speaking objects, and then perform the following steps S530 to S580 , so as to flexibly respond to the situation of multiple people cross-talking in actual dialogue situations, maintain the binding relationship between dialogue sentences and speaking objects, and facilitate independent analysis of emotional clues of different objects.
  • the target object may be the speaking object to reply the first sentence, and the speaking object may be determined according to the speaking account corresponding to the dialogue sentence.
  • N is the number of emotional features of the sentence.
  • the first memory unit may be a GRU unit. Still taking Figure 3 as an example for illustration, sort the sentence emotional features of the four dialogue sentences to obtain a vector sequence [s1, s2, s3, s4], and input the first sentence emotional feature s1 in the vector sequence to the first GRU unit, input the second sentence emotional feature s2 into the second GRU unit, and so on, until the fourth sentence emotional feature s4 is input into the fourth GRU unit, and the first emotional clue output by the fourth GRU unit is obtained feature
  • the discrete emotional features are correlated and integrated to obtain continuous emotional clues, which can more accurately analyze the emotional changes of the dialogue.
  • Step S550 Acquire historical hidden vectors.
  • the historical hidden vector is a hidden vector generated after inputting the second emotional clue feature and the second semantic information corresponding to the historical dialogue information into the second prediction model, and the historical dialogue information includes the second sentence to be replied,
  • the second semantic information is obtained by performing semantic analysis on the second sentence.
  • the generation method of the second emotional clue feature may be as follows: the electronic device inputs the historical dialogue information into the first predictive model for emotional analysis, obtains the second emotional feature information, and then inputs the second emotional feature information into the memory model Emotional clue analysis is carried out to obtain the characteristics of the second emotional clue.
  • Step S560 Concatenate the historical hidden vector, the first emotional clue feature and the first semantic information to obtain the target hidden vector.
  • FIG. 6 is a schematic diagram of a principle of generating predicted vocabulary in an embodiment of the present application.
  • the transformation matrix w can also be determined according to the historical hidden vector and the first semantic information, so that the dimension of the transformation matrix w remains the same as the dimension of the historical hidden vector and the first semantic information Consistent, thereby ensuring the accuracy of splicing processing.
  • the transformation matrix w is used to convert the features of the first emotional cue, and the converted emotional cue features are obtained, which are used for subsequent splicing processing.
  • step S560 may specifically include: concatenating the historical hidden vector, the converted emotional clue feature and the first semantic information to obtain the target hidden vector.
  • Step S570 input the target hidden vector into the second prediction model for vocabulary prediction, and obtain multiple predicted vocabulary.
  • the third analysis module 740 is configured to perform semantic analysis on the first sentence to obtain first semantic information of the first sentence.
  • computer storage media includes both volatile and nonvolatile media implemented in any method or technology for storage of information, such as computer readable instructions, data structures, program modules, or other data. permanent, removable and non-removable media.
  • Computer storage media includes, but is not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, digital versatile disk (DVD) or other optical disk storage, magnetic cartridges, tape, magnetic disk storage or other magnetic storage devices, or can Any other medium used to store desired information and which can be accessed by a computer.
  • communication media typically embodies computer readable instructions, data structures, program modules, or other data in a modulated data signal such as a carrier wave or other transport mechanism, and may include any information delivery media .

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Artificial Intelligence (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computational Linguistics (AREA)
  • Data Mining & Analysis (AREA)
  • Health & Medical Sciences (AREA)
  • General Health & Medical Sciences (AREA)
  • Mathematical Physics (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Databases & Information Systems (AREA)
  • Evolutionary Computation (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Evolutionary Biology (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Human Computer Interaction (AREA)
  • Biomedical Technology (AREA)
  • Biophysics (AREA)
  • Molecular Biology (AREA)
  • Computing Systems (AREA)
  • Software Systems (AREA)
  • Machine Translation (AREA)

Abstract

一种语句生成方法及电子设备、存储介质,属于人工智能技术领域。该方法包括:获取当前对话信息,当前对话信息包括至少两个对话语句,至少两个对话语句中包括待回复的第一语句。将当前对话信息输入到第一预测模型中进行情绪分析,得到第一情绪特征信息,并将第一情绪特征信息输入到记忆模型中进行情绪线索分析,得到第一情绪线索特征。对第一语句进行语义分析,得到第一语句的第一语义信息。将第一情绪线索特征和第一语义信息输入到第二预测模型中进行词汇预测,得到多个预测词汇,从而根据多个预测词汇,生成针对第一语句的回复语句。可见,本申请能够在对话语义中融合交互对话场景下的情绪变化,从而生成拟人化、情感表达更加准确的对话回复。

Description

一种语句生成方法及电子设备、存储介质
本申请要求于2021年12月15日提交中国专利局、申请号为202111536049.5,发明名称为“一种语句生成方法及电子设备、存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及人工智能技术领域,具体涉及一种语句生成方法及电子设备、存储介质。
背景技术
现有的大部分对话系统会采用基于Seq2Seq模型的语音生成技术,通过对文本信息进行编码和解码,自动生成对话回复。然而,发明人发现,这种方式是单独识别每个文本信息的情绪类别,再根据情绪类别生成该文本信息的对话回复,故未能合理考虑交互对话过程的情绪变化,使得对话回复的情绪表达不够准确。
技术问题
以下是发明人意识到的现有技术的技术问题:现有的对话回复生成方式是单独识别每个文本信息的情绪类别,再根据情绪类别生成该文本信息的对话回复,故未能合理考虑交互对话过程的情绪变化,使得对话回复的情绪表达不够准确。
技术解决方案
第一方面,本申请实施例提供了一种语句生成方法,包括:获取当前对话信息,所述当前对话信息包括至少两个对话语句,所述至少两个对话语句中包括待回复的第一语句;将所述当前对话信息输入到第一预测模型中进行情绪分析,得到第一情绪特征信息;将所述第一情绪特征信息输入到记忆模型中进行情绪线索分析,得到所述第一情绪线索特征;对所述第一语句进行语义分析,得到所述第一语句的第一语义信息;将所述第一情绪线索特征和所述第一语义信息输入到第二预测模型中进行词汇预测,得到多个预测词汇;根据多个所述预测词汇,生成针对所述第一语句的回复语句。
第二方面,本申请实施例提出了一种语句生成装置,包括:获取模块,用于获取当前对话信息,所述当前对话信息包括至少两个对话语句,所述至少两个对话语句中包括待回复的第一语句;第一分析模块,用于将所述当前对话信息输入到第一预测模型中进行情绪分析,得到第一情绪特征信息;第二分析模块,用于将所述第一情绪特征信息输入到记忆模型中进行情绪线索分析,得到所述第一情绪线索特征;第三分析模块,用于对所述第一语句进行语义分析,得到所述第一语句的第一语义信息;预测模块,用于将所述第一情绪线索特征和所述第一语义信息输入到第二预测模型中进行词汇预测,得到多个预测词汇;生成模块,用于根据多个所述预测词汇,生成针对所述第一语句的回复语句。
第三方面,本申请实施例提出了一种电子设备,所述电子设备包括存储器和处理器,所述存储器上存储有程序,所述程序被所述处理器执行时实现一种语句生成方法,其中,所述语句生成方法包括:获取当前对话信息,所述当前对话信息包括至少两个对话语句,所述至少两个对话语句中包括待回复的第一语句;将所述当前对话信息输入到第一预测模型中进行情绪分析,得到第一情绪特征信息;将所述第一情绪特征信息输入到记忆模型中进行情绪线索分析,得到所述第一情绪线索特征;对所述第一语句进行语义分析,得到所述第一语句的第一语义信息;将所述第一情绪线索特征和所述第一语义信息输入到第二预测模型中进行词汇预测,得到多个预测词汇;根据多个所述预测词汇,生成针对所述第一语句的回复语句。
第四方面,本申请提供了一种存储介质,用于计算机可读存储,所述存储介质存储有一个或者多个程序,所述一个或者多个程序可被一个或者多个处理器执行,以实现一种语句生成方法,其中,所述语句生成方法包括:获取当前对话信息,所述当前对话信息包括至少两个对话语句,所述至少两个对话语句中包括待回复的第一语句;将所述当前对话信息输入到第一预测模型中进行情绪分析,得到第一情绪特征信息;将所述第一情绪特征信息输入到记忆模型中进行情绪线索分析,得到所述第一情绪线索特征;对所述第一语句进行语义分析,得到所述第一语句的第一语义信息;将所述第一情绪线索特征和所述第一语义信息输入到第二预测模型中进行词汇预测,得到多个预测词汇;根据多个所述预测词汇,生成针对所述第一语句的回复语句。
有益效果
本申请提出的语句生成方法及电子设备、存储介质,可以获取当前对话信息,其中,当前对话信息至少两个对话语句,且两个对话语句中包括待回复的第一语句,先将当前对话信息输入到第一预测模型中进行情绪分析,得到第一情绪特征信息,再将第一情绪特征信息输入到记忆模型中进行情绪线索分析,得到第一情绪线索特征,能够反映交互对话过程的情绪变化。基于此,将对第一语句分析得到的第一语义信息以及上述第一情绪线索特征输入到第二预测模型中进行词汇预测,即可得到多个预测词汇,以此生成对第一语句的回复语句。可见,本申请能够在对话语义中融合交互对话场景下的情绪变化,从而生成更加拟人化、情感表达更加准确的对话回复,进一步优化了人机对话交互效果。
附图说明
图1是本申请实施例所应用的一种电子设备的结构框图;
图2是本申请实施例一提供的语句生成方法的流程图;
图3是本申请实施例中一种生成第一情绪特征信息和第一情绪线索特征的原理示意图;
图4是本申请实施例中一种生成第一语义信息的原理示意图;
图5是本申请实施例二提供的语句生成方法的流程图;
图6是本申请实施例中一种生成预测词汇的原理示意图;
图7是本申请实施例所应用的一种语句生成装置的结构框图。
本发明的实施方式
应当理解,此处所描述的具体实施例仅仅用以解释本申请,并不用于限定本申请。
在后续的描述中,使用用于表示元件的诸如“模块”、“部件”或“单元”的后缀仅为了有利于本申请的说明,其本身没有特有的意义。因此,“模块”、“部件”或“单元”可以混合地使用。
本申请提供一种语句生成方法,应用于一种电子设备。参照图1所示,图1是本申请实施例所应用的一种电子设备的结构框图。
在本实施例中,电子设备可以是服务器、智能手机、平板电脑、便携计算机、桌上型计算机等具有运算功能的终端设备。其中,服务器可以是独立的服务器,也可以是提供云服务、云数据库、云计算、云函数、云存储、网络服务、云通信、中间件服务、域名服务、安全服务、内容分发网络(Content Delivery Network,CDN)、以及大数据和人工智能平台等基础云计算服务的云服务器。
该电子设备包括:存储器11、处理器12、网络接口13及数据总线14。
存储器11包括至少一种类型的可读存储介质,至少一种类型的可读存储介质可为如闪存、硬盘、多媒体卡、卡型存储器等的非易失性存储介质。在一些实施例中,可读存储介质可以是电子设备的内部存储单元,例如该电子设备的硬盘。在另一些实施例中,可读存储介质也可以是电子设备的外部存储器,例如电子设备上配备的插接式硬盘,智能存储卡(Smart Media  Card,SMC),安全数字(Secure Digital,SD)卡,闪存卡(Flash Card)等。
在本实施例中,存储器11的可读存储介质通常用于存储安装于电子设备的语句生成程序等。存储器11还可以用于暂时地存储已经输出或者将要输出的数据。
处理器12在一些实施例中可以是一中央处理器(Central Processing Unit,CPU),微处理器或其他数据处理芯片,用于运行存储器11中存储的程序代码或处理数据,例如执行语句生成程序等。
网络接口13可选地可以包括标准的有线接口、无线接口(如WI-FI接口),通常用于在该电子设备与其他电子设备之间建立通信连接。
数据总线14用于实现这些组件之间的连接通信。
图1仅示出了具有组件11-14的电子设备,但是应理解的是,并不要求实施所有示出的组件,可以替代的实施更多或者更少的组件。
下面对本申请实施例公开的一种语句生成方法进行具体说明。
实施例一
如图2所示,图2是本申请实施例一提供的语句生成方法的流程图。基于图1所示的电子设备,处理器12执行存储器11中存储的语句生成程序时实现如下步骤:
步骤S200:获取当前对话信息,其中,当前对话信息包括至少两个对话语句,至少两个对话语句中包括待回复的第一语句。
在本申请实施例中,具体的,电子设备可以通过多种信源获取原始对话数据,并从原始对话数据中提取出至少一条对话内容,再对各个对话内容进行分析,得到至少一个对话语句,以加入当前对话信息。
其中,电子设备获取原始对话数据的方式可以包括但不限于:1、电子设备上安装有具备对话通讯功能的软件或插件(比如客服机器人、外呼机器人、语音助手和其他第三方社交通讯软件等),则电子设备可以通过上述软件(或插件)前端获取用户手动或语音输入的对话数据,以及接收其他终端发送的对话数据。2、电子设备响应于语句生成指令,并直接获取语句生成指令对应的信息内容,以作为原始对话数据。语句生成指令的触发方式可包括但不限于文本操作或图片操作,比如,当用户在电子设备的操作界面中选中某一段文本,电子设备弹出功能选项框,若功能选项框中的语句生成项(比如上述软件或插件的图标)被选中,则电子设备生成语句生成指令,并将选中的文本确定为语句生成指令对应的信息内容。因此,语句生成指令的触发场景可以更加多样化,使得对话数据的数据源不限于指定软件的前端交互。3、电子设备获取用户输入的对话记录文件,并从对话记录文件中解析出原始对话数据。其中,对话记录文件可以是从第三方社交通讯软件导出的文件,用于以指定格式(比如文本格式或数据库文件等)记录对话信息。
其中,原始对话数据可以记录有标识信息,标识信息可包括但不限于发言账户、分隔符和时间戳等,则电子设备可以按照标识信息的指示,从原始对话数据中提取对话内容。比如,按照不同时间戳,提取各个时间戳对应的对话内容;或者,按照分隔符对原始对话数据进行划分处理后得到至少一条对话内容。
可选的,电子设备对对话内容进行分析时:
若对话内容为文本内容,则对文本内容进行语句分割,得到对话语句。
若对话内容为图像,可以直接根据图像的标签或文件命名生成对话语句,比如,图像命名为“目瞪口呆.jpg”,则确定对话语句为“目瞪口呆”。或者,利用图像识别技术对图像进行特征分析(比如物体、背景、文字、构成、颜色特征、面部表情等特征分析),根据图像分析结果确定图像相关的文本信息,以作为对话语句。再或者,采用图片搜索技术对图像进行搜索(比如以图搜图),得到关联图像,再通过获取关联图像相关的描述信息,确定对话语句。
若对话内容为语音内容,则利用自动语音识别技术(automatic speech recognition,ASR)对语音内容进行文字转换,得到对话语句。
可以理解,本申请可以适用于实时或非实时的交互对话场景,交互对话可以是用户与电子设备之间的智能对话,比如,电子设备通过具备对话通讯功能的软件前端与用户进行对话交互。或者,交互对话也可以是多个用户之间的场景对话,比如,当电子设备的当前用户利用社交软件与其他终端的用户进行对话时,电子设备可以通过调用社交软件上的插件,为当前用户自动生成对话回复。
步骤S210:将当前对话信息输入到第一预测模型中进行情绪分析,得到第一情绪特征信息。
在本申请实施例中,第一情绪特征信息可以包括各个对话语句的语句情绪特征。第一预测模型可以采用神经网络模型(比如卷积神经网络模型和循环神经网络模型等)、贝叶斯模型或注意力模型等,对此不做限定。
一种可选的实施方式中,第一预测模型包括双向神经网络、全连接层和第一分类层,第一分类层可以采用softmax函数,双向神经网络可以采用双向循环神经网络(recurrent neural network,RNN)、双向门循环单元(gate recurrent unit,GRU)或双向长短期记忆网络(long short term memory,LSTM)等,对此不作具体限定。则,步骤S210具体可以为:针对各个对话语句,对对话语句进行分词处理,得到对话语句对应的多个目标词汇。其中,分词处理方式可包括但不限于:利用分词工具,比如hanlp和百度NLP等;采用基于词典的分词方法,比如正向最大匹配法和最短路径法等;采用基于统计的分词方法,比如隐马尔科夫模型和N-gram等。之后,将多个目标词汇输入到第一预测模型中。通过双向神经网络生成各个目标词汇对应的第一向量和第二向量,并通过全连接层和分类层对各个目标词汇对应的第一向量和第二向量进行特征分类处理,得到对话语句的语句情绪特征。可见,采用双向神经网络,能够深度挖掘对话语句中的时序信息以及语义信息,有利于提升情感分类的准确性。
具体的,请参阅图3,图3是本申请实施例中一种生成第一情绪特征信息和第一情绪线索特征的原理示意图。如3所示,双向神经网络采用了多个双向连接的GRU单元。将4个目标词汇w1、w2、w3和w4分别输入不同的GRU单元,得到每个GRU单元输出的表达向量,分别为[第一向量
Figure PCTCN2022090744-appb-000001
第二向量
Figure PCTCN2022090744-appb-000002
]、[第三向量
Figure PCTCN2022090744-appb-000003
第四向量
Figure PCTCN2022090744-appb-000004
]、[第五向量
Figure PCTCN2022090744-appb-000005
第六向量
Figure PCTCN2022090744-appb-000006
]和[第七向量
Figure PCTCN2022090744-appb-000007
第八向量
Figure PCTCN2022090744-appb-000008
]。之后,将每个GRU单元的表达向量依次通过全连接层和分类层,从而将各个表达向量映射到不同的情感类别中,得到对话语句属于不同情感类别的权重向量,从而将上述权重向量确定为语句情绪特征。其中,权重向量是对话语句属于不同情感类别的概率值的向量表示,情感类别包括但不限于喜、怒、忧、思、悲、恐和惊。可以理解的是,图3仅为一种示例,对双向神经网络包含的GRU单元数量不构成具体限定。
更具体的,第一预测模型的训练方式可以为:准备包括一定数量的对话样本数据的第一训练集,并将为对话样本数据标注的多个情感类别及其向量表示作为第一验证集,利用第一训练集训练第一预测模型,以及利用第一验证集验证第一预测模型的输出,若验证输出的准确率大于或等于预设准确率,则训练结束,若准确率小于预设准确率,则继续增加样本数量并重新执行训练步骤。
步骤S220:将第一情绪特征信息输入到记忆模型中进行情绪线索分析,得到第一情绪线索特征。
在本申请实施例中,记忆模型可以采用预先训练好的GRU模型或LTSM模型等,对此不做具体限定。
步骤S230:对第一语句进行语义分析,得到第一语句的第一语义信息。
在本申请实施例中,具体的,电子设备可以将第一语句输入预先确定的语义分析模型中,得到第一语义信息。语义分析模型可以采用BERT模型,对此不做具体限定。语义分析模型的训练步骤包括:准备包括一定数量的语句样本的第二训练集,并将语句样本中各个词汇的嵌入向量加入相应的第二验证集,嵌入向量可以是结合词汇在语句中的上下文语义对词汇转换得到的固定长度的向量表示。利用第二训练集训练神经网络,得到神经网络对各个词汇输出的特征向量,利用第二验证集验证相应词汇的特征向量的准确率,若准确率大于或等于预设 准确率,则训练结束,若准确率小于预设准确率,则继续增加样本数量并重新执行训练步骤。其中,神经网络可以采用卷积神经网络(convolutional neural networks,CNN)、RNN、LSTM或者GRU网络,亦不做具体限定。
一种可选的实施方式中,步骤S230具体可以为:
首先,电子设备可以先对第一语句构建处理序列,处理序列包括文本初始符和第一语句中包括的多个目标词汇。具体的,可以先对第一语句进行字词标记化(Tokenization)处理,得到多个目标词汇,再结合文本初始符,与多个目标词汇构成处理序列。其中,字词标记化处理的算法可以采用条件随机场(conditional random field,CRF)分词算法或者基于隐马尔可夫模型(Hidden Markov Model,简称HMM)的分词算法等,对此不做限定。
以图4为例进行说明,图4是本申请实施例中一种生成第一语义信息的原理示意图。一种实现方式中,第一语句可以包括一个句子A,则对句子A进行字词标记化处理后,得到分词序列X1={词汇Tok1,词汇Tok2,词汇Tok3},说明句子A包括3个目标词汇。基于此,生成的处理序列可为{[CLS],X1,[SEP]},[CLS]为文本初始符,用于标识一个句子的开头。相应的,处理序列还可以包括文本结尾符[SEP],用于标识一个句子的结尾。另一种实现方式中,第一语句可以是至少两个语句,比如图4所示的句子A和句子B,则分别对句子A和句子B进行字词标记化处理,得到分词序列X1以及分词序列X2={词汇Tok4,词汇Tok5,词汇Tok6},再根据分词序列X1和分词序列X2生成处理序列{[CLS],X1,[SEP],X2,[SEP]},实现问答任务。
之后,电子设备再将处理序列输入到语义分析模型中进行语义分析,得到语义分析模型输出的多个目标特征向量,多个目标特征向量中包括文本初始符对应的特征向量。如图4所示,语义分析模型的输出为
Figure PCTCN2022090744-appb-000009
其中,h 0为文本初始符[CLS]对应的特征向量,
Figure PCTCN2022090744-appb-000010
Figure PCTCN2022090744-appb-000011
分别为句子A和句子B的目标特征向量(也即单词嵌入矩阵)。
最后,根据文本初始符对应的特征向量,确定第一语句的第一语义信息,从而融合第一语句中词汇之间的依存关系进行语义分析,有利于提升语义分析的准确度。
步骤S240:将第一情绪线索特征和第一语义信息输入到第二预测模型中进行词汇预测,得到多个预测词汇。
在本申请实施例中,第二预测模型可以是预先训练得到,且第二预测模型可以采用神经网络模型(比如卷积神经网络模型和循环神经网络模型等)、贝叶斯模型或注意力模型等,对此不做限定。
步骤S250:根据多个预测词汇,生成针对第一语句的回复语句。
一种实现方式中,电子设备可以分析各个预测词汇的词性,并根据预测词汇的词性确定预测词汇的语句位置,从而基于预测词汇的语句位置,将多个预测词汇构成完整的回复语句,其中,词性包括但不限于名词、动词、代词、形容词、副词、数词、冠词、介词、连词和感叹词等。另一种实现方式中,可以预先训练生成式模型,生成式模型可以包括第一生成模型和第二生成模型,第一生成模型和第二生成模型均可以包括依次连接的BERT模型、全连接层和分类层,但第一生成模型和第二生成模型采用不同的模型参数和训练策略。将多个预测词汇输入第一生成模型中,可以通过第一生成模型预测多个预测词汇的语句位置,得到对多个预测词汇进行有序排列后的词汇序列。基于此,将词汇序列输入到第二生成模型中,可以通过第二生成模型对有序排列后的词汇序列进行上下文分析及语义理解,得到完整的回复语句。可以理解,第二生成模型的预测过程可以新增词汇序列之外的信息或忽略词汇序列中的部分词汇,以提升回复语句的流畅性。
可见,实施上述方法实施例,能够在对话语义中融合交互对话场景下的情绪变化,从而生成更加拟人化、情感表达更加准确的对话回复,进一步优化了人机对话交互效果。
实施例二
如图5所示,图5是本申请实施例二提供的语句生成方法的流程图。基于图1所示的电子设备,处理器12执行存储器11中存储的语句生成程序时实现如下步骤:
步骤S500:获取当前对话信息,其中,当前对话信息包括至少两个对话语句,至少两个对话语句中包括待回复的第一语句。
步骤S510:将当前对话信息输入到第一预测模型中进行情绪分析,得到各个对话语句的语句情绪特征。
步骤S520:对各个语句情绪特征进行排序处理,得到语句情绪特征的次序。
一种可选的实施方式中,步骤S520可以为:电子设备获取各个对话语句的发言时序。根据各个对话语句的发言时序,对各个语句情绪特征进行排序处理,得到语句情绪特征的次序。具体的,电子设备可以根据对各个对话语句记录的时间戳,确定对话语句的发言时序。比如,时间戳所指示的时刻越早,则发言时序亦越靠前。
另一种可选的实施方式中,步骤S520也可以为:电子设备获取各个对话语句的发言时序以及发言对象,并根据各个对话语句的发言时序,将属于同一个发言对象的语句情绪特征进行排序处理,得到不同发言对象下语句情绪特征的次序。基于此,电子设备可以先单独取目标对象下语句情绪特征的次序,或者按照目标对象优先于其他发言对象的顺序对所有发言对象下语句情绪特征进行二次排序,再执行下述步骤S530至S580,从而灵活应对实际对话场合中多人交叉发言的情况,保持对话语句与发言对象的绑定关系,便于独立分析不同对象的情感线索。其中,目标对象可以是待回复第一语句的发言对象,而发言对象可根据对话语句对应的发言账户所确定。
步骤S530:根据语句情绪特征的次序,将各个语句情绪特征分别输入到记忆模型中依次连接的N个第一记忆单元,并通过N个第一记忆单元进行情绪线索分析,得到N个第一记忆单元中第N个第一记忆单元输出的第一情绪线索特征。
在本申请实施例中,N为语句情绪特征的数量。具体来说,第一记忆单元可以是GRU单元。仍以图3为例进行说明,将4个对话语句的语句情绪特征进行排序后得到向量序列[s1,s2,s3,s4],将向量序列中第一个语句情绪特征s1输入第一个GRU单元,将第二个语句情绪特征s2输入第二个GRU单元,以此类推,直至将第4个语句情绪特征s4输入到第4个GRU单元,得到第4个GRU单元输出的第一情绪线索特征
Figure PCTCN2022090744-appb-000012
从而将离散的情感特征进行关联及整合,获得连续的情感线索,能够更加准确地分析对话的情绪变化。
步骤S540:对第一语句进行语义分析,得到第一语句的第一语义信息。
步骤S550:获取历史隐藏向量。
在本申请实施例中,历史隐藏向量是将历史对话信息对应的第二情绪线索特征和第二语义信息输入第二预测模型后生成的隐藏向量,历史对话信息中包括待回复的第二语句,第二语义信息是通过对第二语句进行语义分析后获得。具体的,第二情绪线索特征的生成方式可以为:电子设备将历史对话信息输入到第一预测模型中进行情绪分析,得到第二情绪特征信息,再将第二情绪特征信息输入到记忆模型中进行情绪线索分析,得到第二情绪线索特征。
步骤S560:将历史隐藏向量、第一情绪线索特征和第一语义信息进行拼接,得到目标隐藏向量。
可见,通过融合历史隐藏向量,在实时对话生成的过程中同时引入历史对话的语义信息和情感线索,进一步提升了生成回复语句的逻辑及情感连贯性。
一种可选的实施方式中,请参阅图6,图6是本申请实施例中一种生成预测词汇的原理示意图。如图6所示,步骤S550之后,以及步骤S560之前,还可以根据历史隐藏向量和第一语义信息,确定变换矩阵w,使得变换矩阵w的维度与历史隐藏向量和第一语义信息的维度保持一致,从而保证拼接处理的准确性。之后,利用变换矩阵w对第一情绪线索特征进行转换,得到转换后的情绪线索特征,用于后续的拼接处理。相应的,步骤S560具体还可以为:将历史隐藏向量、转换后的情绪线索特征和第一语义信息进行拼接,得到目标隐藏向量。
步骤S570:将目标隐藏向量输入到第二预测模型中进行词汇预测,得到多个预测词汇。
一种可选的实施方式中,第二预测模型包括多个依次连接的第二记忆单元和多个第二分类层,第二记忆单元与第二分类层一一对应,依次连接的两个第二记忆单元中,后一第二记 忆单元的输入包括前一第二记忆单元输出的预测向量和隐藏向量。则,步骤S570具体可以为:
将目标隐藏向量输入到第二预测模型中。通过各个第二记忆单元依次进行词汇预测,得到各个第二记忆单元输出的预测向量,再通过第二记忆单元对应的第二分类层对预测向量进行词汇分类,得到多个词汇的预测概率,并取预测概率最大的词汇作为预测词汇。以图6为例,三个第二记忆单元与三个第二分类层一一对应,则三个第二分类层依次输出预测词汇y1、y2和y3。
具体的,第二记忆单元可以采用GRU单元,第二分类层可采用softmax函数。可见,经过第二记忆单元的依次传递、各个第二分类层的特征分类及筛选,最终分别输出的预测词汇之间具备关联性,故能够构建更为准确及流畅的回复语句,还能够融合对话语句的语义特征、整个对话流程的情绪线索特征以及历史对话信息,从而进一步改善答复语句与整个对话场景及情绪变化的匹配性,实现更为拟人化的对话效果。
步骤S580:根据多个预测词汇,生成针对第一语句的回复语句。
可以理解的是,本实施例中步骤S500-S580的具体实现方式还可以参照上述实施例一中对步骤S200-S250的描述,在此不再赘述。
一些可选的实施方式中,电子设备还可以获取目标对象的用户习惯数据,并根据用户习惯数据、第一情绪线索特征和多个预测词汇,生成针对第一语句的回复语句,或者生成回复语句和附加信息,使得回复内容更加贴合目标对象的情绪以及对话习惯。具体的,用户习惯数据可包括但不限于语气词、标点符号、图片、表情包和表情符号等。电子设备可以将用户习惯数据、第一情绪线索特征和多个预测词汇输入预先训练好的生成式模型,得到回复语句。或者,电子设备也可以对第一情绪线索特征进行解码(比如one-hot解码),得到情绪标签,并根据多个预测词汇和情绪标签进行关键词匹配,得到关键词,再从用户习惯数据中获取关键词对应的习惯数据,从而根据关键词对应的习惯数据和多个预测词汇生成回复语句(或者回复语句和附加信息)。
比如,若预测词汇包括“我们”、“去”和“吃饭”,情绪标签为“开心”,则可以从习惯数据中获取被标注为“开心”时使用的标点符号“波浪号”、语气词“吧”以及表情包“吃饭.jpg”,以作为相应的习惯数据,进而结合预测词汇生成回复语句“我们去吃饭吧~”,同时生成附加信息:表情包“吃饭.jpg”。
可见,实施上述方法实施例,能够融合对话语句的语义特征、整个对话流程的情绪线索特征以及历史对话信息,从而进一步改善答复语句与整个对话场景及情绪变化的匹配性,并生成更加拟人化、情感表达更加准确的对话回复,进一步优化了人机对话交互效果。
本申请实施例还提供一种语句生成装置。请参阅图7,图7是本申请实施例所应用的一种语句生成装置的结构框图。如图7所示,该语句生成装置700包括:
获取模块710,用于获取当前对话信息,当前对话信息包括至少两个对话语句,至少两个对话语句中包括待回复的第一语句。
第一分析模块720,用于将当前对话信息输入到第一预测模型中进行情绪分析,得到第一情绪特征信息。
第二分析模块730,用于将第一情绪特征信息输入到记忆模型中进行情绪线索分析,得到第一情绪线索特征。
第三分析模块740,用于对第一语句进行语义分析,得到第一语句的第一语义信息。
预测模块750,用于将第一情绪线索特征和第一语义信息输入到第二预测模型中进行词汇预测,得到多个预测词汇。
生成模块760,用于根据多个预测词汇,生成针对第一语句的回复语句。
需要说明的是,本实施例的具体实现过程可参见上述方法实施例所描述的具体实现过程,亦不再赘述。
本申请实施例还提供了一种电子设备,电子设备包括:存储器、处理器、存储在存储器上并可在处理器上运行的程序以及用于实现处理器和存储器之间的连接通信的数据总线,程 序被处理器执行时实现一种语句生成方法,其中,该语句生成方法包括:获取当前对话信息,当前对话信息包括至少两个对话语句,至少两个对话语句中包括待回复的第一语句;将当前对话信息输入到第一预测模型中进行情绪分析,得到第一情绪特征信息;将第一情绪特征信息输入到记忆模型中进行情绪线索分析,得到第一情绪线索特征;对第一语句进行语义分析,得到第一语句的第一语义信息;将第一情绪线索特征和第一语义信息输入到第二预测模型中进行词汇预测,得到多个预测词汇;根据多个预测词汇,生成针对第一语句的回复语句。
本申请实施例还提供了一种存储介质,存储介质为计算机可读存储介质,用于计算机可读存储,存储介质存储有一个或者多个程序,一个或者多个程序可被一个或者多个处理器执行,以实现一种语句生成方法,其中,该语句生成方法包括:获取当前对话信息,当前对话信息包括至少两个对话语句,至少两个对话语句中包括待回复的第一语句;将当前对话信息输入到第一预测模型中进行情绪分析,得到第一情绪特征信息;将第一情绪特征信息输入到记忆模型中进行情绪线索分析,得到第一情绪线索特征;对第一语句进行语义分析,得到第一语句的第一语义信息;将第一情绪线索特征和第一语义信息输入到第二预测模型中进行词汇预测,得到多个预测词汇;根据多个预测词汇,生成针对第一语句的回复语句。该计算机可读存储介质可以是非易失性,也可以是易失性。
本领域普通技术人员可以理解,上文中所公开方法中的全部或某些步骤、系统、设备中的功能模块/单元可以被实施为软件、固件、硬件及其适当的组合。
在硬件实施方式中,在以上描述中提及的功能模块/单元之间的划分不一定对应于物理组件的划分;例如,一个物理组件可以具有多个功能,或者一个功能或步骤可以由若干物理组件合作执行。某些物理组件或所有物理组件可以被实施为由处理器,如中央处理器、数字信号处理器或微处理器执行的软件,或者被实施为硬件,或者被实施为集成电路,如专用集成电路。这样的软件可以分布在计算机可读介质上,计算机可读介质可以包括计算机存储介质(或非暂时性介质)和通信介质(或暂时性介质)。如本领域普通技术人员公知的,术语计算机存储介质包括在用于存储信息(诸如计算机可读指令、数据结构、程序模块或其他数据)的任何方法或技术中实施的易失性和非易失性、可移除和不可移除介质。计算机存储介质包括但不限于RAM、ROM、EEPROM、闪存或其他存储器技术、CD-ROM、数字多功能盘(DVD)或其他光盘存储、磁盒、磁带、磁盘存储或其他磁存储装置、或者可以用于存储期望的信息并且可以被计算机访问的任何其他的介质。此外,本领域普通技术人员公知的是,通信介质通常包含计算机可读指令、数据结构、程序模块或者诸如载波或其他传输机制之类的调制数据信号中的其他数据,并且可包括任何信息递送介质。
以上参照附图说明了本申请的优选实施例,并非因此局限本申请的权利范围。本领域技术人员不脱离本申请的范围和实质内所作的任何修改、等同替换和改进,均应在本申请的权利范围之内。

Claims (20)

  1. 一种语句生成方法,其中,所述方法包括:
    获取当前对话信息,所述当前对话信息包括至少两个对话语句,所述至少两个对话语句中包括待回复的第一语句;
    将所述当前对话信息输入到第一预测模型中进行情绪分析,得到第一情绪特征信息;
    将所述第一情绪特征信息输入到记忆模型中进行情绪线索分析,得到所述第一情绪线索特征;
    对所述第一语句进行语义分析,得到所述第一语句的第一语义信息;
    将所述第一情绪线索特征和所述第一语义信息输入到第二预测模型中进行词汇预测,得到多个预测词汇;
    根据多个所述预测词汇,生成针对所述第一语句的回复语句。
  2. 根据权利要求1所述的方法,其中,所述第一情绪特征信息包括各个所述对话语句的语句情绪特征;所述第一预测模型包括双向神经网络、全连接层和第一分类层,所述将所述当前对话信息输入到第一预测模型中进行情绪分析,得到第一情绪特征信息,包括:
    对所述对话语句进行分词处理,得到所述对话语句对应的多个目标词汇;
    将所述多个目标词汇输入到第一预测模型中;
    通过所述双向神经网络生成各个所述目标词汇对应的第一向量和第二向量;
    通过所述全连接层和所述第一分类层对各个所述目标词汇对应的第一向量和第二向量进行特征分类处理,得到所述对话语句的语句情绪特征。
  3. 根据权利要求1所述的方法,其中,所述第一情绪特征信息包括各个所述对话语句的语句情绪特征;所述将所述第一情绪特征信息输入到记忆模型中进行情绪线索分析,得到所述第一情绪线索特征,包括:
    对各个所述对话语句的语句情绪特征进行排序处理,得到所述语句情绪特征的次序;
    根据所述语句情绪特征的次序,将各个所述语句情绪特征分别输入到所述记忆模型中依次连接的N个第一记忆单元,并通过所述N个第一记忆单元进行情绪线索分析,得到所述N个第一记忆单元中第N个第一记忆单元输出的第一情绪线索特征,其中,N为所述语句情绪特征的数量。
  4. 根据权利要求3所述的方法,其中,所述对各个所述对话语句的语句情绪特征进行排序处理,得到所述语句情绪特征的次序,包括:
    获取各个所述对话语句的发言时序;
    根据各个所述对话语句的发言时序,对各个所述语句情绪特征进行排序处理,得到所述语句情绪特征的次序。
  5. 根据权利要求1至4任一项所述的方法,其中,所述对所述第一语句进行语义分析,得到所述第一语句的第一语义信息,包括:
    对所述第一语句构建处理序列,所述处理序列包括文本初始符和所述第一语句中包括的多个目标词汇;
    将所述处理序列输入到语义分析模型中进行语义分析,得到所述语义分析模型输出的多个目标特征向量,所述多个目标特征向量中包括所述文本初始符对应的特征向量;
    根据所述文本初始符对应的特征向量,确定所述第一语句的第一语义信息。
  6. 根据权利要求1至4任一项所述的方法,其中,所述将所述第一情绪线索特征和所述第一语义信息输入到第二预测模型中进行词汇预测,得到多个预测词汇,包括:
    获取历史隐藏向量,其中,所述历史隐藏向量是将历史对话信息对应的第二情绪线索特征和第二语义信息输入第二预测模型后生成的隐藏向量,所述历史对话信息中包括待回复的第二语句,所述第二语义信息是通过对所述第二语句进行语义分析后获得;
    将所述历史隐藏向量、所述第一情绪线索特征和所述第一语义信息进行拼接,得到目标 隐藏向量;
    将所述目标隐藏向量输入到所述第二预测模型中进行词汇预测,得到多个预测词汇。
  7. 根据权利要求6所述的方法,其中,所述第二预测模型包括多个依次连接的第二记忆单元和多个第二分类层,所述第二记忆单元与所述第二分类层一一对应;所述将所述目标隐藏向量输入到所述第二预测模型中进行词汇预测,得到多个预测词汇,包括:
    将所述目标隐藏向量输入到所述第二预测模型中;
    通过各个所述第二记忆单元依次进行词汇预测,得到所述第二记忆单元输出的预测向量,再通过所述第二记忆单元对应的第二分类层对所述预测向量进行词汇分类,得到多个词汇的预测概率,并取预测概率最大的词汇作为预测词汇。
  8. 一种语句生成装置,其中,所述装置包括:
    获取模块,用于获取当前对话信息,所述当前对话信息包括至少两个对话语句,所述至少两个对话语句中包括待回复的第一语句;
    第一分析模块,用于将所述当前对话信息输入到第一预测模型中进行情绪分析,得到第一情绪特征信息;
    第二分析模块,用于将所述第一情绪特征信息输入到记忆模型中进行情绪线索分析,得到所述第一情绪线索特征;
    第三分析模块,用于对所述第一语句进行语义分析,得到所述第一语句的第一语义信息;
    预测模块,用于将所述第一情绪线索特征和所述第一语义信息输入到第二预测模型中进行词汇预测,得到多个预测词汇;
    生成模块,用于根据多个所述预测词汇,生成针对所述第一语句的回复语句。
  9. 一种电子设备,所述电子设备包括存储器和处理器,所述存储器上存储有程序,其中,所述程序被所述处理器执行时实现一种语句生成方法,所述方法包括:
    获取当前对话信息,所述当前对话信息包括至少两个对话语句,所述至少两个对话语句中包括待回复的第一语句;
    将所述当前对话信息输入到第一预测模型中进行情绪分析,得到第一情绪特征信息;
    将所述第一情绪特征信息输入到记忆模型中进行情绪线索分析,得到所述第一情绪线索特征;
    对所述第一语句进行语义分析,得到所述第一语句的第一语义信息;
    将所述第一情绪线索特征和所述第一语义信息输入到第二预测模型中进行词汇预测,得到多个预测词汇;
    根据多个所述预测词汇,生成针对所述第一语句的回复语句。
  10. 根据权利要求9所述的电子设备,其中,所述第一情绪特征信息包括各个所述对话语句的语句情绪特征;所述第一预测模型包括双向神经网络、全连接层和第一分类层,所述将所述当前对话信息输入到第一预测模型中进行情绪分析,得到第一情绪特征信息,包括:
    对所述对话语句进行分词处理,得到所述对话语句对应的多个目标词汇;
    将所述多个目标词汇输入到第一预测模型中;
    通过所述双向神经网络生成各个所述目标词汇对应的第一向量和第二向量;
    通过所述全连接层和所述第一分类层对各个所述目标词汇对应的第一向量和第二向量进行特征分类处理,得到所述对话语句的语句情绪特征。
  11. 根据权利要求9所述的电子设备,其中,所述第一情绪特征信息包括各个所述对话语句的语句情绪特征;所述将所述第一情绪特征信息输入到记忆模型中进行情绪线索分析,得到所述第一情绪线索特征,包括:
    对各个所述对话语句的语句情绪特征进行排序处理,得到所述语句情绪特征的次序;
    根据所述语句情绪特征的次序,将各个所述语句情绪特征分别输入到所述记忆模型中依次连接的N个第一记忆单元,并通过所述N个第一记忆单元进行情绪线索分析,得到所述N个第一记忆单元中第N个第一记忆单元输出的第一情绪线索特征,其中,N为所述语句情绪 特征的数量。
  12. 根据权利要求11所述的电子设备,其中,所述对各个所述对话语句的语句情绪特征进行排序处理,得到所述语句情绪特征的次序,包括:
    获取各个所述对话语句的发言时序;
    根据各个所述对话语句的发言时序,对各个所述语句情绪特征进行排序处理,得到所述语句情绪特征的次序。
  13. 根据权利要求9至12任一项所述的电子设备,其中,所述对所述第一语句进行语义分析,得到所述第一语句的第一语义信息,包括:
    对所述第一语句构建处理序列,所述处理序列包括文本初始符和所述第一语句中包括的多个目标词汇;
    将所述处理序列输入到语义分析模型中进行语义分析,得到所述语义分析模型输出的多个目标特征向量,所述多个目标特征向量中包括所述文本初始符对应的特征向量;
    根据所述文本初始符对应的特征向量,确定所述第一语句的第一语义信息。
  14. 根据权利要求9至12任一项所述的电子设备,其中,所述将所述第一情绪线索特征和所述第一语义信息输入到第二预测模型中进行词汇预测,得到多个预测词汇,包括:
    获取历史隐藏向量,其中,所述历史隐藏向量是将历史对话信息对应的第二情绪线索特征和第二语义信息输入第二预测模型后生成的隐藏向量,所述历史对话信息中包括待回复的第二语句,所述第二语义信息是通过对所述第二语句进行语义分析后获得;
    将所述历史隐藏向量、所述第一情绪线索特征和所述第一语义信息进行拼接,得到目标隐藏向量;
    将所述目标隐藏向量输入到所述第二预测模型中进行词汇预测,得到多个预测词汇。
  15. 一种存储介质,用于计算机可读存储,其中,所述存储介质存储有一个或者多个程序,所述一个或者多个程序可被一个或者多个处理器执行,以实现一种语句生成方法,所述方法包括:
    获取当前对话信息,所述当前对话信息包括至少两个对话语句,所述至少两个对话语句中包括待回复的第一语句;
    将所述当前对话信息输入到第一预测模型中进行情绪分析,得到第一情绪特征信息;
    将所述第一情绪特征信息输入到记忆模型中进行情绪线索分析,得到所述第一情绪线索特征;
    对所述第一语句进行语义分析,得到所述第一语句的第一语义信息;
    将所述第一情绪线索特征和所述第一语义信息输入到第二预测模型中进行词汇预测,得到多个预测词汇;
    根据多个所述预测词汇,生成针对所述第一语句的回复语句。
  16. 根据权利要求15所述的存储介质,其中,所述第一情绪特征信息包括各个所述对话语句的语句情绪特征;所述第一预测模型包括双向神经网络、全连接层和第一分类层,所述将所述当前对话信息输入到第一预测模型中进行情绪分析,得到第一情绪特征信息,包括:
    对所述对话语句进行分词处理,得到所述对话语句对应的多个目标词汇;
    将所述多个目标词汇输入到第一预测模型中;
    通过所述双向神经网络生成各个所述目标词汇对应的第一向量和第二向量;
    通过所述全连接层和所述第一分类层对各个所述目标词汇对应的第一向量和第二向量进行特征分类处理,得到所述对话语句的语句情绪特征。
  17. 根据权利要求15所述的存储介质,其中,所述第一情绪特征信息包括各个所述对话语句的语句情绪特征;所述将所述第一情绪特征信息输入到记忆模型中进行情绪线索分析,得到所述第一情绪线索特征,包括:
    对各个所述对话语句的语句情绪特征进行排序处理,得到所述语句情绪特征的次序;
    根据所述语句情绪特征的次序,将各个所述语句情绪特征分别输入到所述记忆模型中依 次连接的N个第一记忆单元,并通过所述N个第一记忆单元进行情绪线索分析,得到所述N个第一记忆单元中第N个第一记忆单元输出的第一情绪线索特征,其中,N为所述语句情绪特征的数量。
  18. 根据权利要求17所述的存储介质,其中,所述对各个所述对话语句的语句情绪特征进行排序处理,得到所述语句情绪特征的次序,包括:
    获取各个所述对话语句的发言时序;
    根据各个所述对话语句的发言时序,对各个所述语句情绪特征进行排序处理,得到所述语句情绪特征的次序。
  19. 根据权利要求15至18任一项所述的存储介质,其中,所述对所述第一语句进行语义分析,得到所述第一语句的第一语义信息,包括:
    对所述第一语句构建处理序列,所述处理序列包括文本初始符和所述第一语句中包括的多个目标词汇;
    将所述处理序列输入到语义分析模型中进行语义分析,得到所述语义分析模型输出的多个目标特征向量,所述多个目标特征向量中包括所述文本初始符对应的特征向量;
    根据所述文本初始符对应的特征向量,确定所述第一语句的第一语义信息。
  20. 根据权利要求15至18任一项所述的存储介质,其中,所述将所述第一情绪线索特征和所述第一语义信息输入到第二预测模型中进行词汇预测,得到多个预测词汇,包括:
    获取历史隐藏向量,其中,所述历史隐藏向量是将历史对话信息对应的第二情绪线索特征和第二语义信息输入第二预测模型后生成的隐藏向量,所述历史对话信息中包括待回复的第二语句,所述第二语义信息是通过对所述第二语句进行语义分析后获得;
    将所述历史隐藏向量、所述第一情绪线索特征和所述第一语义信息进行拼接,得到目标隐藏向量;
    将所述目标隐藏向量输入到所述第二预测模型中进行词汇预测,得到多个预测词汇。
PCT/CN2022/090744 2021-12-15 2022-04-29 一种语句生成方法及电子设备、存储介质 WO2023108994A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202111536049.5 2021-12-15
CN202111536049.5A CN114239547A (zh) 2021-12-15 2021-12-15 一种语句生成方法及电子设备、存储介质

Publications (1)

Publication Number Publication Date
WO2023108994A1 true WO2023108994A1 (zh) 2023-06-22

Family

ID=80756534

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/090744 WO2023108994A1 (zh) 2021-12-15 2022-04-29 一种语句生成方法及电子设备、存储介质

Country Status (2)

Country Link
CN (1) CN114239547A (zh)
WO (1) WO2023108994A1 (zh)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116578731A (zh) * 2023-07-05 2023-08-11 之江实验室 多媒体信息处理方法、系统、计算机设备和存储介质
CN117131182A (zh) * 2023-10-26 2023-11-28 江西拓世智能科技股份有限公司 一种基于ai的对话回复生成方法及系统
CN117808923A (zh) * 2024-02-29 2024-04-02 浪潮电子信息产业股份有限公司 一种图像生成方法、系统、电子设备及可读存储介质
CN118035431A (zh) * 2024-04-12 2024-05-14 青岛网信信息科技有限公司 一种文字客服过程用户情绪预测方法、介质及系统

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114239547A (zh) * 2021-12-15 2022-03-25 平安科技(深圳)有限公司 一种语句生成方法及电子设备、存储介质
CN118014072A (zh) * 2024-04-10 2024-05-10 中国电建集团昆明勘测设计研究院有限公司 水利水电工程用知识图谱的构建方法及系统

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108536681A (zh) * 2018-04-16 2018-09-14 腾讯科技(深圳)有限公司 基于情感分析的智能问答方法、装置、设备及存储介质
CN110990543A (zh) * 2019-10-18 2020-04-10 平安科技(深圳)有限公司 智能对话的生成方法、装置、计算机设备及计算机存储介质
CN111428015A (zh) * 2020-03-20 2020-07-17 腾讯科技(深圳)有限公司 一种信息生成方法、装置、设备及存储介质
CN112214585A (zh) * 2020-09-10 2021-01-12 中国科学院深圳先进技术研究院 回复消息生成方法、系统、计算机设备及存储介质
WO2021132797A1 (ko) * 2019-12-27 2021-07-01 한국과학기술원 반지도 학습 기반 단어 단위 감정 임베딩과 장단기 기억 모델을 이용한 대화 내에서 발화의 감정 분류 방법
CN114239547A (zh) * 2021-12-15 2022-03-25 平安科技(深圳)有限公司 一种语句生成方法及电子设备、存储介质

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108536681A (zh) * 2018-04-16 2018-09-14 腾讯科技(深圳)有限公司 基于情感分析的智能问答方法、装置、设备及存储介质
CN110990543A (zh) * 2019-10-18 2020-04-10 平安科技(深圳)有限公司 智能对话的生成方法、装置、计算机设备及计算机存储介质
WO2021132797A1 (ko) * 2019-12-27 2021-07-01 한국과학기술원 반지도 학습 기반 단어 단위 감정 임베딩과 장단기 기억 모델을 이용한 대화 내에서 발화의 감정 분류 방법
CN111428015A (zh) * 2020-03-20 2020-07-17 腾讯科技(深圳)有限公司 一种信息生成方法、装置、设备及存储介质
CN112214585A (zh) * 2020-09-10 2021-01-12 中国科学院深圳先进技术研究院 回复消息生成方法、系统、计算机设备及存储介质
CN114239547A (zh) * 2021-12-15 2022-03-25 平安科技(深圳)有限公司 一种语句生成方法及电子设备、存储介质

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116578731A (zh) * 2023-07-05 2023-08-11 之江实验室 多媒体信息处理方法、系统、计算机设备和存储介质
CN116578731B (zh) * 2023-07-05 2023-09-29 之江实验室 多媒体信息处理方法、系统、计算机设备和存储介质
CN117131182A (zh) * 2023-10-26 2023-11-28 江西拓世智能科技股份有限公司 一种基于ai的对话回复生成方法及系统
CN117808923A (zh) * 2024-02-29 2024-04-02 浪潮电子信息产业股份有限公司 一种图像生成方法、系统、电子设备及可读存储介质
CN117808923B (zh) * 2024-02-29 2024-05-14 浪潮电子信息产业股份有限公司 一种图像生成方法、系统、电子设备及可读存储介质
CN118035431A (zh) * 2024-04-12 2024-05-14 青岛网信信息科技有限公司 一种文字客服过程用户情绪预测方法、介质及系统

Also Published As

Publication number Publication date
CN114239547A (zh) 2022-03-25

Similar Documents

Publication Publication Date Title
WO2023108994A1 (zh) 一种语句生成方法及电子设备、存储介质
WO2019100350A1 (en) Providing a summary of a multimedia document in a session
CN110795552B (zh) 一种训练样本生成方法、装置、电子设备及存储介质
CN111159385B (zh) 一种基于动态知识图谱的无模板通用智能问答方法
CN110807332A (zh) 语义理解模型的训练方法、语义处理方法、装置及存储介质
CN111930940A (zh) 一种文本情感分类方法、装置、电子设备及存储介质
CN110795945A (zh) 一种语义理解模型训练方法、语义理解方法、装置及存储介质
WO2022252636A1 (zh) 基于人工智能的回答生成方法、装置、设备及存储介质
US11636272B2 (en) Hybrid natural language understanding
CN114757176A (zh) 一种获取目标意图识别模型的方法以及意图识别方法
CN107967250A (zh) 一种信息处理方法及装置
CN111209297B (zh) 数据查询方法、装置、电子设备及存储介质
CN114003682A (zh) 一种文本分类方法、装置、设备及存储介质
CN114706945A (zh) 意图识别方法、装置、电子设备及存储介质
CN113051380A (zh) 信息生成方法、装置、电子设备和存储介质
CN115455982A (zh) 对话处理方法、装置、电子设备及存储介质
CN111368066B (zh) 获取对话摘要的方法、装置和计算机可读存储介质
CN115064154A (zh) 混合语言语音识别模型的生成方法及装置
CN108538292B (zh) 一种语音识别方法、装置、设备及可读存储介质
CN113449081A (zh) 文本特征的提取方法、装置、计算机设备及存储介质
WO2024098763A1 (zh) 文本操作图互检方法及模型训练方法、装置、设备、介质
CN110516125B (zh) 识别异常字符串的方法、装置、设备及可读存储介质
CN110717316B (zh) 字幕对话流的主题分割方法及装置
CN116189663A (zh) 韵律预测模型的训练方法和装置、人机交互方法和装置
US20230029196A1 (en) Method and apparatus related to sentence generation

Legal Events

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

Ref document number: 22905762

Country of ref document: EP

Kind code of ref document: A1