Emotion analysis method and device and storage medium

By obtaining the user's identity information and emotional consultation information, and using a pre-trained sentiment analysis model based on text information and knowledge graphs for analysis, the problem of inaccurate sentiment analysis in the prior art is solved, and efficient and accurate sentiment analysis and abnormal recognition are achieved.

CN119537972APending Publication Date: 2025-02-28BEIJING XIAOMI MOBILE SOFTWARE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311110421.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-08-30
Publication Date
2025-02-28

AI Technical Summary

Technical Problem

The prior art is difficult to conduct emotional analysis in a quick and accurate manner, especially when facing emotional abnormalities, and lack of effective analysis methods and tools, resulting in the inability to identify and deal with emotional abnormalities in a timely manner.

Method used

By obtaining user identity information and emotional consultation information, a pre-trained sentiment analysis model based on text information and knowledge graphs is used for analysis. The model is based on the attention mechanism and the tree attention mechanism, combined with masked text and template text, optimized training to improve the accuracy of sentiment analysis.

Benefits of technology

Accurate analysis of user emotions is achieved, the accuracy and efficiency of emotion analysis is improved, and emotional abnormalities can be identified and handled more accurately.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119537972A_ABST
    Figure CN119537972A_ABST
Patent Text Reader

Abstract

The invention relates to an emotion analysis method and device and a storage medium. The sentiment analysis method comprises the steps that identity information and sentiment consultation information input by a user on electronic equipment are obtained, and the sentiment consultation information is used for requesting sentiment analysis; an emotion analysis result matched with the identity information and the emotion consultation information is obtained, the emotion analysis result is obtained through an emotion analysis model, the emotion analysis model is obtained through pre-training based on the text information and a knowledge graph, and the knowledge graph comprises different emotion anomaly reason information corresponding to different identity information. The sentiment analysis is performed according to the identity information and the input sentiment consultation information, so that the sentiment analysis accuracy is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of artificial intelligence, and in particular to a sentiment analysis method, device and storage medium. Background Art

[0002] In daily study and life, different people may have different psychological problems due to personal or environmental reasons. Among them, abnormal emotional symptoms have become more common in life. Because the emotionally abnormal group may face the influence of academic and social pressure, campus violence, family reasons, physiological genetics and other reasons, it is very easy to cause emotional abnormality, which is a situation that cannot be easily ignored. Moreover, most patients with psychological abnormalities do not have the time, energy and opportunity to seek normal medical treatment, which can easily affect their physical and mental state over time. Therefore, there is a need for a more convenient and easy-to-access method for this group of people, which can accurately perform emotional analysis and determine the causes of emotional abnormalities in this group of people. Summary of the invention

[0003] In order to overcome the problems existing in the related art, the present disclosure provides a sentiment analysis method, device and storage medium.

[0004] According to a first aspect of an embodiment of the present disclosure, a sentiment analysis method is provided, comprising: obtaining identity information and sentiment consultation information input by a user on an electronic device, wherein the sentiment consultation information is used to request sentiment analysis; obtaining a sentiment analysis result that matches the identity information and the sentiment consultation information, wherein the sentiment analysis result is obtained through a sentiment analysis model, and the sentiment analysis model is pre-trained based on text information and a knowledge graph, wherein the knowledge graph includes different sentiment abnormality cause information corresponding to different identity information.

[0005] In one embodiment, the sentiment analysis model is pre-trained based on text information and a knowledge graph in the following manner: a text training set and a knowledge graph are determined, wherein a plurality of information groups are included in the knowledge graph, each of the plurality of information groups includes identity information and a plurality of elements of causes of emotional abnormality corresponding to the identity information, and each of the plurality of elements corresponds to a keyword; the text in the text training set is segmented to obtain N segmented words, where N is a positive integer; the N segmented words are respectively used as first keywords, a second keyword identical to the first keyword is determined in the information group, and the text information and the information group are concatenated according to the first keyword and the second keyword to obtain a first text; based on the first text, a sentiment analysis prediction model is trained to obtain a sentiment analysis model.

[0006] In one embodiment, the method of training a sentiment analysis prediction model based on the first text to obtain a sentiment analysis model includes: adding mask text and template text to the text included in the first text to obtain a second text; and training a sentiment analysis prediction model based on the second text to obtain a sentiment analysis model.

[0007] In one embodiment, the training of the sentiment analysis prediction model to obtain the sentiment analysis model includes: initializing the weight between the first keyword corresponding to the participle and the second keyword corresponding to the element to 0, and initializing the weight between other participles in the participle that are different from the first keyword corresponding to the participle and the second keyword corresponding to the element to negative infinity; according to the initialization weights corresponding to the participles and the elements in the information group, the sentiment analysis prediction model is trained based on the attention mechanism to obtain the sentiment analysis model.

[0008] In one embodiment, the method also includes: storing the emotional consultation information and the emotional analysis results; in response to receiving a confirmation instruction input by the user, optimizing and training the emotional analysis model based on the emotional consultation information and the emotional analysis results; the confirmation instruction is used to indicate confirmation that the emotional analysis model is optimized and trained based on the emotional consultation information and the emotional analysis results.

[0009] In one embodiment, the method also includes: in response to receiving a first operation instruction input by a user on an electronic device, displaying a function interface corresponding to the first operation instruction; wherein the first operation instruction is used to trigger the display of emotion abnormality related information, and the emotion abnormality related information is displayed in the function interface corresponding to the first operation instruction; the emotion abnormality related information includes at least one of the following: popular science information on emotion abnormalities; planning information for users to deal with emotion abnormalities.

[0010] According to a second aspect of an embodiment of the present disclosure, a sentiment analysis device is provided, comprising: a receiving module, used to obtain identity information and sentiment consultation information input by a user on an electronic device, wherein the sentiment consultation information is used to request sentiment analysis; a processing module, used to obtain a sentiment analysis result matching the identity information and the sentiment consultation information, wherein the sentiment analysis result is obtained through a sentiment analysis model, and the sentiment analysis model is pre-trained based on text information and a knowledge graph, and the knowledge graph includes different sentiment abnormality cause information corresponding to different identity information.

[0011] In one embodiment, the sentiment analysis model is obtained by pre-training based on text information and a knowledge graph through the processing module in the following manner: determining a text training set and a knowledge graph, a plurality of information groups in the knowledge graph, each of the plurality of information groups including identity information and a plurality of elements of causes of emotional abnormality corresponding to the identity information, each of the plurality of elements corresponding to a keyword; segmenting the text in the text training set to obtain N segmented words, where N is a positive integer; using the N segmented words as first keywords respectively, determining a second keyword identical to the first keyword in the information group, and concatenating the text information and the information group according to the first keyword and the second keyword to obtain a first text; training a sentiment analysis prediction model based on the first text to obtain a sentiment analysis model.

[0012] In one embodiment, the processing module trains a sentiment analysis prediction model based on the first text to obtain a sentiment analysis model in the following manner: adding mask text and template text to the text included in the first text to obtain a second text; and training a sentiment analysis prediction model based on the second text to obtain a sentiment analysis model.

[0013] In one embodiment, the processing module trains the sentiment analysis prediction model in the following manner to obtain the sentiment analysis model: initialize the weight between the first keyword corresponding to the word segment and the second keyword corresponding to the element to 0, and initialize the weight between other word segments in the word segment that are different from the first keyword corresponding to the word segment and the second keyword corresponding element to negative infinity; train the sentiment analysis prediction model based on the attention mechanism according to the initialization weights corresponding to the word segment and the elements in the information group to obtain the sentiment analysis model.

[0014] In one embodiment, the processing module is also used to: store the emotional consultation information and the emotional analysis results; in response to receiving a confirmation instruction input by the user, optimize the training of the emotional analysis model based on the emotional consultation information and the emotional analysis results; the confirmation instruction is used to indicate confirmation to optimize the training of the emotional analysis model based on the emotional consultation information and the emotional analysis results.

[0015] In one embodiment, the device also includes: a display module, used to display a functional interface corresponding to a first operating instruction in response to receiving a first operating instruction input by a user on an electronic device; wherein the first operating instruction is used to trigger the display of emotion abnormality related information, and the emotion abnormality related information is displayed in the functional interface corresponding to the first operating instruction; the emotion abnormality related information includes at least one of the following: popular science information on emotion abnormalities; planning information for users to deal with emotion abnormalities.

[0016] According to a third aspect of an embodiment of the present disclosure, a sentiment analysis device is provided, comprising: a processor; a memory for storing processor executable instructions; wherein the processor is configured to: execute the method described in the first aspect or any one of the embodiments of the first aspect.

[0017] According to a fourth aspect of an embodiment of the present disclosure, a storage medium is provided, in which instructions are stored. When the instructions in the storage medium are executed by a processor of a terminal, the terminal is enabled to execute the method described in the first aspect or any one of the implementations of the first aspect.

[0018] The technical solution provided by the embodiments of the present disclosure may include the following beneficial effects: sentiment analysis is performed based on identity information and input sentiment consultation information, thereby improving the accuracy of sentiment analysis.

[0019] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.

[0021] Figure 1 It is a schematic diagram of a Transformer architecture according to an exemplary embodiment.

[0022] Figure 2 The figure is a flow chart of a sentiment analysis method according to an exemplary embodiment.

[0023] Figure 3 The figure is a flowchart of training a sentiment analysis model according to an exemplary embodiment.

[0024] Figure 4 The figure is a flowchart of training a sentiment analysis model according to an exemplary embodiment.

[0025] Figure 5 The figure is a flowchart of training a sentiment analysis model according to an exemplary embodiment.

[0026] Figure 6 The present invention is a flowchart showing a method of training a sentiment analysis model according to sentiment analysis related information according to an exemplary embodiment.

[0027] Figure 7 The figure is a schematic diagram of a main interface of an application program according to an exemplary embodiment.

[0028] Figure 8This is a schematic diagram of a consultation interface according to an exemplary embodiment.

[0029] Fig. 9 It is a schematic diagram of a science popularization interface according to an exemplary embodiment.

[0030] Fig.10 The diagram is a schematic diagram of a target planning interface according to an exemplary embodiment.

[0031] Fig.11 It is a schematic diagram of a function interface under development according to an exemplary embodiment.

[0032] Fig.12 It is a schematic diagram of a system for analyzing causes of abnormal emotions according to an exemplary embodiment.

[0033] Fig.13 It is a schematic diagram of a network architecture design of a sentiment analysis module according to an exemplary embodiment.

[0034] Fig.14 It is a schematic diagram showing a knowledge graph based on keyword splicing and word segmentation results according to an exemplary embodiment.

[0035] Fig.15 The figure is a block diagram of a sentiment analysis device according to an exemplary embodiment.

[0036] Fig.16 The present invention is a block diagram of a device for sentiment analysis according to an exemplary embodiment. DETAILED DESCRIPTION

[0037] Here, exemplary embodiments will be described in detail, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present disclosure.

[0038] The current development of the field of Natural Language Processing (NLP) can be divided into three stages according to the quality of text word vectors. The first stage is the word vector with fixed representation of words. In this stage, the same word will be represented by the same vector in different contexts. The representation process is as follows: after receiving a large amount of text input, the neural network generates a fixed word vector for each word. When there is a need for text analysis, the text is queried by vectors to obtain a fixed word vector, and then the text analysis is performed. Representative technologies include CBOW (continuous bag of words, internal bag of words model), Skip-Gram (an unsupervised learning technology) and GloVe (Global Vectors). The second stage is the discriminative word vector of the large model. In this stage, different words have different vector representations. The word vector of this stage has a good effect on discriminative tasks such as sentiment classification. The large model of this stage is mainly designed based on the Transformer architecture. The representative models and technologies include BERT (Bidirectional Encoder Representations from Transformers, a language representation model) and Elmo (Embedding from Language Model). The third stage is the popular application of large generative models. The word vectors in this stage have outstanding performance in generative tasks and can answer many human questions. The representative technologies are GPT-3 (an artificial intelligence algorithm) and chatGPT (Chat Generative Pre-trained Transformer) developed based on GPT3.

[0039] When automatically generating user questions and answers based on the chatGPT architecture, it can be divided into three parts: core architecture principles, model training, and business logic. The underlying model of chatGPT uses the Transformer architecture, the core of which is the self-attention mechanism. This mechanism can analyze the relationship between each position in the input sequence, so as to better understand the context when generating text. The autoregressive generation method of GPT-3 is its key feature. It generates text words one by one in order and uses the previously generated content to predict the next word.

[0040] Figure 1: is a schematic diagram of a Transformer architecture according to an exemplary embodiment. Among them, the entire architecture is divided into two parts, the left part is the encoder Encoder part, and the right part is the decoder Decoder part. In the Encoder part, the Inputs are first received as text data, and then the module first performs word segmentation on the text sentences, and after converting the text sentences into a combination of words, for the words in each sentence, the encoding of the word will be obtained from the pre-defined token dictionary. At this time, the encoding is added to the Position Encoding (position sequence encoding) to generate a formal input encoding. Multi-Head Attention (multi-head attention mechanism) is used in the input for semantic calculation, and the calculated results are input to the Add&Norm layer to ensure that the semantics do not shift, and finally the Feed Forward layer and the Add&Norm layer are respectively trained. Finally, the Encoder outputs the trained vector. In the Decoder part, similar to the Encoder, the output of the Encoder training is received, and the input is accumulated in combination with the Position Embedding, and finally the vector is output through a similar architecture, the vector is linearized (linear calculation) and the final prediction result is output through the softmax layer.

[0041] The chatGPT model uses the Decoder part of the Transformer and is trained on large-scale unsupervised text data to learn language patterns, structures, and knowledge. This enables GPT-3 to perform well on a wide range of natural language processing tasks. The output of the model is then adjusted based on the input provided by the user to generate user responses. The overall logic of chatGPT is to receive user input, generate responses, and generate a dialogue flow based on user needs and return it to the user. When receiving input, the model will rely on classification technology to identify responses in the input that are not in compliance with legal regulations and violate ethics.

[0042] chatGPT has a vast amount of knowledge, which includes highly abstract human knowledge and can answer most questions in open fields. However, the analysis of the causes of abnormal emotions requires more high-quality professional knowledge, which can help the model make more scientific decisions. The chatGPT model lacks this professional knowledge in the pre-training stage, resulting in deviations in the prediction results when analyzing emotions. And due to the lack of recognition of the user's identity, chatGPT can only abstractly tell users the general response strategies for abnormal emotions when answering questions about abnormal emotions. Although such a strategy may answer the user's questions, the user experience is relatively poor.

[0043] In view of this, the present disclosure provides a sentiment analysis method. According to the identity information and text information input by the user, the text information is analyzed by a trained sentiment analysis model to obtain the sentiment analysis result corresponding to the input identity information and the input text. By limiting the identity information, the scope of the sentiment analysis result is narrowed, making the sentiment analysis result more accurate.

[0044] The following will explain how to perform sentiment analysis specifically.

[0045] Figure 2 is a flowchart of a sentiment analysis method according to an exemplary embodiment. Figure 2 As shown, the following steps are included.

[0046] In step S11, identity information and emotional consultation information input by the user on the electronic device are obtained, and the emotional consultation information is used to request emotional analysis.

[0047] In the disclosed embodiment, the input identity information is obtained to determine the identity status of the user, narrow the scope of sentiment analysis, and thus improve accuracy. The sentiment consultation information content is the content of the request for sentiment analysis, which prevents the sentiment analysis from being unable to proceed normally due to the input of irrelevant content, resulting in errors in the sentiment analysis results.

[0048] In step S12, the sentiment analysis results of the matching identity information and the emotional consultation information are obtained, wherein the sentiment analysis results are obtained through a sentiment analysis model, and the sentiment analysis model is pre-trained based on text information and a knowledge graph, and the knowledge graph includes different emotional abnormality cause information corresponding to different identity information.

[0049] In the disclosed embodiment, the sentiment analysis model is a pre-trained model, and is trained based on text information related to sentiment analysis and a knowledge graph. The knowledge graph includes multiple data groups, and each data group includes multiple elements. The element is information related to sentiment including identity information. Each element of the knowledge graph corresponds to one or more keywords. The text information is the text information in the text information set used for training.

[0050] In one implementation, identity information and emotional consultation information input by a user are obtained, and the obtained identity information and emotional consultation information are input into a trained emotional analysis model. The emotional consultation information is analyzed by the trained emotional analysis model to obtain the emotional analysis results corresponding to the input identity information and the input emotional consultation information. By limiting the identity information, the scope of the emotional analysis result judgment is narrowed, making the emotional analysis result more accurate. The emotional analysis model is trained based on training text information and knowledge graphs related to emotional analysis, and the emotional analysis results corresponding to the identity information are more accurate.

[0051] In one implementation, the emotion consultation information involved in the embodiments of the present disclosure may be text type information. A user may directly input text type information representing the emotion consultation content in an application providing emotion consultation in an electronic device.

[0052] In another implementation of the disclosed embodiment, the emotional consultation information may also be non-text type information. The non-text type information may be, for example, images, audio or other types of information. When the emotional consultation information is non-text type information, the non-text form of the emotional consultation information may be converted into corresponding text type information for emotional consultation. For example, when the non-text type information is audio information, the user may directly input a voice representing the emotional consultation content in an application that provides emotional consultation in an electronic device. When determining the result of the emotional analysis, the voice is converted into the corresponding text type information, and the emotional analysis result is determined based on the converted text type information.

[0053] In one implementation, after conducting surveys and collecting data on psychologists, patients with psychological abnormalities, and people with different identity information, a preliminary depression knowledge graph can be constructed that includes different identity information and information related to emotional abnormalities corresponding to the different identity information.

[0054] To perform sentiment analysis, you need to obtain a trained sentiment analysis model. The following describes how to train a sentiment analysis model.

[0055] Figure 3 The figure is a flowchart of training a sentiment analysis model according to an exemplary embodiment.

[0056] In step S21, a text training set and a knowledge graph are determined, wherein the knowledge graph includes multiple information groups, each of the multiple information groups includes identity information and multiple elements of emotional abnormality causes corresponding to the identity information, and each of the multiple elements corresponds to a keyword.

[0057] In the disclosed embodiment, the text training set and the knowledge graph are pre-determined data sets for training the model. Among them, the keywords corresponding to each element in the multiple information groups in the knowledge graph are pre-determined keywords for splicing with the text information of the text training set terminal.

[0058] In step S22, the text in the text training set is segmented to obtain N segmented words, where N is a positive integer.

[0059] In the disclosed embodiment, the segmentation results are used to compare with the keywords in the knowledge graph for splicing.

[0060] In step S23, the N segmented words are respectively used as first keywords, a second keyword identical to the first keyword is determined in the information group, and the text information and the information group are concatenated according to the first keyword and the second keyword to obtain a first text.

[0061] In the disclosed embodiment, each segmentation result after segmentation is compared with the keyword corresponding to each element in the information group of the knowledge graph. When the segmentation and the keyword are the same, the segmentation is spliced ​​with the element of the corresponding keyword. And all segmentations that can be spliced ​​are spliced ​​with the elements of the corresponding keywords. Among them, the text information is the text information in the text training set used for training.

[0062] In step S24, a sentiment analysis prediction model is trained based on the first text to obtain a sentiment analysis model.

[0063] In the embodiment of the present disclosure, the first text is a concatenated text, including text information after word segmentation and concatenated content of the knowledge graph corresponding to the word segmentation, wherein the text information is text information in a text training set used for training.

[0064] In one implementation, the input text information for training is segmented, and the segmented words are compared with the keywords corresponding to the elements in the information group of the knowledge graph. If the segmented words are the same as the keywords, the segmented words are spliced ​​with the elements of the corresponding keywords. Repeat this splicing process for other segmented words in the text information segmentation results, so that all segmented words that can be spliced ​​are spliced ​​with the elements of the corresponding keywords to obtain the text information after the knowledge graph is spliced. The text information after the knowledge graph is spliced ​​is input into the sentiment analysis prediction model for training, and finally a trained sentiment analysis model is obtained.

[0065] Figure 4 The figure is a flowchart of training a sentiment analysis model according to an exemplary embodiment.

[0066] In step S31, mask text and template text are added to the text included in the first text to obtain a second text.

[0067] In the disclosed embodiment, the second text includes the input text after word segmentation and concatenation with the knowledge graph, the mask text after word segmentation, and the template text after word segmentation. Among them, the template text is a predetermined fixed text information, and the masked part of the mask text is the reason for the abnormal emotion.

[0068] In step S32, a sentiment analysis prediction model is trained based on the second text to obtain a sentiment analysis model.

[0069] In the disclosed embodiment, the second text is input into the sentiment analysis prediction model for training until the training is completed to obtain the sentiment analysis model.

[0070] In one embodiment, after the text information for training after word segmentation is spliced ​​with the knowledge graph information group, the template text and mask text after word segmentation are added to the spliced ​​text information to obtain the training text information. The training text information is input into the sentiment analysis prediction model for training until the training is completed to obtain the sentiment analysis model. By adding the template text and mask text, the model can be guided to analyze the causes of sentiment abnormalities and reduce the amount of data used.

[0071] Figure 5 The figure is a flowchart of training a sentiment analysis model according to an exemplary embodiment.

[0072] In step S41, the weight between the first keyword corresponding to the participle and the second keyword corresponding to the element is initialized to 0, and the weight between other participles in the participles other than the first keyword corresponding to the participle and the second keyword corresponding element is initialized to negative infinity.

[0073] In the disclosed embodiment, the default weight is initialized to 0. Once the weight is initialized to negative infinity, it means that the content corresponding to the second keyword is invisible to the first keyword when training the model. Therefore, when performing the attention mechanism calculation, the information group content corresponding to the second keyword is not used as the basis for the calculation of the first keyword that is not connected to it.

[0074] In step S42, according to the initialization weights corresponding to the word segmentation and the elements in the information group, the sentiment analysis prediction model is trained based on the attention mechanism to obtain the sentiment analysis model.

[0075] In the disclosed embodiment, the concatenated text information with weight information is input into a sentiment analysis prediction model, and the sentiment analysis prediction model is trained according to the attention mechanism to obtain a sentiment analysis model.

[0076] In one implementation, the initial weights between the segmentation words and the conjunctions in the spliced ​​training text information are determined, the weights of the knowledge graph information groups corresponding to the segmentation words and the corresponding keywords are set to 0, and the weights of the knowledge graph information groups corresponding to the other segmentation words and the corresponding keywords of the segmentation words are initialized to negative infinity. The spliced ​​text information after the weights are initialized is input into the sentiment analysis prediction model, and the sentiment analysis prediction model is trained according to the attention mechanism to finally obtain the sentiment analysis model. By setting the initial weights of 0 and negative infinity respectively, the segmentation words are prevented from incorrectly referencing the knowledge graph information groups corresponding to the keywords corresponding to other segmentation words, thereby improving the accuracy of the sentiment analysis of the training completed model.

[0077] Figure 6 The present invention is a flowchart showing a method of training a sentiment analysis model according to sentiment analysis related information according to an exemplary embodiment.

[0078] In step S51, the emotion consultation information and the emotion analysis result are stored.

[0079] In the disclosed embodiment, the stored emotion consultation information is the historical emotion consultation information input by the user for emotion analysis, and the emotion analysis result is the historical emotion analysis result determined based on the historical emotion consultation information.

[0080] In step S52, in response to receiving a confirmation instruction input by the user, the sentiment analysis model is optimized and trained based on the sentiment consultation information and the sentiment analysis results, and the confirmation instruction is used to indicate confirmation that the sentiment analysis model is optimized and trained based on the sentiment consultation information and the sentiment analysis results.

[0081] In the disclosed embodiment, only when the user agrees to upload historical emotional consultation information, the historical emotional consultation information and the corresponding emotional analysis results will be used as training data to optimize the model.

[0082] In one implementation, after the user performs sentiment analysis, the historical input sentiment consultation information and the sentiment analysis results obtained based on the historical input sentiment consultation information are stored, and after the user agrees, they are input into the sentiment analysis model for optimization training. The sentiment analysis model is optimized using the relevant data of sentiment analysis performed by real users, the sentiment analysis capability of the sentiment analysis model is improved in real time, and the user's consent is obtained to protect the user's privacy.

[0083] In one implementation, the emotional consultation information may be directly stored without conversion.

[0084] In one embodiment, when the emotional consultation information is non-text type information, the emotional consultation information can be converted into text type information, and the converted text type information is stored. Non-text type information can be, for example, images, audio or other types of information. For example, when the non-text information is audio information, the emotional consultation information is a voice representing the emotional consultation content that the user can directly input in an application that provides emotional consultation in an electronic device. The voice representing the emotional consultation content is converted into corresponding text type information, and the converted text type information is stored.

[0085] In one implementation, the stored emotional consultation information involved in the embodiments of the present disclosure may be text type information. With the user's consent, the text type information representing the emotional consultation content stored in the application providing emotional consultation in the electronic device and the stored historical emotional analysis results may be directly used as training data to train and optimize the emotional analysis model.

[0086] In another implementation of the disclosed embodiment, the stored emotional consultation information may also be non-text type information. Among them, the non-text type information may be, for example, images, audio or other types of information. When the stored emotional consultation information is non-text type information, with the consent of the user, the stored non-text type historical emotional consultation information may be converted into corresponding text type information, and the converted text type information and the emotional analysis results may be used as training data to train the emotional analysis model. For example, when the non-text type information is audio information, the stored emotional consultation information is a voice representing the emotional consultation content that the user can directly input in an application that provides emotional consultation in an electronic device. The stored voice representing the emotional consultation content is converted into corresponding text type information. With the consent of the user, the converted text type information and the emotional analysis results may be used as training data to train and optimize the emotional analysis model.

[0087] In one implementation of the embodiments of the present disclosure, in response to receiving a first operation instruction input by a user on an electronic device, a function interface corresponding to the first operation instruction is displayed.

[0088] In the disclosed embodiment, the first operation instruction is used to trigger the display of abnormal emotion-related information, and the abnormal emotion-related information is displayed in the function interface corresponding to the first operation instruction.

[0089] In the disclosed embodiment, the emotion abnormality related information includes one of the popular science information of emotion abnormality and the planning information of the user to deal with the emotion abnormality.

[0090] In one implementation, a sentiment analysis application may be used to provide users with sentiment analysis consultation dialogue functions, goal planning functions, science popularization functions, and the like.

[0091] Figure 7 FIG. 1 is a schematic diagram of an application main interface according to an exemplary embodiment. Figure 7 As shown, the main interface of the application includes at least identity information, analysis, discovery, planning, my (user management) and other options.

[0092] In one implementation, the main interface of the application may include pages such as the application name and application cover, and may also include identity information options, such as education, occupation, etc. The main interface of the application may include options such as planning, feedback suggestions, social networking, and service customization. The main interface of the application may include options such as analysis, discovery, and user management for switching to corresponding sub-interfaces. In the main interface, users can select their own identity and initiate consultations, view popular science and conduct related goal planning, and perform other operations.

[0093] Figure 8 This is a schematic diagram of a consultation interface according to an exemplary embodiment.

[0094] In one implementation, when the user inputs text and sends it, the application will feedback the analysis result to the user in text form. The analysis result can also be fed back to the user in other forms, such as images, audio, etc.

[0095] Fig. 9 It is a schematic diagram of a science popularization interface according to an exemplary embodiment.

[0096] In one implementation, the application will provide users with sentiment analysis and popular science via pictures, text or other means on the popular science interface, so that users are no longer afraid of psychological problems. Users can also switch popular science content or switch to other interfaces on the popular science interface.

[0097] Fig.10 The diagram is a schematic diagram of a target planning interface according to an exemplary embodiment.

[0098] In one embodiment, a visual target process is provided to the user to encourage the user to overcome psychological difficulties. By setting and completing goals, the sense of achievement of the emotion analysis patient is enhanced, thereby reducing emotional abnormalities.

[0099] Fig.11 It is a schematic diagram of a function interface under development according to an exemplary embodiment.

[0100] In one implementation, a functional interface under development is reserved for subsequent expansion of the sentiment analysis application to facilitate improving the functionality of the sentiment analysis application.

[0101] Fig.12 It is a schematic diagram of a system for analyzing causes of abnormal emotions according to an exemplary embodiment.

[0102] In one implementation, the terminal application provides users with different consultation portals, which include identity information, such as education information, occupation information, etc. When a user initiates a consultation request, the identity information is carried together to the conversation support server. The server first analyzes the cause of abnormal emotions based on the user's conversation content, and selects a suitable template text for the user based on the inducement. At the same time, the server combines the template text, user identity and user consultation content to initiate a consultation to the GPT-3.5-turbo model, and finally displays the consultation result return value to the terminal application to the user.

[0103] In one implementation, the terminal application provides users with a conversation storage function, thereby helping the system to make more scientific judgments on the cause of the conversation based on the context of the conversation. If the user agrees to participate in the user experience improvement plan, the conversation content will be cleaned and integrated to remove sensitive content before being handed over to the learning reinforcement module designed by the system. The abnormal sentiment cause analysis model is trained through the learning reinforcement module, and the performance of the sentiment analysis model is improved by extracting and desensitizing the data.

[0104] In one implementation, the model training can be divided into two stages: pre-training and fine-tuning. Pre-training will be conducted on a large amount of open text, and the training strategies include Mask Language Model (MLM) strategy and Next Sentence Prediction (NSP) strategy. For MLM, some words in the input sequence will be randomly masked (replaced with [MASK] tags), and the model needs to predict these masked words. For NSP, the model receives two sentences and predicts whether the second sentence is the successor of the first sentence. The entire training process is based on Figure 1 The Transformer architecture is used for pre-training. Pre-training has high requirements for computing resources, so we can use Google's open source pre-trained language model BERT for training, or we can use other language models that meet the requirements. After pre-training, BERT can be used for specific natural language processing tasks, such as sentiment analysis mentioned in this solution. The stage after pre-training is called the fine-tuning stage, which only requires a small amount of text in a professional field to help the model learn professional domain knowledge. In this solution, improvements are made based on the BERT model so that the BERT model can be integrated into the pre-built sentiment knowledge graph. During fine-tuning, the training batch size is 32, the training rounds are 5, and the samples are divided into training samples, verification samples, and test samples in a ratio of 7:1:2. The other model architecture related parameters are shown in Table 1. Among them, the training batch, training round, training samples, verification samples, test samples, and the various parameter values ​​in Table 1 are the empirical values ​​for optimal performance.

[0105] Table 1

[0106]

[0107] In one implementation, the use of the above model can be divided into two steps. The first is parameter conversion. This solution is based on the UER (Universal Encoder Representations) framework for model training. In order to use the model, the parameters are first converted into parameters supported by hugging face (a program library). Then, a flask (a web microframework) website response platform is built, the training parameters are loaded on the platform, and model prediction is performed.

[0108] The core module of the sentiment analysis system is the inducement analysis module, which provides users with professional inducement analysis and fully integrates the knowledge graph to enhance the professionalism of the analysis. Fig.13 FIG. 1 is a schematic diagram of a network architecture design of a sentiment analysis module according to an exemplary embodiment. Fig.13 As shown, the input of the model includes model input 1 (user's text input) and model input 2 (constructed knowledge graph).

[0109] In one embodiment, if Fig.13 As shown in Figure 1, input construction is based on user input and the constructed knowledge graph. The user's input text is the model input 1 in the figure. For the user input, firstly, word segmentation is performed to divide the sentence into a set of words (such as Fig.13 W1, W2, ..., Wn), for these n words, they will be used as query keywords to query the knowledge graph, and the knowledge corresponding to the keywords will be spliced. After splicing, the input form is transformed from a basic linear structure to a preliminary tree structure. The core of supporting the splicing of the entire input is to build a good quality knowledge graph.

[0110] In one embodiment, if Fig.13 As shown, the knowledge graph is stored in the form of five tuples, and the five tuples are (identity K0, subject of psychological abnormality K1, event leading to emotional abnormality K2, cause of emotional abnormality K3, and emotional abnormality K4). Among them, the keyword Key used for query can be extracted from K1 to provide a query interface for model input 1. The knowledge graph data can be a data group with other number of elements other than the five-tuple data. Where to extract the query keyword is determined by the actual task requirements.

[0111] In one implementation, template text can be combined with a MASK strategy (a method of masking part of the text) to solve the output result deviation caused by not using the MASK and NSP strategies in fine-tuning, and the template text can also be used to make the model more focused on the speculation of depression causes. Through MASK, the model can be guided to predict the value of MASK during fine-tuning, allowing the model to explore the causes more deeply, and also solve the problem of mismatch between pre-training and fine-tuning training strategies.

[0112] In one implementation, a tree-shaped attention mechanism is used to process text information for training. Fig.13 As shown in the figure, the trunk of the tree is [CLS], W1, W2, …, Wn, [SEP]. [CLS] and [SEP] are filler tags, representing the start and end of the sentence. The W2 word of the trunk can be queried for the corresponding keyword Key in the knowledge base, so the knowledge item corresponding to the keyword Key will be spliced ​​to W2. Based on the same principle, other words of the trunk can be queried for the corresponding keyword Key in the knowledge base according to task requirements, and the knowledge item corresponding to the keyword Key will be spliced ​​to the corresponding trunk word.

[0113] Fig.14 It is a schematic diagram showing a knowledge graph based on keyword splicing and word segmentation results according to an exemplary embodiment.

[0114] In one embodiment, if Fig.14 As shown in the figure, the number next to each word is identified as the position code of the word. When initializing the attention weight, the attention weight will be allocated according to the position code and the branch where the word is located. P1, P2, ..., [MASK] are template text positions, which are located at the end branch of the tree.

[0115] In one embodiment, if Fig.14 As shown in the figure, the initial attention weight of each word in the trunk is 0. When the branch words are connected to the trunk words according to the keywords, the weight between the branch words and the connecting words is initialized to 0, and the weight between the branch words and other non-connecting words in the trunk is initialized to negative infinity. Among them, once the attention weight is initialized to negative infinity, it means that the word is invisible to the corresponding word during training, so that the word will not be affected by the corresponding word, ensuring that the semantics of the sentence is not misinterpreted. Fig.14 As shown, the initial attention weight of each word in the trunk (W1, W2, ..., W5) is 0. When the branch words (K0, K1, ..., K4) are spliced ​​with the trunk word W2 according to the keyword Key extracted from K2, the weight between the branch words and the connected trunk word W2 is initialized to 0, and the weights of the branch words and other non-connected trunk words (W1, W3, W4, W5) are initialized to negative infinity. Among them, W1, W2, W3, W4, W5 are the segmentation results after the input sentence is segmented. They are only examples, and can also be other numbers or types of segmentation results. K0, K1, K2, K3, K4 correspond to a group of data, indicating that this group of data includes 5 elements of data. It is also possible to use data of other numbers of elements to splice the knowledge graph and the segmentation results according to the knowledge graph.

[0116] In one implementation, a psychological analysis model is used to determine a text vector based on the concatenated tree-shaped input data. The [CLS] label itself does not have any semantics before concatenation, but when the label is trained or analyzed by the model, it will contain the semantic information of the entire sentence due to the attention calculation based on the attention mechanism. Fig.14 As shown in the figure, when performing the cause analysis, although the [CLS] tag cannot directly perform attention calculation on the fused knowledge, the [CLS] tag realizes the attention calculation on W2, and W2 integrates the knowledge corresponding to the information group in the knowledge graph, so the [CLS] tag finally grasps the corresponding knowledge and outputs it in the form of a vector. When the model is trained or analyzed, the CLS vector is processed through the fully connected layer and the Softmax function to infer the cause of depression. The model will eventually output the type of inducement to realize the analysis of psychological inducements.

[0117] In one embodiment, two types of data sets are predetermined for model training, including a fine-tuned psychological state description data set, and a psychological state inducement knowledge graph data set. Among them, the fine-tuned psychological state description data set contains a series of psychological state descriptions and corresponding inducements, which are used as input data to train the model. The psychological state inducement knowledge graph data set is used as a knowledge graph of input data to connect with the fine-tuned psychological state description data set to train the model. The two types of data can be collected through the Internet, questionnaires, asking professionals or other methods, and the labels of the two types of data are corrected, and the psychological state inducement is used as the text label of the first type of data to ensure that the trained model focuses on the psychological state inducement when analyzing the text, thereby improving the accuracy of outputting the causes of abnormal emotions.

[0118] In one implementation, after the inducement analysis, combined with the user's identity information and template text, GPT-3.5-turbo (an artificial intelligence chat model) is consulted to determine the final text, and the final text is fed back to the user through the application. After obtaining the inducement analysis results, other intelligent chat models can also be consulted to determine the final sentiment analysis results.

[0119] Based on the same concept, the embodiment of the present disclosure also provides a sentiment analysis device.

[0120] It is understandable that the sentiment analysis device provided by the embodiment of the present disclosure includes hardware structures and / or software modules corresponding to the execution of each function in order to realize the above functions. In combination with the units and algorithm steps of each example disclosed in the embodiment of the present disclosure, the embodiment of the present disclosure can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in the form of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art may use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the technical solution of the embodiment of the present disclosure.

[0121] Fig.15 is a block diagram of a sentiment analysis device according to an exemplary embodiment. Fig.15 The device includes a receiving module 101, a processing module 102 and a display module 103.

[0122] The receiving module 101 is configured to obtain identity information and emotional consultation information input by a user on an electronic device, where the emotional consultation information is used to request emotional analysis.

[0123] The processing module 102 is configured to obtain sentiment analysis results that match identity information and sentiment consultation information, wherein the sentiment analysis results are obtained through a sentiment analysis model, and the sentiment analysis model is pre-trained based on text information and a knowledge graph, and the knowledge graph includes different sentiment abnormality cause information corresponding to different identity information.

[0124] In one implementation of the disclosed embodiments, the sentiment analysis model is obtained by pre-training based on text information and a knowledge graph through a processing module in the following manner: determining a text training set and a knowledge graph, multiple information groups in the knowledge graph, each of the multiple information groups including identity information and multiple elements of causes of emotional abnormality corresponding to the identity information, each of the multiple elements corresponding to a keyword; segmenting the text in the text training set to obtain N segmented words, where N is a positive integer; using the N segmented words as the first keyword, determining a second keyword that is the same as the first keyword in the information group, and concatenating the text information and the information group according to the first keyword and the second keyword to obtain a first text; training a sentiment analysis prediction model based on the first text to obtain a sentiment analysis model.

[0125] In one implementation of the disclosed embodiments, the processing module 102 trains a sentiment analysis prediction model based on the first text to obtain a sentiment analysis model in the following manner: adding mask text and template text to the text included in the first text to obtain a second text; and training a sentiment analysis prediction model based on the second text to obtain a sentiment analysis model.

[0126] In one implementation of the disclosed embodiments, the processing module 102 trains a sentiment analysis prediction model in the following manner to obtain a sentiment analysis model: the weight between the participle corresponding to the first keyword and the element corresponding to the second keyword is initialized to 0, and the weight between other participles in the participle that are different from the participle corresponding to the first keyword and the element corresponding to the second keyword is initialized to negative infinity; according to the initialization weights corresponding to each participle and the elements in the information group, the sentiment analysis prediction model is trained based on the attention mechanism to obtain a sentiment analysis model.

[0127] In one implementation of the disclosed embodiments, the processing module 102 is configured to: store emotional consultation information and emotional analysis results; in response to receiving a confirmation instruction input by the user, optimize and train the emotional analysis model based on the emotional consultation information and the emotional analysis results; the confirmation instruction is used to indicate confirmation to optimize and train the emotional analysis model based on the emotional consultation information and the emotional analysis results.

[0128] The display module 103 is configured to display a functional interface corresponding to a first operating instruction in response to receiving a first operating instruction input by a user on an electronic device; wherein the first operating instruction is used to trigger the display of emotion abnormality related information, and the emotion abnormality related information is displayed in the functional interface corresponding to the first operating instruction; the emotion abnormality related information includes at least one of the following: popular science information on emotion abnormalities; and planning information for users to handle emotion abnormalities.

[0129] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.

[0130] Fig.16 2 is a block diagram of a device 200 for sentiment analysis according to an exemplary embodiment. For example, the device 200 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.

[0131] Reference Fig.16 , the device 200 may include one or more of the following components: a processing component 202 , a memory 204 , a power component 206 , a multimedia component 208 , an audio component 210 , an input / output (I / O) interface 212 , a sensor component 214 , and a communication component 216 .

[0132] The processing component 202 generally controls the overall operation of the device 200, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 202 may include one or more processors 220 to execute instructions to perform all or part of the steps of the above-described method. In addition, the processing component 202 may include one or more modules to facilitate interaction between the processing component 202 and other components. For example, the processing component 202 may include a multimedia module to facilitate interaction between the multimedia component 208 and the processing component 202.

[0133] The memory 204 is configured to store various types of data to support operations on the device 200. Examples of such data include instructions for any application or method operating on the device 200, contact data, phone book data, messages, pictures, videos, etc. The memory 204 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.

[0134] The power component 206 provides power to the various components of the device 200. The power component 206 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the device 200.

[0135] The multimedia component 208 includes a screen that provides an output interface between the device 200 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 208 includes a front camera and / or a rear camera. When the device 200 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.

[0136] The audio component 210 is configured to output and / or input audio signals. For example, the audio component 210 includes a microphone (MIC), and when the device 200 is in an operation mode, such as a call mode, a recording mode, and a speech recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 204 or sent via the communication component 216. In some embodiments, the audio component 210 also includes a speaker for outputting audio signals.

[0137] I / O interface 212 provides an interface between processing component 202 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: a home button, a volume button, a start button, and a lock button.

[0138] The sensor assembly 214 includes one or more sensors for providing various aspects of the status assessment of the device 200. For example, the sensor assembly 214 can detect the open / closed state of the device 200, the relative positioning of components, such as the display and keypad of the device 200, the sensor assembly 214 can also detect the position change of the device 200 or a component of the device 200, the presence or absence of user contact with the device 200, the orientation or acceleration / deceleration of the device 200 and the temperature change of the device 200. The sensor assembly 214 may include a proximity sensor configured to detect the presence of a nearby object without any physical contact. The sensor assembly 214 may also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 214 may also include an accelerometer, a gyroscope sensor, a magnetic sensor, a pressure sensor or a temperature sensor.

[0139] The communication component 216 is configured to facilitate wired or wireless communication between the device 200 and other devices. The device 200 can access a wireless network based on a communication standard, such as WiFi, 2G or 3G, or a combination thereof. In an exemplary embodiment, the communication component 216 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 216 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.

[0140] In an exemplary embodiment, the apparatus 200 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors or other electronic components to perform the above method.

[0141] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 204 including instructions, and the instructions can be executed by the processor 220 of the device 200 to perform the above method. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.

[0142] It is to be understood that in the present disclosure, "plurality" refers to two or more than two, and other quantifiers are similar. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the associated objects before and after are in an "or" relationship. The singular forms "a", "the" and "the" are also intended to include plural forms, unless the context clearly indicates other meanings.

[0143] It is further understood that the terms "first", "second", etc. are used to describe various information, but such information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other, and do not indicate a specific order or degree of importance. In fact, the expressions "first", "second", etc. can be used interchangeably. For example, without departing from the scope of the present disclosure, the first information can also be referred to as the second information, and similarly, the second information can also be referred to as the first information.

[0144] It can be further understood that, unless otherwise specified, “connection” includes a direct connection without other components between the two, and also includes an indirect connection with other components between the two.

[0145] It is further understood that, although the operations are described in a specific order in the drawings in the embodiments of the present disclosure, it should not be understood as requiring the operations to be performed in the specific order shown or in a serial order, or requiring the execution of all the operations shown to obtain the desired results. In certain environments, multitasking and parallel processing may be advantageous.

[0146] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. This application is intended to cover any modifications, uses or adaptations of the present disclosure, which follow the general principles of the present disclosure and include common knowledge or customary technical means in the art that are not disclosed in the present disclosure.

[0147] It should be understood that the present disclosure is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the scope of the appended claims.

Claims

1. A sentiment analysis method, characterized in that: include: Acquiring identity information and emotional consultation information input by a user on an electronic device, wherein the emotional consultation information is used to request emotional analysis; Obtain a sentiment analysis result that matches the identity information and the emotional consultation information, wherein the sentiment analysis result is obtained through a sentiment analysis model, and the sentiment analysis model is pre-trained based on text information and a knowledge graph, and the knowledge graph includes different sentiment abnormality cause information corresponding to different identity information.

2. The method according to claim 1, characterized in that The sentiment analysis model is pre-trained based on text information and knowledge graph in the following way: Determine a text training set and a knowledge graph, wherein the knowledge graph includes a plurality of information groups, each of the plurality of information groups includes identity information and a plurality of elements of emotional abnormality reasons corresponding to the identity information, and each of the plurality of elements corresponds to a keyword; Segmenting the text in the text training set to obtain N segmented words, where N is a positive integer; The N segmented words are respectively used as first keywords, a second keyword identical to the first keyword is determined in the information group, and the text information and the information group are concatenated according to the first keyword and the second keyword to obtain a first text; Based on the first text, a sentiment analysis prediction model is trained to obtain a sentiment analysis model.

3. The method according to claim 2, characterized in that The step of training a sentiment analysis prediction model based on the first text to obtain a sentiment analysis model includes: Adding mask text and template text to the text included in the first text to obtain a second text; Based on the second text, a sentiment analysis prediction model is trained to obtain a sentiment analysis model.

4. The method according to claim 2 or 3, characterized in that: The training of the sentiment analysis prediction model to obtain the sentiment analysis model includes: Initialize the weight between the first keyword corresponding to the participle and the second keyword corresponding to the element to 0, and initialize the weight between the other participles in the participles other than the first keyword corresponding to the participle and the second keyword corresponding to the element to negative infinity; According to the initialization weights corresponding to the word segmentation and the elements in the information group, a sentiment analysis prediction model is trained based on the attention mechanism to obtain a sentiment analysis model.

5. The method according to claim 1, characterized in that The method further comprises: Storing the emotion consultation information and the emotion analysis result; In response to receiving a confirmation instruction input by a user, optimizing and training the sentiment analysis model based on the sentiment consultation information and the sentiment analysis result; The confirmation instruction is used to indicate confirmation to optimize the training of the sentiment analysis model based on the sentiment consultation information and the sentiment analysis result.

6. The method according to claim 1, characterized in that The method further comprises: In response to receiving a first operation instruction input by a user on the electronic device, displaying a function interface corresponding to the first operation instruction; Wherein, the first operation instruction is used to trigger the display of abnormal emotion related information, and the abnormal emotion related information is displayed in the function interface corresponding to the first operation instruction; The abnormal emotion-related information includes at least one of the following: Scientific information on emotional abnormalities; Users process planning information for emotional anomalies.

7. A sentiment analysis device, characterized in that: include: A receiving module, used to obtain identity information and emotional consultation information input by a user on an electronic device, wherein the emotional consultation information is used to request emotional analysis; A processing module is used to obtain a sentiment analysis result that matches the identity information and the emotional consultation information, wherein the sentiment analysis result is obtained through a sentiment analysis model, and the sentiment analysis model is pre-trained based on text information and a knowledge graph, and the knowledge graph includes different emotional abnormality cause information corresponding to different identity information.

8. The device according to claim 7, characterized in that The sentiment analysis model is obtained by pre-training based on text information and knowledge graph by the processing module in the following manner: Determine a text training set and a knowledge graph, wherein the knowledge graph includes a plurality of information groups, each of the plurality of information groups includes identity information and a plurality of elements of emotional abnormality reasons corresponding to the identity information, and each of the plurality of elements corresponds to a keyword; Segmenting the text in the text training set to obtain N segmented words, where N is a positive integer; The N segmented words are respectively used as first keywords, a second keyword identical to the first keyword is determined in the information group, and the text information and the information group are concatenated according to the first keyword and the second keyword to obtain a first text; Based on the first text, a sentiment analysis prediction model is trained to obtain a sentiment analysis model.

9. The device according to claim 8, characterized in that The processing module trains a sentiment analysis prediction model based on the first text to obtain a sentiment analysis model in the following manner: Adding mask text and template text to the text included in the first text to obtain a second text; Based on the second text, a sentiment analysis prediction model is trained to obtain a sentiment analysis model.

10. The device according to claim 8 or 9, characterized in that The processing module trains the sentiment analysis prediction model in the following manner to obtain the sentiment analysis model: Initialize the weight between the first keyword corresponding to the participle and the second keyword corresponding to the element to 0, and initialize the weight between the other participles in the participles other than the first keyword corresponding to the participle and the second keyword corresponding to the element to negative infinity; According to the initialization weights corresponding to the word segmentation and the elements in the information group, a sentiment analysis prediction model is trained based on the attention mechanism to obtain a sentiment analysis model.

11. The device according to claim 7, characterized in that The processing module is also used for: Storing the emotion consultation information and the emotion analysis result; In response to receiving a confirmation instruction input by a user, optimizing and training the sentiment analysis model based on the sentiment consultation information and the sentiment analysis result; The confirmation instruction is used to indicate confirmation to optimize the training of the sentiment analysis model based on the sentiment consultation information and the sentiment analysis result.

12. The device according to claim 7, characterized in that The device also includes: A display module, configured to display a function interface corresponding to a first operation instruction input by a user on the electronic device in response to receiving the first operation instruction; Wherein, the first operation instruction is used to trigger the display of abnormal emotion related information, and the abnormal emotion related information is displayed in the function interface corresponding to the first operation instruction; The abnormal emotion-related information includes at least one of the following: Scientific information on emotional abnormalities; Users process planning information for emotional anomalies.

13. A sentiment analysis device, characterized in that: include: processor; a memory for storing processor-executable instructions; Wherein, the processor is configured to: execute the method described in any one of claims 1 to 6.

14. A storage medium, characterized in that: The storage medium stores instructions, and when the instructions in the storage medium are executed by a processor of the terminal, the terminal is enabled to execute the method according to any one of claims 1 to 6.