Dynamic psychological state assessment method based on deep learning

Deep learning technology is used to preprocess and feature the text information of the people under supervision in the prison environment, and combined with the BERT model and time series analysis, a dynamic mental state assessment model is constructed, which solves the problems of immediacy and privacy of mental state assessment in prisons. , achieving efficient mental state assessment.

CN118629655APending Publication Date: 2024-09-10GUIZHOU DONGGUAN TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410936108.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-12
Publication Date
2024-09-10

AI Technical Summary

Technical Problem

It is difficult for existing technology to assess the psychological state of people under supervision, especially negative psychological changes, in real time and accurately in high-pressure environments such as prisons. Moreover, traditional methods cannot combine real-time events for personalized analysis, and the privacy of people under supervision needs to be guaranteed. .

Method used

Adopting a dynamic mental state assessment method based on deep learning, by obtaining text information for preprocessing, word segmentation, extracting TF-IDF and time feature vectors, and combining the BERT model and time series analysis model, a dynamic mental state assessment model is constructed to implement emotional categories and identification of topics to ensure the immediacy and privacy of assessments.

Benefits of technology

It achieves instant, effective and accurate assessment of the psychological state of the people under supervision in a prison environment, protects the privacy rights of the persons being analyzed, and improves sensitivity to negative emotions and depressed mental states.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118629655A
    Figure CN118629655A
Patent Text Reader

Abstract

The invention discloses a dynamic psychological state assessment method based on deep learning, and the method comprises the steps: obtaining the text information of a supervised crowd in a specific time, and the text information comprises text content and text time features; preprocessing the character information to generate a to-be-processed text; performing word segmentation processing on the to-be-processed text to obtain a to-be-analyzed text; extracting a TF-IDF feature vector from the text to be analyzed; extracting a time feature vector from the character time feature, and combining the time feature vector with the TF-IDF feature vector into a comprehensive feature vector; loading a dynamic psychological state evaluation model, and inputting a comprehensive feature vector; and obtaining a dynamic psychological state evaluation result, wherein the evaluation result comprises an emotion category and a recognition theme. According to the technical scheme, the psychological state and emotional information of the character writer in the detention place can be fed back, the legal rights and interests of the analyzed person are guaranteed, the privacy of the analyzed person is protected from being disclosed, and instantaneity, effectiveness and accuracy of psychological state evaluation are guaranteed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to natural language processing technology in the field of sentiment analysis, and in particular to a dynamic psychological state assessment method based on deep learning. Background Art

[0002] For individuals in special settings, such as prisons, where high-pressure environments exist, it's crucial to accurately capture their psychological state, particularly any immediate changes in negative psychology. Psychological assessments are often conducted through superficial text analysis or periodic psychological assessments. However, these traditional methods cannot incorporate immediate events (such as holidays or temporary incidents) for personalized analysis, nor can they provide immediate assessments. For individuals under supervision in special settings like prisons, the psychological state of each individual requires timely attention and assessment. However, professional psychological staff within these facilities cannot always monitor the status of each individual.

[0003] The expressions produced by supervised individuals, such as conversations and text, can convey their mental state, making text a crucial resource for psychological state analysis. However, even the text of supervised individuals is private. To ensure real-time psychological state tracking while safeguarding the legitimate rights and interests of supervised individuals and protecting their privacy, a technical solution is needed that can assess mental state through text without requiring staff involvement or disclosing the text content. This technical solution, combined with the application environment, current events, and language habits, extracts features to ensure timely, effective, and accurate assessments. Summary of the Invention

[0004] To achieve the above objectives, this application provides a dynamic mental state assessment method based on deep learning, including: Obtain text information of the supervised population within a specific time period, including text content and text time characteristics; Preprocessing text information to generate text to be processed; preprocessing includes: cleaning text content to generate direct text; during cleaning, extracting special information from the text content, performing secondary feature extraction on the special information, and generating indirect text; the direct text and indirect text constitute the text to be processed; Perform word segmentation on the text to be processed to obtain the text to be analyzed; extract the TF-IDF feature vector from the text to be analyzed; extract the time feature vector from the text time feature and merge it with the TF-IDF feature vector to form a comprehensive feature vector; Load the dynamic mental state assessment model and input the comprehensive feature vector: Obtain dynamic mental state assessment results, including emotion categories and identified themes.

[0005] Before loading the dynamic psychological state assessment model, a dynamic psychological state assessment model is constructed; The model structure of the dynamic psychological state assessment model includes: language learning model, time series analysis model; The language learning model adopts the Bert model, and the basic transformer structure is composed of a self-attention mechanism; The time series analysis model includes a trend component Tt, a seasonal component St and a random component Rt.

[0006] Furthermore, cleaning the text content includes: Remove irrelevant characters, special symbols, typos from the text content, standardize punctuation, remove extraneous spaces, and process sensitive information to form direct text; When performing text content cleaning, special information is extracted from the text content, and then secondary feature extraction is performed on the special information to generate indirect text.

[0007] Special information includes: irrelevant characters removed during cleaning, typos and their context, extra spaces and their context; Secondary feature extraction includes: performing graphic recognition on irrelevant characters and extracting text features corresponding to the graphics; extracting typos and context, and extracting corresponding text features based on voice or graphics; and re-segmenting sentences based on the context of extra spaces and extracting text features.

[0008] Furthermore, performing word segmentation processing on the text to be processed includes: Use a word segmenter to break down the text to be processed into separate words and subwords, and assign a corresponding index to each word and subword; Perform complex word segmentation on individual words and subwords, and remove stop words; After synonym replacement for individual words and subwords, part-of-speech tags are added to form the text to be analyzed.

[0009] Extracting TF-IDF feature vectors from the text to be analyzed includes: Calculate the term frequency of each word, calculate the inverse document frequency, and calculate the TF-IDF value of each word.

[0010] Furthermore, text temporal features include: text submission time, writing time length, and writing frequency; Extracting time feature vectors can be achieved through Python's time series analysis library.

[0011] The file time feature also includes event features, which are information extracted from the event information relationship table pre-configured by the administrator based on the text submission time; The contents of the event information relationship table include: event characteristics, emotion categories, identification topics and event association time range.

[0012] Among them, the TF-IDF feature vector and the time feature vector can be horizontally spliced ​​into a comprehensive feature vector using the Python numpy library.

[0013] Furthermore, the emotion categories include: positive, negative, and neutral; and the identified themes include: imprisonment experience, family longing, and personal reflection.

[0014] According to the present invention, the psychological state and emotional information of people writing Chinese characters in detention facilities can be fed back, which not only guarantees the legal rights and interests of the analyzed persons and protects their privacy from being disclosed, but also ensures that the psychological state assessment is immediate, effective and accurate. BRIEF DESCRIPTION OF THE DRAWINGS

[0015] Figure 1 1 is a step diagram of a dynamic psychological state assessment method provided according to an embodiment of the present invention. DETAILED DESCRIPTION

[0016] The dynamic psychological state assessment method based on deep learning provided by the present invention is applied to the information analysis submodule of the information system of the detention facility. The information for assessment comes from the application terminal of the information system. The application terminal is deployed in the intranet of the detention facility and is a special terminal provided to the supervised population for writing text. The terminal application of the information system is pre-installed on the special terminal. The application provides information verification and text writing functions for the supervised population, and supports writing and voice input to text conversion when writing. The information analysis submodule deployed on the server side analyzes and processes the text content from the special terminal in combination with environmental information, and uses a deep learning model to output the author's psychological state and emotional information. The text content analysis process is completed on the server side to ensure the legal rights and interests of the writer. At the same time, the construction and training content of the deep learning model are targeted to a certain extent, matching the psychological characteristics and events of the detained population in the special application environment of the present invention, and providing a higher sensitivity to negative emotions, depressed psychological states and temporary events.

[0017] The specific implementation of the present invention is described in detail below with reference to the accompanying drawings.

[0018] The steps of the dynamic psychological state assessment method provided by the present invention are as follows: Figure 1 As shown, the following steps are included: Step S100: obtaining text information of the supervised population within a specific time period, the text information including: text content and text time characteristics; The text content is the text content submitted to the server by the terminal application of the information system; Text temporal characteristics include: text submission time, writing time length, writing frequency and event characteristics; Event features are extracted from the event information relationship table pre-configured by the administrator based on the text submission time. The content in the event information relationship table includes: event features, emotions, topics, and event-related time ranges, as shown in the following table: Event Characteristics Emotional categories Identify the subject Event time point Event correlation time range (days) Mid-Autumn Festival front Family Missing September 5 (-3,3) praise front Imprisonment June 10 (0,5) The content is defined in the event information relationship table, which associates events, time with emotion categories and identification topics, and assigns labels and topic meanings to specific times and events for the training of dynamic psychological state assessment models.

[0019] If the text is written 3 days before or 3 days after September 5, that is, between September 2 and September 8, it has the event feature of "Mid-Autumn Festival". This event feature will affect the emotional category and recognition theme of the text feedback.

[0020] The embodiment provided in the present invention is a text from an information system application terminal, part of which is as follows: "Night is the hardest time. I always think about the time when we ate moon cakes together. I really want to come back to you as soon as possible."

[0021] Step S110: pre-processing the text information to generate a text to be processed; Preprocessing is a key step before data analysis. During preprocessing, text cleaning techniques are used to remove noise and irrelevant information, such as meaningless punctuation and special characters. Obvious writing errors are deleted to form a standard file. This facilitates subsequent use of NLP techniques such as stemming and part-of-speech tagging to process the text and extract useful features. However, based on the more special application scenarios of the present invention, the sensitivity of the analysis needs to be enhanced. For seemingly meaningless punctuation marks, typos, etc., they need to be identified, corrected, and added to the standard file to ensure the integrity of the analysis content as much as possible.

[0022] Based on this, the content of the text to be processed includes direct text and indirect text.

[0023] Direct text is generated after cleaning the text content in step S111; Specific operations for cleaning text content include: 1. Remove irrelevant characters, special symbols, and typos from the text content: Clean up all special characters and symbols, typos corresponding to the context to keep the text pure; 2. Standardize punctuation: Ensure consistent use of punctuation, such as converting full-width punctuation to half-width punctuation; 3. Remove redundant spaces: Remove redundant spaces to ensure appropriate spacing between words and sentences. 4. Process sensitive information: Desensitize information related to personal privacy.

[0024] The content retained after the above cleaning process constitutes the direct text.

[0025] In the embodiment of the present invention, the direct text formed is "I always think about the time when we ate mooncakes together. I really want to quickly return to your side."

[0026] Among them, the content removed during cleaning, in addition to spaces, also includes the context of misspelled words, such as "夜晚是最难奥的时候" (The night is the most difficult time).

[0027] The content of the indirect text is generated by extracting special information from the text content during text content cleaning in step S112 and then performing secondary feature extraction on the special information.

[0028] Special information refers to: irrelevant characters removed during cleaning, misspelled words and their contexts, redundant spaces and their contexts. For example, "夜晚是最难奥的时候" (The night is the most difficult time) proposed in this embodiment.

[0029] Secondary feature extraction is performed for special information recognition, including: performing graphic recognition on irrelevant characters and extracting the corresponding text features of the graphics; extracting misspelled words and their contexts and extracting the corresponding text features according to pronunciation or graphics; re-segmenting sentences based on the context of redundant spaces and extracting text features. The text features recognized from the special information constitute the indirect text.

[0030] For example: During cleaning, symbols "^_^", ":)" were removed, and misspelled words "蓝受" (难受), "难奥" (难熬) were recognized. In this step, the text features recognized for symbols "^_^", ":)" are smile, and the text feature for ":(" is sad; the text features recognized for "蓝受" (难受), "难奥" (难熬) are uncomfortable, hard to endure.

[0031] In the embodiment of the present invention, "夜晚是最难奥的时候" (The night is the most difficult time) is recognized as "夜晚是最难熬的时候" (The night is the most难熬 time), and this content is used as an indirect file and added to the text to be processed.

[0032] In the currently common solutions, misspelled words and symbols are deleted during the cleaning and denoising process. However, due to the importance of psychological state assessment in high-pressure environments such as prisons, it is necessary to尽量 not reduce the content that can be reflected by the text; at the same time, it is necessary to consider the misspelled words that are easily generated by handwritten input and voice input, and the misspelled words that are easily generated by dialects and Internet terms. Since this type of information can also reflect the psychological state, the "noise" removed during cleaning is identified and supplemented as indirect text to the text to be processed.

[0033] The text to be processed generated in this step provides a textual basis for deep learning dynamic heart rate averaging; in subsequent operations, this textual basis needs to be processed into feature information suitable for the deep learning model. The embodiment provided by the present invention uses the NLP-related deep learning model BERT for sentiment analysis. Therefore, in step S120, the text to be processed is processed based on the sample features of the deep learning model BERT.

[0034] Step S120: extracting a comprehensive feature vector based on the text to be processed and the text time feature; The specific steps include: Perform word segmentation on the text to be processed to obtain the text to be analyzed; Extract the TF-IDF feature vector from the text to be analyzed; extract the time feature vector from the text time feature and merge it with the TF-IDF feature vector to form a comprehensive feature vector.

[0035] 1. Word segmentation processing includes: 1) Use a tokenizer to break the text into individual words and subwords, and assign a corresponding index to each word and subword; The BERT model is used in this invention, so in this step, the BERT tokenizer (such as BertTokenizer in Hugging Face's transformers library) can be used to convert the text into tokens; At the same time, a [CLS] tag is added at the beginning of the text sequence and a [SEP] tag is added between sentences.

[0036] The result of word segmentation is to break the text to be processed into separate words and subwords, and assign a corresponding index to each word and subword. The index is used to store the position in the BERT vocabulary.

[0037] The result after word segmentation is: "Night is the most difficult time. I always think about the time when we ate mooncakes together, which makes me unable to fall asleep."

[0038] 2) performing complex segmentation on the individual words and subwords and removing stop words; Complex word segmentation can be achieved through the Python Chinese word segmentation component jieba. The effect after complex word segmentation is as follows: ['Night' is the most difficult time. I always think of the time we ate mooncakes together. This makes me unable to fall asleep.'] Stop words refer to certain words or terms that are automatically filtered out before or after processing text in information retrieval to save storage space and improve search efficiency. These include: '的' (de), '了' (le), '在' (zài), '是' (shì), '我' (wǒ), '有' (yǒu), '和' (hé). After removing the stop words, the following is left: [ '夜晚' (night), '最' (most), '难熬' (hardest to endure), '时候' (time), ',', '总是' (always), '想' (think), '我们' (we), '一起' (together), '吃' (eat),'月饼' (mooncake), '时光' (time), ',', '这' (this), '让' (make), '无法' (unable to), '入睡' (fall asleep).] 3) Replace the individual words and sub - words with synonyms; 4) Add词性标注: This step classifies words mainly based on grammatical features and also takes into account lexical meanings. Common词性标注include nouns, verbs, adjectives, etc. Specifically as follows: ADJ (Adjective): Adjectives are used to describe the nature or state of nouns; NOUN (Noun): Nouns are used to represent people, things, places, concepts, etc.; PUNCT (Punctuation): Punctuation marks are used to separate sentences and phrases; PRON (Pronoun): Pronouns are used to replace nouns or noun phrases; DET (Determiner): Determiners are used to limit the scope or quantity of nouns; ADV (Adverb): Adverbs are used to modify verbs, adjectives, or other adverbs, indicating time, place, manner, degree, etc. For example, "总是" (always); VERB (Verb): Verbs are used to represent actions, states, or processes; AUX (Auxiliary): Auxiliary verbs are used to help the main verb form various tenses, voices, etc.; PART (Particle): Particles are used to assist in expressing the grammatical functions of sentences; ADP (Adposition): Prepositions or postpositions are used to introduce noun phrases, indicating time, place, manner, etc.

[0039] The content of the text in the embodiments of the present invention after词性标注is as follows: ('夜晚' (night), 'NOUN'), ('最' (most), 'ADV'), ('难熬' (hardest to endure), 'ADJ'), ('时候' (time), 'NOUN'),(',', 'PUNCT'), ('总是' (always), 'ADV'), ('想' (think), 'VERB', It should be noted that the term "词性标注" in the original text seems to be a Chinese term that is not fully translated in the provided English translation requirements. It might be better to use a more appropriate English term like "词性 tagging" or "word - class tagging" for a more accurate translation. Also, the format of the text in the original is a bit inconsistent in terms of the way the lists are presented, which is maintained as much as possible in the translation. ('ARG0', 'Subject', 'I'), ('ARG1', 'object', 'I always think about the time when we ate mooncakes together') ]), ('we', 'PRON'), ('together', 'ADV'), ('eat', 'VERB'), ('time', 'NOUN'), (',', 'PUNCT'), ('this', 'PRON'), ('let', 'VERB', [ ('ARG0', 'Subject', 'This'), ('ARG1', 'object', 'keeps me awake') ]), ('Unable', 'ADV'), ('Fall asleep', 'VERB'), ('.', 'PUNCT'), ] 5) Semantic role labeling: identifying the predicate and its semantic parameters (e.g., agent, patient, etc.) in a sentence; 6) Time code processing: Combine time codes with seasonal and periodic features and convert them into a format that can be used in the model.

[0040] Through the above processing, the text to be processed is converted into the text to be analyzed.

[0041] 2. Extract TF-IDF feature vectors from the text to be analyzed: In applications that require analysis of a large number of words, the TF-IDF bag-of-words model is used to record the number of times each word appears in the text, and consider the distribution of words in the document to reduce the weight of common words; The specific process includes: Calculate the term frequency (TF) of each word; Calculate inverse document frequency (IDF); Calculate the TF-IDF value for each word.

[0042] The code used in the embodiment of the present invention is as follows: “ from sklearn.feature_extraction.text import TfidfVectorizer # Build TF-IDF model vectorizer = TfidfVectorizer() X = vectorizer.fit_transform(texts) ” Among them, texts is the vocabulary involved, for example, "['dear family', 'often', 'feeling', 'difficult', 'every day', 'I'm here', 'very', 'family', 'feeling', 'myself', 'completely', 'isolated']" the final output matrix can be obtained as follows: [ [ 0.378 0 0.378 0.378 0.378 0.378 0.378 0 0 0 0 ] [ 0 0.5 0 0 0 0 0 0 0.5 0.5 0.5 0.5] ] It can be seen that the TF-IDF value of 'dear family' is 0.378, the TF-IDF value of 'often' is 0.5, and the TF-IDF value of 'feeling' is 0.378.

[0043] 3. Extract the time feature vector from the text time feature and merge it with the TF-IDF feature vector to form a comprehensive feature vector: In the application scenarios of this invention, the impact of special times and special events on psychological state needs special attention. For example, holidays that symbolize reunion, conversations between staff members, and family meetings all have an impact on mood. Therefore, this invention also requires time series data processing and feature fusion: First, perform STL decomposition to decompose the file time features and extract trend, seasonality, and residual components. The implementation is as follows: from statsmodels.tsa.seasonal import STL stl = STL(time_data) # time_data is the time characteristics of the text during the writing process res = stl.fit() trend = res.trend seasonal = res.seasonal resid = res.resid Among them, time_data is the text time feature, including: Text submission time: record the timestamp of text submission; Length of writing time: record the duration of writing each text; Writing frequency: record the frequency of writing in a specific time period; Event characteristics: such as holidays and major events corresponding to the time of text submission.

[0044] During feature fusion, the TF-IDF feature vector and the time feature vector after STL decomposition are horizontally spliced ​​to form a comprehensive feature vector. The implementation method is as follows: import numpy as np combined_features = np.hstack([X_tfidf.toarray(), trend.reshape(-1, 1), seasonal.reshape(-1, 1), resid.reshape(-1, 1)]).

[0045] Step S130: Load the dynamic mental state assessment model and input the comprehensive feature vector: Before loading the dynamic mental state assessment model, build a dynamic mental state assessment model; The present invention aims to analyze psychological states from language and text, and therefore adopts the NLP-related deep learning model BERT to perform sentiment analysis and topic recognition. In addition, for the writing process and time feature data, a time series analysis model and seasonally decomposed time series (STL) can be used to analyze the temporal regularity of writing behavior.

[0046] The basic transformer structure of the BERT model is composed of a self-attention mechanism, which is mainly used to understand the context of text language. The specific self-attention mechanism is expressed as follows: Among them, 𝑄, 𝐾, and 𝑉 are query, key, and value matrices respectively, and d is the dimension of the key.

[0047] STL (Seasonally Decomposed Time Series) is a method for analyzing time data that contains a trend component Tt, a seasonal component St, and a random component Rt.

[0048] The time series is decomposed into: The seasonal adjustment is expressed as: .

[0049] After the model structure is built, the training set is prepared: 70% of the collected data is randomly selected as the training set, and the remaining 30% is used as the test set.

[0050] Before training, define the training parameters as follows: labels = [0,1,2] #Sentiment classification label (0: negative, 1: positive, 2: neutral) themes = ['Imprisonment Experience', 'Family Missing', 'Personal Reflection'] # Theme classification label (0: negative, 1: positive, 2: neutral) # Training parameters training_args = TrainingArguments( output_dir='. / results', num_train_epochs=3, per_device_train_batch_size=16, per_device_eval_batch_size=16, warmup_steps=500, weight_decay=0.01, logging_dir='. / logs', logging_steps=10, ) in, num_train_epochs is the number of times the model will be trained on the entire training dataset, i.e. the number of "epochs"; per_device_train_batch_size: is the number of samples processed by each device (such as GPU) in each training step; warmup_steps is the time during which the learning rate gradually increases from 0 to the preset maximum value during the first 500 steps of training; weight_decay is the weight decay coefficient, which is used for L2 regularization to help prevent overfitting; Other parameters, such as output_dir and logging_dir, are the output result and execution log paths, and per_device_train_batch_size and per_device_eval_batch_size are the space configurations allocated during training.

[0051] During training, we first optimize model parameters using k-fold cross-validation to ensure that the model performs well on unseen data. K-fold cross-validation is used to randomly divide all training samples into k mutually exclusive subsets of roughly equal size. The model is trained on k-1 subsets of data each time, and the remaining subset is used to verify model performance. This process is repeated k times, each time selecting a different subset as validation data and the remaining subset as training data. The model performance is evaluated using the average validation statistic over the k iterations: Specifically, a random partitioning method is used in the sample processing process: all training data are randomly divided into k mutually exclusive subsets (usually of equal size).

[0052] The training process adopts a cyclic training method: for each sample subset from i = 1 to k, the following steps are performed: Select the i-th subset as the validation set, and combine the remaining k-1 subsets as the training set; Train the model on the combined training set; Evaluate the model performance on the i-th validation set and record the score; Finally, calculate the average performance: calculate the average of the performance scores obtained on k different validation sets and use this average as the final performance indicator of the model.

[0053] In the embodiment of the present invention, in the 5-fold cross validation, the loss value and accuracy of each validation are as follows: [ {'eval_loss': 0.4, 'eval_accuracy': 0.85}, {'eval_loss': 0.35, 'eval_accuracy': 0.88}, {'eval_loss': 0.38, 'eval_accuracy': 0.87}, {'eval_loss': 0.36, 'eval_accuracy': 0.86}, {'eval_loss': 0.37, 'eval_accuracy': 0.89} ] The average performance results are calculated as follows: average_result = { 'eval_loss': (0.4 + 0.35 + 0.38 + 0.36 + 0.37) / 5, 'eval_accuracy': (0.85 + 0.88 + 0.87 + 0.86 + 0.89) / 5 } The final result is: K-fold cross validation result: {'eval_loss': 0.372, 'eval_accuracy': 0.87} That is, the average loss value of the BERT model in the 5-fold cross validation is 0.372, and the average accuracy is 87%.

[0054] Model training uses GPU-accelerated computing resources to ensure efficient processing of large-scale data.

[0055] In the present invention, the evaluation result of the psychological state evaluation by the dynamic psychological state evaluation model is the probability ratio of the identification theme, and the emotion category is obtained based on the probability ratio of the identification theme.

[0056] Use the deep learning model to combine the comprehensive feature vector combined_features and label content labels for training, and finally train to generate a dynamic mental state assessment model: from keras.models import Sequential from keras.layers import LSTM, Dense model = Sequential() model.add(LSTM(128, input_shape=(combined_features.shape[1], 1))) model.add(Dense(1, activation='sigmoid')) model.compile(loss='binary_crossentropy',optimizer='adam',metrics=['accuracy']) model.fit(combined_features, labels, epochs=10, batch_size=32) #labels is the label of the training data.

[0057] After the dynamic mental state assessment model is completed, the comprehensive feature vector corresponding to the text is passed to the pre-trained BERT model to obtain the output result. The output result is an object containing the model output, which usually contains the original output of the last layer of the model, that is, the linear transformation result logits without the activation function. In this implementation column, it is represented as: probabilities = torch.softmax(outputs.logits, dim=-1).

[0058] Step S140: obtaining a dynamic psychological state assessment result, wherein the assessment result includes an emotion category and an identification theme.

[0059] Emotion categories include: negative, positive, and neutral; Identified themes included: experiences of captivity, thoughts of family, and personal reflection.

[0060] After obtaining the original output (logits) in step S130, the Softmax function is used to convert it into a probability distribution, that is, a real number vector is converted into a probability vector so that the value of each element is between 0 and 1 and the sum of all elements is 1, so as to intuitively represent the predicted probability of each category.

[0061] According to the embodiment of the present invention, the text can output the main emotion category: negative (the model predicts the category to be 0); the topic recognition results are: imprisonment experience: 53%, family longing: 35%, personal reflection: 12%.

[0062] It should be noted that the output results are the probabilities of the main emotions and topics.

[0063] This invention provides a function that alerts supervisory staff based on the assessment results. When the probability of the identified theme in the assessment results reaches a certain threshold, such as when the probability of missing family exceeds 60%, a notification is triggered, notifying relevant staff to pay attention to the designated supervised person. Throughout this process, the program analyzes the text content of the supervised person, and the analysis does not involve specific personal information, ensuring that the supervised person's privacy is not disclosed.

[0064] This invention utilizes a server-side technical solution based on the written text of individuals in detention facilities, combined with information about the environment in which the text was written. During implementation, it deeply processes the collected features. Applying a deep learning model, it not only provides feedback on the writer's psychological state and emotions, but also matches the psychological characteristics of detainees in the specific application environment of this invention, providing a high sensitivity to negative emotions, depressed mental states, and temporary events. This invention not only safeguards the legitimate rights and interests of the individuals being analyzed and protects their privacy from disclosure, but also ensures that psychological assessments are immediate, effective, and accurate.

[0065] The above disclosures are only a few specific embodiments of the present invention. However, the present invention is not limited thereto. Any changes that can be conceived by those skilled in the art should fall within the scope of protection of the present invention.

Claims

1. A dynamic psychological state assessment method based on deep learning, characterized in that: include: Obtaining text information of the supervised population within a specific time period, the text information including: text content, text time characteristics; the text time characteristics including: text submission time, writing time length and writing frequency; Preprocessing the text information to generate a text to be processed; the preprocessing includes: cleaning the text content to generate a direct text; when cleaning, extracting special information from the text content, performing secondary feature extraction on the special information to generate an indirect text; the direct text and the indirect text constitute the text to be processed; Perform word segmentation processing on the text to be processed to obtain the text to be analyzed; extract the TF-IDF feature vector from the text to be analyzed; extract the time feature vector from the text time feature, and merge it with the TF-IDF feature vector into a comprehensive feature vector; Loading a dynamic psychological state assessment model and inputting the comprehensive feature vector; Acquiring a dynamic psychological state assessment result, wherein the assessment result includes an emotion category and an identification theme; Among them, the text time feature also includes event features, and the event features are information extracted from the event information relationship table pre-configured by the administrator according to the text submission time; the content in the event information relationship table includes: event features, emotion categories, identification topics and event-related time ranges, which are used to train a dynamic psychological state assessment model.

2. The dynamic psychological state assessment method according to claim 1, characterized in that: Before loading the dynamic psychological state assessment model, constructing a dynamic psychological state assessment model; The structure of the dynamic psychological state assessment model includes: a language learning model and a time series analysis model; The language learning model adopts the Bert model, and the basic transformer structure is composed of a self-attention mechanism; The time series analysis model includes a trend component Tt, a seasonal component St and a random component Rt.

3. The dynamic psychological state assessment method according to claim 1, characterized in that: Cleaning the text content includes: Remove irrelevant characters, special symbols, typos from the text content, standardize punctuation, remove extraneous spaces, process sensitive information, and form direct text; When cleaning text content, special information is extracted from the text content, and then secondary feature extraction is performed on the special information to generate indirect text.

4. The dynamic psychological state assessment method according to claim 3, characterized in that: The special information refers to: irrelevant characters removed during cleaning, typos and the context in which the typos are located, extra spaces and the context in which the extra spaces are located; The secondary feature extraction includes: performing graphic recognition on irrelevant characters to extract text features corresponding to the graphics; extracting wrong characters and contexts to extract corresponding text features based on voice or graphics; and re-segmenting sentences based on redundant space contexts to extract text features.

5. The dynamic psychological state assessment method according to claim 1, characterized in that: The word segmentation processing of the text to be processed includes: Use a tokenizer to break the text to be processed into separate words and subwords, and assign corresponding indexes to each word and subword; Performing complex word segmentation on the individual words and subwords, and removing stop words; After synonym replacement is performed on the individual words and subwords, part-of-speech tags are added to form a text to be analyzed.

6. The dynamic psychological state assessment method according to claim 1, characterized in that: Extracting the TF-IDF feature vector from the text to be analyzed includes: Calculate the term frequency of each word, calculate the inverse document frequency, and calculate the TF-IDF value of each word.

7. The dynamic psychological state assessment method according to claim 1, characterized in that: The extraction of time feature vectors is implemented by using the Python time series analysis library.

8. The dynamic psychological state assessment method according to claim 1, characterized in that: The merging into a comprehensive feature vector may be performed by horizontally concatenating the TF-IDF feature vector and the time feature vector through the numpy library of Python.

9. The dynamic psychological state assessment method according to claim 1, characterized in that: The emotion categories include: positive, negative, and neutral; Identified themes included: experiences of captivity, thoughts about family, and personal reflection.