Mental health monitoring method and system based on time sequence knowledge graph reasoning
Through the method based on timing knowledge graph reasoning, a static knowledge graph with rich timestamp information is constructed and the Mamba model is used for timing reasoning, which solves the data adaptability and memory usage problems of existing mental health monitoring systems, and realizes high-precision and real-time personalized mental health monitoring.
Patent Information
- Application Number
- CN202510544282.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-28
- Publication Date
- 2025-08-08
AI Technical Summary
The existing mental health monitoring system is insufficient in continuously learning and adapting to new data, and it is difficult to dynamically adjust based on new data and user feedback. In addition, traditional models use too much memory when processing large-scale data, lack real-time and personalized services, and cannot effectively adapt to the diversity and variation of psychological data.
Through the method of inference based on time-series knowledge graph, mental illness types are obtained and pre-trained models are fine-tuned, static knowledge graphs are constructed and timestamp information is added. A prompt diagram is generated using the sliding time window method, input it into the prompt diagram encoder and time-series reasoning is performed through the Mamba model to obtain the mental health prediction results.
It improves the accuracy and practicality of mental health monitoring, can reflect changes in patients' psychological state in real time, capture dynamic evolution, and provide personalized real-time monitoring services.
Smart Images

Figure CN120452698A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of mental health monitoring technology, and in particular to a mental health monitoring method and system based on temporal knowledge graph reasoning. Background Art
[0002] Temporal knowledge graph reasoning methods use analysis and reasoning based on temporal knowledge graphs to predict or complete missing facts or possible future events. Mental health issues such as depression and anxiety have a serious impact on patients' quality of life and social functioning. Traditional mental health monitoring methods rely primarily on clinicians' experience and standardized psychological assessment tools, but these methods have limitations such as high subjectivity and a lack of dynamic monitoring. In recent years, with the development of artificial intelligence technology, temporal knowledge graphs and deep learning models have been widely used in the medical field, providing new ideas for the dynamic monitoring of mental health. Temporal knowledge graph reasoning for mental health monitoring aims to predict the relationship between nodes that have not yet appeared in the temporal knowledge graph. Traditional temporal knowledge graph reasoning often includes methods based on graph neural networks, time series decomposition, and deep reinforcement learning. Among them, the graph neural network-based method uses graph neural networks (GNNs) to model the knowledge graph to capture the complex relationship between nodes and relationships, including R-GCN, RE-GCN, EvoKG, etc. In temporal knowledge graph reasoning for mental health monitoring, GNN methods usually use the attribute features and time information of nodes for training and prediction; the time series decomposition method uses time series decomposition technology to decompose the knowledge graph, converting it into nodes and relationships with time properties, and then uses time series prediction methods to predict the relationship between future nodes. Common time series decomposition methods include STL, HATS, TBATS, etc.; the deep reinforcement learning-based method regards the knowledge graph reasoning task as a Markov decision process (MDP) and learns the optimal strategy to infer missing facts. For example, methods such as TPath, TAgent, and TITer learn multi-hop interpretable paths by utilizing the symbolic combination and transmission of relationships.
[0003] However, existing mental health monitoring systems are deficient in continuous learning and adapting to new data, making it difficult to dynamically adjust based on new data and user feedback. Traditional models consume too much memory when processing large-scale data, especially on hardware such as GPUs and TPUs, where memory bottlenecks become a key factor limiting model performance. In mental health monitoring, most monitoring systems rely on traditional questionnaires or face-to-face interviews, lacking real-time and personalized services. Psychological data is characterized by diversity and variability. For example, the attributes and relationships of the same entity may change at different time points, requiring inference and prediction models to adapt to such changes and diversity.
[0004] Therefore, traditional mental health monitoring methods often have problems with low monitoring accuracy and low practicality due to their inability to adapt to new data and the diversity and changes in data. Summary of the Invention
[0005] Based on this, in order to solve the above technical problems, a mental health monitoring method and system based on temporal knowledge graph reasoning is provided, which can improve the accuracy and practicality of mental health monitoring.
[0006] A mental health monitoring method based on temporal knowledge graph reasoning, the method comprising:
[0007] Obtaining a type of mental illness, inputting the type of mental illness into a pre-trained model, and fine-tuning parameters in the pre-trained model based on labeled data of the type of mental illness to obtain a large language model;
[0008] Collecting patient conversation data, inputting the conversation data into the large language model to extract entities and relationships, and constructing a static knowledge graph based on the entities and relationships;
[0009] Adding timestamp information to the nodes and edges in the static knowledge graph, and constructing a time series knowledge graph using a sliding time window method based on the static knowledge graph after adding the timestamp information;
[0010] Generate a prompt graph for each time window in the temporal knowledge graph, and input the prompt graph into a prompt graph encoder to obtain a prompt representation for each time step;
[0011] The prompt representation of each time step is input into the Mamba model, and temporal reasoning is performed through the Mamba model to obtain a mental health prediction result.
[0012] In one embodiment, obtaining a mental illness type, inputting the mental illness type into a pre-trained model, and fine-tuning parameters in the pre-trained model based on labeled data of the mental illness type to obtain a large language model include:
[0013] Collect the input mental illness type through the display interface, and search for the corresponding pre-trained model based on the mental illness type;
[0014] Determining labeled data for the mental illness type, and inputting the mental illness type into the pre-trained model;
[0015] The pre-trained model is fine-tuned using the labeled data to obtain a large language model.
[0016] In one embodiment, patient conversation data is collected and input into the large language model to extract entities and relationships, and a static knowledge graph is constructed based on the entities and relationships, including:
[0017] Collecting the patient's conversation data through a chat interface and performing data preprocessing on the conversation data;
[0018] Inputting the preprocessed conversation data into the large language model, extracting key entities through the large language model, and identifying semantic relationships between the entities;
[0019] Data cleaning is performed on each of the entities and relationships, and the cleaned entities and relationships are visualized in the form of nodes and edges to construct a static knowledge graph.
[0020] In one embodiment, a time series knowledge graph is constructed using a sliding time window method based on a static knowledge graph after adding timestamp information, including:
[0021] Based on the timestamp information, the data in the target time period is taken as a time window, and each time window is determined based on the static knowledge graph after the timestamp information is added;
[0022] Each of the time windows is grouped into a subgraph, and a temporal knowledge graph with each time subgraph is constructed by sliding the time window.
[0023] In one embodiment, generating a prompt graph for each time window in the temporal knowledge graph includes:
[0024] Find example facts and extract contextual information from a temporal knowledge graph with various temporal subgraphs;
[0025] Integrate the example facts and context information into a subgraph as an initial prompt graph;
[0026] Timestamp information is added to each node and edge in the initial hint graph, and the entities and relationships in the initial hint graph are mapped to predefined tags using the same tokenization method to generate a final hint graph.
[0027] In one embodiment, the prompt map is input into a prompt map encoder to obtain a prompt representation for each time step, including:
[0028] Inputting the prompt graph into a prompt graph encoder, encoding the prompt graph through a message passing neural network in the prompt graph encoder to obtain a prompt representation for each time step;
[0029] Wherein, the prompt is represented as time series data.
[0030] In one embodiment, the prompt representation of each time step is input into a Mamba model, and temporal reasoning is performed using the Mamba model, including:
[0031] The prompt representation of each time step is input into the Mamba model, and the dynamic changes in the time dimension are captured by the Mamba model to complete the temporal reasoning.
[0032] In one embodiment, the Mamba model is used to perform temporal reasoning to obtain a mental health prediction result, including:
[0033] Performing temporal reasoning through the Mamba model and outputting temporal reasoning results;
[0034] Based on the temporal reasoning results, the prompt representation of the time step is mapped to the output space through the output matrix to obtain the entity and relationship prediction results based on the temporal knowledge graph as the mental health prediction results.
[0035] A mental health monitoring system based on temporal knowledge graph reasoning, the system comprising:
[0036] A model fine-tuning module is used to obtain the type of mental illness, input the type of mental illness into a pre-trained model, and fine-tune the parameters of the pre-trained model based on the labeled data of the mental illness type to obtain a large language model;
[0037] A static knowledge graph construction module is used to collect patient conversation data, input the conversation data into the large language model to extract entities and relationships, and construct a static knowledge graph based on the entities and relationships;
[0038] A temporal knowledge graph construction module is used to add timestamp information to the nodes and edges in the static knowledge graph, and to construct a temporal knowledge graph using a sliding time window method based on the static knowledge graph after adding the timestamp information;
[0039] A prompt graph generation module is used to generate a prompt graph for each time window in the temporal knowledge graph, and input the prompt graph into a prompt graph encoder to obtain a prompt representation for each time step;
[0040] The reasoning and prediction module is used to input the prompt representation of each time step into the Mamba model, perform temporal reasoning through the Mamba model, and obtain a mental health prediction result.
[0041] In one embodiment, the model fine-tuning module is also used to collect the input type of mental illness through the display interface, and search for the corresponding pre-trained model based on the mental illness type; determine the labeled data of the mental illness type, and input the mental illness type into the pre-trained model; use the labeled data to fine-tune the parameters of the pre-trained model to obtain a large language model.
[0042] The above-mentioned mental health monitoring method and system based on temporal knowledge graph reasoning identifies entities and relationships through a fine-tuned large language model. Since the large language model has powerful language understanding and generation capabilities, it can improve the accuracy and efficiency of entity and relationship extraction; by adding timestamp information to the static knowledge graph, a denser temporal knowledge graph can be generated, so that missing data can be filled. The temporal knowledge graph can reflect changes in the patient's mental state in real time and capture the dynamic evolution of the mental state, providing a new perspective and tool for mental health monitoring; by generating a prompt graph and using the Mamba model for temporal reasoning, the time series information of nodes and edges can be encoded, thereby improving prediction accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] Figure 1 This is an application environment diagram of a mental health monitoring method based on temporal knowledge graph reasoning in one embodiment;
[0044] Figure 2 1 is a flowchart of a method for monitoring mental health based on temporal knowledge graph reasoning in one embodiment;
[0045] Figure 3 A flowchart of a mental health monitoring method based on temporal knowledge graph reasoning is obtained in another embodiment;
[0046] Figure 4 This is a structural block diagram of a mental health monitoring system based on temporal knowledge graph reasoning in one embodiment;
[0047] Figure 5 Schematic diagram of an application framework of a mental health monitoring system based on temporal knowledge graph reasoning in one embodiment;
[0048] Figure 6 FIG. 1 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0049] In order to make the purpose, technical solutions and advantages of this application more clear, the following further describes this application in detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain this application and are not intended to limit this application.
[0050] The mental health monitoring method based on temporal knowledge graph reasoning provided in the embodiment of the present application can be applied to Figure 1 In the application environment shown. Figure 1 As shown, the application environment includes a computer device 110. The computer device 110 can obtain mental illness types, input the mental illness types into a pre-trained model, and fine-tune the parameters of the pre-trained model based on the labeled data of the mental illness types to obtain a large language model. The computer device 110 can collect patient conversation data and input the conversation data into the large language model to extract entities and relationships, and construct a static knowledge graph based on the entities and relationships. The computer device 110 can add timestamp information to nodes and edges in the static knowledge graph and use a sliding time window method to construct a temporal knowledge graph based on the static knowledge graph with timestamp information. The computer device 110 can generate a prompt graph for each time window in the temporal knowledge graph and input the prompt graph into a prompt graph encoder to obtain a prompt representation for each time step. The computer device 110 can input the prompt representation of each time step into a Mamba model, perform temporal reasoning using the Mamba model, and obtain a mental health prediction result. The computer device 110 can be, but is not limited to, various personal computers, laptops, smartphones, robots, tablets, and other devices.
[0051] In one embodiment, Figure 2 As shown, a mental health monitoring method based on temporal knowledge graph reasoning is provided, which includes the following steps:
[0052] Step 202: Obtain the type of mental illness, input the type of mental illness into the pre-trained model, and fine-tune the parameters in the pre-trained model based on the labeled data of the mental illness type to obtain a large language model.
[0053] The computer device can obtain the type of mental illness diagnosed by the doctor based on the user's personal input, and use this as a prompt to input into pre-trained models with good performance in the mental health field, such as GPT-4 and LLaMA. The pre-trained model can then be fine-tuned using labeled data from the mental health field to ensure that the model can accurately identify relevant symptoms and behaviors.
[0054] In one embodiment, a mental health monitoring method based on temporal knowledge graph reasoning is provided, which may also include a process of fine-tuning the model. The specific process includes: collecting the input mental illness type through the display interface, and searching for the corresponding pre-trained model according to the mental illness type; determining the labeled data of the mental illness type, and inputting the mental illness type into the pre-trained model; using the labeled data to fine-tune the parameters of the pre-trained model to obtain a large language model.
[0055] The computer device can obtain the type of mental illness diagnosed by the doctor and input it as a prompt into the pre-trained model. Specifically, the computer device can collect the doctor's diagnosis results through the user interface, such as the user input "depression". The computer device then selects a pre-trained model that performs well in the mental health field, such as LLaMA. The pre-trained model is then fine-tuned using annotated data from the mental health field to ensure that the model can accurately identify relevant symptoms and behaviors.
[0056] In this embodiment, it is assumed that the labeled dataset where X i is the input text, Y i is for the symptom label. The fine-tuning objective function can be expressed as: Among them, f θ It is a parameterized model (such as a neural network) whose parameters are θ; x i is the i-th input text (such as the patient's conversation text, symptom description, etc.); y i is the true symptom label of the i-th sample, that is, the correct value predicted by the expected model.
[0057] Step 204: Collect patient conversation data, input the conversation data into a large language model to extract entities and relationships, and construct a static knowledge graph based on the entities and relationships.
[0058] Computer equipment can collect patients' daily conversation data through a chat interface, analyze chat content, identify entities related to mental illness (symptoms, behaviors, etc.) and causal relationships, integrate the extracted entities and relationships into a knowledge graph, and form a structured knowledge system stored in the Neo4j graph database.
[0059] In one embodiment, a mental health monitoring method based on temporal knowledge graph reasoning is provided, which may also include a process of constructing a static knowledge graph. The specific process includes: collecting the patient's conversation data through a chat interface and performing data preprocessing on the conversation data; inputting the preprocessed conversation data into a large language model, extracting key entities through the large language model, and identifying the semantic relationships between each entity; performing data cleaning on each entity and relationship, visualizing the cleaned entities and relationships in the form of nodes and edges, and constructing a static knowledge graph.
[0060] The computer device can collect daily conversation data from users and construct a static knowledge graph. Specifically, the computer device can collect daily conversation data from patients through a chat interface. For example, a user in the chat interface enters the following data: "I feel very tired and depressed today, and I don't want to go out." A pre-trained model can then be used to extract key entities and relationships. Example output: entity [depression, fatigue], relationship [depression leads to fatigue]. The computer device can integrate the extracted entities and relationships into a knowledge graph and store them in a Neo4j graph database. Example: Graph = {Nodes: {depression, fatigue}, Edges: {depression → fatigue}}.
[0061] Step 206: add timestamp information to the nodes and edges in the static knowledge graph, and construct a temporal knowledge graph using a sliding time window method based on the static knowledge graph after adding the timestamp information.
[0062] The computer device can add timestamps and construct a temporal knowledge graph. Specifically, the computer device can add timestamp information to each node and edge of the static knowledge graph. For example: Temporal Graph = {Nodes: {depression, fatigue}, Edges: {depression → fatigue}, Timestamps: {2024-10-01 10:00:00}}. The timestamp information formula is: Next, the computer device can use the sliding time window method to construct the temporal knowledge graph, constructing the data of each time window into a subgraph.
[0063] In one embodiment, a mental health monitoring method based on temporal knowledge graph reasoning is provided, which may also include a process of constructing a temporal knowledge graph. The specific process includes: taking the data in the target time period as a time window based on the timestamp information, and determining each time window based on the static knowledge graph after adding the timestamp information; forming each time window into a subgraph, and constructing a temporal knowledge graph with each time subgraph by sliding the time window.
[0064] Computers can add timestamp information to each node and edge of a static knowledge graph. Using a sliding time window approach, chat data over a period of time is treated as a time window, and emotional events occurring within that time are grouped into subgraphs. By continuously sliding the time window backwards, a temporal knowledge graph with subgraphs for psychological monitoring is constructed.
[0065] Step 208: Generate a prompt graph for each time window in the temporal knowledge graph, and input the prompt graph into the prompt graph encoder to obtain a prompt representation for each time step.
[0066] In each time series knowledge graph, the knowledge graph of each time window can be regarded as a static KG. The computer device can generate a hint graph for each time window to capture the entity and relationship information of that time step.
[0067] In one embodiment, a mental health monitoring method based on temporal knowledge graph reasoning is provided, which may also include a process of generating a prompt graph. The specific process includes: searching for example facts and extracting context information from a temporal knowledge graph having various temporal subgraphs; integrating the example facts and context information into a subgraph as an initial prompt graph; adding timestamp information to each node and edge in the initial prompt graph, and using the same tokenization method to map the entities and relationships in the initial prompt graph to predefined tags to generate a final prompt graph.
[0068] The generation of the hint graph follows the KG-ICL approach, which involves sampling facts related to the query and extracting their subgraphs as hint graphs. The core of the KG-ICL approach is to sample facts related to the query and extract their subgraphs as hint graphs. Assuming the knowledge graph is G and the query is q, the generation process of the hint graph Gq can be expressed as: Gq = Sample(G, q).
[0069] Specifically, in this embodiment, the computer device can select an example fact c = (u, q, v, t) related to the query relationship from the subgraph within the current time window. For example, it can select an emotion change event shown by the user within the time window, where u is the user, q is the emotion change relationship, v is the target emotional state, and t is the timestamp.
[0070] Next, the computer device can extract contextual information, specifically the paths related to emotional changes, such as the user's path from anxiety to depression, and the interactive relationships related to these emotions. The example facts and their contextual information are then integrated into a subgraph as the prompt graph G. prompt . The node collection E of the prompt graph pmt Defined as: r represents the edge; the edge set R of the prompt graph pmt Defined as:
[0071] in,
[0072] T is the subgraph within the current time window.
[0073] The computer device can add timestamp information to each node and edge in the prompt graph so that the model can capture the temporal dynamics. The timestamp can be used as an attribute of the node or edge, such as (u, t u ) and (r, t r). Then, a unified tokenization method can be used to map the entities and relations in the prompt graph to predefined tags. Entity tagging is based on the shortest path length from the entity to the subject and object of the example. The specific expression can be: tokenize(e) = [dist(u,e),dist(v,e),t e ]; e represents a node. Relationship tagging is based on whether the relationship is the same as the query relationship, where same(r,q)=1 if r=q, otherwise 0. The specific expression can be: tokenize(r)=[same(r,q),t r ]; Finally, we get the prompt G prompt =(E pmt , R pmt , T pmt ).
[0074] In one embodiment, a mental health monitoring method based on temporal knowledge graph reasoning is provided, which may also include a process of encoding a prompt graph. The specific process includes: inputting the prompt graph into a prompt graph encoder, encoding the prompt graph through a message passing neural network in the prompt graph encoder, and obtaining a prompt representation for each time step; wherein the prompt representation is time series data.
[0075] The computer device can input the prompt map of each time window into the prompt map encoder of KG-ICL to obtain the prompt representation of each time step, which can be regarded as time series data.
[0076] Specifically, the prompt image encoder can encode the prompt image through a message passing neural network (MPNN).
[0077] Among them, each node e∈E pmt and edge r∈R pmt are initialized to a vector representation, including time information:
[0078] The expression for entity update can be expressed as:
[0079]
[0080] The expression for relation update can be expressed as: After L layers of message passing, the final representation of each node and edge is: h e (L) and h r (L) , get the encoded prompt graph representation h prompt .
[0081] In step 210 , the prompt representation of each time step is input into the Mamba model, and temporal reasoning is performed through the Mamba model to obtain a mental health prediction result.
[0082] Computer devices can input prompt representations of multiple time steps into the Mamba model to capture dynamic changes in the time dimension, and use Mamba's output as the input of the KG-ICL reasoning module to initialize the representation of entities and relationships and perform temporal knowledge graph reasoning.
[0083] In one embodiment, a mental health monitoring method based on temporal knowledge graph reasoning is provided, which may also include a process of performing temporal reasoning. The specific process includes: inputting the prompt representation of each time step into the Mamba model, capturing the dynamic changes in the time dimension through the Mamba model, and completing the temporal reasoning.
[0084] Each time window has a corresponding prompt graph. For multiple time steps, the generated prompt graph representation can be input into a time series model for temporal reasoning. In the Mamba model, time series encoding is implemented using a selective structured state space model.
[0085] In another embodiment, a mental health monitoring method based on temporal knowledge graph reasoning is provided, which may also include a process of performing temporal reasoning, and the specific process includes: performing temporal reasoning through the Mamba model and outputting the temporal reasoning results; based on the temporal reasoning results, mapping the prompt representation of the time step to the output space through the output matrix, and obtaining entity and relationship prediction results based on the temporal knowledge graph as mental health prediction results.
[0086] In this embodiment, for each time step t in the time series, the state h T The update formula can be expressed as: t+1 =e AΔ h t +(1-e AΔ )Bh prompt,t ; The final time series representation h seq is the state h of the last time step T :h seq =Mamba(h prompt,1 ,h prompt,2 ,…,h prompt,T ).
[0087] In the Mamba model, the inference output R pred The time series is represented by the output matrix C h seqMapping to output space: R pred =Ch seq Among them, C is the output matrix, which controls the influence of the state on the output. pred It is the entity and relationship prediction result based on temporal graph reasoning. For example, it can predict whether a patient will experience more anxiety or depression symptoms in the future.
[0088] In this application, a mental health monitoring method based on temporal knowledge graph reasoning is provided, which can improve the accuracy and practicality of predictions. Specifically, by adding time information to the static knowledge graph, a denser temporal knowledge graph can be generated, so that missing data can be filled, thereby improving the accuracy of the model; traditional graph-based prediction models have difficulty handling the dynamic evolution of nodes and edges, while the use of temporal knowledge graphs can encode the time series information of nodes and edges into the model, thereby improving the prediction accuracy of the model; the use of temporal knowledge graphs can capture the time evolution trends of nodes and edges, which can better reflect the timeliness of psychological data, thereby improving the practicality of predictions.
[0089] In one embodiment, a mental health monitoring method based on temporal knowledge graph reasoning is provided. Figure 3 As shown, the specific process includes:
[0090] Fine-tune the pre-trained model using labeled data from the mental health field, and input the acquired disease information as prompts into the large language model.
[0091] Obtain chat data, use the fine-tuned large language model to extract entities and relationships, integrate them into the knowledge graph, and store them in the Neo4j graph database;
[0092] Add timestamp information to each node and edge of the static knowledge graph and use a sliding window to construct a temporal knowledge subgraph;
[0093] Prompt graph generation: using the TKG-ICL model based on KG-ICL to generate prompt graphs;
[0094] The generated prompt graph representation is input into the Mamba model for temporal reasoning to obtain the final prediction result.
[0095] In this embodiment, the powerful language understanding and generation capabilities of the large language model are utilized to significantly improve the accuracy and efficiency of entity and relationship extraction; the temporal knowledge graph can reflect changes in the patient's mental state in real time and capture the dynamic evolution of the mental state, providing a new perspective and tool for mental health monitoring; the prompt graph mechanism of KG-ICL can adapt to the structural differences of different TKGs and improve the generalization ability of the reasoning model; through the Mamba model, dynamic changes in the time dimension can be efficiently captured, which is suitable for temporal knowledge graph reasoning.
[0096] It should be understood that, although the various steps in the above flow chart are shown in sequence as indicated by the arrows, these steps are not necessarily performed 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 performed in other orders. Moreover, at least a portion of the steps in the above flow chart may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily performed at the same time, but can be performed at different times, and the execution order of these sub-steps or stages is not necessarily to be performed in sequence, but can be performed in turn or alternately with other steps or at least a portion of the sub-steps or stages of other steps.
[0097] In one embodiment, Figure 4 As shown, a mental health monitoring system based on temporal knowledge graph reasoning is provided, including: a model fine-tuning module 410, a static knowledge graph construction module 420, a temporal knowledge graph construction module 430, a prompt graph generation module 440 and an inference prediction module 450, wherein:
[0098] A model fine-tuning module 410 is configured to obtain a mental illness type, input the mental illness type into a pre-trained model, and fine-tune the parameters of the pre-trained model based on the labeled data of the mental illness type to obtain a large language model;
[0099] Static knowledge graph construction module 420 is used to collect patient conversation data, input the conversation data into a large language model to extract entities and relationships, and construct a static knowledge graph based on the entities and relationships;
[0100] A time series knowledge graph construction module 430 is used to add timestamp information to nodes and edges in a static knowledge graph, and to construct a time series knowledge graph using a sliding time window method based on the static knowledge graph after adding timestamp information;
[0101] A prompt graph generation module 440 is used to generate a prompt graph for each time window in the temporal knowledge graph and input the prompt graph into a prompt graph encoder to obtain a prompt representation for each time step;
[0102] The reasoning and prediction module 450 is used to input the prompt representation of each time step into the Mamba model, perform temporal reasoning through the Mamba model, and obtain a mental health prediction result.
[0103] In one embodiment, the model fine-tuning module 410 is also used to collect the input mental illness type through the display interface, and search for the corresponding pre-trained model based on the mental illness type; determine the labeled data of the mental illness type, and input the mental illness type into the pre-trained model; use the labeled data to fine-tune the parameters of the pre-trained model to obtain a large language model.
[0104] In one embodiment, the static knowledge graph construction module 420 is also used to collect patient conversation data through a chat interface and perform data preprocessing on the conversation data; input the preprocessed conversation data into a large language model, extract key entities through the large language model, and identify the semantic relationships between various entities; perform data cleaning on various entities and relationships, and visualize the cleaned entities and relationships in the form of nodes and edges to construct a static knowledge graph.
[0105] In one embodiment, the temporal knowledge graph construction module 430 is also used to treat the data within the target time period as a time window based on the timestamp information, and determine each time window based on the static knowledge graph after adding the timestamp information; each time window is grouped into a subgraph, and a temporal knowledge graph with each time subgraph is constructed by sliding the time window.
[0106] In one embodiment, the prompt graph generation module 440 is also used to find example facts and extract context information from a temporal knowledge graph having various time subgraphs; integrate the example facts and context information into a subgraph as an initial prompt graph; add timestamp information to each node and edge in the initial prompt graph, and use the same tokenization method to map entities and relationships in the initial prompt graph to predefined tags to generate a final prompt graph.
[0107] In one embodiment, the prompt graph generation module 440 is further configured to input the prompt graph into a prompt graph encoder, encode the prompt graph through a message passing neural network in the prompt graph encoder, and obtain a prompt representation for each time step; wherein the prompt representation is time series data.
[0108] In one embodiment, the inference prediction module 450 is further configured to input the prompt representation of each time step into the Mamba model, and to capture dynamic changes in the time dimension through the Mamba model to complete temporal reasoning.
[0109] In one embodiment, the reasoning and prediction module 450 is also used to perform temporal reasoning through the Mamba model and output the temporal reasoning results; based on the temporal reasoning results, the prompt representation of the time step is mapped to the output space through the output matrix to obtain the entity and relationship prediction results based on the temporal knowledge graph as the mental health prediction results.
[0110] In one embodiment, the mental health monitoring system based on temporal knowledge graph reasoning can also be applied to Figure 5 In the system framework shown in Figure 5 As shown, the system architecture can include three modules: acquiring a temporal knowledge graph in the field of mental health, encoding a temporal knowledge graph in the field of mental health, and reasoning about a temporal knowledge graph in the field of mental health, which are used to construct a temporal knowledge graph, encode a temporal knowledge graph, and reason about a temporal knowledge graph, respectively.
[0111] In one embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as follows: Figure 6 As shown. The computer device includes a processor, memory, network interface, display screen and input device connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a mental health monitoring method based on temporal knowledge graph reasoning is implemented. The display screen of the computer device can be a liquid crystal display or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a button, trackball or touchpad provided on the computer device casing, or an external keyboard, touchpad or mouse, etc.
[0112] Those skilled in the art will understand that Figure 6 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.
[0113] In one embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the steps of the mental health monitoring method based on temporal knowledge graph reasoning are implemented.
[0114] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the mental health monitoring method based on temporal knowledge graph reasoning are implemented.
[0115] Those skilled in the art will appreciate that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0116] 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.
[0117] The above-described embodiments merely represent several implementation methods of the present application. While the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the present invention. It should be noted that a person skilled in the art could make various modifications and improvements without departing from the spirit of the present application, all of which fall within the scope of protection of the present application. Therefore, the scope of protection of the present patent application shall be determined by the appended claims.
Claims
1. A mental health monitoring method based on temporal knowledge graph reasoning, characterized in that: The method comprises: Obtaining a type of mental illness, inputting the type of mental illness into a pre-trained model, and fine-tuning parameters in the pre-trained model based on labeled data of the type of mental illness to obtain a large language model; Collecting patient conversation data, inputting the conversation data into the large language model to extract entities and relationships, and constructing a static knowledge graph based on the entities and relationships; Adding timestamp information to the nodes and edges in the static knowledge graph, and constructing a time series knowledge graph using a sliding time window method based on the static knowledge graph after adding the timestamp information; Generate a prompt graph for each time window in the temporal knowledge graph, and input the prompt graph into a prompt graph encoder to obtain a prompt representation for each time step; The prompt representation of each time step is input into the Mamba model, and temporal reasoning is performed through the Mamba model to obtain a mental health prediction result.
2. The mental health monitoring method based on temporal knowledge graph reasoning according to claim 1 is characterized in that: Obtaining a mental illness type, inputting the mental illness type into a pre-trained model, and fine-tuning the parameters of the pre-trained model based on the labeled data of the mental illness type to obtain a large language model, including: Collect the input mental illness type through the display interface, and search for the corresponding pre-trained model based on the mental illness type; Determining labeled data for the mental illness type, and inputting the mental illness type into the pre-trained model; The pre-trained model is fine-tuned using the labeled data to obtain a large language model.
3. The mental health monitoring method based on temporal knowledge graph reasoning according to claim 1 is characterized in that: Collect patient conversation data, input the conversation data into the large language model to extract entities and relationships, and build a static knowledge graph based on the entities and relationships, including: Collecting the patient's conversation data through a chat interface and performing data preprocessing on the conversation data; Inputting the preprocessed conversation data into the large language model, extracting key entities through the large language model, and identifying semantic relationships between the entities; Data cleaning is performed on each of the entities and relationships, and the cleaned entities and relationships are visualized in the form of nodes and edges to construct a static knowledge graph.
4. The mental health monitoring method based on temporal knowledge graph reasoning according to claim 1 is characterized in that: Based on the static knowledge graph with timestamp information added, a sliding time window method is used to construct a temporal knowledge graph, including: Based on the timestamp information, the data in the target time period is taken as a time window, and each time window is determined based on the static knowledge graph after the timestamp information is added; Each of the time windows is grouped into a subgraph, and a temporal knowledge graph with each time subgraph is constructed by sliding the time window.
5. The mental health monitoring method based on temporal knowledge graph reasoning according to claim 4 is characterized in that: Generate a prompt graph for each time window in the temporal knowledge graph, including: Find example facts and extract contextual information from a temporal knowledge graph with various temporal subgraphs; Integrate the example facts and context information into a subgraph as an initial prompt graph; Timestamp information is added to each node and edge in the initial hint graph, and the entities and relationships in the initial hint graph are mapped to predefined tags using the same tokenization method to generate a final hint graph.
6. The mental health monitoring method based on temporal knowledge graph reasoning according to claim 5 is characterized in that: The prompt map is input into the prompt map encoder to obtain the prompt representation of each time step, including: Inputting the prompt graph into a prompt graph encoder, encoding the prompt graph through a message passing neural network in the prompt graph encoder to obtain a prompt representation for each time step; Wherein, the prompt is represented as time series data.
7. The mental health monitoring method based on temporal knowledge graph reasoning according to claim 1 is characterized in that: Inputting the prompt representation of each time step into the Mamba model, and performing temporal reasoning through the Mamba model, including: The prompt representation of each time step is input into the Mamba model, and the dynamic changes in the time dimension are captured by the Mamba model to complete the temporal reasoning.
8. The mental health monitoring method based on temporal knowledge graph reasoning according to claim 1 is characterized in that: By performing temporal reasoning using the Mamba model, we can obtain mental health prediction results, including: Performing temporal reasoning through the Mamba model and outputting temporal reasoning results; Based on the temporal reasoning results, the prompt representation of the time step is mapped to the output space through the output matrix to obtain the entity and relationship prediction results based on the temporal knowledge graph as the mental health prediction results.
9. A mental health monitoring system based on temporal knowledge graph reasoning, characterized in that: The system comprises: A model fine-tuning module is used to obtain the type of mental illness, input the type of mental illness into a pre-trained model, and fine-tune the parameters of the pre-trained model based on the labeled data of the mental illness type to obtain a large language model; A static knowledge graph construction module is used to collect patient conversation data, input the conversation data into the large language model to extract entities and relationships, and construct a static knowledge graph based on the entities and relationships; A temporal knowledge graph construction module is used to add timestamp information to the nodes and edges in the static knowledge graph, and to construct a temporal knowledge graph using a sliding time window method based on the static knowledge graph after adding the timestamp information; A prompt graph generation module is used to generate a prompt graph for each time window in the temporal knowledge graph, and input the prompt graph into a prompt graph encoder to obtain a prompt representation for each time step; The reasoning and prediction module is used to input the prompt representation of each time step into the Mamba model, perform temporal reasoning through the Mamba model, and obtain a mental health prediction result.
10. The mental health monitoring system based on temporal knowledge graph reasoning according to claim 9 is characterized in that: The model fine-tuning module is further configured to collect input mental illness types through a display interface, and search for a corresponding pre-trained model based on the mental illness types; determine the labeled data of the mental illness types, and input the mental illness types into the pre-trained model; The pre-trained model is fine-tuned using the labeled data to obtain a large language model.