Emotion polarity representation method, device and computer storage medium
By referring to the context of the Ou's semantic space, it is mapped to the dual -song semantic space, and the dual -curved distance is calculated, which solves the problem of not effectively tap emotional information in the existing technology. Polarity representation and semantic hierarchical structure is better embedded.
Patent Information
- Application Number
- CN202111081658.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-15
- Publication Date
- 2025-01-28
- Estimated Expiration
- 2041-09-15
AI Technical Summary
Existing structural probes can only mine syntactic information in language models and fail to effectively mine other valuable semantic information, especially emotional polarity information.
By obtaining the context word under the Eushi semantic space, and entering the pre -trained probe, the parameters of the probe are mapped to the dual -song semantic space, and The distance, determine the emotional polarity according to the negative correlation relationship.
The effective emotional polarity of the context vector vector is realized. The embedded of the dual -song semantic space can better capture the semantic structure and emotional information, and improve the reliability of semantic indelding bias and emotional representation.
Smart Images

Figure CN113947088B_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present invention relate to the field of computer technology, and in particular, to a method and device for expressing emotion polarity, and a computer storage medium. Background Art
[0002] Generally speaking, contextual word representations contain rich semantic information, and pre-trained language models that learn contextual word representations can achieve significant performance improvements in various downstream tasks of natural language processing.
[0003] Typically, probes can be constructed that are external to different components of a language model, such as a pre-trained model, to determine the semantic information learned by each component. For example, a structural probe can be constructed to explore how a grammatical tree is encoded in the context word representation of a language model.
[0004] However, structural probes only mine the syntactic information in the language model, but fail to mine other valuable semantic information. Summary of the invention
[0005] In view of this, an embodiment of the present invention provides a method, device and computer storage medium for expressing emotion polarity to at least partially solve the above-mentioned problems.
[0006] According to a first aspect of an embodiment of the present invention, a method for representing sentiment polarity is provided, comprising: obtaining a context word representation in a Euclidean semantic space; inputting the context word representation into a pre-trained probe to obtain a sentiment representation in a hyperbolic semantic space, wherein a parameter of the pre-trained probe indicates a mapping from the Euclidean semantic space to the hyperbolic semantic space; calculating a hyperbolic distance between the sentiment representation and a sentiment polarity meta-representation in the hyperbolic semantic space, the sentiment polarity meta-representation indicating a positive sentiment or a negative sentiment in the hyperbolic semantic space; and determining the degree of sentiment polarity represented by the context word according to a negative correlation with the hyperbolic distance.
[0007] According to a second aspect of an embodiment of the present invention, a sentiment polarity representation device is provided, comprising: an acquisition module, which acquires context word representation in a Euclidean semantic space; a mapping module, which inputs the context word representation into a pre-trained probe to obtain a sentiment representation in a hyperbolic semantic space, wherein the parameters of the pre-trained probe are used for mapping from the Euclidean semantic space to the hyperbolic semantic space; a calculation module, which calculates the hyperbolic distance between the sentiment representation and a sentiment polarity meta-representation in the hyperbolic semantic space, wherein the sentiment polarity meta-representation indicates a positive emotion or a negative emotion in the hyperbolic semantic space; and a determination module, which determines the degree of sentiment polarity represented by the context word according to a negative correlation with the hyperbolic distance.
[0008] According to a third aspect of an embodiment of the present invention, there is provided an electronic device, comprising: a processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other via the communication bus; the memory is used to store at least one executable instruction, and the executable instruction enables the processor to perform an operation corresponding to the method described in the first aspect.
[0009] According to a fourth aspect of an embodiment of the present invention, there is provided a computer storage medium on which a computer program is stored. When the program is executed by a processor, the method described in the first aspect is implemented.
[0010] In the scheme of the embodiment of the present invention, since the pre-trained probe can map the context word representation in the Euclidean semantic space to the hyperbolic semantic space, the hyperbolic space can embed the semantic hierarchical structure of the context word representation more efficiently, so the pre-trained probe achieves a better semantic induction bias, thereby obtaining a reliable sentiment representation in the hyperbolic semantic space. In addition, by calculating the hyperbolic distance between the sentiment representation and the sentiment polarity element representation in the hyperbolic semantic space, the degree of sentiment polarity of the context word representation can be effectively obtained, and an effective sentiment polarity representation of the context word vector is achieved. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the embodiments of the present invention. For ordinary technicians in this field, other drawings can also be obtained based on these drawings.
[0012] Figure 1 A schematic diagram of a typical example of a probe used to pre-train a language model;
[0013] Figure 2A A flowchart of a method for expressing sentiment polarity according to another embodiment of the present invention;
[0014] Figure 2B A schematic diagram of a method for expressing sentiment polarity according to another embodiment of the present invention;
[0015] Figure 3 A flowchart of a method for expressing sentiment polarity according to another embodiment of the present invention;
[0016] Figure 4 is a structural block diagram of a device for expressing emotion polarity according to another embodiment of the present invention; and
[0017] Figure 5FIG. 4 is a schematic structural diagram of an electronic device according to another embodiment of the present invention. DETAILED DESCRIPTION
[0018] In order to enable those skilled in the art to better understand the technical solutions in the embodiments of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. All other embodiments obtained by ordinary technicians in the field based on the embodiments in the embodiments of the present invention should fall within the scope of protection of the embodiments of the present invention.
[0019] The specific implementation of the embodiment of the present invention is further described below in conjunction with the accompanying drawings of the embodiment of the present invention.
[0020] Figure 1 A typical example of a probe used to pre-train a language model is shown in Figure 2. Figure 1 As shown, pre-trained language models (Pre-trained Language Models, PLMs) include models for natural language processing (Natural Language Processing, NLP), specifically, including but not limited to ELMo models, generative pre-training (Generative Pre-Training, GPT) models, bidirectional encoder representations from transformers (Bidirectional Encoder Representations from Transformers, BERT) models, and models improved based on the BERT model.
[0021] This example uses BERT as an example to explain and illustrate the semantic analysis process of the probe. It should be understood that the probe can not only perform semantic analysis on the pre-trained language model, but also on other models used for natural language processing.
[0022] In general, the probe can be constructed as a neural network, connected to a neural network model that has been trained or phased, and performs semantic analysis on the model. Specifically, the probe can be connected to at least one component (e.g., at least one encoder) of the BERT model to obtain the contextual semantic relationship learned by at least one component, for example, Figure 1 In the example, the probe obtains context word representations from at least one component.
[0023] In one example, the probe may be a structural probe, which is used to map word representations into a high-dimensional semantic space and calculate the distances between word representations and the corresponding relationship between the distances between words in the syntax tree in the high-dimensional semantic space.
[0024] Although structure probes effectively perform semantic dependency analysis on pre-trained language models such as BERT, they are unable to mine valuable semantic information such as sentiment polarity.
[0025] Figure 2A This is a flowchart of the steps of the emotion polarity representation method according to another embodiment of the present invention. The solution of this embodiment can be applied to any appropriate electronic device with data processing capabilities, including but not limited to: servers, mobile terminals (such as mobile phones, PADs, etc.) and PCs, etc. Specifically, the device to which the solution of this embodiment is applicable has a hardware and software configuration capable of performing neural network operations. Figure 1 The sentiment polarity representation methods include:
[0026] S210: Obtain context word representation in the Euclidean semantic space.
[0027] It should be understood that the "word" in the word representation in this embodiment includes but is not limited to words, phrases, words, characters, etc. For example, in the Latin language family, "word" can refer to a word, and in the Sino-Tibetan language family, "word" can refer to a character.
[0028] It should also be understood that the context word representation can be obtained from at least one component of a language model such as a pre-trained model. For example, the context word representation can be obtained from at least one encoder of a BERT model. The context word representation can be expressed in the form of a word vector or other mathematical expressions, which is not limited in this embodiment.
[0029] S220: Input the context word representation into a pre-trained probe to obtain a sentiment representation in a hyperbolic semantic space, wherein the parameters of the pre-trained probe are used for mapping from the Euclidean semantic space to the hyperbolic semantic space.
[0030] It should be understood that the pre-trained probe can be obtained by training the neural network structure. The context word representation output by at least one component of the language model such as the pre-trained model can be used as a training sample to train the neural network. Preferably, the context word representation output by different components can be used to train the neural network. Preferably, in the training sample, the context word representation output by the component of the middle layer has a larger data ratio than the context word representation output by the components on both sides.
[0031] It should also be understood that the neural network structure may include an exponential mapping function and a linear mapping matrix connected in sequence. The neural network structure may also include a first linear mapping matrix, an exponential mapping matrix, and a second linear mapping matrix connected in sequence.
[0032] S230: Calculate the hyperbolic distance between the emotion representation and the emotion polarity meta-representation in the hyperbolic semantic space, where the emotion polarity meta-representation indicates a positive emotion or a negative emotion in the hyperbolic semantic space.
[0033] It should be understood that the sentiment polarity meta-representation can be a hyperparameter that can be set. An initial meta-representation can also be set, and as the probe is trained, the meta-representation is continuously adjusted to obtain the sentiment polarity meta-representation.
[0034] It should also be understood that sentiment polarity, including positive and negative, is defined as a hierarchical structure, for example, words of the same polarity are closer to the root of the sentiment polarity branch.
[0035] S240: Determine the degree of sentiment polarity represented by the context word based on the negative correlation with the hyperbolic distance.
[0036] It should be understood that if the sentiment polarity element indicates that the sentiment is positive, then there is a negative correlation between the degree of sentiment positivity expressed by the context word and the hyperbolic distance. In other words, the larger the hyperbolic distance, the smaller the degree of sentiment positivity and the larger the degree of sentiment negativity. If the sentiment polarity element indicates that the sentiment is negative, then there is a negative correlation between the degree of sentiment negativity expressed by the context word and the hyperbolic distance. In other words, the larger the hyperbolic distance, the smaller the degree of sentiment negativity and the larger the degree of sentiment positivity.
[0037] In other words, the sentiment polarity includes opposite first sentiment polarity and second sentiment polarity (eg, sentiment negative and sentiment positive). The first sentiment polarity degree of the context word representation is positively correlated with the second sentiment polarity meta-representation and the hyperbolic distance.
[0038] In the scheme of the embodiment of the present invention, since the pre-trained probe can map the context word representation in the Euclidean semantic space to the hyperbolic semantic space, the hyperbolic space can embed the semantic hierarchical structure of the context word representation more efficiently, so the pre-trained probe achieves a better semantic induction bias, thereby obtaining a reliable sentiment representation in the hyperbolic semantic space. In addition, by calculating the hyperbolic distance between the sentiment representation and the sentiment polarity element representation in the hyperbolic semantic space, the degree of sentiment polarity of the context word representation can be effectively obtained, and an effective sentiment polarity representation of the context word vector is achieved.
[0039] In other words, the structural probe is based on the assumption of Euclidean semantic space, and uses the square of the Euclidean distance between word representations to correspond to the distance in the syntactic dependency relationship. In other words, the hierarchical structure of syntactic dependency relationships cannot be effectively embedded in the Euclidean semantic space, while the hierarchical structure of syntactic dependency relationships can be effectively embedded in the hyperbolic semantic space of the embodiment of the present invention.
[0040] In addition, the neural network structure of the probe of this embodiment can also be trained into a model for analyzing semantic dependencies through grammatical analysis tasks. In this case, the sentiment expression under the hyperbolic semantic space in the sentiment polarity analysis corresponds to the semantic dependency expression, and in the hyperbolic semantic space, the distance between the semantic dependency expressions of the two words indicates the distance in the semantic dependency, which more reliably represents the distance in the semantic dependency than in the Euclidean semantic space. In other words, the neural network structure of the probe of this embodiment more efficiently embeds the hierarchical structure of semantic dependencies in the hyperbolic semantic space, and is better compatible with a variety of semantic analysis tasks.
[0041] As another implementation method of this embodiment, the degree of emotion polarity includes the degree of emotion positivity, and the hyperbolic distance between the emotion polarity meta-representation indicating the emotion negativity is positively correlated with the degree of emotion positivity, or the degree of emotion polarity includes the degree of emotion negativity, and the hyperbolic distance between the emotion polarity meta-representation indicating the emotion positivity is positively correlated with the degree of emotion negativity.
[0042] Since the emotion polarity meta-representation indicating negative emotion is relative to the emotion polarity meta-representation indicating negative emotion, the higher the degree of positive emotion represented by a specific context word, the lower the degree of negative emotion. The hyperbolic distance between the emotion polarity meta-representation indicating negative emotion and the hyperbolic distance between the emotion polarity meta-representation indicating positive emotion are negatively correlated. Based on such a configuration of the present embodiment, the degree of emotion polarity represented by the context word can be quickly obtained.
[0043] In addition, the two distances can be combined to comprehensively determine the degree of sentiment polarity represented by the context word, namely, the hyperbolic distance between the sentiment polarity meta-representation indicating negative sentiment and the hyperbolic distance between the sentiment polarity meta-representation indicating positive sentiment.
[0044] As another implementation method of this embodiment, the context word representation is input into a pre-trained probe to obtain the sentiment representation in the hyperbolic semantic space, including: mapping the context word representation in the Euclidean semantic space to a low-dimensional semantic space having a dimension lower than the Euclidean semantic space through the first parameter of the pre-trained probe; mapping the context word representation in the low-dimensional semantic space to the hyperbolic semantic space through the second parameter of the pre-trained probe to obtain the sentiment representation in the hyperbolic semantic space.
[0045] Based on this configuration, the mapping from Euclidean semantic space to hyperbolic semantic space is achieved using simple operations.
[0046] As another implementation manner of this embodiment, the dimension of the first Euclidean semantic space is one order of magnitude lower than the dimension of the second Euclidean semantic space.
[0047] Since sentiment polarity analysis requires a lower dimension than the context word representation, based on this configuration, the computational efficiency is improved while ensuring the accuracy of the sentiment polarity degree. In addition, due to the limitation of the modulus length in the hyperbolic space, the excessively high dimension makes the element value of each dimension too small. Through the above-mentioned dimensionality reduction process, the element value in the hyperbolic semantic space is increased, and the numerical accuracy is improved.
[0048] As another implementation method of this embodiment, the context word representation in the Euclidean semantic space is mapped to a low-dimensional semantic space whose dimension is lower than that of the Euclidean semantic space through the first parameter of the pre-trained probe, including: multiplying the first word vector corresponding to the context word representation in the Euclidean semantic space with the first linear mapping matrix to obtain a second word vector corresponding to the context word representation in the low-dimensional semantic space, wherein the two dimensions of the first linear mapping matrix are respectively equal to the dimension of the Euclidean semantic space and the dimension of the low-dimensional semantic space.
[0049] Based on such a configuration, the above-mentioned dimensionality reduction processing is implemented by using a concise first linear mapping matrix, thereby improving the efficiency of the dimensionality reduction processing.
[0050] Specifically, Figure 2B FIG. 1 shows a method for expressing sentiment polarity according to another embodiment of the present invention. As shown in the figure, the probe may include a first linear mapping matrix and the second linear mapping matrix The k-dimensional hyperbolic sphere model is Let L represent the language model, given a sentence w of t words 1:t , the language model generates contextual word representations
[0051] The probes of this embodiment may include syntactic probes and sentiment probes.
[0052] In one example, the probe of this embodiment can project the context word representation of the pre-trained language model into the syntactic semantic space.
[0053] In another example, the probe of this embodiment is able to represent the context words of the pre-trained language model in a hyperbolic semantic space (emotional semantic space).
[0054] It should be understood that the first linear mapping matrix P in the hyperbolic probe can represent the high-dimensional word generated by the language model L 1:t (For example, BERT base The first word vector of the first Euclidean semantic space is projected to a semantic space of lower dimension (e.g., 64 dimensions) by linear mapping (which may be 768 dimensions). In other words, the first word vector of the first Euclidean semantic space is mapped to the second word vector of the second Euclidean semantic space. It should be understood that the dimension of the first Euclidean semantic space may be one order of magnitude lower than the dimension of the second Euclidean semantic space.
[0055]
[0056] Then, the second word vector can be projected into the hyperbolic space using the exponential mapping and the second linear mapping matrix Q,
[0057]
[0058] in, represents the Möbius matrix-vector multiplication ( Matrix-Vector Multiplication), q i is a vector in hyperbolic space.
[0059] Furthermore, for two vectors q in hyperbolic space i and q j , the hyperbolic distance between the two can be obtained by calculation:
[0060]
[0061] In one example, for a syntactic probe task, we can let d 距离 (w i , w j ) represents the distance between words i and j on the dependency syntax tree, that is, the number of edges connecting words i and j. We can let d 深度 (w i ) represents the depth of word i in the syntax tree, that is, the length of the edge from word i to the root node of the syntax tree. The optimization goals of the syntax probe for distance and depth are:
[0062]
[0063]
[0064] The optimization method used is Adam.
[0065] In another example, for the emotion probe task, we can set the learnable emotion positive meta-representation and emotion negative meta-representation
[0066] As another implementation method of this embodiment, the context word representation in the low-dimensional semantic space is mapped to the hyperbolic semantic space through the second parameter of the pre-trained probe to obtain the sentiment representation in the hyperbolic semantic space, including: performing exponential mapping processing on the second word vector to obtain the exponential mapping vector of the second word vector; using the Möbius matrix-vector multiplication to multiply the exponential mapping vector with the second linear mapping matrix to obtain a vector corresponding to the sentiment representation in the hyperbolic semantic space.
[0067] Based on such a configuration, the mapping process of context word representation from Euclidean semantic space to hyperbolic semantic space is efficiently implemented using exponential mapping processing and the second linear mapping matrix.
[0068] As another implementation of this embodiment, the method also includes: determining each first hyperbolic distance between each context word representation and the emotional positive element representation corresponding to the target sentence, and each second hyperbolic distance between each context word representation and the emotional negative element representation; summing each first hyperbolic distance and each second hyperbolic distance respectively to obtain a first hyperbolic distance sum and a second hyperbolic distance sum; determining a negative emotional degree that is positively correlated with the first hyperbolic distance sum, and a positive emotional degree that is positively correlated with the second hyperbolic distance sum.
[0069] Since each first hyperbolic distance reflects the degree of negative emotion expressed by each context word, and each second hyperbolic distance reflects the degree of positive emotion expressed by each context word, the corresponding first hyperbolic distance sum and second hyperbolic distance sum respectively indicate the degree of negative emotion and the degree of positive emotion of the target sentence. In addition, the degree of emotional polarity of the target sentence is more stable and accurate than the degree of emotional polarity expressed by the context words.
[0070] As another implementation of this embodiment, the probe is trained in the following manner: taking the representations of each context word corresponding to the sentence sample as the input of the neural network, and taking the degree of sentiment polarity of the sentence sample as a supervision condition to train the neural network, wherein the neural network includes a first neural network and a second neural network, the output of the first neural network is connected to the input of the second neural network, the first neural network is used to map the representations of each context word from the Euclidean semantic space to the hyperbolic semantic space, and the second neural network is used to calculate the sentiment representation in the hyperbolic space and calculate the degree of sentiment polarity of the sentence sample; the trained first neural network is determined as the probe.
[0071] Based on this configuration, the sentiment polarity of sentence samples is used as a supervision condition, and the sentiment polarity at the word level can be restored from the supervision information at the sentence level. In addition, the sentiment polarity of sentence samples is more stable and accurate than the representation of context words, and is convenient for sentiment polarity labeling, which improves the analysis accuracy of the probe while reducing the workload of manual labeling.
[0072] Specifically, the sentence-level sentiment polarity can be calculated by the hyperbolic distance between each word and the opposite sentiment meta-representation,
[0073]
[0074] After Softmax normalization, cross entropy is used as the loss function. The optimization method adopts the Riemannian Adaption method.
[0075] As another implementation method of this embodiment, the second neural network calculates the degree of sentiment polarity of the sentence sample based on the hyperbolic distances between the sentiment representation represented by each context word and the sentiment polarity meta-representation to be adjusted. During the training of the second neural network, the sentiment polarity meta-representation to be adjusted is adjusted to obtain the sentiment polarity meta-representation.
[0076] Based on such a configuration, the sentiment polarity meta-representation to be adjusted is accurately adjusted in the training of the second neural network, and a more accurate sentiment polarity meta-representation is obtained, thereby improving the accuracy of the sentiment polarity degree represented by the context words.
[0077] The following will be combined Figure 3 A method for expressing emotion polarity of a specific example is described. It should be understood that the method for expressing emotion polarity of this example is merely exemplary, and the method of this example may include more or fewer steps than the steps shown, and some of the steps may also be replaced by other implementations. The scheme of this embodiment can be applied to any appropriate electronic device with data processing capabilities, including but not limited to: servers, mobile terminals (such as mobile phones, PADs, etc.) and PCs, etc. Specifically, the device to which the scheme of this embodiment is applicable has a hardware and software configuration capable of performing neural network operations. Specifically, Figure 3 The following are the steps of a method for expressing sentiment polarity according to another embodiment of the present invention:
[0078] S310: Obtain context word representation in the Euclidean semantic space.
[0079] Specifically, the context word representation can be obtained from at least one component of a language model such as a pre-trained model. For example, the context word representation can be obtained from at least one encoder of a BERT model. The context word representation can be expressed in the form of a word vector or other mathematical expressions, which is not limited in this embodiment.
[0080] S320: Multiply the first word vector corresponding to the context word representation in the Euclidean semantic space by the first linear mapping matrix to obtain a second word vector corresponding to the context word representation in the low-dimensional semantic space.
[0081] Specifically, the pre-trained probe may include a first linear mapping matrix, an exponential mapping function, and a second linear mapping matrix connected in sequence. The pre-trained probe may be obtained by training a neural network structure. The context word representation output by at least one component of a language model such as a pre-trained model may be used as a training sample to train the neural network. Preferably, the context word representation output by different components may be used to train the neural network. Preferably, in the training sample, the context word representation output by the component of the middle layer has a larger data ratio than the context word representation output by the components on both sides. The two dimensions of the first linear mapping matrix are equal to the dimension of the Euclidean semantic space and the dimension of the low-dimensional semantic space, respectively.
[0082] S330: Perform exponential mapping processing on the second word vector to obtain an exponential mapping vector of the second word vector.
[0083] Specifically, the second word vector can be projected into the hyperbolic space using the exponential mapping and the second linear mapping matrix Q.
[0084]
[0085] in, represents the Möbius matrix-vector multiplication ( Matrix-Vector Multiplication).
[0086] S340: Using the Möbius matrix-vector multiplication, the exponential mapping vector is multiplied by the second linear mapping matrix to obtain a vector corresponding to the sentiment representation in the hyperbolic semantic space.
[0087] Specifically, the hyperbolic distance between word representations can be obtained by calculation:
[0088]
[0089] Based on such a configuration, the mapping process of context word representation from Euclidean semantic space to hyperbolic semantic space is efficiently implemented using exponential mapping processing and the second linear mapping matrix.
[0090] S350: Calculate a first hyperbolic distance between a vector corresponding to the emotion representation in a hyperbolic semantic space and a vector indicating a positive element representation of the emotion, and a second hyperbolic distance between a vector corresponding to the emotion representation and a vector indicating a negative element representation of the emotion.
[0091] Specifically, the sentiment polarity meta-representation indicates sentiment positivity or sentiment negativity in a hyperbolic semantic space. The sentiment polarity meta-representation can have settable hyperparameters. An initial meta-representation can also be set, and as the probe is trained, the meta-representation is continuously adjusted to obtain the sentiment polarity meta-representation. Sentiment polarity, including positive and negative, is defined as a hierarchical structure, for example, words of the same polarity are closer to the root of the sentiment polarity branch.
[0092] S360: Determine a negative emotion level that is positively correlated with the first hyperbolic distance, and a positive emotion level that is positively correlated with the second hyperbolic distance.
[0093] Specifically, if the sentiment polarity element indicates that the sentiment is positive, then there is a negative correlation between the sentiment positivity expressed by the context word and the hyperbolic distance. In other words, the larger the hyperbolic distance, the smaller the sentiment positivity and the greater the sentiment negativity. If the sentiment polarity element indicates that the sentiment is negative, then there is a negative correlation between the sentiment negativity expressed by the context word and the hyperbolic distance. In other words, the larger the hyperbolic distance, the smaller the sentiment negativity and the greater the sentiment positivity.
[0094] Figure 4 : is a structural block diagram of an emotion polarity representation device according to another embodiment of the present invention. The solution of this embodiment can be applied to any appropriate electronic device with data processing capabilities, including but not limited to: servers, mobile terminals (such as mobile phones, PADs, etc.) and PCs, etc. Specifically, the device to which the solution of this embodiment is applied has a hardware and software configuration capable of performing neural network operations. Figure 4 The emotional polarity representation device includes:
[0095] An acquisition module 410 acquires a context word representation in a Euclidean semantic space;
[0096] A mapping module 420, inputting the context word representation into a pre-trained probe to obtain a sentiment representation in a hyperbolic semantic space, wherein the parameters of the pre-trained probe are used for mapping from the Euclidean semantic space to the hyperbolic semantic space;
[0097] A calculation module 430 calculates a hyperbolic distance between the emotion representation and the emotion polarity element representation in the hyperbolic semantic space, wherein the emotion polarity element representation indicates a positive emotion or a negative emotion in the hyperbolic semantic space;
[0098] The determination module 440 determines the degree of sentiment polarity represented by the context word according to the negative correlation with the hyperbolic distance.
[0099] In the scheme of the embodiment of the present invention, since the pre-trained probe can map the context word representation of the Euclidean semantic space to the hyperbolic semantic space, the hyperbolic space can embed the semantic hierarchical structure of the context word representation more efficiently, and thus a better semantic induction bias is achieved through the pre-trained probe, thereby obtaining a reliable sentiment representation in the hyperbolic semantic space. In addition, by calculating the hyperbolic distance between the sentiment representation and the sentiment polarity meta-representation in the hyperbolic semantic space, the degree of sentiment polarity of the context word representation can be effectively obtained, and an effective sentiment polarity representation of the context word vector is achieved.
[0100] In other words, the structural probe is based on the assumption of Euclidean semantic space, and uses the square of the Euclidean distance between word representations to correspond to the distance in the syntactic dependency relationship. In other words, the hierarchical structure of syntactic dependency relationships cannot be effectively embedded in the Euclidean semantic space, while the hierarchical structure of syntactic dependency relationships can be effectively embedded in the hyperbolic semantic space of the embodiment of the present invention.
[0101] In addition, the neural network structure of the probe of this embodiment can also be trained into a model for analyzing semantic dependencies through grammatical analysis tasks. In this case, the sentiment expression under the hyperbolic semantic space in the sentiment polarity analysis corresponds to the semantic dependency expression, and in the hyperbolic semantic space, the distance between the semantic dependency expressions of the two words indicates the distance in the semantic dependency, which more reliably represents the distance in the semantic dependency than in the Euclidean semantic space. In other words, the neural network structure of the probe of this embodiment more efficiently embeds the hierarchical structure of semantic dependencies in the hyperbolic semantic space, and is better compatible with a variety of semantic analysis tasks.
[0102] As another implementation method of this embodiment, the emotion polarity degree includes the emotion positivity degree, and the hyperbolic distance between the emotion polarity element representation indicating the emotion negativity is positively correlated with the emotion positivity degree; or, the emotion polarity degree includes the emotion negativity degree, and the hyperbolic distance between the emotion polarity element representation indicating the emotion positivity is positively correlated with the emotion negativity degree.
[0103] As another implementation method of this embodiment, the mapping module is specifically used to: map the context word representation in the Euclidean semantic space to a low-dimensional semantic space whose dimension is lower than that of the Euclidean semantic space through the first parameter of the pre-trained probe; and map the context word representation in the low-dimensional semantic space to the hyperbolic semantic space through the second parameter of the pre-trained probe to obtain the emotion representation in the hyperbolic semantic space.
[0104] As another implementation manner of this embodiment, the dimension of the first Euclidean semantic space is one order of magnitude lower than the dimension of the second Euclidean semantic space.
[0105] As another implementation method of this embodiment, the mapping module is specifically used to: multiply the first word vector corresponding to the context word representation in the Euclidean semantic space by a first linear mapping matrix to obtain a second word vector corresponding to the context word representation in the low-dimensional semantic space, wherein the two dimensions of the first linear mapping matrix are respectively equal to the dimension of the Euclidean semantic space and the dimension of the low-dimensional semantic space.
[0106] As another implementation method of this embodiment, the mapping module is specifically used to: perform exponential mapping processing on the second word vector to obtain an exponential mapping vector of the second word vector; use Möbius matrix-vector multiplication to multiply the exponential mapping vector with the second linear mapping matrix to obtain a vector corresponding to the sentiment representation in the hyperbolic semantic space.
[0107] As another implementation method of this embodiment, the determination module is also used to: determine each first hyperbolic distance between each context word representation and the emotional positive element representation corresponding to the target sentence, and each second hyperbolic distance between each context word representation and the emotional negative element representation; sum each first hyperbolic distance and each second hyperbolic distance respectively to obtain a first hyperbolic distance sum and a second hyperbolic distance sum; determine the degree of emotional negativity that is positively correlated with the first hyperbolic distance sum, and the degree of emotional positivity that is positively correlated with the second hyperbolic distance sum.
[0108] As another implementation of this embodiment, the probe is trained in the following manner: taking the representations of each context word corresponding to a sentence sample as input of a neural network, and taking the degree of sentiment polarity of the sentence sample as a supervision condition to train the neural network, wherein the neural network includes a first neural network and a second neural network, the output of the first neural network is connected to the input of the second neural network, the first neural network is used to map the representations of each context word from the Euclidean semantic space to the hyperbolic semantic space, and the second neural network is used to calculate the sentiment representation in the hyperbolic space and the degree of sentiment polarity of the sentence sample; the trained first neural network is determined as the probe.
[0109] As another implementation method of this embodiment, the second neural network calculates the degree of sentiment polarity of the sentence sample based on each hyperbolic distance between the sentiment representation represented by each context word and the sentiment polarity meta-representation to be adjusted, and in the training of the second neural network, the sentiment polarity meta-representation to be adjusted is adjusted to obtain the sentiment polarity meta-representation.
[0110] The device of this embodiment is used to implement the corresponding methods in the aforementioned multiple method embodiments, and has the beneficial effects of the corresponding method embodiments, which will not be repeated here. In addition, the functional implementation of each module in the device of this embodiment can refer to the description of the corresponding parts in the aforementioned method embodiments, which will not be repeated here.
[0111] Reference Figure 5 , shows a schematic structural diagram of an electronic device according to another embodiment of the present invention. The specific embodiment of the present invention does not limit the specific implementation of the electronic device.
[0112] like Figure 5 As shown, the electronic device may include: a processor (processor) 502 , a communication interface (Communications Interface) 504 , a memory (memory) 506 , and a communication bus 508 .
[0113] in:
[0114] The processor 502 , the communication interface 504 , and the memory 506 communicate with each other via a communication bus 508 .
[0115] The communication interface 504 is used to communicate with other electronic devices or servers.
[0116] The processor 502 is used to execute the program 510, and specifically can execute the relevant steps in the above method embodiment.
[0117] Specifically, the program 510 may include program codes, which include computer operation instructions.
[0118] The processor 502 may be a central processing unit (CPU), or an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present invention. The one or more processors included in the smart device may be processors of the same type, such as one or more CPUs; or processors of different types, such as one or more CPUs and one or more ASICs.
[0119] The memory 506 is used to store the program 510. The memory 506 may include a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.
[0120] Program 510 can be specifically used to enable the processor 502 to perform the following operations: obtain context word representation in Euclidean semantic space; input the context word representation into a pre-trained probe to obtain an emotion representation in a hyperbolic semantic space, wherein the parameters of the pre-trained probe indicate a mapping from the Euclidean semantic space to the hyperbolic semantic space; calculate the hyperbolic distance between the emotion representation and the emotion polarity meta-representation in the hyperbolic semantic space, the emotion polarity meta-representation indicating a positive emotion or a negative emotion in the hyperbolic semantic space; determine the degree of emotion polarity of the context word representation based on the negative correlation with the hyperbolic distance.
[0121] In addition, the specific implementation of each step in program 510 can refer to the corresponding description of the corresponding steps and units in the above method embodiment, which will not be repeated here. Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working process of the above-described devices and modules can refer to the corresponding process description in the above method embodiment, which will not be repeated here.
[0122] It should be pointed out that, according to the needs of implementation, the various components / steps described in the embodiments of the present invention can be split into more components / steps, or two or more components / steps or partial operations of components / steps can be combined into new components / steps to achieve the purpose of the embodiments of the present invention.
[0123] The above-described method according to an embodiment of the present invention may be implemented in hardware, firmware, or as software or computer code that may be stored in a recording medium (such as a CD ROM, RAM, floppy disk, hard disk, or magneto-optical disk), or as computer code that is originally stored in a remote recording medium or a non-temporary machine-readable medium downloaded over a network and will be stored in a local recording medium, so that the method described herein may be stored in such software processing on a recording medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware (such as an ASIC or FPGA). It is understood that a computer, processor, microprocessor controller, or programmable hardware includes a storage component (e.g., RAM, ROM, flash memory, etc.) that can store or receive software or computer code, and when the software or computer code is accessed and executed by a computer, processor, or hardware, the method described herein is implemented. In addition, when a general-purpose computer accesses the code for implementing the method shown herein, the execution of the code converts the general-purpose computer into a dedicated computer for executing the method shown herein.
[0124] Those of ordinary skill in the art will appreciate that the units and method steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the embodiments of the present invention.
[0125] The above implementation methods are only used to illustrate the embodiments of the present invention, and are not limitations of the embodiments of the present invention. Ordinary technicians in the relevant technical field may make various changes and modifications without departing from the spirit and scope of the embodiments of the present invention. Therefore, all equivalent technical solutions also belong to the scope of the embodiments of the present invention. The patent protection scope of the embodiments of the present invention should be defined by the claims.
Claims
1. A method for expressing sentiment polarity, comprising: Get the context word representation in Euclidean semantic space; Inputting the context word representation into a pre-trained probe to obtain a sentiment representation in a hyperbolic semantic space, wherein a parameter of the pre-trained probe indicates a mapping from the Euclidean semantic space to the hyperbolic semantic space; Calculating a hyperbolic distance between the emotion representation and an emotion polarity meta-representation in the hyperbolic semantic space, wherein the emotion polarity meta-representation indicates a positive emotion or a negative emotion in the hyperbolic semantic space; The degree of sentiment polarity represented by the context word is determined according to the negative correlation with the hyperbolic distance, wherein the degree of sentiment polarity includes one of the following: a positive sentiment degree and a negative sentiment degree.
2. The method according to claim 1, wherein: The hyperbolic distance between the emotional positivity level and the emotional polarity meta-representation indicating the emotional negativity is positively correlated with the emotional positivity level, or the hyperbolic distance between the emotional negativity level and the emotional polarity meta-representation indicating the emotional positivity is positively correlated with the emotional negativity level.
3. The method according to claim 2, wherein: The step of inputting the context word representation into a pre-trained probe to obtain a sentiment representation in a hyperbolic semantic space includes: Mapping the context word representation in the Euclidean semantic space to a low-dimensional semantic space having a dimension lower than that of the Euclidean semantic space through the first parameter of the pre-trained probe; The context word representation in the low-dimensional semantic space is mapped to the hyperbolic semantic space through the second parameter of the pre-trained probe to obtain the emotion representation in the hyperbolic semantic space.
4. The method according to claim 3, wherein: The dimension of the low-dimensional semantic space is one order of magnitude lower than the dimension of the Euclidean semantic space.
5. The method according to claim 3, wherein: The mapping of the context word representation in the Euclidean semantic space to a low-dimensional semantic space having a dimension lower than that of the Euclidean semantic space by using the first parameter of the pre-trained probe comprises: The first word vector corresponding to the context word representation in the Euclidean semantic space is multiplied by the first linear mapping matrix to obtain a second word vector corresponding to the context word representation in the low-dimensional semantic space, wherein the two dimensions of the first linear mapping matrix are respectively equal to the dimension of the Euclidean semantic space and the dimension of the low-dimensional semantic space.
6. The method according to claim 5, wherein: in, The step of mapping the context word representation in the low-dimensional semantic space to the hyperbolic semantic space through the second parameter of the pre-trained probe to obtain the sentiment representation in the hyperbolic semantic space includes: Performing exponential mapping processing on the second word vector to obtain an exponential mapping vector of the second word vector; The exponential mapping vector is multiplied by the second linear mapping matrix using the Möbius matrix-vector multiplication to obtain a vector corresponding to the sentiment representation in the hyperbolic semantic space.
7. The method according to claim 1, wherein: The method further comprises: Determine each first hyperbolic distance between each context word representation and the sentiment positive meta-representation corresponding to the target sentence, and each second hyperbolic distance between each context word representation and the sentiment negative meta-representation; Respectively summing the first hyperbolic distances and the second hyperbolic distances to obtain a first hyperbolic distance sum and a second hyperbolic distance sum; A degree of sentiment negativity positively correlated with the first hyperbolic distance sum and a degree of sentiment positivity positively correlated with the second hyperbolic distance sum are determined.
8. The method according to claim 1, wherein: The probe is trained in the following way: Taking each context word representation corresponding to a sentence sample as an input of a neural network, and taking the degree of sentiment polarity of the sentence sample as a supervision condition, the neural network is trained, wherein the neural network includes a first neural network and a second neural network, the output of the first neural network is connected to the input of the second neural network, the first neural network is used to map each context word representation from the Euclidean semantic space to the hyperbolic semantic space, and the second neural network is used to calculate the sentiment representation in the hyperbolic semantic space to calculate the degree of sentiment polarity of the sentence sample; A trained first neural network is determined as the probe.
9. The method according to claim 8, wherein: The second neural network calculates the degree of sentiment polarity of the sentence sample based on the hyperbolic distances between the sentiment representations represented by the respective context words and the sentiment polarity meta-representation to be adjusted. During the training of the second neural network, the sentiment polarity meta-representation to be adjusted is adjusted to obtain the sentiment polarity meta-representation.
10. An emotional polarity representation device, comprising: The acquisition module obtains the context word representation in the Euclidean semantic space; A mapping module, inputting the context word representation into a pre-trained probe to obtain a sentiment representation in a hyperbolic semantic space, wherein the parameters of the pre-trained probe are used for mapping from the Euclidean semantic space to the hyperbolic semantic space; A calculation module, calculating a hyperbolic distance between the emotion representation and the emotion polarity element representation in the hyperbolic semantic space, wherein the emotion polarity element representation indicates a positive emotion or a negative emotion in the hyperbolic semantic space; A determination module determines the degree of sentiment polarity represented by the context word according to a negative correlation with the hyperbolic distance, wherein the degree of sentiment polarity includes one of the following: a positive sentiment degree and a negative sentiment degree.
11. A computer storage medium having a computer program stored thereon, wherein when the program is executed by a processor, the method according to any one of claims 1 to 9 is implemented.
Citation Information
Patent Citations
Deep memory network model for target emotion classification and classification method thereof
CN110008339A
Information extraction method based on non-Euclidean space
CN113111302A