CN112015896A - Emotion classification method and device based on artificial intelligence - Google Patents

Emotion classification method and device based on artificial intelligence Download PDF

Info

Publication number
CN112015896A
CN112015896A CN202010876860.7A CN202010876860A CN112015896A CN 112015896 A CN112015896 A CN 112015896A CN 202010876860 A CN202010876860 A CN 202010876860A CN 112015896 A CN112015896 A CN 112015896A
Authority
CN
China
Prior art keywords
emotion
domain
text sample
source domain
domain text
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202010876860.7A
Other languages
Chinese (zh)
Other versions
CN112015896B (en
Inventor
曹禹
赵瑞辉
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN202010876860.7A priority Critical patent/CN112015896B/en
Publication of CN112015896A publication Critical patent/CN112015896A/en
Application granted granted Critical
Publication of CN112015896B publication Critical patent/CN112015896B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/35Clustering; Classification
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/33Querying
    • G06F16/3331Query processing
    • G06F16/334Query execution
    • G06F16/3344Query execution using natural language analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/21Design or setup of recognition systems or techniques; Extraction of features in feature space; Blind source separation
    • G06F18/214Generating training patterns; Bootstrap methods, e.g. bagging or boosting
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/24Classification techniques
    • G06F18/241Classification techniques relating to the classification model, e.g. parametric or non-parametric approaches
    • G06F18/2411Classification techniques relating to the classification model, e.g. parametric or non-parametric approaches based on the proximity to a decision surface, e.g. support vector machines
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/24Classification techniques
    • G06F18/241Classification techniques relating to the classification model, e.g. parametric or non-parametric approaches
    • G06F18/2415Classification techniques relating to the classification model, e.g. parametric or non-parametric approaches based on parametric or probabilistic models, e.g. based on likelihood ratio or false acceptance rate versus a false rejection rate

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Artificial Intelligence (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Evolutionary Biology (AREA)
  • Evolutionary Computation (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Databases & Information Systems (AREA)
  • Probability & Statistics with Applications (AREA)
  • Computational Linguistics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application provides an emotion classification method, device, electronic equipment and computer readable storage medium based on artificial intelligence; the method comprises the following steps: obtaining emotion classification results and domain classification results of source domain text samples and domain classification results of target domain text samples through an emotion classification model to be trained; determining a training difficulty coefficient of the source domain text sample based on the emotion classification result of the source domain text sample; determining a migration degree coefficient of the source domain text sample based on a domain classification result of the source domain text sample; constructing a loss function of the emotion classification model according to the migration degree coefficient and the training difficulty coefficient of the source domain text sample and the domain classification result of the target domain text sample, and updating parameters of the emotion classification model according to the loss function; and obtaining the emotion classification result of the text to be detected based on the trained emotion classification model. Through the method and the device, the text emotion recognition efficiency and accuracy can be improved.

Description

Emotion classification method and device based on artificial intelligence
Technical Field
The present application relates to natural language processing technologies in the field of artificial intelligence, and in particular, to an emotion classification method and apparatus based on artificial intelligence, an electronic device, and a computer-readable storage medium.
Background
Artificial Intelligence (AI) is a theory, method and technique and application system that uses a digital computer or a machine controlled by a digital computer to simulate, extend and expand human Intelligence, perceive the environment, acquire knowledge and use the knowledge to obtain the best results. Natural Language Processing (NLP) is an important direction in artificial intelligence, and various theories and methods for realizing efficient communication between a person and a computer using natural Language are mainly studied.
Text emotion analysis is a branch of natural language processing and refers to the attribute of identifying whether the emotion polarity in the text is positive or negative. In the related art, text emotion analysis is usually implemented by a domain adaptation technique. However, during the training process, training data is usually collected by crawling the internet or social media, and the obtained training data inevitably contains noise samples. In the case of neglecting negative transition caused by noise samples, the model is not suitable for the target domain, so that the text emotion recognition is inaccurate. The related art has no effective solution for this.
Disclosure of Invention
The embodiment of the application provides an emotion classification method and device based on artificial intelligence, electronic equipment and a computer readable storage medium, and the efficiency and the accuracy of text emotion recognition can be improved.
The technical scheme of the embodiment of the application is realized as follows:
the embodiment of the application provides an emotion classification method based on artificial intelligence, which comprises the following steps:
obtaining emotion classification results and domain classification results of source domain text samples and domain classification results of target domain text samples through an emotion classification model to be trained;
determining a training difficulty coefficient of the source domain text sample based on the emotion classification result of the source domain text sample;
determining a migration degree coefficient of the source domain text sample based on a domain classification result of the source domain text sample;
constructing a loss function of the emotion classification model according to the migration degree coefficient and the training difficulty coefficient of the source domain text sample and the domain classification result of the target domain text sample, and updating parameters of the emotion classification model according to the loss function;
and obtaining the emotion classification result of the text to be detected based on the emotion classification model after training.
The embodiment of the application provides an emotion classification device based on artificial intelligence, includes:
the obtaining module is used for obtaining the emotion classification result and the domain classification result of the source domain text sample and the domain classification result of the target domain text sample through the emotion classification model to be trained;
the determining module is used for determining a training difficulty coefficient of the source domain text sample based on the emotion classification result of the source domain text sample;
the determining module is further configured to determine a migration degree coefficient of the source domain text sample based on a domain classification result of the source domain text sample;
the updating module is used for constructing a loss function of the emotion classification model according to the migration degree coefficient and the training difficulty coefficient of the source domain text sample and the domain classification result of the target domain text sample, and updating parameters of the emotion classification model according to the loss function;
and the classification module is used for obtaining the emotion classification result of the text to be detected based on the emotion classification model after training.
In the above scheme, the determining module is further configured to determine an emotion loss between the emotion classification result of the source domain text sample and a pre-marked emotion polarity; determining a training difficulty coefficient positively correlated to the emotional loss.
In the foregoing solution, the determining module is further configured to determine a migration degree coefficient positively correlated to the domain classification result of the source domain text sample.
In the above scheme, the loss function of the emotion classification model includes a first sub-loss function and a second sub-loss function; the updating module is further used for determining a weight coefficient of the source domain text sample according to the migration degree coefficient and the training difficulty coefficient of the source domain text sample; determining emotion loss between the emotion classification result of the source domain text sample and the pre-marked emotion polarity; determining the product of the weight coefficient and the emotional loss as the first sub-loss function; determining a difference between the first function and the second function as the second sub-loss function; wherein the first function is a product between the weight coefficient and a first sub-function that positively correlates with a probability of a domain classification result of the source domain text sample; wherein the second function is inversely related to the probability of the domain classification result of the target domain text sample.
In the above scheme, the updating module is further configured to perform proportional summation on the migration degree coefficient and the training difficulty coefficient; determining the weight coefficient as a first weight having a value of 1 when the sum does not exceed a migration threshold; determining the weight coefficient as a second weight having a value of zero when the sum exceeds the migration threshold.
In the foregoing solution, the updating module is further configured to determine a parameter variation value of the emotion classification model when a difference between the first sub-loss function and the second sub-loss function takes a minimum value and the second sub-loss function takes the minimum value; and adding the parameter change value and the parameter of the emotion classification model, and taking the added result as the updated parameter of the emotion classification model.
In the above scheme, the classification module is further configured to obtain a text to be detected; executing the following processing by the emotion classification model after training: performing feature extraction processing on the text to be detected to obtain emotional features of the text to be detected, and mapping the emotional features of the text to be detected into probabilities of different emotional polarities; and determining the emotion polarity corresponding to the maximum probability as the emotion type classification result of the text to be detected.
In the above scheme, the obtaining module is further configured to perform feature extraction processing on the source domain text sample to obtain an emotion feature of the source domain text sample, perform domain classification processing based on the emotion feature of the source domain text sample to obtain a domain classification result that the source domain text sample belongs to a source domain or a target domain, and perform emotion classification processing based on the emotion feature of the source domain text sample to obtain an emotion classification result that the source domain text sample belongs to a negative emotion or a positive emotion; and performing feature extraction processing on the target domain text sample to obtain the emotional features of the target domain text sample, and performing domain classification processing based on the emotional features of the target domain text sample to obtain a domain classification result of the target domain text sample belonging to a source domain or a target domain.
In the above scheme, the obtaining module is further configured to perform word segmentation processing on the source domain text sample so as to divide the source domain text sample into a plurality of words; respectively encoding a plurality of words to obtain a word vector corresponding to each word; extracting emotional features of the source domain text sample from the plurality of word vectors corresponding to the source domain text sample.
In the above scheme, the obtaining module is further configured to perform word segmentation processing on the target domain text sample so as to divide the target domain text sample into a plurality of words; respectively encoding a plurality of words to obtain a word vector corresponding to each word; extracting emotional features of the target domain text sample from a plurality of word vectors corresponding to the target domain text sample.
In the above scheme, the obtaining module is further configured to map emotion features of the source domain text sample into probabilities of respectively belonging to a negative emotion and a positive emotion; and determining the emotion polarity with the maximum probability as the emotion classification result of the source domain text sample.
In the above scheme, the obtaining module is further configured to map the emotional features of the source domain text sample into probabilities of respectively belonging to a source domain and a target domain; and determining the sample source with the maximum probability as the domain classification result of the source domain text sample.
In the above scheme, the obtaining module is further configured to map the emotional features of the target domain text sample into probabilities of respectively belonging to a source domain or a target domain; and determining the sample source with the maximum probability as the domain classification result of the target domain text sample.
An embodiment of the present application provides an electronic device, including:
a memory for storing executable instructions;
and the processor is used for realizing the emotion classification method based on artificial intelligence provided by the embodiment of the application when the executable instructions stored in the memory are executed.
The embodiment of the application provides a computer-readable storage medium, which stores executable instructions for causing a processor to execute the method for emotion classification based on artificial intelligence provided by the embodiment of the application.
The embodiment of the application has the following beneficial effects:
the emotion classification model is trained simultaneously based on the source domain text sample and the target domain text sample, so that the richness and diversity of training data are increased, the robustness of the emotion classification model can be improved, and overfitting is avoided; and different weights are given to different source domain text samples for training based on two dimensions of training difficulty and migration degree, the applicability of the training samples in the training process can be improved, and therefore the efficiency and the accuracy of text emotion recognition based on the emotion classification model finished by training in the follow-up process can be improved.
Drawings
FIG. 1 is a schematic diagram of an artificial intelligence based emotion classification system 100 provided by an embodiment of the present application;
fig. 2 is a schematic structural diagram of an electronic device 500 provided in an embodiment of the present application;
FIG. 3 is a flowchart of an emotion classification method based on artificial intelligence provided by an embodiment of the present application;
FIG. 4 is a schematic structural diagram of an emotion classification model provided in an embodiment of the present application;
FIG. 5 is a flowchart illustrating an emotion classification method based on artificial intelligence according to an embodiment of the present application;
FIG. 6 is a flowchart illustrating an emotion classification method based on artificial intelligence according to an embodiment of the present application;
FIG. 7 is a schematic diagram of an application scenario of an artificial intelligence based emotion classification method provided in an embodiment of the present application;
fig. 8 is a schematic view of an application scenario of the artificial intelligence based emotion classification method provided in the embodiment of the present application.
Detailed Description
In order to make the objectives, technical solutions and advantages of the present application clearer, the present application will be described in further detail with reference to the attached drawings, the described embodiments should not be considered as limiting the present application, and all other embodiments obtained by a person of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.
In the following description, reference is made to "some embodiments" which describe a subset of all possible embodiments, but it is understood that "some embodiments" may be the same subset or different subsets of all possible embodiments, and may be combined with each other without conflict.
In the following description, references to the terms "first/second" are only to distinguish similar items and do not denote a particular order, but rather the terms "first/second" may, where permissible, be interchanged with a particular order or sequence so that embodiments of the application described herein may be practiced in other than the order shown or described herein.
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing embodiments of the present application only and is not intended to be limiting of the application.
Before further detailed description of the embodiments of the present application, terms and expressions referred to in the embodiments of the present application will be described, and the terms and expressions referred to in the embodiments of the present application will be used for the following explanation.
1) And (3) natural language processing: is an important direction in the fields of computer science and artificial intelligence. It studies various theories and methods that enable efficient communication between humans and computers using natural language. Natural language processing is a science integrating linguistics, computer science and mathematics. Therefore, the research in this field will involve natural language, i.e. the language that people use everyday, so it is closely related to the research of linguistics. Natural language processing techniques typically include text processing, semantic understanding, machine translation, robotic question and answer, knowledge mapping, and the like.
2) Curriculum Learning (Curriculum Learning): similar to the human learning mechanism, the training samples with different difficulties are assigned with different weights according to the difficulty of the samples in course learning. In the initial stage, the weight of the simple samples is given the highest, and as the training process continues, the weight of the harder samples will be gradually increased. Such a process of dynamically assigning weights to samples is called Curriculum (Curriculum), the number of simple samples at the initial stage of the Curriculum is large, and the difficulty of samples at the final stage of the Curriculum is increased. This makes it easy for the model to find better local optima, while speeding up the training.
3) Word embedding: means that a high-dimensional space with the number of all words is embedded into a continuous vector space with a much lower dimension, and each word or phrase is mapped to a vector on the real number domain. Word embedding is actually a type of technique that represents individual words as real-valued vectors in a predetermined vector space, i.e., digitizing the text to facilitate fitting algorithms. Word vectors represented using word embedding tend to have only tens or hundreds of dimensions.
4) And (3) emotion analysis: text sentiment analysis is primarily implemented to automatically identify whether sentiment polarity (or sentiment attributes) in text data is positive or negative.
5) Cross-domain emotion analysis: cross-domain emotion analysis refers to training on a labeled source domain to infer textual emotion on an unlabeled target domain.
6) Training difficulty coefficient: in the process of training a model by using the source domain text samples, the training difficulty for characterizing the source domain text samples is used. The training difficulty coefficient is associated with the emotion classification result of the source domain text sample belonging to the negative emotion or the positive emotion.
7) Migration degree coefficient: the method is used for characterizing the migration degree of the source domain text sample to the target domain in the process of training the model by using the source domain text sample. The migration degree coefficient is associated with a domain classification result of the source domain text sample belonging to the source domain or the target domain.
8) Parameters of the neural network model: parameters obtained by automatic updating or self-learning in the training process of the neural network model comprise characteristic weight, bias and the like.
9) Gradient: the method is used for carrying out gradient calculation on model parameters in the training process of the neural network model. The process of training the neural network model by the model computation nodes according to the subsets of the received sample data comprises forward propagation and backward propagation. The forward propagation refers to a process of inputting a subset of sample data in a training model, obtaining a prediction result, and calculating the difference between the prediction result and an expected result; the backward propagation is to calculate the gradient (i.e., update value) of the model parameter of each layer in the opposite direction according to the difference between the predicted result and the expected result in the order of the output layer, the intermediate layer, and the input layer, so as to update the model parameter according to the gradient.
10) Artificial intelligence cloud Service (AiaaS, AI as a Service): the AIaaS platform is a service mode of an artificial intelligence platform, and particularly divides several types of common AI services and provides independent or packaged services at a cloud end. This service model is similar to the one opened in an AI theme mall: all developers can access one or more artificial intelligence services provided by the platform by means of Application Programming Interface (API), and some of the sophisticated developers can also use the AI framework and the AI infrastructure provided by the platform to deploy and operate and maintain their own dedicated cloud artificial intelligence services.
In the related art, a domain sharing word is usually used to construct a bridge between a source domain and a target domain, and specifically includes two schemes, which are: (1) antagonistic learning, i.e. confusing a domain classifier by training a feature extractor; (2) maximum mean difference, i.e., learning invariant features by minimizing the difference between both the source and target domains in the deep neural network.
However, domain adaptation in the related art typically assumes that the source domain is a precisely labeled data set, and is noise-free. However, in implementing the domain adaptation problem, a high-quality data set cannot be obtained due to the acquisition of high-quality data and the consumption of time and resources.
In practical applications, data is collected by crawling the internet or social media, so that the acquired data sets are large in quantity and easy to obtain, but inevitably polluted by noise samples. In the case of neglecting the negative migration caused by the noise samples, the related art makes the model not suitable for the target domain, thereby causing the generalization performance to be reduced.
In view of the above technical problems, embodiments of the present application provide an emotion classification method and apparatus based on artificial intelligence, an electronic device, and a computer-readable storage medium, which can improve the efficiency and accuracy of text emotion recognition. The following describes an exemplary application of the emotion classification method based on artificial intelligence provided in the embodiment of the present application, and the emotion classification method based on artificial intelligence provided in the embodiment of the present application may be implemented by various electronic devices, for example, by a terminal, a server or a server cluster, or by a cooperation of a terminal and a server.
In the following, an embodiment of the present application is described by taking a terminal and a server as an example, referring to fig. 1, fig. 1 is a schematic structural diagram of an emotion classification system 100 based on artificial intelligence provided in the embodiment of the present application. The emotion classification system 100 based on artificial intelligence includes: the server 200, the network 300, the terminal 400, and the client 410 operating in the terminal 400 will be described separately.
Server 200 is a background server of client 410, and is configured to obtain source domain text samples and target domain text samples, train an emotion classification model (the process of training an emotion classification model will be described in detail below); the emotion recognition module is further used for receiving the text to be detected sent by the client 410 and determining the emotion polarity of the text to be detected through the emotion classification model; and also for sending recommendation information associated with the emotion polarity of the text to be detected to client 410.
The network 300 is used as a medium for communication between the server 200 and the terminal 400, and may be a wide area network or a local area network, or a combination of both.
The terminal 400 is used for running a client 410, and the client 410 is various Applications (APPs) with text emotion recognition functions, such as a shopping APP, a video APP, or a music APP. The client 410 is configured to send a text to be detected to the server 200, obtain corresponding recommendation information sent by the server 200, and display the recommendation information (e.g., recommended goods, recommended videos, recommended music, or the like) to the user.
It should be noted that the client 410 can not only identify the emotion polarity of the text by calling the emotion identification service of the server 200; the emotion polarity of the text can also be recognized by calling the emotion recognition service of the terminal 400.
As an example, the client 410 invokes an emotion recognition service of the terminal 400 to recognize the emotion polarity of the text; and sending a corresponding request to the server 200 according to the identified emotional polarity, so that the server 200 acquires a corresponding resource (for example, commodity, video or music and the like) from a database or a network according to the request, receives the resource returned by the server 200, and displays the resource (for example, recommended commodity, recommended video or recommended music and the like) to the user.
The embodiments of the present application may be implemented by means of Cloud Technology (Cloud Technology), which refers to a hosting Technology for unifying series resources such as hardware, software, and network in a wide area network or a local area network to implement data calculation, storage, processing, and sharing.
The cloud technology is a general term of network technology, information technology, integration technology, management platform technology, application technology and the like applied based on a cloud computing business model, can form a resource pool, is used as required, and is flexible and convenient. Cloud computing technology will become an important support. Background services of the technical network system require a large amount of computing and storage resources.
As an example, the server 200 may be an independent physical server, may be a server cluster or a distributed system formed by a plurality of physical servers, and may also be a cloud server providing basic cloud computing services such as a cloud service, a cloud database, cloud computing, a cloud function, cloud storage, a web service, cloud communication, a middleware service, a domain name service, a security service, a CDN, and a big data and artificial intelligence platform. The terminal 400 may be, but is not limited to, a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a smart watch, and the like. The terminal 400 and the server 200 may be directly or indirectly connected through wired or wireless communication, and the embodiment of the present application is not limited thereto.
The embodiment of the application can be applied to various scenes, such as a shopping scene, a video playing scene or a music playing scene.
Taking a shopping scenario as an example, client 410 may be a shopping APP. The client 410 collects comments (or ratings) of the user on the goods, such as "this one-piece dress is beautiful, i like; the client 410 sends the comment to the server 200; the server 200 identifies the received comments and determines that the emotion polarity of the user for the 'one-piece dress' is positive emotion; the server 200 searches for the commodity information similar to the 'one-piece dress' in the database or the network, and sends the searched commodity information to the client 410; the client 410 presents the received merchandise information.
Alternatively, the client 410 collects user comments about the goods, such as "this dress is beautiful, i like"; the client 410 identifies the comment and determines that the emotion polarity of the user for the 'one-piece dress' is positive emotion; the client 410 sends a commodity information acquisition request to the server 200, so that the server 200 searches for commodity information similar to a 'one-piece dress' from a database or a network, and returns the commodity information to the client 410; the client 410 presents the received merchandise information.
Taking a video playing scene as an example, the client 410 may be a video APP. The client 410 calls a microphone of the terminal 400 to acquire a voice operation instruction of the user, for example, "i like liu XX", and performs voice recognition on the voice operation instruction to obtain a corresponding text; the client 410 sends the text to the server 200; the server 200 identifies the text and determines that the emotion polarity of the user for the Liu XX is a positive emotion; the server 200 searches for video resources related to "liu XX" in a database or a network, and sends the video resources to the client 410; the client 410 plays the received video asset.
Or, the client 410 calls a microphone of the terminal 400 to acquire a voice operation instruction of the user, for example, "i like liu XX", and performs voice recognition on the voice operation instruction to obtain a corresponding text; the client 410 calls the emotion recognition service of the terminal 400 to recognize the text, and determines that the user is a positive emotion for the emotion polarity of "Liu XX"; the client 410 sends a video acquisition request to the server 200, so that the server 200 searches for video resources related to "liu XX" from a database or a network, and returns the video resources to the client 410; the client 410 plays the received video asset.
Taking a music playing scene as an example, the client 410 may be a music APP. The client 410 calls a microphone of the terminal 400 to collect a voice operation instruction of the user, for example, "i like light music", and performs voice recognition on the voice operation instruction to obtain a corresponding text; the client 410 sends the text to the server 200; the server 200 identifies the text and determines that the emotion polarity of the user for the 'light music' is positive emotion; the server 200 searches for music resources related to the "light music" in a database or a network and transmits the music resources to the client 410; the client 410 plays the received music asset.
Or, the client 410 calls a microphone of the terminal 400 to collect a voice operation instruction of the user, for example, "i like light music", and performs voice recognition on the voice operation instruction to obtain a corresponding text; the client 410 calls the emotion recognition service of the terminal 400 to recognize the text and determines that the emotion polarity of the user for the 'light music' is positive emotion; the client 410 sends a music acquisition request to the server 200, so that the server 200 searches a database or a network for music resources related to the "light music" and returns the music resources to the client 410; the client 410 plays the received music asset.
Next, a structure of an electronic device for text emotion recognition provided in an embodiment of the present application will be described, where the electronic device may be the server 200 or the terminal 400 shown in fig. 1. The following describes a structure of the electronic device by taking the electronic device as the server 200 shown in fig. 1 as an example, referring to fig. 2, fig. 2 is a schematic structural diagram of an electronic device 500 provided in an embodiment of the present application, and the electronic device 500 shown in fig. 2 includes: at least one processor 510, memory 540, and at least one network interface 520. The various components in the electronic device 500 are coupled together by a bus system 530. It is understood that the bus system 530 is used to enable communications among the components. The bus system 530 includes a power bus, a control bus, and a status signal bus in addition to a data bus. For clarity of illustration, however, the various buses are labeled as bus system 530 in FIG. 2.
The Processor 510 may be an integrated circuit chip having Signal processing capabilities, such as a general purpose Processor, a Digital Signal Processor (DSP), or other programmable logic device, discrete gate or transistor logic device, discrete hardware components, or the like, wherein the general purpose Processor may be a microprocessor or any conventional Processor, or the like.
The memory 540 includes either volatile memory or nonvolatile memory, and may include both volatile and nonvolatile memory. The non-volatile Memory may be a Read Only Memory (ROM), and the volatile Memory may be a Random Access Memory (RAM). The memory 540 described in embodiments herein is intended to comprise any suitable type of memory. Memory 540 optionally includes one or more storage devices physically located remote from processor 510.
In some embodiments, memory 540 is capable of storing data, examples of which include programs, modules, and data structures, or subsets or supersets thereof, as exemplified below, to support various operations.
An operating system 541 including system programs for handling various basic system services and performing hardware-related tasks, such as a framework layer, a core library layer, a driver layer, etc., for implementing various basic services and for handling hardware-based tasks;
a network communication module 542 for communicating to other computing devices via one or more (wired or wireless) network interfaces 520, exemplary network interfaces 520 including: bluetooth, wireless compatibility authentication (WiFi), and Universal Serial Bus (USB), etc.;
in some embodiments, the artificial intelligence based emotion classification apparatus provided in the embodiments of the present application can be implemented in software, and fig. 2 shows an artificial intelligence based emotion classification apparatus 543 stored in a storage 540, which can be software in the form of programs and plug-ins, and includes the following software modules: an acquisition module 5431, a determination module 5432, an update module 5433, and a classification module 5434. These modules may be logical functional modules and thus may be arbitrarily combined or further divided according to the functions implemented. The functions of the respective modules will be explained below.
In other embodiments, the artificial intelligence based emotion classification apparatus 543 provided in this embodiment of the present Application may be implemented by a combination of hardware and software, and as an example, the apparatus provided in this embodiment of the present Application may be a processor in the form of a hardware decoding processor, which is programmed to execute the artificial intelligence based emotion classification method provided in this embodiment of the present Application, for example, the processor in the form of a hardware decoding processor may employ one or more Application Specific Integrated Circuits (ASICs), DSPs, Programmable Logic Devices (PLDs), Complex Programmable Logic Devices (CPLDs), Field Programmable Gate Arrays (FPGAs), or other electronic components.
The server 200 in fig. 1 implements the emotion classification method based on artificial intelligence provided in the embodiment of the present application as an example. Referring to fig. 3, fig. 3 is a schematic flowchart of an emotion classification method based on artificial intelligence according to an embodiment of the present application, which will be described with reference to the steps shown in fig. 3.
In step S101, through the emotion classification model to be trained, an emotion classification result and a domain classification result of the source domain text sample and a domain classification result of the target domain text sample are obtained.
In some embodiments, referring to fig. 4, fig. 4 is a schematic structural diagram of an emotion classification model provided in an embodiment of the present application. The emotion classification model includes a feature extraction network, an emotion classification network, and a domain classification network, and a specific implementation manner of the emotion classification method based on artificial intelligence provided in the embodiment of the present application is described below with reference to fig. 4.
In some embodiments, referring to fig. 5, fig. 5 is a flowchart illustrating an emotion classification method based on artificial intelligence provided in an embodiment of the present application, and step S101 shown in fig. 3 may be further implemented by steps S1011 to S1015.
In step S1011, a feature extraction process is performed on the source domain text sample to obtain an emotional feature of the source domain text sample.
In some embodiments, a word segmentation process is performed on the source domain text sample to divide the source domain text sample into a plurality of words; respectively coding a plurality of words to obtain a word vector corresponding to each word; and extracting the emotional characteristics of the source domain text sample from a plurality of word vectors corresponding to the source domain text sample through a characteristic extraction network.
Here, the feature extraction Network may be a feature extraction Network in which a Long Short-Term Memory Network (LSTM), a Recurrent Neural Network (RNN), or a Gated Recurrent Neural Network (GRU) is used as a framework, or may be a Bidirectional Encoder Representation from transforms (BERT) model and an XLNET model with better effect.
As an example, for a labeled source domain text sample { xi s,yi s300-dimensional word vector representation by word embedding, where yi sIs the emotion label (including negative emotion and positive emotion) corresponding to the source domain text sample. By convolutional neural network GfPerforming emotional feature extraction on the word embedded expression of the source domain text sample to obtain an emotional feature G corresponding to the source domain text samplef(xi s)。
In step S1012, a domain classification process is performed based on the emotional features of the source domain text sample to obtain a domain classification result that the source domain text sample belongs to the source domain or the target domain.
In some embodiments, the emotional features of the source domain text samples are mapped to probabilities of belonging to the source domain and the target domain, respectively, through a domain classification network; and determining the sample source with the maximum probability as the domain classification result of the source domain text sample.
For example, when the probability of mapping the emotion features of the source domain text sample to belong to the source domain is 0.7 and the probability of belonging to the target domain is 0.3, the domain classification result of the source domain text sample characterizes that the sample source is the source domain.
In step S1013, emotion classification processing is performed based on emotion features of the source domain text samples to obtain emotion classification results that the source domain text samples belong to negative emotions or positive emotions.
In some embodiments, the emotion characteristics of the source domain text samples are mapped to probabilities of belonging to negative and positive emotions, respectively, through an emotion classification network; and determining the emotion polarity with the maximum probability as the emotion classification result of the source domain text sample.
For example, when mapping emotion features of source domain text samples to have a probability of belonging to a negative emotion of 0.7 and a probability of belonging to a positive emotion of 0.3, the emotion classification results of the source domain text samples characterize that the emotion polarity of the samples is a negative emotion.
It should be noted that step S1012 and step S1013 may be executed in parallel, or may not be executed in a sequential order, that is, the domain classification processing may be performed on the emotion features of the source domain text sample first, the emotion features of the source domain text sample may be performed first, or the domain classification processing and the emotion classification processing may be performed on the emotion features of the source domain text sample in parallel.
In step S1014, feature extraction processing is performed on the target domain text sample to obtain an emotional feature of the target domain text sample.
In some embodiments, the target domain text sample is subjected to word segmentation processing to divide the target domain text sample into a plurality of words; respectively coding a plurality of words to obtain a word vector corresponding to each word; and extracting the emotional characteristics of the target domain text sample from the plurality of word vectors corresponding to the target domain text sample through a characteristic extraction network.
As an example, for the target domain text sample { xi tAnd 300-dimensional word vector representation is performed through word embedding. By convolutional neural network GfPerforming emotional feature extraction on the word embedded expression of the target domain text sample to obtain the emotional feature G corresponding to the target domain text samplef(xi t)。
In step S1015, a domain classification process is performed based on the emotional features of the target domain text sample to obtain a domain classification result that the target domain text sample belongs to the source domain or the target domain.
In some embodiments, the emotional features of the target domain text samples are mapped to probabilities of belonging to the source domain or the target domain, respectively, through the domain classification network; and determining the sample source with the maximum probability as the domain classification result of the target domain text sample.
For example, when the probability of mapping the emotion features of the target domain text sample to belong to the source domain is 0.3 and the probability of belonging to the target domain is 0.7, the domain classification result of the target domain text sample characterizes that the sample source is the target domain.
Here, steps S1011 to S1013 and steps S1014 to S1015 may be executed in parallel, or may not be executed in sequential order, that is, the emotion features of the source domain text sample may be first classified (including domain classification processing and emotion classification processing), the emotion features of the target domain text sample may be first classified, or the emotion features of the source domain text sample and the target domain text sample may be parallel classified.
The method and the device have the advantages that the source domain text samples and the target domain text samples are subjected to feature extraction based on the feature extraction network, and the source domain text samples and the target domain text samples are classified subsequently; and classifying the extracted features in the sample based on the emotion classification network and the domain classification network to obtain corresponding emotion classification results and domain classification results, and the emotion classification results and the domain classification results can be used as index parameters for subsequently measuring the training difficulty and the migration degree of the sample, so that the accuracy of a training model can be improved.
In step S102, a training difficulty coefficient of the source domain text sample is determined based on the emotion classification result of the source domain text sample.
In some embodiments, determining an emotion loss between the emotion classification result and the pre-labeled emotion polarity for the source domain text sample; and determining a training difficulty coefficient positively correlated with the emotional loss.
As an example, will
Figure BDA0002652842970000151
Determining a training difficulty coefficient for the source domain text sample, wherein,
Figure BDA0002652842970000152
is the emotion classification result of the source domain text sample, yi sIs the pre-marked emotion polarity (including negative and positive emotions) of the source domain text sample,
Figure BDA0002652842970000153
is the cross entropy loss between the emotion classification result of the source domain text sample and the pre-labeled emotion polarity.
It should be noted that, as long as the function positively correlated to the emotional loss can be regarded as the training difficulty coefficient in the present application, the present application does not limit this.
In step S103, a migration degree coefficient of the source domain text sample is determined based on the domain classification result of the source domain text sample.
In some embodiments, a migration degree coefficient is determined that positively correlates with the domain classification results of the source domain text samples.
As an example, will
Figure BDA0002652842970000161
A migration degree coefficient is determined for the source domain text sample, wherein,
Figure BDA0002652842970000162
is the domain classification result of the source domain text sample.
It should be noted that, as long as the function positively correlated with the domain classification result of the source domain text sample can be regarded as the migration degree coefficient in the present application, the present application does not limit this.
In step S104, a loss function of the emotion classification model is constructed according to the migration degree coefficient and the training difficulty coefficient of the source domain text sample and the domain classification result of the target domain text sample.
In some embodiments, the penalty function of the sentiment classification model comprises a first sub-penalty function and a second sub-penalty function; referring to fig. 6, fig. 6 is a schematic flowchart of an emotion classification method based on artificial intelligence according to an embodiment of the present application, and step S104 shown in fig. 3 can be further implemented through step S1041 to step S1045.
In step S1041, a weight coefficient of the source domain text sample is determined according to the migration degree coefficient and the training difficulty coefficient of the source domain text sample.
In some embodiments, the migration degree coefficient and the training difficulty coefficient are proportionally summed; determining the weight coefficient as a first weight having a value of 1 when the sum does not exceed the migration threshold; when the sum exceeds the migration threshold, the weight coefficient is determined as a second weight having a value of 0.
As an example, according to a formula
Figure BDA0002652842970000163
λ > 0, η is the migration threshold, a weighting factor is determined, where liIs the training difficulty coefficient; tau isiIs the migration degree coefficient; eta can be any value, when eta is larger, the screening precision of the characterization sample is smaller, and when eta is smaller, the screening precision of the characterization sample is larger;
Figure BDA0002652842970000164
are weight coefficients corresponding to the text samples.
When l isi+λτiWhen the value is less than or equal to eta, determining that the weight coefficient from the text sample is 1; when l isi+λτiWhen η, it is determined that the weight coefficient derived from the text sample is 0.
In step S1042, the emotion loss between the emotion classification result of the source domain text sample and the pre-labeled emotion polarity is determined.
As an example, the cross entropy loss between emotion classification results and pre-labeled emotion polarities for source domain text samples
Figure BDA0002652842970000171
The loss of emotion is determined, wherein,
Figure BDA0002652842970000172
is the emotion classification result of the source domain text sample, yi sIs the pre-marked emotion polarity (including negative and positive emotions) of the source domain text sample.
In step S1043, the product of the weight coefficient and the emotion loss is determined as a first sub-loss function.
Here, the value of the weight coefficient in step S1043 may be completely equal to the value of the weight coefficient in step S1041, or may be a proportional value of the weight coefficient in step S1041, as long as the first sub-loss function includes an arithmetic term composed of a product between the weight coefficient and the emotion loss, which is not limited in the present application.
As an example, the product of the first parameter, the weight coefficient and the affective loss is determined as a first sub-loss function.
For example, will
Figure BDA0002652842970000173
Is determined as a first sub-loss function, wherein-1/nsIs a first parameter, nsIs the number of source domain text samples.
In step S1044, a difference between the first function and the second function is determined as a second sub-loss function.
As an example, the first function is a product between the weight coefficient and a first sub-function, which positively correlates with the probability of the domain classification result of the source domain text sample.
Here, the value of the weight coefficient in step S1044 may be completely equal to the value of the weight coefficient in step S1041, or may be a proportional value of the weight coefficient in step S1041, as long as the first function includes an arithmetic term composed of a product between the weight coefficient and the first sub-function, which is not limited in this application.
Here, the probability of the domain classification result of the source domain text sample refers to the probability of mapping the emotion feature of the source domain text sample to belong to the type of the corresponding pre-labeled sample source (i.e., the source domain), for example, when the probability of mapping the emotion feature of the source domain text sample to belong to the source domain is 0.7 and the probability of belonging to the target domain is 0.3, the probability of the domain classification result of the source domain text sample is 0.7.
For example, the first function is a product between the second parameter, the weight coefficient, and a first sub-function that positively correlates with the probability of the domain classification result of the source domain text sample.
For example, will
Figure BDA0002652842970000181
Determined as a first sub-function of
Figure BDA0002652842970000182
Is determined as a first function, wherein-1/nsIs the second parameter, nsIs the number of source domain text samples. Need toIt should be noted that, as long as the function positively correlated with the probability of the domain classification result of the source domain text sample can be regarded as the first sub-function in the present application, the present application does not limit this.
As an example, the second function is inversely related to the probability of the domain classification result of the target domain text sample.
For example, will
Figure BDA0002652842970000183
Determined as a second function, where ntIs the number of target domain text samples. It should be noted that, as long as the function negatively correlated with the probability of the domain classification result of the target domain text sample can be regarded as the second function in the present application, the present application does not limit this function.
To sum up, the following steps are carried out
Figure BDA0002652842970000184
Determined as a second sub-loss function.
In step S1045, the first sub-loss function and the second sub-loss function are determined as the loss functions of the emotion classification model.
As an example, a first sub-loss function
Figure BDA0002652842970000185
And a second sub-loss function
Figure BDA0002652842970000186
And determining a loss function of the emotion classification model.
According to the embodiment of the application, different weight coefficients are given to the source domain text samples based on the migration degree and the training difficulty of the source domain text samples, so that the simple source domain text samples can be given higher weights in the initial stage of training, and the weights of the difficult source domain text samples can be gradually increased along with the continuation of the training process. This makes it easy for the model to find better local optima, while speeding up the training.
In step S105, parameters of the emotion classification model are updated according to the loss function.
In some embodiments, determining a parameter variation value of the emotion classification model when the difference between the first sub-loss function and the second sub-loss function takes a minimum value; and updating the parameters of the emotion classification model based on the parameter change values.
As an example, updating the parameters of the emotion classification model based on the parameter change values may include: and adding the parameter change value and the parameter of the emotion classification model, and taking the added result as the updated parameter of the emotion classification model.
For example, determine when satisfied
Figure BDA0002652842970000191
And
Figure BDA0002652842970000192
parameters of an emotion classification model (including a feature extraction network, a domain classification network, and an emotion classification network), where θfIs a feature extraction network GfParameter of (a), thetadIs a domain classification network GdParameter of (a) and thetayIs an emotion classification network GyThe parameter (c) of (c).
In each round of training process, different weights are applied to the source domain text samples, so that the forward action of transfer learning is greatly enhanced, the negative effect caused by noise samples is avoided, the transfer performance is improved, and the final representation information can adapt to natural language processing tasks in different fields.
In step S106, an emotion classification result of the text to be detected is obtained based on the trained emotion classification model.
In some embodiments, a text to be detected is obtained; the following processing is executed through the trained emotion classification model: performing feature extraction processing on the text to be detected to obtain emotional features of the text to be detected, and mapping the emotional features of the text to be detected into probabilities of different emotional polarities; and determining the emotion polarity corresponding to the maximum probability as the emotion type classification result of the text to be detected.
As an example, a text to be detected is obtained; performing feature extraction processing on the text to be detected through a feature extraction network to obtain emotional features of the text to be detected; mapping the emotional characteristics of the text to be detected into probabilities of different emotional polarities through an emotion classification network; and determining the emotion polarity corresponding to the maximum probability as the emotion type classification result of the text to be detected.
For example, when the emotion feature of the text to be detected is mapped to have a probability of belonging to a negative emotion of 0.7 and a probability of belonging to a positive emotion of 0.3, the emotion classification result of the text to be detected indicates that the emotion polarity of the text to be detected is a negative emotion.
According to the text emotion recognition method and device, text emotion recognition is achieved based on the trained emotion classification model, and the efficiency and accuracy of text emotion analysis can be improved.
An exemplary software implementation of the emotion classification apparatus 543 based on artificial intelligence according to the embodiment of the present application is described below with reference to fig. 2.
In some embodiments, the artificial intelligence based emotion classification device 543 can be implemented as mobile-side applications and modules.
The embodiment of the application can provide a software module designed by using programming languages such as C/C + +, Java and the like, and the software module is embedded into various mobile terminal Apps based on systems such as Android or iOS and the like (stored in a storage medium of the mobile terminal as an executable instruction and executed by a processor of the mobile terminal), so that tasks such as text emotion recognition and the like are completed by directly using computing resources of the mobile terminal, and text emotion recognition results are transmitted to a remote server through various network communication modes periodically or aperiodically or are stored locally at the mobile terminal.
In other embodiments, the artificial intelligence based emotion classification device 543 can be implemented as a server application and platform.
The embodiment of the application can provide application software designed by using programming languages such as C/C + +, Java and the like or a special software module in a large-scale software system, operate in a server end (stored in a storage medium of the server end in an executable instruction mode and operated by a processor of the server end), combine at least one of various received original data, intermediate data of each level and final results from other equipment with some data or results existing on the server to perform emotion recognition on a text to be detected, and then output the emotion recognition results to other application programs or modules in real time or non-real time for use, or write the emotion recognition results into a database or file of the server end for storage.
Continuing with FIG. 2 to describe the structure of the electronic device 500, in some embodiments, as shown in FIG. 2, the software modules stored in the artificial intelligence based emotion classification apparatus 543 of the memory 540 may include: an acquisition module 5431, a determination module 5432, an update module 5433, and a classification module 5434.
An obtaining module 5431, configured to obtain, through an emotion classification model to be trained, an emotion classification result and a domain classification result of a source domain text sample, and a domain classification result of a target domain text sample;
a determining module 5432, configured to determine, based on the emotion classification result of the source domain text sample, a training difficulty coefficient of the source domain text sample;
the determining module 5432 is further configured to determine a migration degree coefficient of the source domain text sample based on a domain classification result of the source domain text sample;
an updating module 5433, configured to construct a loss function of the emotion classification model according to the migration degree coefficient and the training difficulty coefficient of the source domain text sample and the domain classification result of the target domain text sample, and update a parameter of the emotion classification model according to the loss function;
and the classification module 5434 is configured to obtain an emotion classification result of the text to be detected based on the emotion classification model after training.
In the above solution, the determining module 5432 is further configured to determine an emotion loss between the emotion classification result of the source domain text sample and a pre-marked emotion polarity; determining a training difficulty coefficient positively correlated to the emotional loss.
In the above solution, the determining module 5432 is further configured to determine a migration degree coefficient positively correlated to the domain classification result of the source domain text sample.
In the above scheme, the loss function of the emotion classification model includes a first sub-loss function and a second sub-loss function; the updating module 5433 is further configured to determine a weight coefficient of the source domain text sample according to the migration degree coefficient and the training difficulty coefficient of the source domain text sample; determining emotion loss between the emotion classification result of the source domain text sample and the pre-marked emotion polarity; determining the product of the weight coefficient and the emotional loss as the first sub-loss function; determining a difference between the first function and the second function as the second sub-loss function; wherein the first function is a product between the weight coefficient and a first sub-function that positively correlates with a probability of a domain classification result of the source domain text sample; wherein the second function is inversely related to the probability of the domain classification result of the target domain text sample.
In the above scheme, the updating module 5433 is further configured to perform proportional summation on the migration degree coefficient and the training difficulty coefficient; determining the weight coefficient as a first weight having a value of 1 when the sum does not exceed a migration threshold; determining the weight coefficient as a second weight having a value of zero when the sum exceeds the migration threshold.
In the above solution, the updating module 5433 is further configured to determine a parameter variation value of the emotion classification model when the difference between the first sub-loss function and the second sub-loss function is a minimum value, and the second sub-loss function is a minimum value; and adding the parameter change value and the parameter of the emotion classification model, and taking the added result as the updated parameter of the emotion classification model.
In the above scheme, the classification module 5434 is further configured to obtain a text to be detected; executing the following processing by the emotion classification model after training: performing feature extraction processing on the text to be detected to obtain emotional features of the text to be detected, and mapping the emotional features of the text to be detected into probabilities of different emotional polarities; and determining the emotion polarity corresponding to the maximum probability as the emotion type classification result of the text to be detected.
In the above scheme, the obtaining module 5431 is further configured to perform feature extraction processing on the source domain text sample to obtain an emotion feature of the source domain text sample, perform domain classification processing based on the emotion feature of the source domain text sample to obtain a domain classification result that the source domain text sample belongs to a source domain or a target domain, and perform emotion classification processing based on the emotion feature of the source domain text sample to obtain an emotion classification result that the source domain text sample belongs to a negative emotion or a positive emotion; and performing feature extraction processing on the target domain text sample to obtain the emotional features of the target domain text sample, and performing domain classification processing based on the emotional features of the target domain text sample to obtain a domain classification result of the target domain text sample belonging to a source domain or a target domain.
In the above scheme, the obtaining module 5431 is further configured to perform word segmentation on the source domain text sample, so as to divide the source domain text sample into a plurality of words; respectively encoding a plurality of words to obtain a word vector corresponding to each word; extracting emotional features of the source domain text sample from the plurality of word vectors corresponding to the source domain text sample.
In the above scheme, the obtaining module 5431 is further configured to perform word segmentation on the target domain text sample, so as to divide the target domain text sample into a plurality of words; respectively encoding a plurality of words to obtain a word vector corresponding to each word; extracting emotional features of the target domain text sample from a plurality of word vectors corresponding to the target domain text sample.
In the above solution, the obtaining module 5431 is further configured to map emotion features of the source domain text sample into probabilities of belonging to a negative emotion and a positive emotion, respectively; and determining the emotion polarity with the maximum probability as the emotion classification result of the source domain text sample.
In the above scheme, the obtaining module 5431 is further configured to map the emotional features of the source domain text sample into probabilities of respectively belonging to a source domain and a target domain; and determining the sample source with the maximum probability as the domain classification result of the source domain text sample.
In the above scheme, the obtaining module 5431 is further configured to map the emotional features of the target domain text sample into probabilities of respectively belonging to a source domain or a target domain; and determining the sample source with the maximum probability as the domain classification result of the target domain text sample.
Embodiments of the present application provide a computer program product or computer program comprising computer instructions stored in a computer readable storage medium. The processor of the computer device reads the computer instructions from the computer readable storage medium, and the processor executes the computer instructions to make the computer device execute the artificial intelligence based emotion classification method described in the embodiment of the application.
Embodiments of the present application provide a computer-readable storage medium having stored thereon executable instructions that, when executed by a processor, cause the processor to perform an artificial intelligence based emotion classification method provided by embodiments of the present application, for example, the artificial intelligence based emotion classification method illustrated in fig. 3, 5 or 6.
In some embodiments, the computer-readable storage medium may be memory such as FRAM, ROM, PROM, EPROM, EEPROM, flash, magnetic surface memory, optical disk, or CD-ROM; or may be various devices including one or any combination of the above memories.
In some embodiments, executable instructions may be written in any form of programming language (including compiled or interpreted languages), in the form of programs, software modules, scripts or code, and may be deployed in any form, including as a stand-alone program or as a module, component, subroutine, or other unit suitable for use in a computing environment.
By way of example, executable instructions can correspond, but do not necessarily correspond, to files in a file system, and can be stored in a portion of a file that holds other programs or data, e.g., in one or more scripts stored in a hypertext markup language document, in a single file dedicated to the program in question, or in multiple coordinated files (e.g., files that store one or more modules, sub-programs, or portions of code).
By way of example, executable instructions may be deployed to be executed on one computing device or on multiple computing devices at one site or distributed across multiple sites and interconnected by a communication network.
The emotion classification method based on artificial intelligence provided in the embodiments of the present application will be described below by taking an example in which text is an evaluation of a product.
Aiming at the condition of insufficient field labeling data in cross-field emotion analysis, the embodiment of the application provides an emotion classification method based on artificial intelligence based on the cross-field emotion analysis learning of course learning, and the problem of domain adaptation can be solved.
The embodiment of the application can effectively fuse the convolutional neural network model, and in each round of training process, different weights are applied to the source domain marking samples (namely the source domain text samples), so that the forward action of transfer learning is greatly enhanced, the negative effect brought by the noise samples is avoided, the transfer performance is improved, and the final representation information can adapt to natural language processing tasks in different fields.
Referring to fig. 7 and 8, fig. 7 and 8 are schematic diagrams illustrating an application scenario of the artificial intelligence based emotion classification method according to the embodiment of the present application.
A user usually evaluates purchased commodities, and the corresponding emotion polarity can be identified according to the evaluation in the embodiment of the present application, for example, in fig. 7, the "appearance of the PC looks good but the battery life is too short" the corresponding emotion polarity 701 is identified as a negative emotion according to the evaluation of the user; in fig. 8, the user can "the appearance of the piece of clothing looks good and the fabric still does not" recognize that the corresponding emotion polarity 801 is a positive emotion.
The embodiment of the application is suitable for user evaluation of electronic commerce, for example, for commodities in different fields, wherein expression emotion modes of each field are different, and the embodiment of the application can enable a neural network model to achieve the effect of knowledge migration in evaluation in different fields.
In the following, a specific implementation of the emotion classification method based on artificial intelligence according to the embodiment of the present application will be described.
First, emotion analysis
(1) Sentence (i.e., text above) vectorization: for marked source domain samples (i.e., the source domain text samples described above) { xi s,yi sAnd unlabeled target Domain samples (i.e., target Domain text samples as described above) { xi tAnd representing samples of the two domains by Word embedding with a 300-dimensional Word vector (Global Vectors for Word Representation).
Wherein, yi sIs the emotion label corresponding to the source domain sample.
(2) Sentence emotional feature extraction: by convolutional neural network GfPerforming emotional feature extraction on the word embedding representations of the two fields to respectively obtain emotional features G corresponding to the source domain samplesf(xi s) And emotional characteristics G corresponding to the target domain samplesf(xi t)。
Two, dynamic course learning
The core part of the embodiment of the application is dynamic course learning, and learning modes can be changed from simple data (namely samples) to difficult data and from migratable examples (namely samples) to non-migratable examples.
The embodiment of the present application aims to train an emotion classification model based on a source domain sample and a target domain sample, where the emotion classification model includes a convolutional neural network (i.e., the above-mentioned feature extraction network), a domain discriminator (i.e., the above-mentioned domain classification network), and an emotion classifier (i.e., the above-mentioned emotion classification network), so as to obtain parameters of the emotion classification model, and the parameters include: parameters of a convolutional neural network, parameters of a domain discriminator and parameters of an emotion classifier.
In the practical application process, when a text to be detected is input, corresponding emotion characteristics are extracted through a convolutional neural network, and then an emotion classification result is obtained through an emotion classifier (namely, the emotion polarity of the text to be detected is judged to be positive emotion or negative emotion).
The specific training process of the emotion classification model comprises the following steps:
(1) course learning: in the embodiment of the present application, it is necessary to learn a convertible course, which can select a sample useful for testing data. In particular, embodiments of the present application prioritize partial samples by assigning them a higher weight from both the ease and migratability dimensions.
The implementation mode is as follows: for example, the samples a and the samples B are respectively input into the emotion classification model, and the loss a of the corresponding sample a and the loss B of the corresponding sample B are respectively calculated according to a loss function carrying weight coefficients, wherein the loss a and the loss B respectively correspond to different weights (i.e., the following loss a and loss B are respectively assigned with different weights)
Figure BDA0002652842970000261
The weight coefficients are associated with the classification results (including domain classification results and emotion classification results).
The embodiment of the application obtains the emotional characteristics G in two fieldsf(xi s) And Gf(xi t) Performing course learning, wherein the emotion classification model comprises a convolution neural network GfAnd a domain discriminator GdEmotion classifier GyWherein n issIs the number of source domain samples, ntIs the number of samples of the target domain,
Figure BDA0002652842970000262
weights are set for the source domain samples during the training process.
Wherein, the domain discriminator GdFor obtaining domain classification results (i.e. judgment samples)Originally belonging to the source domain or the target domain), a domain discriminator GdIs the emotional characteristics G of the samplef(xi s) And Gf(xi t) The output is the domain classification result of the corresponding sample;
wherein, the emotion classifier GyFor obtaining emotion classification results (i.e. judging whether the emotion polarity of the sample is positive emotion or negative emotion), the emotion classifier GyIs the emotional characteristics G of the samplef(xi s) And Gf(xi t) Outputting the emotion classification result of the corresponding sample;
the loss function of the emotion classification model consists of two parts, wherein the first part is the loss L of the emotion classifier1(i.e., the first sub-loss function described above), emotion classifier loss L1As shown in equation (1); the second part is the domain discriminator loss L2(i.e., the second sub-loss function described above), the domain discriminator loss L2As shown in equation (2).
Figure BDA0002652842970000263
Figure BDA0002652842970000264
Wherein,
Figure BDA0002652842970000265
is the sentiment classification result of the source domain samples,
Figure BDA0002652842970000266
is the result of the domain classification of the source domain samples,
Figure BDA0002652842970000267
is the domain classification result of the target domain sample.
Weight coefficient
Figure BDA0002652842970000268
As shown in equation (3):
Figure BDA0002652842970000269
λ > 0, η is the threshold (3)
Weight coefficient
Figure BDA0002652842970000271
Consisting of two parts, expressing two layers, the first being the ease of migration
Figure BDA0002652842970000272
The second is a domain discriminator GdDefined degree of migratability
Figure BDA0002652842970000273
(2) Training process: by weighting emotion classifier loss and domain discriminator loss, and combining course learning processes, a new form of confrontational training can be obtained, see equations (4) - (6), where θfdyAre each Gf,Gd,GyThe goal is to train the saddle point solution generated by a minimax optimization process
Figure BDA0002652842970000274
Figure BDA0002652842970000275
Figure BDA0002652842970000276
It should be noted that, in the core technology "course learning" in the embodiment of the present application, domain differences are explicitly modeled and optimized through end-to-end small-batch training, and the embodiment of the present application may also replace the feature extraction Network with a Long Short-Term Memory Network (LSTM), a Recurrent Neural Network (RNN), or a Gated Recurrent Neural Network (GRU) as a feature extraction Network with a framework. If the effect is better, the feature extraction network can be replaced by a better two-way coder Representation (BERT) model, an XLNET model and the like.
According to the embodiment of the application, the noise samples causing damage to the emotion classifier and the field discriminator can be filtered out simultaneously through course learning, and related samples are transferred to the target field through field antagonism learning under guidance of a convertible course, so that a forward migration effect is promoted, and a negative migration effect is reduced. The embodiment of the application is also suitable for other natural language processing tasks, such as question answering and machine translation, and can obtain better effects.
In summary, the embodiment of the present application has the following beneficial effects:
(1) the emotion classification model is trained simultaneously based on the source domain text sample and the target domain text sample, so that the richness and diversity of training data are increased, the robustness of the emotion classification model can be improved, and overfitting is avoided; and based on two dimensions of training difficulty and migration degree, different weights are given to different source domain text samples for training, the applicability of the training samples can be improved, and therefore the efficiency and the accuracy of text emotion recognition based on the emotion classification model finished by training in the follow-up process can be improved.
(2) The source domain text sample and the target domain text sample are subjected to feature extraction based on a feature extraction network, so that the source domain text sample and the target domain text sample can be classified subsequently; and classifying the extracted features in the sample based on the emotion classification network and the domain classification network to obtain corresponding emotion classification results and domain classification results, and the emotion classification results and the domain classification results can be used as index parameters for subsequently measuring the training difficulty and the migration degree of the sample, so that the accuracy of a training model can be improved.
(3) Different weight coefficients are given to the source domain text samples based on the migration degree and the training difficulty of the source domain text samples, so that the simple source domain text samples can be given higher weight in the initial stage of training, and the weight of the difficult source domain text samples can be gradually increased along with the continuation of the training process. This makes it easy for the model to find better local optima, while speeding up the training.
(4) In each round of training process, different weights are applied to the source domain text samples, so that the forward action of transfer learning is greatly enhanced, the negative effect brought by noise samples is avoided, the transfer performance is improved, and the final representation information can adapt to natural language processing tasks in different fields.
(5) Text emotion recognition is realized based on the trained emotion classification model, and the efficiency and accuracy of text emotion analysis can be improved.
The above description is only an example of the present application, and is not intended to limit the scope of the present application. Any modification, equivalent replacement, and improvement made within the spirit and scope of the present application are included in the protection scope of the present application.

Claims (10)

1. An emotion classification method based on artificial intelligence is characterized by comprising the following steps:
obtaining emotion classification results and domain classification results of source domain text samples and domain classification results of target domain text samples through an emotion classification model to be trained;
determining a training difficulty coefficient of the source domain text sample based on the emotion classification result of the source domain text sample;
determining a migration degree coefficient of the source domain text sample based on a domain classification result of the source domain text sample;
constructing a loss function of the emotion classification model according to the migration degree coefficient and the training difficulty coefficient of the source domain text sample and the domain classification result of the target domain text sample, and updating parameters of the emotion classification model according to the loss function;
and obtaining the emotion classification result of the text to be detected based on the emotion classification model after training.
2. The method of claim 1,
determining a training difficulty coefficient of the source domain text sample based on the emotion classification result of the source domain text sample, including:
determining emotion loss between the emotion classification result of the source domain text sample and the pre-marked emotion polarity;
determining a training difficulty coefficient positively correlated with the emotional loss;
the determining a migration degree coefficient of the source domain text sample based on the domain classification result of the source domain text sample comprises:
and determining a migration degree coefficient positively correlated with the domain classification result of the source domain text sample.
3. The method of claim 1,
the loss function of the emotion classification model comprises a first sub-loss function and a second sub-loss function;
the constructing the loss function of the emotion classification model according to the migration degree coefficient and the training difficulty coefficient of the source domain text sample and the domain classification result of the target domain text sample comprises:
determining a weight coefficient of the source domain text sample according to the migration degree coefficient and the training difficulty coefficient of the source domain text sample;
determining emotion loss between the emotion classification result of the source domain text sample and the pre-marked emotion polarity;
determining the product of the weight coefficient and the emotional loss as the first sub-loss function;
determining a difference between the first function and the second function as the second sub-loss function;
wherein the first function is a product between the weight coefficient and a first sub-function that positively correlates with a probability of a domain classification result of the source domain text sample;
wherein the second function is inversely related to the probability of the domain classification result of the target domain text sample.
4. The method of claim 3, wherein determining the weight coefficient of the source domain text sample according to the migration degree coefficient and the training difficulty coefficient of the source domain text sample comprises:
proportionally adding the migration degree coefficient and the training difficulty coefficient;
determining the weight coefficient as a first weight having a value of 1 when the sum does not exceed a migration threshold;
determining the weight coefficient as a second weight having a value of zero when the sum exceeds the migration threshold.
5. The method of claim 3, wherein updating the parameters of the emotion classification model according to the loss function comprises:
determining a parameter change value of the emotion classification model when the difference value between the first sub-loss function and the second sub-loss function is the minimum value;
and adding the parameter change value and the parameter of the emotion classification model, and taking the added result as the updated parameter of the emotion classification model.
6. The method according to claim 1, wherein obtaining emotion classification results of the text to be detected based on the trained emotion classification model comprises:
acquiring a text to be detected;
executing the following processing by the emotion classification model after training: performing feature extraction processing on the text to be detected to obtain emotional features of the text to be detected, and mapping the emotional features of the text to be detected into probabilities of different emotional polarities;
and determining the emotion polarity corresponding to the maximum probability as the emotion type classification result of the text to be detected.
7. The method of claim 1, wherein obtaining emotion classification results and domain classification results of source domain text samples and domain classification results of target domain text samples through an emotion classification model to be trained comprises:
performing feature extraction processing on the source domain text sample to obtain the emotional features of the source domain text sample, and performing domain classification processing based on the emotional features of the source domain text sample to obtain a domain classification result of the source domain text sample belonging to a source domain or a target domain;
performing emotion classification processing based on the emotion characteristics of the source domain text sample to obtain an emotion classification result of the source domain text sample belonging to negative emotion or positive emotion;
and performing feature extraction processing on the target domain text sample to obtain the emotional features of the target domain text sample, and performing domain classification processing based on the emotional features of the target domain text sample to obtain a domain classification result of the target domain text sample belonging to a source domain or a target domain.
8. The method of claim 7,
the performing feature extraction processing on the source domain text sample to obtain the emotional features of the source domain text sample includes:
performing word segmentation processing on the source domain text sample to divide the source domain text sample into a plurality of words;
respectively encoding a plurality of words to obtain a word vector corresponding to each word;
extracting emotional features of the source domain text sample from a plurality of word vectors corresponding to the source domain text sample;
the performing feature extraction processing on the target domain text sample to obtain the emotional features of the target domain text sample includes:
performing word segmentation processing on the target domain text sample to divide the target domain text sample into a plurality of words;
respectively encoding a plurality of words to obtain a word vector corresponding to each word;
extracting emotional features of the target domain text sample from a plurality of word vectors corresponding to the target domain text sample.
9. The method of claim 7,
the emotion classification processing is carried out based on the emotion characteristics of the source domain text sample so as to obtain an emotion classification result that the source domain text sample belongs to a negative emotion or a positive emotion, and the emotion classification processing comprises the following steps:
mapping the emotion characteristics of the source domain text sample into probabilities of respectively belonging to a negative emotion and a positive emotion;
determining the emotion polarity with the maximum probability as the emotion classification result of the source domain text sample;
the performing domain classification processing based on the emotional features of the source domain text sample to obtain a domain classification result that the source domain text sample belongs to a source domain or a target domain includes:
mapping the emotional characteristics of the source domain text sample into probabilities respectively belonging to a source domain and a target domain;
determining the sample source with the maximum probability as the domain classification result of the source domain text sample;
the domain classification processing is performed based on the emotional features of the target domain text sample to obtain a domain classification result that the target domain text sample belongs to a source domain or a target domain, and the domain classification processing comprises:
mapping the emotional characteristics of the target domain text sample into probabilities of respectively belonging to a source domain or a target domain;
and determining the sample source with the maximum probability as the domain classification result of the target domain text sample.
10. An emotion classification apparatus based on artificial intelligence, the apparatus comprising:
the obtaining module is used for obtaining the emotion classification result and the domain classification result of the source domain text sample and the domain classification result of the target domain text sample through the emotion classification model to be trained;
the determining module is used for determining a training difficulty coefficient of the source domain text sample based on the emotion classification result of the source domain text sample;
the determining module is further configured to determine a migration degree coefficient of the source domain text sample based on a domain classification result of the source domain text sample;
the updating module is used for constructing a loss function of the emotion classification model according to the migration degree coefficient and the training difficulty coefficient of the source domain text sample and the domain classification result of the target domain text sample, and updating parameters of the emotion classification model according to the loss function;
and the classification module is used for obtaining the emotion classification result of the text to be detected based on the emotion classification model after training.
CN202010876860.7A 2020-08-27 2020-08-27 Emotion classification method and device based on artificial intelligence Active CN112015896B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010876860.7A CN112015896B (en) 2020-08-27 2020-08-27 Emotion classification method and device based on artificial intelligence

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010876860.7A CN112015896B (en) 2020-08-27 2020-08-27 Emotion classification method and device based on artificial intelligence

Publications (2)

Publication Number Publication Date
CN112015896A true CN112015896A (en) 2020-12-01
CN112015896B CN112015896B (en) 2024-02-06

Family

ID=73503239

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010876860.7A Active CN112015896B (en) 2020-08-27 2020-08-27 Emotion classification method and device based on artificial intelligence

Country Status (1)

Country Link
CN (1) CN112015896B (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112541081A (en) * 2020-12-21 2021-03-23 中国人民解放军国防科技大学 Migratory rumor detection method based on field self-adaptation
CN113505582A (en) * 2021-05-25 2021-10-15 腾讯音乐娱乐科技(深圳)有限公司 Music comment sentiment analysis method, equipment and medium
CN113705697A (en) * 2021-08-31 2021-11-26 平安科技(深圳)有限公司 Information pushing method, device, equipment and medium based on emotion classification model
CN114443849A (en) * 2022-02-09 2022-05-06 北京百度网讯科技有限公司 Method and device for selecting marked sample, electronic equipment and storage medium
CN116029394A (en) * 2023-03-29 2023-04-28 季华实验室 Self-adaptive text emotion recognition model training method, electronic equipment and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20120185415A1 (en) * 2011-01-13 2012-07-19 International Business Machines Corporation System and method for domain adaption with partial observation
CN109271522A (en) * 2018-11-20 2019-01-25 深圳大学 Comment sensibility classification method and system based on depth mixed model transfer learning
CN109308318A (en) * 2018-08-14 2019-02-05 深圳大学 Training method, device, equipment and the medium of cross-domain texts sentiment classification model
CN114186063A (en) * 2021-12-14 2022-03-15 合肥工业大学 Training method and classification method of cross-domain text emotion classification model

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20120185415A1 (en) * 2011-01-13 2012-07-19 International Business Machines Corporation System and method for domain adaption with partial observation
CN109308318A (en) * 2018-08-14 2019-02-05 深圳大学 Training method, device, equipment and the medium of cross-domain texts sentiment classification model
CN109271522A (en) * 2018-11-20 2019-01-25 深圳大学 Comment sensibility classification method and system based on depth mixed model transfer learning
CN114186063A (en) * 2021-12-14 2022-03-15 合肥工业大学 Training method and classification method of cross-domain text emotion classification model

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112541081A (en) * 2020-12-21 2021-03-23 中国人民解放军国防科技大学 Migratory rumor detection method based on field self-adaptation
CN112541081B (en) * 2020-12-21 2022-09-16 中国人民解放军国防科技大学 Migratory rumor detection method based on field self-adaptation
CN113505582A (en) * 2021-05-25 2021-10-15 腾讯音乐娱乐科技(深圳)有限公司 Music comment sentiment analysis method, equipment and medium
CN113705697A (en) * 2021-08-31 2021-11-26 平安科技(深圳)有限公司 Information pushing method, device, equipment and medium based on emotion classification model
CN114443849A (en) * 2022-02-09 2022-05-06 北京百度网讯科技有限公司 Method and device for selecting marked sample, electronic equipment and storage medium
CN114443849B (en) * 2022-02-09 2023-10-27 北京百度网讯科技有限公司 Labeling sample selection method and device, electronic equipment and storage medium
US11907668B2 (en) 2022-02-09 2024-02-20 Beijing Baidu Netcom Science Technology Co., Ltd. Method for selecting annotated sample, apparatus, electronic device and storage medium
CN116029394A (en) * 2023-03-29 2023-04-28 季华实验室 Self-adaptive text emotion recognition model training method, electronic equipment and storage medium

Also Published As

Publication number Publication date
CN112015896B (en) 2024-02-06

Similar Documents

Publication Publication Date Title
CN112015896A (en) Emotion classification method and device based on artificial intelligence
CN112380435B (en) Document recommendation method and system based on heterogeneous graph neural network
US11645548B1 (en) Automated cloud data and technology solution delivery using machine learning and artificial intelligence modeling
CN111523640B (en) Training method and device for neural network model
CN111831826B (en) Training method, classification method and device of cross-domain text classification model
US20210383205A1 (en) Taxonomy Construction via Graph-Based Cross-domain Knowledge Transfer
CN113590863A (en) Image clustering method and device and computer readable storage medium
CN114443899A (en) Video classification method, device, equipment and medium
CN114610989A (en) Personalized thesis recommendation method and system based on heterogeneous graph dynamic information compensation
CN115391499A (en) Method for generating multitask generation model, question-answer pair generation method and related device
CN116541492A (en) Data processing method and related equipment
CN114529761A (en) Video classification method, device, equipment, medium and product based on classification model
Kavikondala et al. Automated retraining of machine learning models
Fong et al. Augmented intelligence with ontology of semantic objects
CN112712056A (en) Video semantic analysis method and device, storage medium and electronic equipment
CN112256917A (en) User interest identification method, device, equipment and computer readable storage medium
CN110969549B (en) Judicial data processing method and system
CN117033649A (en) Training method and device for text processing model, electronic equipment and storage medium
US20230117893A1 (en) Machine learning techniques for environmental discovery, environmental validation, and automated knowledge repository generation
CN111460169B (en) Semantic expression generation method, device and equipment
CN115186085A (en) Reply content processing method and interaction method of media content interaction content
CN110210518B (en) Method and device for extracting dimension reduction features
CN112417260B (en) Localized recommendation method, device and storage medium
CN115843364A (en) Continuous learning using cross-connects
CN117711001B (en) Image processing method, device, equipment and medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant