An explainable depression detection method and system
By dynamically matching the optimal inference strategy and large language model through an adaptive selection mechanism, the problem of insufficient interpretability of existing depression detection methods is solved, and accurate prediction and personalized detection of depressive symptoms are achieved.
Patent Information
- Application Number
- CN202511021766.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-24
- Publication Date
- 2025-09-30
- Estimated Expiration
- 2045-07-24
AI Technical Summary
Existing depression detection methods lack the interpretability required by clinicians and are difficult to effectively promote in practical applications.
An adaptive selection mechanism is adopted to generate question-aware text representations through the Longformer encoder and attention mechanism. The hybrid expert network is combined to dynamically select the optimal inference strategy and large language model from a predefined pool of inference strategies and large language models, and the joint loss function is used to optimize the selection process.
It achieves accurate prediction of depressive symptoms, improves the interpretability and accuracy of detection, adapts to the personalized needs of different users, and overcomes the limitations of fixed reasoning models.
Smart Images

Figure CN120527003B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to an explainable depression detection method and system. Background Art
[0002] In recent years, researchers have increasingly focused on the role of social media data in analyzing mental health disorders. Numerous studies have demonstrated the significant value of user-generated content in identifying depression and other mental health disorders. Consequently, computational linguistics methods have been widely applied to depression detection. For example, the following technical solutions exist:
[0003] (1) Design a set of features to model the relationship between individual writing and depression, and then detect depression through machine learning methods.
[0004] (2) Combining the embedding of a pre-trained text model FastText with a hybrid classifier integrating convolutional neural networks and recurrent neural networks achieves high-precision depression detection.
[0005] However, these methods lack the interpretability required by clinicians, limiting their practical application. To bridge this gap, CLEF eRisk 2019 proposed a task focused on automatically predicting depression levels of social media users based on their writing content using the Beck Depression Inventory-II (BDI-II) questionnaire, which was continued in 2020 and 2021.
[0006] The goal of this invention is to predict the severity of each symptom in the Beck Depression Inventory-II (BDI-II) questionnaire based on the user's complete posting history and determine its overall severity according to the clinical classification scheme. Summary of the Invention
[0007] To address the above technical issues, the present invention provides an explainable depression detection method and system. Unlike traditional large language model-based methods (which typically employ fixed inference patterns and large language models), the present method implements an adaptive selection mechanism. Specifically, based on a user's posts and the depressive symptom to be predicted, the present invention automatically selects the most appropriate combination of inference strategy and large language model from a predefined pool to infer the severity of the user's symptom.
[0008] In order to solve the above technical problems, the present invention adopts the following technical solutions:
[0009] In a first aspect, the present invention provides an interpretable depression detection method, comprising:
[0010] Retrieving posts related to depressive symptoms from users’ social media histories;
[0011] Map each depressive symptom to the corresponding symptom question. Based on the post text corresponding to the symptom question, generate a question-aware text representation by fusing the Longformer encoder and the attention mechanism. Then, select the optimal reasoning strategy from the predefined reasoning strategy pool through the first hybrid expert network.
[0012] Based on the question-aware text representation and selected reasoning strategy, the second hybrid expert network selects the most suitable large language model from the predefined large language model pool;
[0013] Infer the severity of each depressive symptom of the user based on the selected inference strategy and large language model, and then calculate the severity of the user's overall depressive symptoms;
[0014] Among them, the inference strategy pool includes zero-shot inference strategy, few-shot inference strategy and thought chain inference strategy, and the large language model pool includes multiple heterogeneous large language models; the selection process of inference strategy and large language model is optimized by a joint loss function, and the joint loss function includes a main loss based on the deviation between the predicted value and the true label, and an auxiliary loss based on the usage frequency and average selection probability of each expert route in the two hybrid expert networks.
[0015] In one embodiment, retrieving posts related to depression symptoms from the user's social media history specifically includes:
[0016] The depressive symptoms in the Beck Depression Inventory II questionnaire are converted into query sentences. The pre-trained SBERT model is used to calculate the embedding vectors of the post and the query sentence of depressive symptoms. The cosine similarity between the embedding vectors is used To characterize the semantic similarity between posts and query sentences about depression symptoms :
[0017] ;
[0018] in, and Represents query statements respectively and candidate posts The embedding vector of represents the pre-trained SBERT model; the top K posts with the highest semantic similarity will be retained as posts related to depressive symptoms.
[0019] In one embodiment, mapping each depressive symptom to a corresponding symptom question, and generating a question-aware text representation based on the post text corresponding to the symptom question by fusing a Longformer encoder with an attention mechanism, specifically includes:
[0020] Connect the posts related to depression symptoms into post text, input the symptom questions and the corresponding post text into the Longformer encoder to obtain the symptom question representation and post text representation ; Use attention mechanism to integrate and , deriving question-aware text representation .
[0021] In one embodiment, selecting the optimal reasoning strategy from a predefined reasoning strategy pool through the first hybrid expert network specifically includes:
[0022] The strategy routing score of each strategy expert route in the first hybrid expert network is calculated by the inference gated network, and the probability distribution of the inference strategy is generated after the strategy expert route is screened by the strategy routing score, and the optimal inference strategy is output through sampling.
[0023] In one embodiment, the gated network is used to calculate the policy routing score of each policy expert route in the first hybrid expert network through inference, the policy expert routes are filtered by the policy routing score, and a probability distribution of the inference strategy is generated, and the optimal inference strategy is output through sampling. Specifically, the following steps are performed:
[0024] Each strategy expert route in the first hybrid expert network is expected to handle different categories of depressive symptoms and generate corresponding probability distributions for the selection of reasoning strategies; the reasoning gated network GR is used to capture the intrinsic characteristics of different symptom problems and calculate the strategy routing scores for all strategy expert routes to obtain the strategy routing score vector :
[0025] ;
[0026] ;
[0027] in, The symptom problem representation obtained by inputting the symptom problem into the Longformer encoder Sentence-level embedding function return A vector consisting of the highest k values in and the corresponding index vector , filter strategy expert routing subset :
[0028] ;
[0029] for The k-th policy expert routing in for The kth index in ; routing subset by policy expert Sentence-level embeddings for question-aware text representations Determine the probability distribution of the inference strategy :
[0030] ;
[0031] ;
[0032] Represents a vector After probability normalization, the result is represents the Softmax function, express The i-th element of is the randomly initialized embedding vector corresponding to the inference strategy pool, for The i-th policy expert routing in ;
[0033] Probability distribution based on inference strategy , determine the optimal inference strategy through sampling methods.
[0034] In one embodiment, each strategy expert routing in the first hybrid expert network is implemented by a neural network and a Softmax function, and the i-th strategy expert routing The output formula is:
[0035] ;
[0036] in, and yes The learnable parameters in Sentence-level embeddings for question-aware text representation, is the randomly initialized embedding vector corresponding to the inference strategy pool, represents the Softmax function, Indicates transpose.
[0037] In one embodiment, the reasoning strategy based on question-aware text representation and selection, which selects the most suitable large language model from a predefined large language model pool through a second hybrid expert network, specifically includes:
[0038] The problem-aware text representation and the selected inference strategy are taken as input, and the model gating network is used to generate the model routing score. After the large language model routing is filtered by the TopK function, the probability distribution of the large language model is calculated by splicing the input and learnable parameters, and the most suitable large language model is sampled and selected.
[0039] In one embodiment, the method uses the question-aware text representation and the selected inference strategy as input, generates a model routing score using a model gating network, filters the large language model routing using a TopK function, calculates the probability distribution of the large language model by concatenating the input and learnable parameters, and selects the most suitable large language model by sampling, specifically including:
[0040] Generate gate vectors using the model gating network GL , the gate vector Each element in is the model routing score of each large language model; based on ,application The function obtains the vector consisting of the first k model routing scores and a corresponding index vector; routing a set of large language models from a second hybrid expert network based on the index value in the index vector Filtering a large language model routing subset , and calculate the probability distribution of the large language model ;
[0041] ;
[0042] ;
[0043] Represents a vector After probability normalization, the result is represents the Softmax function, express The i-th element of Sentence-level embeddings for question-aware text representation, is the optimal inference strategy, is the randomly initialized embedding vector corresponding to the large language model pool, for The i-th large language model routing, , Represents a splicing operation, and yes The learnable parameters of represents transpose;
[0044] according to Sample the large language model and select the most suitable large language model.
[0045] In one embodiment, the inference strategy and the selection process of the large language model are optimized by a joint loss function, wherein the joint loss function includes a main loss based on the deviation between the predicted value and the true label and an auxiliary loss based on the usage frequency and average selection probability of each expert route in the two hybrid expert networks, specifically including:
[0046] Main loss for:
[0047] ;
[0048] ;
[0049] in, represents the training dataset, represents the reasoning strategy, represents the probability distribution of the inference strategy, represents a large language model used for inference, is the probability distribution of the large language model, is the query input to the large language model, is the corresponding true label; represents the reward function, Represents the process of reasoning using reasoning strategy r and reasoning model l;
[0050] Adding auxiliary loss To promote balanced utilization of expert routing within a hybrid expert network:
[0051] ;
[0052] ;
[0053] ;
[0054] in, is the number of expert routes in the hybrid expert network, is a batch in the training process, is the size of the batch, is the probability of routing the expert routing query x to the i-th expert routing; represents the average probability of routing the batch to the i-th expert routing, represents the average number of times the i-th expert route is selected in this batch; is an indicator function used to indicate whether the expert routing query x is routed to the i-th expert routing. If yes, it returns 1, otherwise it returns 0;
[0055] Joint Loss ;
[0056] in, is a hyperparameter used to balance the main loss and auxiliary loss.
[0057] In a second aspect, the present invention provides a computer system comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the method of any one embodiment of the first aspect when executing the computer program.
[0058] Compared with the prior art, the beneficial technical effects of the present invention are:
[0059] The present invention dynamically selects reasoning strategies and large language models through a hybrid expert network, adaptively matching the optimal processing combination for different symptom characteristics and post content, overcoming the limitations of fixed reasoning models; the routing balancing mechanism avoids overloading a small number of experts and ensures balanced processing capabilities for diversified queries. BRIEF DESCRIPTION OF THE DRAWINGS
[0060] Figure 1 4 is a flow chart of a method in an embodiment of the present invention.
[0061] Figure 2 Schematic diagram of the detection framework in an embodiment of the present invention.
[0062] Figure 3 Schematic diagram of the impact of hybrid expert network parameters on detection results in an embodiment of the present invention. DETAILED DESCRIPTION
[0063] A preferred embodiment of the present invention will be described in detail below with reference to the accompanying drawings.
[0064] like Figure 1 As shown, an interpretable depression detection method in the present invention comprises the following steps:
[0065] S1, retrieve posts related to depressive symptoms from users’ social media history;
[0066] S2 maps each depressive symptom to the corresponding symptom question. Based on the post text corresponding to the symptom question, a problem-aware text representation is generated by fusing the Longformer encoder and the attention mechanism. The first hybrid expert network selects the optimal reasoning strategy from the predefined reasoning strategy pool.
[0067] S3, based on question-aware text representation and selection reasoning strategy, selects the most suitable large language model from the predefined large language model pool through the second hybrid expert network;
[0068] S4, inferring the severity of each depressive symptom of the user based on the selected inference strategy and the large language model, and then calculating the severity of the user's overall depressive symptoms;
[0069] Among them, the inference strategy pool includes zero-shot inference strategy, few-shot inference strategy and thought chain inference strategy, and the large language model pool includes multiple heterogeneous large language models; the selection process of inference strategy and large language model is optimized by a joint loss function, and the joint loss function includes a main loss based on the deviation between the predicted value and the true label, and an auxiliary loss based on the usage frequency and average selection probability of each expert route in the two hybrid expert networks.
[0070] like Figure 2 As shown in Figure 1, the method of the present invention mainly includes the following three parts: (1) post retrieval: retrieving posts related to depressive symptoms from the user's entire post history; (2) inference method allocation: selecting the optimal inference strategy from a predefined inference strategy pool based on the depressive symptoms and the retrieved posts; (3) large language model selection: determining the most appropriate large language model from the large language model pool based on the post text and the selected inference strategy. Finally, based on the automatically selected inference strategy and large language model, the severity of the user's depressive symptoms is inferred.
[0071] Post retrieval: Considering the context length limitations of large language models and the presence of a large amount of content unrelated to depressive symptoms in user post history, this paper first extracts posts related to depressive symptoms from user post history through a retrieval process. First, the depressive symptoms in the Beck Depression Inventory-II (BDI-II) questionnaire are converted into query statements. In order to identify posts related to depressive symptoms, this paper uses the existing pre-trained SBERT model to calculate the embedding vectors of the posts and the query statements for depressive symptoms, and then calculates their semantic similarity through cosine similarity. :
[0072] ; (1)
[0073] in, and Represents query statements respectively and candidate posts The top K posts with the highest semantic similarity will be retained as posts related to depressive symptoms.
[0074] Reasoning method assignment: First determine the reasoning strategy, and then select the large language model. In order to select the appropriate reasoning strategy, each depression symptom needs to be mapped to its corresponding symptom question, such as Figure 2 As shown in Figure 2, the posts related to depression symptoms are connected into a unified text. Next, the symptom questions and their related post texts are input into the Longformer encoder to obtain the symptom question representation. and post text representation . Then, the attention mechanism is used to integrate and information, derive question-aware text representation . and The sentence-level embeddings are and , that is, the representation of their corresponding [CLS] tags.
[0075] At the same time, the present invention constructs an inference strategy pool containing multiple inference strategies, and the randomly initialized embedding vector corresponding to the inference strategy pool is recorded as .here, is the number of inference strategies, The vector dimension of the embedding vector for each inference strategy. A hybrid expert network is used to dynamically select the most appropriate inference strategy from the inference strategy pool. Specifically, the first hybrid expert network layer consists of strategy expert routing, denoted as , is a set of policy expert routes; each policy expert route is expected to specialize in processing different categories of depressive symptoms and generate a corresponding distribution for the selection of reasoning strategies.
[0076] Gating the network using an inference method Capture the intrinsic characteristics of different symptom problems and calculate the policy routing score for all policy expert routes to obtain the policy routing score vector :
[0077] ; (2)
[0078] ; (3)
[0079] Among them, the function return A vector consisting of the highest k values in and the corresponding index vector .
[0080] Used to select a subset of policy expert routes :
[0081] ; (4)
[0082] for The k-th policy expert routing in for The kth index in the first hybrid expert network; each policy expert routing It is implemented by a simple neural network followed by a Softmax function.
[0083] The i-th policy expert routing The output formula is:
[0084] ; (5)
[0085] in, , and Expert Routing The learnable parameters in .
[0086] Finally, the selected policy expert routing subset Sentence-level embeddings using question-aware text representations Determine the probability distribution of all available inference strategies in the inference strategy pool:
[0087] ; (6)
[0088] ; (7)
[0089] Probability distribution based on inference strategy , the inference strategy is determined by sampling method, and the strategy obtained by sampling is recorded as .
[0090] Large language model selection: After determining the inference strategy, the next step is to select an appropriate large language model for the current depressive symptoms. First, a model pool containing candidate large language models is constructed. The embedding vectors of these candidate large language models are generated by random initialization and are recorded as ,in Indicates the number of large language models, The dimension of the embedding vector of each candidate large language model. The second hybrid expert network selects the most suitable large language model from the predefined large language model pool.
[0091] To identify depressive symptom-specific large language model routing, sentence-level embeddings of question-aware text representations and the optimal inference strategy As input, use another large language model gating network Generate gating vector .based on ,application The function obtains the vector consisting of the first k model routing scores and the corresponding index vector.
[0092] The indices in the index vector are used to route the ensemble from the large language model. Select the top k large language model routes to form a set , the process is similar to formula (2), (3) and (4). Large language model routing The output is calculated as follows:
[0093] ; (8)
[0094] in Represents a splicing operation, and yes The learnable parameters.
[0095] Then the probability distribution of the candidate large language model is calculated:
[0096] ; (9)
[0097] . (10)
[0098] Finally, according to the probability distribution of the large language model The large language model is sampled. The sampled large language model and inference strategy are used to predict the severity of the user's depressive symptoms. Prompt templates for different inference strategies are shown in Tables 1 to 3. The underlined parts need to be filled in according to the specific content.
[0099] Table 1 Zero-shot inference strategy
[0100]
[0101] Table 2 Few-shot inference strategies
[0102]
[0103] Table 3 Thinking chain reasoning strategy
[0104]
[0105] The main loss of the present invention as follows:
[0106] ; (11)
[0107] . (12)
[0108] in, represents the training dataset, represents the reasoning strategy, Refers to large language models used for inference. It is a query input into the large language model, which is a sentence composed of a specially designed query template (such as the sentence in Table 1) and specific content. is the corresponding true label. The ideal performance is achieved by maximizing the probability of generating a label closer to the true label. The present invention uses the policy gradient algorithm to minimize the main loss .
[0109] The first hybrid expert network and the second hybrid expert network are collectively referred to as the hybrid expert network, and the strategy expert routing and the large language model routing are collectively referred to as the expert routing. The present invention adds an auxiliary loss in the training process. To promote the balanced utilization of expert routes within the hybrid expert network:
[0110] ; (13)
[0111] ; (14)
[0112] ; (15)
[0113] in, is the number of expert routes in the hybrid expert network, i.e., the number of policy expert routes in the first hybrid expert network or the number of large language model routes in the second hybrid expert network, is a batch in the training process, is the batch size, is the probability of routing expert routing query x to expert i, where expert routing query x is a feature vector.
[0114] Therefore, the joint loss function that needs to be minimized is as follows:
[0115] ; (16)
[0116] in is a hyperparameter used to balance the two losses.
[0117] During the post retrieval process, the present invention sets the number of posts corresponding to each depressive symptom to 5. In the process of allocating inference methods and selecting large language models, the present invention configures the maximum number of expert routes to 8, and selects 2 expert routes from them for inference strategies and large language model routes respectively. In the present invention, the large language model pool of the present invention includes Neural-chat-7b-v3-1, Qwen2.5-32b and LLaMA3-70b, and all models are from Ollama, an open source tool for managing and deploying LLM. The inference strategy pool includes three inference strategies: zero-shot, few-shot and chain of thought (CoT). The present invention sets the temperature to 0.1 during the inference process and configures hyperparameters during training. The α is 0.05, the learning rate is 0.01, and the maximum number of training rounds is set to 8. All experiments are performed on an A800 GPU.
[0118] The dataset used in the experiment of the present invention comes from the eRisk "Measuring Depression Severity" task, covering three versions in 2019, 2020, and 2021. The task requires the assessment of the severity of depression based on the user's social media posts and provides researchers with a complete posting history of each user. In addition, users are required to complete a standard depression questionnaire (ie, BDI-II). The questionnaire filled out by the user (ie, the true label) is used to evaluate the quality of the prediction results. In the present invention, the eRisk2020 dataset is used for training, and the eRisk2019 dataset and the eRisk2021 dataset are used as test sets.
[0119] Evaluation Metrics: This paper uses the same evaluation metrics as the eRisk benchmark to ensure a fair comparison with the baseline method. These metrics evaluate the quality of the system's questionnaire completion by comparing it with questionnaires completed by actual social media users. The four metrics used for evaluation are as follows:
[0120] (1) Average Hit Rate (AHR): The average hit rate is the average of the hit rates (HR) of all users. The hit rate is calculated as the proportion of cases where the system-generated questionnaire answers are the same as the actual questionnaire answers.
[0121] (2) Average Closeness Rate (ACR): The average closeness rate is the average of the closeness rates (CR) of all users. The closeness rate is used to calculate the closeness between the answers to the questionnaire filled in by the system and the answers to the questionnaire filled in by the user. The calculation formula is:
[0122] ; (17)
[0123] in, represents the maximum absolute difference, is the absolute difference between the two answers.
[0124] (3) Average difference in depression level (ADODL): The average difference in depression level is the average of the overall difference in depression level (DODL) of all users. DODL is used to calculate the degree of closeness between the overall depression level of the questionnaire filled in by the system and the questionnaire filled in by the user. The calculation formula is:
[0125] ; (18)
[0126] in, It represents the absolute difference between the true total score and the automatically generated total score. The maximum total score of the Beck Depression Inventory-Second Edition (BDI-II) questionnaire is 63.
[0127] (4) Depression category hit rate (DCHR): DCHR is used to calculate the percentage of correctly estimated depression severity.
[0128] Table 4 Comparison results of the method of the present invention and other methods on the eRisk2019 dataset.
[0129]
[0130] Table 5 Comparison results of the method of the present invention and other methods on the eRisk2021 dataset.
[0131]
[0132] In Tables 4 and 5, the best results are marked with a "*," and the suboptimal results are underlined. As shown in Tables 4 and 5, the proposed method achieved satisfactory results. In terms of questionnaire-level indicators, the proposed method outperformed other methods on both the eRisk2019 and eRisk2021 datasets, highlighting its effectiveness in assessing users' overall depression levels. A more in-depth analysis of the eRisk2021 dataset, which includes more samples, yielded the following conclusions: First, the proposed method significantly surpassed the average performance of non-large language model-based methods. This can be attributed to the powerful text understanding capabilities of large language models, highlighting their potential for this task. Second, the proposed method also demonstrated significant improvement over other large language model-based methods. This may be due to the proposed method's ability to adaptively select the most appropriate large language model and inference strategy based on user posts and depressive symptoms, thereby leveraging the advantages of different inference combinations. Furthermore, the proposed method also achieved good results on depressive symptom-level indicators, demonstrating its ability to effectively differentiate the severity of different depressive symptoms among users and demonstrating its potential for clinical application. This success is attributed to the hybrid expert network structure used in the method, which takes into account the heterogeneity between different depressive symptoms, thereby further optimizing the selection of inference strategies and large language models.
[0133] Table 6 The impact of different inference strategy pools on the performance of the method proposed in this invention.
[0134]
[0135] As shown in Table 6, the experimental results reveal the following three findings: First, performance degraded significantly when using a fixed inference strategy, highlighting its limitations when processing diverse inputs and emphasizing the importance of adaptively selecting the most appropriate inference strategy. Second, performance improved with increasing strategy diversity within the inference strategy pool, demonstrating the effectiveness of our approach in optimizing results using diverse strategies. Third, we found that few-shot inference performed the worst among the three methods, and removing it from the inference strategy pool resulted in the smallest performance drop. This may be attributed to the subjectivity of the Beck Depression Inventory-Second Edition (BDI-II) questionnaire—users who post similar content may receive different BDI-II scores, reducing the reference value of the provided examples.
[0136] Table 7. The impact of different large language model pools on the performance of the proposed method.
[0137]
[0138] As shown in Table 7, the experimental results verify the impact of different large language model pools on performance, and the following key conclusions are drawn: First, the present invention discovered a similar pattern to the inference strategy pool research, namely that the continuous use of a fixed large language model leads to suboptimal performance, which highlights the importance of adaptively selecting large language models. Second, the performance of different large language models is similar, but as their number increases, the performance shows a gradual improvement trend. This shows that different large language models have different advantages when processing different types of queries, which indirectly verifies the rationality of the present invention's method.
[0139] Table 8 Ablation studies of other components.
[0140]
[0141] To explore the impact of other key components in this method, we designed three different variants for experiments, as shown in Table 8. These variants include: (1) without mixture of experts (w / o MoE): removing the mixture of experts component and using two fixed routers to select the inference strategy and the large language model respectively; (2) without routers (w / o Routers): bypassing the adaptive selection of the router from the inference strategy pool and the large language model pool and replacing it with random selection; (3) without auxiliary loss (w / o ): Eliminate auxiliary losses during the optimization phase As shown in Table 8, ablation of each component results in a decrease in the evaluation metrics. Compared to the "no routing" variant, our method shows significant improvement, demonstrating its ability to handle diverse queries by adaptively selecting inference strategies and large language models. In addition, the combination of the hybrid expert network architecture and the corresponding auxiliary loss enables the model to select appropriate routes based on specific depressive symptoms, further improving performance.
[0142] In the present invention, the optimal parameter values for the maximum number n of shared expert routes and the number k of selected expert routes in the inference mode allocation process and the large language model selection process are determined through a series of experiments. Figure 3 (a) shows the effect of parameter k on performance when n=8: The results show that the performance first improves with the increase of k, reaches the optimal value when k=2, and then decreases as k continues to increase. Figure 3 (b) shows the effect of n on performance when k is fixed at 2, showing a similar trend: the performance is optimal when n = 8. Based on the above findings, in a preferred embodiment of the present invention, the maximum number of expert routes n is set to 8, and the number of selected expert routes k is set to 2.
[0143] The technical solution of the present invention is described in more detail below with reference to an embodiment.
[0144] Input: user’s posting history and depressive symptoms (sadness) from the Beck Depression Inventory-Second Edition (BDI-II) questionnaire.
[0145] Step 1: Retrieve posts related to depression symptoms (sadness) from the user’s posting history. The post contents are shown in Table 9.
[0146] Table 9
[0147]
[0148] Step 2: Choose an appropriate inference strategy:
[0149] In the reasoning style assignment process, the Chain of Thought (CoT) reasoning strategy was automatically selected based on the depressive symptom (sadness) and the posts related to the depressive symptoms obtained in step 1.
[0150] Step 3: Select an appropriate large language model: During the large language model selection process, a large language model (Qwen2.5-32b) is automatically selected based on the inference strategy obtained in step 2 and the posts related to depression symptoms and depression symptoms obtained in step 1.
[0151] Output: Using the selected large language model (Qwen2.5-32b) and reasoning strategy (CoT), and using the prompt words in Table 3, the severity of depressive symptoms is calculated (score: 2). Once the severity of all depressive symptoms in the BDI-II questionnaire is predicted, the overall severity of the user's depressive symptoms can be calculated using the BDI-II questionnaire's scoring rules.
[0152] It should be understood that although the steps in the flowcharts of the accompanying drawings are shown in sequence as indicated by the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and these steps can be executed in other orders. Moreover, at least some of the steps in the flowcharts of the accompanying drawings may include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times. The order of execution of these steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least a portion of the steps or stages in other steps.
[0153] In one embodiment, the present invention provides a computer system, which may be a server. The computer system includes a processor, a memory, and a network interface connected via a system bus. The processor of the computer system is used to provide computing and control capabilities. The memory of the computer system includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of the operating system and computer program in the non-volatile storage medium. The database of the computer system is used to store data used in the above method. The network interface of the computer system is used to communicate with an external terminal via a network connection. When the computer program is executed by the processor, the above method is implemented.
[0154] The technical features of the above embodiments can be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0155] It will be apparent to those skilled in the art that the present invention is not limited to the details of the exemplary embodiments described above and that the invention can be embodied in other specific forms without departing from the spirit or essential characteristics of the invention. Therefore, the embodiments should be considered in all respects as illustrative and non-limiting, and the scope of the invention is defined by the appended claims rather than the foregoing description. It is intended that all variations within the meaning and range of equivalents of the claims be embraced herein, and any reference signs in the claims should not be construed as limiting the claims to which they relate.
[0156] In addition, it should be understood that although this specification is described in terms of implementation methods, not every implementation method contains only one independent technical solution. This narrative method of the specification is only for the sake of clarity. Those skilled in the art should regard the specification as a whole. The technical solutions in each embodiment can also be appropriately combined to form other implementation methods that can be understood by those skilled in the art.
Claims
1. A method for detecting depression that can be explained, characterized in that include: Retrieving posts related to depressive symptoms from users’ social media histories; Map each depressive symptom to the corresponding symptom question. Based on the post text corresponding to the symptom question, generate a question-aware text representation by fusing the Longformer encoder and the attention mechanism. Then, select the optimal reasoning strategy from the predefined reasoning strategy pool through the first hybrid expert network. Based on the question-aware text representation and selected reasoning strategy, the second hybrid expert network selects the most suitable large language model from the predefined large language model pool; Infer the severity of each depressive symptom of the user based on the selected inference strategy and large language model, and then calculate the severity of the user's overall depressive symptoms; Among them, the inference strategy pool includes zero-shot inference strategy, few-shot inference strategy and thought chain inference strategy, and the large language model pool includes multiple heterogeneous large language models; the selection process of inference strategy and large language model is optimized by a joint loss function, and the joint loss function includes a main loss based on the deviation between the predicted value and the true label, and an auxiliary loss based on the usage frequency and average selection probability of each expert route in the two hybrid expert networks.
2. The method for detecting depression according to claim 1, wherein: The post related to depression symptoms is retrieved from the user's social media history, specifically including: The depressive symptoms in the Beck Depression Inventory II questionnaire are converted into query sentences. The pre-trained SBERT model is used to calculate the embedding vectors of the post and the query sentence of depressive symptoms. The cosine similarity between the embedding vectors is used To characterize the semantic similarity between posts and query sentences about depression symptoms : ; in, and Represents query statements respectively and candidate posts The embedding vector of represents the pre-trained SBERT model; the top K posts with the highest semantic similarity will be retained as posts related to depressive symptoms.
3. The method for detecting depression according to claim 1, wherein: The method maps each depressive symptom to a corresponding symptom question. Based on the post text corresponding to the symptom question, a problem-aware text representation is generated by fusing the Longformer encoder and the attention mechanism. Specifically, the following steps are performed: Connect the posts related to depression symptoms into post text, input the symptom questions and the corresponding post text into the Longformer encoder to obtain the symptom question representation and post text representation ; Use attention mechanism to integrate and , deriving question-aware text representation .
4. The method for detecting depression according to claim 1, wherein: The selecting the optimal reasoning strategy from the predefined reasoning strategy pool by the first hybrid expert network specifically includes: The strategy routing score of each strategy expert routing in the first hybrid expert network is calculated by the inference gated network, and the probability distribution of the inference strategy is generated after the strategy expert routing is screened by the strategy routing score, and the optimal inference strategy is output through sampling.
5. The method for detecting explainable depression according to claim 4, wherein: The gated network is used to calculate the policy routing scores of each policy expert route in the first hybrid expert network through inference, and the probability distribution of the inference strategy is generated after filtering the policy expert routes through the policy routing scores, and the optimal inference strategy is output through sampling, specifically including: Each strategy expert route in the first hybrid expert network is expected to handle different categories of depressive symptoms and generate corresponding probability distributions for the selection of reasoning strategies; the reasoning gated network GR is used to capture the intrinsic characteristics of different symptom problems and calculate the strategy routing scores for all strategy expert routes to obtain the strategy routing score vector : ; ; in, The symptom problem representation obtained by inputting the symptom problem into the Longformer encoder Sentence-level embedding function return A vector consisting of the highest k values in and the corresponding index vector , filter strategy expert routing subset : ; for The k-th policy expert routing in for The kth index in ; routing subset by policy expert and sentence-level embeddings for question-aware text representations Determine the probability distribution of the inference strategy : ; ; Represents a vector After probability normalization, the result is represents the Softmax function, express The i-th element of is the randomly initialized embedding vector corresponding to the inference strategy pool, for The i-th policy expert routing in ; Probability distribution based on inference strategy , determine the optimal inference strategy through sampling methods.
6. The method for detecting explainable depression according to claim 4, wherein: Each strategy expert routing in the first hybrid expert network is implemented by a neural network and a Softmax function. The i-th strategy expert routing The output formula is: ; in, and yes The learnable parameters in Sentence-level embeddings for question-aware text representation, is the randomly initialized embedding vector corresponding to the inference strategy pool, represents the Softmax function, Indicates transpose.
7. The method for detecting depression according to claim 1, wherein: The reasoning strategy based on question-aware text representation and selection selects the most suitable large language model from a predefined large language model pool through a second hybrid expert network, specifically including: The problem-aware text representation and the selected inference strategy are taken as input, and the model gating network is used to generate the model routing score. After the large language model routing is filtered by the TopK function, the probability distribution of the large language model is calculated by splicing the input and learnable parameters, and the most suitable large language model is sampled and selected.
8. The method for detecting explainable depression according to claim 7, wherein: The method takes the question-aware text representation and the selected inference strategy as input, uses the model gating network to generate the model routing score, and after filtering the large language model routing with the TopK function, calculates the probability distribution of the large language model by splicing the input and the learnable parameters, and samples and selects the most suitable large language model. Specifically, it includes: Generate gate vectors using the model gating network GL , the gate vector Each element in is the model routing score of each large language model; based on ,application The function obtains the vector consisting of the first k model routing scores and a corresponding index vector; routing a set of large language models from a second hybrid expert network based on the index value in the index vector Filtering a large language model routing subset , and calculate the probability distribution of the large language model ; ; ; Represents a vector After probability normalization, the result is represents the Softmax function, express The i-th element of Sentence-level embeddings for question-aware text representation, is the optimal inference strategy, is the randomly initialized embedding vector corresponding to the large language model pool, for The i-th large language model routing, , Represents a splicing operation, and yes The learnable parameters of represents transpose; according to Sample the large language model and select the most suitable large language model.
9. The method for detecting depression according to claim 1, wherein: The inference strategy and the selection process of the large language model are optimized by a joint loss function. The joint loss function includes a main loss based on the deviation between the predicted value and the true label and an auxiliary loss based on the usage frequency and average selection probability of each expert route in the two hybrid expert networks. Specifically, it includes: Main loss for: ; ; in, represents the training dataset, represents the reasoning strategy, represents the probability distribution of the inference strategy, represents a large language model used for inference, is the probability distribution of the large language model, is the query input to the large language model, is the corresponding true label; represents the reward function, Represents the process of reasoning using reasoning strategy r and reasoning model l; Adding auxiliary loss To promote balanced utilization of expert routing within a hybrid expert network: ; ; ; in, is the number of expert routes in the hybrid expert network, is a batch in the training process, is the size of the batch, is the probability of routing the expert routing query x to the i-th expert routing; represents the average probability of routing the batch to the i-th expert routing, represents the average number of times the i-th expert route is selected in this batch; is an indicator function used to indicate whether the expert routing query x is routed to the i-th expert routing. If yes, it returns 1, otherwise it returns 0; Joint Loss ; in, is a hyperparameter used to balance the main loss and auxiliary loss.
10. A computer system comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 9 are implemented.