A psychological diagnosis and treatment dialogue method based on dynamic knowledge evolution and adaptive retrieval

By employing a psychological diagnosis and treatment dialogue method based on dynamic knowledge evolution and adaptive retrieval, the patient's personalized knowledge base is updated in real time. This addresses the shortcomings of existing systems in long-term tracking of changes in cognitive state and insufficient perception of clinical urgency, thus achieving efficient and safe psychological intervention.

CN122369985APending Publication Date: 2026-07-10UNIV OF ELECTRONICS SCI & TECH OF CHINA

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
UNIV OF ELECTRONICS SCI & TECH OF CHINA
Filing Date
2026-04-16
Publication Date
2026-07-10

AI Technical Summary

Technical Problem

Existing psychological counseling dialogue systems based on large language models lack long-term personalized cognitive modeling capabilities, cannot dynamically track changes in patients' psychological states, lack clinical urgency perception and information grading mechanisms, and have rigid knowledge base update mechanisms with high computational costs, making it difficult to meet the need for real-time integration of new patient feedback.

Method used

A psychological counseling generation model and an urgency prediction module are constructed. Through dynamic knowledge evolution and adaptive retrieval, the patient's personalized knowledge base is updated incrementally in real time. Combining the Ebbinghaus forgetting curve and flashlight memory theory, the information retrieval weight is adaptively adjusted to prioritize the processing of high-risk signals.

Benefits of technology

It achieves long-term coherent dialogue logic and personalized consistency, significantly improving the safety and real-time nature of psychological intervention, reducing the risk of missing high-risk information, and reducing the computational overhead of knowledge base updates.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122369985A_ABST
    Figure CN122369985A_ABST
Patent Text Reader

Abstract

This invention proposes a psychological diagnosis and treatment dialogue method based on dynamic knowledge evolution and adaptive retrieval, belonging to the fields of natural language processing and intelligent medical technology. The method includes constructing a psychological counseling generation model, an urgency prediction module, and a background process auxiliary model; initializing a patient knowledge base; sending the patient's current dialogue input to the background process auxiliary model to extract key information and determine whether retrieval is needed; if no retrieval is needed, the psychological counseling generation model generates a response, and the current dialogue ends; otherwise, the retrieval yields a set of candidate structured memory units, which are adaptively reordered to obtain context information; the context information is concatenated with the current dialogue input and sent to the psychological counseling generation model to generate a therapeutic response conforming to psychological counseling standards; and the knowledge base undergoes dynamic evolution and incremental updates. This invention overcomes the limitations of the traditional "static profile" of dialogue systems, achieving long-term continuity and dynamic adaptability of diagnostic and treatment memory.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the fields of natural language processing and intelligent medical technology, and in particular relates to a psychological diagnosis and treatment dialogue method based on dynamic knowledge evolution and adaptive retrieval. Background Technology

[0002] With the surge in global demand for mental health services and the relative shortage of professional mental health counselors, psychotherapy systems based on artificial intelligence (AI) and large language models (LLM) are gradually becoming an important solution for providing large-scale, 24 / 7 psychological support. These systems can simulate human therapists through dialogue, providing patients with immediate psychological intervention and emotional support.

[0003] However, existing psychological counseling dialogue systems based on large language models still have significant technical limitations in practical applications, mainly in the following aspects:

[0004] Lack of long-term personalized cognitive modeling capabilities: Psychotherapy is a deep and long-term process that requires therapists to continuously update their understanding of patients over time. Most existing dialogue systems rely on short-term dialogue histories, fixed preset templates, or static user profiles for interaction. This approach treats each user interaction as a relatively independent event, failing to construct a dynamically evolving cognitive framework like a human therapist. Consequently, the system struggles to track the long-term trajectory of changes in the patient's psychological state, lacking continuity and consistency.

[0005] Lack of awareness and prioritization of clinical urgency: In psychological intervention scenarios, the clinical value of different information varies greatly. For example, high-risk signals such as acute suicidal ideation or severe anxiety attacks need to be prioritized, while general daily trivialities have lower weight. Current large-scale dialogue systems assign equal weight to all user input, lacking an information grading mechanism based on clinical urgency. This can easily lead to critical high-risk signals being overwhelmed by a large amount of outdated or irrelevant historical background information, resulting in intervention delays or misjudgments of risk.

[0006] Knowledge base update mechanisms are rigid and inefficient: Traditional Retrieval Augmented Generation (RAG) techniques typically assume that external knowledge bases are pre-indexed and remain unchanged at runtime (such as domain knowledge documents and question-answering databases). This static mechanism is unsuitable for psychological counseling scenarios because patients' symptoms, life events, and medication responses change in real time. Furthermore, existing knowledge update methods often require re-segmenting and vectorizing the entire document repository, resulting in high computational costs and time consumption, making it difficult to meet the need for real-time integration of new patient feedback to achieve dynamic profile updates.

[0007] In conclusion, how to construct a psychological diagnosis and treatment dialogue method that can update the dynamic profile of patients in real time and adaptively adjust information retrieval strategies according to clinical urgency and time factors is a technical problem that urgently needs to be solved in this field. Summary of the Invention

[0008] The purpose of this invention is to provide a psychological diagnosis and treatment dialogue method based on dynamic knowledge evolution and adaptive retrieval. This method incrementally updates the patient's personalized knowledge base in real time and adaptively adjusts the information retrieval weights according to the clinical urgency and time memory patterns, thereby improving the long-term coherence and clinical safety of the dialogue system. This addresses the technical problems of existing psychological counseling dialogue systems based on large language models, such as the inability to dynamically track changes in the patient's cognitive state over a long period and the lack of priority perception and processing of clinically urgent information (such as high-risk information) during the information retrieval and generation process.

[0009] To solve the above-mentioned technical problems, the specific technical solution of the present invention is as follows:

[0010] A psychological diagnosis and treatment dialogue method based on dynamic knowledge evolution and adaptive retrieval, the method comprising the following steps:

[0011] Step S1: Construct and fine-tune the psychological counseling generation model and urgency prediction module to obtain the trained psychological counseling generation model and urgency prediction module; construct the back-end process auxiliary model;

[0012] Step S2: Initialization and structured coding of the patient knowledge base;

[0013] Step S3: The patient's current dialogue input is sent to the background process assistance model. The background process assistance model extracts key information from the dialogue input and decides whether retrieval is needed. If retrieval is needed, the current dialogue input is sent to the embedded encoder, and step S4 is executed; if retrieval is not needed, the current dialogue input is sent to the psychological counseling generation model, which generates a response, and the current dialogue ends.

[0014] Step S4: Extract features from the current dialogue input to obtain the query vector, calculate the cosine similarity between the query vector and the encoding vector in the patient knowledge base, complete the preliminary retrieval, and obtain a set of candidate structured memory units;

[0015] Step S5: Perform adaptive reordering of the candidate structured memory unit set based on memory patterns, calculate the reordering score, and select the text content of the Top-N structured memory units with the highest reordering scores as context information;

[0016] Step S6: Concatenate the context information with the current dialogue input and send it to the psychological counseling generation model to generate a therapeutic response that conforms to the norms of psychological counseling;

[0017] Step S7: Dynamic evolution and incremental update of the knowledge base.

[0018] Further, step S2 includes the following steps:

[0019] Step S21: Obtain the patient's electronic medical record, perform text slicing on the electronic medical record to obtain several independent text fragments;

[0020] Step S22: Input each text segment into the embedding encoder for feature extraction, mapping it into a high-dimensional dense encoding vector;

[0021] Step S23: Input each text segment into the trained urgency prediction module and assign an urgency score to each text segment;

[0022] Step S24: Combine the text content, encoding vector, timestamp, and urgency score of each text fragment to construct a structured memory unit and store it in the vector database. All structured memory units together constitute the patient's knowledge base.

[0023] Further, step S4 includes the following steps:

[0024] Step S41: The embedded encoder receives the current dialogue input and extracts features from the current dialogue input to obtain the query vector;

[0025] Step S42: Based on cosine similarity, retrieve the Top-K candidate structured memory units from the patient's knowledge base that are semantically most similar to the query vector.

[0026] Furthermore, the cosine similarity between the query vector and the encoding vector is calculated as follows:

[0027]

[0028] in, Represents the query vector; Indicates the first One encoded vector; Represents the query vector With the Encoded vectors Cosine similarity between them; This represents the L2 norm.

[0029] Furthermore, the reordering score in step S5 is calculated as follows:

[0030]

[0031] in, Represents the first in the candidate structured memory unit set. The reordering score of each structured memory unit; Indicates the first Timestamp of a structured memory unit The time interval since the current conversation; Indicates the first The urgency score of each structured memory unit; The minimum decay threshold representing memory strength; This represents the time decay function.

[0032] Furthermore, the attenuation function is calculated as follows:

[0033]

[0034] in, Indicates the reference attenuation rate parameter; This represents the urgency persistence scaling factor.

[0035] Further, step S7 includes the following steps:

[0036] Step S71: Based on the key information extracted by the background process auxiliary model, determine the semantic module to which the key information belongs and the timestamp and text content of the most recent update of the corresponding semantic module in the patient knowledge base;

[0037] Step S72: Determine whether the new key information meets the merging conditions;

[0038] Step S73: If the merging condition is met, merge the new key information text content into the end of the most recently updated text content of the corresponding semantic module and update the timestamp; if the merging condition is not met, construct a structured memory unit for the new key information and update the knowledge base.

[0039] Furthermore, in step S72, the merging of new key information needs to meet the following two conditions:

[0040] Condition 1: The time interval between the timestamp of the new key information and the timestamp of the most recent update of the corresponding semantic module is less than a preset time threshold;

[0041] Condition 2: The combined text length of the new key information text content and the text content of the corresponding semantic module in the most recent update is less than or equal to the maximum token limit.

[0042] Further, in step S73, if the condition is not met: the new key information is regarded as a new independent event; the urgency score of the new key information text content is calculated using the trained urgency prediction module, that is, the urgency score of the new key information; the new key information encoding vector is generated by using the embedded encoder to extract the features of the new key information text content; the new key information text content, the new key information encoding vector, the new key information timestamp, and the new key information urgency score are inserted into the vector database as new structured memory units to update the knowledge base.

[0043] Compared with the prior art, the present invention has the following beneficial technical effects:

[0044] 1) This invention overcomes the limitations of traditional dialogue systems' "static profiling," achieving long-term continuity and dynamic adaptability of diagnostic and treatment memory. Existing technologies often rely on fixed background documents or short-term context windows, making it difficult to track the patient's changing psychological state over time. This invention, through a dynamic knowledge evolution mechanism, can extract new atomic information from each round of dialogue in real time and incrementally update the knowledge base. This gives the system "growth potential," enabling it to build and maintain a patient cognitive model that evolves throughout the treatment process, much like a human therapist, thus maintaining the coherence of dialogue logic and personalized consistency in long-term consultations.

[0045] 2) This invention significantly improves the safety of psychological interventions and effectively prevents the omission of high-risk clinical information. Addressing the shortcomings of existing dialogue systems, such as a lack of risk perception and the tendency to bury crucial distress signals in massive amounts of historical data, this invention innovatively introduces a clinical urgency prediction model and a reordering algorithm based on flashlight memory theory. This approach can identify high-risk signals (such as suicidal ideation) in dialogues and forcibly increase the weight of such information during retrieval, resisting time decay. This ensures that even if such information has not been mentioned for a long time, crucial risk memories can be prioritized and processed in emergencies, thereby significantly reducing the clinical risks of AI-assisted diagnosis and treatment.

[0046] 3) This invention solves the problem of high computational cost in real-time knowledge base updates and meets the needs of real-time interaction. Existing RAG technology typically requires re-slicing and indexing the entire document library to update knowledge, which is time-consuming and computationally expensive. This invention adopts an incremental update strategy based on atomic information, only performing vectorized insertion or attribute updates on newly extracted knowledge points, without the need to reconstruct the index. This low-latency, low-overhead update method enables the system to complete "memory storage" within millisecond response time, perfectly meeting the stringent real-time requirements of online psychological counseling. Attached Figure Description

[0047] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0048] Figure 1 This is a schematic diagram of the architecture of the psychological diagnosis and treatment dialogue method based on dynamic knowledge evolution and adaptive retrieval of the present invention.

[0049] Figure 2 The information weight decay values ​​for different urgency levels in this invention are ( A schematic diagram showing how the time changes the symbol.

[0050] Figure 3 This is a schematic diagram illustrating how the time required to update the knowledge base of this invention varies with the size of the electronic medical record file. Detailed Implementation

[0051] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0052] This invention proposes a psychological diagnosis and treatment dialogue method based on dynamic knowledge evolution and adaptive retrieval, such as... Figure 1 As shown, the method includes the following steps:

[0053] Step S1: Construct and fine-tune the psychological counseling generation model and urgency prediction module to obtain the trained psychological counseling generation model and urgency prediction module; construct the background process auxiliary model.

[0054] Step S11: Construct and fine-tune a psychological counseling generation model to obtain a trained psychological counseling generation model.

[0055] The psychological counseling generation model selects an open-source large language model (such as Llama or GLM) as its base model. An open-source multi-turn psychological counseling dialogue dataset (containing patient statements and professional counselor responses) is acquired to construct a fine-tuned corpus. Low-Rank Adaptation (LoRA) technology is used to efficiently fine-tune the parameters of the base model, training a psychological counseling generation model with empathy and professional language. This model serves as the Speaker LLM and is used to generate the final treatment responses.

[0056] Step S12: Construct and fine-tune the urgency prediction module to obtain the trained urgency prediction module.

[0057] The Emergency Predictor module uses a pre-trained language model (e.g., MentalBERT) as its base model. An open-source labeled dataset containing psychological counseling dialogues and their corresponding clinical risk level labels is obtained. This dataset is used to supervise and fine-tune the base model, training a clinical urgency classifier capable of classifying and predicting input text—the Emergency Predictor module. This classifier outputs an Emergency Score (E) reflecting the risk level of the text.

[0058] Step S13: Construct a background process auxiliary model.

[0059] The background process auxiliary model deploys an open-source large language model (such as Llama or GLM model), sets system instructions, and enables the model to determine whether to retrieve the corresponding knowledge base in response to user input, and to extract key information involved in the user input. The background process auxiliary model acts as a listener LLM.

[0060] The semantic modules for key information include patient information, family and social background, mental health history, currently reported mental health problems, current medication status, counseling goals, and whether a search is required.

[0061]

[0062] Step S2: Initialization and structured coding of the patient knowledge base.

[0063] When the system starts up or a new patient is admitted, the patient's electronic medical records are first processed in a structured manner.

[0064] Step S21: Obtain the patient's electronic medical record, perform text slicing on the electronic medical record to obtain several independent text fragments.

[0065] Specifically, text slicing operations use delimiters (such as the paragraph mark "\n" and the period ".") to divide continuous electronic medical records into several independent text segments.

[0066]

[0067] Step S22: Input each text segment into the embedding encoder for feature extraction and map it into a high-dimensional dense encoding vector.

[0068] Specifically, the Mental BERT model is used as the embedding encoder to extract features from each text segment, mapping them into a high-dimensional, dense encoded vector. Indicates the first The encoded vector is the first one. The encoding vector corresponding to each text segment.

[0069] Step S23: Input each text segment into the trained urgency prediction module and assign an urgency score to each text segment.

[0070] Specifically, a trained urgency prediction module is used to analyze the psycholinguistic features of text fragments, assigning an urgency score to each fragment. Indicates the first The urgency score is the first one. The urgency score corresponding to each text fragment.

[0071] The urgency score uses a 0-3 scale, where 0 represents mild concern: the problem is in its early stages or of low severity, with minimal impact on daily life, usually requiring only monitoring and self-management; 1 represents moderate concern: the psychological problem has begun to affect daily life, but is not yet severe, and preventative intervention is recommended; 2 represents high concern: the patient exhibits significant psychological distress, and daily functioning is substantially impaired, and professional psychological intervention or treatment is strongly recommended; and 3 represents critical concern: an acute crisis exists, such as suicidal ideation, self-harming behavior, or severe psychotic symptoms, posing an immediate threat to life.

[0072] Step S24: Combine the text content, encoding vector, timestamp, and urgency score of each text fragment to construct a structured memory unit and store it in the vector database. All structured memory units together constitute the patient's knowledge base.

[0073] Specifically, the recording time of electronic medical records is extracted as the timestamp of the text segment, using... Indicates the first The timestamps corresponding to each text fragment; Indicates the first The text content corresponding to each text fragment.

[0074] No. The text content corresponding to each text fragment , No. The encoding vector corresponding to each text segment , No. Timestamps corresponding to each text fragment and the The urgency score corresponding to each text fragment Together constitute the first Each text fragment is a structured memory unit, which is stored in a vector database. All structured memory units together constitute the patient's knowledge base.

[0075] Step S3: The patient's current dialogue input is sent to the background process assistance model. The background process assistance model extracts key information from the dialogue input and decides whether retrieval is needed. If retrieval is needed, the current dialogue input is sent to the embedded encoder, and step S4 is executed; if retrieval is not needed, the current dialogue input is sent to the psychological counseling generation model, which generates a response, and the current dialogue ends.

[0076]

[0077] Step S4: Extract features from the current dialogue input to obtain the query vector, calculate the cosine similarity between the query vector and the encoding vector in the patient knowledge base, complete the preliminary retrieval, and obtain a set of candidate structured memory units.

[0078] Step S41: The embedded encoder receives the current dialogue input and extracts features from the current dialogue input to obtain the query vector.

[0079] Specifically, the embedded encoder receives the current dialogue input, extracts features from the current dialogue input to obtain a query vector, and uses... This represents the query vector.

[0080] Step S42: Based on cosine similarity, retrieve the Top-K candidate structured memory units from the patient's knowledge base that are semantically most similar to the query vector.

[0081] The cosine similarity between the query vector and the encoded vector is calculated as follows:

[0082]

[0083] in, Represents the query vector With the Encoded vectors The cosine similarity between the query vector and the first vector represents the similarity between the query vector and the first vector. The degree of semantic similarity between the encoded vectors; This represents the L2 norm.

[0084] Calculate the cosine similarity between the query vector and the encoded vector in the knowledge base. Based on the cosine similarity score, select the top K most relevant structured memory units from high to low to form a candidate structured memory unit set.

[0085] Step S5: Perform adaptive reordering of the candidate structured memory unit set based on memory patterns, calculate the reordering score, and select the text content of the Top-N structured memory units with the highest reordering scores as context information.

[0086] To address the shortcomings of traditional retrieval methods that neglect time factors and clinical priority, this invention introduces an adaptive reordering method based on memory patterns, combining the Ebbinghaus forgetting curve and flashlight memory theory. This adaptive reordering based on memory patterns calculates a reordering score. The candidate structured memory unit set is sorted a second time.

[0087] Reordering scores The calculation formula is as follows:

[0088]

[0089] in, Represents the first in the candidate structured memory unit set. The reordering score of each structured memory unit; Indicates the first Timestamp of a structured memory unit The time interval since the current conversation; Indicates the first The urgency score of each structured memory unit; The minimum decay threshold representing memory strength ( This is used to ensure that information is not completely lost even after a long period of time; This represents the time decay function, which is the decay factor resulting from the combined effects of time and urgency score. Its specific decay function is defined as follows:

[0090]

[0091] in, Indicates the reference attenuation rate parameter ( This controls the rate at which information is forgotten under normal circumstances; Indicates the urgency persistence scaling factor ( (This is used to regulate the inhibitory effect of urgency scores on the rate of forgetting).

[0092] Explanation of the principle: The reordering score calculation combines time patterns and clinical risk to dynamically adjust information weights, realizing a mathematical simulation of the Ebbinghaus forgetting curve and the cognitive psychology mechanism of flashlight memory theory.

[0093] (1) Ebbinghaus forgetting curve: Calculate the time interval between the timestamp of each structured memory unit in the candidate structured memory unit set and the current dialogue, construct a time decay function, so that the memory strength of knowledge fragments decreases exponentially over time. The time decay function is as follows:

[0094]

[0095] when When the value is small, the time decay function exhibits exponential decay, simulating the rapid forgetting of short-term memory;

[0096]

[0097] when As it approaches infinity, the time decay function converges to power-law decay (∝ 1 / This aligns with the solidification pattern of long-term memory.

[0098] (2) Flash memory theory: The time decay function is adjusted using urgency scores, and the term in the formula... This plays a crucial moderating role; when the urgency score is high, this item decreases, thus significantly reducing the rate of time decay (i.e., increasing the weight of memory retention). Mathematically, this simulates the psychological phenomenon that "traumatic or highly evocative events are difficult to forget," thereby mimicking the mechanism by which humans deeply remember critical information (even long-standing historical risk information) under strong emotional stimuli. For example... Figure 2 As shown, information with a high urgency score takes two to three times longer to decay to the same weight as information with a low urgency score.

[0099] This adaptive reordering mechanism, based on memory patterns, ensures that it prioritizes recent interactions while maintaining high-risk events from the past (such as past suicide attempts) with high weight, preventing them from being overwhelmed by new daily conversations.

[0100] By calculating the reordering score, the structures are reordered according to the reordering score, and the text content of the top-N structured memory units with the highest reordering scores is selected as the final context information.

[0101] Step S6: Concatenate the context information with the current dialogue input and send it to the psychological counseling generation model to generate a therapeutic response that conforms to the norms of psychological counseling.

[0102] Specifically, the contextual information includes the patient's personalized electronic medical information background. The contextual information is concatenated with the current dialogue input, and the concatenated content is sent to the psychological counseling generation model. The psychological counseling generation model combines the retrieved personalized electronic medical information background knowledge and the urgency score of the current dialogue input to generate a therapeutic response that conforms to clinical norms.

[0103] Step S7: Dynamic evolution and incremental update of the knowledge base.

[0104] Specifically, steps S7 and S4 are performed asynchronously in the background for knowledge extraction and data entry, aiming to achieve real-time updates of patient profiles. To avoid costly re-indexing of the entire knowledge base, this invention employs a rule-based incremental update strategy, including the following steps:

[0105] Step S71: Based on the key information extracted by the background process auxiliary model, determine the semantic module to which the key information belongs and the timestamp and text content of the most recent update of the corresponding semantic module in the patient knowledge base.

[0106] The semantic module to which the key information belongs is determined by the JSON format content output by the backend process auxiliary model when extracting key information (patient information, family and social background, mental health history, currently reported mental health problems, current medication status, consultation goals, and whether retrieval is required). The value in the JSON is the extracted key information content, and the corresponding key value is the semantic module to which the key information belongs.

[0107] The extracted new key information is ,in For new key information text content, This is a timestamp for new key information.

[0108] Locating the latest fragment: Find the structured memory unit in the patient knowledge base that was most recently updated for the corresponding semantic module, with its timestamp being [timestamp value missing]. The text content is .

[0109] Step S72: Determine whether the new key information meets the merging conditions.

[0110] The merging of new key information requires the following two conditions to be met:

[0111] Condition 1: The time interval between the timestamp of the new key information and the timestamp of the most recent update of the corresponding semantic module is less than a preset time threshold, i.e. ; This indicates the time interval between the timestamp of the new key information and the timestamp of the most recent update of the corresponding semantic module; The preset time threshold is, for example, 1 week.

[0112] Condition 2: The combined length of the new key information text and the text content of the corresponding semantic module in the most recent update is less than or equal to the maximum token limit. ; This indicates the length of the text after merging the new key information text content with the text content of the corresponding semantic module that was most recently updated; Set a maximum token limit, for example, 256.

[0113] Step S73: If the merging condition is met, merge the new key information text content into the end of the most recently updated text content of the corresponding semantic module and update the timestamp; if the merging condition is not met, construct a structured memory unit for the new key information and update the knowledge base.

[0114] If the conditions are met: the new key information text content It is directly appended to the end of the most recently updated text content of the corresponding semantic module and its timestamp is updated. This operation does not require creating new structured memory units, but only updates the parameters of existing structured memory units, thus maintaining the compactness of storage.

[0115] If the condition is not met: treat the new key information as a new independent event. Use the trained urgency prediction module to calculate the text content of the new key information. The urgency score, i.e., the urgency score of new key information. Use an embedded encoder to extract new key information text content Feature generation of new key information encoding vectors The new key information text content New key information encoding vector New key information timestamp And the urgency score of new key information As a new structured memory unit ( , , , Insert into the vector database and update the knowledge base.

[0116] This incremental update does not require reslicing and recoding the entire electronic medical record, and the time consumption is as follows: Figure 3 As shown, One, Two, and Three represent the time required for incremental updates of one, two, and three text segments, respectively, while ALL represents the time required for traditional RAG technology to update the knowledge base by reslicing and encoding all text segments. Incremental updates do not change with the size of the patient's electronic medical record and can complete the knowledge base update in just milliseconds.

[0117] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.

Claims

1. A psychological diagnosis and treatment dialogue method based on dynamic knowledge evolution and adaptive retrieval, characterized in that, The method includes the following steps: Step S1: Construct and fine-tune the psychological counseling generation model and urgency prediction module to obtain the trained psychological counseling generation model and urgency prediction module; construct the back-end process auxiliary model; Step S2: Initialization and structured coding of the patient knowledge base; Step S3: Send the patient's current dialogue input to the background process assistance model. The background process assistance model extracts key information from the dialogue input and decides whether a retrieval is needed. If a retrieval is required, the current dialogue input is sent to the embedded encoder, and step S4 is executed; If no retrieval is required, the current dialogue input is sent to the psychological counseling generation model, which generates a response, and the current dialogue ends. Step S4: Extract features from the current dialogue input to obtain the query vector, calculate the cosine similarity between the query vector and the encoding vector in the patient knowledge base, complete the preliminary retrieval, and obtain a set of candidate structured memory units; Step S5: Perform adaptive reordering of the candidate structured memory unit set based on memory patterns, calculate the reordering score, and select the text content of the Top-N structured memory units with the highest reordering scores as context information; Step S6: Concatenate the context information with the current dialogue input and send it to the psychological counseling generation model to generate a therapeutic response that conforms to the norms of psychological counseling; Step S7: Dynamic evolution and incremental update of the knowledge base.

2. The psychological diagnosis and treatment dialogue method based on dynamic knowledge evolution and adaptive retrieval according to claim 1, characterized in that, Step S2 includes the following steps: Step S21: Obtain the patient's electronic medical record, perform text slicing on the electronic medical record to obtain several independent text fragments; Step S22: Input each text segment into the embedding encoder for feature extraction, mapping it into a high-dimensional dense encoding vector; Step S23: Input each text segment into the trained urgency prediction module and assign an urgency score to each text segment; Step S24: Combine the text content, encoding vector, timestamp, and urgency score of each text fragment to construct a structured memory unit and store it in the vector database. All structured memory units together constitute the patient's knowledge base.

3. The psychological diagnosis and treatment dialogue method based on dynamic knowledge evolution and adaptive retrieval according to claim 2, characterized in that, Step S4 includes the following steps: Step S41: The embedded encoder receives the current dialogue input and extracts features from the current dialogue input to obtain the query vector; Step S42: Based on cosine similarity, retrieve the Top-K candidate structured memory units from the patient's knowledge base that are semantically most similar to the query vector.

4. The psychological diagnosis and treatment dialogue method based on dynamic knowledge evolution and adaptive retrieval according to claim 3, characterized in that, The cosine similarity between the query vector and the encoded vector is calculated as follows: in, Represents the query vector; Indicates the first One encoded vector; Represents the query vector With the Encoded vectors Cosine similarity between them; This represents the L2 norm.

5. The psychological diagnosis and treatment dialogue method based on dynamic knowledge evolution and adaptive retrieval according to claim 1, characterized in that, The reordering score in step S5 is calculated as follows: in, Represents the first in the candidate structured memory unit set. The reordering score of each structured memory unit; Indicates the first Timestamp of a structured memory unit The time interval since the current conversation; Indicates the first The urgency score of each structured memory unit; The minimum decay threshold representing memory strength; This represents the time decay function.

6. The psychological diagnosis and treatment dialogue method based on dynamic knowledge evolution and adaptive retrieval according to claim 5, characterized in that, The attenuation function is calculated as follows: in, Indicates the reference attenuation rate parameter; This represents the urgency persistence scaling factor.

7. The psychological diagnosis and treatment dialogue method based on dynamic knowledge evolution and adaptive retrieval according to claim 2, characterized in that, Step S7 includes the following steps: Step S71: Based on the key information extracted by the background process auxiliary model, determine the semantic module to which the key information belongs and the timestamp and text content of the most recent update of the corresponding semantic module in the patient knowledge base; Step S72: Determine whether the new key information meets the merging conditions; Step S73: If the merging conditions are met, merge the new key information text content into the end of the most recently updated text content of the corresponding semantic module, and update the timestamp; If the merging conditions are not met, a new structured memory unit for key information is constructed, and the knowledge base is updated.

8. The psychological diagnosis and treatment dialogue method based on dynamic knowledge evolution and adaptive retrieval according to claim 7, characterized in that, In step S72, the merging of new key information needs to meet the following two conditions: Condition 1: The time interval between the timestamp of the new key information and the timestamp of the most recent update of the corresponding semantic module is less than a preset time threshold; Condition 2: The combined text length of the new key information text content and the text content of the corresponding semantic module in the most recent update is less than or equal to the maximum token limit.

9. The psychological diagnosis and treatment dialogue method based on dynamic knowledge evolution and adaptive retrieval according to claim 7, characterized in that, In step S73, if the condition is not met: the new key information is regarded as a new independent event; the urgency score of the new key information text content is calculated using the trained urgency prediction module, i.e., the urgency score of the new key information; the new key information encoding vector is generated by using the embedded encoder to extract the features of the new key information text content; the new key information text content, the new key information encoding vector, the new key information timestamp, and the new key information urgency score are inserted into the vector database as new structured memory units to update the knowledge base.