WO2022095376A1 - 方面级别情感分类方法、装置、设备及可读存储介质 - Google Patents

方面级别情感分类方法、装置、设备及可读存储介质 Download PDF

Info

Publication number
WO2022095376A1
WO2022095376A1 PCT/CN2021/091198 CN2021091198W WO2022095376A1 WO 2022095376 A1 WO2022095376 A1 WO 2022095376A1 CN 2021091198 W CN2021091198 W CN 2021091198W WO 2022095376 A1 WO2022095376 A1 WO 2022095376A1
Authority
WO
WIPO (PCT)
Prior art keywords
token
sequence
probability
text
classified
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Ceased
Application number
PCT/CN2021/091198
Other languages
English (en)
French (fr)
Inventor
刘剑
杨海钦
姚晓远
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ping An Technology Shenzhen Co Ltd
Original Assignee
Ping An Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ping An Technology Shenzhen Co Ltd filed Critical Ping An Technology Shenzhen Co Ltd
Publication of WO2022095376A1 publication Critical patent/WO2022095376A1/zh
Anticipated expiration legal-status Critical
Ceased legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/30Semantic analysis
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; 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 OR CALCULATING; 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/3346Query execution using probabilistic model
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; 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/35Clustering; Classification
    • G06F16/353Clustering; Classification into predefined classes
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; 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 OR CALCULATING; 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, and in particular, to an aspect-level emotion classification method, apparatus, device, and readable storage medium.
  • Sentiment analysis is a process of analyzing, processing, summarizing and reasoning on subjective texts with emotional color.
  • an aspect-level sentiment analysis is proposed to refine the granularity of the analysis. to the aspect level; the inventor realizes that in the prior art, most of the neural network models are trained by means of supervised learning to obtain sentiment classifiers for sentiment analysis at the aspect level, and inevitably, the neural network is trained by means of supervised learning.
  • a large number of labeled training samples are required in the process of modeling, and the lack of labeled training samples has become the main obstacle to obtaining sentiment classifiers.
  • the purpose of the present application is to provide an aspect-level sentiment classification method, apparatus, device, and readable storage medium, which can realize cross-domain aspect-level sentiment analysis.
  • an aspect-level sentiment classification method comprising:
  • the text to be classified and convert the keywords contained in the text to be classified into tokens to form a token sequence; wherein, the token sequence includes T tokens;
  • the probability matrix is a matrix of T columns and (T+1) rows, and each column of the probability matrix represents A token, the first row of the probability matrix represents the probability value of each token belonging to the aspect term, and the second row to (T+1)th row represent that each token belongs to the emotional order mapped to the corresponding aspect term. the probability value of the card;
  • a preset Transformer model and a classifier are used to determine the emotion type corresponding to the text to be classified.
  • the present application also provides an aspect-level emotion classification device, the device comprising:
  • an acquisition module configured to acquire the text to be classified, and convert the keywords contained in the text to be classified into tokens to form a token sequence; wherein the token sequence includes T tokens;
  • an input module configured to input the token sequence into a preset token processing model to obtain a probability matrix; wherein the probability matrix is a matrix of T columns and (T+1) rows, and the probability matrix Each column of the probability matrix represents a token, the first row of the probability matrix represents the probability value of each token belonging to the aspect term, the second row to the (T+1)th row represent that each token belongs to the corresponding aspect term The probability value of the mapped sentiment token;
  • the processing module is configured to set the token whose probability value belonging to the aspect term is greater than the preset threshold as the target token, and set the probability of the second row to the (T+1)th row corresponding to the target token values form a sequence of sentiment token probabilities;
  • the determining module determines the emotion type corresponding to the text to be classified by using a preset Transformer model and a classifier based on the emotion token probability sequence.
  • the present application also provides a computer device, the computer device specifically includes: a memory, a processor, and a computer program stored in the memory and running on the processor, the processor executes the computer program. The following steps are implemented when the computer program is described:
  • the text to be classified and convert the keywords contained in the text to be classified into tokens to form a token sequence; wherein, the token sequence includes T tokens;
  • the probability matrix is a matrix of T columns and (T+1) rows, and each column of the probability matrix represents A token, the first row of the probability matrix represents the probability value of each token belonging to the aspect term, and the second row to (T+1)th row represent that each token belongs to the emotional order mapped to the corresponding aspect term. the probability value of the card;
  • a preset Transformer model and a classifier are used to determine the emotion type corresponding to the text to be classified.
  • the present application also provides a computer-readable storage medium on which a computer program is stored, and the computer program implements the following steps when executed by a processor:
  • the text to be classified and convert the keywords contained in the text to be classified into tokens to form a token sequence; wherein, the token sequence includes T tokens;
  • the probability matrix is a matrix of T columns and (T+1) rows, and each column of the probability matrix represents A token, the first row of the probability matrix represents the probability value of each token belonging to the aspect term, and the second row to (T+1)th row represent that each token belongs to the emotional order mapped to the corresponding aspect term. the probability value of the card;
  • a preset Transformer model and a classifier are used to determine the emotion type corresponding to the text to be classified.
  • the aspect-level sentiment classification method, device, device and readable storage medium provided by this application, by using the powerful feature representation capability of the pre-training model, propose a cross-domain aspect-level sentiment analysis method based on the pre-training model, and the pre-training
  • the structure of the model is relatively simple and can be widely applied to other similar tasks; this application sets a threshold so that aspect terms larger than the threshold can participate in the subsequent aspect-level sentiment analysis tasks, thereby effectively reducing the amount of computation and further improving the model’s performance. performance.
  • FIG. 1 is an optional schematic flowchart of the aspect-level sentiment classification method provided in Embodiment 1;
  • Embodiment 2 is a schematic diagram of an emotion classification model provided by Embodiment 1;
  • Embodiment 3 is a schematic diagram of an optional composition structure of the aspect-level emotion classification device provided in Embodiment 3;
  • FIG. 4 is a schematic diagram of an optional hardware architecture of the computer device provided in the fourth embodiment.
  • the embodiment of the present application provides an aspect-level emotion classification method, as shown in FIG. 1 , the method specifically includes the following steps:
  • Step S101 Acquire the text to be classified, and convert the keywords contained in the text to be classified into tokens to form a token sequence; wherein the token sequence includes T tokens.
  • step S101 includes:
  • Step A1 performing word segmentation processing on the text to be classified to obtain T keywords contained in the text to be classified;
  • Step A2 encode each keyword separately to obtain the token of each keyword
  • Step A3 Composing all tokens into the token sequence.
  • obtain the text to be classified entered by the user: "The service of this restaurant is very good, and the food is also very good”; perform word segmentation on the text to be classified to obtain the keywords: this, restaurant, of, service, Very good, and, meal, also, very good; use One-Hot encoding to encode each keyword into a corresponding token, so as to form a token sequence X ⁇ x 1 , x 2 according to the tokens of all keywords ,...,x T ⁇ .
  • Step S102 Input the token sequence into a preset token processing model to obtain a probability matrix; wherein, the probability matrix is a matrix of T columns and (T+1) rows, and each probability matrix is One column represents a token, the first row of the probability matrix represents the probability value of each token belonging to the aspect term, the second row to (T+1)th row represent that each token belongs to the mapping with the corresponding aspect term The probability value of the sentiment token.
  • the token processing model includes: a BERT model, a fully connected layer and a softmax function.
  • step S102 includes:
  • Step B1 Input the token sequence into the BERT (Bidirectional Encoder Representation from Transformers) model in the token processing model, obtain the corresponding feature representation of each token that integrates the information of the front and back tokens, and convert all the tokens into the BERT (Bidirectional Encoder Representation from Transformers) model
  • the feature representation constitutes a feature representation sequence
  • This embodiment introduces a BERT module as a pre-training word embedding layer, and the BERT module is a pre-training model capable of context awareness obtained by pre-training on a large-scale data set.
  • Step B2 Input the feature representation sequence into the fully connected layer in the token processing model, and normalize the output of the fully connected layer through a softmax function to obtain the probability matrix;
  • the above feature representation sequence HL is input to a task-specific neural architecture layer, preferably, the neural architecture layer is a fully connected layer; in addition, the neural architecture layer also includes a softmax function model for probabilistic The normalization operation of , that is, output T+1 dimensions corresponding to each token x i , thus forming a T ⁇ (T+1) probability matrix; where the first row of the probability matrix represents each token x The probability that i belongs to the aspect term; for the target token x i , the second row to the T+1th row of the probability matrix indicates that the tokens x 1 , x 2 ,...,x T belong to the aspect with the target token x i , respectively The probability of the emotional token corresponding to the term, so that each token xi in the token sequence is probabilistically marked using the above T+1 dimensions.
  • Step S103 Set the token whose probability value belonging to the aspect term is greater than the preset threshold as the target token, and form the probability value of the second row to the (T+1)th row corresponding to the target token. Sentiment token probability sequence.
  • the token sequence filter out target tokens whose probability value belonging to an aspect term is greater than a preset threshold. If the probability of any token belonging to an aspect term is greater than the preset threshold, it is proved that the token has a probability of belonging to an aspect term.
  • Step S104 Based on the emotion token probability sequence, using a preset Transformer model and a classifier, determine the emotion type corresponding to the text to be classified.
  • step S104 includes:
  • Step C1 Multiplying the feature representation sequence and the emotion token probability sequence by elements at the vector level to obtain a representation result
  • Step C2 Input the characterization results into the Transformer model and the classifier in turn to obtain the emotion type corresponding to the text to be classified.
  • the sentiment analysis task is performed according to the sentiment token probability sequence of the target token.
  • the feature representation sequence incorporating the context is Perform element multiplication operation at the vector level with the emotional token probability sequence of the target token to obtain the final representation result, use the Transformer model to perform feature transformation, and convert the final representation result into the target representation sequence fused with sentence semantics , further, using the fully connected layer to integrate the converted target representation sequence to obtain a target representation that can characterize the token sequence, and finally, input the target representation to the classifier, and filter to obtain the emotion corresponding to the token sequence category.
  • the method also includes:
  • Step D1 obtaining a sample text set; wherein, each sample text in the sample text set is marked with a corresponding aspect term and emotion type;
  • Step D2 Train the initial neural network model based on the sample text set, so as to modify each parameter in the initial neural network model to obtain a sentiment classification model; wherein, the sentiment classification model includes: a token processing model , Transformer models and classifiers.
  • FIG. 2 it is a schematic diagram of the sentiment classification model. It can be seen from FIG. 2 that the token sequence X formed according to the text to be classified is firstly input into the BERT model in the token processing model, so as to obtain a fusion of the front and rear commands.
  • the feature representation sequence HL of the card information is successively input into the fully connected layer (FC Layer) and the softmax function (Softmax Layer) in the token processing model, to obtain the probability matrix, and according to The probability matrix obtains the emotional token probability sequence P; then the feature representation sequence HL and the emotional token probability sequence P are multiplied by the elements of the vector level to obtain the characterization result; finally, the characterization results are sequentially Input into the Transformer model (Transformer Block) and the classifier (Classifier Layer) to obtain the emotion type corresponding to the text to be classified.
  • the BERT model includes: Token Embedding, Segment Embedding, Position Embedding, and L Transformer Blocks.
  • the embodiment of the present application provides an aspect-level emotion classification method, and the method specifically includes the following steps:
  • step S1 a sample text set is obtained, and the neural network model is trained by using the sample text set.
  • the BERT module receives the token sequence X, it outputs a feature representation sequence fused with context in, is the feature representation corresponding to token x i , i ⁇ [1,T].
  • the feature representation sequence HL is input to the task-specific neural architecture layer, which includes a softmax function model for normalizing the probability, that is, outputting the T+1 corresponding to each token xi .
  • the first dimension represents the probability that the token xi belongs to the aspect term
  • the second to T+1th dimensions represent that each token xi in the token sequence X belongs to the aspect term corresponding to the Probability of sentiment tokens.
  • Step S2 inputting the token sequence into the token processing model, and generating a probability mark corresponding to each token;
  • the feature representation sequence HL is input to the task-specific neural architecture layer, which includes a softmax function model for probability normalization operation, that is, output T+1 dimensions corresponding to each token xi , that is, a T ⁇ (T+1) matrix; where the first row of the matrix represents the probability that each token xi belongs to the aspect term, The second row to the T+1th row respectively represent the probability that each token xi in the token sequence X belongs to the emotional token corresponding to the term in this aspect, and use the above T+1 dimensions to evaluate each token in the token sequence.
  • the tokens xi are marked with probability.
  • step S3 a target token is selected from the token sequence, and sentiment analysis is performed on the target token to complete the training of the Transformer model and the classifier in the field corresponding to the token sequence.
  • a probability threshold is preset, and in the token sequence, the target token whose probability of belonging to an aspect term is greater than the preset probability threshold is screened out.
  • the threshold is set, it is proved that the token is an aspect term; for example, a token sequence of ⁇ this, restaurant, , service, good, and, meal, also, good ⁇ , its corresponding aspect term makes The tokens are "service” and "meal”.
  • the probability that the token corresponding to the token belongs to the aspect term output by the neural network model in this embodiment is greater than the preset probability threshold.
  • the target token is selected, calculation is performed according to the probability of the emotion token belonging to the aspect term corresponding to each token xi in the probability token of the target token.
  • the feature representation sequence fused with the context obtained in step S2 The probability of the sentiment token belonging to the aspect term corresponding to each token xi in the probability token of the target token is multiplied by the elements of the vector level to obtain the final feature representation, and the feature representation sequence is used by the Transformer module. Perform feature transformation to convert the final feature representation sequence into a feature representation sequence fused with sentence semantics. Further, use the fully connected layer to integrate the feature representation sequence to obtain a feature representation that can characterize the token sequence. Finally, the feature representation Input to the classifier, and filter to obtain the sentiment classification corresponding to the token sequence.
  • step S4 the text to be classified is acquired, the sentiment classification model is used to perform sentiment classification, and the sentiment classification category corresponding to the text to be classified is screened.
  • Obtain the text to be classified entered by the user, and split the text to be classified into a token sequence X ⁇ x 1 , x 2 ,..., x T ⁇ composed of several tokens; for example, the text to be classified entered by the customer is "The service at this restaurant is good, and the meal is good", then splits the text to be classified into a sequence of tokens ⁇ this, restaurant, of, service, good, and, meal, also, good ⁇ .
  • the above token sequence is input into the token processing model composed of the BERT model, and a feature representation sequence that integrates the context is output. in, is the feature representation corresponding to token x i , i ⁇ [1,T].
  • the above-mentioned feature representation sequence HL is input to the task-specific neural architecture layer, which includes a softmax function model for normalizing the probability, that is, outputting the T+ corresponding to each token xi . 1 dimension, that is, a T ⁇ (T+1) matrix; the first row of the matrix represents the probability that each token x i belongs to the aspect term, and the second to T+1th rows represent the order The probability that each token xi in the card sequence X belongs to the emotion token corresponding to the term in this aspect, and the above T+1 dimension is used to mark each token xi in the token sequence with probability.
  • the task-specific neural architecture layer which includes a softmax function model for normalizing the probability, that is, outputting the T+ corresponding to each token xi . 1 dimension, that is, a T ⁇ (T+1) matrix; the first row of the matrix represents the probability that each token x i belongs to the aspect term, and the second to T+1th rows represent the order The probability that each token xi in the
  • a target token whose probability of belonging to an aspect term is greater than the preset probability threshold is selected, and if the probability mark of the token shows that the probability of belonging to an aspect term is greater than the preset threshold, then Prove that the token is an aspect term; for example, a token sequence of ⁇ this, restaurant, of, service, good, and, meal, also, good ⁇ with a preset probability threshold of 0.5, and in the current order In the card sequence, only the probability of tokens "service” and "meal” belonging to aspect terms is greater than the preset probability threshold of 0.5, then the output aspect term tokens are "service" and "meal".
  • the target token is selected, calculation is performed according to the probability of the emotion token belonging to the aspect term corresponding to each token xi in the token sequence X in the probability token of the target token.
  • the feature representation sequence fused with the context will be obtained
  • the probability of the emotional token belonging to the aspect term corresponding to each token xi in the probability token of the target token is multiplied by the elements of the vector level to obtain the final feature representation, and the feature representation sequence is used by the Transformer model.
  • the fully connected layer is used to integrate the converted feature representation sequence to obtain a feature representation that can characterize the token sequence.
  • the feature representation is input to the classifier, and the sentiment classification category corresponding to the token sequence is obtained by screening.
  • the embodiment of the present application provides an aspect-level emotion classification device, as shown in FIG. 3 , the device specifically includes the following components:
  • the obtaining module 301 is configured to obtain the text to be classified, and convert the keywords contained in the text to be classified into tokens to form a token sequence; wherein, the token sequence includes T tokens;
  • the input module 302 is configured to input the token sequence into a preset token processing model to obtain a probability matrix; wherein, the probability matrix is a matrix of T columns and (T+1) rows, and the probability Each column of the matrix represents a token, the first row of the probability matrix represents the probability value of each token belonging to the aspect term, and the second to (T+1)th rows represent that each token belongs to the corresponding aspect.
  • the processing module 303 is configured to set the token whose probability value belonging to the aspect term is greater than the preset threshold as the target token, and set the tokens corresponding to the target token in the second row to the (T+1)th row.
  • the probability values form the emotional token probability sequence
  • a determination module 304 is configured to determine an emotion type corresponding to the text to be classified by using a preset Transformer model and a classifier based on the emotion token probability sequence.
  • the acquisition module 301 is used for:
  • the input module 302 is used for:
  • the feature representation sequence is input into the fully connected layer in the token processing model, and the output of the fully connected layer is normalized by a softmax function to obtain the probability matrix.
  • determining module 304 is used for:
  • the characterization results are sequentially input into the Transformer model and the classifier to obtain the emotion type corresponding to the text to be classified.
  • the device also includes:
  • each sample text in the sample text set is marked with a corresponding aspect term and sentiment type;
  • the initial neural network model is trained based on the sample text set, so as to modify each parameter in the initial neural network model to obtain a sentiment classification model; wherein, the sentiment classification model includes: a token processing model, a Transformer model and classifier.
  • This embodiment also provides a computer device, such as a smart phone, a tablet computer, a notebook computer, a desktop computer, a rack server, a blade server, a tower server or a cabinet server (including independent servers, or A server cluster composed of multiple servers), etc.
  • the computer device 40 in this embodiment at least includes but is not limited to: a memory 401 and a processor 402 that can be communicatively connected to each other through a system bus.
  • FIG. 4 only shows the computer device 40 having components 401-402, but it should be understood that implementation of all of the illustrated components is not required, and more or fewer components may be implemented instead.
  • the memory 401 (that is, a readable storage medium) includes a flash memory, a hard disk, a multimedia card, a card-type memory (eg, SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), Programmable Read Only Memory (PROM), Magnetic Memory, Magnetic Disk, Optical Disk, etc.
  • the memory 401 may be an internal storage unit of the computer device 40 , such as a hard disk or a memory of the computer device 40 .
  • the memory 401 may also be an external storage device of the computer device 40, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, flash memory card (Flash Card), etc.
  • the memory 401 may also include both the internal storage unit of the computer device 40 and its external storage device.
  • the memory 401 is generally used to store the operating system and various application software installed on the computer device 40 .
  • the memory 401 can also be used to temporarily store various types of data that have been output or will be output.
  • the processor 402 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chips in some embodiments.
  • the processor 402 is typically used to control the overall operation of the computer device 40 .
  • the processor 402 is configured to execute the program of the aspect-level sentiment classification method stored in the processor 402, and the following steps are implemented when the program of the aspect-level sentiment classification method is executed:
  • the text to be classified and convert the keywords contained in the text to be classified into tokens to form a token sequence; wherein, the token sequence includes T tokens;
  • the probability matrix is a matrix of T columns and (T+1) rows, and each column of the probability matrix represents A token, the first row of the probability matrix represents the probability value of each token belonging to the aspect term, and the second row to (T+1)th row represent that each token belongs to the emotional order mapped to the corresponding aspect term. the probability value of the card;
  • a preset Transformer model and a classifier are used to determine the emotion type corresponding to the text to be classified.
  • This embodiment also provides a computer-readable storage medium, such as a flash memory, a hard disk, a multimedia card, a card-type memory (for example, SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), only Read-Only Memory (ROM), Electrically Erasable Programmable Read-Only Memory (EEPROM), Programmable Read-Only Memory (PROM), Magnetic Memory, Magnetic Disk, Optical Disc, Server, App Store, etc., the computer-readable storage medium It can be non-volatile or volatile, and a computer program is stored thereon, and when the computer program is executed by the processor, the following method steps are implemented:
  • the text to be classified and convert the keywords contained in the text to be classified into tokens to form a token sequence; wherein, the token sequence includes T tokens;
  • the probability matrix is a matrix of T columns and (T+1) rows, and each column of the probability matrix represents A token, the first row of the probability matrix represents the probability value of each token belonging to the aspect term, and the second row to (T+1)th row represent that each token belongs to the emotional order mapped to the corresponding aspect term. the probability value of the card;
  • a preset Transformer model and a classifier are used to determine the emotion type corresponding to the text to be classified.

Landscapes

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

Abstract

一种方面级别情感分类方法、装置、设备及可读存储介质,所述方法包括:获取待分类文本,并将包含在所述待分类文本中的关键词转化为令牌,以形成令牌序列;其中,所述令牌序列包括T个令牌(S101);将所述令牌序列输入到预设的令牌处理模型中,以得到概率矩阵;其中,所述概率矩阵为T列、(T+1)行的矩阵(S102);将所述属于方面术语的概率值大于预设阈值的令牌设置为目标令牌,并将与所述目标令牌对应的第二行至第(T+1)行的概率值形成情感令牌概率序列(S103);基于所述情感令牌概率序列,利用预设的Transformer模型和分类器,确定出与所述待分类文本对应的情感类型(S104);所述方法能够实现跨领域的方面级别情感分析。

Description

方面级别情感分类方法、装置、设备及可读存储介质
相关申请的交叉引用
本申请申明享有2020年11月06日递交的申请号为202011227233.7、名称为“方面级别情感分类方法、装置、设备及可读存储介质”的中国专利申请的优先权,该中国专利申请的整体内容以参考的方式结合在本申请中。
技术领域
本申请涉及人工智能技术领域,特别涉及一种方面级别情感分类方法、装置、设备及可读存储介质。
背景技术
随着网络社交媒体的崛起,互联网上产生了大量的用户评论信息,这些用户评论信息中表达了各种各样的情感色彩和情感倾向性,通过对用户评论信息进行情感分析,可以了解大众舆论对于某一时事件或产品的看法。
情感分析是一个对带有情感色彩的主观性文本进行分析、处理、归纳和推理的过程,为了充分的获取某文本中各个方面的情感倾向,提出方面级别的情感分析,将分析的粒度细化到方面的级别;发明人意识到,现有技术中大多通过监督学习的方式训练神经网络模型,以获取用于方面级别情感分析的情感分类器,不可避免的,以监督学习的方式训练神经网络模型的过程中需要大量的被标记的训练样本,缺乏被标记的训练样本成为获取情感分类器的主要障碍。
因此,如何避免获取情感分类器无足够被标记的训练样本的障碍,如何利用预训练模型的强大特征表征能力,实现跨领域的方面级别情感分析,是本领域技术人员需要解决的问题。
发明内容
本申请的目的在于提供一种方面级别情感分类方法、装置、设备及可读存储介质,能够实现跨领域的方面级别情感分析。
根据本申请的一个方面,提供了一种方面级别情感分类方法,所述方法包括:
获取待分类文本,并将包含在所述待分类文本中的关键词转化为令牌,以形成令牌序列;其中,所述令牌序列包括T个令牌;
将所述令牌序列输入到预设的令牌处理模型中,以得到概率矩阵;其中,所述概率矩阵为T列、(T+1)行的矩阵,所述概率矩阵的每一列表征一种令牌,所述概率矩阵的第一行表征各个令牌属于方面术语的概率值、第二行至第(T+1)行表征每个令牌属于与对应方面术语相映射的情感令牌的概率值;
将所述属于方面术语的概率值大于预设阈值的令牌设置为目标令牌,并将与所述目标令牌对应的第二行至第(T+1)行的概率值形成情感令牌概率序列;
基于所述情感令牌概率序列,利用预设的Transformer模型和分类器,确定出与所述待分类文本对应的情感类型。
为了实现上述目的,本申请还提供一种方面级别情感分类装置,所述装置包括:
获取模块,用于获取待分类文本,并将包含在所述待分类文本中的关键词转化为令牌,以形成令牌序列;其中,所述令牌序列包括T个令牌;
输入模块,用于将所述令牌序列输入到预设的令牌处理模型中,以得到概率矩阵;其中,所述概率矩阵为T列、(T+1)行的矩阵,所述概率矩阵的每一列表征一种令牌,所述概率矩阵的第一行表征各个令牌属于方面术语的概率值、第二行至第(T+1)行表征每个令 牌属于与对应方面术语相映射的情感令牌的概率值;
处理模块,用于将所述属于方面术语的概率值大于预设阈值的令牌设置为目标令牌,并将与所述目标令牌对应的第二行至第(T+1)行的概率值形成情感令牌概率序列;
确定模块,基于所述情感令牌概率序列,利用预设的Transformer模型和分类器,确定出与所述待分类文本对应的情感类型。
为了实现上述目的,本申请还提供一种计算机设备,该计算机设备具体包括:存储器、处理器以及存储在所述存储器上并可在所述处理器上运行的计算机程序,所述处理器执行所述计算机程序时实现以下步骤:
获取待分类文本,并将包含在所述待分类文本中的关键词转化为令牌,以形成令牌序列;其中,所述令牌序列包括T个令牌;
将所述令牌序列输入到预设的令牌处理模型中,以得到概率矩阵;其中,所述概率矩阵为T列、(T+1)行的矩阵,所述概率矩阵的每一列表征一种令牌,所述概率矩阵的第一行表征各个令牌属于方面术语的概率值、第二行至第(T+1)行表征每个令牌属于与对应方面术语相映射的情感令牌的概率值;
将所述属于方面术语的概率值大于预设阈值的令牌设置为目标令牌,并将与所述目标令牌对应的第二行至第(T+1)行的概率值形成情感令牌概率序列;
基于所述情感令牌概率序列,利用预设的Transformer模型和分类器,确定出与所述待分类文本对应的情感类型。
为了实现上述目的,本申请还提供一种计算机可读存储介质,其上存储有计算机程序,所述计算机程序被处理器执行时实现以下步骤:
获取待分类文本,并将包含在所述待分类文本中的关键词转化为令牌,以形成令牌序列;其中,所述令牌序列包括T个令牌;
将所述令牌序列输入到预设的令牌处理模型中,以得到概率矩阵;其中,所述概率矩阵为T列、(T+1)行的矩阵,所述概率矩阵的每一列表征一种令牌,所述概率矩阵的第一行表征各个令牌属于方面术语的概率值、第二行至第(T+1)行表征每个令牌属于与对应方面术语相映射的情感令牌的概率值;
将所述属于方面术语的概率值大于预设阈值的令牌设置为目标令牌,并将与所述目标令牌对应的第二行至第(T+1)行的概率值形成情感令牌概率序列;
基于所述情感令牌概率序列,利用预设的Transformer模型和分类器,确定出与所述待分类文本对应的情感类型。
本申请提供的方面级别情感分类方法、装置、设备及可读存储介质,通过利用预训练模型强大的特征表征能力,提出了一种基于预训练模型的跨领域方面级别情感分析方法,且预训练模型的结构比较简单,能够广泛应用到其他相似任务中;本申请通过设置阈值,使得大于阈值的方面术语才能参与后续的方面级别情感分析的任务,从而有效减少了计算量,能够进一步提升模型的性能。
附图说明
通过阅读下文优选实施方式的详细描述,各种其他的优点和益处对于本领域普通技术人员将变得清楚明了。附图仅用于示出优选实施方式的目的,而并不认为是对本申请的限制。而且在整个附图中,用相同的参考符号表示相同的部件。在附图中:
图1为实施例一提供的方面级别情感分类方法的一种可选的流程示意图;
图2为实施例一提供的情感分类模型的示意图;
图3为实施例三提供的方面级别情感分类装置的一种可选的组成结构示意图;
图4为实施例四提供的计算机设备的一种可选的硬件架构示意图。
具体实施方式
为了使本申请的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本 申请进行进一步详细说明。应当理解,此处所描述的具体实施例仅用以解释本申请,并不用于限定本申请。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。
实施例一
本申请实施例提供了一种方面级别情感分类方法,如图1所示,该方法具体包括以下步骤:
步骤S101:获取待分类文本,并将包含在所述待分类文本中的关键词转化为令牌,以形成令牌序列;其中,所述令牌序列包括T个令牌。
具体的,步骤S101,包括:
步骤A1:对所述待分类文本进行分词处理,以得到包含在所述待分类文本中的T个关键词;
步骤A2:分别对每个关键词进行编码,以得到每个关键词的令牌;
步骤A3:将所有令牌组成所述令牌序列。
例如,获取用户输入的待分类文本:“这家餐馆的服务很好,并且饭菜也很好”;对所述待分类文本进行分词处理,以得到关键词:这家、餐馆、的、服务、很好、并且、饭菜、也、很好;利用One-Hot编码分别将每个关键词编码为对应的令牌,从而根据所有关键词的令牌形成令牌序列X={x 1,x 2,…,x T}。
步骤S102:将所述令牌序列输入到预设的令牌处理模型中,以得到概率矩阵;其中,所述概率矩阵为T列、(T+1)行的矩阵,所述概率矩阵的每一列表征一种令牌,所述概率矩阵的第一行表征各个令牌属于方面术语的概率值、第二行至第(T+1)行表征每个令牌属于与对应方面术语相映射的情感令牌的概率值。
其中,所述令牌处理模型包括:BERT模型、全连接层和softmax函数。
具体的,步骤S102,包括:
步骤B1:将所述令牌序列输入到所述令牌处理模型中的BERT(Bidirectional Encoder Representation from Transformers)模型中,得到每个令牌对应的融合了前后令牌信息的特征表征,并将所有所述特征表征组成特征表征序列;
例如,将令牌序列X={x 1,x 2,…,x T}输入至由BERT模型构成的预训练词嵌入层中,从而输出了一个融合了上下文的特征表征序列
Figure PCTCN2021091198-appb-000001
其中,
Figure PCTCN2021091198-appb-000002
为令牌x i对应的特征表征,i∈[1,T]。本实施例引入BERT模块作为预训练词嵌入层,该BERT模块是一个通过大规模数据集进行预训练获得的能够进行上下文感知的预训练模型。
步骤B2:将所述特征表征序列输入到所述令牌处理模型中的全连接层中,并通过softmax函数对所述全连接层的输出进行归一化处理,以得到所述概率矩阵;
例如,将上述特征表征序列H L输入至特定于任务的神经体系结构层,优选的,该神经体系结构层为全连接层;此外,该神经体系结构层还包括softmax函数模型,用于进行概率的归一化操作,即输出每一个令牌x i对应的T+1个维度,从而形成一个T×(T+1)的概率矩阵;其中,概率矩阵的第一行表示每个令牌x i属于方面术语的概率;针对目标令牌x i,概率矩阵的第二行至第T+1行则分别表示令牌x 1,x 2,…,x T属于与目标令牌x i的方面术语对应的情感令牌的概率,从而利用上述T+1个维度对令牌序列中每个令牌x i进行概率标记。
步骤S103:将所述属于方面术语的概率值大于预设阈值的令牌设置为目标令牌,并将与所述目标令牌对应的第二行至第(T+1)行的概率值形成情感令牌概率序列。
在令牌序列中,筛选出属于方面术语的概率值大于预设阈值的目标令牌,若任一令牌的概率标记中显示其属于方面术语的概率大于预设阈值时,则证明该令牌为方面术语;例如,一个令牌序列为{这家,餐馆,的,服务,很好,并且,饭菜,也,很好},预设的概率阈值为0.5,而在当前令牌序列中,只有令牌“服务”和“饭菜”属于方面术语的概率大于预设概率阈值0.5,那么输出的目标令牌所对应的方面术语为“服务”和“饭菜”。
步骤S104:基于所述情感令牌概率序列,利用预设的Transformer模型和分类器,确定出与所述待分类文本对应的情感类型。
具体的,步骤S104,包括:
步骤C1:将所述特征表征序列与所述情感令牌概率序列进行向量级别的元素相乘,以得到表征结果;
步骤C2:将所述表征结果依次输入所述Transformer模型和分类器中,以得到与所述待分类文本对应的情感类型。
在从令牌序列中确定出目标令牌之后,根据该目标令牌的情感令牌概率序列去做情感分析任务。具体的,将融合了上下文的特征表征序列
Figure PCTCN2021091198-appb-000003
与目标令牌的情感令牌概率序列进行向量级别的元素相乘运算,获取最终的表征结果,将该表征结果利用Transformer模型进行特征转换,将最终的表征结果转换为融合句子语义的目标表征序列,进一步的,利用全连接层将转换后的目标表征序列进行整合,获得能够表征所述令牌序列的一个目标表征,最后,将目标表征输入至分类器,筛选获得该令牌序列对应的情感类别。
进一步的,所述方法还包括:
步骤D1:获取样本文本集;其中,所述样本文本集中的每个样本文本均标注有对应的方面术语和情感类型;
步骤D2:基于所述样本文本集对初始神经网络模型进行训练,以对所述初始神经网络模型中的各个参数进行修正,得到情感分类模型;其中,所述情感分类模型包括:令牌处理模型、Transformer模型和分类器。
优选的,如图2所示,为情感分类模型的示意图,由图2可知,根据待分类文本形成的令牌序列X先输入到令牌处理模型中的BERT模型中,以得到融合了前后令牌信息的特征表征序列H L;再将所述特征表征序列H L先后输入到令牌处理模型中的全连接层(FC Layer)和softmax函数(Softmax Layer)中,以得到概率矩阵,并根据所述概率矩阵得到情感令牌概率序列P;再将所述特征表征序列H L与所述情感令牌概率序列P进行向量级别的元素相乘,以得到表征结果;最后将所述表征结果先后输入到Transformer模型(Transformer Block)和分类器(Classifier Layer)中,以得到与所述待分类文本对应的情感类型。其中,BERT模型包括:Token Embedding(令牌嵌入)、Segment Embedding(分片嵌入)、Position Embedding(位置嵌入)、以及L个Transformer Block。
实施例二
本申请实施例提供了一种方面级别情感分类方法,该方法具体包括以下步骤:
步骤S1,获取样本文本集,并利用所述样本文本集对神经网络模型进行训练。
在本实施例中,神经网络模型由预训练词嵌入层和神经体系结构层组成;首先将样本文本拆分为若干令牌,即若干词语,并将若干令牌组成令牌序列X={x 1,x 2,…,x T}输入至预训练词嵌入层;其中,本实施例引入BERT模块作为预训练词嵌入层,该BERT模块是一个通过大规模数据集进行预训练获得的能够进行上下文感知的预训练模型。
进一步的,在BERT模块接收了令牌序列X后,输出一个融合了上下文的特征表征序列
Figure PCTCN2021091198-appb-000004
其中,
Figure PCTCN2021091198-appb-000005
为令牌x i对应的特征表征,i∈[1,T]。
进一步的,将特征表征序列H L输入至特定于任务的神经体系结构层,该层包括softmax函数模型,用于进行概率的归一化操作,即输出每一个令牌x i对应的T+1个维度;其中,第一个维度表示该令牌x i属于方面术语的概率,第二至第T+1个维度则表示令牌序列X中的每一个令牌x i属于该方面术语对应的情感令牌的概率。
进一步的,冻结神经网络模型的全部参数,完成用于方面级别情感分析的神经网络模型的微调,以得到令牌处理模型。
步骤S2,将所述令牌序列输入至所述令牌处理模型中,生成每个令牌对应的概率标记;
将令牌序列X={x 1,x 2,…,x T}输入至步骤S1微调后的令牌处理模型中,利用BERT模型,输出一个融合了上下文的特征表征序列
Figure PCTCN2021091198-appb-000006
其中,
Figure PCTCN2021091198-appb-000007
为令牌x i对应的特征表征,i∈[1,T];将特征表征序列H L输入至特定于任务的神经体系结构层,该层包括softmax函数模型,用于进行概率的归一化操作,即输出每一个令牌x i对应的T+1个维度,即一个T×(T+1)的矩阵;其中,矩阵的第一行表示每个令牌x i属于方面术语的概率,第二行至第T+1行则分别表示令牌序列X中的每一个令牌x i属于该方面术语对应的情感令牌的概率,并利用上述T+1个维度对令牌序列中每个令牌x i进行概率标记。
步骤S3,在所述令牌序列中筛选出目标令牌,对所述目标令牌进行情感分析,完成对所述令牌序列对应领域的Transformer模型和分类器的训练。
预先设定一个概率阈值,在令牌序列中,筛选出属于方面术语的概率大于该预设的概率阈值的目标令牌,若任一令牌的概率标记中显示其属于方面术语的概率大于预设阈值时,则证明该令牌为方面术语;例如,一个令牌序列为{这家,餐馆,的,服务,很好,并且,饭菜,也,很好},则其对应的方面术语令牌为“服务”和“饭菜”,自然本实施例中神经网络模型输出的该令牌对应的属于方面术语的概率大于预设概率阈值。
进一步的,在选择完目标令牌后,根据该目标令牌的概率标记中每个令牌x i对应的属于该方面术语的情感令牌的概率进行运算。具体的,将步骤S2中获得融合了上下文的特征表征序列
Figure PCTCN2021091198-appb-000008
与该目标令牌的概率标记中每个令牌x i对应的属于该方面术语的情感令牌的概率进行向量级别的元素相乘运算,获取最终的特征表征,将该特征表征序列利用Transformer模块进行特征转换,将最终的特征表征序列转换为融合句子语义的特征表征序列,进一步的,利用全连接层将特征表征序列进行整合,获得能够表征令牌序列的一个特征表征,最后,将特征表征输入至分类器,筛选获得该令牌序列对应的情感分类。
进一步的,根据上述步骤,完成了针对该令牌序列对应领域的方面级别情感分析的情感分类模型的训练。
步骤S4,获取待分类文本,利用所述情感分类模型进行情感分类,筛选所述待分类文本对应的情感分类类别。
获取用户输入的待分类文本,并将该待分类文本拆分为由若干令牌构成的令牌序列X={x 1,x 2,…,x T};例如,客户输入的待分类文本为“这家餐馆的服务很好,并且饭菜也很好”,则将该待分类文本拆分为令牌序列{这家,餐馆,的,服务,很好,并且,饭菜,也,很好}。
进一步的,将上述令牌序列输入至由BERT模型构成的令牌处理模型中,输出一个融合了上下文的特征表征序列
Figure PCTCN2021091198-appb-000009
其中,
Figure PCTCN2021091198-appb-000010
为令牌x i对应的特征表征,i∈[1,T]。
进一步的,将上述特征表征序列H L输入至特定于任务的神经体系结构层,该层包括softmax函数模型,用于进行概率的归一化操作,即输出每一个令牌x i对应的T+1个维度,即一个T×(T+1)的矩阵;其中,矩阵的第一行表示表示每个令牌x i属于方面术语的概率,第二行至第T+1行则分别表示令牌序列X中的每一个令牌x i属于该方面术语对应的情感令牌的概率,并利用上述T+1个维度对令牌序列中每个令牌x i进行概率标记。
进一步的,在令牌序列中,筛选出属于方面术语的概率大于该预设的概率阈值的目标令牌,若该令牌的概率标记中显示其属于方面术语的概率大于预设阈值时,则证明该令牌为方面术语;例如,一个令牌序列为{这家,餐馆,的,服务,很好,并且,饭菜,也,很好},预设的概率阈值为0.5,而在当前令牌序列中,只有令牌“服务”和“饭菜”属于方面术语的概率大于预设概率阈值0.5,那么输出的方面术语令牌为“服务”和“饭菜”。
进一步的,在选择完目标令牌后,根据该目标令牌的概率标记中令牌序列X中的每一个令牌x i对应的属于该方面术语的情感令牌的概率进行运算。具体的,将获得融合了上下文的特征表征序列
Figure PCTCN2021091198-appb-000011
与该目标令牌的概率标记中每个令牌x i对应的属于该 方面术语的情感令牌的概率进行向量级别的元素相乘运算,获取最终的特征表征,将该特征表征序列利用Transformer模型进行特征转换,将最终的特征表征序列转换为融合句子语义的特征表征序列,进一步的,利用全连接层将转换后的特征表征序列进行整合,获得能够表征令牌序列的一个特征表征,最后,将特征表征输入至分类器,筛选获得该令牌序列对应的情感分类类别。
实施例三
本申请实施例提供了一种方面级别情感分类装置,如图3所示,该装置具体包括以下组成部分:
获取模块301,用于获取待分类文本,并将包含在所述待分类文本中的关键词转化为令牌,以形成令牌序列;其中,所述令牌序列包括T个令牌;
输入模块302,用于将所述令牌序列输入到预设的令牌处理模型中,以得到概率矩阵;其中,所述概率矩阵为T列、(T+1)行的矩阵,所述概率矩阵的每一列表征一种令牌,所述概率矩阵的第一行表征各个令牌属于方面术语的概率值、第二行至第(T+1)行表征每个令牌属于与对应方面术语相映射的情感令牌的概率值;
处理模块303,用于将所述属于方面术语的概率值大于预设阈值的令牌设置为目标令牌,并将与所述目标令牌对应的第二行至第(T+1)行的概率值形成情感令牌概率序列;
确定模块304,用于基于所述情感令牌概率序列,利用预设的Transformer模型和分类器,确定出与所述待分类文本对应的情感类型。
具体的,获取模块301,用于:
对所述待分类文本进行分词处理,以得到包含在所述待分类文本中的T个关键词;
分别对每个关键词进行编码,以得到每个关键词的令牌;
将所有令牌组成所述令牌序列。
进一步的,输入模块302,用于:
将所述令牌序列输入到所述令牌处理模型中的BERT模型中,得到每个令牌对应的融合了前后令牌信息的特征表征,并将所有所述特征表征组成特征表征序列;
将所述特征表征序列输入到所述令牌处理模型中的全连接层中,并通过softmax函数对所述全连接层的输出进行归一化处理,以得到所述概率矩阵。
进一步的,确定模块304,用于:
将所述特征表征序列与所述情感令牌概率序列进行向量级别的元素相乘,以得到表征结果;
将所述表征结果依次输入所述Transformer模型和分类器中,以得到与所述待分类文本对应的情感类型。
更进一步的,所述装置还包括:
训练模块,用于
获取样本文本集;其中,所述样本文本集中的每个样本文本均标注有对应的方面术语和情感类型;
基于所述样本文本集对初始神经网络模型进行训练,以对所述初始神经网络模型中的各个参数进行修正,得到情感分类模型;其中,所述情感分类模型包括:令牌处理模型、Transformer模型和分类器。
实施例四
本实施例还提供一种计算机设备,如可以执行程序的智能手机、平板电脑、笔记本电脑、台式计算机、机架式服务器、刀片式服务器、塔式服务器或机柜式服务器(包括独立的服务器,或者多个服务器所组成的服务器集群)等。如图4所示,本实施例的计算机设 备40至少包括但不限于:可通过系统总线相互通信连接的存储器401、处理器402。需要指出的是,图4仅示出了具有组件401-402的计算机设备40,但是应理解的是,并不要求实施所有示出的组件,可以替代的实施更多或者更少的组件。
本实施例中,存储器401(即可读存储介质)包括闪存、硬盘、多媒体卡、卡型存储器(例如,SD或DX存储器等)、随机访问存储器(RAM)、静态随机访问存储器(SRAM)、只读存储器(ROM)、电可擦除可编程只读存储器(EEPROM)、可编程只读存储器(PROM)、磁性存储器、磁盘、光盘等。在一些实施例中,存储器401可以是计算机设备40的内部存储单元,例如该计算机设备40的硬盘或内存。在另一些实施例中,存储器401也可以是计算机设备40的外部存储设备,例如该计算机设备40上配备的插接式硬盘,智能存储卡(Smart Media Card,SMC),安全数字(Secure Digital,SD)卡,闪存卡(Flash Card)等。当然,存储器401还可以既包括计算机设备40的内部存储单元也包括其外部存储设备。在本实施例中,存储器401通常用于存储安装于计算机设备40的操作系统和各类应用软件。此外,存储器401还可以用于暂时地存储已经输出或者将要输出的各类数据。
处理器402在一些实施例中可以是中央处理器(Central Processing Unit,CPU)、控制器、微控制器、微处理器、或其他数据处理芯片。该处理器402通常用于控制计算机设备40的总体操作。
具体的,在本实施例中,处理器402用于执行处理器402中存储的方面级别情感分类方法的程序,所述方面级别情感分类方法的程序被执行时实现如下步骤:
获取待分类文本,并将包含在所述待分类文本中的关键词转化为令牌,以形成令牌序列;其中,所述令牌序列包括T个令牌;
将所述令牌序列输入到预设的令牌处理模型中,以得到概率矩阵;其中,所述概率矩阵为T列、(T+1)行的矩阵,所述概率矩阵的每一列表征一种令牌,所述概率矩阵的第一行表征各个令牌属于方面术语的概率值、第二行至第(T+1)行表征每个令牌属于与对应方面术语相映射的情感令牌的概率值;
将所述属于方面术语的概率值大于预设阈值的令牌设置为目标令牌,并将与所述目标令牌对应的第二行至第(T+1)行的概率值形成情感令牌概率序列;
基于所述情感令牌概率序列,利用预设的Transformer模型和分类器,确定出与所述待分类文本对应的情感类型。
上述方法步骤的具体实施例过程可参见第一实施例,本实施例在此不再重复赘述。
实施例五
本实施例还提供一种计算机可读存储介质,如闪存、硬盘、多媒体卡、卡型存储器(例如,SD或DX存储器等)、随机访问存储器(RAM)、静态随机访问存储器(SRAM)、只读存储器(ROM)、电可擦除可编程只读存储器(EEPROM)、可编程只读存储器(PROM)、磁性存储器、磁盘、光盘、服务器、App应用商城等等,所述计算机可读存储介质可以是非易失性,也可以是易失性,其上存储有计算机程序,所述计算机程序被处理器执行时实现如下方法步骤:
获取待分类文本,并将包含在所述待分类文本中的关键词转化为令牌,以形成令牌序列;其中,所述令牌序列包括T个令牌;
将所述令牌序列输入到预设的令牌处理模型中,以得到概率矩阵;其中,所述概率矩阵为T列、(T+1)行的矩阵,所述概率矩阵的每一列表征一种令牌,所述概率矩阵的第一行表征各个令牌属于方面术语的概率值、第二行至第(T+1)行表征每个令牌属于与对应方面术语相映射的情感令牌的概率值;
将所述属于方面术语的概率值大于预设阈值的令牌设置为目标令牌,并将与所述目标令牌对应的第二行至第(T+1)行的概率值形成情感令牌概率序列;
基于所述情感令牌概率序列,利用预设的Transformer模型和分类器,确定出与所述待分类文本对应的情感类型。
上述方法步骤的具体实施例过程可参见第一实施例,本实施例在此不再重复赘述。
需要说明的是,在本文中,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者装置不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者装置所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括该要素的过程、方法、物品或者装置中还存在另外的相同要素。
上述本申请实施例序号仅仅为了描述,不代表实施例的优劣。
通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到上述实施例方法可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件,但很多情况下前者是更佳的实施方式。
以上仅为本申请的优选实施例,并非因此限制本申请的专利范围,凡是利用本申请说明书及附图内容所作的等效结构或等效流程变换,或直接或间接运用在其他相关的技术领域,均同理包括在本申请的专利保护范围内。

Claims (20)

  1. 一种方面级别情感分类方法,其中,所述方法包括:
    获取待分类文本,并将包含在所述待分类文本中的关键词转化为令牌,以形成令牌序列;其中,所述令牌序列包括T个令牌;
    将所述令牌序列输入到预设的令牌处理模型中,以得到概率矩阵;其中,所述概率矩阵为T列、(T+1)行的矩阵,所述概率矩阵的每一列表征一种令牌,所述概率矩阵的第一行表征各个令牌属于方面术语的概率值、第二行至第(T+1)行表征每个令牌属于与对应方面术语相映射的情感令牌的概率值;
    将所述属于方面术语的概率值大于预设阈值的令牌设置为目标令牌,并将与所述目标令牌对应的第二行至第(T+1)行的概率值形成情感令牌概率序列;
    基于所述情感令牌概率序列,利用预设的Transformer模型和分类器,确定出与所述待分类文本对应的情感类型。
  2. 根据权利要求1所述的方面级别情感分类方法,其中,所述获取待分类文本,并将包含在所述待分类文本中的关键词转化为令牌,以形成令牌序列,具体包括:
    对所述待分类文本进行分词处理,以得到包含在所述待分类文本中的T个关键词;
    分别对每个关键词进行编码,以得到每个关键词的令牌;
    将所有令牌组成所述令牌序列。
  3. 根据权利要求1所述的方面级别情感分类方法,其中,所述将所述令牌序列输入到预设的令牌处理模型中,以得到概率矩阵,具体包括:
    将所述令牌序列输入到所述令牌处理模型中的BERT模型中,得到每个令牌对应的融合了前后令牌信息的特征表征,并将所有所述特征表征组成特征表征序列;
    将所述特征表征序列输入到所述令牌处理模型中的全连接层中,并通过softmax函数对所述全连接层的输出进行归一化处理,以得到所述概率矩阵。
  4. 根据权利要求3所述的方面级别情感分类方法,其中,所述基于所述情感令牌概率序列,利用预设的Transformer模型和分类器,确定出与所述待分类文本对应的情感类型,具体包括:
    将所述特征表征序列与所述情感令牌概率序列进行向量级别的元素相乘,以得到表征结果;
    将所述表征结果依次输入所述Transformer模型和分类器中,以得到与所述待分类文本对应的情感类型。
  5. 根据权利要求1所述的方面级别情感分类方法,其中,所述方法还包括:
    获取样本文本集;其中,所述样本文本集中的每个样本文本均标注有对应的方面术语和情感类型;
    基于所述样本文本集对初始神经网络模型进行训练,以对所述初始神经网络模型中的各个参数进行修正,得到情感分类模型;其中,所述情感分类模型包括:令牌处理模型、Transformer模型和分类器。
  6. 一种方面级别情感分类装置,其中,所述装置包括:
    获取模块,用于获取待分类文本,并将包含在所述待分类文本中的关键词转化为令牌,以形成令牌序列;其中,所述令牌序列包括T个令牌;
    输入模块,用于将所述令牌序列输入到预设的令牌处理模型中,以得到概率矩阵;其中,所述概率矩阵为T列、(T+1)行的矩阵,所述概率矩阵的每一列表征一种令牌,所述概率矩阵的第一行表征各个令牌属于方面术语的概率值、第二行至第(T+1)行表征每个令牌属于与对应方面术语相映射的情感令牌的概率值;
    处理模块,用于将所述属于方面术语的概率值大于预设阈值的令牌设置为目标令牌, 并将与所述目标令牌对应的第二行至第(T+1)行的概率值形成情感令牌概率序列;
    确定模块,基于所述情感令牌概率序列,利用预设的Transformer模型和分类器,确定出与所述待分类文本对应的情感类型。
  7. 根据权利要求6所述的方面级别情感分类装置,其中,所述获取模块,具体用于:
    对所述待分类文本进行分词处理,以得到包含在所述待分类文本中的T个关键词;
    分别对每个关键词进行编码,以得到每个关键词的令牌;
    将所有令牌组成所述令牌序列。
  8. 根据权利要求6所述的方面级别情感分类装置,其中,所述输入模块,具体用于:
    将所述令牌序列输入到所述令牌处理模型中的BERT模型中,得到每个令牌对应的融合了前后令牌信息的特征表征,并将所有所述特征表征组成特征表征序列;
    将所述特征表征序列输入到所述令牌处理模型中的全连接层中,并通过softmax函数对所述全连接层的输出进行归一化处理,以得到所述概率矩阵。
  9. 根据权利要求8所述的方面级别情感分类装置,其中,所述确定模块,具体用于:
    将所述特征表征序列与所述情感令牌概率序列进行向量级别的元素相乘,以得到表征结果;
    将所述表征结果依次输入所述Transformer模型和分类器中,以得到与所述待分类文本对应的情感类型。
  10. 根据权利要求6所述的方面级别情感分类装置,其中,所述装置还包括训练模块,用于:
    获取样本文本集;其中,所述样本文本集中的每个样本文本均标注有对应的方面术语和情感类型;
    基于所述样本文本集对初始神经网络模型进行训练,以对所述初始神经网络模型中的各个参数进行修正,得到情感分类模型;其中,所述情感分类模型包括:令牌处理模型、Transformer模型和分类器。
  11. 一种计算机设备,所述计算机设备包括:存储器、处理器以及存储在所述存储器上并可在所述处理器上运行的计算机程序,其中,所述处理器执行所述计算机程序时实现以下步骤:
    获取待分类文本,并将包含在所述待分类文本中的关键词转化为令牌,以形成令牌序列;其中,所述令牌序列包括T个令牌;
    将所述令牌序列输入到预设的令牌处理模型中,以得到概率矩阵;其中,所述概率矩阵为T列、(T+1)行的矩阵,所述概率矩阵的每一列表征一种令牌,所述概率矩阵的第一行表征各个令牌属于方面术语的概率值、第二行至第(T+1)行表征每个令牌属于与对应方面术语相映射的情感令牌的概率值;
    将所述属于方面术语的概率值大于预设阈值的令牌设置为目标令牌,并将与所述目标令牌对应的第二行至第(T+1)行的概率值形成情感令牌概率序列;
    基于所述情感令牌概率序列,利用预设的Transformer模型和分类器,确定出与所述待分类文本对应的情感类型。
  12. 根据权利要求11所述的计算机设备,其中,所述处理器执行所述计算机程序以实现所述获取待分类文本,并将包含在所述待分类文本中的关键词转化为令牌,以形成令牌序列时,具体包括:
    对所述待分类文本进行分词处理,以得到包含在所述待分类文本中的T个关键词;
    分别对每个关键词进行编码,以得到每个关键词的令牌;
    将所有令牌组成所述令牌序列。
  13. 根据权利要求11所述的计算机设备,其中,所述处理器执行所述计算机程序以实现所述将所述令牌序列输入到预设的令牌处理模型中,以得到概率矩阵时,具体包括:
    将所述令牌序列输入到所述令牌处理模型中的BERT模型中,得到每个令牌对应的融合了前后令牌信息的特征表征,并将所有所述特征表征组成特征表征序列;
    将所述特征表征序列输入到所述令牌处理模型中的全连接层中,并通过softmax函数对所述全连接层的输出进行归一化处理,以得到所述概率矩阵。
  14. 根据权利要求13所述的计算机设备,其中,所述处理器执行所述计算机程序以实现所述基于所述情感令牌概率序列,利用预设的Transformer模型和分类器,确定出与所述待分类文本对应的情感类型时,具体包括:
    将所述特征表征序列与所述情感令牌概率序列进行向量级别的元素相乘,以得到表征结果;
    将所述表征结果依次输入所述Transformer模型和分类器中,以得到与所述待分类文本对应的情感类型。
  15. 根据权利要求11所述的计算机设备,其中,所述处理器执行所述计算机程序时还实现以下步骤:
    获取样本文本集;其中,所述样本文本集中的每个样本文本均标注有对应的方面术语和情感类型;
    基于所述样本文本集对初始神经网络模型进行训练,以对所述初始神经网络模型中的各个参数进行修正,得到情感分类模型;其中,所述情感分类模型包括:令牌处理模型、Transformer模型和分类器。
  16. 一种计算机可读存储介质,其上存储有计算机程序,其中,所述计算机程序被处理器执行时实现以下步骤:
    获取待分类文本,并将包含在所述待分类文本中的关键词转化为令牌,以形成令牌序列;其中,所述令牌序列包括T个令牌;
    将所述令牌序列输入到预设的令牌处理模型中,以得到概率矩阵;其中,所述概率矩阵为T列、(T+1)行的矩阵,所述概率矩阵的每一列表征一种令牌,所述概率矩阵的第一行表征各个令牌属于方面术语的概率值、第二行至第(T+1)行表征每个令牌属于与对应方面术语相映射的情感令牌的概率值;
    将所述属于方面术语的概率值大于预设阈值的令牌设置为目标令牌,并将与所述目标令牌对应的第二行至第(T+1)行的概率值形成情感令牌概率序列;
    基于所述情感令牌概率序列,利用预设的Transformer模型和分类器,确定出与所述待分类文本对应的情感类型。
  17. 根据权利要求16所述的计算机可读存储介质,其中,所述计算机程序被处理器执行时以实现所述获取待分类文本,并将包含在所述待分类文本中的关键词转化为令牌,以形成令牌序列时,具体包括:
    对所述待分类文本进行分词处理,以得到包含在所述待分类文本中的T个关键词;
    分别对每个关键词进行编码,以得到每个关键词的令牌;
    将所有令牌组成所述令牌序列。
  18. 根据权利要求16所述的计算机可读存储介质,其中,所述计算机程序被处理器执行时以实现所述将所述令牌序列输入到预设的令牌处理模型中,以得到概率矩阵时,具体包括:
    将所述令牌序列输入到所述令牌处理模型中的BERT模型中,得到每个令牌对应的融合了前后令牌信息的特征表征,并将所有所述特征表征组成特征表征序列;
    将所述特征表征序列输入到所述令牌处理模型中的全连接层中,并通过softmax函数 对所述全连接层的输出进行归一化处理,以得到所述概率矩阵。
  19. 根据权利要求18所述的计算机可读存储介质,其中,所述计算机程序被处理器执行时以实现所述基于所述情感令牌概率序列,利用预设的Transformer模型和分类器,确定出与所述待分类文本对应的情感类型时,具体包括:
    将所述特征表征序列与所述情感令牌概率序列进行向量级别的元素相乘,以得到表征结果;
    将所述表征结果依次输入所述Transformer模型和分类器中,以得到与所述待分类文本对应的情感类型。
  20. 根据权利要求16所述的计算机可读存储介质,其中,所述计算机程序被处理器执行时还实现以下步骤:
    获取样本文本集;其中,所述样本文本集中的每个样本文本均标注有对应的方面术语和情感类型;
    基于所述样本文本集对初始神经网络模型进行训练,以对所述初始神经网络模型中的各个参数进行修正,得到情感分类模型;其中,所述情感分类模型包括:令牌处理模型、Transformer模型和分类器。
PCT/CN2021/091198 2020-11-06 2021-04-29 方面级别情感分类方法、装置、设备及可读存储介质 Ceased WO2022095376A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202011227233.7A CN112347787A (zh) 2020-11-06 2020-11-06 方面级别情感分类方法、装置、设备及可读存储介质
CN202011227233.7 2020-11-06

Publications (1)

Publication Number Publication Date
WO2022095376A1 true WO2022095376A1 (zh) 2022-05-12

Family

ID=74428904

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/091198 Ceased WO2022095376A1 (zh) 2020-11-06 2021-04-29 方面级别情感分类方法、装置、设备及可读存储介质

Country Status (2)

Country Link
CN (1) CN112347787A (zh)
WO (1) WO2022095376A1 (zh)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115659995A (zh) * 2022-12-30 2023-01-31 荣耀终端有限公司 一种文本情感分析方法和装置
CN116414979A (zh) * 2023-03-02 2023-07-11 中国人民解放军国防科技大学 基于分层对比学习的样本立场检测方法、装置
CN116541705A (zh) * 2023-05-06 2023-08-04 石家庄铁道大学 文本分类模型的训练方法及文本分类方法
CN116737938A (zh) * 2023-07-19 2023-09-12 人民网股份有限公司 基于微调大模型在线数据网络细粒度情感检测方法及装置
CN117992737A (zh) * 2024-04-01 2024-05-07 齐鲁工业大学(山东省科学院) 基于遥感大数据的土地利用判别方法、装置及电子设备
CN119441483A (zh) * 2024-11-07 2025-02-14 杭州征信有限公司 一种基于大语言模型的术语识别方法及系统

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112347787A (zh) * 2020-11-06 2021-02-09 平安科技(深圳)有限公司 方面级别情感分类方法、装置、设备及可读存储介质
CN113947694B (zh) * 2021-09-30 2025-06-03 东软集团股份有限公司 信息的识别方法、装置、存储介质和电子设备
CN115878787B (zh) * 2022-03-07 2026-02-06 北京中关村科金技术有限公司 细粒度情感分析方法、装置及存储介质
CN114492387B (zh) * 2022-04-18 2022-07-19 哈尔滨工业大学(深圳)(哈尔滨工业大学深圳科技创新研究院) 基于句法结构的领域自适应方面术语抽取方法及系统
CN117688611B (zh) * 2024-01-30 2024-06-04 深圳昂楷科技有限公司 电子病历脱敏方法及系统、电子设备、存储介质
CN119601036A (zh) * 2025-01-26 2025-03-11 南昌大学 一种基于事件级检测技术的呼吸音识别方法

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060116862A1 (en) * 2004-12-01 2006-06-01 Dictaphone Corporation System and method for tokenization of text
CN110633730A (zh) * 2019-08-07 2019-12-31 中山大学 一种基于课程学习的深度学习机器阅读理解训练方法
CN111143553A (zh) * 2019-12-06 2020-05-12 国家计算机网络与信息安全管理中心 一种实时文本数据流的特定信息识别方法及系统
CN111444709A (zh) * 2020-03-09 2020-07-24 腾讯科技(深圳)有限公司 文本分类方法、装置、存储介质及设备
CN112347787A (zh) * 2020-11-06 2021-02-09 平安科技(深圳)有限公司 方面级别情感分类方法、装置、设备及可读存储介质
CN112632982A (zh) * 2020-10-29 2021-04-09 国网浙江省电力有限公司湖州供电公司 一种能用于供应商评价的对话文本情感分析方法

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110851604B (zh) * 2019-11-12 2022-09-13 鼎富智能科技有限公司 一种文本分类方法、装置、电子设备及存储介质

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060116862A1 (en) * 2004-12-01 2006-06-01 Dictaphone Corporation System and method for tokenization of text
CN110633730A (zh) * 2019-08-07 2019-12-31 中山大学 一种基于课程学习的深度学习机器阅读理解训练方法
CN111143553A (zh) * 2019-12-06 2020-05-12 国家计算机网络与信息安全管理中心 一种实时文本数据流的特定信息识别方法及系统
CN111444709A (zh) * 2020-03-09 2020-07-24 腾讯科技(深圳)有限公司 文本分类方法、装置、存储介质及设备
CN112632982A (zh) * 2020-10-29 2021-04-09 国网浙江省电力有限公司湖州供电公司 一种能用于供应商评价的对话文本情感分析方法
CN112347787A (zh) * 2020-11-06 2021-02-09 平安科技(深圳)有限公司 方面级别情感分类方法、装置、设备及可读存储介质

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115659995A (zh) * 2022-12-30 2023-01-31 荣耀终端有限公司 一种文本情感分析方法和装置
CN115659995B (zh) * 2022-12-30 2023-05-23 荣耀终端有限公司 一种文本情感分析方法和装置
CN116414979A (zh) * 2023-03-02 2023-07-11 中国人民解放军国防科技大学 基于分层对比学习的样本立场检测方法、装置
CN116541705A (zh) * 2023-05-06 2023-08-04 石家庄铁道大学 文本分类模型的训练方法及文本分类方法
CN116541705B (zh) * 2023-05-06 2024-06-11 石家庄铁道大学 文本分类模型的训练方法及文本分类方法
CN116737938A (zh) * 2023-07-19 2023-09-12 人民网股份有限公司 基于微调大模型在线数据网络细粒度情感检测方法及装置
CN117992737A (zh) * 2024-04-01 2024-05-07 齐鲁工业大学(山东省科学院) 基于遥感大数据的土地利用判别方法、装置及电子设备
CN117992737B (zh) * 2024-04-01 2024-05-31 齐鲁工业大学(山东省科学院) 基于遥感大数据的土地利用判别方法、装置及电子设备
CN119441483A (zh) * 2024-11-07 2025-02-14 杭州征信有限公司 一种基于大语言模型的术语识别方法及系统

Also Published As

Publication number Publication date
CN112347787A (zh) 2021-02-09

Similar Documents

Publication Publication Date Title
WO2022095376A1 (zh) 方面级别情感分类方法、装置、设备及可读存储介质
CN112347367B (zh) 信息服务提供方法、装置、电子设备和存储介质
CN105279495B (zh) 一种基于深度学习和文本总结的视频描述方法
CN111191092A (zh) 画像数据处理方法和画像模型训练方法
CN113361258A (zh) 基于图卷积网络和选择注意力的方面级情感分析方法及系统
CN113139134A (zh) 一种社交网络中用户生成内容的流行度预测方法、装置
CN106897262A (zh) 一种文本分类方法和装置以及处理方法和装置
CN111445545B (zh) 一种文本转贴图方法、装置、存储介质及电子设备
CN114372475A (zh) 一种基于RoBERTa模型的网络舆情情感分析方法及系统
CN112580366B (zh) 情绪识别方法以及电子设备、存储装置
CN114579876A (zh) 虚假信息检测方法、装置、设备及介质
CN110046353A (zh) 一种基于多语言层次机制的方面级情感分析方法
CN112463964A (zh) 文本分类及模型训练方法、装置、设备及存储介质
CN111563380A (zh) 一种命名实体识别方法及其装置
WO2019227629A1 (zh) 文本信息的生成方法、装置、计算机设备及存储介质
CN116450946A (zh) 一种音乐推荐方法、推荐系统、智能座舱及车辆
CN114328916B (zh) 事件抽取、及其模型的训练方法,及其装置、设备和介质
CN119578427B (zh) 属性级情感分类方法及设备
CN120236331A (zh) 基于多模态知识图谱推理增强的人体行为识别方法及设备
CN112632229A (zh) 文本聚类方法及装置
CN117932016A (zh) 对话生成方法及相关装置、设备和存储介质
CN112686052B (zh) 试题推荐及相关模型的训练方法、电子设备、存储装置
CN113610080B (zh) 基于跨模态感知的敏感图像识别方法、装置、设备及介质
CN117349402A (zh) 一种基于机器阅读理解的情绪原因对识别方法及系统
CN116680401A (zh) 文档处理方法、文档处理装置、设备及存储介质

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

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

Country of ref document: EP

Kind code of ref document: A1