Traditional Chinese medicine dialogue generation method and device based on large language model
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- HANGZHOU WANGCHAI TECHNOLOGY CO LTD
- Filing Date
- 2026-05-15
- Publication Date
- 2026-08-07
AI Technical Summary
目前大语言模型通常围绕本轮输入、近期对话记录和检索片段展开,在中医对话场景中,由于中医对话涉及病情演变、症状反复、生活方式调整与疗效反馈等跨时间因素,导致同一用户在不同对话中遗漏重要背景,进而使得推理不准确
[0015]本申请实施例通过对检索到的多条增强信息进行基于相关性的排序与融合,有效筛选并整合了最高质量的外部知识,确保了输入模型的信息增强文本兼具高度相关性与完整性,从而显著提升了中医对话生成的专业精度和知识可靠性,避免了信息冗余或矛盾,使得最终回复内容更加权威、聚焦且实用。
Smart Images

Figure CN122529089A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of artificial intelligence technology, and more specifically, to a method and apparatus for generating traditional Chinese medicine dialogues based on a large language model. Background Technology
[0002] With the continuous development of artificial intelligence technology, natural language processing technology is gradually maturing. More and more industries are beginning to use dialogue systems to replace existing traditional human question-and-answer business scenarios, especially the medical industry.
[0003] The vast majority of existing dialogue systems utilize deep learning techniques. For dialogue systems, deep learning can learn meaningful feature representations and generate response strategies by leveraging large-scale data, while requiring only a very small amount of handcrafted features.
[0004] With the rapid development of medical informatization in recent years, medical big data has experienced explosive growth. Building medical dialogue systems based on medical data and machine learning technology to answer users' medical questions has become a hot topic. Currently, large language models typically revolve around the current input, recent dialogue records, and retrieved fragments. However, in traditional Chinese medicine (TCM) dialogue scenarios, because TCM dialogues involve time-varying factors such as disease progression, symptom recurrence, lifestyle adjustments, and efficacy feedback, the same user may miss important background information in different dialogues, leading to inaccurate inferences. Summary of the Invention
[0005] The purpose of this application is to provide a method and apparatus for generating TCM dialogues based on a large language model, so as to improve the accuracy of TCM dialogue generation.
[0006] In a first aspect, embodiments of this application provide a method for generating TCM dialogues based on a large language model, including: After receiving the user's consultation information, a user profile is obtained; the user profile is generated from the user's historical diagnostic features and preference information extracted from the long-term memory; the historical diagnostic features and preference information are obtained from multiple historical dialogues; Semantic recognition is performed based on consultation information to obtain the user's needs and intentions; Based on the user's intent, historical memory entries related to the current conversation turn are retrieved from the long-term memory bank; the long-term memory bank also contains memory entries related to the user's health extracted from multiple conversations within a historical time period. The dialogue response content for the current round is generated based on historical memory entries and user profiles.
[0007] This application embodiment achieves personalization and continuity in the generation of TCM dialogues by constructing a long-term memory bank and user profiles. It can accurately understand the user's needs and intentions based on historical diagnostic features and preference information, and generate targeted responses by combining relevant historical memory entries, thereby improving the accuracy of the generated dialogue content.
[0008] In one possible implementation of the first aspect, the method further includes: Based on the consultation information and corresponding contextual information, retrieve information-enhanced text from external TCM knowledge bases and / or local knowledge sets to obtain information relevant to the current round of dialogue; The dialogue response content for the current round is generated based on historical memory entries and user profiles, including: The dialogue response content for the current round is generated based on information-enhanced text, historical memory entries, and user profiles.
[0009] This application embodiment introduces a real-time retrieval and information enhancement mechanism combining an external TCM knowledge base and a local knowledge set. This mechanism dynamically injects authoritative and professional medical knowledge into each round of dialogue, thereby significantly improving the accuracy, professionalism, and practicality of the generated content based on user profiles and historical memories. This ensures the scientific validity and reliability of TCM advice, ultimately providing users with more accurate and trustworthy health consultation and management services.
[0010] In one possible implementation of the first aspect, the method further includes: Dynamic service strategies are generated based on user intent and user profiles, taking into account the user's physical condition and syndrome background. The dialogue response content for the current round is generated based on information-enhanced text, historical memory entries, and user profiles, including: The dialogue response content for the current round is generated based on dynamic service strategies, enhanced text, historical memory entries, and user profiles.
[0011] This application's embodiments introduce a dynamic service strategy based on demand intent and user profiles, enabling the system to adapt to the user's specific constitution and syndrome background in real time and intelligently. By integrating external knowledge enhancement and historical memory, it achieves highly personalized and dynamically adjusted dialogue responses, significantly improving the accuracy, adaptability, and intervention effect of TCM health consultation, and promoting the intelligent service upgrade from static question and answer to proactive and continuous health management.
[0012] In one possible implementation of the first aspect, after retrieving historical memory entries related to the current dialogue turn from the long-term memory bank based on demand intent, the method further includes: For cases where there are multiple historical memory entries, the importance index corresponding to each historical memory entry is calculated based on the relevance of each historical memory entry to the demand intention and the timestamp; Multiple historical memory entries were ranked according to their importance.
[0013] This application embodiment intelligently sorts multiple historical memory entries based on relevance and timestamp importance indicators, ensuring that the system can prioritize and integrate the most relevant and up-to-date historical information that is most relevant to the current consultation intent. This significantly improves the utilization efficiency and accuracy of long-term memory, making the final generated dialogue response more focused and more in line with the user's real-time health status and long-term change trajectory, thereby enhancing the consistency of health management services and the quality of intelligent decision-making.
[0014] In one possible implementation of the first aspect, information-enhanced text is obtained by retrieving information from an external TCM knowledge base and / or a local knowledge set based on the consultation information and corresponding contextual information, including: Based on the consultation information and corresponding contextual information, multiple pieces of enhanced information are retrieved from external TCM knowledge bases and / or local knowledge sets; Multiple pieces of enhanced information are sorted and merged based on their relevance to the intended demand, resulting in enhanced text.
[0015] This application embodiment effectively filters and integrates the highest quality external knowledge by sorting and fusing multiple retrieved enhanced information based on relevance. This ensures that the information enhancement text input to the model is both highly relevant and complete, thereby significantly improving the professional accuracy and knowledge reliability of TCM dialogue generation, avoiding information redundancy or contradictions, and making the final response content more authoritative, focused, and practical.
[0016] In one possible implementation of the first aspect, after generating the dialogue response content for the current round, the method further includes: Based on preset extraction rules, target information is extracted from the dialogue response content and stored in long-term memory. Among them, the preset extraction rules are used to extract at least one of the following: factual information, intervention information, preference and contraindication information, model analysis information, and traditional Chinese medicine identification information.
[0017] This application embodiment automatically extracts and updates the long-term memory bank from dialogue responses through preset rules, realizing the continuous accumulation and structured storage of key information such as user health facts, intervention measures, personal preferences, and TCM identification results. This forms a closed-loop system that can dynamically evolve, significantly enhancing the model's long-term memory capacity and personalized service level. This enables subsequent dialogues to respond more accurately based on the user's complete historical health context, promoting the continuous optimization and adaptive growth of the intelligent health management system.
[0018] In one possible implementation of the first aspect, the target information is stored in a long-term memory, including: Generate the timestamp, tag, and confidence level of the target information; If it is determined from the tags that the long-term memory contains an entry that is the same as the target information, then the information corresponding to the entry and the target information are archived together, and the target information and the corresponding timestamp and confidence level are inserted under the entry; If it is determined based on the label that the long-term memory does not contain an entry identical to the target information, then the target information, timestamp, and confidence level are added to the long-term memory incrementally.
[0019] This application embodiment ensures the accuracy, timeliness, and completeness of long-term memory information by attaching structured metadata such as timestamps, tags, and importance to the target information and adopting an intelligent management mechanism of conflict replacement and incremental updates. At the same time, it preserves the evolution trajectory of key information, thereby significantly improving the system's ability to dynamically maintain and trace user health data. This lays a solid data foundation for the continuous optimization and adaptive learning of personalized TCM services.
[0020] In one possible implementation of the first aspect, the method further includes: Obtain user feedback and update user profiles based on dialogue responses and user feedback.
[0021] This application embodiment updates user profiles based on user feedback, enabling the system to calibrate and optimize its understanding of user health status and preferences in real time. This makes the profile data more accurate and timely in reflecting the user's real changes, thereby significantly improving the personalization of subsequent dialogues, the accuracy of services, and user satisfaction. It forms a closed-loop adaptive learning system, promoting the continuous evolution of TCM health management towards a more intelligent and responsive direction.
[0022] In one possible implementation of the first aspect, the method further includes: Long-term care tasks are generated based on the changing trends of user profiles; long-term care tasks include at least one of the following: follow-up reminders, exercise recommendations, and personalized content recommendations.
[0023] This application's embodiments intelligently generate long-term care tasks by analyzing the dynamic changing trends of user profiles, achieving a leap from one-off question-and-answer sessions to continuous health management. This enables the system to proactively plan and execute personalized services such as follow-up reminders, exercise suggestions, and content push notifications, significantly enhancing the continuity, foresight, and user engagement of health interventions. Ultimately, it promotes the transformation of health management from a passive response to a proactive, adaptive care model, helping users achieve their long-term health improvement goals.
[0024] In one possible implementation of the first aspect, obtaining the user profile includes: Extract users' historical diagnostic characteristics and preference information from long-term memory; Generate basic symptoms and personalized information for users based on historical diagnostic features and preference information; personalized information includes at least one of the following: constitution classification tags, previous tongue images, offline medical history, medication records, and face-to-face consultation records.
[0025] This application embodiment extracts and integrates multi-dimensional historical data of users from long-term memory to generate a structured user profile containing TCM-specific information such as basic symptoms and constitution classification, tongue appearance, medical history, and medication records. This constructs a comprehensive and accurate personal health digital twin, providing authoritative and reliable core evidence for subsequent syndrome differentiation analysis, personalized dialogue generation, and long-term health management, significantly improving the professional depth and individual adaptability of TCM intelligent services.
[0026] In one possible implementation of the first aspect, the method further includes: If the dialogue response references an external knowledge base, add a reference marker to the corresponding part of the dialogue response.
[0027] This application's embodiments make the dialogue response content more credible by adding a citation marker to the dialogue response content.
[0028] Secondly, embodiments of this application provide a TCM dialogue generation device based on a large language model, comprising: The information receiving module is used to obtain the user profile after receiving the user's consultation information; the user profile is generated from the user's historical diagnostic features and preference information extracted from the long-term memory; the historical diagnostic features and preference information are obtained from multiple historical dialogues; The intent recognition module is used to perform semantic recognition based on consultation information to obtain the user's needs and intent. The memory retrieval module is used to retrieve historical memory entries related to the current conversation turn from the long-term memory bank based on the user's intent; the long-term memory bank also contains memory entries related to the user's health extracted from multiple conversations within a historical time period. The dialogue generation module is used to generate dialogue responses for the current round based on historical memory entries and user profiles.
[0029] Thirdly, embodiments of this application provide an electronic device, including: a processor, a memory, and a bus, wherein: The processor and memory communicate with each other via a bus; The memory stores program instructions that can be executed by the processor, and the processor can execute the method of the first aspect by calling the program instructions.
[0030] Fourthly, embodiments of this application provide a non-transitory computer-readable storage medium, comprising: A non-transitory computer-readable storage medium stores computer instructions that cause the computer to perform the methods in the various possible implementations of the first aspect.
[0031] Fifthly, embodiments of this application provide a computer program product, including computer program instructions, which, when read and executed by a processor, perform the methods in various possible implementations of the first aspect.
[0032] Other features and advantages of this application will be set forth in the following description and will be apparent in part from the description or may be learned by practicing embodiments of this application. The objectives and other advantages of this application may be realized and obtained by means of the structures particularly pointed out in the written description and the accompanying drawings. Attached Figure Description
[0033] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments of this application will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0034] Figure 1 A schematic diagram of a method for generating TCM dialogues based on a large language model, provided for an embodiment of this application; Figure 2 This is a schematic diagram of another method for generating TCM dialogues provided in an embodiment of this application; Figure 3 A schematic diagram of a TCM dialogue generation device based on a large language model provided in an embodiment of this application; Figure 4 This is a schematic diagram of the physical structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0035] The embodiments of the technical solution of this application will now be described in detail with reference to the accompanying drawings. These embodiments are only used to more clearly illustrate the technical solution of this application and are therefore merely examples, and should not be used to limit the scope of protection of this application.
[0036] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs; the terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit this application; the terms “comprising” and “having”, and any variations thereof, in the specification and the foregoing description of the drawings are intended to cover non-exclusive inclusion.
[0037] In the description of the embodiments of this application, technical terms such as "first" and "second" are used only to distinguish different objects and should not be construed as indicating or implying relative importance or implicitly specifying the number, specific order, or primary and secondary relationship of the indicated technical features. In the description of the embodiments of this application, "multiple" means two or more, unless otherwise explicitly defined.
[0038] In this document, the term "embodiment" means that a particular feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.
[0039] In the description of the embodiments in this application, the term "and / or" is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. Additionally, the character " / " in this document generally indicates that the preceding and following related objects have an "or" relationship.
[0040] In the description of the embodiments of this application, the term "multiple" refers to two or more (including two), similarly, "multiple sets" refers to two or more (including two sets), and "multiple pieces" refers to two or more (including two pieces).
[0041] In the description of the embodiments of this application, unless otherwise expressly specified and limited, technical terms such as "installation," "connection," "joining," and "fixing" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral part; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; they can refer to the internal communication of two components or the interaction between two components. For those skilled in the art, the specific meaning of the above terms in the embodiments of this application can be understood according to the specific circumstances.
[0042] With the continuous advancement of artificial intelligence technology and the increasing maturity of natural language processing, dialogue systems have gradually replaced traditional manual question-and-answer models in many industries, with the medical field being one of its key application scenarios. Currently, most dialogue systems rely on deep learning technology, which can automatically learn meaningful feature representations and response strategies using large-scale data, significantly reducing reliance on manual features. At the same time, the rapid development of medical informatization has spurred an explosive growth in medical data, making the construction of intelligent question-and-answer systems based on medical big data and machine learning technology a hot topic in the industry. However, existing large language models typically rely only on the current input, recent dialogue records, and retrieved fragments for response. In traditional Chinese medicine dialogue scenarios, the evolution of the disease, recurring symptoms, lifestyle adjustments, and efficacy feedback often span multiple long conversations, causing users to easily overlook key historical context when interacting with large language models, thus limiting the accuracy of system inference.
[0043] To address the aforementioned technical issues, this application provides a TCM dialogue method based on a large language model. This method constructs a long-term memory bank. After the large language model receives the user's consultation information, it obtains a user profile based on the long-term memory bank before inference. During inference, it extracts historical memory entries related to the current consultation information from the long-term memory bank and combines the user profile and historical memory entries for inference. Since the long-term memory bank is constructed by the large language model based on valuable information extracted from multiple dialogues with the user within a historical time period, the large language model has richer contextual information to refer to during inference, thus improving the accuracy of inference.
[0044] It is understood that the TCM dialogue generation method provided in this application embodiment can be applied to a TCM dialogue system, which can run on a user terminal, such as a smartphone, tablet, desktop computer, laptop, or smart wearable device. The architecture of the large language model can be based on the Transformer architecture, such as the GPT series, Claude series, Gemimi series, etc. Furthermore, the names "large language model" and "large model" mentioned in this application embodiment refer to models used for generating TCM dialogues.
[0045] Figure 1 A flowchart illustrating a method for generating TCM dialogues based on a large language model, as provided in this application embodiment, is shown below. Figure 1 As shown, the method includes: Step 101: Receive user consultation information. After receiving the user's consultation information, obtain the user profile.
[0046] The consultation information can be entered by the user through the input boxes provided on the large language model interface, or it can be input by the user via voice on the large language model interface, and then the large language model converts the audio into text. Furthermore, the user can send consultation information within an existing session, or create a new session and send consultation information within that session. It is understood that a session can include at least one round of dialogue. A round of dialogue refers to the user sending a message to the large language model, and the large language model responding based on the message sent by the user; this interaction constitutes one round of dialogue.
[0047] For example, consultation information may include consultation requests, symptom descriptions, health consultations, etc. The large language model normalizes the received consultation information and passes the processed input to subsequent models for further semantic analysis and dialogue progression.
[0048] Step 102: Obtain user profiles.
[0049] Before large-scale model inference, a user profile can be obtained based on a long-term memory (LTM). For example, the LTM is a continuously updated structured or unstructured database specifically built for each user. The system first locates the user in the LTM using their identifier (e.g., user ID) and extracts all historical dialogue records related to that user. Then, the system uses natural language processing techniques (e.g., named entity recognition, relation extraction, sentiment analysis) to automatically analyze these massive amounts of historical dialogues, extracting two key types of information: first, historical diagnostic features, including but not limited to symptoms described by the user, past symptom diagnoses, treatment plans received and their feedback, and the evolution of the condition; second, user preference information, such as the user's acceptance of specific treatment methods (e.g., medicinal diets, moxibustion), communication style preferences, and explicitly stated contraindications or concerns. Finally, the system cleans, integrates, and structures this extracted, discrete historical information, dynamically generating a comprehensive, machine-readable user profile. This profile not only includes a basic overview of the user's symptoms, but also integrates personalized information with distinctive characteristics of traditional Chinese medicine and individual value, such as their constitution classification tags (e.g., Yin deficiency, phlegm-dampness), tongue descriptions from previous consultations, medical history of diagnosis at offline hospitals, past medication records, and consultation conclusions.
[0050] Understandably, user profiles can be newly generated in each dialogue round, allowing each round to perform inference based on the latest user profile, thus improving inference accuracy. Alternatively, a user profile can be generated at the start of each session so that it can be directly used in subsequent dialogues, reducing computational load. Furthermore, for a single session, the large language model can update the user profile at preset time intervals, avoiding the possibility of changes in the user profile across multiple time periods within a single session.
[0051] Step 103: Perform semantic analysis and intent recognition based on the information.
[0052] The large language model performs semantic analysis on the user's input consultation information to identify the user's needs and intentions in the current round of dialogue. These needs and intentions can include consultation, recommendations, or lifestyle adjustments. For example, if a user inputs "I've been having insomnia and dry mouth lately," the large language model's semantic analysis will reveal "the main complaints are insomnia and dry mouth," and further determine that the user's potential intention may be to seek a diagnosis.
[0053] Step 104: Based on the demand intent, retrieve relevant health-related memories from the long-term memory bank and relevant traditional Chinese medicine knowledge from the knowledge base.
[0054] In the specific implementation process, the long-term memory not only contains the general features of the user profile, but also includes health-related memory entries extracted from multiple conversations over a historical period. These memory entries record in detail specific health events, symptom changes, medication feedback, and lifestyle adjustments extracted from each round of dialogue in each conversation. The large language model retrieves the user's historical health information relevant to the current TCM diagnosis and treatment context from the long-term memory. The retrieved content includes past syndrome judgment records, constitution change trends, historical acupoint recommendations and implementation feedback, medication and treatment history, tongue and facial diagnosis records, contraindications and preferences, etc. For the structured long-term memory, because the long-term memory entries are extracted and tagged, each memory entry is accompanied by TCM semantic tags and metadata. Therefore, the memory retrieval process can accurately filter and recall based on syndrome themes, constitution categories, symptom types, or time trends, achieving customized memory reuse for TCM scenarios, rather than simple text similarity matching.
[0055] As one implementation method, for cases where there are multiple historical memory entries, the importance index corresponding to each historical memory entry is calculated based on the relevance of each historical memory entry to the demand intent and the timestamp; Multiple historical memory entries were ranked according to their importance.
[0056] In the specific implementation process, the memory entries contained in the long-term memory bank carry timestamps. These timestamps are based on the time when the dialogue that formed the memory entry was generated, or they can be the time when the large language model stored the memory entry in the long-term memory bank.
[0057] The system can calculate a comprehensive importance index for each retrieved historical memory entry. This index is mainly determined by two core dimensions, and the weights can be configured.
[0058] One core dimension is the relevance score, which is calculated, for example, by comparing the semantic content of historical memory entries with the current demand intent. For instance, if the current intent is "to inquire about the reasons for recurring insomnia," then historical entries about "insomnia," "sleep quality," and "feedback on calming remedies" will receive extremely high relevance scores, while entries about "stomach pain" will receive very low scores. This is typically achieved through vector similarity calculations (such as cosine similarity).
[0059] Another core dimension is the time decay factor, which is calculated based on the timestamps of historical memory entries. For example, the more recent a record is, the higher its timeliness value, and therefore it receives a higher time weight in importance assessments. The system can use a time decay function (such as exponential decay) to give more natural weight to recent records than older records. This is crucial for tracking changes in disease progression and evaluating the effectiveness of recent interventions.
[0060] The system combines the relevance score of each entry with a time decay factor according to predetermined weights to calculate the final importance index. Then, all retrieved historical memory entries are sorted in descending order based on this index, with the entries having the highest importance index listed first.
[0061] The sorted list of historical memory entries will serve as refined and ordered historical memory information input into the subsequent response generation module. When utilizing this information, the generation model will naturally prioritize and integrate the more important memories at the top of the list.
[0062] This application embodiment intelligently sorts multiple historical memory entries based on relevance and timestamp importance indicators, ensuring that the system can prioritize and integrate the most relevant and up-to-date historical information that is most relevant to the current consultation intent. This significantly improves the utilization efficiency and accuracy of long-term memory, making the final generated dialogue response more focused and more in line with the user's real-time health status and long-term change trajectory, thereby enhancing the consistency of health management services and the quality of intelligent decision-making.
[0063] Step 105: Generate the response content for the current round of dialogue based on memory, knowledge base content, user profile, etc.
[0064] After acquiring user profiles and historical memory entries, the large language model combines these to construct a continuous and comprehensive understanding of the current user's health background. Guided by this health background understanding, the large language model generates the final response text.
[0065] It is understood that the large language model in this application embodiment is an artificial intelligence model that is trained on a large amount of TCM-related text data and is capable of understanding, generating and reasoning about natural language.
[0066] Step 106: Extract TCM health-related content from the dialogue to form new memories and profiles.
[0067] The specific implementation of this step is described in the following embodiment. It should be noted that step 106 is optional; that is, step 106 is not executed in every round of dialogue. Instead, the system can choose whether to execute step 106 based on the content of the current round of dialogue. For example, the system can determine whether there is valuable information in the current round of dialogue. If valuable information exists, step 106 can be executed; otherwise, step 106 is not executed.
[0068] This application embodiment achieves personalization and continuity in the generation of TCM dialogues by constructing a long-term memory bank and user profiles. It can accurately understand the user's needs and intentions based on historical diagnostic features and preference information, and generate targeted responses by combining relevant historical memory entries, thereby improving the accuracy of the generated dialogue content.
[0069] Based on the above embodiments, after obtaining the consultation information, information enhancement text related to the current round of dialogue can be obtained by retrieving from external TCM knowledge bases and / or local knowledge sets according to the consultation information and corresponding context information.
[0070] The large language model, after generating the user's intent, can also generate reference control signals based on that intent. These signals indicate which sub-tasks need to be executed and whether external tools should be invoked. When the reference control signal indicates that the information-enhanced retrieval sub-task needs to be executed, the large language model invokes an external Traditional Chinese Medicine (TCM) knowledge base or retrieves information from its local knowledge set. Based on the user's consultation information input in the current dialogue round, it retrieves professional theoretical support information related to the current symptoms, syndromes, or constitution from the TCM knowledge base. The TCM knowledge base includes meridian theory, viscera theory, constitution classification system, common syndromes and diagnostic principles, TCM medical guidelines, acupoint efficacy descriptions, and dietary therapy and conditioning principles. During the retrieval process, not only semantic similarity is considered, but also keyword matching is performed in conjunction with the constitution tags and syndrome trends in the current user profile to obtain theoretical basis that better matches the individual's TCM condition—i.e., information-enhanced text. This information-enhanced text can be used to enhance the professionalism and consistency of subsequent dialogue generation.
[0071] After obtaining the information-enhanced text, the information-enhanced text, together with historical memory entries and user profiles, is used as the user's health background cognition and participates in subsequent reasoning operations.
[0072] This application embodiment introduces a real-time retrieval and information enhancement mechanism combining an external TCM knowledge base and a local knowledge set. This mechanism dynamically injects authoritative and professional medical knowledge into each round of dialogue, thereby significantly improving the accuracy, professionalism, and practicality of the generated content based on user profiles and historical memories. This ensures the scientific validity and reliability of TCM advice, ultimately providing users with more accurate and trustworthy health consultation and management services.
[0073] As one implementation method, multiple pieces of enhanced information are obtained by retrieving information from an external TCM knowledge base and / or a local knowledge set based on contextual information; For each piece of augmentation information, a semantic relevance score to the user's intent is calculated. For example, this can be achieved by converting the augmentation information and the intent into vectors and calculating their similarity. The augmentation information with the highest score is considered the core knowledge most directly related to the user's current problem.
[0074] During the relevance-based ranking process, the system identifies and merges semantically repetitive information (e.g., similar definitions of "spleen deficiency" from different sources). For potentially conflicting information (e.g., subtle differences in the diagnosis of a symptom across different texts), the system makes a decision based on pre-defined rules (e.g., prioritizing more authoritative sources or more recent literature) to ensure the internal consistency of the output information. The system then organizes the top-ranked and cleaned key information into coherent text paragraphs according to a logical structure, creating information-enhanced text.
[0075] This application embodiment effectively filters and integrates the highest quality external knowledge by sorting and fusing multiple retrieved enhanced information based on relevance. This ensures that the information enhancement text input to the model is both highly relevant and complete, thereby significantly improving the professional accuracy and knowledge reliability of TCM dialogue generation, avoiding information redundancy or contradictions, and making the final response content more authoritative, focused, and practical.
[0076] Building upon the above embodiments, the reference control signal can also instruct the large language model to execute a strategy preparation subtask. This subtask generates a dynamic service strategy that matches the user's constitution and syndrome profile based on their desired intent and user profile. The dynamic service strategy may include whether to trigger acupoint recommendations or action therapy plans, or whether to provide a diagnostic conclusion. If the dynamic service strategy triggers acupoint recommendations, then acupoint-related components can be invoked to generate acupoint recommendations that meet the user's needs. This subtask, in a Traditional Chinese Medicine (TCM) context, serves as the intervention method decision-maker, enabling the system to dynamically adjust service strategies under different constitutions and syndrome profiles, rather than outputting a fixed template.
[0077] After obtaining the dynamic service strategy, the dynamic service strategy, information-enhanced text, historical memory entries, and user profile are used together as the user's health background cognition and participate in subsequent reasoning operations.
[0078] This application's embodiments introduce a dynamic service strategy based on demand intent and user profiles, enabling the system to adapt to the user's specific constitution and syndrome background in real time and intelligently. By integrating external knowledge enhancement and historical memory, it achieves highly personalized and dynamically adjusted dialogue responses, significantly improving the accuracy, adaptability, and intervention effect of TCM health consultation, and promoting the intelligent service upgrade from static question and answer to proactive and continuous health management.
[0079] Based on the above embodiments, in medical (especially traditional Chinese medicine health management) dialogues, user health information exhibits significant temporal evolution and phased characteristics. Symptoms may worsen or improve, triggers and lifestyles may change, interventions and responses accumulate over time, some information may become outdated, and some information needs to be revised by new evidence. Therefore, after retrieving historical memory entries related to the current dialogue round from the long-term memory bank based on demand intent, this application embodiment further includes: Based on the above embodiments, after generating the dialogue response content for the current round, the method further includes: Based on preset extraction rules, target information is extracted from the dialogue response content and stored in long-term memory.
[0080] In the specific implementation process, after each round of dialogue, the response text, along with its corresponding dialogue context (such as the user's current consultation information and intent), is used as input for memory entry extraction. The large language model filters candidate information based on cross-conversation reuse value and long-term health management impact, generating corresponding long-term memory entries only when the information has continuous reference value or may affect subsequent treatment recommendations, thus avoiding simply piling all dialogue content into the database.
[0081] For example, the system will run a predefined set of preset extraction rules for TCM health dialogue scenarios to perform structured parsing of the responses. The preset extraction rules are used to extract at least one of the following: factual information, interventional information, preference and contraindication information, model analysis information, and TCM identification information. Factual information includes symptom descriptions, duration, changes in severity, past medical history, and test results. Interventional information includes medication, acupressure, behavioral therapy measures, and their effect feedback. Preference and contraindication information includes dietary preferences, lifestyle habits, prohibited behaviors, and willingness to implement them. Model analysis information includes stage-by-stage judgments, constitution or syndrome tendencies, and risk warnings. TCM identification information includes tongue appearance characteristics and facial diagnosis manifestations.
[0082] Each extracted piece of target information is automatically converted into a structured memory entry. This entry not only contains the information content itself but also automatically includes key metadata, such as: Source: which round of conversation it originated from (conversation ID); Type Tag: which of the five categories mentioned above it belongs to; Timestamp: the date and time of extraction / occurrence; Confidence Level: the system's assessment of the reliability of the information (e.g., high confidence for facts directly confirmed by the user, medium confidence for information inferred by the model). Understandably, it may also include status markers, such as: archived, valid, resolved, etc. It may also include validity period parameters, topic association identifiers, etc.
[0083] Subsequently, these structured new memory entries will be sent to the long-term memory bank's storage and update module. This module will perform intelligent integration; for example, if it is new information, it will be stored as a new entry, enriching the user's personal health profile. If the long-term memory bank contains entries that are the same as or similar to the target information, the information corresponding to that entry in the long-term memory bank will be archived along with the target information, and the target information, along with its corresponding timestamp and confidence level, will be inserted under that entry. This allows for tracing the user's factual evolution. It can be understood that archiving is a state; archived memory entries will be marked as archived, essentially a hidden state, and will not participate in retrieval by default unless deliberately traced back to the facts. This can be controlled by AI.
[0084] This application embodiment ensures the accuracy, timeliness, and completeness of long-term memory information by attaching structured metadata such as timestamps, tags, and importance to the target information and adopting an intelligent management mechanism of conflict replacement and incremental updates. At the same time, it preserves the evolution trajectory of key information, thereby significantly improving the system's ability to dynamically maintain and trace user health data. This lays a solid data foundation for the continuous optimization and adaptive learning of personalized TCM services.
[0085] Based on the above embodiments, user feedback can be collected through two channels. First, a feedback interface can be provided directly to the user, such as a satisfaction rating (e.g., 1-5 stars) for "Was this helpful to you?"; or a yes / no option for "Did this solve your problem?". Second, the large language model can automatically infer feedback by analyzing the user's subsequent behavior and conversation content. For example, whether the user followed the previous advice in subsequent conversations, whether they repeatedly asked the same question, their tone or emotional changes (e.g., the previous method didn't work), or whether they proactively provided new information (e.g., after taking the medicine you recommended, my stomach feels much better).
[0086] The system precisely correlates the feedback it receives with the specific dialogue responses that triggered that feedback. For example, it may know that a user gave a 5-star review specifically for the suggestion to practice the Eight-Section Brocade exercise, or that the user's expressed confusion was related to an explanation of Yin deficiency with excessive Yang.
[0087] Based on the results of the correlation analysis, the system intelligently updates the corresponding fields in the structured user profile.
[0088] The update process is a fine-tuning process. For example, if a user provides positive feedback on a certain type of suggestion (such as dietary therapy), the weight or confidence of dietary therapy preference under the preference information in their user profile is increased; conversely, if a user explicitly rejects a certain approach, it is recorded as a new contraindication. User feedback regarding symptom relief or ineffectiveness is converted into updates to the relevant symptom status or treatment efficacy in historical diagnostic features. For example, updating the status of currently taking Plan A to having discontinued Plan A indicates ineffective feedback and may lead to new features such as insensitivity to a certain type of herb. When user feedback repeatedly confirms or refutes a certain inference of the system (such as constitution assessment), the confidence of that feature in the profile will increase or decrease accordingly, providing a more reliable reference for future diagnosis. New symptoms, new habits, etc., mentioned in user feedback are extracted as new factual information, stored in the memory bank, and integrated into the user profile summary.
[0089] In this embodiment, after each round of dialogue, long-term valuable medical information and individual characteristic information are extracted from the dialogue content and user feedback to form structured long-term memory entries, which are then stored in a long-term memory bank. Memory entries in the long-term memory bank may include, but are not limited to, descriptions of symptoms and signs, duration and changes, intervention measures and response results, risk warnings, preferences and contraindications, compliance and feasibility information, etc. Subsequently, the user profile formation module aggregates and updates based on historical long-term memory and newly added memory in the current round, forming an evolvable user health profile (long-term user state). At the beginning of subsequent dialogues, the user profile preparation module reads this user health profile and injects it into a unified dialogue state object, enabling the system to stably obtain a summary of individual health facts and trends that should be continuously used in each interaction. Therefore, this embodiment can maintain a consistent understanding of the same user's health background in multi-round, cross-conversation medical dialogues, reduce suggestion bias caused by the omission of key historical facts, and support continuous tracking of symptom change trends and intervention effects, thereby achieving a continuous and evolvable health service effect for individuals.
[0090] Based on the above embodiments, the method further includes: Long-term care tasks are generated based on the changing trends of user profiles; long-term care tasks include at least one of the following: follow-up reminders, exercise recommendations, and personalized content recommendations.
[0091] In practice, the system periodically (e.g., daily or weekly) scans and analyzes changes in key fields within user profiles. For example: it identifies a significant increase in the frequency of difficulty falling asleep over the past two weeks; it observes a sustained improvement in records of thick, greasy tongue coating after dietary adjustments; it notes a decrease in user acceptance ratings for traditional Chinese medicine decoctions following the most recent feedback; and it monitors a negative correlation between fatigue scores and exercise tracking records.
[0092] Based on the above trend analysis, the system calls upon a pre-defined care strategy rule base to deduce proactive intervention tasks to be performed. These tasks aim to consolidate therapeutic effects, prevent relapse, or promote healthy behaviors. If the system identifies a symptom that persists without improvement or a key indicator (such as a self-reported distress index) exceeding a threshold, it will automatically generate a scheduled follow-up task. For example: Follow-up reminder: The user's recurring insomnia trend has persisted for two weeks; a follow-up message is planned to be sent in 3 days to inquire about sleep improvement and current difficulties. Exercise / behavior recommendation: Combining the user's constitution (such as Qi deficiency) and current trend (such as increased fatigue), the system matches the most suitable intervention plan from the rule base. For example: If the system detects a decline in energy levels under the user's Qi deficiency constitution tag and no recent exercise records, it recommends starting low-intensity Baduanjin exercises and pushes a breakdown instructional video. Personalized content recommendation: Based on the user's interests and preferences (such as interest in medicinal cuisine) and changes in health needs (such as new onset of spleen and stomach disharmony), the system filters and pushes relevant articles, recipes, or popular science videos from the content library. For example, if a user adds a record of loose stools and their preference tags include "dietary therapy", the system will push an article titled "Selected Recipes for Strengthening the Spleen and Removing Dampness".
[0093] This application's embodiments intelligently generate long-term care tasks by analyzing the dynamic changing trends of user profiles, achieving a leap from one-off question-and-answer sessions to continuous health management. This enables the system to proactively plan and execute personalized services such as follow-up reminders, exercise suggestions, and content push notifications, significantly enhancing the continuity, foresight, and user engagement of health interventions. Ultimately, it promotes the transformation of health management from a passive response to a proactive, adaptive care model, helping users achieve their long-term health improvement goals.
[0094] Based on the above embodiments, the method further includes: If the dialogue response references an external knowledge base, add a reference marker to the corresponding part of the dialogue response.
[0095] In the specific implementation process, for situations where external knowledge bases are referenced in the dialogue response content, such as during the information augmentation text generation stage, when the system retrieves, sorts, and integrates information fragments from external knowledge bases, it can automatically bind the source metadata to an adopted information fragment. This metadata includes at least: the knowledge base name (e.g., "Chinese Materia Medica"), the specific entry ID or title, and the version number (if any). This information augmentation text with implicit source tags is then fed into the generation model. The large language model generates a response based on the augmented text with source tags, historical memory, and user profiles. During the generation process, when the model decides to reference a piece of external knowledge to support its statement (e.g., explaining the properties and meridians of Astragalus membranaceus), it associates the corresponding source tag with the generated text fragment. Before finally outputting the response content, the system performs post-processing, scanning all locations in the generated text associated with source tags. At these locations, the system inserts a pre-formatted citation identifier.
[0096] This application's embodiments, by adding citation markers, not only significantly improve the professional credibility and transparency of the system's responses, enabling users or professionals to verify the basis, but also enhance the system's interpretability. Furthermore, this citation data can be recorded for subsequent analysis of the system's dependence on different knowledge sources, providing feedback for optimizing knowledge base retrieval strategies and forming a closed loop to improve content quality.
[0097] Figure 2 This is a schematic flowchart of another method for generating TCM dialogues provided in an embodiment of this application. The large language model may include a user input receiving module, a user profile preparation module, an intent recognition module, a parallel subtask execution module, a retrieval and reordering module, a large language model generation module, a tool invocation execution module, a dialogue storage module, an extraction and memory module, and a user profile formation module. The specific steps are as follows: The user input receiving module is responsible for receiving natural language input from the user terminal. This input can be text or text generated after speech recognition. After receiving the input, the module performs normalization processing and passes the processed user input to subsequent modules for further semantic analysis and dialogue progression.
[0098] The user profile preparation module extracts user history information from the long-term memory before each round of dialogue to construct the current user profile. The user profile data extracted by this module includes the user's basic information, health preferences, historical interaction behavior tags, and previous medical treatment summaries, which are used to provide a personalized context for the current round of dialogue.
[0099] The intent recognition module performs semantic analysis on the natural language input received from the user input receiving module to identify the user's intent or request category in the current dialogue, such as medical consultation, recommendation requests, or lifestyle adjustments. Simultaneously, this module generates reference control signals for subsequent policy calculations based on the recognition results, which are used by the policy preparation subtask.
[0100] The parallel subtask execution module is used to trigger multiple subtasks in parallel based on a unified dialogue state. Each subtask is executed in parallel based on the current input and dialogue state, and its execution results are written back to the unified dialogue state management object without blocking the main process. The parallel subtasks include at least an information retrieval enhancement subtask, a memory retrieval subtask, and a strategy preparation subtask.
[0101] The information retrieval enhancement subtask, within the parallel subtask module, is responsible for retrieving text or structured content relevant to the current dialogue from one or more external knowledge bases or ontology knowledge sets based on the semantic and contextual information of the current input, in order to enrich and improve the accuracy of the dialogue generation context.
[0102] The memory retrieval subtask, located within the parallel subtask module, is used to retrieve historical memory information related to the current dialogue turn from the long-term memory bank. This historical memory information includes past dialogue fragments, behavioral characteristics, and user interaction tags, in order to provide personalized feature information for the current dialogue.
[0103] The strategy preparation subtask generates a dynamic service policy within the parallel subtask module based on the intent recognition results and the current dialogue state. This dynamic service policy includes control signals to guide dialogue generation and action execution, such as whether to invoke external tools, whether to trigger specific subtasks, and whether to update the user profile. After obtaining the dynamic service policy, corresponding operations are performed based on it. For example, if the dynamic service policy is to invoke external tools, then the external tools are invoked to obtain the relevant information.
[0104] After the memory retrieval subtask completes the retrieval in parallel, the retrieval reordering module is responsible for sorting and merging the retrieval results based on indicators such as relevance and timestamps, forming high-quality reference context data for the dialogue generation module.
[0105] The large language model generation module generates the dialogue response content for the current round based on a unified dialogue state, sorted retrieval enhancement context, user profile information, and dynamic service strategies. The generation process supports streaming output, allowing users to receive the generated content incrementally before it is completed, and the generated result can also be submitted as a complete dialogue response.
[0106] During the generation of the large language model, the tool execution module selectively triggers specific tool execution operations based on the control information output by the subtasks prepared according to the strategy. For example, it calls the traditional Chinese medicine knowledge base based on the user's symptoms and cites relevant knowledge of traditional Chinese medicine theory in the text.
[0107] The dialogue storage module is used to store the user input content and the response content generated by the large language model in the current dialogue into the database. This dialogue is used to maintain the contextual continuity of the current dialogue round so that it can be called in subsequent dialogue rounds.
[0108] After the dialogue is generated, the memory extraction module determines whether to extract important information contained in the current dialogue as long-term memory based on the content of the current dialogue and the historical context, and stores the extracted long-term memory information into the long-term memory bank for use in subsequent dialogue calls and profile updates.
[0109] The memory extraction process involves a large model filtering information based on the semantic type and long-term value of the dialogue information, extracting information with reusable value or a lasting impact on health management as long-term memory entries. These information types include, but are not limited to: factual information (such as symptom presentation, duration, past medical history, test results, etc.), preference information (such as dietary preferences, contraindications, lifestyle habits, willingness to implement interventions, etc.), model-analytical information (such as stage-specific assessments, constitution or syndrome tendencies, etc.), tongue and facial diagnostic features, and intervention measures and their effect feedback. Extracted memory entries are tagged with multidimensional labels during storage, such as category labels for lifestyle habits, constitution, symptoms, medical history, diet, medication, intervention implementation, and risk warnings, and metadata such as timestamps, importance scores, confidence levels, status markers, and expiration dates are also recorded. Based on the aforementioned metadata, the system performs refined management of long-term memory, including merging and updating items on the same topic, detecting and handling conflicts, dynamically adjusting importance, and extracting trends and summarizing them in stages. This ensures that long-term memory remains updatable, traceable, and evolving, thereby supporting stable reuse across sessions and continuous personalized health management.
[0110] The data components include long-term memory, a health knowledge base, a user information database, a policy template library, and an execution record library. These data components provide the necessary data support for information retrieval, dialogue generation, policy calculation, and user profiling.
[0111] The subtask execution module is used to execute additional tasks in the background asynchronously or to trigger them on demand, other than the main process. This module can perform actions such as data analysis, updating recommended content, and pushing lifestyle suggestions, thereby enriching the system's health service capabilities.
[0112] The user profile generation module integrates user long-term memory, historical preferences, interaction tags, and current conversation information to create or update user profiles, and stores the updated user profiles in the user profile database. The updated user profile information can be used as a basis for subsequent conversations to achieve long-term personalized dialogue and health service suggestions.
[0113] This application embodiment integrates intent recognition results, user profile summaries, and multi-source retrieval information into a reference control signal to guide the generation of dialogue and the triggering of health service actions. Compared to methods that rely solely on single-turn input or fixed templates for recommendations / prompts, this application embodiment can determine whether to trigger long-term care actions based on the user's long-term status, including but not limited to follow-up reminders, trend reviews, intervention execution prompts and feedback collection, and personalized content recommendations (such as health cards, popular science content, or guidance videos), ensuring that action triggering is consistent with the user's long-term characteristics, thereby improving the targeting and continuity of personalized services.
[0114] To address the requirements for professional basis and explainability in medical, especially Traditional Chinese Medicine (TCM) scenarios, this application embodiment accesses the TCM knowledge base through a tool invocation module under policy guidance. This obtains TCM theoretical support information (including but not limited to meridian and organ relationships, constitution / syndrome tendencies, treatment principles and precautions, etc.) that matches the current user profile, symptom characteristics, or health needs. This information is then written into a unified dialogue state object in the form of structured evidence entries. The dialogue generation module explicitly integrates these evidence entries when generating responses, enabling the system to present the theoretical basis and citation path when providing suggestions and explanations. Because the theoretical support information is obtained and structurally injected through tool invocation, rather than relying entirely on impromptu inference from a language model, it helps improve the professional consistency and traceability of the suggested content and reduces the risk of generating contradictory explanations for similar questions in different rounds.
[0115] Furthermore, this application embodiment executes some long-term care capabilities in the background, isolating additional actions such as recommendation updates, trend analysis, card creation, and evaluation calculations from the main dialogue output in terms of execution sequence. This makes the impact on the main dialogue chain more controllable when expanding new medical service actions or tool capabilities, and prevents anomalies in additional tasks from easily interfering with the availability of the main dialogue, thereby improving the overall reliability and maintainability of the system. In engineering implementation, information retrieval, memory retrieval, and strategy calculation can be scheduled in parallel or asynchronously to further improve the real-time performance of the interaction, without affecting the core effects of long-term memory extraction, profile evolution, and continuous personalized medical services in this application embodiment.
[0116] In summary, the embodiments of this application, through technical means such as structured extraction and lifecycle-based accumulation of long-term memory, evolution and pre-injection of user profiles, strategy-driven long-term care actions, tool-based generation of TCM theoretical support, and isolated execution of background care tasks, have achieved objective improvements with causal chain support compared to existing technologies in terms of cross-session consistency, personalized continuous service, trend tracking capabilities, professional interpretability, and system scalability.
[0117] Figure 3 This application provides a schematic diagram of a TCM dialogue generation device based on a large language model, which can be a module, program segment, or code on an electronic device. It should be understood that this device is similar to the one described above. Figure 1 The method implementation corresponds to this and can be executed. Figure 1 The specific functions of the device involved in the method embodiment can be found in the description above; to avoid repetition, detailed descriptions are omitted here. The device includes: an information receiving module 301, an intent recognition module 302, a memory retrieval module 303, and a dialogue generation module 304, wherein: The information receiving module 301 is used to obtain the user profile after receiving the user's consultation information; wherein, the user profile is generated from the user's historical diagnostic features and preference information extracted from the long-term memory; the historical diagnostic features and preference information are extracted from multiple historical dialogues; The intent recognition module 302 is used to perform semantic recognition based on the consultation information to obtain the user's needs and intent; The memory retrieval module 303 is used to retrieve historical memory entries related to the current dialogue turn from the long-term memory bank based on the demand intent; the long-term memory bank also contains memory entries related to the user's health extracted from multiple dialogues within a historical time period. The dialogue generation module 304 is used to generate dialogue response content for the current round based on historical memory entries and user profiles.
[0118] Based on the above embodiments, the device further includes an information enhancement module, used for: Based on the consultation information and corresponding context information, information-enhanced text related to the current round of dialogue is retrieved from external TCM knowledge bases and / or local knowledge sets. Accordingly, the dialogue generation module 304 is specifically used for: The dialogue response content for the current round is generated based on the enhanced text, the historical memory entries, and the user profile.
[0119] Based on the above embodiments, the device further includes a dynamic service module, used for: Based on the stated demand intent and the stated user profile, a dynamic service strategy is generated that conforms to the user's physical condition and syndrome background. Accordingly, the dialogue generation module 304 is specifically used for: The dialogue response content for the current round is generated based on the dynamic service strategy, the information enhancement text, the historical memory entries, and the user profile.
[0120] Based on the above embodiments, the device further includes an information sorting module, used for: When there are multiple historical memory entries, the importance index corresponding to each historical memory entry is calculated based on the relevance of each historical memory entry to the demand intent and the timestamp; Multiple historical memory entries were ranked according to the aforementioned importance index.
[0121] Based on the above embodiments, the information enhancement module is specifically used for: Based on the consultation information and corresponding context information, multiple pieces of enhanced information are retrieved from external TCM knowledge bases and / or local knowledge sets; Based on the relevance of each piece of enhanced information to the stated intent, multiple pieces of enhanced information are sorted and fused to obtain the enhanced text.
[0122] Based on the above embodiments, the device further includes a memory bank update module, used for: Based on preset extraction rules, target information is extracted from the dialogue response content and stored in a long-term memory. The preset extraction rules are used to extract at least one of the following: factual information, intervention information, preference and taboo information, model analysis information, and traditional Chinese medicine identification information.
[0123] Based on the above embodiments, the memory bank update module is specifically used for: The timestamp, tag, and confidence level of the target information are generated; If it is determined based on the tag that the long-term memory contains an entry that is identical to the target information, then the information corresponding to the entry and the target information are archived together, and the target information, the corresponding timestamp, and the confidence level are inserted under the entry. If it is determined based on the label that the long-term memory does not contain an entry identical to the target information, then the target information, the timestamp, and the confidence level are added to the long-term memory incrementally.
[0124] Based on the above embodiments, the device further includes a feedback module, used for: Obtain user feedback and update the user profile based on the dialogue responses and user feedback.
[0125] Based on the above embodiments, the device further includes a long-term care module, used for: Long-term care tasks are generated based on the changing trends of the user profile; the long-term care tasks include at least one of follow-up reminders, exercise recommendations, and personalized content recommendations.
[0126] Based on the above embodiments, the information receiving module 301 is specifically used for: Extract the user's historical diagnostic features and preference information from the long-term memory; The user's basic symptoms and personalized information are generated based on the historical diagnostic features and the preference information; the personalized information includes at least one of the following: constitution classification tags, previous tongue images, offline medical history, medication records, and face-to-face consultation records.
[0127] Based on the above embodiments, the device further includes a reference module, used for: If the dialogue response content references an external knowledge base, a reference identifier is added to the corresponding part of the dialogue response content.
[0128] Figure 4 This is a schematic diagram of the physical structure of the electronic device provided in the embodiments of this application, such as... Figure 4 As shown, the electronic device includes: a processor 401, a memory 402, and a bus 403; wherein: The processor 401 and the memory 402 communicate with each other through the bus 403; The processor 401 is used to call program instructions in the memory 402 to execute the methods provided in the above-described method embodiments.
[0129] Processor 401 can be an integrated circuit chip with signal processing capabilities. The processor 401 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the various methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor can be a microprocessor or any conventional processor.
[0130] The memory 402 may include, but is not limited to, random access memory (RAM), read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), etc.
[0131] This embodiment discloses a computer program product, which includes a computer program stored on a non-transitory computer-readable storage medium. The computer program includes program instructions, and when the program instructions are executed by a computer, the computer can perform the methods provided in the above-described method embodiments.
[0132] This embodiment provides a non-transitory computer-readable storage medium that stores computer instructions that cause the computer to execute the methods provided in the above-described method embodiments.
[0133] In the embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. The apparatus embodiments described above are merely illustrative. For example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. Furthermore, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Additionally, the displayed or discussed mutual couplings, direct couplings, or communication connections may be through some communication interfaces; indirect couplings or communication connections between devices or units may be electrical, mechanical, or other forms.
[0134] Furthermore, the units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0135] Furthermore, the functional modules in the various embodiments of this application can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.
[0136] In this document, relational terms such as first and second are used only to distinguish one entity or operation from another entity or operation, without necessarily requiring or implying any such actual relationship or order between these entities or operations.
[0137] The above description is merely an embodiment of this application and is not intended to limit the scope of protection of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of protection of this application.
Claims
1. A method for generating TCM dialogues based on a large language model, characterized in that, include: After receiving the user's consultation information, a user profile of the user is obtained; wherein, the user profile is generated from the user's historical diagnostic features and preference information extracted from the long-term memory; the historical diagnostic features and preference information are obtained from multiple historical sessions; Based on the consultation information, semantic recognition is performed to obtain the user's needs and intentions; Based on the stated intent, historical memory entries related to the current conversation turn are retrieved from the long-term memory bank; the long-term memory bank also contains memory entries related to the user's health extracted from multiple conversations within a historical time period. The dialogue response content for the current round is generated based on the historical memory entries and the user profile.
2. The method according to claim 1, characterized in that, The method further includes: Based on the consultation information and corresponding context information, information-enhanced text related to the current round of dialogue is retrieved from external TCM knowledge bases and / or local knowledge sets. The process of generating the dialogue response content for the current round based on the historical memory entries and the user profile includes: The dialogue response content for the current round is generated based on the enhanced text, the historical memory entries, and the user profile.
3. The method according to claim 2, characterized in that, The method further includes: Based on the stated demand intent and the stated user profile, a dynamic service strategy is generated that conforms to the user's physical condition and syndrome background. The process of generating the dialogue response content for the current round based on the enhanced text, the historical memory entries, and the user profile includes: The dialogue response content for the current round is generated based on the dynamic service strategy, the information enhancement text, the historical memory entries, and the user profile.
4. The method according to claim 1, characterized in that, After retrieving historical memory entries related to the current dialogue turn from the long-term memory bank based on the stated demand intent, the method further includes: When there are multiple historical memory entries, the importance index corresponding to each historical memory entry is calculated based on the relevance of each historical memory entry to the demand intent and the timestamp; Multiple historical memory entries were ranked according to the aforementioned importance index.
5. The method according to claim 2, characterized in that, The step of retrieving enhanced text from an external TCM knowledge base and / or a local knowledge set based on the consultation information and corresponding context information includes: Based on the consultation information and corresponding context information, multiple pieces of enhanced information are retrieved from external TCM knowledge bases and / or local knowledge sets; Based on the relevance of each piece of enhanced information to the stated intent, multiple pieces of enhanced information are sorted and fused to obtain the enhanced text.
6. The method according to claim 1, characterized in that, After generating the dialogue response content for the current round, the method further includes: Based on preset extraction rules, target information is extracted from the dialogue response content and stored in a long-term memory. The preset extraction rules are used to extract at least one of the following: factual information, intervention information, preference and taboo information, model analysis information, and traditional Chinese medicine identification information.
7. The method according to claim 6, characterized in that, The step of storing the target information into a long-term memory includes: The timestamp, tag, and confidence level of the target information are generated; If it is determined based on the tag that the long-term memory contains an entry that is identical to the target information, then the information corresponding to the entry and the target information are archived together, and the target information, the corresponding timestamp, and the confidence level are inserted under the entry. If it is determined based on the label that the long-term memory does not contain an entry identical to the target information, then the target information, the timestamp, and the confidence level are added to the long-term memory incrementally.
8. The method according to claim 1, characterized in that, The method further includes: Obtain user feedback and update the user profile based on the dialogue responses and user feedback.
9. The method according to claim 8, characterized in that, The method further includes: Long-term care tasks are generated based on the changing trends of the user profile; the long-term care tasks include at least one of follow-up reminders, exercise recommendations, and personalized content recommendations.
10. The method according to claim 1, characterized in that, The process of obtaining the user profile includes: Extract the user's historical diagnostic features and preference information from the long-term memory; The user's basic symptoms and personalized information are generated based on the historical diagnostic features and the preference information; the personalized information includes at least one of the following: constitution classification tags, previous tongue images, offline medical history, medication records, and face-to-face consultation records.
11. The method according to any one of claims 1-10, characterized in that, The method further includes: If the dialogue response content references an external knowledge base, a reference identifier is added to the corresponding part of the dialogue response content.
12. A TCM dialogue generation device based on a large language model, characterized in that, include: The information receiving module is used to obtain a user profile of the user after receiving the user's consultation information; wherein, the user profile is generated from the user's historical diagnostic features and preference information extracted from a long-term memory bank; the historical diagnostic features and preference information are obtained from multiple historical dialogues; The intent recognition module is used to perform semantic recognition based on the consultation information to obtain the user's demand intent; The memory retrieval module is used to retrieve historical memory entries related to the current dialogue turn from the long-term memory bank based on the stated demand intent; the long-term memory bank also contains memory entries related to the user's health extracted from multiple dialogues within a historical time period. The dialogue generation module is used to generate dialogue response content for the current round based on the historical memory entries and the user profile.
13. An electronic device, characterized in that, include: Processor, memory, and bus, among which: The processor and the memory communicate with each other via the bus; The memory stores program instructions that can be executed by the processor, and the processor can invoke the program instructions to perform the method as described in any one of claims 1-11.
14. A non-transitory computer-readable storage medium, characterized in that, The non-transitory computer-readable storage medium stores computer instructions that, when executed by a computer, cause the computer to perform the method as described in any one of claims 1-11.
15. A computer program product, characterized in that, It includes computer program instructions, which, when read and executed by a processor, perform the method as described in any one of claims 1-11.