WO2021051598A1 - 文本情感分析模型训练方法、装置、设备及可读存储介质 - Google Patents

文本情感分析模型训练方法、装置、设备及可读存储介质 Download PDF

Info

Publication number
WO2021051598A1
WO2021051598A1 PCT/CN2019/118268 CN2019118268W WO2021051598A1 WO 2021051598 A1 WO2021051598 A1 WO 2021051598A1 CN 2019118268 W CN2019118268 W CN 2019118268W WO 2021051598 A1 WO2021051598 A1 WO 2021051598A1
Authority
WO
WIPO (PCT)
Prior art keywords
text
text sample
neural network
deep neural
sample
Prior art date
Application number
PCT/CN2019/118268
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 WO2021051598A1 publication Critical patent/WO2021051598A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/24Classification techniques
    • G06F18/241Classification techniques relating to the classification model, e.g. parametric or non-parametric approaches
    • G06F18/2411Classification techniques relating to the classification model, e.g. parametric or non-parametric approaches based on the proximity to a decision surface, e.g. support vector machines
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/045Combinations of networks
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods

Definitions

  • This application relates to the field of artificial intelligence technology, and in particular to methods, devices, equipment and readable storage media for training text sentiment analysis models.
  • a deep neural network is usually used to deal with text sentiment analysis.
  • the deep neural network can capture long-range context information and has strong feature extraction capabilities.
  • the deep neural network has only one output. Therefore, the inventor realized that relying on the deep neural network can only complete two-category sentiment analysis, and the accuracy of existing text sentiment analysis methods is low.
  • the main purpose of this application is to provide a text sentiment analysis model training method, device, equipment, and readable storage medium, aiming to solve the technical problem of low accuracy of the existing text sentiment analysis method.
  • the text sentiment analysis model training method includes the following steps: obtaining a text sample to be trained, wherein the text sample carries label information, and the label The information is the correct emotion category contained in the text sample; word segmentation is performed on the text sample through a preset word segmentation method, and the text sample is divided into a number of different words; Different words are encoded separately to obtain the word vector corresponding to the text sample; the word vector is input into a preset deep neural network, and based on the embedded layer in the preset deep neural network, the Dimensionality reduction processing is performed on the word vector to obtain a dimensionality-reduced word vector; based on the preset hidden layer in the deep neural network, the dimensionality-reduced word vector is calculated to obtain the feature corresponding to the text sample; The multi-class SVM support vector machine classifies the features corresponding to the text sample, determines the emotion category corresponding to the text sample; determines the difference value between the emotion category and the correct
  • a second aspect of the present application provides a text sentiment analysis model training device.
  • the text sentiment analysis model training device includes: an acquisition module for acquiring a text sample to be trained, wherein the text sample carries annotated information, so The labeling information is the correct emotion category contained in the text sample; the word segmentation module is used to perform word segmentation processing on the text sample through a preset word segmentation method, and divide the text sample into a number of different words; encoding module, Used to separately encode the several different words based on the preset encoding method to obtain the word vector corresponding to the text sample; the dimensionality reduction module is used to input the word vector to the preset deep neural network Dimensionality reduction processing is performed on the word vector based on the embedding layer in the preset deep neural network to obtain the reduced dimensionality word vector; the feature module is used for hiding in the preset deep neural network The layer calculates the dimensionality-reduced word vector to obtain the feature corresponding to the text sample; the classification module is used to classify the feature corresponding to the text
  • a third aspect of the present application provides a text sentiment analysis model training device, including: a memory and at least one processor, the memory stores instructions, the memory and the at least one processor are interconnected by wires; the at least A processor calls the instructions in the memory, so that the text sentiment analysis model training device executes the method described in the first aspect.
  • the fourth aspect of the present application provides a computer-readable storage medium, the computer-readable storage medium stores computer instructions, and when the computer instructions run on a computer, the computer executes the above-mentioned first aspect method.
  • the text sentiment analysis model training method, device, equipment and readable storage medium provided in this application first obtain a text sample to be trained with label information, the label information is the correct emotion category contained in the text sample, and the text sample is processed Word segmentation process to obtain several different words; to encode several different words separately to obtain the word vector corresponding to the text sample, and input the word vector into the preset deep neural network, based on the preset deep neural network
  • the embedding layer in the embedded layer performs dimensionality reduction processing on the word vector; further, based on the preset hidden layer in the deep neural network, the dimensionality-reduced word vector is calculated to obtain the features corresponding to the text sample; finally, the multi-class SVM supports The vector machine classifies the calculated features to determine the emotion category corresponding to the text sample.
  • the difference value between the emotion category and the correct emotion category is determined based on the loss function.
  • the text sentiment analysis model training method proposed in this application extracts sentiment features in text samples through a deep neural network, and then uses a multi-class SVM support vector machine to multi-classify the extracted features to achieve the effect of improving classification accuracy.
  • FIG. 1 is a schematic structural diagram of a text sentiment analysis model training device in a hardware operating environment involved in the solution of the embodiment of the application;
  • FIG. 2 is a schematic flowchart of an embodiment of a text sentiment analysis model training method in this application
  • FIG. 3 is a schematic diagram of functional modules of an embodiment of a text sentiment analysis model training device in this application;
  • FIG. 4 is a schematic diagram of functional units of a word segmentation module in an embodiment of the text sentiment analysis model training device in this application;
  • FIG. 5 is a schematic diagram of the functional units of the feature module in an embodiment of the text sentiment analysis model training device in this application;
  • FIG. 6 is a schematic diagram of the functional units of the classification module in an embodiment of the text sentiment analysis model training device in this application.
  • the embodiments of the application provide a text sentiment analysis model training method, device, equipment, and storage medium, which are used to extract sentiment features in text samples through a deep neural network, and then use a multi-class SVM support vector machine to pair the extracted features Perform multiple classifications to achieve the effect of improving the accuracy of classification.
  • FIG. 1 is a schematic diagram of the structure of a text sentiment analysis model training device in a hardware operating environment involved in a solution of an embodiment of the application.
  • the text sentiment analysis model training device in the embodiment of the present application may be a terminal device with data processing capabilities such as a portable computer and a server.
  • the text sentiment analysis model training device may include: a processor 1001, such as a CPU, a network interface 1004, a user interface 1003, a memory 1005, and a communication bus 1002.
  • the communication bus 1002 is used to implement connection and communication between these components.
  • the user interface 1003 may include a display screen (Display) and an input unit such as a keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface and a wireless interface.
  • the network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a WI-FI interface).
  • the memory 1005 may be a high-speed RAM memory, or a non-volatile memory (non-volatile memory), such as a magnetic disk memory.
  • the memory 1005 may also be a storage device independent of the aforementioned processor 1001.
  • the structure of the text sentiment analysis model training device shown in FIG. 1 does not constitute a limitation on the text sentiment analysis model training device, and may include more or fewer components than shown in the figure, or a combination of certain components. Components, or different component arrangements.
  • the memory 1005 as a computer storage medium may include an operating system, a network communication module, a user interface module, and a text emotion analysis model training program.
  • the network interface 1004 is mainly used to connect to the back-end server and communicate data with the back-end server;
  • the user interface 1003 is mainly used to connect to the client (user side) and conduct data with the client Communication; and the processor 1001 can be used to call the text sentiment analysis model training program stored in the memory 1005, and execute the operations of the following text sentiment analysis model training methods.
  • Figure 2 is a schematic flowchart of an embodiment of a text sentiment analysis model training method according to the application.
  • the text sentiment analysis model training method includes:
  • Step S10 Obtain a text sample to be trained, where the text sample carries label information, and the label information is the correct emotion category contained in the text sample.
  • a text sample to be trained is obtained, so as to train a preset text sentiment analysis model based on the text sample.
  • the text sample to be trained carries label information, where the label information is mainly emotional category information contained in the text sample.
  • the emotional category information includes, but is not limited to, optimism, pessimism, anger, surprise, etc.
  • Step S20 Perform word segmentation processing on the text sample through a preset word segmentation method, and divide the text sample into several different words.
  • the text samples to be trained are preprocessed, and the process of preprocessing is mainly to segment the text samples.
  • Modern word segmentation is based on statistical word segmentation, and the statistical sample content comes from some standard corpora. Through the standard corpus, the binary conditional probability between all words can be calculated approximately. Based on the standard corpus, the binary conditional probability corresponding to each word contained in the text sample can be calculated, the joint distribution probability of the text sample is determined by the binary conditional probability, and the word segmentation method corresponding to the maximum joint distribution probability is determined as the most corresponding to the text sample. Excellent word segmentation method, in order to divide the text sample into several different words through the optimal word segmentation method.
  • step S30 a number of different words are respectively encoded based on a preset encoding method to obtain a word vector corresponding to the text sample.
  • one-hot encoding is mainly used.
  • the purpose of one-hot encoding is to convert categorical variables into a form that is easy to use by machine learning algorithms.
  • one-hot encoding converts discrete variables obtained after word segmentation of text samples into continuous variables.
  • the use of one-hot encoding to "binarize" each word contained in the text sample improves the rationality of the calculation of the distance between variables. It can be understood that, in this embodiment, the word vector corresponding to each word is obtained by encoding each word obtained after word segmentation processing of the text sample.
  • Step S40 Input the word vector into a preset deep neural network, and perform dimensionality reduction processing on the word vector based on the embedding layer in the preset deep neural network to obtain a reduced-dimensional word vector.
  • the word vector obtained by encoding is input into the deep neural network, and the word vector obtained by encoding is processed based on the deep neural network to perform feature extraction of the text sample.
  • the word vector obtained by using one-hot encoding has a high dimensionality and is sparse, first, the input word vector is reduced in dimensionality through the embedding layer in the deep neural network.
  • the process of dimensionality reduction is as follows: First, obtain the weight matrix W stored in the embedding layer, because the embedding layer in the deep neural network is essentially a special fully connected, but the vector input to the deep neural network is 0 or 1. Therefore, multiplying the input word vector by the weight matrix W can reduce the dimensionality of the input word vector.
  • Step S50 Calculate the dimensionality-reduced word vector based on the hidden layer in the preset deep neural network to obtain the feature corresponding to the text sample.
  • the dimensionality-reduced word vector is calculated through the hidden layer in the deep neural network, thereby performing feature extraction on the dimensionality-reduced word vector, and the extracted feature is the feature corresponding to the text sample.
  • the word vector is used as the feature of the first text sample extracted by the deep neural network; further, the weight matrix of the L-1th hidden layer in the preset deep neural network is obtained, and the L-1th layer is calculated based on the nonlinear activation function.
  • the weight matrix of and the features of the first paragraph of text samples are calculated to obtain the features of the first paragraph of text samples.
  • the calculation formula based on the nonlinear activation function is as follows:
  • X i is the vector word i sample text paragraph segmentation after coding processing and obtained
  • a neural network is a preset depth of paragraph 1 extracted text samples h i
  • is a nonlinear activation function
  • W L-1 is the weight matrix of the L-1th hidden layer in the preset deep neural network
  • h i L is the feature of the L-th text sample extracted by the preset deep neural network.
  • step S60 the features corresponding to the text sample are classified by the multi-class SVM support vector machine, and the emotion category corresponding to the text sample is determined.
  • the extracted features are further classified based on the multi-class SVM (Support Vector Machine, Support Vector Machine), so as to determine the emotion category of the text sample.
  • SVM Small Vector Machine, Support Vector Machine
  • the types of emotions in the preset data set of the multi-class SVM support vector machine are k types, denoted as y ⁇ 1,...,K ⁇ ; at the same time, k weight vectors W y are randomly initialized, then for the i
  • the decision of the multi-class SVM support vector machine is:
  • the preset text emotion analysis model distinguishes
  • the category information corresponding to the maximum product of is the emotion category corresponding to the text sample.
  • Step S70 Determine the difference value between the emotion category and the correct emotion category based on the loss function, and when the difference value meets a preset condition, it is determined that the training of the text emotion analysis model is completed.
  • the loss function is used to determine whether the training of the text sentiment analysis model is completed.
  • the loss function is defined as follows:
  • y i is the correct emotion category corresponding to the text sample.
  • the loss function requires that the scores of all error categories are less than the correct category scores. Score.
  • the loss function requires that the interval between the score of the wrong category and the score of the correct category is greater than the difference ⁇ (y i , y) between the two.
  • the label information is the correct emotion category contained in the text sample, and perform word segmentation processing on the text sample to obtain several different words; for several different words Perform encoding processing separately to obtain the word vector corresponding to the text sample, and input the word vector into a preset deep neural network, and perform dimensionality reduction processing on the word vector based on the embedded layer in the preset deep neural network; further, based on The hidden layer in the preset deep neural network calculates the dimensionality-reduced word vector to obtain the features corresponding to the text sample; finally, the calculated features are classified by the multi-class SVM support vector machine to determine the corresponding text sample Sentiment category, in the text sentiment analysis model training process, the difference value between the sentiment category and the correct sentiment category is determined based on the loss function.
  • the text sentiment analysis model training method proposed in this application extracts sentiment features in text samples through a deep neural network, and then uses a multi-class SVM support vector machine to multi-classify the extracted features to achieve the effect of improving classification accuracy.
  • step S20 includes:
  • Step S21 Calculate the binary conditional probability corresponding to each word contained in the text sample based on the standard corpus, where the binary conditional probability distribution of any two words W 1 and W 2 in the standard corpus is expressed as:
  • freq(W 1 ,W 2 ) represents the number of times that W 1 and W 2 appear next to each other in the standard corpus
  • freq(W 1 ) and freq(W 2 ) respectively represent the occurrence of W 1 and W 2 in the standard corpus The number of statistics
  • Step S22 Determine the joint distribution probability of each word in the text sample based on the binary conditional probability, determine the maximum joint distribution probability from the joint distribution probability, and determine the word segmentation method corresponding to the maximum joint distribution probability as the optimal word segmentation method corresponding to the text sample ;
  • step S23 the text sample is divided into several different words based on the optimal word segmentation method.
  • the binary conditional probability corresponding to each word contained in the text sample is calculated through the standard corpus, the joint distribution probability of the text sample is determined by the binary conditional probability, and the word segmentation method corresponding to the maximum joint distribution probability is determined as The optimal word segmentation method corresponding to the text sample.
  • freq(W 1 , W 2 ) represents the number of times that W 1 and W 2 appear next to each other in the standard corpus
  • freq(W 1 ) and freq(W 2 ) respectively represent W 1 and W 2 in the standard corpus The number of statistics that appear in.
  • the binary conditional probability corresponding to each word contained in the text sample is calculated, the joint distribution probability of each word in the text sample is determined according to the binary conditional probability, and the word segmentation method corresponding to the maximum joint distribution probability is found , Which is the optimal word segmentation method corresponding to the text sample.
  • the text sample can be divided into several different words.
  • step S70 the method further includes:
  • the preset text sentiment analysis model is first obtained, and the preset text sentiment analysis model is used to perform the analysis on the text to be analyzed. Text sentiment analysis to output the sentiment category information contained in the text to be analyzed.
  • preprocess the input text to be analyzed that is, perform word segmentation on the text to be analyzed; further, encode several words obtained by word segmentation based on the one-hot encoding method to obtain the corresponding word vector;
  • the word vector of is input into the deep neural network to extract the features of the text sample through the deep neural network; finally, based on the multi-class SVM support vector machine, the extracted features are classified by emotion category, and the emotion corresponding to the text to be analyzed is finally output Category information.
  • FIG. 3 is a schematic diagram of functional modules of an embodiment of a text sentiment analysis model training device according to the present application.
  • the text sentiment analysis model training device includes:
  • the obtaining module 10 is configured to obtain a text sample to be trained, wherein the text sample carries label information, and the label information is the correct emotion category contained in the text sample;
  • the word segmentation module 20 is configured to perform word segmentation processing on the text sample through a preset word segmentation method, and divide the text sample into a number of different words;
  • the encoding module 30 is configured to separately encode the several different words based on a preset encoding method to obtain the word vector corresponding to the text sample;
  • the dimensionality reduction module 40 is configured to input the word vector into a preset deep neural network, and perform dimensionality reduction processing on the word vector based on the embedding layer in the preset deep neural network to obtain a reduced dimensionality Word vector
  • the feature module 50 is configured to calculate the dimensionality-reduced word vector based on the hidden layer in the preset deep neural network to obtain the feature corresponding to the text sample;
  • the classification module 60 is configured to classify the features corresponding to the text sample through a multi-class SVM support vector machine, and determine the emotion category corresponding to the text sample;
  • the completion module 70 is configured to determine the difference value between the emotion category and the correct emotion category based on a loss function, and when the difference value meets a preset condition, determine that the text emotion analysis model training is completed.
  • the word segmentation module 20 includes:
  • the probability calculation unit 201 is configured to calculate the binary conditional probability corresponding to each word contained in the text sample based on the standard corpus, where the binary conditional probability distribution of any two words W 1 and W 2 in the standard corpus is expressed as:
  • freq(W 1 , W 2 ) represents the number of times that W 1 and W 2 appear next to each other in the standard corpus
  • freq(W 1 ) and freq(W 2 ) respectively represent the occurrence of W 1 and W 2 in the standard corpus The number of statistics
  • the optimal word segmentation unit 202 is configured to determine the joint distribution probability of each word in the text sample based on the binary conditional probability, determine the maximum joint distribution probability from the joint distribution probability, and assign the maximum joint distribution probability to the corresponding
  • the word segmentation method is determined as the optimal word segmentation method corresponding to the text sample;
  • the text division unit 203 is configured to divide the text sample into several different words based on the optimal word segmentation method
  • the feature module 50 includes:
  • the feature calculation unit 501 is configured to use the reduced-dimensional word vector corresponding to the L-1 paragraph of text sample as the feature of the first paragraph of text sample, and obtain the L-1th layer in the preset deep neural network
  • the weight matrix of the hidden layer is calculated based on the nonlinear activation function for the weight matrix of the L-1 layer and the features of the first paragraph of text samples to obtain the features of the Lth paragraph of text samples, wherein, based on the nonlinear activation
  • the formula for function calculation is as follows:
  • X-i is the i-th paragraph of text term vectors sample after segmentation and the encoding process is obtained
  • ⁇ nonlinear activation function WL-1 is the weight matrix of the L-1th hidden layer in the preset deep neural network
  • h i L is the feature of the L-th text sample extracted by the preset deep neural network.
  • the classification module 60 includes:
  • the category calculation unit 601 is used to randomly initialize k weight vectors W y , then for the i-th text sample, the decision of the multi-class SVM support vector machine is:
  • k is the number of emotion categories in the preset data set of the multi-class SVM support vector machine
  • the category determining unit 602 is configured to The emotion category corresponding to the largest product of is determined as the emotion category corresponding to the text sample.
  • the dimensionality reduction module 40 is specifically used for:
  • the word vector is multiplied by the weight matrix to obtain the word vector after dimensionality reduction.
  • the present application also provides a text sentiment analysis model training device, including: a memory and at least one processor, the memory stores instructions, the memory and the at least one processor are interconnected by wires; the at least one processor The instructions in the memory are invoked, so that the text sentiment analysis model training device executes the steps in the above-mentioned text sentiment analysis model training method.
  • the present application also provides a computer-readable storage medium.
  • the computer-readable storage medium may be a non-volatile computer-readable storage medium or a volatile computer-readable storage medium.
  • the computer-readable storage medium stores computer instructions, and when the computer instructions are executed on the computer, the computer executes the following steps:
  • a difference value between the emotion category and the correct emotion category is determined based on a loss function, and when the difference value meets a preset condition, it is determined that the training of the text emotion analysis model is completed.
  • the disclosed system, device, and method may be implemented in other ways.
  • the device embodiments described above are merely illustrative, for example, multiple units or components may be combined or integrated into another system, or some features may be omitted or not implemented.
  • the displayed or discussed mutual coupling or direct coupling or communication connection may be indirect coupling or communication connection through some interfaces, devices or units, and may be in electrical, mechanical or other forms.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Evolutionary Computation (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Artificial Intelligence (AREA)
  • General Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Computing Systems (AREA)
  • Software Systems (AREA)
  • Molecular Biology (AREA)
  • Computational Linguistics (AREA)
  • Biophysics (AREA)
  • Biomedical Technology (AREA)
  • Mathematical Physics (AREA)
  • General Health & Medical Sciences (AREA)
  • Health & Medical Sciences (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Evolutionary Biology (AREA)
  • Machine Translation (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

一种文本情感分析模型训练方法、装置、设备及可读存储介质,涉及人工智能技术领域,所述方法包括:获取待训练的文本样本(S10);通过预设的分词方法对文本样本进行分词处理,划分为若干个不同的词(S20);基于预设的编码方法对若干个不同的词分别进行编码处理,得到词向量(S30);将词向量输入至预设的深度神经网络中,基于嵌入层对词向量进行降维处理(S40);基于深度神经网络中的隐藏层对降维后的词向量进行计算,得到对应的特征(S50);通过多分类SVM支持向量机对文本样本对应的特征进行分类,确定情感类别(S60);基于损失函数确定情感类别与正确情感类别的差异值,当差异值满足预设条件时,判定文本情感分析模型训练完成(S70)。所述方法提高了文本情感分析的准确率。

Description

文本情感分析模型训练方法、装置、设备及可读存储介质
本申请要求于2019年9月19日提交中国专利局、申请号为201910884618.1、发明名称为“文本情感分析模型训练方法、装置、设备及可读存储介质”的中国专利申请的优先权,其全部内容通过引用结合在申请中。
技术领域
本申请涉及人工智能技术领域,尤其涉及文本情感分析模型训练方法、装置、设备及可读存储介质。
背景技术
在现有技术中,通常是使用深度神经网络来处理文本情感分析问题,深度神经网络能够捕捉长程的上下文信息,具有较强的特征抽取能力。但是,深度神经网络只有一个输出,因此,发明人意识到依靠深度神经网络只能完成二分类情感分析,现有的文本情感分析方法的准确率较低。
发明内容
本申请的主要目的在于提供一种文本情感分析模型训练方法、装置、设备及可读存储介质,旨在解决现有的文本情感分析方法的准确率低的技术问题。
为实现上述目的,本申请提供一种文本情感分析模型训练方法,所述文本情感分析模型训练方法包括以下步骤:获取待训练的文本样本,其中,所述文本样本带有标注信息,所述标注信息为所述文本样本包含的正确情感类别;通过预设的分词方法对所述文本样本进行分词处理,将所述文本样本划分为若干个不同的词;基于预设的编码方法对所述若干个不同的词分别进行编码处理,得到所述文本样本对应的词向量;将所述词向量输入至预设的深度神经网络中,基于所述预设的深度神经网络中的嵌入层对所述词向量进行降维处理,得到降维后的词向量;基于所述预设的深度神经网络中的隐藏层对所述降维后的词向量进行计算,得到所述文本样本对应的特征;通过多分类SVM支持向量机对所述文本样本对应的特征进行分类,确定所述文本样本对应的情感类别;基于损失函数确定所述情感类别与所述正确情感类别的差异值,当所述差异值满足预设条件时,判定所述文本情感分析模型训练完成。
本申请第二方面提供了一种文本情感分析模型训练装置,所述文本情感分析模型训练装置包括:获取模块,用于获取待训练的文本样本,其中,所述文本样本带有标注信息,所述标注信息为所述文本样本包含的正确情感类别;分词模块,用于通过预设的分词方法对所述文本样本进行分词处理,将所述文本样本划分为若干个不同的词;编码模块,用于基于预设的编码方法对所述若干个不同的词分别进行编码处理,得到所述文本样本对应的词向量;降维模块,用于将所述词向量输入至预设的深度神经网络中,基于所述预设的深度神经网络中的嵌入层对所述词向量进行降维处理,得到降维后的词向量;特征模块, 用于基于所述预设的深度神经网络中的隐藏层对所述降维后的词向量进行计算,得到所述文本样本对应的特征;分类模块,用于通过多分类SVM支持向量机对所述文本样本对应的特征进行分类,确定所述文本样本对应的情感类别;完成模块,用于基于损失函数确定所述情感类别与正确情感类别的差异值,当所述差异值满足预设条件时,判定所述文本情感分析模型训练完成。
本申请第三方面提供了一种文本情感分析模型训练设备,包括:存储器和至少一个处理器,所述存储器中存储有指令,所述存储器和所述至少一个处理器通过线路互联;所述至少一个处理器调用所述存储器中的所述指令,以使得所述文本情感分析模型训练设备执行上述第一方面所述的方法。
本申请的第四方面提供了一种计算机可读存储介质,所述计算机可读存储介质中存储有计算机指令,当所述计算机指令在计算机上运行时,使得计算机执行上述第一方面所述的方法。
本申请提供的一种文本情感分析模型训练方法、装置、设备及可读存储介质,首先获取带有标注信息的待训练文本样本,标注信息为文本样本包含的正确情感类别,并对文本样本进行分词处理,得到若干个不同的词;对若干个不同的词分别进行编码处理,得到文本样本对应的词向量,并将词向量输入至预设的深度神经网络中,基于预设的深度神经网络中的嵌入层对词向量进行降维处理;进一步地,基于预设的深度神经网络中的隐藏层对降维后的词向量进行计算,得到文本样本对应的特征;最后,通过多分类SVM支持向量机对计算得到的特征进行分类,从而确定文本样本对应的情感类别,在文本情感分析模型训练过程中,基于损失函数确定情感类别与正确情感类别的差异值,当差异值满足预设条件时,即可判定文本情感分析模型训练完成。本申请提出的文本情感分析模型训练方法,通过深度神经网络来抽取文本样本中的情感特征,再使用多分类SVM支持向量机对提取出的特征进行多分类,达到提高分类准确率的效果。
附图说明
图1为本申请中实施例方案涉及的硬件运行环境的文本情感分析模型训练设备结构示意图;
图2为本申请中文本情感分析模型训练方法一实施例的流程示意图;
图3为本申请中文本情感分析模型训练装置一实施例的功能模块示意图;
图4为本申请中文本情感分析模型训练装置一实施例中分词模块的功能单元示意图;
图5为本申请中文本情感分析模型训练装置一实施例中特征模块的功能单元示意图;
图6为本申请中文本情感分析模型训练装置一实施例中分类模块的功能单元示意图。
具体实施方式
本申请实施例提供了一种文本情感分析模型训练方法、装置、设备及存储介质,用于通过深度神经网络来抽取文本样本中的情感特征,再使用多分类SVM支持向量机对提取出的特征进行多分类,达到提高分类准确率的效果。
为了使本技术领域的人员更好地理解本申请方案,下面将结合本申请实施例中的附图,对本申请实施例进行描述。
如图1所示,图1为本申请实施例方案涉及的硬件运行环境的文本情感分析模型训练设备结构示意图。
本申请实施例中的文本情感分析模型训练设备可以是便携计算机、服务器等具有数据处理能力的终端设备。
如图1所示,该文本情感分析模型训练设备可以包括:处理器1001,例如CPU,网络接口1004,用户接口1003,存储器1005,通信总线1002。其中,通信总线1002用于实现这些组件之间的连接通信。用户接口1003可以包括显示屏(Display)、输入单元比如键盘(Keyboard),可选用户接口1003还可以包括标准的有线接口、无线接口。网络接口1004可选地可以包括标准的有线接口、无线接口(如WI-FI接口)。存储器1005可以是高速RAM存储器,也可以是稳定的存储器(non-volatile memory),例如磁盘存储器。存储器1005可选地还可以是独立于前述处理器1001的存储装置。
本领域技术人员可以理解,图1中示出的文本情感分析模型训练设备结构并不构成对文本情感分析模型训练设备的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置。
如图1所示,作为一种计算机存储介质的存储器1005中可以包括操作系统、网络通信模块、用户接口模块以及文本情感分析模型训练程序。
在图1所示的文本情感分析模型训练设备中,网络接口1004主要用于连接后台服务器,与后台服务器进行数据通信;用户接口1003主要用于连接客户端(用户端),与客户端进行数据通信;而处理器1001可以用于调用存储器1005中存储的文本情感分析模型训练程序,并执行以下文本情感分析模型训练方法的各实施例的操作。
参照图2,图2为本申请文本情感分析模型训练方法一实施例的流程示意图,在该实施例中,文本情感分析模型训练方法包括:
步骤S10,获取待训练的文本样本,其中,文本样本带有标注信息,标注信息为文本样本包含的正确情感类别。
在本实施例中,首先,获取待训练的文本样本,以便基于文本样本对预设的文本情感分析模型进行训练。具体地,待训练的文本样本带有标注信息,其中,标注信息主要是文本样本所包含的情感类别信息,在本实施例中,情感类别信息包括但不限于乐观、悲观、愤怒及惊讶等。
步骤S20,通过预设的分词方法对文本样本进行分词处理,将文本样本划分为若干个不同的词。
进一步地,对待训练的文本样本进行预处理,预处理的过程主要是对文本样本进行分词。现代分词都是基于统计的分词,而统计的样本内容来自于一些标准的语料库,通过标准语料库,可以近似地计算出所有的词之间的二元条件概率。基于标准语料库可以计算出文本样本中包含的各个词对应的二元条件概率,通过二元条件概率确定文本样本的联合分布概率,将最大联合分布概率对应的分词方法,确定为文本样本对应的最优分词方法,以便通过最优分词方法将文本样本划分为若干个不同的词。
步骤S30,基于预设的编码方法对若干个不同的词分别进行编码处理,得到文本样本对应的词向量。
进一步地,对文本样本进行分词后,将分词得到的若干个词分别进行编码,在本实施例中,主要是采用one-hot编码。one-hot编码的目的是将类别变量转换为机器学习算法易于利用的一种形式,也就是说,one-hot编码是把文本样本分词后得到的离散变量转换为连续变量。使用one-hot编码对文本样本包含的各个词进行“二进制化”操作,提高了变量之间的距离计算的合理性。可以理解的是,在本实施例中,对文本样本分词处理后得到的各个词进行编码得到的是各个词对应的词向量。
步骤S40,将词向量输入至预设的深度神经网络中,基于预设的深度神经网络中的嵌入层对词向量进行降维处理,得到降维后的词向量。
进一步地,将编码得到的词向量输入至深度神经网络中,基于深度神经网络对编码得到的词向量进行处理,以进行文本样本的特征提取。在本实施例中,由于使用one-hot编码得到的词向量维数高且稀疏,因此,首先通过深度神经网络中的嵌入层对输入的词向量进行降维处理。
具体地,降维处理的过程如下:首先,获取嵌入层中存储的权重矩阵W,因为深度神经网络中的嵌入层本质就是一个特殊的全连接,只是输入至深度神经网络的向量都是0或1,因此,将输入的词向量与权重矩阵W相乘,就可以降低输入词向量的维度。
步骤S50,基于预设的深度神经网络中的隐藏层对降维后的词向量进行计算,得到文本样本对应的特征。
进一步地,通过深度神经网络中的隐藏层对降维后的词向量进行计算,从而对降维后的词向量进行特征提取,提取出的特征即为文本样本对应的特征。
具体地,特征提取的过程如下:
随机将第L-1段文本样本经过分词及编码后得到的词向量输入至深度神经网络中,通过嵌入层的权重矩阵W对输入的词向量进行降维处理,并将降维处理后得到的词向量作为深度神经网络提取出的第1个文本样本的特征;进一步地,获取预设的深度神经网络中第L-1层隐藏层的权重矩阵,基于非线性激活函数对第L-1层的权重矩阵及第1段文本样本的特征进行计算,得到第L段文本样本的特征,其中,基于非线性激活函数进行计算的公式如下:
Figure PCTCN2019118268-appb-000001
Figure PCTCN2019118268-appb-000002
其中,X i为第i段文本样本经过分词及编码处理后得到的词向量,h i 1为预设的深度神经网络提取出的第1段文本样本的特征,σ为非线性激活函数,W L-1为预设的深度神经网络中第L-1层隐藏层的权重矩阵,h i L为预设的深度神经网络提取出的第L段文本样本的特征。
步骤S60,通过多分类SVM支持向量机对文本样本对应的特征进行分类,确定文本样本对应的情感类别。
完成待训练的文本样本的特征提取后,进一步地,基于多分类SVM(Support Vector Machine,支持向量机)对提取的特征进行分类,从而确定文本样本的情感类别。
具体地,假设多分类SVM支持向量机的预设数据集中情感的种类为k种,记为y∈{1,…,K};同时,随机初始化k个权重向量W y,则对于第i个文本样本,多分类SVM支持向量机的决策为:
Figure PCTCN2019118268-appb-000003
即在k个情感种类中,预设的文本情感分析模型判别出
Figure PCTCN2019118268-appb-000004
的最大乘积所对应的类别信息,为文本样本对应的情感类别。
步骤S70,基于损失函数确定情感类别与正确情感类别的差异值,当差异值满足预设条件时,判定文本情感分析模型训练完成。
在本实施例中,是通过损失函数来判断文本情感分析模型是否训练完成,损失函数定义如下:
Figure PCTCN2019118268-appb-000005
s.t.对于所有i,所有y:
Figure PCTCN2019118268-appb-000006
其中,y i为文本样本对应的正确情感类别,在本实施例中,因为待训练的文本样本均带有正确的情感类别标注信息,因此,损失函数要求所有错误类别的得分都小于正确类别的得分。同时,在本实施例中,定义情感类别之间的差异度Δ(y,j),同种情感类别之间的差异度Δ(y,y)=0,不同种情感类别之间的差异可以设置为1也可以设置为不同值。损失函数要求错误类别的得分与正确类别的得分之间的间隔大于二者之间的差异Δ(y i,y)。
在本实施例中,首先获取带有标注信息的待训练文本样本,标注信息为文 本样本包含的正确情感类别,并对文本样本进行分词处理,得到若干个不同的词;对若干个不同的词分别进行编码处理,得到文本样本对应的词向量,并将词向量输入至预设的深度神经网络中,基于预设的深度神经网络中的嵌入层对词向量进行降维处理;进一步地,基于预设的深度神经网络中的隐藏层对降维后的词向量进行计算,得到文本样本对应的特征;最后,通过多分类SVM支持向量机对计算得到的特征进行分类,从而确定文本样本对应的情感类别,在文本情感分析模型训练过程中,基于损失函数确定情感类别与正确情感类别的差异值,当差异值满足预设条件时,即可判定文本情感分析模型训练完成。本申请提出的文本情感分析模型训练方法,通过深度神经网络来抽取文本样本中的情感特征,再使用多分类SVM支持向量机对提取出的特征进行多分类,达到提高分类准确率的效果。
进一步地,所述步骤S20包括:
步骤S21,基于标准语料库计算文本样本中包含的各个词对应的二元条件概率,其中,标准语料库中任意两个词W 1和W 2的二元条件概率分布表示为:
Figure PCTCN2019118268-appb-000007
Figure PCTCN2019118268-appb-000008
其中,freq(W 1,W 2)表示W 1和W 2在标准语料库中相邻一起出现的次数,freq(W 1)和freq(W 2)分别表示W 1和W 2在标准语料库中出现的统计次数;
步骤S22,基于二元条件概率确定文本样本中各个词的联合分布概率,从联合分布概率中确定最大联合分布概率,将最大联合分布概率对应的分词方法,确定为文本样本对应的最优分词方法;
步骤S23,基于最优分词方法将文本样本划分为若干个不同的词。
在本实施例中,通过标准语料库计算出文本样本中包含的各个词对应的二元条件概率,通过二元条件概率确定文本样本的联合分布概率,将最大联合分布概率对应的分词方法,确定为文本样本对应的最优分词方法。
具体地,对于任意两个词W 1和W 2,它们的二元条件概率分布可以近似的表示为:
Figure PCTCN2019118268-appb-000009
Figure PCTCN2019118268-appb-000010
其中,freq(W 1,W 2)表示W 1和W 2在标准语料库中相邻一起出现的次数,而freq(W 1)和freq(W 2)则分别表示W 1和W 2在标准语料库中出现的统计次数。
通过上述二元条件概率分布公式,计算出文本样本中包含的各个词对应的二元条件概率,根据二元条件概率确定文本样本中各个词的联合分布概率,找 到最大联合分布概率对应的分词方法,即为文本样本对应的最优分词方法。通过最优分词方法对文本样本进行分词处理,即可将文本样本划分为若干个不同的词。
进一步地,在步骤S70之后,还包括:
在本实施例中,完成对预设的文本情感分析模型的训练后,当接收到文本情感分析指令时,首先获取预设的文本情感分析模型,使用预设的文本情感分析模型对待分析文本进行文本情感分析,以输出待分析文本包含的情感类别信息。
具体地,首先,对输入的待分析文本进行预处理,即对待分析文本进行分词;进一步地,基于one-hot编码方法对分词得到的若干个词进行编码,得到对应的词向量;将编码得到的词向量输入至深度神经网络中,以便通过深度神经网络提取出文本样本的特征;最后,基于多分类SVM支持向量机对提取出的特征进行情感类别分类,并最终输出待分析文本对应的情感类别信息。
参照图3,图3为本申请文本情感分析模型训练装置一实施例的功能模块示意图。
在本实施例中,文本情感分析模型训练装置包括:
获取模块10,用于获取待训练的文本样本,其中,所述文本样本带有标注信息,所述标注信息为所述文本样本包含的正确情感类别;
分词模块20,用于通过预设的分词方法对所述文本样本进行分词处理,将所述文本样本划分为若干个不同的词;
编码模块30,用于基于预设的编码方法对所述若干个不同的词分别进行编码处理,得到所述文本样本对应的词向量;
降维模块40,用于将所述词向量输入至预设的深度神经网络中,基于所述预设的深度神经网络中的嵌入层对所述词向量进行降维处理,得到降维后的词向量;
特征模块50,用于基于所述预设的深度神经网络中的隐藏层对所述降维后的词向量进行计算,得到所述文本样本对应的特征;
分类模块60,用于通过多分类SVM支持向量机对所述文本样本对应的特征进行分类,确定所述文本样本对应的情感类别;
完成模块70,用于基于损失函数确定所述情感类别与所述正确情感类别的差异值,当所述差异值满足预设条件时,判定所述文本情感分析模型训练完成。
进一步地,参照图4,所述分词模块20包括:
概率计算单元201,用于基于标准语料库计算所述文本样本中包含的各个词对应的二元条件概率,其中,标准语料库中任意两个词W 1和W 2的二元条件概率分布表示为:
Figure PCTCN2019118268-appb-000011
Figure PCTCN2019118268-appb-000012
其中,freq(W 1,W 2)表示W 1和W 2在标准语料库中相邻一起出现的次数,freq(W 1)和freq(W 2)分别表示W 1和W 2在标准语料库中出现的统计次数;
最优分词单元202,用于基于所述二元条件概率确定所述文本样本中各个词的联合分布概率,从所述联合分布概率中确定最大联合分布概率,将所述最大联合分布概率对应的分词方法,确定为所述文本样本对应的最优分词方法;
文本划分单元203,用于基于所述最优分词方法将所述文本样本划分为若干个不同的词
进一步地,参照图5,所述特征模块50包括:
特征计算单元501,用于将第L-1段文本样本对应的所述降维后的词向量作为第1段文本样本的特征,并获取所述预设的深度神经网络中第L-1层隐藏层的权重矩阵,基于非线性激活函数对所述第L-1层的权重矩阵及所述第1段文本样本的特征进行计算,得到第L段文本样本的特征,其中,基于非线性激活函数进行计算的公式如下:
Figure PCTCN2019118268-appb-000013
Figure PCTCN2019118268-appb-000014
其中,X i为第i段文本样本经过分词及编码处理后得到的词向量,h i 1为所述预设的深度神经网络提取出的第1段文本样本的特征,σ为非线性激活函数,W L-1为所述预设的深度神经网络中第L-1层隐藏层的权重矩阵,h i L为所述预设的深度神经网络提取出的第L段文本样本的特征。
进一步地,参照图6,所述分类模块60包括:
类别计算单元601,用于随机初始化k个权重向量W y,则对于第i个文本样本,所述多分类SVM支持向量机的决策为:
Figure PCTCN2019118268-appb-000015
其中,k为所述多分类SVM支持向量机的预设数据集中的情感类别数目;
类别确定单元602,用于将
Figure PCTCN2019118268-appb-000016
的最大乘积对应的情感类别确定为所述文本样本对应的情感类别。
进一步地,所述降维模块40具体用于:
在预设的深度神经网络中,获取权重矩阵,所述权重矩阵设置在所述预设的深度神经网络中的嵌入层中;
将所述词向量与权重矩阵相乘,得到降维后的词向量。
本申请还提供一种文本情感分析模型训练设备,包括:存储器和至少一个 处理器,所述存储器中存储有指令,所述存储器和所述至少一个处理器通过线路互联;所述至少一个处理器调用所述存储器中的所述指令,以使得所述文本情感分析模型训练设备执行上述文本情感分析模型训练方法中的步骤。
本申请还提供一种计算机可读存储介质,该计算机可读存储介质可以为非易失性计算机可读存储介质,也可以为易失性计算机可读存储介质。计算机可读存储介质存储有计算机指令,当所述计算机指令在计算机上运行时,使得计算机执行如下步骤:
获取待训练的文本样本,其中,所述文本样本带有标注信息,所述标注信息为所述文本样本包含的正确情感类别;
通过预设的分词方法对所述文本样本进行分词处理,将所述文本样本划分为若干个不同的词;
基于预设的编码方法对所述若干个不同的词分别进行编码处理,得到所述文本样本对应的词向量;
将所述词向量输入至预设的深度神经网络中,基于所述预设的深度神经网络中的嵌入层对所述词向量进行降维处理,得到降维后的词向量;
基于所述预设的深度神经网络中的隐藏层对所述降维后的词向量进行计算,得到所述文本样本对应的特征;
通过多分类SVM支持向量机对所述文本样本对应的特征进行分类,确定所述文本样本对应的情感类别;
基于损失函数确定所述情感类别与所述正确情感类别的差异值,当所述差异值满足预设条件时,判定所述文本情感分析模型训练完成。
在本申请所提供的几个实施例中,应该理解到,所揭露的系统,装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。
以上所述,以上实施例仅用以说明本申请的技术方案,而非对其限制;尽管参照前述实施例对本申请进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本申请各实施例技术方案的精神和范围。

Claims (20)

  1. 一种文本情感分析模型训练方法,所述文本情感分析模型训练方法包括以下步骤:
    获取待训练的文本样本,其中,所述文本样本带有标注信息,所述标注信息为所述文本样本包含的正确情感类别;
    通过预设的分词方法对所述文本样本进行分词处理,将所述文本样本划分为若干个不同的词;
    基于预设的编码方法对所述若干个不同的词分别进行编码处理,得到所述文本样本对应的词向量;
    将所述词向量输入至预设的深度神经网络中,基于所述预设的深度神经网络中的嵌入层对所述词向量进行降维处理,得到降维后的词向量;
    基于所述预设的深度神经网络中的隐藏层对所述降维后的词向量进行计算,得到所述文本样本对应的特征;
    通过多分类SVM支持向量机对所述文本样本对应的特征进行分类,确定所述文本样本对应的情感类别;
    基于损失函数确定所述情感类别与所述正确情感类别的差异值,当所述差异值满足预设条件时,判定所述文本情感分析模型训练完成。
  2. 如权利要求1所述的文本情感分析模型训练方法,所述通过预设的分词方法对所述文本样本进行分词处理,将所述文本样本划分为若干个不同的词包括:
    基于标准语料库计算所述文本样本中包含的各个词对应的二元条件概率,其中,标准语料库中任意两个词W 1和W 2的二元条件概率分布表示为:
    Figure PCTCN2019118268-appb-100001
    Figure PCTCN2019118268-appb-100002
    其中,freq(W 1,W 2)表示W 1和W 2在标准语料库中相邻一起出现的次数,freq(W 1)和freq(W 2)分别表示W 1和W 2在标准语料库中出现的统计次数;
    基于所述二元条件概率确定所述文本样本中各个词的联合分布概率,从所述联合分布概率中确定最大联合分布概率,将所述最大联合分布概率对应的分词方法,确定为所述文本样本对应的最优分词方法;
    基于所述最优分词方法将所述文本样本划分为若干个不同的词。
  3. 如权利要求1所述的文本情感分析模型训练方法,所述基于所述预设的深度神经网络中的隐藏层对所述降维后的词向量进行计算,得到所述文本样本对应的特征包括:
    将第L-1段文本样本对应的所述降维后的词向量作为第1段文本样本的特征,并获取所述预设的深度神经网络中第L-1层隐藏层的权重矩阵,基于非线 性激活函数对所述第L-1层的权重矩阵及所述第1段文本样本的特征进行计算,得到第L段文本样本的特征,其中,基于非线性激活函数进行计算的公式如下:
    Figure PCTCN2019118268-appb-100003
    Figure PCTCN2019118268-appb-100004
    其中,X i为第i段文本样本经过分词及编码处理后得到的词向量,h i 1为所述预设的深度神经网络提取出的第1段文本样本的特征,σ为非线性激活函数,W L-1为所述预设的深度神经网络中第L-1层隐藏层的权重矩阵,h i L为所述预设的深度神经网络提取出的第L段文本样本的特征。
  4. 如权利要求3所述的文本情感分析模型训练方法,所述通过多分类SVM支持向量机对所述文本样本对应的特征进行分类,确定所述文本样本对应的情感类别包括:
    随机初始化k个权重向量W y,则对于第i个文本样本,所述多分类SVM支持向量机的决策为:
    Figure PCTCN2019118268-appb-100005
    其中,k为所述多分类SVM支持向量机的预设数据集中的情感类别数目;
    Figure PCTCN2019118268-appb-100006
    的最大乘积对应的情感类别确定为所述文本样本对应的情感类别。
  5. 如权利要求1所述的文本情感分析模型训练方法,所述将所述词向量输入至预设的深度神经网络中,基于所述预设的深度神经网络中的嵌入层对所述词向量进行降维处理,得到降维后的词向量包括:
    在预设的深度神经网络中,获取权重矩阵,所述权重矩阵设置在所述预设的深度神经网络中的嵌入层中;
    将所述词向量与权重矩阵相乘,得到降维后的词向量。
  6. 一种文本情感分析模型训练装置,所述文本情感分析模型训练装置包括:
    获取模块,用于获取待训练的文本样本,其中,所述文本样本带有标注信息,所述标注信息为所述文本样本包含的正确情感类别;
    分词模块,用于通过预设的分词方法对所述文本样本进行分词处理,将所述文本样本划分为若干个不同的词;
    编码模块,用于基于预设的编码方法对所述若干个不同的词分别进行编码处理,得到所述文本样本对应的词向量;
    降维模块,用于将所述词向量输入至预设的深度神经网络中,基于所述预设的深度神经网络中的嵌入层对所述词向量进行降维处理,得到降维后的词向量;
    特征模块,用于基于所述预设的深度神经网络中的隐藏层对所述降维后的词向量进行计算,得到所述文本样本对应的特征;
    分类模块,用于通过多分类SVM支持向量机对所述文本样本对应的特征进行分类,确定所述文本样本对应的情感类别;
    完成模块,用于基于损失函数确定所述情感类别与所述正确情感类别的差异值,当所述差异值满足预设条件时,判定所述文本情感分析模型训练完成。
  7. 如权利要求6所述的文本情感分析模型训练装置,所述分词模块包括:
    概率计算单元,用于基于标准语料库计算所述文本样本中包含的各个词对应的二元条件概率,其中,标准语料库中任意两个词W 1和W 2的二元条件概率分布表示为:
    Figure PCTCN2019118268-appb-100007
    Figure PCTCN2019118268-appb-100008
    其中,freq(W 1,W 2)表示W 1和W 2在标准语料库中相邻一起出现的次数,freq(W 1)和freq(W 2)分别表示W 1和W 2在标准语料库中出现的统计次数;
    最优分词单元,用于基于所述二元条件概率确定所述文本样本中各个词的联合分布概率,从所述联合分布概率中确定最大联合分布概率,将所述最大联合分布概率对应的分词方法,确定为所述文本样本对应的最优分词方法;
    文本划分单元,用于基于所述最优分词方法将所述文本样本划分为若干个不同的词。
  8. 如权利要求6所述的文本情感分析模型训练装置,所述特征模块包括:
    特征计算单元,用于将第L-1段文本样本对应的所述降维后的词向量作为第1段文本样本的特征,并获取所述预设的深度神经网络中第L-1层隐藏层的权重矩阵,基于非线性激活函数对所述第L-1层的权重矩阵及所述第1段文本样本的特征进行计算,得到第L段文本样本的特征,其中,基于非线性激活函数进行计算的公式如下:
    Figure PCTCN2019118268-appb-100009
    Figure PCTCN2019118268-appb-100010
    其中,X i为第i段文本样本经过分词及编码处理后得到的词向量,h i 1为所述预设的深度神经网络提取出的第1段文本样本的特征,σ为非线性激活函数,W L-1为所述预设的深度神经网络中第L-1层隐藏层的权重矩阵,h i L为所述预设的深度神经网络提取出的第L段文本样本的特征。
  9. 如权利要求8所述的文本情感分析模型训练装置,所述分类模块包括:
    类别计算单元,用于随机初始化k个权重向量W y,则对于第i个文本样本,所述多分类SVM支持向量机的决策为:
    Figure PCTCN2019118268-appb-100011
    其中,k为所述多分类SVM支持向量机的预设数据集中的情感类别数目;
    类别确定单元,用于将
    Figure PCTCN2019118268-appb-100012
    的最大乘积对应的情感类别确定为所述文本样本对应的情感类别。
  10. 如权利要求6所述的文本情感分析模型训练装置,所述降维模块具体用于:
    在预设的深度神经网络中,获取权重矩阵,所述权重矩阵设置在所述预设的深度神经网络中的嵌入层中;
    将所述词向量与权重矩阵相乘,得到降维后的词向量。
  11. 一种文本情感分析模型训练设备,包括存储器、处理器及存储在所述存储器上并可在所述处理器上运行的计算机程序,所述处理器执行所述计算机程序时实现如下步骤:
    获取待训练的文本样本,其中,所述文本样本带有标注信息,所述标注信息为所述文本样本包含的正确情感类别;
    通过预设的分词方法对所述文本样本进行分词处理,将所述文本样本划分为若干个不同的词;
    基于预设的编码方法对所述若干个不同的词分别进行编码处理,得到所述文本样本对应的词向量;
    将所述词向量输入至预设的深度神经网络中,基于所述预设的深度神经网络中的嵌入层对所述词向量进行降维处理,得到降维后的词向量;
    基于所述预设的深度神经网络中的隐藏层对所述降维后的词向量进行计算,得到所述文本样本对应的特征;
    通过多分类SVM支持向量机对所述文本样本对应的特征进行分类,确定所述文本样本对应的情感类别;
    基于损失函数确定所述情感类别与所述正确情感类别的差异值,当所述差异值满足预设条件时,判定所述文本情感分析模型训练完成。
  12. 如权利要求11所述的文本情感分析模型训练设备,所述处理器执行所述计算机程序实现所述通过预设的分词方法对所述文本样本进行分词处理,将所述文本样本划分为若干个不同的词时,包括以下步骤:
    基于标准语料库计算所述文本样本中包含的各个词对应的二元条件概率,其中,标准语料库中任意两个词W 1和W 2的二元条件概率分布表示为:
    Figure PCTCN2019118268-appb-100013
    Figure PCTCN2019118268-appb-100014
    其中,freq(W 1,W 2)表示W 1和W 2在标准语料库中相邻一起出现的次数, freq(W 1)和freq(W 2)分别表示W 1和W 2在标准语料库中出现的统计次数;
    基于所述二元条件概率确定所述文本样本中各个词的联合分布概率,从所述联合分布概率中确定最大联合分布概率,将所述最大联合分布概率对应的分词方法,确定为所述文本样本对应的最优分词方法;
    基于所述最优分词方法将所述文本样本划分为若干个不同的词。
  13. 如权利要求11所述的文本情感分析模型训练设备,所述处理器执行所述计算机程序实现所述基于所述预设的深度神经网络中的隐藏层对所述降维后的词向量进行计算,得到所述文本样本对应的特征时,包括以下步骤:
    将第L-1段文本样本对应的所述降维后的词向量作为第1段文本样本的特征,并获取所述预设的深度神经网络中第L-1层隐藏层的权重矩阵,基于非线性激活函数对所述第L-1层的权重矩阵及所述第1段文本样本的特征进行计算,得到第L段文本样本的特征,其中,基于非线性激活函数进行计算的公式如下:
    Figure PCTCN2019118268-appb-100015
    Figure PCTCN2019118268-appb-100016
    其中,X i为第i段文本样本经过分词及编码处理后得到的词向量,h i 1为所述预设的深度神经网络提取出的第1段文本样本的特征,σ为非线性激活函数,W L-1为所述预设的深度神经网络中第L-1层隐藏层的权重矩阵,h i L为所述预设的深度神经网络提取出的第L段文本样本的特征。
  14. 如权利要求13所述的文本情感分析模型训练设备,所述处理器执行所述计算机程序实现所述通过多分类SVM支持向量机对所述文本样本对应的特征进行分类,确定所述文本样本对应的情感类别时,包括以下步骤:
    随机初始化k个权重向量W y,则对于第i个文本样本,所述多分类SVM支持向量机的决策为:
    Figure PCTCN2019118268-appb-100017
    其中,k为所述多分类SVM支持向量机的预设数据集中的情感类别数目;
    Figure PCTCN2019118268-appb-100018
    的最大乘积对应的情感类别确定为所述文本样本对应的情感类别。
  15. 如权利要求11所述的文本情感分析模型训练设备,所述处理器执行所述计算机程序实现所述将所述词向量输入至预设的深度神经网络中,基于所述预设的深度神经网络中的嵌入层对所述词向量进行降维处理,得到降维后的词向量时,包括以下步骤:
    在预设的深度神经网络中,获取权重矩阵,所述权重矩阵设置在所述预设的深度神经网络中的嵌入层中;
    将所述词向量与权重矩阵相乘,得到降维后的词向量。
  16. 一种计算机可读存储介质,所述计算机可读存储介质中存储计算机指令,当所述计算机指令在计算机上运行时,使得计算机执行如下步骤:
    获取待训练的文本样本,其中,所述文本样本带有标注信息,所述标注信息为所述文本样本包含的正确情感类别;
    通过预设的分词方法对所述文本样本进行分词处理,将所述文本样本划分为若干个不同的词;
    基于预设的编码方法对所述若干个不同的词分别进行编码处理,得到所述文本样本对应的词向量;
    将所述词向量输入至预设的深度神经网络中,基于所述预设的深度神经网络中的嵌入层对所述词向量进行降维处理,得到降维后的词向量;
    基于所述预设的深度神经网络中的隐藏层对所述降维后的词向量进行计算,得到所述文本样本对应的特征;
    通过多分类SVM支持向量机对所述文本样本对应的特征进行分类,确定所述文本样本对应的情感类别;
    基于损失函数确定所述情感类别与所述正确情感类别的差异值,当所述差异值满足预设条件时,判定所述文本情感分析模型训练完成。
  17. 如权利要求16所述的计算机可读存储介质,当所述计算机指令在计算机上运行所述通过预设的分词方法对所述文本样本进行分词处理,将所述文本样本划分为若干个不同的词时,使得计算机执行如下步骤:
    基于标准语料库计算所述文本样本中包含的各个词对应的二元条件概率,其中,标准语料库中任意两个词W 1和W 2的二元条件概率分布表示为:
    Figure PCTCN2019118268-appb-100019
    Figure PCTCN2019118268-appb-100020
    其中,freq(W 1,W 2)表示W 1和W 2在标准语料库中相邻一起出现的次数,freq(W 1)和freq(W 2)分别表示W 1和W 2在标准语料库中出现的统计次数;
    基于所述二元条件概率确定所述文本样本中各个词的联合分布概率,从所述联合分布概率中确定最大联合分布概率,将所述最大联合分布概率对应的分词方法,确定为所述文本样本对应的最优分词方法;
    基于所述最优分词方法将所述文本样本划分为若干个不同的词。
  18. 如权利要求16所述的计算机可读存储介质,当所述计算机指令在计算机上运行所述基于所述预设的深度神经网络中的隐藏层对所述降维后的词向量进行计算,得到所述文本样本对应的特征时,使得计算机执行如下步骤:
    将第L-1段文本样本对应的所述降维后的词向量作为第1段文本样本的特征,并获取所述预设的深度神经网络中第L-1层隐藏层的权重矩阵,基于非线 性激活函数对所述第L-1层的权重矩阵及所述第1段文本样本的特征进行计算,得到第L段文本样本的特征,其中,基于非线性激活函数进行计算的公式如下:
    Figure PCTCN2019118268-appb-100021
    Figure PCTCN2019118268-appb-100022
    其中,X i为第i段文本样本经过分词及编码处理后得到的词向量,h i 1为所述预设的深度神经网络提取出的第1段文本样本的特征,σ为非线性激活函数,W L-1为所述预设的深度神经网络中第L-1层隐藏层的权重矩阵,h i L为所述预设的深度神经网络提取出的第L段文本样本的特征。
  19. 如权利要求18所述的计算机可读存储介质,当所述计算机指令在计算机上运行所述通过多分类SVM支持向量机对所述文本样本对应的特征进行分类,确定所述文本样本对应的情感类别时,使得计算机执行如下步骤:
    随机初始化k个权重向量W y,则对于第i个文本样本,所述多分类SVM支持向量机的决策为:
    Figure PCTCN2019118268-appb-100023
    其中,k为所述多分类SVM支持向量机的预设数据集中的情感类别数目;
    Figure PCTCN2019118268-appb-100024
    的最大乘积对应的情感类别确定为所述文本样本对应的情感类别。
  20. 如权利要求16所述的计算机可读存储介质,当所述计算机指令在计算机上运行所述将所述词向量输入至预设的深度神经网络中,基于所述预设的深度神经网络中的嵌入层对所述词向量进行降维处理,得到降维后的词向量时,使得计算机执行如下步骤:
    在预设的深度神经网络中,获取权重矩阵,所述权重矩阵设置在所述预设的深度神经网络中的嵌入层中;
    将所述词向量与权重矩阵相乘,得到降维后的词向量。
PCT/CN2019/118268 2019-09-19 2019-11-14 文本情感分析模型训练方法、装置、设备及可读存储介质 WO2021051598A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910884618.1 2019-09-19
CN201910884618.1A CN110807314A (zh) 2019-09-19 2019-09-19 文本情感分析模型训练方法、装置、设备及可读存储介质

Publications (1)

Publication Number Publication Date
WO2021051598A1 true WO2021051598A1 (zh) 2021-03-25

Family

ID=69487688

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/118268 WO2021051598A1 (zh) 2019-09-19 2019-11-14 文本情感分析模型训练方法、装置、设备及可读存储介质

Country Status (2)

Country Link
CN (1) CN110807314A (zh)
WO (1) WO2021051598A1 (zh)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113283232A (zh) * 2021-05-31 2021-08-20 支付宝(杭州)信息技术有限公司 自动解析文本中隐私信息的方法和装置
CN113326695A (zh) * 2021-04-26 2021-08-31 东南大学 一种基于迁移学习的情感极性分析方法
CN113656548A (zh) * 2021-08-18 2021-11-16 福州大学 基于数据包络分析的文本分类模型解释方法及系统
CN113657446A (zh) * 2021-07-13 2021-11-16 广东外语外贸大学 多标签情绪分类模型的处理方法、系统和存储介质
CN115203412A (zh) * 2022-07-06 2022-10-18 腾讯科技(深圳)有限公司 情感观点信息分析方法、装置、存储介质及电子设备
CN116522932A (zh) * 2023-06-26 2023-08-01 云目未来科技(湖南)有限公司 一种文本分析方法及系统

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110990837B (zh) * 2020-02-29 2023-03-24 网御安全技术(深圳)有限公司 系统调用行为序列降维方法、系统、设备和存储介质
CN111339305B (zh) * 2020-03-20 2023-04-14 北京中科模识科技有限公司 文本分类方法、装置、电子设备及存储介质
CN113626587B (zh) * 2020-05-08 2024-03-29 武汉金山办公软件有限公司 一种文本类别识别方法、装置、电子设备及介质
CN112084316A (zh) * 2020-09-09 2020-12-15 浙江连信科技有限公司 一种情绪识别模型的训练方法及装置
CN112612878A (zh) * 2020-12-17 2021-04-06 大唐融合通信股份有限公司 一种客服信息提供方法、电子设备及装置

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107391483A (zh) * 2017-07-13 2017-11-24 武汉大学 一种基于卷积神经网络的商品评论数据情感分类方法
CN108108355A (zh) * 2017-12-25 2018-06-01 北京牡丹电子集团有限责任公司数字电视技术中心 基于深度学习的文本情感分析方法和系统
US20180246959A1 (en) * 2015-09-08 2018-08-30 Stefano Maria Iacus Isa: a fast scalable and accurate algorithm for supervised opinion analysis
CN109284376A (zh) * 2018-09-10 2019-01-29 成都信息工程大学 基于领域自适应的跨领域新闻数据情感分析方法
CN109857864A (zh) * 2019-01-07 2019-06-07 平安科技(深圳)有限公司 文本情感分类方法、装置、计算机设备及存储介质
CN110209824A (zh) * 2019-06-13 2019-09-06 中国科学院自动化研究所 基于组合模型的文本情感分析方法、系统、装置

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105868178B (zh) * 2016-03-28 2018-07-17 浙江大学 一种基于短语主题建模的多文档自动摘要生成方法
CN106844424B (zh) * 2016-12-09 2020-11-03 宁波大学 一种基于lda的文本分类方法
CN109299263B (zh) * 2018-10-10 2021-01-05 上海观安信息技术股份有限公司 文本分类方法、电子设备

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20180246959A1 (en) * 2015-09-08 2018-08-30 Stefano Maria Iacus Isa: a fast scalable and accurate algorithm for supervised opinion analysis
CN107391483A (zh) * 2017-07-13 2017-11-24 武汉大学 一种基于卷积神经网络的商品评论数据情感分类方法
CN108108355A (zh) * 2017-12-25 2018-06-01 北京牡丹电子集团有限责任公司数字电视技术中心 基于深度学习的文本情感分析方法和系统
CN109284376A (zh) * 2018-09-10 2019-01-29 成都信息工程大学 基于领域自适应的跨领域新闻数据情感分析方法
CN109857864A (zh) * 2019-01-07 2019-06-07 平安科技(深圳)有限公司 文本情感分类方法、装置、计算机设备及存储介质
CN110209824A (zh) * 2019-06-13 2019-09-06 中国科学院自动化研究所 基于组合模型的文本情感分析方法、系统、装置

Cited By (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113326695A (zh) * 2021-04-26 2021-08-31 东南大学 一种基于迁移学习的情感极性分析方法
CN113326695B (zh) * 2021-04-26 2024-04-26 东南大学 一种基于迁移学习的情感极性分析方法
CN113283232A (zh) * 2021-05-31 2021-08-20 支付宝(杭州)信息技术有限公司 自动解析文本中隐私信息的方法和装置
CN113657446A (zh) * 2021-07-13 2021-11-16 广东外语外贸大学 多标签情绪分类模型的处理方法、系统和存储介质
CN113656548A (zh) * 2021-08-18 2021-11-16 福州大学 基于数据包络分析的文本分类模型解释方法及系统
CN113656548B (zh) * 2021-08-18 2023-08-04 福州大学 基于数据包络分析的文本分类模型解释方法及系统
CN115203412A (zh) * 2022-07-06 2022-10-18 腾讯科技(深圳)有限公司 情感观点信息分析方法、装置、存储介质及电子设备
CN115203412B (zh) * 2022-07-06 2024-02-20 腾讯科技(深圳)有限公司 情感观点信息分析方法、装置、存储介质及电子设备
CN116522932A (zh) * 2023-06-26 2023-08-01 云目未来科技(湖南)有限公司 一种文本分析方法及系统
CN116522932B (zh) * 2023-06-26 2023-09-19 云目未来科技(湖南)有限公司 一种文本分析方法及系统

Also Published As

Publication number Publication date
CN110807314A (zh) 2020-02-18

Similar Documents

Publication Publication Date Title
WO2021051598A1 (zh) 文本情感分析模型训练方法、装置、设备及可读存储介质
CN110188343B (zh) 基于融合注意力网络的多模态情感识别方法
Das et al. Sign language recognition using deep learning on custom processed static gesture images
US10021276B1 (en) Method and device for processing video, electronic device and storage medium
WO2020147395A1 (zh) 基于情感的文本分类处理方法、装置和计算机设备
US11113323B2 (en) Answer selection using a compare-aggregate model with language model and condensed similarity information from latent clustering
CN112269868B (zh) 一种基于多任务联合训练的机器阅读理解模型的使用方法
CN112395979B (zh) 基于图像的健康状态识别方法、装置、设备及存储介质
WO2021042505A1 (zh) 基于文字识别技术的笔记生成方法、装置和计算机设备
WO2021139316A1 (zh) 建立表情识别模型方法、装置、计算机设备及存储介质
CN110083832B (zh) 文章转载关系的识别方法、装置、设备及可读存储介质
CN108090099B (zh) 一种文本处理方法及装置
WO2021051586A1 (zh) 面试回答文本的分类方法及装置、电子设备、存储介质
CN113239807B (zh) 训练票据识别模型和票据识别的方法和装置
CN110796089A (zh) 用于训练换脸模型的方法和设备
WO2021127916A1 (zh) 脸部情感识别方法、智能装置和计算机可读存储介质
CN111651606B (zh) 一种文本处理方法、装置及电子设备
CN107818173B (zh) 一种基于向量空间模型的中文虚假评论过滤方法
CN115827995A (zh) 基于大数据分析的社交匹配方法
CN110910388A (zh) 一种基于U-Net和密度估计的癌细胞图像分割方法
CN113255501A (zh) 生成表格识别模型的方法、设备、介质及程序产品
US11756244B1 (en) System and method for handwriting generation
CN115546813A (zh) 一种文档分析方法、装置、存储介质及设备
WO2021217619A1 (zh) 基于标签平滑的语音识别方法、终端及介质
CN114064873A (zh) 保险领域faq知识库构建方法、装置及电子设备

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

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 19946137

Country of ref document: EP

Kind code of ref document: A1