A social media stress category detection method and device

By conducting meta-learning training on frequently occurring stress categories, combined with coding, induction and relational modules, the problem of low detection accuracy of infrequent stress categories in the existing technology is solved, and accurate identification of less common stress categories is achieved. and detection.

CN114842246BActive Publication Date: 2024-09-06TSINGHUA UNIVERSITY
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202210411487.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-19
Publication Date
2024-09-06
Estimated Expiration
2042-04-19

AI Technical Summary

Technical Problem

The existing technology has low detection accuracy for social media stress categories that appear infrequently, and it is difficult to effectively identify serious but less common stress categories such as pregnancy stress.

Method used

A social media stress category detection method based on meta-learning is adopted. By training on frequently occurring stress categories, the meta-learning model is used to achieve accurate identification on a small number of infrequently occurring stress categories, including a coding module, an induction module and a relationship module. Combining technologies such as BERT, dependency tree, and dependency graph convolutional network, the model is optimized using meta-training and meta-testing mechanisms.

Benefits of technology

The detection accuracy of infrequently occurring pressure categories is improved, allowing the model to accurately identify those less common pressure categories with a small amount of data, improving detection accuracy and efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114842246B
    Figure CN114842246B
Patent Text Reader

Abstract

The present invention provides a social media stress category detection method and device, wherein the method comprises: obtaining an object to be classified and a support set; inputting the object to be classified and the support set into a stress category detection model, and obtaining a classification result output by the stress category detection model; wherein the stress category detection model is obtained after meta-learning based on a training set and a test set, the training set includes training samples and corresponding classification labels, the test set includes test samples and corresponding classification labels, and the support set includes at least one category, each category includes at least one support sample and a classification label corresponding to each support sample. The social media stress category detection method and device provided by the present invention enable the stress category detection model to directly identify those infrequently occurring stress categories based on a small amount of infrequently occurring stress category data through meta-learning.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a method and device for detecting stress categories in social media. Background Art

[0002] Understanding stress categories is very important to help people take effective measures to deal with stress. Due to the rich information on social media, people's stress categories can be analyzed through social media. Current stress category detection methods focus on detecting stress categories that frequently appear on social media (academic, work, economy, etc.), while ignoring those stress categories that do not appear frequently. These categories of stress are often more serious, such as the stress categories experienced by minority groups (pregnancy stress).

[0003] Due to the problem of data scarcity, the detection accuracy of infrequently occurring stress categories needs to be improved. Summary of the invention

[0004] The present invention provides a social media stress category detection method, which is used to solve the defect of low detection accuracy for infrequently occurring stress categories in the prior art and improve the accuracy of detection for infrequently occurring stress categories.

[0005] In a first aspect, the present invention provides a method for detecting stress categories in social media, comprising:

[0006] Get the object to be classified and the support set;

[0007] Inputting the object to be classified and the support set into a pressure category detection model to obtain a classification result output by the pressure category detection model;

[0008] Among them, the stress category detection model is obtained after meta-learning based on the training set and the test set, the training set includes training samples and corresponding classification labels, the test set includes test samples and corresponding classification labels, the support set includes at least one category, each category includes at least one support sample and the classification label corresponding to each support sample.

[0009] Optionally, the stress category detection model includes: an encoding module, an induction module and a relationship module;

[0010] The step of inputting the object to be classified and the support set into a pressure category detection model to obtain a classification result output by the pressure category detection model includes:

[0011] Inputting the object to be classified into the encoding module to obtain the vector to be classified output by the encoding module;

[0012] Inputting the support set into the induction module to obtain a category vector set output by the induction module, wherein the category vector set includes at least one category vector, and each category vector corresponds to the classification label one by one;

[0013] The vector to be classified and the category vector set are input into the relationship module to obtain the classification result output by the relationship module.

[0014] Optionally, the induction module includes a vector unit and a weighting unit;

[0015] The step of inputting the support set into the induction module to obtain a category vector set output by the induction module includes:

[0016] Inputting the support set into the vector unit to obtain an expert vector set output by the vector unit, wherein the expert vector set includes at least one expert vector, and each of the expert vectors corresponds one-to-one to a support sample in the support set;

[0017] The expert vector set is input into a weighting unit, and a weighting operation is performed on the expert vector set based on a preset weighting formula to obtain an output category vector set of the weighting unit.

[0018] Optionally, the preset weighting formula includes an initial value formula, a threshold value formula and a category representation function;

[0019] The initial value formula is:

[0020] η i =Relu(e i W g +b g );

[0021] The threshold value formula is:

[0022]

[0023] The category representation function is:

[0024]

[0025] Among them, η i represents the initial gate value corresponding to the i-th expert sample, Relu represents the ReLU activation function, and e i represents the expert vector corresponding to the i-th expert sample, W g represents the training parameters, b g represents the training parameters, g i represents the final gate value corresponding to the i-th expert sample, exp represents the exponential function, K represents that a category contains K samples, and c jRepresents the category vector of the j-th category, i is a positive integer greater than or equal to 1, j is a positive integer greater than or equal to 1, and K is a positive integer greater than or equal to 1.

[0026] Optionally, the inputting the vector to be classified and the category vector set into the relationship module to obtain the classification result output by the relationship module includes:

[0027] The vector to be classified and the category vector set are input into the relationship module, and the category vector most similar to the vector to be classified is determined based on cosine similarity to obtain a classification result output by the relationship module.

[0028] Optionally, the pressure category detection model is trained by the following steps:

[0029] Meta-training the stress category detection model based on the training set, the loss function and a preset number of meta-training iterations;

[0030] Performing a meta-test on the stress category detection model based on the test set and a preset number of meta-test iterations;

[0031] The above steps are performed alternately until the preset number of training times is exhausted or the meta-test result output by the pressure category detection model reaches a preset accuracy rate.

[0032] In a second aspect, the present invention further provides a social media stress category detection device, comprising:

[0033] An acquisition module is used to obtain the objects to be classified and the support set;

[0034] A classification module, used for inputting the object to be classified and the support set into a pressure category detection model to obtain a classification result output by the pressure category detection model;

[0035] Among them, the stress category detection model is obtained after meta-learning based on the training set and the test set, the training set includes training samples and corresponding classification labels, the test set includes test samples and corresponding classification labels, the support set includes at least one category, each category includes at least one support sample and the classification label corresponding to each support sample.

[0036] In a third aspect, the present invention further provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the social media stress category detection method as described in the first aspect is implemented.

[0037] In a fourth aspect, the present invention further provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the social media stress category detection method as described in the first aspect.

[0038] In a fifth aspect, the present invention further provides a computer program product, comprising a computer program, which, when executed by a processor, implements the social media stress category detection method as described in the first aspect.

[0039] The social media stress category detection method and device provided by the present invention enable the stress category detection model to have the ability of "learning how to learn" through meta-learning, so that after the stress category detection model is trained on frequently occurring stress categories, it does not need to be adjusted, and only needs data of a small number of infrequently occurring stress categories to directly identify those infrequently occurring stress categories. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0041] Figure 1 This is one of the flow charts of the social media stress category detection method provided by an embodiment of the present invention;

[0042] Figure 2 This is a second flow chart of the social media stress category detection method provided by an embodiment of the present invention;

[0043] Figure 3 is a structural schematic diagram of a social media stress category detection device provided by an embodiment of the present invention;

[0044] Figure 4 It is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0045] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0046] The following is an introduction to the technical terms involved in the present invention:

[0047] Meta-learning: Meta-learning is the hope that the model can acquire the ability to "learn to learn" so that it can quickly learn new tasks based on the existing "knowledge". Its intention is to design a model that can quickly learn new skills or adapt to new environments through a small number of training examples. The meta-learning system must be trained on a large number of tasks and predict its ability to learn new tasks.

[0048] Artificial Intelligence (AI): AI is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results. AI basic technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing, operation / interaction systems, mechatronics, computer vision, speech processing, natural language processing and machine learning / deep learning.

[0049] Attention: This is a very common fact that is often overlooked. For example, when a bird flies across the sky, people often follow the bird, and the sky naturally becomes background information in the human visual system. The basic idea of ​​the attention mechanism in computer vision is to let the system learn to focus on the areas of interest, ignore background information and focus on key information.

[0050] Loss Function: Also known as the cost function or objective function, it is used to measure the degree of inconsistency between the model's predicted value f(x) and the true value Y. It is usually a non-negative real-valued function expressed as L(Y, f(x)). Generally speaking, the smaller the value of the loss function (i.e., the loss value), the better the model fits and the stronger the ability to predict new data. The loss function is the "baton" for training models in deep learning, guiding the learning of model parameters by back-propagating the errors generated by the labels of predicted samples and true samples. When the loss value of the loss function gradually decreases (converges), the model training can be considered complete.

[0051] Current stress detection focuses on stress categories that appear frequently on social media. However, stress types that are rarely seen on social media are more serious, such as the stress experienced by some vulnerable groups (e.g., stress caused by pregnancy in women, who often experience a lot of stress during pregnancy due to previous negative pregnancy experiences, unexpected pregnancies, or coping with physical changes). In addition, according to the classic psychological theory SRRS, people tend not to express some important stress categories on social media, such as stress caused by mortgages, housing, and pregnancy, so there is less data for these categories. However, artificial intelligence relies on learning from big data, and it is difficult to quickly generalize a model with less data, resulting in low detection accuracy for these infrequent stress categories.

[0052] To address the above issues, we propose a meta-learning-based method for stress detection in social media. This method is trained on frequently occurring stress categories and can be directly applied to rarely occurring stress categories.

[0053] Combine the following Figure 1 - Figure 2 A social media stress category detection method provided by an embodiment of the present invention is described.

[0054] Figure 1 is one of the flow charts of the social media stress category detection method provided by an embodiment of the present invention. Figure 1 As shown, an embodiment of the present invention provides a social media stress category detection method, comprising:

[0055] Step 110, obtaining the object to be classified and the support set;

[0056] Specifically, the objects to be classified are social media content, such as text data, image data, audio data, and video data posted by users on social media. The support set may contain a small number of labeled samples for the stress category detection model to learn classification. Optionally, the samples in the support set may be infrequently occurring stress category samples (i.e., stress category samples with less data). It should be understood that the objects to be classified may be captured from the Internet, the support set may be obtained from a database, or may be manually labeled, and the embodiments of the present invention do not limit the sources of the objects to be classified and the support set.

[0057] Step 120, inputting the object to be classified and the support set into a pressure category detection model to obtain a classification result output by the pressure category detection model;

[0058] Among them, the stress category detection model is obtained after meta-learning based on the training set and the test set, the training set includes training samples and corresponding classification labels, the test set includes test samples and corresponding classification labels, the support set includes at least one category, each category includes at least one support sample and the classification label corresponding to each support sample.

[0059] Specifically, through meta-learning, during the training process of the stress category detection model, after a large amount of training, different tasks are encountered each time the training is performed, and there are samples in this task that have not been seen in the previous tasks. The stress category detection model has to learn a new task each time, and after a large amount of training, the stress category detection model can have the ability to handle new tasks. This new task can be a small sample task, which supports a small number of labeled samples that have not been seen in the previous training of the stress category detection model. After meta-learning, the stress category detection model can classify and identify unlabeled objects to be classified with the help of these small samples. This learning method enables the stress category detection model to better handle the differences between tasks and ignore the characteristics of specific tasks after multiple trainings on different tasks. In this way, accurate classification can be achieved based on a small number of labeled samples when encountering new tasks of small sample classification.

[0060] The social media stress category detection method provided by the embodiment of the present invention enables the stress category detection model to have the ability of "learning how to learn" through meta-learning, so that after the stress category detection model is trained on frequently occurring stress categories, it does not need to be adjusted, and only needs data of a small number of infrequently occurring stress categories to directly identify those infrequently occurring stress categories.

[0061] Next, possible implementations of the above steps in specific embodiments are further described.

[0062] refer to Figure 2 , Figure 2 This is the second flow chart of the social media stress category detection method provided by the embodiment of the present invention. Optionally, the stress category detection model includes: an encoding module, an induction module and a relationship module;

[0063] The step of inputting the object to be classified and the support set into a pressure category detection model to obtain a classification result output by the pressure category detection model includes:

[0064] Step 121, inputting the object to be classified into the encoding module to obtain the vector to be classified output by the encoding module;

[0065] Step 122, inputting the support set into the induction module to obtain a category vector set output by the induction module, wherein the category vector set includes at least one category vector, and each category vector corresponds to the classification label one by one;

[0066] Step 123: input the vector to be classified and the category vector set into the relationship module to obtain the classification result output by the relationship module.

[0067] Specifically, the stress category detection model consists of three modules: encoding module, induction module and relation module. The encoding module is used to obtain the category-related representation of the object to be classified; the induction module is used to summarize and generate the support set representation of each category; and the relation module is used to determine which category the object to be classified belongs to.

[0068] Step 121: input the object to be classified into the encoding module to obtain the vector to be classified output by the encoding module.

[0069] In one embodiment, when the object to be classified includes text data, the encoding module includes: a BERT unit, a dependency tree unit, and a dependency graph unit.

[0070] Step 1211, input the text data into the BERT unit to obtain a word embedding vector set corresponding to the object to be classified output by the BERT unit. It should be understood that each word in the text data corresponds to a word embedding vector.

[0071] Specifically, the BERT unit is a pre-trained BERT model. The BERT model can provide powerful context-related representations and can be used for various target tasks. Therefore, in the embodiment of the present invention, the pre-trained BERT is used to obtain the word embedding vector set corresponding to the object to be classified. The word embedding vector set can reflect the semantic representation of the object to be classified, and the semantic representation of the word can effectively understand the semantics of the entire sentence.

[0072] The social media stress category detection method provided by the embodiment of the present invention converts the incalculable text data into a vector form through word embedding, and then can perform calculations on the text information, thereby analyzing the text content of social media and obtaining a stress detection classification structure.

[0073] Step 1212, input the text data into the dependency tree unit, and obtain the dependency tree corresponding to the object to be classified output by the dependency tree unit.

[0074] Specifically, the dependency tree unit may be formed by a dependency tree generation tool such as spaCy, and the embodiment of the present invention does not limit the tool for generating the dependency tree.

[0075] Step 1213, construct a dependency graph based on the dependency tree and word embedding vector set of the object to be classified. In the dependency graph, the nodes are word embedding vectors and the edges are relationships in the dependency tree. The adjacency matrix is ​​calculated as follows:

[0076]

[0077] Among them, A i,j Represents the connection between the i-th word and the j-th word, A i,j ∈R Y×Y , that is, A i,j Belongs to the node matrix of Y×Y dimension, i is a positive integer greater than or equal to 1, j is a positive integer greater than or equal to 1, T(W i ,W j ) represents the i-th word W i With the jth word W j There is a relationship between A i,j =1 means there is an edge between the node of the i-th word and the node of the j-th word, A i,j = 0 means that there is no edge between the node of the i-th word and the node of the j-th word. i,j The connection relationship between the i-th word and the j-th word can be determined by the dependency tree.

[0078] Step 1214, input the word embedding vector set and the dependency graph into the dependency graph unit, and obtain the first matrix to be classified output by the dependency graph unit. Specifically, the dependency graph unit can be a dependency graph convolutional network, which uses a graph convolutional network to learn syntactic dependency information. The dependency graph convolutional network takes the dependency graph and the word embedding vector corresponding to each node in the dependency graph as input, and each node in the 1-th layer is updated according to the hidden representation of its neighborhood:

[0079]

[0080]

[0081] Among them, H I is the first matrix to be classified, which is used to represent the hidden layer representation of the graph convolutional network, H I ∈R Y×d , H I is a Y×d-dimensional matrix, ReLU represents the ReLU activation function, represents the normalized adjacency matrix, A represents the adjacency matrix, D represents the degree of A, W I is the training parameter of the 1-th layer, W I ∈R d×d , W I is a d×d dimensional matrix, b Iare the training parameters of the 1-th layer.

[0082] It should be understood that H I It is a representation of the dependency information after the dependency graph convolution network. The normalized adjacency matrix can reduce the complexity of the syntactic structure while expressing the syntactic structure, thereby reducing the time complexity. The activation function can use the ReLU function or other functions.

[0083] The social media stress category detection method provided by the embodiment of the present invention combines the dependency tree with the word embedding to combine the syntactic structure with the word meaning, so that the stress category detection model can understand the semantics of the entire object to be classified from both the syntactic structure and the word meaning, thereby improving the accuracy of the semantic understanding of the object to be classified.

[0084] Optionally, when the object to be classified also includes image data:

[0085] The encoding module also includes a picture unit and a connection unit;

[0086] Step 1215: input the picture data into the picture unit to obtain a second matrix to be classified output by the picture unit.

[0087] Specifically, the picture unit is used to encode the picture data to obtain a second matrix to be classified, and the second matrix to be classified is used to represent the meaning of the picture. Optionally, the picture unit may include ResNet. ResNet can effectively obtain image features from social media data, so picture features can be extracted based on the pre-trained 34-layer ResNet. The final second matrix to be classified is X = {x 1 ,x 2 ,…,x δ}, where δ represents the number of image data (such as the number of matching Figure 3 Zhang, then δ=3), x i Represents the vector representation of the i-th image, 1≤i≤δ; X∈R δ×d , the second matrix to be classified is a matrix of δ×d dimensions.

[0088] Step 1216: concatenate the first matrix to be classified and the second matrix to be classified to obtain a matrix to be classified.

[0089] Let's take the simplified first matrix to be classified and the second matrix to be classified as an example:

[0090]

[0091]

[0092]

[0093] Among them, H is the text representation of the object to be classified, that is, the first matrix to be classified, X is the image representation of the object to be classified, that is, the second matrix to be classified, con represents the concatenation function, P represents the final representation of the object to be classified, P∈R t×d , P is a t×d dimensional matrix, where t=Y+δ.

[0094] Optionally, the encoding module further includes an attention unit;

[0095] Step 1217, input the matrix to be classified into the attention unit to obtain the vector to be classified output by the attention unit;

[0096] It should be understood that when the object to be classified includes only the text data, the matrix to be classified is the first matrix to be classified; when the object to be classified includes the text data and the image data, the matrix to be classified is the matrix obtained by concatenating the first matrix to be classified and the second matrix to be classified.

[0097] Specifically, the attention unit is constructed based on the attention mechanism. Taking the case where the object to be classified includes the text data and the image data as an example, the stress category detection model can learn to pay attention to stress-related information by fusing the two data modalities based on the attention mechanism.

[0098] Optionally, inputting the matrix to be classified into an attention unit to obtain the vector to be classified output by the attention unit includes:

[0099] Obtaining an attention vector based on an attention vector formula and the matrix to be classified;

[0100] A vector to be classified is obtained based on the attention vector and the matrix to be classified.

[0101] The attention vector formula is:

[0102] v=Softmax(PW p +b p );

[0103] F=v T P;

[0104] Where v represents the attention vector, v∈R t×1 , v is a t×1 dimensional matrix, Softmax represents the softmax function, P represents the matrix to be classified, W p represents the training parameters, W p ∈R d×1 , W p is a d×1 dimensional matrix, b pRepresents the training parameters, F is the vector to be classified, which is used to represent the object to be classified, F∈R 1×d , F is a 1×d-dimensional matrix, v T Represents the transpose of v.

[0105] The social media stress category detection method provided by the embodiment of the present invention combines text data and image data so that the stress category detection model can understand the semantics of the entire object to be classified from both text and image aspects, thereby improving the accuracy of semantic understanding of the object to be classified.

[0106] Step 122, input the support set into the induction module to obtain a category vector set output by the induction module, wherein the category vector set includes at least one category vector, and each category vector corresponds to the classification label one by one.

[0107] Optionally, the induction module includes a vector unit and a weighting unit;

[0108] The step of inputting the support set into the induction module to obtain a category vector set output by the induction module includes:

[0109] Step 1221, inputting the support set into the vector unit to obtain an expert vector set output by the vector unit, wherein the expert vector set includes at least one expert vector, and each of the expert vectors corresponds one-to-one to a support sample in the support set;

[0110] Specifically, the support set may include support samples of N categories, each category may include K support samples, and the process of converting support samples into expert vectors may refer to the above steps 1211 to 1217. The embodiment of the present invention does not limit the process of converting support samples into expert vectors.

[0111] Step 1222: input the expert vector set into a weighting unit, perform a weighting operation on the expert vector set based on a preset weighting formula, and obtain an output category vector set of the weighting unit.

[0112] Specifically, the induction module is used to generate a category representation corresponding to each category from the support set. The weighting unit is designed based on a hybrid expert mechanism and is used to generate a category representation corresponding to each category based on an expert vector set. The weighting unit weights each expert vector in each category so that multiple different expert vectors with different weights can be combined to represent the corresponding category, so that the stress category detection model can utilize the key information of each expert vector (i.e., support sample) and ignore the noise. That is, each support sample in the support set is regarded as an expert, and each expert aims to learn information related to the category. All experts share the same parameters.

[0113] Optionally, the preset weighting formula can be determined by a data modeling algorithm-optimal weighting method, or by a combination weighting method or an indicator weighting method, etc. The embodiment of the present invention does not limit the specific form of the preset weighting formula.

[0114] Optionally, the preset weighting formula includes an initial value formula, a threshold value formula and a category representation function;

[0115] The initial value formula is:

[0116] η i =Relu(e i W g +b g );

[0117] The threshold value formula is:

[0118]

[0119] The category representation function is:

[0120]

[0121] Among them, η i represents the initial gate value corresponding to the i-th expert sample, Relu represents the ReLU activation function, and e i represents the expert vector corresponding to the i-th expert sample, W g represents the training parameters, b g represents the training parameters, g i represents the final gate value corresponding to the i-th expert sample, exp represents the exponential function, K represents that a category contains K samples, and c j Represents the category vector of the j-th category, i is a positive integer greater than or equal to 1, j is a positive integer greater than or equal to 1, and K is a positive integer greater than or equal to 1.

[0122] Specifically, the threshold value is a nonlinear transformation of the expert vector, and the threshold value calculation is used for the pressure category detection model to learn and measure the importance of expert information. It should be understood that Figure 2 The middle gate value unit is used to calculate the gate value through the gate value formula, and the coordination unit is used to calculate the category representation.

[0123] The social media stress category detection method provided by the embodiment of the present invention weights the representation (expert vector) of the support samples, so that the stress category detection model can utilize the key information of each expert vector and ignore the noise, thereby improving the accuracy of the category representation.

[0124] Optionally, step 123, inputting the vector to be classified and the category vector set into the relationship module to obtain the classification result output by the relationship module, includes:

[0125] The vector to be classified and the category vector set are input into the relationship module, and the category vector most similar to the vector to be classified is determined based on cosine similarity to obtain a classification result output by the relationship module.

[0126] Specifically, the relationship module is used to measure the correlation between the query vector (i.e., the vector to be classified) and the category (i.e., each category vector in the category vector set). Cosine similarity shows great superiority in measuring the relationship between two vectors. Therefore, the embodiment of the present invention uses the cosine similarity formula to calculate the similarity between the vector to be classified and the category vector:

[0127] The cosine similarity formula is:

[0128]

[0129] Among them, q represents the vector to be classified, c i Represents the category vector of the i-th category, i is a positive integer, j is a positive integer, Represents a relationship score ranging from -1 to 1, where a score close to 1 indicates that the two vectors are more similar.

[0130] Classify the object to be classified into the category corresponding to the maximum relationship score.

[0131] The social media stress category detection method provided by the embodiment of the present invention compares the vector to be classified with the category vector one by one. Since the vector to be classified can comprehensively represent the semantic meaning of the object to be classified, the accuracy of the category vector's category representation is improved by weighting, thereby improving the accuracy of social media stress category classification.

[0132] Optionally, the pressure category detection model is trained by the following steps:

[0133] Step 210, meta-training the stress category detection model based on the training set, the loss function and a preset number of meta-training tasks;

[0134] Step 220, performing a meta-test on the stress category detection model based on the test set and a preset number of meta-test tasks;

[0135] The above steps are performed alternately until the preset number of iterations is exhausted or the meta-test result output by the pressure category detection model reaches a preset accuracy rate.

[0136] Specifically, Table 1 is a meta-learning algorithm provided by an embodiment of the present invention.

[0137] Table 1. Meta-learning algorithms

[0138]

[0139]

[0140] Meta-training To effectively utilize the training set, we adopt a meta-training strategy. In each training episode, a meta-task is constructed to calculate the gradient and update our model. As shown in Table 1, the meta-task is formed by randomly sampling N categories from the training set categories, and then selecting K labeled samples for each category as the support set S, and a portion of the remaining samples of those categories are selected as the query set Q. The meta-training process aims to learn how to learn meaningful features to minimize the loss on the query set Q.

[0141] This meta-training mechanism allows the stress category detection model to learn the common parts of different meta-tasks, such as how to extract important features and compare sample similarities, while forgetting the task-specific parts of the meta-tasks. Therefore, the model can still work effectively when facing new meta-tasks.

[0142] Meta-testing After meta-training, the same episode construction mechanism is applied to test whether the stressed category detection model can be directly applied to new categories. To create a test episode, first randomly sample N new categories from the test set. Then sample the test support set and test query set from the N categories. The output of the stressed category detection model can represent the average performance of the query set of all test episodes.

[0143] If the accuracy of the output result of the pressure category detection model after the meta-test does not reach the preset accuracy, the pressure category detection model is meta-trained again, and the meta-trained pressure category detection model is tested again until the number of iterations is exhausted or the accuracy of the output result of the pressure category detection model reaches the preset accuracy, and then the training of the pressure category detection model is stopped.

[0144] Optionally, during the meta-training phase, we use mean squared error to optimize our model.

[0145] The social media stress category detection method provided by the embodiment of the present invention enables the stress category detection model to have the ability of "learning how to learn" through meta-learning, so that after the stress category detection model is trained on frequently occurring stress categories, it does not need to be adjusted, and only needs data of a small number of infrequently occurring stress categories to directly identify those infrequently occurring stress categories.

[0146] The social media stress category detection device provided by the present invention is described below. The social media stress category detection device described below and the social media stress category detection method described above can be referenced to each other.

[0147] Figure 3is a schematic diagram of the structure of a device for detecting stress categories in social media provided by an embodiment of the present invention. Figure 3 As shown, an embodiment of the present invention provides a social media stress category detection device, comprising:

[0148] An acquisition module 310 is used to acquire the object to be classified and the support set;

[0149] A classification module 320, configured to input the object to be classified and the support set into a pressure category detection model to obtain a classification result output by the pressure category detection model;

[0150] Among them, the stress category detection model is obtained after meta-learning based on the training set and the test set, the training set includes training samples and corresponding classification labels, the test set includes test samples and corresponding classification labels, the support set includes at least one category, each category includes at least one support sample and the classification label corresponding to each support sample.

[0151] It should be noted here that the above-mentioned device provided in the embodiment of the present invention can implement all the method steps implemented in the above-mentioned method embodiment, and can achieve the same technical effect. The parts and beneficial effects that are the same as the method embodiment in this embodiment will not be described in detail here.

[0152] Figure 4 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 4 As shown, the electronic device may include: a processor 410, a communication interface 420, a memory 430 and a communication bus 440, wherein the processor 410, the communication interface 420 and the memory 430 communicate with each other through the communication bus 440. The processor 410 may call the logic instructions in the memory 430 to execute the social media stress category detection method, including: obtaining an object to be classified and a support set; inputting the object to be classified and the support set into a stress category detection model to obtain a classification result output by the stress category detection model; wherein the stress category detection model is obtained after meta-learning based on a training set and a test set, wherein the training set includes training samples and corresponding classification labels, the test set includes test samples and corresponding classification labels, the support set includes at least one category, each category includes at least one support sample and a classification label corresponding to each support sample.

[0153] In addition, the logic instructions in the above-mentioned memory 430 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.

[0154] On the other hand, the present invention also provides a computer program product, which includes a computer program, and the computer program can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the social media stress category detection method provided by the above methods, and the method includes: obtaining an object to be classified and a support set; inputting the object to be classified and the support set into a stress category detection model to obtain a classification result output by the stress category detection model; wherein the stress category detection model is obtained after meta-learning based on a training set and a test set, the training set includes training samples and corresponding classification labels, the test set includes test samples and corresponding classification labels, and the support set includes at least one category, each category includes at least one support sample and a classification label corresponding to each support sample.

[0155] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to execute the social media stress category detection method provided by the above-mentioned methods, the method comprising: obtaining an object to be classified and a support set; inputting the object to be classified and the support set into a stress category detection model to obtain a classification result output by the stress category detection model; wherein the stress category detection model is obtained after meta-learning based on a training set and a test set, the training set includes training samples and corresponding classification labels, the test set includes test samples and corresponding classification labels, the support set includes at least one category, each category includes at least one support sample and a classification label corresponding to each support sample.

[0156] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.

[0157] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0158] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for detecting stress categories in social media, characterized in that: include: Get the object to be classified and the support set; Inputting the object to be classified and the support set into a pressure category detection model to obtain a classification result output by the pressure category detection model; The stress category detection model is obtained after meta-learning based on a training set and a test set, wherein the training set includes training samples and corresponding classification labels, the test set includes test samples and corresponding classification labels, the support set includes at least one category, each category includes at least one support sample and a classification label corresponding to each support sample; The stress category detection model includes: an encoding module, an induction module and a relationship module; The step of inputting the object to be classified and the support set into a pressure category detection model to obtain a classification result output by the pressure category detection model includes: Inputting the object to be classified into the encoding module to obtain the vector to be classified output by the encoding module; Inputting the support set into the induction module to obtain a category vector set output by the induction module, wherein the category vector set includes at least one category vector, and each category vector corresponds to the classification label one by one; Inputting the vector to be classified and the category vector set into the relationship module to obtain the classification result output by the relationship module; The induction module includes a vector unit and a weighting unit; The step of inputting the support set into the induction module to obtain a category vector set output by the induction module includes: Inputting the support set into the vector unit to obtain an expert vector set output by the vector unit, wherein the expert vector set includes at least one expert vector, and each of the expert vectors corresponds one-to-one to a support sample in the support set; Inputting the expert vector set into a weighting unit, performing a weighting operation on the expert vector set based on a preset weighting formula, and obtaining an output category vector set of the weighting unit; The preset weighting formula includes an initial value formula, a threshold value formula and a category representation function; The initial value formula is: η i JRelu(e i W g +b g )4 The threshold value formula is: The category representation function is: Among them, η i represents the initial gate value corresponding to the i-th expert sample, Relu represents the ReLU activation function, and e i represents the expert vector corresponding to the i-th expert sample, W g represents the training parameters, b g represents the training parameters, g i represents the final gate value corresponding to the i-th expert sample, exp represents the exponential function, K represents that a category contains K samples, and c j Represents the category vector of the j-th category, i is a positive integer greater than or equal to 1, j is a positive integer greater than or equal to 1, and K is a positive integer greater than or equal to 1.

2. The social media stress category detection method according to claim 1, characterized in that: The step of inputting the vector to be classified and the category vector set into the relationship module to obtain the classification result output by the relationship module includes: The vector to be classified and the category vector set are input into the relationship module, and the category vector most similar to the vector to be classified is determined based on cosine similarity to obtain a classification result output by the relationship module.

3. The social media stress category detection method according to any one of claims 1-2, characterized in that: The pressure category detection model is trained by the following steps: Meta-training the stress category detection model based on the training set, the loss function and a preset number of meta-training iterations; Performing a meta-test on the stress category detection model based on the test set and a preset number of meta-test iterations; The above steps are performed alternately until the preset number of training times is exhausted or the meta-test result output by the stress category detection model reaches a preset accuracy rate.

4. A social media stress category detection device, characterized in that: include: An acquisition module is used to obtain the objects to be classified and the support set; A classification module, used for inputting the object to be classified and the support set into a pressure category detection model to obtain a classification result output by the pressure category detection model; The stress category detection model is obtained after meta-learning based on a training set and a test set, wherein the training set includes training samples and corresponding classification labels, the test set includes test samples and corresponding classification labels, the support set includes at least one category, each category includes at least one support sample and a classification label corresponding to each support sample; The stress category detection model includes: an encoding module, an induction module and a relationship module; The step of inputting the object to be classified and the support set into a pressure category detection model to obtain a classification result output by the pressure category detection model includes: Inputting the object to be classified into the encoding module to obtain the vector to be classified output by the encoding module; Inputting the support set into the induction module to obtain a category vector set output by the induction module, wherein the category vector set includes at least one category vector, and each category vector corresponds to the classification label one by one; Inputting the vector to be classified and the category vector set into the relationship module to obtain the classification result output by the relationship module; The induction module includes a vector unit and a weighting unit; The step of inputting the support set into the induction module to obtain a category vector set output by the induction module includes: Inputting the support set into the vector unit to obtain an expert vector set output by the vector unit, wherein the expert vector set includes at least one expert vector, and each of the expert vectors corresponds one-to-one to a support sample in the support set; Inputting the expert vector set into a weighting unit, performing a weighting operation on the expert vector set based on a preset weighting formula, and obtaining an output category vector set of the weighting unit; The preset weighting formula includes an initial value formula, a threshold value formula and a category representation function; The initial value formula is: η i JRelu(e i W g +b g )4 The threshold value formula is: The category representation function is: Among them, η i represents the initial gate value corresponding to the i-th expert sample, Relu represents the ReLU activation function, and e i represents the expert vector corresponding to the i-th expert sample, W g represents the training parameters, b g represents the training parameters, g i represents the final gate value corresponding to the i-th expert sample, exp represents the exponential function, K represents that a category contains K samples, and c j Represents the category vector of the j-th category, i is a positive integer greater than or equal to 1, j is a positive integer greater than or equal to 1, and K is a positive integer greater than or equal to 1.

5. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the social media stress category detection method according to any one of claims 1 to 3 is implemented.

6. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the social media stress category detection method according to any one of claims 1 to 3 is implemented.

7. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the social media stress category detection method according to any one of claims 1 to 3 is implemented.

Citation Information

Patent Citations

  • Meta-learning-based target classification method and device, equipment and storage medium

    CN112613555A

  • Method and apparatus for meta few-shot leanrer

    GB202114806D0

  • System and method for automatically detecting depression symptoms of a social media user

    WO2021133157A1