WO2024114382A1 - 文本分析方法、情感分类模型、装置、介质、终端及产品 - Google Patents

文本分析方法、情感分类模型、装置、介质、终端及产品 Download PDF

Info

Publication number
WO2024114382A1
WO2024114382A1 PCT/CN2023/131788 CN2023131788W WO2024114382A1 WO 2024114382 A1 WO2024114382 A1 WO 2024114382A1 CN 2023131788 W CN2023131788 W CN 2023131788W WO 2024114382 A1 WO2024114382 A1 WO 2024114382A1
Authority
WO
WIPO (PCT)
Prior art keywords
target
sentence
sentiment
target sentence
classification model
Prior art date
Application number
PCT/CN2023/131788
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 WO2024114382A1 publication Critical patent/WO2024114382A1/zh

Links

Definitions

  • the embodiments of this specification relate to the field of natural language processing technology, and in particular, to a text analysis method, a sentiment classification model, a text analysis device, a computer-readable storage medium, a terminal, and a computer program product.
  • the purpose of the embodiments of this specification is to provide a text analysis method, sentiment classification model, text analysis device, computer-readable storage medium, terminal and computer program product, which can at least improve the feature extraction effect and sentiment semantic extraction effect of text to a certain extent.
  • a text analysis method which includes: encoding a target sentence in a text to obtain a target word vector corresponding to each word in the target sentence; extracting contextual semantic features of the target word vector to obtain a feature vector corresponding to the target word vector; classifying the feature vector to obtain an emotional semantic type of the target sentence; and obtaining an analysis result of the target sentence based on the emotional semantic type of the target sentence and keywords in the target sentence.
  • the above-mentioned feature vector is classified to obtain the emotional semantic type of the above-mentioned target sentence, including: determining the weight of the above-mentioned feature vector in the above-mentioned target sentence through an attention mechanism to obtain a weighted feature vector; classifying the above-mentioned weighted feature vector to obtain the above-mentioned target sentence The emotional semantic type.
  • the above-mentioned weighted feature vector is classified to obtain the emotional semantic type of the above-mentioned target sentence, including: performing dimensionality reduction processing on the above-mentioned weighted feature vector to obtain a reduced-dimensional feature vector; inputting the reduced-dimensional feature vector into a classifier, and obtaining the emotional semantic type of the above-mentioned target sentence based on the output result of the above-mentioned classifier.
  • the above-mentioned encoding of the target sentence in the text to obtain the target word vector corresponding to each word in the above-mentioned target sentence includes: encoding the target sentence in the text through the pre-trained language representation model in the sentiment classification model to obtain the target word vector corresponding to each word in the above-mentioned target sentence; the above-mentioned extraction of the contextual semantic features of the above-mentioned target word vector to obtain the feature vector corresponding to the above-mentioned target word vector includes: extracting the contextual semantic features of the above-mentioned target word vector through the bidirectional gated recurrent unit in the above-mentioned sentiment classification model to obtain the feature vector corresponding to the above-mentioned target word vector; before obtaining the analysis result of the above-mentioned target sentence according to the sentiment semantic type of the above-mentioned target sentence and the keywords in the above-mentioned target sentence, the above-mentioned method also includes: determining the keywords
  • the method before the target sentence in the text is input into the sentiment classification model, the method further includes: training the sentiment classification model to be trained to determine the sentiment classification model; wherein the training of the sentiment classification model to be trained to determine the sentiment classification model includes: obtaining N sample sentences, and annotating the nth sample sentence according to the actual sentiment semantic type of the nth sample sentence in the N sample sentences to obtain the nth annotated sentence, wherein N is a positive integer and n is a positive integer less than or equal to N; using the pre-trained language representation model, annotating the nth annotated sentence
  • the sentence is encoded to obtain M word vectors corresponding to the M words in the n-th labeled sentence, wherein M is a positive integer; the contextual semantic features of the M word vectors are extracted through the bidirectional gated recurrent unit to obtain M feature vectors corresponding to the M word vectors; the M feature vectors are classified to obtain the predicted emotional semantic type of the n-th sample sentence; the loss function of the
  • the above-mentioned M feature vectors are classified to obtain the predicted emotional semantic type of the above-mentioned nth sample sentence, including: determining the weights of the above-mentioned M feature vectors in the above-mentioned nth sample sentence through the above-mentioned attention mechanism to obtain M weighted feature vectors; and classifying the above-mentioned M weighted feature vectors to obtain the predicted emotional semantic type of the above-mentioned nth sample sentence.
  • the above-mentioned M weighted feature vectors are classified to obtain the above
  • the predicted emotional semantic type of the nth sample sentence includes: performing dimensionality reduction processing on the M weighted feature vectors to obtain M reduced-dimensional feature vectors; inputting the M reduced-dimensional feature vectors into the classifier, and obtaining the predicted emotional semantic type of the nth sample sentence according to the output result of the classifier.
  • a sentiment classification model which includes: a pre-trained language representation model, which is used to encode the target sentence in the text to obtain the target word vector corresponding to each word in the target sentence; a bidirectional gated recurrent unit, which is used to extract the contextual semantic features of the target word vector to obtain the feature vector corresponding to the target word vector; and an output layer, which is used to classify the feature vector to obtain the sentiment semantic type of the target sentence.
  • a text analysis device includes: a sentiment classification module, which is used to: encode the target sentence in the text through the pre-trained language representation model in the sentiment classification model, and obtain the target word vector corresponding to each word in the target sentence; extract the contextual semantic features of the target word vector through the bidirectional gated recurrent unit in the sentiment classification model, and obtain the feature vector corresponding to the target word vector; classify the feature vector through the sentiment classification model to obtain the sentiment semantic type of the target sentence; an analysis result determination module, which is used to: determine the keywords in the target sentence, and obtain the analysis result of the target sentence according to the sentiment semantic type of the target sentence and the keywords in the target sentence.
  • a sentiment classification module which is used to: encode the target sentence in the text through the pre-trained language representation model in the sentiment classification model, and obtain the target word vector corresponding to each word in the target sentence; extract the contextual semantic features of the target word vector through the bidirectional gated recurrent unit in the sentiment classification model, and obtain the feature vector corresponding to the target word vector; classify the
  • a terminal comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the text analysis method described in the first aspect when executing the computer program.
  • a computer-readable storage medium on which a computer program is stored.
  • the computer program is executed by a processor, the text analysis method described in the first aspect is implemented.
  • a computer program product is provided.
  • the computer or the processor implements the text analysis method described in the first aspect when executing the computer or the processor.
  • the text analysis method, sentiment classification model, text analysis device, computer-readable storage medium, terminal, and computer program product provided in the embodiments of this specification have the following technical effects:
  • the scheme provided in the exemplary embodiments of this specification is suitable for shallow feature extraction and deep context feature extraction of text sentences to achieve sentiment classification and opinion analysis of text.
  • the target sentence in the text is encoded to obtain the target word vector corresponding to each word in the target sentence.
  • the context semantic features of the target word vector are extracted to obtain the target word vector.
  • the feature vector corresponding to the vector is obtained.
  • the feature vector is classified and the emotional semantic type of the target sentence is obtained according to the classification result.
  • the analysis result of the target sentence is obtained according to the emotional semantic type of the target sentence and the keywords in the target sentence. In this way, the opinion mining of the text is realized and the mining effect of the opinion is improved.
  • FIG1 is a schematic flow chart of a text analysis method provided by an exemplary embodiment of this specification.
  • FIG2 is a schematic structural diagram of a sentiment classification model provided by an exemplary embodiment of this specification.
  • FIG3 is a schematic structural diagram of a pre-trained language representation model provided in an exemplary embodiment of this specification.
  • FIG4 is a schematic structural diagram of a bidirectional gating unit provided in an exemplary embodiment of this specification.
  • FIG5 is a schematic flow chart of a feature vector classification method provided by an exemplary embodiment of this specification.
  • FIG6 is a schematic flow chart of a method for training a sentiment classification model provided in an exemplary embodiment of this specification
  • FIG7 is a schematic structural diagram of a text analysis device provided in an exemplary embodiment of this specification.
  • FIG8 is a schematic structural diagram of a text analysis device provided by another exemplary embodiment of this specification.
  • FIG. 9 is a schematic block diagram of a terminal provided by an exemplary embodiment of this specification.
  • Opinion mining or sentiment analysis aims to mine people's expressed opinions or emotions from texts, so as to identify the topics people talk about and the emotional tendencies they express on the topics.
  • the embodiments of this specification provide a text analysis method, sentiment classification model, device, medium and terminal. Below, each step of the text analysis method in this example implementation will be described in more detail in combination with the drawings and embodiments.
  • Figure 1 schematically shows a flow chart of a text analysis method according to an exemplary embodiment of this specification
  • Figure 2 shows a structural diagram of a sentiment classification model according to an exemplary embodiment of this specification.
  • the sentiment classification model can be applied to the text analysis method.
  • the target sentence in the text is encoded to obtain a target word vector corresponding to each word in the target sentence.
  • the financial planner when the financial planner communicates with the user on the application platform, some communication data will be generated.
  • the communication data can be obtained through the chat records between the financial planner and the user, or the conversation content between the financial planner and the user can be converted into recognizable text through automatic speech recognition technology (Automatic Speech Recognition, ASR), etc.
  • ASR Automatic Speech Recognition
  • the main focus is on acquiring the statements of the financial planner's views.
  • the sentences in the acquired text are: "Compared with other financial products, xxx product is a relatively good product now.”, "You can buy this relatively stable financial product. Although the subsequent income will not be much higher than the current investment, it will not cause losses. Loss.”, "But this does not mean that I am not optimistic about xxx company.”, etc.
  • the acquired text may be input into the sentiment classification model shown in Fig. 2.
  • the sentiment classification model includes an input layer, an embedding layer, a bidirectional gated unit layer, an attention mechanism layer, and an output layer.
  • the embedding layer includes a pre-trained language representation model, which is used to encode the target sentence in the text to obtain the target word vector corresponding to each word in the target sentence.
  • the bidirectional gated recurrent unit is used to extract the contextual semantic features of the target word vector to obtain the feature vector corresponding to the target word vector.
  • the output layer is used to classify the feature vector to obtain the emotional semantic type of the target sentence.
  • the following uses one of the target sentences in the text as an example to illustrate the specific text analysis method and sentiment classification model.
  • the target words in the target sentence are recorded as W1, W2, W3, ... Wm-2, Wm-1, Wm, where m is a positive integer from 1 to M.
  • the target words in the target sentence can be encoded through the embedding layer to obtain the target word vector corresponding to the target word.
  • the model used in the embedding layer can be a pre-trained language representation model, that is, a BERT pre-trained model.
  • the BERT pre-training model will first perform word segmentation on the target sentence, and obtain the input representations W 1 , W 2 , ..., W m corresponding to the target word through token embeddings, segment embeddings, and position embeddings. Then, the target word vectors e 1 , e 2 , ..., e m corresponding to the target word are obtained through multiple encoders (Transformers). Only the encoding part (Encoder) of the original Transformer is retained in the BERT pre-training model.
  • Using multiple Transformers to achieve bidirectional encoding can enable the target word vector output by the BERT pre-training model to describe the overall information of the input target sentence as comprehensively and accurately as possible, handle the situation of polysemy of a word, and realize dynamic adjustment of the target word vector in conjunction with the context, thereby improving the extraction effect of shallow semantic information of the target sentence.
  • the contextual semantic features of the target word vector are extracted to obtain a feature vector corresponding to the target word vector.
  • the BiGRU model includes the forward GRU and Inverse GRU GRU
  • the unit retains the advantages of Long Short-Term Memory (LSTM) in solving the gradient vanishing problem of Recurrent Neural Network (RNN), and has a simpler internal structure, a 1/3 reduction in parameters, and is relatively superior in convergence time and the number of required iterations.
  • LSTM Long Short-Term Memory
  • RNN Recurrent Neural Network
  • the forward GRU is used to process the forward information of the forward target sentence (i.e., the target sentence arranged in a forward direction), and the reverse GRU is used to process the reverse information of the reverse target sentence (i.e., the target sentence arranged in a reverse direction, but the target word itself is not reversed).
  • the input will provide two GRUs in opposite directions at the same time, and the output is determined by the two GRUs.
  • the deep contextual semantic features corresponding to the target word vector can be extracted to obtain the corresponding feature vector, that is, the feature vector contains both the previous information (forward information) of the target word and the following information (reverse information) of the target word.
  • the output result h t is composed of the output connection of the forward GRU and the reverse GRU.
  • t is any positive integer from 1 to M
  • xt is the input vector of BiGRU obtained according to the target word vector et
  • et represents the hidden state of the forward propagation at time t
  • h t represents the hidden state of back propagation at time t
  • the final output feature vector h t is given by and It contains the bidirectional semantic information of the target word vector e t , that is, the contextual semantic information.
  • the feature vector is classified to obtain the emotional semantic type of the target sentence.
  • the sentiment classification model can implement the process of step S130 according to the flowchart shown in Fig. 5.
  • the process includes steps S510 and S530.
  • the feature vectors are input into the attention mechanism (Attention) layer.
  • the attention mechanism is a mechanism for allocating attention resources similar to the human brain. Since the importance of each feature vector to the classification task of the target sentence is different, for example, for the classification of investment advisors' opinions, "return" is more important than "consideration”. Therefore, the importance of each feature vector ⁇ 1 , ⁇ 2 , ⁇ 3 , ...
  • ⁇ m can be calculated through the attention mechanism, so as to obtain The feature vectors are assigned corresponding weights to obtain weighted feature vectors. Higher weights are assigned to feature vectors with higher importance, so that when the classifier is classified, feature vectors with higher importance can receive more attention, thus improving the classification effect of the sentiment classification model.
  • ⁇ w and bw are the adjustable weights and bias terms of the attention mechanism
  • ht is the above-mentioned feature vector
  • ut is the implicit state of ht
  • uw is the weight parameter of the Softmax classifier
  • ⁇ t is used to calculate the importance of the feature vector
  • V is the weighted feature vector.
  • the BiGRU-Attention structure can use the attention mechanism to obtain the most important information in the target sentence, and is superior to the text convolutional neural network (TextCNN) in learning long-distance semantics, and can improve the classification effect of the sentiment classification model.
  • TextCNN text convolutional neural network
  • the weighted feature vector can then be input into a fully connected layer (Dense Layer) to perform dimensionality reduction processing and obtain a feature vector after dimensionality reduction.
  • Dense Layer fully connected layer
  • the sentiment semantic type of the target sentence is, the sentiment semantic type of the target sentence, wherein the sentiment semantic type may include “optimistic”, “unoptimistic”, “neutral”, “non-opinion”, etc.
  • the sentiment semantic type may be set according to the specific application scenario, and this embodiment does not limit the content of the sentiment semantic type.
  • ⁇ 0 is the weight coefficient matrix
  • b 0 is the bias matrix
  • p is the output sentiment semantic type.
  • an analysis result of the target sentence is obtained according to the emotional semantic type of the target sentence and the keywords in the target sentence.
  • the emotional semantics expressed by the financial planner can be known through the emotional semantics type of the target sentence. For example, for the target sentence "Compared with other financial products, xxx product is a relatively good product now.”, it is input into the sentiment classification model, and the obtained sentiment classification result may be "optimistic", from which it can be known that the emotional semantics expressed by the financial planner is positive.
  • the keywords in the target sentence published by the financial advisor can also be obtained.
  • keywords may include fund products, fund managers, and so on. Keywords can be identified and extracted through a preset dictionary, and the preset dictionary can be pre-constructed according to specific application scenarios.
  • the preset dictionary constructed for the investment advisor scenario can include a large number of words related to the investment advisor scenario.
  • the method for extracting keywords in the target sentence can be implemented through a deep neural network, for example, a recurrent neural network (RNN), a long short-term memory network LSTM (Long-Short Term Memory), etc.
  • the keyword extraction method is not limited in this embodiment.
  • the obtained keywords may be "xxx product” and the like.
  • the investment advisor's viewpoint can be analyzed as a whole. For example, for the target sentence "Compared with other financial products, xxx product is a relatively good product now.”, its sentiment type is "optimistic” and the keyword is "xxx product", then based on these two results, the investment advisor's viewpoint can be analyzed as "optimistic about xxx product/positive attitude towards xxx product".
  • a text analysis system capable of executing the method can also be constructed, and the system can be run in a terminal, so that the financial advisor's opinions and the preset opinions provided by the application platform can be analyzed offline in batches and online in real time.
  • the opinion analysis results and the financial products involved in the opinions can be tracked and recalled, so as to improve the financial advisor's analysis results and financial products in a targeted manner. In this way, the level and quality of the investment advisory business in the financial application platform can be improved, and user stickiness can be improved and maintained.
  • This specification also provides a method for training a sentiment classification model.
  • a sentiment classification model For the specific training process, please refer to the embodiment shown in FIG6 .
  • N is a positive integer
  • n is a positive integer less than or equal to N.
  • the training samples can also be obtained through the chat records between the financial planner and the user, or the conversation content between the financial planner and the user can be converted into recognizable text through automatic speech recognition technology (Automatic Speech Recognition, ASR), etc.
  • ASR Automatic Speech Recognition
  • This embodiment does not limit the method of obtaining training samples.
  • the training samples can be divided into sentences to obtain N sample sentences.
  • the nth sample sentence among the N sample sentences is labeled to determine the actual emotional semantic type of the nth sample sentence, where n is a positive integer from 1 to N.
  • the actual emotional semantic types can be divided into “optimistic”, “pessimistic”, “neutral”, “non-opinion”, etc., and a corresponding emotional label (label) is set for each actual emotional semantic type.
  • the label corresponding to "optimistic” can be "3”
  • the label corresponding to "pessimistic” can be "2”
  • the label corresponding to "neutral” can be "1”
  • the label corresponding to "non-opinion” can be "0”.
  • the actual emotional semantic type and its label can be set according to the specific application scenario, and this embodiment does not limit the content of the emotional semantic type.
  • the obtained nth labeled sentence can be input into the sentiment classification model through the input layer.
  • the nth labeled sentence can be encoded by the BERT pre-trained model in the embedding layer to obtain M word vectors corresponding to the M words in the nth labeled sentence.
  • the BiGRU layer After obtaining M word vectors, they are input into the BiGRU layer to extract the contextual semantic features of the M word vectors through BiGRU to obtain M feature vectors corresponding to the M word vectors, and the feature vectors contain the contextual semantic information of the word vectors.
  • S640 Classify the M feature vectors to obtain the predicted sentiment semantic type of the nth sample sentence.
  • the feature vectors are input into the attention mechanism layer to assign corresponding weights to the M feature vectors according to their importance in the nth labeled sentence, and finally obtain M weighted feature vectors.
  • the M weighted feature vectors can be input into the fully connected layer to perform dimension reduction processing on the M weighted feature vectors to obtain M reduced dimension feature vectors.
  • the M reduced dimension feature vectors are input into the Softmax classifier, and the predicted sentiment semantic type of the nth sample sentence is obtained according to the output result of the classifier.
  • the predicted emotion semantic type of the nth sample sentence may be the same as the actual emotion semantic type, or may be different from the actual emotion semantic type.
  • the emotion label of the actual emotion semantic type annotated for the nth annotated sentence is "3”
  • the emotion label of the predicted emotion semantic type output by the emotion classification model may be "3" or other emotion labels such as "2”. That is, the emotion classification model may have a certain error in the classification of the nth annotated sentence. Therefore, it is necessary to further optimize the emotion classification model according to the predicted emotion semantic type and the actual emotion semantic type to improve the classification effect of emotion semantics.
  • the cross entropy between the predicted sentiment semantic type and the actual sentiment semantic type can be calculated, and the relevant parameters in the sentiment classification model can be optimized by minimizing the cross entropy to determine the sentiment classification model.
  • the calculation formula of the cross entropy can refer to formula (8):
  • D is the training data set
  • C is the number of types of sentiment labels
  • y is the actual sentiment semantic type.
  • is L2 regularization and ⁇ is a configurable parameter.
  • the text analysis method provided in the embodiment of this specification and the sentiment classification model used in the text analysis method encode the target sentence in the text, obtain the target word vector corresponding to each word in the target sentence, and extract the shallow features of the text sentence. Then, the contextual semantic features of the target word vector are extracted to obtain the feature vector corresponding to the target word vector, thereby extracting the deep contextual features of the text sentence. Afterwards, the feature vector is classified and processed, and the sentiment semantic type of the target sentence is obtained according to the classification result. Finally, according to the sentiment semantic type of the target sentence and the keywords in the target sentence, the analysis result of the target sentence is obtained. Thereby realizing the mining of the viewpoints of the text and improving the mining effect of the viewpoints.
  • FIG. 7 shows a structural diagram of a text analysis device according to an exemplary embodiment of the present specification.
  • the text analysis device 700 in the embodiment of the present specification includes: a sentiment classification module 710, and an analysis result determination module 720, wherein: the sentiment classification module 710 is used to: encode the target sentence in the text through the pre-trained language representation model in the sentiment classification model to obtain the target word vector corresponding to each word in the target sentence; The contextual semantic features of the target word vector are extracted through the bidirectional gated recurrent unit in the sentiment classification model to obtain a feature vector corresponding to the target word vector; the feature vector is classified and processed through the sentiment classification model to obtain the sentiment semantic type of the target sentence; the analysis result determination module 720 is used to: determine the keywords in the target sentence, and obtain the analysis result of the target sentence based on the sentiment semantic type of the target sentence and the keywords in the target sentence.
  • FIG8 shows a structural diagram of a text analysis device according to another exemplary embodiment of the present specification.
  • the sentiment classification module 710 is specifically used to: determine the weight of the feature vector in the target sentence through an attention mechanism to obtain a weighted feature vector; and classify the weighted feature vector to obtain the sentiment semantic type of the target sentence.
  • the sentiment classification module 710 is specifically used to: perform dimensionality reduction processing on the weighted feature vector to obtain a reduced-dimensional feature vector; input the reduced-dimensional feature vector into a classifier, and obtain the sentiment semantic type of the target sentence based on the output result of the classifier.
  • the sentiment classification module 710 is specifically used to encode the target sentence in the text through the pre-trained language representation model in the sentiment classification model to obtain the target word vector corresponding to each word in the target sentence.
  • the sentiment classification module 710 is specifically used to extract contextual semantic features of the target word vector through a bidirectional gated recurrent unit in the sentiment classification model to obtain a feature vector corresponding to the target word vector.
  • the sentiment classification module 710 is specifically used to determine keywords in the target sentence through a preset dictionary.
  • the apparatus further includes: a training module 730.
  • the training module 730 is used to: train the sentiment classification model to be trained to determine the sentiment classification model.
  • the training module is specifically used to: obtain N sample sentences, and label the nth sample sentence according to the actual emotional semantic type of the nth sample sentence in the N sample sentences to obtain the nth labeled sentence, wherein N is a positive integer and n is a positive integer less than or equal to N; encode the nth labeled sentence through a pre-trained language representation model to obtain M word vectors corresponding to M words in the nth labeled sentence, wherein M is a positive integer; extract the contextual semantic features of the M word vectors through a bidirectional gated recurrent unit to obtain M feature vectors corresponding to the M word vectors; classify the M feature vectors to obtain the predicted emotional semantic type of the nth sample sentence; determine the emotional semantic type to be trained according to the actual emotional semantic type and the predicted emotional semantic type
  • the loss function of the classification model is obtained, and the parameters in the sentiment classification model to be trained are optimized according to the loss function to determine the sentiment classification model.
  • the above-mentioned training module is specifically used to: determine the weights of M feature vectors in the nth sample sentence through the attention mechanism to obtain M weighted feature vectors; classify the M weighted feature vectors to obtain the predicted emotional semantic type of the nth sample sentence.
  • the above training module is specifically used to: perform dimensionality reduction processing on M weighted feature vectors to obtain M reduced-dimensionality feature vectors; input the M reduced-dimensionality feature vectors into a classifier, and obtain the predicted emotional semantic type of the nth sample sentence based on the output result of the classifier.
  • the text analysis device provided in the above embodiment executes the text analysis method
  • only the division of the above functional modules is used as an example.
  • the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above.
  • the text analysis device provided in the above embodiment and the text analysis method embodiment belong to the same concept. Therefore, for details not disclosed in the device embodiment of this specification, please refer to the text analysis method embodiment of the above specification, which will not be repeated here.
  • the embodiments of this specification also provide a computer-readable storage medium on which a computer program is stored, and when the program is executed by a processor, the steps of the method of any of the above embodiments are implemented.
  • the computer-readable storage medium may include, but is not limited to, any type of disk, including a floppy disk, an optical disk, a DVD, a CD-ROM, a micro drive, and a magneto-optical disk, a ROM, a RAM, an EPROM, an EEPROM, a DRAM, a VRAM, a flash memory device, a magnetic card or an optical card, a nanosystem (including a molecular memory IC), or any type of medium or device suitable for storing instructions and/or data.
  • the embodiments of the present specification also provide a terminal, including a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor implements the steps of any of the above-mentioned embodiments when executing the program.
  • Fig. 9 schematically shows a structure diagram of a terminal according to an exemplary embodiment of this specification.
  • a terminal 900 includes: a processor 901 and a memory 902 .
  • the processor 901 is the control center of the computer system, which can be a processor of a physical machine or a processor of a virtual machine.
  • the processor 901 can include one or more processing cores, such as a 4-core processor, an 8-core processor, etc.
  • the processor 901 can use digital signal processing (Digital Signal Processing, DSP), field programmable gate array (Field-Programmable Gate Array, FPGA), programmable logic array
  • DSP Digital Signal Processing
  • FPGA Field-Programmable Gate Array
  • the processor 901 may also include a main processor and a coprocessor.
  • the main processor is a processor for processing data in the awake state, also known as a central processing unit (CPU);
  • the coprocessor is a low-power processor for processing data in the standby state.
  • the processor 901 is specifically used to: encode the target sentence in the text to obtain a target word vector corresponding to each word in the target sentence; extract the contextual semantic features of the target word vector to obtain a feature vector corresponding to the target word vector; classify the feature vector to obtain the emotional semantic type of the target sentence; and obtain an analysis result of the target sentence based on the emotional semantic type of the target sentence and the keywords in the target sentence.
  • the processor 901 is specifically used to: determine the weight of the feature vector in the target sentence through an attention mechanism to obtain a weighted feature vector; and classify the weighted feature vector to obtain the emotional semantic type of the target sentence.
  • the processor 901 is specifically used to: perform dimensionality reduction processing on the weighted feature vector to obtain a reduced-dimensional feature vector; input the reduced-dimensional feature vector into a classifier, and obtain the emotional semantic type of the target sentence based on the output result of the classifier.
  • the processor 901 is specifically used to: encode a target sentence in the text through a pre-trained language representation model in a sentiment classification model to obtain a target word vector corresponding to each word in the target sentence.
  • the processor 901 is specifically used to extract contextual semantic features of the target word vector through the bidirectional gated recurrent unit in the sentiment classification model to obtain a feature vector corresponding to the target word vector.
  • the processor 901 is further specifically configured to: determine keywords in the target sentence through a preset dictionary.
  • the processor 901 is further specifically used to: train the sentiment classification model to be trained to determine the sentiment classification model.
  • the processor 901 is specifically used to: obtain N sample sentences, and annotate the nth sample sentence according to the actual emotional semantic type of the nth sample sentence in the N sample sentences to obtain the nth annotated sentence, wherein N is a positive integer and n is a positive integer less than or equal to N; encode the nth annotated sentence through the pre-trained language representation model to obtain M word vectors corresponding to the M words in the nth annotated sentence, wherein M is a positive integer; encode the context language of the M word vectors through the bidirectional gated recurrent unit.
  • the semantic features are extracted to obtain M feature vectors corresponding to the M word vectors; the M feature vectors are classified to obtain the predicted emotional semantic type of the nth sample sentence; the loss function of the emotion classification model to be trained is determined according to the actual emotional semantic type and the predicted emotional semantic type, and the parameters in the emotion classification model to be trained are optimized according to the loss function to determine the emotion classification model.
  • the processor 901 is specifically used to: determine the weights of the M feature vectors in the nth sample sentence through the attention mechanism to obtain M weighted feature vectors; and classify the M weighted feature vectors to obtain the predicted sentiment semantic type of the nth sample sentence.
  • the processor 901 is specifically used to: perform dimensionality reduction processing on the M weighted feature vectors to obtain M reduced-dimensionality feature vectors; input the M reduced-dimensionality feature vectors into the classifier, and obtain the predicted sentiment semantic type of the nth sample sentence based on the output result of the classifier.
  • the memory 902 may include one or more computer-readable storage media, which may be non-transitory.
  • the memory 902 may also include a high-speed random access memory and a non-volatile memory, such as one or more disk storage terminals and flash memory storage terminals.
  • the non-transitory computer-readable storage medium in the memory 902 is used to store at least one instruction, which is used to be executed by the processor 901 to implement the method in the embodiment of the present specification.
  • the terminal 900 further includes: a peripheral terminal interface 903 and at least one peripheral terminal.
  • the processor 901, the memory 902 and the peripheral terminal interface 903 may be connected via a bus or a signal line.
  • Each peripheral terminal may be connected to the peripheral terminal interface 903 via a bus, a signal line or a circuit board.
  • the peripheral terminal includes: at least one of a display screen 904, a camera 905 and an audio circuit 906.
  • the peripheral terminal interface 903 may be used to connect at least one peripheral terminal related to input/output (I/O) to the processor 901 and the memory 902.
  • the processor 901, the memory 902, and the peripheral terminal interface 903 are integrated on the same chip or circuit board; in some other embodiments of the present specification, any one or two of the processor 901, the memory 902, and the peripheral terminal interface 903 may be implemented on a separate chip or circuit board. This embodiment of the present specification does not specifically limit this.
  • the display screen 904 is used to display a user interface (UI).
  • the UI may include graphics, text, icons, videos, and any combination thereof.
  • the display screen 904 also has the ability to collect touch signals on the surface of the display screen 904 or above the surface.
  • the touch signal can be input as a control signal to the processor 901 for processing.
  • the display screen 904 can also be used to provide virtual buttons and/or virtual keyboards, also known as soft buttons and/or soft keyboards.
  • the display screen 904 can be a terminal, and a terminal can be set.
  • the display screen 904 is a front panel of the terminal 900; in some other embodiments of the present specification, the display screen 904 may be at least two, which are respectively arranged on different surfaces of the terminal 900 or are folded; in some other embodiments of the present specification, the display screen 904 may be a flexible display screen, which is arranged on a curved surface or a folded surface of the terminal 900. Even more, the display screen 904 may be arranged in a non-rectangular irregular shape, that is, a special-shaped screen.
  • the display screen 904 may be made of materials such as a liquid crystal display (LCD), an organic light-emitting diode (OLED), etc.
  • Camera 905 is used to capture images or videos.
  • camera 905 includes a front camera and a rear camera.
  • the front camera is arranged on the front panel of the terminal, and the rear camera is arranged on the back of the terminal.
  • there are at least two rear cameras which are any one of a main camera, a depth of field camera, a wide-angle camera, and a telephoto camera, so as to realize the fusion of the main camera and the depth of field camera to realize the background blur function, the fusion of the main camera and the wide-angle camera to realize panoramic shooting and virtual reality (VR) shooting function or other fusion shooting functions.
  • camera 905 may also include a flash.
  • the flash can be a monochrome temperature flash or a dual-color temperature flash.
  • a dual-color temperature flash refers to a combination of a warm light flash and a cold light flash, which can be used for light compensation at different color temperatures.
  • the audio circuit 906 may include a microphone and a speaker.
  • the microphone is used to collect sound waves from the user and the environment, and convert the sound waves into electrical signals and input them into the processor 901 for processing.
  • the microphone may also be an array microphone or an omnidirectional collection microphone.
  • the power supply 907 is used to power various components in the terminal 900.
  • the power supply 907 can be an alternating current, a direct current, a disposable battery, or a rechargeable battery.
  • the rechargeable battery can be a wired rechargeable battery or a wireless rechargeable battery.
  • a wired rechargeable battery is a battery charged through a wired line
  • a wireless rechargeable battery is a battery charged through a wireless coil.
  • the rechargeable battery can also be used to support fast charging technology.
  • the terminal structure block diagram shown in the embodiment of this specification does not constitute a limitation on the terminal 900.
  • the terminal 900 may include more or fewer components than those shown in the figure, or combine certain components, or adopt a different component arrangement.
  • the terms “first”, “second”, etc. are used for descriptive purposes only and are not to be understood as indicating or implying relative importance or order; the term “plurality” refers to two or more, unless otherwise expressly defined.
  • the terms “installed”, “connected”, “connected”, “fixed”, etc. should be understood in a broad sense. For example, “connected” can be a fixed connection, a detachable connection, or an integral connection; “connected” can be a direct connection or an indirect connection through an intermediate medium.
  • the specific meanings of the above terms in this specification can be understood according to the specific circumstances.
  • the embodiments of this specification also provide a computer-readable storage medium, which stores instructions, and when the instructions are executed on a computer or a processor, the computer or the processor executes one or more steps in the above embodiments. If the components of the above text analysis device are implemented in the form of software functional units and sold or used as independent products, they can be stored in the above computer-readable storage medium.
  • the above embodiments it can be implemented in whole or in part by software, hardware, firmware or any combination thereof.
  • software it can be implemented in whole or in part in the form of a computer program product.
  • the above computer program product includes one or more computer instructions.
  • the above computer program instructions When the above computer program instructions are loaded and executed on a computer, the above process or function according to the embodiment of this specification is generated in whole or in part.
  • the above computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device.
  • the above computer instructions can be stored in a computer-readable storage medium or transmitted through the above computer-readable storage medium.
  • the above computer instructions can be transmitted from a website, computer, server or data center to another website, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.).
  • the above computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server or data center that includes one or more available media integrated.
  • the above-mentioned available media can be magnetic media (for example, floppy disks, hard disks, tapes), optical media (for example, digital versatile discs (DVD)), or semiconductor media (for example, solid-state drives (SSD)), etc.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Computational Linguistics (AREA)
  • General Health & Medical Sciences (AREA)
  • Health & Medical Sciences (AREA)
  • Artificial Intelligence (AREA)
  • Machine Translation (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)

Abstract

本说明书实施例提供了一种文本分析方法、情感分类模型、文本分析装置、计算机可读存储介质、终端以及计算机程序产品。该方法包括:对文本中的目标语句进行编码,得到目标语句中每个词对应的目标词向量。之后,对目标词向量的上下文语义特征进行提取,得到目标词向量对应的特征向量。根据对特征向量的分类结果得到目标语句的情感语义类型。最后根据目标语句的情感语义类型以及目标语句中的关键词,得到对目标语句的分析结果。

Description

文本分析方法、情感分类模型、装置、介质、终端及产品 技术领域
本说明书实施例涉及自然语言处理技术领域,尤其涉及一种文本分析方法、情感分类模型、文本分析装置、计算机可读存储介质、终端以及计算机程序产品。
背景技术
在理财应用平台中,理财师作为平台和用户之间的重要桥梁,对客户表述的投顾观点往往会在很大程度上影响用户的理财决策,而用户的体验和投资收益也会成为维持用户粘性的重要因素。因此,现在大多数平台都会通过机器模型等手段来对理财师所提供的投顾观点进行分析,以更好地对投顾观点和理财产品进行改善。
现阶段对于投顾观点的分析方法还需要更加准确高效的方案来实现。
需要说明的是,在上述背景技术部分公开的信息仅用于加强对本说明书的背景的理解,因此可以包括不构成对本领域普通技术人员已知的相关技术的信息。
发明内容
本说明书实施例的目的在于提供一种文本分析方法、情感分类模型、文本分析装置、计算机可读存储介质、终端以及计算机程序产品,至少能够在一定程度上提高对文本的特征提取效果和情感语义提取效果。
本说明书实施例的其他特性和优点将通过下面的详细描述变得显然,或部分地通过本说明书的实践而习得。
根据本说明书实施例的第一个方面,提供一种文本分析方法,上述方法包括:对文本中的目标语句进行编码,得到上述目标语句中每个词对应的目标词向量;对上述目标词向量的上下文语义特征进行提取,得到上述目标词向量对应的特征向量;对上述特征向量进行分类处理,以得到上述目标语句的情感语义类型;根据上述目标语句的情感语义类型以及上述目标语句中的关键词,得到对上述目标语句的分析结果。
在本说明书一个实施例中,上述对上述特征向量进行分类处理,以得到上述目标语句的情感语义类型,包括:通过注意力机制确定上述特征向量在上述目标语句中的权重,得到加权后的特征向量;对上述加权后的特征向量进行分类处理,以得到上述目标语句 的情感语义类型。
在本说明书一个实施例中,上述对上述加权后的特征向量进行分类处理,以得到上述目标语句的情感语义类型,包括:对上述加权后的特征向量进行降维处理,得到降维后的特征向量;将上述降维后的特征向量输入至分类器中,并根据上述分类器的输出结果得到上述目标语句的情感语义类型。
在本说明书一个实施例中,上述对文本中的目标语句进行编码,得到上述目标语句中每个词对应的目标词向量,包括:通过情感分类模型中的预训练的语言表示模型,对文本中的目标语句进行编码,得到上述目标语句中每个词对应的目标词向量;上述对上述目标词向量的上下文语义特征进行提取,得到上述目标词向量对应的特征向量,包括:通过上述情感分类模型中的双向门控循环单元,对上述目标词向量的上下文语义特征进行提取,得到上述目标词向量对应的特征向量;在上述根据上述目标语句的情感语义类型以及上述目标语句中的关键词,得到对上述目标语句的分析结果之前,上述方法还包括:通过预设词典确定上述目标语句中的关键词。
在本说明书一个实施例中,在上述将文本中的目标语句输入至情感分类模型中之前,上述方法还包括:对待训练的情感分类模型进行训练,以确定上述情感分类模型;其中,上述对待训练的情感分类模型进行训练,以确定上述情感分类模型,包括:获取N个样本语句,并根据上述N个样本语句中第n样本语句的实际情感语义类型,对上述第n样本语句进行标注,得到第n标注语句,其中,N为正整数,n为小于等于N的正整数;通过上述预训练的语言表示模型,对上述第n标注语句进行编码,得到上述第n标注语句中M个词对应的M个词向量,其中,M为正整数;通过上述双向门控循环单元,对上述M个词向量的上下文语义特征进行提取,得到上述M个词向量对应的M个特征向量;对上述M个特征向量进行分类处理,以得到上述第n样本语句的预测情感语义类型;根据上述实际情感语义类型和上述预测情感语义类型确定上述待训练的情感分类模型的损失函数,并根据上述损失函数优化上述待训练的情感分类模型中的参数,以确定上述情感分类模型。
在本说明书一个实施例中,上述对上述M个特征向量进行分类处理,以得到上述第n样本语句的预测情感语义类型,包括:通过上述注意力机制确定上述M个特征向量在上述第n样本语句中的权重,得到M个加权特征向量;对上述M个加权特征向量进行分类处理,以得到上述第n样本语句的预测情感语义类型。
在本说明书一个实施例中,上述对上述M个加权特征向量进行分类处理,以得到上 述第n样本语句的预测情感语义类型,包括:对上述M个加权特征向量进行降维处理,得到M个降维特征向量;将上述M个降维特征向量输入至上述分类器中,并根据上述分类器的输出结果得到上述第n样本语句的预测情感语义类型。
根据本说明书实施例的第二个方面,提供一种情感分类模型,上述模型包括:预训练的语言表示模型,用于对文本中的目标语句进行编码,得到上述目标语句中每个词对应的目标词向量;双向门控循环单元,用于对上述目标词向量的上下文语义特征进行提取,得到上述目标词向量对应的特征向量;输出层,用于对上述特征向量进行分类处理,以得到上述目标语句的情感语义类型。
根据本说明书实施例的第三个方面,提供一种文本分析装置,上述装置包括:情感分类模块,用于:通过情感分类模型中的预训练的语言表示模型,对文本中的目标语句进行编码,得到上述目标语句中每个词对应的目标词向量;通过上述情感分类模型中的双向门控循环单元,对上述目标词向量的上下文语义特征进行提取,得到上述目标词向量对应的特征向量;通过上述情感分类模型对上述特征向量进行分类处理,以得到上述目标语句的情感语义类型;分析结果确定模块,用于:确定上述目标语句中的关键词,并根据上述目标语句的情感语义类型以及上述目标语句中的关键词,得到对上述目标语句的分析结果。
根据本说明书实施例的第四个方面,提供一种终端,包括:存储器、处理器以及存储在上述存储器中并可在上述处理器上运行的计算机程序,上述处理器执行上述计算机程序时实现上述第一个方面所述的文本分析方法。
根据本说明书实施例的第五个方面,提供一种计算机可读存储介质,其上存储有计算机程序,上述计算机程序被处理器执行时实现上述第一个方面所述的文本分析方法。
根据本说明书实施例的第六个方面,提供一种计算机程序产品,当上述计算机程序产品在计算机或处理器上运行时,使得上述计算机或处理器执行时实现上述第一个方面所述的文本分析方法。
本说明书的实施例所提供的文本分析方法、情感分类模型、文本分析装置、计算机可读存储介质、终端以及计算机程序产品,具备以下技术效果:本说明书示例性的实施例提供的方案适用于对文本语句的浅层特征提取以及深层上下文特征提取,以实现对文本的情感分类和观点分析。具体地,对文本中的目标语句进行编码,得到目标语句中每个词对应的目标词向量。然后,对目标词向量的上下文语义特征进行提取,得到目标词 向量对应的特征向量。之后,对特征向量进行分类处理,并根据分类结果得到目标语句的情感语义类型。最后,根据目标语句的情感语义类型以及目标语句中的关键词,得到对目标语句的分析结果。从而实现对文本的观点挖掘,并提高对观点的挖掘效果。
应当理解的是,以上的一般描述和后文的细节描述仅是示例性和解释性的,并不能限制本说明书。
附图说明
此处的附图被并入说明书中并构成本说明书的一部分,示出了符合本说明书的实施例,并与说明书一起用于解释本说明书的原理。显而易见地,下面描述中的附图仅仅是本说明书的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1是本说明书一示例性的实施例提供的文本分析方法的示意性流程图;
图2是本说明书一示例性的实施例提供的情感分类模型的示意性结构图;
图3是本说明书一示例性的实施例提供的预训练的语言表示模型的示意性结构图;
图4是本说明书一示例性的实施例提供的双向门控单元的示意性结构图;
图5是本说明书一示例性的实施例提供的特征向量分类方法的示意性流程图;
图6是本说明书一示例性的实施例提供的情感分类模型的训练方法的示意性流程图;
图7是本说明书一示例性的实施例提供的文本分析装置的示意性结构图;
图8是本说明书另一示例性的实施例提供的文本分析装置的示意性结构图;
图9是本说明书一示例性的实施例提供的终端的示意性框图。
具体实施方式
为使本说明书的目的、技术方案和优点更加清楚,下面将结合附图对本说明书实施例方式作进一步地详细描述。
下面的描述涉及附图时,除非另有表示,不同附图中的相同数字表示相同或相似的要素。以下示例性实施例中所描述的实施方式并不代表与本说明书相一致的所有实施方式。相反,它们仅是如所附权利要求书中所详述的、本说明书的一些方面相一致的装置和方法的例子。
在本说明书的描述中,需要理解的是,术语“第一”、“第二”等仅用于描述目的,而不能理解为指示或暗示相对重要性。对于本领域的普通技术人员而言,可以具体情况理解上述术语在本说明书中的具体含义。此外,在本说明书的描述中,除非另有说明,“多个”是指两个或两个以上。“和/或”,描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况。字符“/”一般表示前后关联对象是一种“或”的关系。
观点挖掘或情感分析旨在从文本中挖掘出人们所表达的观点或情感,以识别出人们所谈论的主题以及针对该主题所表达出的情感倾向等。
传统的观点挖掘或情感分析主要基于情感词典和机器学习模型,但这些方法需要大量的人工干预。并且,在新词频出的信息大***时代下,很难构建完备的情感词典;传统机器学习模型则面临数据特征稀疏、泛化能力不足等问题,无法很好地抽取文本中包含的情感信息。
针对上述问题,本说明书实施例提供了一种文本分析方法、情感分类模型、装置、介质及终端,下面,将结合附图及实施例对本示例实施方式中的文本分析方法的各个步骤进行更详细的说明。
其中,图1示意性示出了根据本说明书一示例性的实施例中文本分析方法的流程图,图2示出了本说明书一示例性的实施例中情感分类模型的结构图。情感分类模型可以运用于文本分析方法中。
本说明书实施例将结合图2示出的情感分类模型对图1所示实施例进行详细介绍。
在S110中,对文本中的目标语句进行编码,得到目标语句中每个词对应的目标词向量。
示例性的,理财师与用户在应用平台上沟通时,会生成若干沟通数据。可选的,沟通数据可以通过理财师与用户的聊天记录获取,也可以将理财师与用户的通话内容通过自动语音识别技术(Automatic Speech Recognition,ASR)转换为可识别的文本,等等。本实施例对获取沟通数据的方式不做限制。
示例性的,因为最终的目的是对理财师的观点进行分析,因此,在对沟通数据的获取过程中,主要是对理财师所发表的观点语句进行获取。例如,所获取的文本中的语句有:“相对于其他的理财产品,xxx产品是现在卖的比较好的产品。”,“您可以购买这种相对稳健一点的理财产品,后续的收益虽然不会比现在的投入高很多,但是不会造成亏 损。”,“但是这并不代表我不看好xxx企业。”,等等。
示例性的,接下来,可以将所获取的文本输入至图2所示的情感分类模型中。如图2所示,情感分类模型包括输入层、嵌入层、双向门控单元层、注意力机制层、以及输出层。
示例性的,其中,嵌入层包括预训练的语言表示模型,预训练的语言表示模型,用于对文本中的目标语句进行编码,得到目标语句中每个词对应的目标词向量。双向门控循环单元,用于对目标词向量的上下文语义特征进行提取,得到目标词向量对应的特征向量。输出层,用于对特征向量进行分类处理,以得到目标语句的情感语义类型。
下面以文本中的其中一个目标语句为例对具体的文本分析方法以及情感分类模型进行说明。
示例性的,如图2所示,假设目标语句中共有M个目标词,并将目标语句中的目标词记为W1、W2、W3、……Wm-2、Wm-1、Wm,其中,m取值为1至M的每一个正整数。将目标语句输入至嵌入层后,可以使用通过嵌入层对目标语句中的目标词进行编码,从而得到目标词对应的目标词向量。在嵌入层所使用的模型可以为预训练的语言表示模型,即BERT预训练模型。
示例性的,参考图3所示的预训练的语言表示模型的结构图。BERT预训练模型首先会对目标语句进行分词处理,并通过词嵌入(Token Embeddings)、段嵌入(Segment Embeddings)、以及位置嵌入(Position Embeddings)得到目标词对应的输入表征W1、W2、……、Wm。然后通过多个编码器(Transformer)得到目标词对应的目标词向量e1、e2、……、em。BERT预训练模型中只保留了原始Transformer的编码部分(Encoder)。使用多个Transformer实现双向编码,可以使得BERT预训练模型所输出的目标词向量能够尽可能地全面、准确地刻画输入目标语句的整体信息,能够处理一词多义的情况,并能配合上下文语境实现目标词向量的动态调整,提高对目标语句的浅层语义信息的提取效果。
在S120中,对目标词向量的上下文语义特征进行提取,得到目标词向量对应的特征向量。
示例性的,如图2所示,在得到上述目标词向量后,将它们输入至双向门控单元(Bidirectional Gated Recurrent Unit,BiGRU)层中。参考图4所示的双向门控单元的结构图。如图4所示,BiGRU模型中包括正向GRU和反向GRUGRU 单元保留了长短期记忆(Long Short-Term Memory,LSTM)对解决循环神经网络(Recurrent Neural Network,RNN)梯度消失问题的优点,并且内部结构更简单,参数减少了1/3,收敛时间和需要的迭代次数上也相对更胜一筹。
示例性的,其中,正向GRU用于处理正向目标语句(即正向排列的目标语句)的正向信息,反向GRU用于处理反向目标语句(即反向排列的目标语句,但目标词本身不反向)的反向信息,在每一时刻,输入会同时提供两个方向相反的GRU,而输出则由这两个GRU共同决定。通过BiGRU可以提取目标词向量对应的深层次的上下文语义特征,得到对应的特征向量,即特征向量中既包含目标词的上文信息(正向信息),也包含目标词的下文信息(反向信息)。
示例性的,如图4所示,以时刻t为例,其输出结果ht由正向GRU和反向GRU的输出连接组成,计算方法可参考公式(1)-(4):
xt=Weet,t∈[1,M]      (1)


其中,t取值为1至M的每一个正整数,We为BiGRU的权重矩阵,xt为根据目标词向量et得到的BiGRU的输入向量,表示在t时刻下正向传播的隐状态,表示在t时刻下反向传播的隐状态,最终输出的特征向量ht拼接而成,其中包含目标词向量et的双向语义信息,即上下文语义信息。
在S130中,对特征向量进行分类处理,以得到目标语句的情感语义类型。
一种可能的场景中,情感分类模型可以根据图5所示的流程图实现步骤S130的过程。该过程包括步骤S510步骤S530。
S510,通过注意力机制确定特征向量在目标语句中的权重,得到加权后的特征向量。
示例性的,如图2所示,由BiGRU层得到目标词向量对应的特征向量h1、h2、h3、……hm-2、hm-1、hm之后,将特征向量输入至注意力机制(Attention)层中。注意力机制是一种类似人脑的注意力资源分配机制,由于每个特征向量对目标语句的分类任务的重要性不同,例如,对于投顾观点的分类,“收益”会比“考虑”的重要性更高,因此,可以通过注意力机制来计算每个特征向量的重要性α1、α2、α3、……αm,从而为 特征向量分配相应的权重,得到加权后的特征向量。对重要性较高的特征向量分配更高的权重,从而在分类器进行分类时,重要性较高的特征向量可以获得更多的关注,提高情感分类模型的分类效果。
示例性的,对于特征向量的权重的计算方法,可参考公式(4)-(6):
ut=tanh(ωwht+bw),t∈[1,M]      (4)

V=∑tαtht          (6)
其中,ωw和bw为注意力机制的可调节权重和偏置项,ht为上述特征向量,ut为ht的隐含状态,uw为Softmax分类器的权重参数,αt用于计算特征向量的重要性,V即为加权后的特征向量。
示例性的,BiGRU-Attention结构可以利用注意力机制获取目标语句中最重要的信息,且在学习长距离语义上优于文本卷积神经网络(TextCNN),并且可以提高情感分类模型的分类效果。
S520,对加权后的特征向量进行降维处理,得到降维后的特征向量。
示例性的,接下来可以将加权后的特征向量输入至全连接层(Dense Layer)中,以进行降维处理,并得到降维后的特征向量。
S530,将降维后的特征向量输入至分类器中,并根据分类器的输出结果得到目标语句的情感语义类型。
示例性的,如图2所示,得到降维后的特征向量后,将其输入至输出层中的Softmax分类器中,从而得到情感分类模型的最终情感分类结果,即目标语句的情感语义类型,其中,情感语义类型可以包括“看好”、“不看好”、“中立”、“非观点”等等,情感语义类型可以根据具体的应用场景进行设定,本实施例对情感语义类型的内容不做限制。
示例性的,Softmax分类器的计算公式可参考公式(7):
p=softmax(ω0V+b0)        (7)
其中,ω0为权重系数矩阵,b0为偏置矩阵,p为输出的情感语义类型。
在S140中,根据目标语句的情感语义类型以及目标语句中的关键词,得到对目标语句的分析结果。
示例性的,通过上述目标语句的情感语义类型可以得知理财师所表达的情感语义。例如,对于目标语句“相对于其他的理财产品,xxx产品是现在卖的比较好的产品。”,将其输入至情感分类模型中,所得到的情感分类结果可能为“看好”,由此便可以得知理财师所表达的情感语义是积极的。
示例性的,除了得知理财师所表达的情感语义之外,还可以对理财师所发表的目标语句中的关键词进行获取。对于投顾场景,关键词可以包括基金产品、基金经理等等。关键词可以通过预设词典来进行识别与提取,预设词典可以根据具体的应用场景进行预先构建,例如,为投顾场景所构建的预设词典中,可以包括大量的与投顾场景相关的词汇。需要说明的是,对目标语句中关键词的提取方法可以通过深度神经网络实现,例如,循环神经网络(Recurrent Neural Network,RNN)、长短时记忆网络LSTM(Long-Short Term Memory)等等,本实施例中对关键词的提取方法不做限制。
示例性的,对于目标语句“相对于其他的理财产品,xxx产品是现在卖的比较好的产品。”,通过预设词典对该目标语句进行关键词的识别与提取后,所得到关键词可能为“xxx产品”等。
示例性的,在得到目标语句的情感类型以及关键词后,便可以对理财师的投顾观点进行整体的分析。例如,对于上述目标语句“相对于其他的理财产品,xxx产品是现在卖的比较好的产品。”,其情感类型为“看好”,关键词为“xxx产品”,那么便可以根据这两个结果分析得到理财师的投顾观点为“对xxx产品看好/对xxx产品持积极态度”。
示例性的,另外,通过本说明书所提供的文本分析方法,还可以构建能够执行该方法的文本分析***,该***可以运行于终端中,从而可以通过该***对理财师的观点和应用平台所提供的预设观点等进行离线批量分析以及在线实时分析。并且,还可以对观点分析结果以及观点中所涉及的理财产品进行跟踪与召回,从而有针对性地对理财师的分析效果和理财产品进行改善。从而可以提升理财应用平台中的投顾业务的水平和质量,提高并维持用户粘性。
本说明书还提供了一种情感分类模型的训练方法。具体的训练过程请参考图6所示实施例。
S610,获取N个样本语句,并根据N个样本语句中第n样本语句的实际情感语义类型,对第n样本语句进行标注,得到第n标注语句,其中,N为正整数,n为小于等于N的正整数。
示例性的,对于训练样本,同样可以通过理财师与用户的聊天记录获取,也可以将理财师与用户的通话内容通过自动语音识别技术(Automatic Speech Recognition,ASR)转换为可识别的文本,等等。本实施例对获取训练样本的方式不做限制。进一步的,可以将训练样本以语句为单位进行划分,得到N个样本语句。
示例性的,之后,再对N个样本语句中的第n样本语句进行标注,以确定第n样本语句的实际情感语义类型,其中,n取值为1至N的每一个正整数。例如,对于投顾场景,可以将实际情感语义类型分为“看好”、“不看好”、“中立”、“非观点”等等,并对每一种实际情感语义类型设定相应的情感标签(label)。例如,“看好”对应的标签可以为“3”,“不看好”对应的标签可以为“2”,“中立”对应的标签可以为“1”,“非观点”对应的标签可以为“0”。实际情感语义类型及其标签可以根据具体的应用场景进行设定,本实施例对情感语义类型的内容不做限制。
示例性的,对第n样本语句进行标注后,可以将所得到的第n标注语句通过输入层输入至情感分类模型中。
S620,通过预训练的语言表示模型,对第n标注语句进行编码,得到第n标注语句中M个词对应的M个词向量,其中,M为正整数。
示例性的,接下来,可以通过嵌入层中的BERT预训练模型对第n标注语句进行编码,以得到第n标注语句中M个词对应的M个词向量。
S630,通过双向门控循环单元,对M个词向量的上下文语义特征进行提取,得到M个词向量对应的M个特征向量。
示例性的,得到M个词向量后,将它们输入至BiGRU层中,以通过BiGRU对M个词向量的上下文语义特征进行提取,得到M个词向量对应的M个特征向量,特征向量中包含词向量的上下文语义信息。
S640,对M个特征向量进行分类处理,以得到第n样本语句的预测情感语义类型。
示例性的,得到M个特征向量后,将特征向量输入至注意力机制层中,以根据M个特征向量在第n标注语句中的重要性,来对M个特征向量分配对应的权重,最终得到M个加权特征向量。
示例性的,接下来,可以将M个加权特征向量输入至全连接层中,以对M个加权特征向量进行降维处理,得到M个降维特征向量。之后,再将M个降维特征向量输入至Softmax分类器中,并根据分类器的输出结果得到第n样本语句的预测情感语义类型。
示例性的,对于情感分类模型中上述各层的具体执行过程可以参考图1至图5所示的实施例,本实施例中不再赘述。
S650,根据实际情感语义类型和预测情感语义类型确定待训练的情感分类模型的损失函数,并根据损失函数优化待训练的情感分类模型中的参数,以确定情感分类模型。
示例性的,第n样本语句的预测情感语义类型可能与实际情感语义类型相同,也可能与实际情感语义类型不同。例如,假设对第n标注语句所标注的实际情感语义类型的情感标签为“3”,那么情感分类模型所输出的预测情感语义类型的情感标签可能为“3”,也可能为“2”等其他情感标签。即情感分类模型对于第n标注语句的分类可能具有一定的误差。因此,还需要根据预测情感语义类型和实际情感语义类型来对情感分类模型进行进一步的优化,以提高情感语义的分类效果。
示例性的,可以计算预测情感语义类型和实际情感语义类型的交叉熵,并通过最小化交叉熵的方法来优化情感分类模型中的相关参数,从而确定情感分类模型。交叉熵的计算公式可参考公式(8):
其中,D为训练数据集,C为情感标签的类型数,y为实际情感语义类型,为预测情感语义类型,λ为L2正则化,θ为可设置的参数。
本说明书实施例所提供的文本分析方法以及运用于文本分析方法的情感分类模型,对文本中的目标语句进行编码,得到目标语句中每个词对应的目标词向量,而对文本语句的浅层特征进行提取。然后,对目标词向量的上下文语义特征进行提取,得到目标词向量对应的特征向量,从而对文本语句的深层上下文特征进行提取。之后,对特征向量进行分类处理,并根据分类结果得到目标语句的情感语义类型。最后,根据目标语句的情感语义类型以及目标语句中的关键词,得到对目标语句的分析结果。从而实现对文本的观点挖掘,并提高对观点的挖掘效果。
下述为本说明书装置实施例,可以用于执行本说明书方法实施例。对于本说明书装置实施例中未披露的细节,请参照本说明书方法实施例。
其中,图7示出了根据本说明书一示例性的实施例中文本分析装置的结构图。
本说明书实施例中的文本分析装置700包括:情感分类模块710,以及分析结果确定模块720,其中:情感分类模块710,用于:通过情感分类模型中的预训练的语言表示模型,对文本中的目标语句进行编码,得到目标语句中每个词对应的目标词向量;通 过情感分类模型中的双向门控循环单元,对目标词向量的上下文语义特征进行提取,得到目标词向量对应的特征向量;通过情感分类模型对特征向量进行分类处理,以得到目标语句的情感语义类型;分析结果确定模块720,用于:确定目标语句中的关键词,并根据目标语句的情感语义类型以及目标语句中的关键词,得到对目标语句的分析结果。
其中,图8示出了根据本说明书另一示例性的实施例中文本分析装置的结构图。
一种可能的实现方式中,上述情感分类模块710具体用于:通过注意力机制确定特征向量在目标语句中的权重,得到加权后的特征向量;对加权后的特征向量进行分类处理,以得到目标语句的情感语义类型。
一种可能的实现方式中,上述情感分类模块710具体用于:对加权后的特征向量进行降维处理,得到降维后的特征向量;将降维后的特征向量输入至分类器中,并根据分类器的输出结果得到目标语句的情感语义类型。
一种可能的实现方式中,上述情感分类模块710具体用于:通过情感分类模型中的预训练的语言表示模型,对文本中的目标语句进行编码,得到目标语句中每个词对应的目标词向量。
一种可能的实现方式中,上述情感分类模块710具体用于:通过情感分类模型中的双向门控循环单元,对目标词向量的上下文语义特征进行提取,得到目标词向量对应的特征向量。
一种可能的实现方式中,上述情感分类模块710具体用于:通过预设词典确定目标语句中的关键词。
可选的,上述装置还包括:训练模块730。在上述情感分类模块710将文本中的目标语句输入至情感分类模型中之前,上述训练模块730用于:对待训练的情感分类模型进行训练,以确定情感分类模型。
一种可能的实现方式中,上述训练模块具体用于:获取N个样本语句,并根据N个样本语句中第n样本语句的实际情感语义类型,对第n样本语句进行标注,得到第n标注语句,其中,N为正整数,n为小于等于N的正整数;通过预训练的语言表示模型,对第n标注语句进行编码,得到第n标注语句中M个词对应的M个词向量,其中,M为正整数;通过双向门控循环单元,对M个词向量的上下文语义特征进行提取,得到M个词向量对应的M个特征向量;对M个特征向量进行分类处理,以得到第n样本语句的预测情感语义类型;根据实际情感语义类型和预测情感语义类型确定待训练的情感 分类模型的损失函数,并根据损失函数优化待训练的情感分类模型中的参数,以确定情感分类模型。
一种可能的实现方式中,上述训练模块具体用于:通过注意力机制确定M个特征向量在第n样本语句中的权重,得到M个加权特征向量;对M个加权特征向量进行分类处理,以得到第n样本语句的预测情感语义类型。
一种可能的实现方式中,上述训练模块具体用于:对M个加权特征向量进行降维处理,得到M个降维特征向量;将M个降维特征向量输入至分类器中,并根据分类器的输出结果得到第n样本语句的预测情感语义类型。
需要说明的是,上述实施例提供的文本分析装置在执行文本分析方法,时,仅以上述各功能模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能模块完成,即将设备的内部结构划分成不同的功能模块,以完成以上描述的全部或者部分功能。另外,上述实施例提供的文本分析装置与文本分析方法实施例属于同一构思,因此对于本说明书装置实施例中未披露的细节,请参照本说明书上述的文本分析方法的实施例,这里不再赘述。
上述本说明书实施例序号仅仅为了描述,不代表实施例的优劣。
本说明书实施例还提供了一种计算机可读存储介质,其上存储有计算机程序,该程序被处理器执行时实现前述任一实施例方法的步骤。其中,计算机可读存储介质可以包括但不限于任何类型的盘,包括软盘、光盘、DVD、CD-ROM、微型驱动器以及磁光盘、ROM、RAM、EPROM、EEPROM、DRAM、VRAM、闪速存储器设备、磁卡或光卡、纳米***(包括分子存储器IC),或适合于存储指令和/或数据的任何类型的媒介或设备。
本说明书实施例还提供了一种终端,包括存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,处理器执行程序时实现上述任一实施例方法的步骤。
图9示意性示出了根据本说明书一示例性的实施例中终端的结构图。请参见图9所示,终端900包括有:处理器901和存储器902。
本说明书实施例中,处理器901为计算机***的控制中心,可以是实体机的处理器,也可以是虚拟机的处理器。处理器901可以包括一个或多个处理核心,比如4核心处理器、8核心处理器等。处理器901可以采用数字信号处理(Digital Signal Processing,DSP)、现场可编程门阵列(Field-Programmable GateArray,FPGA)、可编程逻辑阵列 (ProgrammableLogic Array,PLA)中的至少一种硬件形式来实现。处理器901也可以包括主处理器和协处理器,主处理器是用于对在唤醒状态下的数据进行处理的处理器,也称中央处理器(CentralProcessing Unit,CPU);协处理器是用于对在待机状态下的数据进行处理的低功耗处理器。
在本说明书实施例中,上述处理器901具体用于:对文本中的目标语句进行编码,得到上述目标语句中每个词对应的目标词向量;对上述目标词向量的上下文语义特征进行提取,得到上述目标词向量对应的特征向量;对上述特征向量进行分类处理,以得到上述目标语句的情感语义类型;根据上述目标语句的情感语义类型以及上述目标语句中的关键词,得到对上述目标语句的分析结果。
进一步地,在本说明书一个实施例中,上述处理器901具体用于:通过注意力机制确定上述特征向量在上述目标语句中的权重,得到加权后的特征向量;对上述加权后的特征向量进行分类处理,以得到上述目标语句的情感语义类型。
可选的,上述处理器901具体用于:对上述加权后的特征向量进行降维处理,得到降维后的特征向量;将上述降维后的特征向量输入至分类器中,并根据上述分类器的输出结果得到上述目标语句的情感语义类型。
可选的,上述处理器901具体用于:通过情感分类模型中的预训练的语言表示模型,对文本中的目标语句进行编码,得到上述目标语句中每个词对应的目标词向量。
可选的,上述处理器901具体用于:通过上述情感分类模型中的双向门控循环单元,对上述目标词向量的上下文语义特征进行提取,得到上述目标词向量对应的特征向量。
可选的,上述处理器901还具体用于:通过预设词典确定上述目标语句中的关键词。
可选的,上述处理器901还具体用于:对待训练的情感分类模型进行训练,以确定上述情感分类模型。
可选的,上述处理器901具体用于:获取N个样本语句,并根据上述N个样本语句中第n样本语句的实际情感语义类型,对上述第n样本语句进行标注,得到第n标注语句,其中,N为正整数,n为小于等于N的正整数;通过上述预训练的语言表示模型,对上述第n标注语句进行编码,得到上述第n标注语句中M个词对应的M个词向量,其中,M为正整数;通过上述双向门控循环单元,对上述M个词向量的上下文语 义特征进行提取,得到上述M个词向量对应的M个特征向量;对上述M个特征向量进行分类处理,以得到上述第n样本语句的预测情感语义类型;根据上述实际情感语义类型和上述预测情感语义类型确定上述待训练的情感分类模型的损失函数,并根据上述损失函数优化上述待训练的情感分类模型中的参数,以确定上述情感分类模型。
可选的,上述处理器901具体用于:通过上述注意力机制确定上述M个特征向量在上述第n样本语句中的权重,得到M个加权特征向量;对上述M个加权特征向量进行分类处理,以得到上述第n样本语句的预测情感语义类型。
可选的,上述处理器901具体用于:对上述M个加权特征向量进行降维处理,得到M个降维特征向量;将上述M个降维特征向量输入至上述分类器中,并根据上述分类器的输出结果得到上述第n样本语句的预测情感语义类型。
存储器902可以包括一个或多个计算机可读存储介质,该计算机可读存储介质可以是非暂态的。存储器902还可包括高速随机存取存储器,以及非易失性存储器,比如一个或多个磁盘存储终端、闪存存储终端。在本说明书的一些实施例中,存储器902中的非暂态的计算机可读存储介质用于存储至少一个指令,该至少一个指令用于被处理器901所执行以实现本说明书实施例中的方法。
一些实施例中,终端900还包括有:***终端接口903和至少一个***终端。处理器901、存储器902和***终端接口903之间可以通过总线或信号线相连。各个***终端可以通过总线、信号线或电路板与***终端接口903相连。具体地,***终端包括:显示屏904、摄像头905和音频电路906中的至少一种。
***终端接口903可被用于将输入/输出(Input/Output,I/O)相关的至少一个***终端连接到处理器901和存储器902。在本说明书的一些实施例中,处理器901、存储器902和***终端接口903被集成在同一芯片或电路板上;在本说明书的一些其他实施例中,处理器901、存储器902和***终端接口903中的任意一个或两个可以在单独的芯片或电路板上实现。本说明书实施例对此不作具体限定。
显示屏904用于显示用户界面(UserInterface,UI)。该UI可以包括图形、文本、图标、视频及其它们的任意组合。当显示屏904是触摸显示屏时,显示屏904还具有采集在显示屏904的表面或表面上方的触摸信号的能力。该触摸信号可以作为控制信号输入至处理器901进行处理。此时,显示屏904还可以用于提供虚拟按钮和/或虚拟键盘,也称软按钮和/或软键盘。在本说明书的一些实施例中,显示屏904可以为一个,设置终 端900的前面板;在本说明书的另一些实施例中,显示屏904可以为至少两个,分别设置在终端900的不同表面或呈折叠设计;在本说明书的再一些实施例中,显示屏904可以是柔性显示屏,设置在终端900的弯曲表面上或折叠面上。甚至,显示屏904还可以设置成非矩形的不规则图形,也即异形屏。显示屏904可以采用液晶显示屏(Liquid CrystalDisplay,LCD)、有机发光二极管(OrganicLight-EmittingDiode,OLED)等材质制备。
摄像头905用于采集图像或视频。可选地,摄像头905包括前置摄像头和后置摄像头。通常,前置摄像头设置在终端的前面板,后置摄像头设置在终端的背面。在一些实施例中,后置摄像头为至少两个,分别为主摄像头、景深摄像头、广角摄像头、长焦摄像头中的任意一种,以实现主摄像头和景深摄像头融合实现背景虚化功能、主摄像头和广角摄像头融合实现全景拍摄以及虚拟现实(VirtualReality,VR)拍摄功能或者其它融合拍摄功能。在本说明书的一些实施例中,摄像头905还可以包括闪光灯。闪光灯可以是单色温闪光灯,也可以是双色温闪光灯。双色温闪光灯是指暖光闪光灯和冷光闪光灯的组合,可以用于不同色温下的光线补偿。
音频电路906可以包括麦克风和扬声器。麦克风用于采集用户及环境的声波,并将声波转换为电信号输入至处理器901进行处理。出于立体声采集或降噪的目的,麦克风可以为多个,分别设置在终端900的不同部位。麦克风还可以是阵列麦克风或全向采集型麦克风。
电源907用于为终端900中的各个组件进行供电。电源907可以是交流电、直流电、一次性电池或可充电电池。当电源907包括可充电电池时,该可充电电池可以是有线充电电池或无线充电电池。有线充电电池是通过有线线路充电的电池,无线充电电池是通过无线线圈充电的电池。该可充电电池还可以用于支持快充技术。
本说明书实施例中示出的终端结构框图并不构成对终端900的限定,终端900可以包括比图示更多或更少的组件,或者组合某些组件,或者采用不同的组件布置。
在本说明书中,术语“第一”、“第二”等仅用于描述的目的,而不能理解为指示或暗示相对重要性或顺序;术语“多个”则指两个或两个以上,除非另有明确的限定。术语“安装”、“相连”、“连接”、“固定”等术语均应做广义理解,例如,“连接”可以是固定连接,也可以是可拆卸连接,或一体地连接;“相连”可以是直接相连,也可以通过中间媒介间接相连。对于本领域的普通技术人员而言,可以根据具体情况理解上述术语在本说明书中的具体含义。
本说明书的描述中,需要理解的是,术语“上”、“下”等指示的方位或位置关系为基于附图所示的方位或位置关系,仅是为了便于描述本说明书和简化描述,而不是指示或暗示所指的装置或单元必须具有特定的方向、以特定的方位构造和操作,因此,不能理解为对本说明书的限制。
本说明书实施例还提供了计算机可读存储介质,该计算机可读存储介质中存储有指令,当其在计算机或处理器上运行时,使得计算机或处理器执行上述实施例中的一个或多个步骤。上述文本分析装置的各组成模块如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在上述计算机可读取存储介质中。
在上述实施例中,可以全部或部分地通过软件、硬件、固件或者其任意组合来实现。当使用软件实现时,可以全部或部分地以计算机程序产品的形式实现。上述计算机程序产品包括一个或多个计算机指令。在计算机上加载和执行上述计算机程序指令时,全部或部分地产生按照本说明书实施例上述的流程或功能。上述计算机可以是通用计算机、专用计算机、计算机网络、或者其他可编程装置。上述计算机指令可以存储在计算机可读存储介质中,或者通过上述计算机可读存储介质进行传输。上述计算机指令可以从一个网站站点、计算机、服务器或数据中心通过有线(例如同轴电缆、光纤、数字用户线(Digital Subscriber Line,DSL))或无线(例如红外、无线、微波等)方式向另一个网站站点、计算机、服务器或数据中心进行传输。上述计算机可读存储介质可以是计算机能够存取的任何可用介质或者是包含一个或多个可用介质集成的服务器、数据中心等数据存储设备。上述可用介质可以是磁性介质,(例如,软盘、硬盘、磁带)、光介质(例如,数字多功能光盘(Digital Versatile Disc,DVD))、或者半导体介质(例如,固态硬盘(Solid State Disk,SSD))等。
上述对本说明书特定实施例进行了描述。其它实施例在所附权利要求书的范围内。在一些情况下,在权利要求书中记载的动作或步骤可以按照不同于实施例中的顺序来执行并且仍然可以实现期望的结果。另外,在附图中描绘的过程不一定要求示出的特定顺序或者连续顺序才能实现期望的结果。在某些实施方式中,多任务处理和并行处理也是可以的或者可能是有利的。
以上所述,仅为本说明书的具体实施方式,但本说明书的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本说明书揭露的技术范围内,可轻易想到变化或替换,都应涵盖在本说明书的保护范围之内。因此,依本说明书权利要求所作的等同变化,仍属本说明书所涵盖的范围。

Claims (12)

  1. 一种文本分析方法,其中,包括:
    对文本中的目标语句进行编码,得到所述目标语句中每个词对应的目标词向量;
    对所述目标词向量的上下文语义特征进行提取,得到所述目标词向量对应的特征向量;
    对所述特征向量进行分类处理,以得到所述目标语句的情感语义类型;
    根据所述目标语句的情感语义类型以及所述目标语句中的关键词,得到对所述目标语句的分析结果。
  2. 根据权利要求1所述的文本分析方法,其中,所述对所述特征向量进行分类处理,以得到所述目标语句的情感语义类型,包括:
    通过注意力机制确定所述特征向量在所述目标语句中的权重,得到加权后的特征向量;
    对所述加权后的特征向量进行分类处理,以得到所述目标语句的情感语义类型。
  3. 根据权利要求2所述的文本分析方法,其中,所述对所述加权后的特征向量进行分类处理,以得到所述目标语句的情感语义类型,包括:
    对所述加权后的特征向量进行降维处理,得到降维后的特征向量;
    将所述降维后的特征向量输入至分类器中,并根据所述分类器的输出结果得到所述目标语句的情感语义类型。
  4. 根据权利要求1至3中任意一项所述的文本分析方法,其中,
    所述对文本中的目标语句进行编码,得到所述目标语句中每个词对应的目标词向量,包括:
    通过情感分类模型中的预训练的语言表示模型,对文本中的目标语句进行编码,得到所述目标语句中每个词对应的目标词向量;
    所述对所述目标词向量的上下文语义特征进行提取,得到所述目标词向量对应的特征向量,包括:
    通过所述情感分类模型中的双向门控循环单元,对所述目标词向量的上下文语义特征进行提取,得到所述目标词向量对应的特征向量;
    在所述根据所述目标语句的情感语义类型以及所述目标语句中的关键词,得到对所述目标语句的分析结果之前,所述方法还包括:
    通过预设词典确定所述目标语句中的关键词。
  5. 根据权利要求1至3中任意一项所述的文本分析方法,其中,在将文本中的目标 语句输入至情感分类模型中之前,所述方法还包括:对待训练的情感分类模型进行训练,以确定所述情感分类模型;
    其中,所述对待训练的情感分类模型进行训练,以确定所述情感分类模型,包括:
    获取N个样本语句,并根据所述N个样本语句中第n样本语句的实际情感语义类型,对所述第n样本语句进行标注,得到第n标注语句,其中,N为正整数,n为小于等于N的正整数;
    对所述第n标注语句进行编码,得到所述第n标注语句中M个词对应的M个词向量,其中,M为正整数;
    对所述M个词向量的上下文语义特征进行提取,得到所述M个词向量对应的M个特征向量;
    对所述M个特征向量进行分类处理,以得到所述第n样本语句的预测情感语义类型;
    根据所述实际情感语义类型和所述预测情感语义类型确定所述待训练的情感分类模型的损失函数,并根据所述损失函数优化所述待训练的情感分类模型中的参数,以确定所述情感分类模型。
  6. 根据权利要求5所述的文本分析方法,所述对所述M个特征向量进行分类处理,以得到所述第n样本语句的预测情感语义类型,包括:
    通过注意力机制确定所述M个特征向量在所述第n样本语句中的权重,得到M个加权特征向量;
    对所述M个加权特征向量进行分类处理,以得到所述第n样本语句的预测情感语义类型。
  7. 根据权利要求6所述的文本分析方法,其中,所述对所述M个加权特征向量进行分类处理,以得到所述第n样本语句的预测情感语义类型,包括:
    对所述M个加权特征向量进行降维处理,得到M个降维特征向量;
    将所述M个降维特征向量输入至所述分类器中,并根据所述分类器的输出结果得到所述第n样本语句的预测情感语义类型。
  8. 一种情感分类模型,其中,包括:
    预训练的语言表示模型,用于对文本中的目标语句进行编码,得到所述目标语句中每个词对应的目标词向量;
    双向门控循环单元,用于对所述目标词向量的上下文语义特征进行提取,得到所述目标词向量对应的特征向量;
    输出层,用于对所述特征向量进行分类处理,以得到所述目标语句的情感语义类型。
  9. 一种文本分析装置,其中,包括:
    情感分类模块,用于:通过情感分类模型中的预训练的语言表示模型,对文本中的目标语句进行编码,得到所述目标语句中每个词对应的目标词向量;通过所述情感分类模型中的双向门控循环单元,对所述目标词向量的上下文语义特征进行提取,得到所述目标词向量对应的特征向量;通过所述情感分类模型对所述特征向量进行分类处理,以得到所述目标语句的情感语义类型;
    分析结果确定模块,用于:确定所述目标语句中的关键词,并根据所述目标语句的情感语义类型以及所述目标语句中的关键词,得到对所述目标语句的分析结果。
  10. 一种终端,包括存储器、处理器以及存储在所述存储器中并可在所述处理器上运行的计算机程序,其特征在于,所述处理器执行所述计算机程序时实现如权利要求1至7中任一项所述的文本分析方法。
  11. 一种计算机可读存储介质,其上存储有计算机程序,其特征在于,所述计算机程序被处理器执行时实现如权利要求1至7中任一项所述的文本分析方法。
  12. 一种包含指令的计算机程序产品,当所述计算机程序产品在计算机或处理器上运行时,使得所述计算机或处理器执行如权利要求1至7中任一项所述的文本分析方法。
PCT/CN2023/131788 2022-11-28 2023-11-15 文本分析方法、情感分类模型、装置、介质、终端及产品 WO2024114382A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202211503709.4A CN115828889A (zh) 2022-11-28 2022-11-28 文本分析方法、情感分类模型、装置、介质、终端及产品
CN202211503709.4 2022-11-28

Publications (1)

Publication Number Publication Date
WO2024114382A1 true WO2024114382A1 (zh) 2024-06-06

Family

ID=85532318

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2023/131788 WO2024114382A1 (zh) 2022-11-28 2023-11-15 文本分析方法、情感分类模型、装置、介质、终端及产品

Country Status (2)

Country Link
CN (1) CN115828889A (zh)
WO (1) WO2024114382A1 (zh)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115828889A (zh) * 2022-11-28 2023-03-21 蚂蚁财富(上海)金融信息服务有限公司 文本分析方法、情感分类模型、装置、介质、终端及产品
CN116822522B (zh) * 2023-06-13 2024-05-28 连连银通电子支付有限公司 一种语义分析方法、装置、设备及存储介质

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20110087483A1 (en) * 2009-10-09 2011-04-14 Institute For Information Industry Emotion analyzing method, emotion analyzing system, computer readable and writable recording medium and emotion analyzing device
CN105893344A (zh) * 2016-03-28 2016-08-24 北京京东尚科信息技术有限公司 基于用户语义情感分析的应答方法和装置
CN106855852A (zh) * 2015-12-09 2017-06-16 北京国双科技有限公司 语句情感的确定方法及装置
CN114564565A (zh) * 2022-03-02 2022-05-31 湖北大学 面向公共安全事件分析的深度语义识别模型及其构建方法
CN115828889A (zh) * 2022-11-28 2023-03-21 蚂蚁财富(上海)金融信息服务有限公司 文本分析方法、情感分类模型、装置、介质、终端及产品

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20110087483A1 (en) * 2009-10-09 2011-04-14 Institute For Information Industry Emotion analyzing method, emotion analyzing system, computer readable and writable recording medium and emotion analyzing device
CN106855852A (zh) * 2015-12-09 2017-06-16 北京国双科技有限公司 语句情感的确定方法及装置
CN105893344A (zh) * 2016-03-28 2016-08-24 北京京东尚科信息技术有限公司 基于用户语义情感分析的应答方法和装置
CN114564565A (zh) * 2022-03-02 2022-05-31 湖北大学 面向公共安全事件分析的深度语义识别模型及其构建方法
CN115828889A (zh) * 2022-11-28 2023-03-21 蚂蚁财富(上海)金融信息服务有限公司 文本分析方法、情感分类模型、装置、介质、终端及产品

Also Published As

Publication number Publication date
CN115828889A (zh) 2023-03-21

Similar Documents

Publication Publication Date Title
WO2021047286A1 (zh) 文本处理模型的训练方法、文本处理方法及装置
CN108985358B (zh) 情绪识别方法、装置、设备及存储介质
CN112131350B (zh) 文本标签确定方法、装置、终端及可读存储介质
US11409791B2 (en) Joint heterogeneous language-vision embeddings for video tagging and search
WO2024114382A1 (zh) 文本分析方法、情感分类模型、装置、介质、终端及产品
US10303768B2 (en) Exploiting multi-modal affect and semantics to assess the persuasiveness of a video
CN111026861B (zh) 文本摘要的生成方法、训练方法、装置、设备及介质
JP6967059B2 (ja) 映像を生成するための方法、装置、サーバ、コンピュータ可読記憶媒体およびコンピュータプログラム
JP2023509031A (ja) マルチモーダル機械学習に基づく翻訳方法、装置、機器及びコンピュータプログラム
CN110737801A (zh) 内容分类方法、装置、计算机设备和存储介质
CN111444357B (zh) 内容信息确定方法、装置、计算机设备及存储介质
CN107066464A (zh) 语义自然语言向量空间
Shashidhar et al. Combining audio and visual speech recognition using LSTM and deep convolutional neural network
CN112069309B (zh) 信息获取方法、装置、计算机设备及存储介质
WO2022253061A1 (zh) 一种语音处理方法及相关设备
CN109034203A (zh) 表情推荐模型的训练、表情推荐方法、装置、设备及介质
CN116955699B (zh) 一种视频跨模态搜索模型训练方法、搜索方法及装置
WO2023071562A1 (zh) 语音识别文本处理方法、装置、设备、存储介质及程序产品
CN112364168A (zh) 一种基于多属性信息融合的舆情分类方法
CN111783903A (zh) 文本处理方法、文本模型的处理方法及装置、计算机设备
CN116821457B (zh) 一种基于多模态大模型的智能咨询及舆情处理***
WO2020192523A1 (zh) 译文质量检测方法、装置、机器翻译***和存储介质
CN113158656A (zh) 讽刺内容识别方法、装置、电子设备以及存储介质
CN112115131A (zh) 数据去噪方法、装置、设备及计算机可读存储介质
Gandhi et al. Multimodal sentiment analysis: review, application domains and future directions