A Text Detection Method for Depression Based on Semantic and Sentiment Adaptive Fusion

By constructing a depression recognition network and combining the BERT model, hierarchical semantic module, and emotion perception module, we achieved adaptive fusion of semantics and emotion in depression texts, thus improving the performance and interpretability of depression detection.

CN121506460BActive Publication Date: 2026-03-10ANHUI IND TECH INNOVATION RES INST +1
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2026-01-08
Publication Date
2026-03-10

AI Technical Summary

Technical Problem

Existing technologies for detecting text related to depression suffer from insufficient and non-adaptive integration of semantic and emotional cues, resulting in limited detection performance.

Method used

A depression recognition network is constructed. Text semantic features are extracted through a pre-trained BERT model. Multi-granularity feature extraction and emotion enhancement are performed by combining a hierarchical semantic module and an emotion perception module. Adaptive weighted fusion is performed using a feature fusion module. Finally, a classifier is used to detect depression.

Benefits of technology

It significantly improves the detection performance and interpretability of texts related to depression, enabling more accurate capture of the potential complex emotional states in the text, dynamically adjusting the contribution of semantic and emotional features, and generating more discriminative feature representations.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121506460B_ABST
    Figure CN121506460B_ABST
Patent Text Reader

Abstract

This invention provides a text detection method for depression based on adaptive fusion of semantics and sentiment. The method includes: acquiring the original text to be detected; inputting the original text into a trained depression recognition network to obtain a depression detection result. The depression recognition network includes a pre-trained BERT model, a hierarchical semantic module, a sentiment perception module, a feature fusion module, and a classifier. This invention captures implicit semantic dependencies in the text at multiple scales through the hierarchical semantic module, explicitly models word-level sentiment and constructs a sentiment association matrix through the sentiment perception module to enhance the perception of complex emotional states, and adaptively balances and fuses semantic and sentiment features through the feature fusion module, dynamically adjusting the contribution of the two types of information to generate a more discriminative comprehensive feature representation. This significantly improves the detection performance and model interpretability of texts related to depression.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of artificial intelligence model technology, and in particular to a text detection method for depression based on semantic and emotion adaptive fusion. Background Technology

[0002] Traditional methods for diagnosing depression primarily rely on clinical interviews and scales (such as the PHQ-9), which have limitations such as high subjectivity, time-consuming nature, and dependence on professionals. Furthermore, some patients fail to be diagnosed in a timely manner due to stigma associated with the illness or mild symptoms. With the widespread use of social media, users spontaneously express their emotions and experiences in massive amounts of text, providing a new data source and possibility for the early identification of depression. This makes text-based automated depression detection an important research direction in the field of mental health.

[0003] Existing machine learning-based detection methods typically rely on manually designed language features (such as LIWC and n-grams) combined with classifiers (such as SVM), but feature engineering is complex and generalization ability is limited. With the development of deep learning, methods based on CNN, RNN / LSTM, and pre-trained language models (such as BERT) can automatically learn text semantic representations, achieving significant performance improvements. However, these methods mainly focus on the semantic information of text and are insufficient in capturing the subtle, implicit, and dynamically changing emotional cues in the expression of depression, while emotional state is one of the core dimensions of depression. Existing research has attempted to incorporate emotional information, such as through emotional attention networks or multimodal fusion, but there are still significant shortcomings in fine-grained emotional intensity modeling, dynamic dependencies between emotional words, and adaptive deep fusion of semantics and emotion. Summary of the Invention

[0004] In view of the above-mentioned deficiencies of the prior art, the present invention provides a method for detecting depressive text based on semantic and emotional adaptive fusion, so as to solve the technical problems of insufficient and non-adaptive fusion of semantic and emotional cues in depressive text.

[0005] To achieve the above and other related objectives, this invention provides a text detection method for depression based on adaptive fusion of semantics and sentiment, comprising: acquiring the original text to be detected; inputting the original text into a trained depression recognition network to obtain a depression detection result, wherein the depression recognition network comprises: a pre-trained BERT model for encoding the original text to obtain a context embedding vector; a hierarchical semantic module for extracting multi-granular semantic features from the context embedding vector and performing hierarchical fusion to obtain hierarchical semantic features; a sentiment perception module for predicting the sentiment intensity and polarity of each word based on the context embedding vector, constructing a sentiment correlation matrix based on the sentiment intensity and polarity, and using the sentiment correlation matrix to perform sentiment enhancement processing on the context embedding vector to obtain sentiment perception features; a feature fusion module for adaptively weighting and fusing the hierarchical semantic features and the sentiment perception features to obtain a first fusion feature; and a classifier for classifying based on the first fusion feature to obtain a depression detection result.

[0006] In one embodiment of the present invention, the hierarchical semantic module obtains the hierarchical semantic features through the following steps: performing multi-granularity feature extraction and fusion on the context embedding vector to obtain a second fused feature; using a state-space model Mamba layer to perform long-distance semantic dependency modeling on the second fused feature to obtain a long-range semantic feature; concatenating the second fused feature with the long-range semantic feature, and performing a fully connected projection on the concatenated feature to obtain the hierarchical semantic features.

[0007] In one embodiment of the present invention, multi-granularity feature extraction and fusion are performed on the context embedding vector to obtain a second fused feature, including: performing a convolution operation on the context embedding vector using a multi-granularity convolution unit to extract three semantic features with different spans; performing attention interaction on the three semantic features with different spans using a cross-granularity attention unit to obtain attention-enhanced features; concatenating the three semantic features with different spans using a residual fusion unit, performing linear projection through a fully connected layer to obtain residual projection features, and adding and activating the attention-enhanced features and the residual projection features to obtain the second fused feature.

[0008] In one embodiment of the present invention, the emotion perception module obtains the emotion perception features through the following steps: predicting the emotion intensity value and emotion polarity value of each word in the text sequence based on the context embedding vector; constructing an emotion correlation matrix based on the predicted emotion intensity value and emotion polarity value; using the emotion correlation matrix, performing emotion enhancement processing on the context embedding vector through a dual-branch path; and fusing the outputs of the dual-branch path to obtain the emotion perception features.

[0009] In one embodiment of the present invention, predicting the sentiment intensity value and sentiment polarity value of each word in a text sequence based on the context embedding vector includes: inputting the context embedding vector into a state space model Mamba layer for sequence modeling; inputting the output of the Mamba layer into a multilayer perceptron to predict a sentiment intensity value and a sentiment polarity value for each word.

[0010] In one embodiment of the present invention, an emotion correlation matrix is ​​constructed based on predicted emotion intensity values ​​and emotion polarity values, including: calculating the intensity interaction value between word pairs based on the emotion intensity values ​​of all words; calculating the polarity similarity between word pairs based on the emotion polarity values ​​of all words; combining the intensity interaction value and the polarity similarity to obtain a regular emotion correlation matrix; inputting the emotion intensity value and emotion polarity value of each word into a multilayer perceptron for transformation, and obtaining a learnable emotion correlation matrix through the interaction of transformation vectors between word pairs; and weighted summing the regular emotion correlation matrix and the learnable emotion correlation matrix to obtain the emotion correlation matrix.

[0011] In one embodiment of the present invention, the context embedding vector is subjected to sentiment enhancement processing through a dual-branch path using the sentiment correlation matrix, including: weighting the context embedding vector with the sentiment correlation matrix, and then inputting the weighted result into the Mamba layer of the state space model for processing to obtain the first branch output; inputting the context embedding vector into the Mamba layer of the state space model for processing, and then weighting the processing result with the sentiment correlation matrix to obtain the second branch output.

[0012] In one embodiment of the present invention, the feature fusion module obtains the first fused feature through the following steps: performing pooling operations on the hierarchical semantic features and the sentiment perception features respectively to obtain pooled hierarchical semantic features and pooled sentiment perception features; calculating adaptive fusion weights based on the pooled hierarchical semantic features and pooled sentiment perception features; and using the adaptive fusion weights to perform weighted fusion of the pooled hierarchical semantic features and pooled sentiment perception features to obtain the first fused feature.

[0013] In one embodiment of the present invention, an adaptive fusion weight is calculated based on the pooled hierarchical semantic features and the pooled sentiment perception features, including: concatenating the pooled hierarchical semantic features and the pooled sentiment perception features; inputting the concatenated features into a fully connected layer, and then normalizing them using the Softmax function to output the adaptive fusion weight.

[0014] In one embodiment of the present invention, the total loss function of the depression recognition network during the training process is calculated according to the following formula:

[0015] ,

[0016] ,

[0017] In the formula, L total L cls L emo These are the total loss function, the binary cross-entropy loss function, and the sentiment loss function, respectively, with λ being the balance coefficient; N matched Let be the number of matching words in the external sentiment dictionary, M be the set of indices for the matching words, and s be the number of matching words. i and p i These represent the predicted sentiment intensity and sentiment polarity values, respectively. and Supervision labels provided for the external sentiment dictionary.

[0018] The beneficial effects of this invention are as follows: This invention proposes a text detection method for depression based on adaptive fusion of semantics and sentiment. This method achieves accurate detection of depression cues in the original text by constructing a depression recognition network. First, a hierarchical semantic module captures sparse and implicit semantic dependencies in the text at multiple scales. Second, an sentiment perception module explicitly models the sentiment intensity and polarity of each word and constructs a sentiment correlation matrix to capture the sentiment associations between words, effectively enhancing the model's ability to perceive potential and complex emotional states in the text. Finally, a feature fusion module adaptively balances and fuses semantic and sentiment features, enabling the model to dynamically adjust the contribution of the two types of information according to different text characteristics, thereby generating a more discriminative comprehensive feature representation. This method significantly improves the detection performance of depression text and the interpretability of the model. Attached Figure Description

[0019] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the accompanying drawings used in the description of the embodiments or the prior art will be briefly introduced below. The accompanying drawings are incorporated in and constitute a part of this specification, illustrating embodiments consistent with this application, and are used together with the description to explain the principles of this application. Obviously, the drawings described below are merely some embodiments of the present invention, and those skilled in the art can obtain other drawings based on these drawings without creative effort.

[0020] Figure 1 This is an architecture diagram of a depression recognition network provided in an embodiment of the present invention;

[0021] Figure 2 This is an architecture diagram of a hierarchical semantic module provided in an embodiment of the present invention;

[0022] Figure 3This is an architecture diagram of an emotion perception module provided in an embodiment of the present invention;

[0023] Figure 4 This is an architecture diagram of a feature fusion module provided in an embodiment of the present invention. Detailed Implementation

[0024] The following specific embodiments illustrate the implementation of the present invention. Those skilled in the art can easily understand other advantages and effects of the present invention from the content disclosed in this specification. It should be noted that, unless otherwise specified, the following embodiments and features can be combined with each other. In addition to the specific methods, equipment, and materials used in the embodiments, based on the knowledge of the prior art and the description of the present invention by those skilled in the art, any prior art methods, equipment, and materials similar to or equivalent to the methods, equipment, and materials in the embodiments of the present invention can be used to implement the present invention.

[0025] It should be understood that the terminology used in the embodiments of this invention is for describing specific particular implementations and not for limiting the scope of protection of this invention. Unless otherwise defined, all technical and scientific terms used in this invention have the same meaning as commonly understood by one of ordinary skill in the art.

[0026] In the following description, numerous details are explored to provide a more thorough explanation of embodiments of the invention. However, it will be apparent to those skilled in the art that embodiments of the invention may be practiced without these specific details. In some embodiments, well-known structures and devices are shown in block diagram form rather than in detail to avoid obscuring embodiments of the invention.

[0027] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functions, and operations that may be implemented in the methods and computer program products according to various embodiments of the present invention. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.

[0028] An embodiment of the present invention provides a text detection method for depression based on semantic and emotion adaptive fusion, including steps 1.1 and 1.2.

[0029] Step 1.1: Obtain the raw text to be tested. The raw text may come from user-posted content, comments, or logs on social media platforms. This text is usually unstructured, conversational, and short, and may contain sentences expressing emotions, describing experiences, or stating opinions. It is a primary data source for depression detection.

[0030] Step 1.2: Input the original text into the trained depression recognition network to obtain the depression detection result. This depression recognition network is the innovation of this invention; simply inputting the original text into the trained network allows it to output a depression detection result. The detection result can be, for example, labels (such as yes / no; or severe, moderate, mild, none), or a score (such as 0-1 points, with higher scores indicating greater severity).

[0031] Please see Figure 1 , Figure 1 The diagram illustrates the overall architecture of the depression recognition network, which includes a pre-trained BERT model (i.e., Figure 1 The BERT model consists of a pre-trained encoder, a hierarchical semantic module, a sentiment perception module, a feature fusion module, and a classifier. The pre-trained BERT model encodes the original text to obtain context embedding vectors. The hierarchical semantic module extracts multi-granular semantic features from the context embedding vectors and performs hierarchical fusion to obtain hierarchical semantic features. The sentiment perception module predicts the sentiment intensity and polarity of each word based on the context embedding vectors, constructs a sentiment relevance matrix based on the sentiment intensity and polarity, and uses the sentiment relevance matrix to enhance the sentiment of the context embedding vectors, obtaining sentiment perception features. The feature fusion module adaptively weights and fuses the hierarchical semantic features and sentiment perception features to obtain the first fused feature. The classifier classifies the text based on the first fused feature to obtain the depression detection result.

[0032] In this embodiment, the innovation of the network architecture lies in the systematic integration and enhancement of two key types of information: semantics and sentiment. The BERT encoder provides a powerful basic contextual representation. Building upon this, the hierarchical semantic module captures hierarchical semantic patterns from local to global through multi-granularity convolution and cross-granularity attention, and introduces Mamba layers to efficiently model long sequence dependencies. The sentiment perception module innovatively predicts word-level sentiment and constructs a sentiment matrix, modulating the original features in a two-branch manner. The feature fusion module ultimately fuses the two types of enhanced features in an adaptive manner. This design enables the network not only to understand what the text "says" (semantics) but also to perceive how the text "feels" (sentiment), and to dynamically adjust the importance of both according to the context, thus possessing a stronger ability to recognize the expression patterns of depression, which are often intertwined with semantics and sentiment.

[0033] In this embodiment, the pre-trained BERT (Bidirectional Encoder Representations from Transformers) model is a deep bidirectional language representation model based on the Transformer architecture. It has been pre-trained on massive general-purpose corpora through tasks such as masked language modeling, demonstrating powerful language understanding and feature extraction capabilities. In this invention, the BERT model serves as the initial feature extractor of the network. Its input is the original text sequence after word segmentation and the addition of special tokens (such as [CLS], [SEP]), and its output is the context-related embedding vector (i.e., context embedding vector E) corresponding to each word (Token) in the sequence. During training, a fine-tuning strategy is typically employed, meaning that the parameters of the BERT model participate in gradient updates and optimization along with the parameters of subsequent custom modules to better adapt it to the specific task of detecting text related to depression.

[0034] Please see Figure 2 In a specific embodiment of the present invention, the hierarchical semantic module obtains hierarchical semantic features through steps 2.1 to 2.3.

[0035] Step 2.1: Perform multi-granularity feature extraction and fusion on the context embedding vector to obtain the second fused feature.

[0036] In a specific embodiment of the present invention, step 2.1 includes steps 2.1.1 to 2.1.3.

[0037] Step 2.1.1: Perform convolution operations on the context embedding vector using multi-granularity convolutional units to extract semantic features of three different spans. In this step, multi-granularity convolution is first applied to the context embedding vector E to obtain representations of different word spans, i.e., F. c2 F c3 and F c4Cross-granularity interaction enhances semantic consistency across different scales and strengthens the representation of subtle semantic dependencies distributed throughout the text. Specifically, this step is achieved through parallel one-dimensional convolutions with different kernel sizes (e.g., kernel sizes of 2, 3, and 4).

[0038] Step 2.1.2: Utilize cross-granularity attention units to perform attention interactions on semantic features of three different granularities to obtain attention-enhanced features F. attn This step can be expressed by the formula:

[0039] ,

[0040] In the formula, F c2 F c3 and F c4 Let Q be the query, K be the key, and V be the value, with Attn representing the multi-head self-attention mechanism. Cross-granularity interaction achieves information alignment and captures key dependencies by performing multi-head attention computation on multi-granularity representations.

[0041] Step 2.1.3: After concatenating the three semantic features with different spans using the residual fusion unit, linear projection is performed through a fully connected layer to obtain the residual projection feature. The attention enhancement feature is then added to the residual projection feature and activated to obtain the second fused feature. In this step, the residual projection feature is F... proj The second fusion feature, F1, can be expressed by the formula:

[0042] ,

[0043] ,

[0044] In the formula, SiLU is the activation function. This operation constitutes a residual learning unit. The attention-enhanced feature F... attn The residual projection characteristic after linear projection, i.e., F proj The purpose of this addition is to preserve the cross-granularity interaction information extracted through the attention mechanism while retaining the details of the original multi-scale features through shortcut connections. This helps alleviate the gradient vanishing problem in deep networks and promotes the fusion and reuse of information from different levels of features, ensuring that the network can stably learn effective hierarchical semantic representations. The SiLU activation function further introduces non-linearity, enhancing the model's expressive power.

[0045] Step 2.2: Use the Mamba layer of the state-space model to model the long-distance semantic dependency of the second fused feature to obtain long-range semantic features.

[0046] In this step, the State Space Model (SSM) Mamba layer is a novel sequence modeling architecture. Compared to traditional Recurrent Neural Networks (RNNs) or Transformers, Mamba theoretically has linear computational complexity and can efficiently capture long-range dependencies. It models sequences through state-space equations and utilizes structured matrices and hardware-aware algorithms for efficient computation. The Mamba layer is introduced in this module to perform global, long-range contextual semantic optimization on the initially fused features F1, aiming to capture semantic cues that may be scattered over a long range in depressive texts and overcome the limitation of limited local receptive fields in traditional CNNs. The long-range semantic features obtained after this step are termed F2.

[0047] Step 2.3: Concatenate the second fused feature F1 with the long-range semantic feature F2, and perform a fully connected projection on the concatenated feature to obtain the hierarchical semantic feature F. sem This step is the final integration stage of the hierarchical semantic module. F1, containing local multi-granularity interaction information, is concatenated with F2, containing global long-range dependency information, aiming to fuse local details with global structure. Subsequently, a fully connected layer is used for projection, which on the one hand reduces and integrates the concatenated high-dimensional features, and on the other hand learns an optimal linear combination, thereby generating the final hierarchical semantic feature F that combines fine-grained semantic awareness and long-range contextual understanding. sem .

[0048] Please see Figure 3 In a specific embodiment of the present invention, the emotion perception module obtains emotion perception features through steps 3.1 to 3.4.

[0049] Step 3.1: Based on the context embedding vector, predict the sentiment intensity and sentiment polarity of each word in the text sequence.

[0050] In a specific embodiment of the present invention, step 3.1 includes: (1) inputting the context embedding vector into the state space model Mamba layer for sequence modeling, which can be expressed by the formula F=Mamba(E); (2) inputting the output F of the Mamba layer into a multilayer perceptron to predict an emotional intensity value and an emotional polarity value for each word (also called a token), which can be expressed by the formula: [s i ,p i =MLP(F). In this step, under weak supervision of an external sentiment lexicon (such as SentiWordNet, VADER), a sentiment intensity value s is predicted for each word. i and emotional polarity value p i , where s i ∈[0,1], p i∈[-1,1].

[0051] Step 3.2: Construct an emotion correlation matrix based on the predicted emotion intensity and emotion polarity values.

[0052] In a specific embodiment of the present invention, step 3.2 includes steps 3.2.1 to 3.2.5.

[0053] Step 3.2.1: Based on the sentiment intensity values ​​of all words, calculate the intensity interaction value I between word pairs. ij This can be expressed as a formula:

[0054] .

[0055] Step 3.2.2: Calculate the polarity similarity P between word pairs based on the sentiment polarity values ​​of all words. ij It can be expressed by the formula:

[0056] .

[0057] Step 3.2.3: Combine the intensity interaction value with the polarity similarity to obtain the rule-based sentiment association matrix A. rule It can be expressed by the formula:

[0058] .

[0059] Step 3.2.4: Input the sentiment intensity value and sentiment polarity value of each word into a multilayer perceptron for transformation, and obtain the learnable sentiment association matrix A through the interaction of transformation vectors between word pairs. learn It can be expressed by the formula:

[0060] ,

[0061] In this step, the MLP receives the sentiment prediction pair for each word [s]. i ,p i As input, it is mapped to a learnable scalar feature e. i (This involves compressing 2D sentiment features into a 1D implicit representation). During interaction computation, this feature sequence is transformed into column vectors (L*1) and row vectors (1*L). Based on the outer product principle, e is calculated via a broadcast mechanism. i ×e j By iterating through all possible (i,j) combinations, a complete L*L learnable sentiment association matrix is ​​finally generated.

[0062] Step 3.2.5: Sum the regular sentiment correlation matrix and the learnable sentiment correlation matrix using a weighted sum to obtain the sentiment correlation matrix A, which can be expressed by the formula:

[0063] ,

[0064] In the formula, α is the learnable weight of the balancing rule component and the learning component, and its initial value can be set to, for example, 0.5, and then it learns on its own.

[0065] Step 3.3: Using the sentiment correlation matrix, perform sentiment enhancement processing on the context embedding vector through a dual-branch path.

[0066] In a specific embodiment of the present invention, step 3.3 includes: (1) performing a weighted operation on the context embedding vector and the sentiment correlation matrix, and then inputting the weighted result into the Mamba layer of the state space model for processing to obtain the first branch output; (2) inputting the context embedding vector into the Mamba layer of the state space model for processing, and then performing a weighted operation on the processing result and the sentiment correlation matrix to obtain the second branch output. Both branches involve the Mamba layer of the state space model and the weighting operation, the difference being the processing order of these two operations.

[0067] This dual-branch design offers two complementary perspectives on sentiment enhancement. The first branch (weighted then Mamba) essentially "filters" or "focuses" the raw input with sentiment-related information, emphasizing the emotionally important parts, before performing sequence modeling, thus guiding the model with sentiment during the encoding stage. The second branch (Mamba then weighted) first performs conventional semantic sequence modeling to obtain context-aware feature representations, then "modulates" or "recalibrates" them using the sentiment matrix. The combination of these two sequences ensures that sentiment information guides both the feature extraction process and optimizes the representation of extracted features, thereby achieving more comprehensive and robust sentiment enhancement.

[0068] Step 3.4: Fuse the outputs of the two-branch paths to obtain the emotion perception feature F. emo The fusion process in this step can, for example, involve feature splicing.

[0069] Please see Figure 4 In a specific embodiment of the present invention, the feature fusion module obtains the first fused feature F through steps 4.1 to 4.3. fused .

[0070] Step 4.1: Perform pooling operations on the hierarchical semantic features and sentiment perception features respectively to obtain the pooled hierarchical semantic features and pooled sentiment perception features. Specifically, the pooling operation is mean pooling along the sequence dimension, and the pooled hierarchical semantic features are F. sem_pool The pooled emotion perception feature is F emo_pool。

[0071] Step 4.2: Calculate adaptive fusion weights based on the pooled hierarchical semantic features and the pooled sentiment perception features.

[0072] In a specific embodiment of the present invention, step 4.2 includes: (1) concatenating the pooled hierarchical semantic features and the pooled sentiment perception features; (2) inputting the concatenated features into a fully connected layer, then normalizing them using the Softmax function, and outputting adaptive fusion weights. This step can be expressed by the formula:

[0073] ,

[0074] In the formula, Concat represents concatenation, Linear represents a fully connected layer, Softmax represents the activation function, and the resulting adaptive fusion weights are two: and .

[0075] Step 4.3: Use adaptive fusion weights to perform weighted fusion of the pooled hierarchical semantic features and the pooled sentiment perception features to obtain the first fused feature. This step can be expressed by the formula:

[0076] .

[0077] The core of the feature fusion module lies in its adaptive weighting mechanism. Instead of simply concatenating or averaging semantic and sentiment features, this module uses a learnable weighting network to dynamically evaluate the contribution of semantic and sentiment information based on the specific content of the current sample. and For example, for texts with strong logic and subtle emotional expression, the semantic weight α1 may be higher; for texts with strong emotional expression and relatively simple semantics, the emotional weight α2 may be higher. This adaptability allows the model to flexibly cope with the diversity of depressive texts, achieve better feature fusion, and thus improve the decision quality of the classifier.

[0078] A classifier typically consists of one or more fully connected layers, whose input is the first fused feature F output by the feature fusion module. fused The output dimension of the last fully connected layer corresponds to the number of categories (e.g., 2 neurons for a binary classification task). Typically, a softmax function is applied to convert the output into a predicted probability distribution for each category. In the binary classification task for depression detection in this invention, the classifier output can be, for example, a probability value representing the confidence level that the input text belongs to the depression category. The final binary classification result is obtained by comparing this value with a preset threshold (e.g., 0.5).

[0079] In a specific embodiment of the present invention, the above-mentioned depression recognition network needs to be trained, and the training steps are roughly as follows: (1) constructing a dataset; (2) constructing a depression recognition network; (3) training the depression recognition network using the dataset. During training, the constructed depression recognition network is trained end-to-end using an annotated depression text dataset. The training adopts a multi-task joint optimization strategy, and the overall goal is to minimize the total loss function composed of the weighted sum of the main classification loss and the sentiment auxiliary loss. Through the backpropagation algorithm, the gradient of the total loss simultaneously updates all learnable parameters of the pre-trained BERT model, the hierarchical semantic module, the sentiment perception module, the feature fusion module, and the classifier. This training method makes the sentiment perception task and the main classification task mutually reinforcing: the sentiment module provides higher quality sentiment features for the main task, while the gradient of the main task also guides the sentiment module to learn more useful sentiment representations for depression detection.

[0080] In a specific embodiment of the present invention, the total loss function of the depression recognition network during the training process is calculated according to the following formula:

[0081] ,

[0082] In the formula, L total L cls L emo These represent the total loss function, the binary cross-entropy loss function, and the sentiment loss function, respectively. λ is a balancing coefficient used to adjust the impact of sentiment supervision on the optimization of the main task, enabling dynamic joint training across multiple tasks. A multi-task joint optimization strategy is adopted, integrating the training objectives of the main task classification and the sentiment perception auxiliary task to ensure that the model progresses synergistically between semantics and sentiment.

[0083] The main task classification uses the binary cross-entropy loss function, the expression of which is as follows:

[0084] ,

[0085] In the formula, y represents the actual label. This represents the model's predicted probability. The loss function is jointly driven by features extracted from the hierarchical semantic module, the sentiment perception module, and the feature fusion module, which helps integrate multi-source information and improve the model's ability to discriminate expressions of depressive tendencies.

[0086] The emotion perception auxiliary task uses an emotion loss function, the expression of which is as follows:

[0087] ,

[0088] In the formula, N matched Let be the number of matching words in the external sentiment dictionary, M be the set of indices for the matching words, and s be the number of matching words. i and p iThese represent the predicted sentiment intensity and sentiment polarity values, respectively. and Supervision tags are provided for external sentiment dictionaries. In the sentiment perception module, weak supervision signals are introduced to supervise sentiment intensity and polarity.

[0089] It should be noted that the steps of the various methods described above are only for clarity. In practice, they can be combined into one step or some steps can be split into multiple steps. As long as they contain the same logical relationship, they are all within the scope of protection of this application. Adding insignificant modifications or introducing insignificant designs to the algorithm or process, but without changing the core design of the algorithm and process, are also within the scope of protection of this patent.

[0090] The above embodiments are merely illustrative of the principles and effects of the present invention and are not intended to limit the invention. Any person skilled in the art can modify or alter the above embodiments without departing from the spirit and scope of the present invention. Therefore, all equivalent modifications or alterations made by those skilled in the art without departing from the spirit and technical concept disclosed in the present invention should still be covered by the claims of the present invention.

Claims

1. A depression text detection method based on semantic and emotional adaptive fusion, characterized in that, The method comprises the following steps: obtaining an original text to be detected; inputting the original text into a trained depression recognition network to obtain a depression detection result, wherein the depression recognition network comprises: a pre-trained BERT model for encoding the original text to obtain a context embedding vector; a hierarchical semantic module for extracting multi-granularity semantic features from the context embedding vector and performing hierarchical fusion to obtain hierarchical semantic features; an emotion perception module for predicting the sentiment intensity and polarity of each word based on the context embedding vector, constructing an emotion-related matrix based on the sentiment intensity and polarity, and performing emotion enhancement processing on the context embedding vector using the emotion-related matrix to obtain emotion perception features; a feature fusion module for adaptively weighting and fusing the hierarchical semantic features and the emotion perception features to obtain first fused features; and a classifier for classifying based on the first fused features to obtain a depression detection result; The emotion perception module obtains the emotion perception features by the following steps: based on the context embedding vector, predicting the sentiment intensity value and sentiment polarity value of each word in the text sequence; based on the predicted sentiment intensity value and sentiment polarity value, constructing an emotion-related matrix; using the emotion-related matrix, performing emotion enhancement processing on the context embedding vector through a double-branch path; fusing the outputs of the double-branch path to obtain the emotion perception features; based on the predicted sentiment intensity value and sentiment polarity value, constructing an emotion-related matrix, comprising: Based on the sentiment intensity values for all the words, the intensity interaction values I between pairs of words are computed ij , which is expressed in formula as ; Based on the sentiment polarity values of all the words, the polarity similarity P between the word pairs is calculated ij , which can be expressed by the formula as follows: ; Combining the intensity interaction value and the polarity similarity, a rule sentiment correlation matrix A is obtained rule , which can be expressed by formula as ; The sentiment intensity value and the sentiment polarity value of each word are input into a multi-layer perceptron for transformation, and a learnable sentiment correlation matrix A is obtained through interaction of the transformation vectors between word pairs learn , which can be expressed by a formula as ; The rule sentiment correlation matrix and the learnable sentiment correlation matrix are weighted and summed to obtain the sentiment correlation matrix A, which can be expressed by a formula as follows: In the formula, a is a learnable weight for balancing the rule component and the learning component. using the emotion-related matrix, performing emotion enhancement processing on the context embedding vector through a double-branch path, comprising: performing weighting operation on the context embedding vector and the emotion-related matrix, and then inputting the weighted result into a state space model Mamba layer for processing to obtain a first branch output; inputting the context embedding vector into a state space model Mamba layer for processing, and then performing weighting operation on the processing result and the emotion-related matrix to obtain a second branch output.

2. The depression text detection method based on semantic and sentiment self-adaptive fusion according to claim 1, characterized in that, The hierarchical semantic module obtains the hierarchical semantic features by the following steps: performing multi-granularity feature extraction and fusion on the context embedding vector to obtain second fused features; using a state space model Mamba layer to model long-distance semantic dependencies of the second fused features to obtain long-range semantic features; concatenating the second fused features and the long-range semantic features, and performing full connection projection on the concatenated features to obtain the hierarchical semantic features. 3.The depression text detection method based on semantic and sentiment self-adaptive fusion according to claim 2, characterized in that, performing multi-granularity feature extraction and fusion on the context embedding vector to obtain second fused features, comprising: performing convolution operation on the context embedding vector using a multi-granularity convolution unit to extract semantic features of three different spans; performing attention interaction on the semantic features of the three different spans using a cross-granularity attention unit to obtain attention-enhanced features; The three different span semantic features are spliced by using a residual fusion unit, linear projection is performed on the spliced features by a full connection layer to obtain residual projection features, the attention enhanced features and the residual projection features are added and activated to obtain the second fusion features. 4.The depression text detection method based on semantic and sentiment self-adaptive fusion according to claim 1, characterized in that, Based on the context embedding vector, the sentiment intensity value and the sentiment polarity value of each word in the text sequence are predicted, including: The context embedding vector is input into a state space model Mamba layer for sequence modeling. The output of the Mamba layer is input into a multi-layer perceptron to predict a sentiment intensity value and a sentiment polarity value for each word respectively.

5. The method of claim 1, wherein the method further comprises: The feature fusion module obtains the first fusion features by the following steps: The hierarchical semantic features and the sentiment perception features are respectively subjected to a pooling operation to obtain pooled hierarchical semantic features and pooled sentiment perception features. Based on the pooled hierarchical semantic features and the pooled sentiment perception features, adaptive fusion weights are calculated. The pooled hierarchical semantic features and the pooled sentiment perception features are weighted fused by using the adaptive fusion weights to obtain the first fusion features.

6. The depression text detection method based on semantic and sentiment self-adaptive fusion according to claim 5, characterized in that, Based on the pooled hierarchical semantic features and the pooled sentiment perception features, adaptive fusion weights are calculated, including: The pooled hierarchical semantic features and the pooled sentiment perception features are spliced. The spliced features are input into a full connection layer, and then normalized by a Softmax function to output the adaptive fusion weights. 7.The depression text detection method based on semantic and sentiment self-adaptive fusion according to claim 1, characterized in that, The total loss function of the depression recognition network in the training process is calculated according to the following formula: , , In the formula, L total , L cls , L emo are a total loss function, a binary cross-entropy loss function, and a sentiment loss function, respectively, λ is a balance coefficient; N matched is the number of matching words in an external sentiment dictionary, M is an index set of the matching words, s i and p i respectively represent a sentiment intensity value and a sentiment polarity value predicted by a model, and are supervised labels provided by the external sentiment dictionary.

Citation Information

Patent Citations

  • Feature fusion method and device based on attention multi-granularity mechanism, equipment and medium

    CN120744821A

  • Multi-task emotion recognition method for embedding fine-grained image blocks

    CN121074952A