A personality recognition method and device based on Chinese social network text features
By improving the BERT model and DeepMoji model and combining them with Chinese sentiment analysis, the problem of low accuracy in personality recognition in Chinese social networks was solved, and more efficient personality feature analysis of Chinese text datasets was achieved.
Patent Information
- Application Number
- CN202310681670.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-09
- Publication Date
- 2026-01-02
- Estimated Expiration
- 2043-06-09
AI Technical Summary
Existing personality recognition methods in Chinese social networks lack analysis of emotional information and psycholinguistic features, and traditional methods have low accuracy in the Chinese environment, failing to effectively utilize Chinese text datasets.
An improved BERT model is used for sentence-level text semantic extraction, combined with the DeepMoji model to obtain facial expression feature vectors, and a Chinese sentiment analysis model to obtain sentiment vectors. Finally, these vectors are concatenated and input into a CNN convolutional neural network for personality classification.
It improves the accuracy and recall of Big Five personality traits prediction in Chinese social networks, enabling more accurate detection of the personality characteristics of social network users.
Smart Images

Figure CN116910243B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of text mining, and particularly relates to a personality recognition method and device based on Chinese social network text features. BACKGROUND
[0002] With the rapid development of the Internet and the continuous increase of social media platforms, social media has become an important medium for users to show their personal image and communicate with others. Researchers have found that user-generated text content is an important feature in judging user personality characteristics.
[0003] Existing technologies focus on mining language clues from public text, analyzing user text through deep learning methods, and establishing a connection with the user. However, these methods have two main limitations: first, they only extract keywords for personality detection, lacking analysis of emotional information and psycholinguistic features; second, they ignore information about context and polysemous words, and the polysemy of a word can likely lead to some personality inaccuracies, and these methods are mostly based on user text data from English social media such as Twitter and Facebook, and Chinese text data sets are very scarce.
[0004] Big Five Personality is a popular personality testing method. Psychologists define personality as a basic, relatively stable, and personally inclined psychological characteristic. Research in different fields has fully shown that personality characteristics will affect people's external performance and decision-making behavior, including their language style and body behavior. The Big Five personality traits are also known as the Five-Factor Model, where "O" represents openness, "C" represents conscientiousness, "E" represents extraversion, "A" represents agreeableness, and "N" represents neuroticism. Traditional Big Five personality recognition algorithms are trained and verified based on English text, but the effect in the Chinese environment is not ideal, with low accuracy.
[0005] The invention with the authorized publication number CN 112364638 B discloses a personality recognition method based on social text, which includes representing the obtained social text data as a word vector using a word embedding model, using the word vector as the input of a convolutional neural network and a long short-term memory network, fusing the original word vector features, the output features of the CNN and the LSTM, and using an attention mechanism to filter out more critical features from the fused features, and finally realizing social network user personality classification based on the Big Five personality model, but the invention lacks analysis of emotional information and expression information of social text data.
[0006] In summary, there is an urgent need for a new personality recognition method suitable for Chinese social network user text features to make up for the lack of current Chinese text data sets and improve the Big Five personality prediction effect. SUMMARY
[0007] The purpose of the present application is to provide a personality recognition method and device based on Chinese social network text features, which makes up for the lack of current Chinese text data sets. The present application realizes automatic personality prediction through an improved text mining model, effectively improving the Big Five personality prediction effect.
[0008] The first aspect of the present application provides a personality recognition method based on Chinese social network text features, comprising the following steps:
[0009] S1, obtaining user social text, preprocessing the social text to obtain preprocessed data;
[0010] S2, extracting emoji and Chinese sentences from the preprocessed data, inputting the emoji into the DeepMoji model to obtain an emoji feature vector, embedding the Chinese sentences into an improved BERT model to obtain a text vector, integrating the emoji feature vector and the text vector to obtain an aggregated text vector;
[0011] S3, inputting the extracted Chinese sentences in the preprocessed data into a Chinese sentiment analysis model for emotion analysis to obtain an emotion vector;
[0012] S4, splicing the emotion vector obtained in step S3 to the CLS of the aggregated text vector obtained in step S2 to obtain a spliced vector;
[0013] S5, inputting the spliced vector into a CNN convolutional neural network model to output a prediction result.
[0014] The present application extracts Chinese data sets from social platforms, uses a pre-trained BERT model to dynamically encode text vectors, uses a multi-head attention mechanism to allow each word in the text to perform context semantic analysis on the text vector information at other positions to generate corresponding semantic text encoding, then embeds the emoji into the DeepMoji model to obtain an emoji feature vector, integrates the emoji feature vector with the text vector to obtain an aggregated text vector. Considering that the generated text encoding may lack context adaptation and emotional color, the emotional polarity and emotional characteristics are extracted in combination with an emotion dictionary, the emotional polarity is mapped to the text vector space, combined with the text, so that it is more consistent with the context, then the emotion vector is spliced to the CLS of the aggregated text vector, input into a CNN convolutional neural network model for further feature extraction and classification, and finally a personality analysis model based on Chinese text social networks is realized.
[0015] Due to the lack of public Chinese Big Five personality data sets, the present application builds a corpus to obtain user social text to help data analysis and processing.
[0016] Further, in step S1, the specific steps of obtaining the user social text, preprocessing the social text, and obtaining the preprocessed data are as follows: the user's microblog data is crawled by using the scrapy package of Python to obtain the original data; after the original data obtained is segmented into sentences and words, analysis and data cleaning are performed, and numbers, punctuation, and stops are deleted to obtain the preprocessed data.
[0017] Specifically, the text data of part of the users on the microblog is obtained by using the Scrapy package of Python, and five personality questionnaires are sent to the users for investigation; after the questionnaire feedback filled in by the users is combined with the respective text data, analysis and processing are performed, the collected text articles are deleted from the stop words, numbers, and punctuation symbols, and each word in the text is subjected to vocabulary analysis to obtain the preprocessed data, i.e., the five-personality dataset based on Chinese text.
[0018] Further, in step S1, the preprocessed data adopts the following data form: K consecutive microblogs or texts with the same label used by a user are taken as a sample, and the sample is input into the improved BERT model after vectorization for training.
[0019] The BERT model is a pre-trained model proposed by Google, which uses a large number of multi-head attention mechanisms and feedforward neural networks to improve the current sequence-to-sequence task, and uses the bidirectional encoder of the transformer in model learning to finally generate more complex word feature vectors to learn word semantics. Since the context embedding learned by the BERT model has more theoretical and empirical advantages than the traditional word embedding, the BERT model is used to construct a new sentence-level embedding in the personality detection model.
[0020] The BERT model has 12 hidden layers, each with a size of 768, i.e., in text training, each word is converted into a 768-dimensional vector representation. Since the pre-trained BERT model can accept a text vector of at most 512 dimensions, and in Chinese microblog, a single user often has more than 512 microblogs, more than 512 contents in the BERT model cannot be combined into a text.
[0021] In order to solve the above problems, the existing BERT model is improved, and the prototype of the improved BERT model is the BERT-base5 model published by Google, wherein the network layer L is set to 12 layers, the hidden layer dimension H is set to 768 dimensions, and the attention weight is set to 12.
[0022] Further, in step S2, the specific steps of improving the BERT model are: first, extracting the CLS vector (H0∈R 768 ) in the second-to-last hidden layer of the BERT model, representing it as a text vector of each microblog; then connecting the CLS vectors of multiple texts without using token embedding; using a k value as a vector limit, that is, assuming that a sample has k sentences, if there are more than k sentences, the first k sentences are extracted, and if the number of sentences is less than k, the 768-dimensional vector is filled with 0; dividing the preprocessed data into a training set, a validation set and a test set, and optimizing and training the BERT model.
[0023] In order to verify the specific k value, the application assigns a value to k on the training set, starting from the minimum value, increasing to the maximum value according to a given step size, and then encoding the k consecutive sentences by the improved BERT model, and then performing multi-label classification, and determining the optimal k value according to the prediction result.
[0024] Further, in step S2, the specific steps of extracting the emoji and Chinese sentences from the preprocessed data, inputting the emoji into the DeepMoji model to obtain an emoji feature vector, embedding the Chinese sentence into the improved BERT model to obtain a text vector, and integrating the emoji feature vector and the text vector to obtain an aggregated text vector are as follows:
[0025] S201: Obtain an emoji feature vector: extract an emoji from the preprocessed data, convert the emoji into a Unicode code, input the emoji into a sentiment model in DeepMoji, and obtain an emoji feature vector.
[0026] Since the microblog Chinese text often appears with emojis, the emotional information possessed by the emojis cannot be ignored. DeepMoji is an open source model for identifying emotional features of emojis, and in step S201, an emoji feature vector is generated by the sentiment model in DeepMoji.
[0027] S202: Obtain a text vector: extract a Chinese sentence from the preprocessed data and embed it into the improved BERT model to obtain a text vector.
[0028] Specifically, in step S202, the Chinese sentence is extracted from the preprocessed data and encoded into a vector representation by the improved BERT model; after encoding, each sentence is represented as (N, 768), where N is the number of tokens in the sentence and 768 is the number of dimensions; the sentence sequence level representation is extracted; the length of the sample sentence is analyzed, and the text exceeding the k sentence length is discarded, and the 768-dimensional vector is filled with 0 if the length of the sentence is less than k, to obtain a text vector H∈R M*k*768Where M represents the number of samples, k represents the maximum sentence length, and 768 represents the vector dimension. Through the above steps, each word in the sentence is converted into a 768-dimensional vector representation, thus converting the text dataset into a vector representation, i.e., a text vector.
[0029] S203: Input the facial expression feature vector and text vector obtained in steps S201 and S202 into the fully connected layer, and retain the matrix formed by the facial expression vector and text vector during training to obtain the aggregated text vector.
[0030] Specifically, in step S203, suppose there is the sentence "The weather is really nice today". Using s = {s1, s2, ..., s} i Describe all sentences u posted by the i-th user. i First, emojis are converted to Unicode. Then, using the sentiment model in DeepMoji, emoji feature vectors are generated. For the sth i The emoticon vector contained in the nth text of a user. Represent the original text vector as... For the sth i The nth text from a user. and The input is fed into a fully connected layer, and the matrix consisting of the expression vector and the text vector is retained during training, finally yielding the aggregated text vector.
[0031] To more accurately analyze corresponding personality traits from Weibo texts, this invention performs sentiment analysis on Weibo texts. This invention uses the Chinese Sentiment sentiment analysis database to perform sentiment analysis on Weibo texts. This database integrates the CNKI Hownet sentiment dictionary and the Dalian University of Technology sentiment lexicon, which can extract sentiment polarity from the text and provide the corresponding polarity score X∈(-1, 1).
[0032] Further, in step S3, the Chinese sentences extracted from the preprocessed data are input into the Chinese sentiment analysis model for sentiment analysis to obtain the sentiment vector. The specific steps are as follows: First, the Chinese Sentiment sentiment analysis library is used to extract the sentiment tendency of certain words, including positive and negative, and the corresponding polarity score X∈(-1, 1) is given; the sentiment polarity score is subdivided into f rating levels, where 20≤f≤50; then these f level sentiment polarity scores are mapped to the f-dimensional feature vector X∈R. f In this context, each sentiment level is mapped to an f-dimensional vector, with a value at the corresponding position. The value is 1, and the remaining positions are x. i The result is 0, and this value is used as an indicator of the sentiment polarity of the sample. The relevant formula is as follows:
[0033]
[0034]
[0035] where E score is the score of each emotion in the f-dimensional feature vector; E class is the calculated emotion rating; is the final emotional feature representation; x f is the fth rating level.
[0036] The present application adopts a CNN convolutional neural network model (CNN) for personality classification. The CNN convolutional neural network model is a deep learning model used for image processing, computer vision, and natural language processing tasks. The CNN convolutional neural network model of the present application is designed by referring to a multi-label classification model.
[0037] Further, in step S5, the CNN convolutional neural network model is a three-layer convolutional neural network, including a convolutional layer, a pooling layer, and a fully connected layer. The convolutional layer is used to extract personality features of the text. The pooling layer is used to reduce the dimension of the output of the convolutional layer, improve the computational efficiency and robustness of the model. The fully connected layer maps the features output by the pooling layer to the label space and outputs the prediction result. The prediction result outputs the Big Five personality, including openness, conscientiousness, extraversion, agreeableness, and neuroticism.
[0038] Further, the CNN convolutional neural network model adopts a Max Pooling strategy, taking the maximum value output by each convolution kernel as the input of the next layer.
[0039] Further, the CNN convolutional neural network model adopts Cross Entropy as the loss function and adopts Stochastic Gradient Descent (SGD) algorithm for optimization.
[0040] Further, in the output prediction result stage, a sigmoid function is used to convert the output scalar to the range of [0, 1]. Since the five personalities in the Big Five personality are not mutually exclusive, the recognition result of each personality is a binary value. When designing the output result, the multi-label classification is converted into multiple binary classification problems. If the output value is greater than or less than 0.5, it is considered to belong to a class.
[0041]
[0042] loss ij= -[y ij *lnP ij +(1-y ij )ln(1-P ij )]
[0043] where logits ij is the output of the fully connected layer; P ij is the binary classification output probability value; loss ij is the loss function of the jth class of the ith sample; y ij is the label of the jth class of the ith sample, which is 0 or 1.
[0044] The second aspect of the present application provides a personality recognition device based on Chinese social network text features, comprising:
[0045] A preprocessing module is configured to obtain user social text, preprocess the social text, and obtain preprocessed data.
[0046] An embedding module is configured to extract emoji and Chinese sentences from the preprocessed data, input the emoji into a DeepMoji model to obtain an emoji feature vector, embed the Chinese sentences into an improved BERT model to obtain a text vector, and integrate the emoji feature vector and the text vector to obtain an aggregated text vector.
[0047] An emotion analysis module is configured to input the extracted Chinese sentences in the preprocessed data into a Chinese sentiment analysis model for emotion analysis to obtain a sentiment vector.
[0048] A vector splicing module is configured to splice the obtained sentiment vector to the CLS of the aggregated text vector to obtain a spliced vector.
[0049] A model output module is configured to input the spliced vector into a CNN convolutional neural network model to output a prediction result.
[0050] The third aspect of the present application provides a computer device, comprising a processor and a memory for storing a program executable by the processor, wherein the processor executes the program stored in the memory to implement the personality recognition method based on Chinese social network text features.
[0051] The fourth aspect of the present application provides a storage medium storing a program, wherein the program is executed by a processor to implement the personality recognition method based on Chinese social network text features.
[0052] Compared with the prior art, the present application has at least the following beneficial effects:
[0053] 1、The improved BERT model is adopted for sentence-level text semantic extraction to obtain a text vector, an expression feature vector is obtained by using a DeepMoji model, then the text vector and the expression feature vector are aggregated to obtain an aggregated text vector, a sentiment dictionary is combined to analyze the sentiment of each text, the ability to explain personality is increased, a sentiment vector is obtained, finally, the obtained sentiment vector is spliced to the CLS of the aggregated text vector and input into a neural network classification model, and a multi-label classifier is used to calculate the result. The personality characteristics of the social network user can be more accurately detected by using only a small amount of social media text.
[0054] 2、The application introduces a global model based on BERT sentence representation and emotion detection in a Chinese environment, which can capture more context elements than ordinary word embedding, and can play a great role in personality recognition of text with greater overall semantic relevance, and has good accuracy, recall rate and prediction effect. BRIEF DESCRIPTION OF DRAWINGS
[0055] Figure 1 The flowchart of the personality recognition method based on the Chinese social network text features in the embodiment.
[0056] Figure 2 The multi-dimensional vector splicing based on the BERT model in the embodiment.
[0057] Figure 3 The flowchart of the CNN convolutional neural network output prediction result in the embodiment. DETAILED DESCRIPTION
[0058] In order to make the purpose, technical scheme and advantages of the present application clearer, the technical scheme of the present application will be described clearly and completely in combination with the specific embodiments of the present application and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of the present application, not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor belong to the scope of protection of the present application.
[0059] Figure 1 The flowchart of the personality recognition method based on the Chinese social network text features in the embodiment, comprising the following steps:
[0060] S1, obtaining user social text, pre-processing the social text to obtain pre-processed data.
[0061] Specifically, the text data of some users on the microblog is obtained by using the Scrapy package of Python, and a five-personality questionnaire is sent to the users for investigation; after the feedback of the questionnaire filled by the users is combined with the corresponding text data, analysis and processing are performed, the stop words, numbers and punctuation marks in the collected text articles are deleted, and vocabulary analysis is performed on each word in the text to obtain preprocessed data, i.e., a five-personality dataset based on Chinese text.
[0062] Further, in step S1, the preprocessed data adopts the following data form: using K continuous microblogs or texts with the same label used by a user as a sample, the sample is input into the improved BERT model after vectorization for training.
[0063] S2, the emoticons and Chinese sentences are extracted from the preprocessed data, the emoticons are input into the DeepMoji model to obtain an emoticon feature vector, the Chinese sentences are embedded into the improved BERT model to obtain a text vector, and the emoticon feature vector and the text vector are integrated to obtain an aggregated text vector.
[0064] The prototype for improving the BERT model in the embodiment is the BERT-base5 model released by Google, wherein the network layer L is set to 12 layers, the hidden layer dimension H is set to 768 dimensions, and the attention weight is set to 12.
[0065] Specifically, the steps for improving the BERT model are as follows: first, the CLS vector (H0∈R 768 ) in the second-to-last hidden layer of the BERT model is extracted and represented as a text vector of each microblog; then, the CLS vectors of multiple texts are connected without using token embedding; a k value is used as a vector limit to analyze the sentence length of the sample, and the texts exceeding the k sentence length are discarded, and the texts less than the k sentence length are filled with 0 in the 768-dimensional vector; the preprocessed data is divided into a training set, a validation set and a test set, and the BERT model is optimized and trained.
[0066] In order to verify the specific k value, k is assigned on the training set, starting from the minimum value, increasing to the maximum value according to a given step. In an embodiment of the present application, the step value is 10. The k continuous sentences are encoded by the improved BERT model, and then input into a classification neural network (full connection layer + classification output) for multi-label classification, and a fixed-size convolution kernel is added to the classification neural network to speed up feature extraction, a 3*3 convolution kernel is added to speed up feature extraction in the embodiment, and the optimal k value is determined according to the prediction result.
[0067] In one embodiment of the present application, on the Chinese micro-blog data set (with a size of millions), the model output accuracy of BERT+CNN is the highest when k=50, so the value of k is determined as 50.
[0068] Specifically, the specific steps of obtaining the aggregated text vector in this embodiment are as follows:
[0069] S201: Obtain an expression feature vector: extract an expression symbol from the preprocessed data, convert the expression symbol into a Unicode code, input the expression symbol into a sentiment model in DeepMoji, and obtain an expression feature vector.
[0070] In this embodiment, a 300-dimensional expression feature vector is generated by the sentiment model in DeepMoji.
[0071] S202: Obtain a text vector: extract a Chinese sentence from the preprocessed data, embed the Chinese sentence into an improved BERT model, and obtain a text vector.
[0072] Specifically, the Chinese sentence extracted from the preprocessed data is encoded into a vector representation by the improved BERT model; after encoding, each sentence is represented as (N, 768), where N is the number of tokens in the sentence and 768 is the number of dimensions; the sentence sequence level representation is extracted; the length of the sample sentence is analyzed, and the text with a length exceeding k sentences is discarded, and the 768-dimensional vector of the text with a length less than k sentences is filled with 0 to obtain a text vector H R M*K*768 where M represents the number of samples, k represents the maximum length of the sentence, and 768 represents the vector dimension. Through the above steps, each word in the sentence is converted into a 768-dimensional vector representation, thereby converting the text data set into a vector representation, i.e., a text vector.
[0073] S203: Input the expression feature vector and the text vector obtained in steps S201 and S202 into a fully connected layer, and retain the matrix composed of the expression vector and the text vector in training to obtain an aggregated text vector.
[0074] In this embodiment, the 768-dimensional text vector and the 300-dimensional expression feature vector are integrated to obtain a 1068-dimensional aggregated text vector.
[0075] S3, input the Chinese sentence extracted from the preprocessed data into a Chinese sentiment analysis model for emotion analysis to obtain a sentiment vector.
[0076] In this embodiment, first use Chinese Sentiment sentiment analysis library to extract the emotional tendency of some words, including positive and negative, and give the corresponding polarity score X ∈ (-1, 1). Since the feature vector output by the BERT model is 768-dimensional, the emotional polarity score needs to be refined. In this embodiment, the emotional polarity score is divided into 20 score levels, and then the 20 levels of emotional polarity scores are mapped to a 20-dimensional feature vector X ∈ R 20 The upper. Each emotional level is mapped to a 20-dimensional vector, with a value of 1 at the corresponding position, and 0 at the remaining positions. The resulting result is used as an indication of the emotional polarity of the sample, and the relevant formula is as follows:
[0077]
[0078]
[0079] Where E score is the score of each emotion in the 20-dimensional feature vector, E class is the calculated emotional level, is the final emotional feature representation.
[0080] S4, the emotional vector obtained in step S3 is spliced into the CLS of the aggregated text vector obtained in step S2 to obtain a spliced vector.
[0081] Figure 2 The multi-dimensional vector splicing diagram based on the BERT model in the embodiment is shown in the figure, wherein the vector U is an expression feature vector output by the DeepMoji model, which has 300 dimensions. H is a text vector provided by the improved BERT model, which has 768 dimensions, and the two are spliced to form an aggregated text vector with 1068 dimensions, wherein H0 is the CLS vector of the text vector. E is an emotional vector output by the Chinese Sentiment model, which has 20 dimensions. The emotional vector is spliced into the CLS of the aggregated text vector to obtain a spliced vector with 1088 dimensions.
[0082] S5, the spliced vector is input into the CNN convolutional neural network model to output a prediction result.
[0083] The CNN convolutional neural network model used in this embodiment includes convolutional layers, pooling layers and fully connected layers.
[0084] The flow chart of the CNN convolutional neural network model used in this embodiment to output the prediction result is as Figure 3The convolutional layer is the core component of the CNN, which is used to extract the personality features of the text. In this embodiment, the first layer of the convolutional kernel size is 1*3, which is used to capture the features in the semantic direction; the second layer of the convolutional kernel size is 3*3, which is used to capture more extensive features, including angles, oblique lines, etc.; and the third layer of the convolutional kernel size is 3*1, which is used to capture the features in the time sequence direction.
[0085] The pooling layer is used to reduce the dimension of the output of the convolutional layer, and improve the calculation efficiency and robustness of the model. In this embodiment, the maximum pooling (Max Pooling) strategy is adopted, and the maximum value of the output of each convolutional kernel is taken as the input of the next layer.
[0086] The setting of the training hyperparameters is an important problem in the training of the CNN. In this embodiment, the cross entropy (Cross Entropy) is used as the loss function, and the stochastic gradient descent (Stochastic Gradient Descent, SGD) algorithm is used for optimization. The learning rate is set to 0.001, the weight decay is set to 0.0005, the momentum is set to 0.9, and the training epoch is set to 20. In addition, the batch normalization (Batch Normalization) is set to 256 and the dropout is set to 0.5, in order to improve the generalization ability and robustness of the model.
[0087] Finally, the fully connected layer maps the features output by the pooling layer to the label space, and outputs the prediction result. The prediction result outputs the big five personality, including openness, conscientiousness, extraversion, agreeableness, and neuroticism.
[0088] In the output prediction stage, the sigmoid function is used to convert the output scalar to the range of [0, 1]. Since the five personalities in the big five personality are not mutually exclusive, the identification result of each personality is a binary value, and when designing the output result, the multi-label classification is converted into multiple binary classification problems. If the output value is greater than or less than 0.5, it is considered to belong to a class.
[0089]
[0090] loss ij =-[y ij *lnP ij +(1-y ij )ln(1-P ij )]
[0091] where logits ij is the output of the fully connected layer, P ij is the binary classification output probability value, and loss ijLoss function for the j-th class of the i-th sample; y ij is the label of the j-th class of the i-th sample, and is 0 or 1.
[0092] The embodiment also provides a personality recognition device based on Chinese social network text features, comprising:
[0093] A preprocessing module is configured to acquire user social text, pre-process the social text, and obtain pre-processed data.
[0094] An embedding module is configured to extract emoji and Chinese sentences from the pre-processed data, input the emoji into a DeepMoji model to obtain an emoji feature vector, embed the Chinese sentences into an improved BERT model to obtain a text vector, and integrate the emoji feature vector and the text vector to obtain an aggregated text vector.
[0095] An emotion analysis module is configured to input the Chinese sentences extracted from the pre-processed data into a Chinese sentiment analysis model to perform emotion analysis and obtain a sentiment vector.
[0096] A vector splicing module is configured to splice the obtained sentiment vector to a CLS of the aggregated text vector to obtain a spliced vector.
[0097] A model output module is configured to input the spliced vector into a CNN convolutional neural network model to output a prediction result.
[0098] The embodiment also provides a computer device, comprising a processor and a memory for storing a program executable by the processor, and the processor implements the personality recognition method based on Chinese social network text features when executing the program stored in the memory.
[0099] The embodiment also provides a storage medium storing a program, and the program is executed by a processor to implement the personality recognition method based on Chinese social network text features.
Claims
1. A personality recognition method based on Chinese social network text features, characterized in that, Includes the following steps: S1. Obtain user social text, preprocess the social text, and obtain preprocessed data; S2. Extract emojis and Chinese sentences from the preprocessed data. Input the emojis into the DeepMoji model to obtain emoji feature vectors. Embed the Chinese sentences into the improved BERT model to obtain text vectors. Integrate the emoji feature vectors and text vectors to obtain aggregated text vectors. S3. Input the Chinese sentences extracted from the preprocessed data into the Chinese sentiment analysis model for sentiment analysis to obtain sentiment vectors; S4. Patch the sentiment vector obtained in step S3 to the CLS position of the aggregated text vector obtained in step S2 to obtain the spliced vector. S5. Input the concatenated vector into the CNN convolutional neural network model and output the prediction result.
2. The personality recognition method based on Chinese social network text features according to claim 1, characterized in that, In step S1, the specific steps for obtaining user social text and preprocessing the social text to obtain preprocessed data are as follows: use the Python scrapy package to crawl the user's Weibo data to obtain raw data; after segmenting the obtained raw data into sentences and words, analyze and clean the data, and delete numbers, punctuation marks and stop words to obtain preprocessed data.
3. The personality recognition method based on Chinese social network text features according to claim 1, characterized in that, In step S2, the steps to improve the BERT model are as follows: First, extract the CLS vector from the second-to-last hidden layer of the BERT model and represent it as the text vector of each Weibo post; concatenate the CLS vectors of multiple texts without using labeled embedding; use a k value as a vector constraint to analyze the sentence length of the samples, discarding texts longer than k sentences and padding the 768-dimensional vectors with 0s for those shorter than k sentences; divide the preprocessed data into training, validation, and test sets, and optimize the training of the BERT model.
4. The personality recognition method based on Chinese social network text features according to claim 3, characterized in that, The method for determining the value of k is as follows: k is assigned a value on the training set, starting from the minimum value and increasing to the maximum value according to a given step size. k consecutive sentences are encoded by the improved BERT model, and then multi-label classification is performed. The optimal value of k is determined based on the prediction results.
5. The personality recognition method based on Chinese social network text features according to claim 1, characterized in that, In step S2, the specific steps for extracting emojis and Chinese sentences from the preprocessed data, inputting the emojis into the DeepMoji model to obtain emoji feature vectors, embedding the Chinese sentences into the improved BERT model to obtain text vectors, and integrating the emoji feature vectors and text vectors to obtain aggregated text vectors are as follows: S201: Obtain facial expression feature vector: Extract emojis from the preprocessed data, convert the emojis into Unicode codes, input them into the sentiment model in DeepMoji, and obtain facial expression feature vectors; S202: Obtaining Text Vectors: Extract Chinese sentences from the preprocessed data and embed them into the improved BERT model to obtain text vectors; S203: Input the facial expression feature vector and text vector obtained in steps S201 and S202 into the fully connected layer, and retain the matrix formed by the facial expression vector and text vector during training to obtain the aggregated text vector.
6. The personality recognition method based on Chinese social network text features according to claim 1, characterized in that, In step S3, the Chinese sentences extracted from the preprocessed data are input into the Chinese sentiment analysis model for sentiment analysis to obtain the sentiment vector. The steps are as follows: First, the Chinese Sentiment sentiment analysis library is used to extract the sentiment tendency of words, including positive and negative, and give the corresponding polarity scores. The sentiment polarity scores are subdivided into f rating levels, where 20≤f≤50. Then, the f level sentiment polarity scores are mapped to f-dimensional feature vectors. Each sentiment level is mapped to an f-dimensional vector, with a value of 1 at the corresponding position and 0 at the other positions. The results are used as an indicator of the sentiment polarity of the sample.
7. The personality recognition method based on Chinese social network text features according to claim 1, characterized in that, In step S5, the CNN convolutional neural network model is a three-layer convolutional neural network, including convolutional layers, pooling layers, and fully connected layers. The convolutional layers are used to extract personality features from the text, the pooling layers are used to reduce the dimensionality of the output of the convolutional layers, and improve the computational efficiency and robustness of the model. The fully connected layers map the features output by the pooling layers to the label space and output the prediction results. The CNN convolutional neural network model adopts the max pooling strategy, using the maximum value output by each convolutional kernel as the input of the next layer, using cross-entropy as the loss function, and using the stochastic gradient descent algorithm for optimization.
8. A personality recognition device based on Chinese social network text features, comprising: Preprocessing module: The preprocessing module is used to acquire user social text, preprocess the social text, and obtain preprocessed data; Embedding Module: The embedding module is used to extract emojis and Chinese sentences from the preprocessed data, input the emojis into the DeepMoji model to obtain emoji feature vectors, embed the Chinese sentences into the improved BERT model to obtain text vectors, and integrate the emoji feature vectors and text vectors to obtain aggregated text vectors; Sentiment Analysis Module: The sentiment analysis module is used to input the Chinese sentences extracted from the preprocessed data into the Chinese sentiment analysis model for sentiment analysis, and obtain sentiment vectors; Vector concatenation module: The vector concatenation module is used to concatenate the obtained emotion vector to the CLS position of the aggregated text vector to obtain the concatenated vector; Model output module: The model output module is used to input the concatenated vector into the CNN convolutional neural network model and output the prediction result.
9. A computer device comprising a processor and a memory for storing a processor-executable program, wherein when the processor executes the program stored in the memory, it implements the personality recognition method based on Chinese social network text features as described in any one of claims 1-7.
10. A storage medium storing a program, which, when executed by a processor, implements the personality recognition method based on Chinese social network text features as described in any one of claims 1-7.
Citation Information
Patent Citations
A Personality Recognition Method Based on Social Text
CN112364638B
A social network user personality prediction method based on Chinese text analysis
CN109635207A
Social text sentiment analysis method and device fused with emoticons
CN115221314A