A traditional chinese medicine ancient and modern situation comparison method based on agent loss

By constructing a structured network of ancient and modern Chinese medical records and using a deep metric learning method with differentiated proxy loss, the semantic gap between ancient and modern Chinese medical records was solved, achieving high-precision intelligent comparison and knowledge association of cross-era medical records.

CN121122776BActive Publication Date: 2026-05-01SOUTH CHINA UNIV OF TECH
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
SOUTH CHINA UNIV OF TECH
Filing Date
2025-09-10
Publication Date
2026-05-01

AI Technical Summary

Technical Problem

Existing technologies struggle to effectively bridge the semantic gap between ancient and modern medical records in traditional Chinese medicine, resulting in significant differences in semantic expression between ancient and modern medical records. This makes it impossible to achieve efficient and accurate intelligent comparison and knowledge association of cross-era medical record contexts.

Method used

We construct a structured network of ancient and modern Chinese medical records. Through data preprocessing, text structuring, semantic feature extraction, and semantic similarity analysis, we utilize a deep metric learning method with differentiated proxy loss to achieve high-precision contextual semantic comparison of ancient and modern medical records.

Benefits of technology

It achieves high-precision, automated, and multi-dimensional cross-era intelligent comparison of medical records from ancient and modern times, eliminates unstructured noise, enhances intra-class tightness and inter-class distinguishability, and supports bidirectional high-precision retrieval.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121122776B_ABST
    Figure CN121122776B_ABST
Patent Text Reader

Abstract

The application discloses a traditional Chinese medicine ancient and modern situation comparison method based on agent loss, and comprises the following steps: constructing a traditional Chinese medicine ancient and modern medical record structured network; inputting ancient and modern traditional Chinese medicine medical records into the traditional Chinese medicine ancient and modern medical record structured network to construct a structured medical record database; constructing a traditional Chinese medicine ancient and modern medical record semantic alignment network; collecting samples from the structured traditional Chinese medicine medical record database, and extracting global-local representations in each sample according to dimensions; training a semantic similarity analysis module by using a deep metric learning method based on a differentiated agent loss; realizing high-precision situation semantic comparison by using the traditional Chinese medicine ancient and modern medical record structured network and the traditional Chinese medicine ancient and modern medical record semantic alignment network; extracting multi-dimensional situation characteristics of the traditional Chinese medicine ancient and modern medical record by using the traditional Chinese medicine ancient and modern medical record structured network, and fusing the differentiated agent loss and the traditional Chinese medicine ancient and modern medical record semantic alignment network to realize precise bidirectional mapping and intelligent inheritance of cross-era traditional Chinese medicine diagnosis and treatment experience.
Need to check novelty before this filing date? Find Prior Art

Description

A method for comparing ancient and modern contexts of traditional Chinese medicine based on proxy loss Technical Field

[0001] This invention relates to the field of artificial intelligence, and in particular to a method for comparing ancient and modern contexts of traditional Chinese medicine based on agent loss. Background Technology

[0002] Traditional Chinese medicine (TCM) is the culmination of thousands of years of medical practice by the Chinese nation, and its core diagnostic and treatment wisdom is largely contained in the medical case records of physicians throughout history. These case records, written in text, detail the patient's symptoms, the physician's diagnostic reasoning, treatment principles and methods, and the application of prescriptions and medications. They are an indispensable and valuable resource for inheriting TCM clinical experience and improving diagnostic and treatment levels. However, due to the vast historical span, changes in language environment, evolution of diagnostic and treatment habits, and differences in recording standards, there is a significant "semantic gap" between ancient medical case records (such as classics like "Treatise on Febrile and Miscellaneous Diseases" and "Clinical Guidelines and Medical Case Records") and modern medical case records (recorded based on modern standard medical record systems or digital platforms). This has become a core bottleneck hindering the efficient inheritance and intelligent utilization of TCM experience.

[0003] First, the significant heterogeneity between ancient and modern languages ​​leads to a profound gap in semantic expression. Ancient medical records were mostly written in classical Chinese, with concise sentences, rich in allusions and metaphors (such as "sunstroke," "spleen fullness," and "chest knot"), and terms with specific historical and regional characteristics (such as "sha zhang" and "dong qiang"). Their semantic connotations often require a deep understanding of classical texts and professional knowledge to accurately interpret. In contrast, modern medical records are primarily written in vernacular Chinese, habitually using modern medical anatomy, physiology, pathology, and standardized diagnostic terminology (such as "upper respiratory tract infection," "chronic gastritis," and "pleural effusion"). The expressions are more intuitive and specific, and the structure is clearer. This fundamental difference in linguistic paradigms means that symptoms or signs expressing similar clinical realities (for example, the ancient medical records terms "depression" and "hysteria" versus the modern mental health terms "depression" and "anxiety") may present completely different forms in textual representation, making direct and effective semantic comparison and association difficult.

[0004] Secondly, the implicit expression and structural differences in diagnostic and treatment logic exacerbate the difficulty of cross-generational understanding. Traditional Chinese medicine medical records often follow the characteristic of "describing without creating," where the internal logic of the physician's diagnosis and treatment (such as the analysis of etiology and pathogenesis, the deduction of the eight principles of visceral differentiation, and the derivation chain of theory, method, prescription, and medicine) is usually implicit in the narrative description of symptoms and the selection of prescriptions and medications, lacking explicit structured labels. Although modern medical records have made significant progress in structured recording (such as chief complaint, present illness history, past medical history, diagnosis, treatment method, and prescription), both still lack a unified and interoperable mapping framework in terms of the precision of the differentiation of diagnostic dimensions, the scope of the definition of core concepts (such as the connotation of "syndrome"), and the level of detail in the description of treatment methods. This makes it difficult to have effective standardized means when extracting key diagnostic and treatment decision elements (disease, syndrome, symptoms, cause, location, nature, method, prescription, and medicine) and making precise correspondences.

[0005] Furthermore, existing technological methods struggle to effectively bridge the aforementioned semantic gap, hindering the deep interaction and application of cross-generational experiences. Traditional text analysis methods based on keyword matching or pre-defined rule templates exhibit insufficient robustness and generalization ability when faced with rich variations in ancient and modern terminology, subtle shifts in the meaning of the same term (such as the difference between the ancient and modern meanings of "typhoid fever"), and the complexity of contextual dependence. While general-purpose deep semantic models that have emerged in recent years (such as text representation models based on BERT and LSTM) can extract certain levels of textual features, they are typically trained on non-medical or single-temporal representative corpora, lacking targeted modeling for the unique context of Traditional Chinese Medicine and the systematic shifts in semantic patterns between ancient and modern times. Without specific design, such models are prone to misclassifying clinical situations with similar ancient expressions as having significant semantic differences (e.g., classifying cases of "qi deficiency fever" with different ancient and modern expressions as irrelevant), or misaligning situations with similar modern expressions but different clinical manifestations (e.g., cases with the same symptom of "fever" but different core pathogenesis), failing to support accurate and reliable cross-generational semantic similarity measurement. Furthermore, most existing information systems or tools focused on medical case analysis can only handle medical cases from a single era, or fail to deeply integrate the unique and complete diagnostic and treatment decision-making chain structure of traditional Chinese medicine in terms of analytical dimensions, and fail to construct a semantic space that can be compatible with both ancient and modern characteristics and decoupled and aligned according to key dimensions (disease, syndrome, symptom, method, prescription, medicine).

[0006] Therefore, the valuable clinical experience contained in the vast amount of ancient and modern medical records is difficult to efficiently and accurately achieve bidirectional mapping and intelligent inheritance. Manual comparison methods, which heavily rely on individual expert knowledge and experience, are inefficient, difficult to scale, and cannot support deep knowledge discovery in the context of big data. This bottleneck severely restricts the use of ancient wisdom to provide accurate references for modern clinical decision-making, and hinders the practice of "mutual learning between the past and present"—using modern effective experience to enrich the understanding of classical theories—impeding the pace of cross-temporal inheritance and innovation of TCM diagnostic and treatment experience. Currently, the field urgently needs a novel technological solution that can effectively identify and overcome the semantic heterogeneity of ancient and modern TCM texts, construct a unified, structured semantic representation space for TCM diagnostic and treatment elements, and ultimately achieve high-precision, automated, and multi-dimensional cross-era intelligent comparison and knowledge association of medical records. Summary of the Invention

[0007] (1) Technical problems to be solved

[0008] This invention discloses a method for comparing ancient and modern Chinese medicine contexts based on proxy loss, aiming to solve the problems of low recognition accuracy and low intelligence level of existing ancient and modern Chinese medicine models.

[0009] (2) Technical solution

[0010] This invention provides a method for comparing ancient and modern contexts of traditional Chinese medicine based on proxy loss, comprising the following steps:

[0011] Step 1: Construct a structured network of ancient and modern Chinese medical records, including a data preprocessing module and a text structuring module;

[0012] Step 2: Ancient and modern TCM medical records are used as inputs to the TCM ancient and modern medical record structured network. Key dimension information is extracted and transformed into structured contextual text using the data preprocessing module and the trained text structuring module to construct a structured medical record database.

[0013] Step 3: Construct a semantic alignment network for ancient and modern Chinese medical records, including a sampling module, a semantic feature extraction module, and a semantic similarity analysis module;

[0014] Step 4: Collect several samples from the structured TCM medical record database through the sampling module, and extract global-local representations from each sample according to each dimension through the semantic feature extraction module.

[0015] Step 5: Input each global-local representation into the semantic similarity analysis module, and train the semantic similarity analysis module using a deep metric learning method based on differential proxy loss;

[0016] Step 6: Use the trained structured network of ancient and modern Chinese medical records and the semantic alignment network of ancient and modern Chinese medical records to achieve high-precision contextual semantic comparison.

[0017] Furthermore, step 2 is specifically as follows:

[0018] Step 201: The ancient and modern TCM medical records are preprocessed by the data preprocessing module and converted into the format of prompt words - TCM medical records.

[0019] Step 202: Input the preprocessed ancient Chinese medicine medical records and modern Chinese medicine medical records into the text structuring module respectively, and train the text structuring module through low-rank adaptive parameter fine-tuning method and autoregressive loss fine-tuning.

[0020] Step 203: Use the fine-tuned text structuring module to extract key dimension information from ancient and modern TCM medical records and transform it into corresponding structured contextual text to jointly construct a structured medical record database.

[0021] Furthermore, step 201 specifically involves the following steps:

[0022] Step 20101: Construct guiding prompts;

[0023] Step 20102: Construct and extract format hint words;

[0024] Step 20103: Construct example prompt words;

[0025] Step 20104: Concatenate the guiding prompt, the extracted format prompt, and the example prompt in sequence to obtain the merged prompt Prompt;

[0026] Step 20105: Concatenate the ancient and modern TCM medical records according to the format [{"role": "system", "content": Prompt}, {"role": "user", "content": TCM medical record to be structured}] to obtain the preprocessed ancient and modern TCM medical records; where, the TCM medical record to be structured represents the input ancient or modern TCM medical record; role, system, content, user, and content are all input format guide words of the text structuring module.

[0027] Further, step 20102 includes the following:

[0028]

[0029] in, It is a key dimension of TCM context evaluated by TCM experts, including the spatiotemporal dimension, the actor, clinical decision-making, and doctor-patient interaction;

[0030] These are the key sub-dimensions corresponding to the key macro-dimensions of the TCM context as assessed by TCM experts, including:

[0031] The corresponding time of medical visit, seasonal climate, and location of treatment in the spatiotemporal dimension;

[0032] The subjects of the action include: doctors, other personnel, patient names, patient gender, age, previous patients, marital and reproductive status, endowment, physical characteristics, living habits, occupation, emotional characteristics, and dietary preferences;

[0033] Clinical decision-making includes corresponding auxiliary diagnosis and treatment, symptoms / signs, previous medical treatment process, disease name, syndrome type, treatment, and number of visits;

[0034] The corresponding treatment efficacy assessment, compliance, patient's purpose of seeking medical treatment, and doctor's purpose of diagnosis and treatment in the context of doctor-patient interaction;

[0035] A clear definition for each key sub-dimension;

[0036] This indicates the number of the key subdimensions.

[0037] Furthermore, step 202 specifically includes the following steps:

[0038] Step 20201: Utilize a locally deployed general-purpose large language model as the text structuring module. Preprocessed ancient and modern TCM medical records are used as the model's training dataset. The training loss function employs autoregressive loss, which is used to determine the difference between the predicted probability of the next character and the target value. This follows the model pre-training paradigm to train the text structuring module. The specific formula for the autoregressive loss is as follows:

[0039] ;

[0040] ;

[0041] Among them, input For tokenized preprocessed text, For the current moment, Let be the entire probability distribution output by the model at time t. For the model at time step Predict the next preprocessed text The probability, Let be the prediction loss at time t. For autoregressive loss, This represents the total number of time steps.

[0042] Step 20202: Using the preprocessed ancient and modern TCM medical records as training datasets respectively, the text structuring module is fine-tuned using a low-rank adaptation method, with the specific formula as follows:

[0043]

[0044] in, For the input model, preprocessed text that is not tokenized, It is the original parameter matrix. It is a reduced-rank matrix. It is an increasing-rank matrix. As a response Additional adjustment items, overall weight During training, only updates are performed. and The parameters, Keep frozen.

[0045] Furthermore, step 4 specifically involves the following steps:

[0046] Step 401: First, classify the categories by disease name, and collect several samples from the structured TCM medical record database through the sampling module, with at least 2 samples extracted from each category;

[0047] Step 402: A locally deployed general text representation model is used as the semantic feature extraction module;

[0048] Step 403: Extract the semantic features of each sample by dimension through the semantic feature extraction module. The semantic features of each sample include local tensor representation and global tensor representation. The global tensor representation and local tensor representation are fused into a global-local representation.

[0049] Furthermore, step 5 specifically involves the following steps:

[0050] Step 501: Input the global-local representations of all samples into the multilayer perceptron in the semantic similarity analysis module. Then, establish the association between the local tensor representations and the global tensor representations one by one through the cross-attention mechanism in the multilayer perceptron. The specific formula is as follows:

[0051]

[0052] in, Cross-attention functions The query matrix, key matrix, and value matrix are defined in the matrix; is the transpose of the key matrix. The dimension of the key vector; It is an activation function;

[0053] Step 502: Perform normalized inner product on each of the global-local representations in the associated samples. The formula for normalized inner product is... as follows:

[0054]

[0055] in, , Let be any two vectors;

[0056] Step 503: Construct the differentiated proxy loss function, the specific formula of which is as follows:

[0057]

[0058] in, For differentiated proxy loss function; For batches of Zhengzheng agents; For negative agents in batches; This represents the global-local representation of all positive samples in the batch. This represents the global-local representation of all samples in the batch. A global-local representation of a single sample; Global-local representation of a single sample Learnable representations of disease categories Normalized inner product between A scaling factor to control the sensitivity of similarity to the loss; boundary threshold. Define the similarity boundaries between positive and negative sample pairs;

[0059] Step 504: Freeze all parameters of the semantic similarity analysis module and train the semantic similarity analysis module based on differential proxy loss.

[0060] Furthermore, step 6 specifically involves the following steps:

[0061] Step 601: Input ancient Chinese medicine medical records into the trained structured network of ancient and modern Chinese medicine medical records and transform it into structured contextual text;

[0062] Step 602: Extract global-local representations of structured contextual texts through the semantic feature extraction module and construct an index database of ancient Chinese medicine medical records;

[0063] Step 603: Input modern TCM medical records into the trained TCM ancient and modern medical record structured network and transform it into structured contextual text;

[0064] Step 604: Extract global-local representations of structured contextual texts through the semantic feature extraction module and construct a modern TCM medical record index database;

[0065] Step 605: Given a modern TCM medical record, input the TCM ancient and modern medical record structured network into a structured contextual text, input the structured contextual text into the TCM ancient and modern medical record semantic alignment network, extract global-local representations through the semantic feature extraction module, calculate the semantic similarity with ancient TCM medical records in the ancient TCM medical record index database using the semantic similarity analysis module, retrieve similar ancient medical records from the ancient TCM medical record index database, and select the top K results in descending order of similarity as output, thus realizing the search for similar ancient medical records using modern medical records;

[0066] Step 606: Given an ancient Chinese medicine medical record, input the ancient and modern Chinese medicine medical record structured network into a structured contextual text, input the structured contextual text into the ancient and modern Chinese medicine medical record semantic alignment network, extract global-local representations through the semantic feature extraction module, calculate the semantic similarity with modern Chinese medicine medical records in the modern Chinese medicine medical record index database using the semantic similarity analysis module, retrieve similar modern medical records from the modern Chinese medicine medical record index database, and select the top K results in descending order of similarity as output, thus realizing the search for modern similar medical records using ancient medical records.

[0067] Compared with the prior art, the beneficial effects of the present invention are as follows:

[0068] This invention presents a structured contextual representation framework that unifies the semantic expression of ancient and modern medical records across four dimensions, eliminating unstructured noise. It combines differentiated proxy loss with proxy center optimization to enhance intra-class tightness for positive samples and sample center optimization to improve inter-class discriminability for negative samples. A global-local feature fusion mechanism is designed, establishing the association between local features of each dimension and global contextual semantics through cross-attention, preserving fine-grained information. This is supplemented by a structured dimension constraint framework, forcing the model to learn within the four dimensions and avoiding semantic shift between ancient and modern times. A fully automated framework is integrated, from original medical record input → structured generation → semantic alignment → retrieval output, all in one step. Simultaneously, an index database of ancient and modern TCM medical records is constructed, supporting bidirectional high-precision retrieval.

[0069] This invention overcomes the semantic gap between ancient and modern Chinese medicine through the synergistic innovation of structured context representation and differentiated proxy loss. It breaks through technical bottlenecks in retrieval accuracy, training efficiency and cross-era adaptability, and provides a core driving force for the inheritance and innovation of traditional Chinese medicine. Attached Figure Description

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

[0071] Figure 1 is a flowchart illustrating the implementation method of the present invention.

[0072] Figure 2 is a schematic diagram of the structure of an embodiment of the present invention.

[0073] Figure 3 is a schematic diagram of the calculation of differentiated proxy loss in an embodiment of the present invention. Detailed Implementation

[0074] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, 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 some embodiments of the present invention, but 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.

[0075] As shown in Figure 1, this invention discloses a method for comparing ancient and modern contexts of traditional Chinese medicine based on proxy loss, comprising the following steps:

[0076] Step 1: Construct a structured network of ancient and modern Chinese medical records, including a data preprocessing module and a text structuring module;

[0077] Step 2: Ancient and modern TCM medical records are used as inputs to the TCM ancient and modern medical record structured network. Key dimension information is extracted and transformed into structured contextual text using the data preprocessing module and the trained text structuring module to construct a structured medical record database.

[0078] Step 3: Construct a semantic alignment network for ancient and modern Chinese medical records, including a sampling module, a semantic feature extraction module, and a semantic similarity analysis module;

[0079] Step 4: Collect several samples from the structured medical record database through the sampling module, and extract global-local representations from each sample according to each dimension through the semantic feature extraction module;

[0080] Step 5: Input each global-local representation into the semantic similarity analysis module, and train the semantic similarity analysis module using a deep metric learning method based on differential proxy loss;

[0081] Step 6: Use the trained structured network of ancient and modern Chinese medical records and the semantic alignment network of ancient and modern Chinese medical records to achieve high-precision contextual semantic comparison.

[0082] Specifically, in step 2, the data preprocessing module first preprocesses all ancient and modern TCM medical records in TCM classics such as the "Chinese Medical Encyclopedia" and converts them into the format of "prompt words-TCM medical records". Then, the preprocessed ancient and modern TCM medical records are used to train the text structuring module. Finally, the trained text structuring module is used to extract the key dimension information of ancient and modern TCM medical records and convert it into structured contextual text to build a structured medical record database.

[0083] Furthermore, the specific steps for step 2 in this example are as follows:

[0084] Step 201: The ancient and modern TCM medical records are preprocessed using the data preprocessing module to convert them into a "prompt word-TCM medical record" format. The specific steps are as follows:

[0085] Step 20101: Construct guiding prompts, the specific content of which is as follows:

[0086] The prompt message reads: "You are a TCM expert. Please strictly follow the given elements and their definitions to extract the elements that meet the definitions from the following TCM medical case. If certain elements are not present in the case, the content corresponding to those elements will be empty."

[0087] Step 20102: Construct and extract format hints, the details of which are as follows:

[0088]

[0089] in, It is a key dimension of TCM context (medical case) evaluated by TCM experts, including the spatiotemporal dimension, the actor, clinical decision-making and doctor-patient interaction;

[0090] These are the key sub-dimensions corresponding to the key macro-dimensions of the TCM context as assessed by TCM experts, including:

[0091] The corresponding time of medical visit, seasonal climate, and location of treatment in the spatiotemporal dimension;

[0092] The subjects of the action include: doctors, other personnel, patient names, patient gender, age, previous patients, marital and reproductive status, endowment, physical characteristics, living habits, occupation, emotional characteristics, and dietary preferences;

[0093] Clinical decision-making includes corresponding auxiliary diagnosis and treatment, symptoms / signs, previous medical treatment process, disease name, syndrome type, treatment, and number of visits;

[0094] The corresponding treatment efficacy assessment, compliance, patient's purpose of seeking medical treatment, and doctor's purpose of diagnosis and treatment in the context of doctor-patient interaction;

[0095] A clear definition for each key sub-dimension;

[0096] The specific representation format of the key macro-dimensional and key micro-dimensional aspects of the TCM context is as follows:

[0097] ;

[0098] The three key contexts of TCM medical cases in the spatiotemporal dimension are reading, namely the time of consultation, the season and climate, and the location of treatment.

[0099] ;

[0100] The number of key contextual dimensions in TCM medical cases under the subject of the action is as follows: doctor, other personnel, patient name, patient gender, age, previous illness, marital and reproductive status, endowment, physical characteristics, living habits, occupation, emotional characteristics, and dietary preferences.

[0101] ;

[0102] The seven key context dimensions of TCM medical cases under clinical decision-making are: auxiliary diagnosis and treatment, symptoms / signs, previous treatment process, disease name, syndrome type, treatment, and number of visits.

[0103] ;

[0104] The four key context dimensions of TCM medical cases under doctor-patient interaction are efficacy evaluation, compliance, patient's purpose of seeking medical treatment, and doctor's purpose of diagnosis and treatment.

[0105]

[0106] Clear definition of each subdimension as follows:

[0107] 1. Timing of consultation: The time when TCM diagnosis and treatment activities occur, including the historical stage and the influence of seasonal changes, diurnal rhythm factors, etc. on the diagnosis and treatment process and efficacy;

[0108] 2. Seasonal climate: refers to the phenomena of weather changes and the states and patterns of organisms that change with the weather;

[0109] 3. Location of diagnosis and treatment: The location where TCM diagnosis and treatment activities take place and the influence of its geographical and social environment on the diagnosis and treatment process and efficacy (east, south, west, north, and center);

[0110] 4. Physician: Record the physician's name to determine the impact of factors such as school of thought, clinical experience, and professional knowledge on the physician's clinical diagnosis and treatment.

[0111] 5. Other personnel: In addition to doctors and patients, other medical personnel and family members who may affect the diagnosis and treatment;

[0112] 6. Patient Name: Record the patient's name;

[0113] 7. Patient gender: refers to the patient's gender, divided into male and female;

[0114] 8. Age: refers to the patient's specific age or a certain stage of life;

[0115] 9. Pre-existing conditions: including past medical history, allergy history, family history, menstrual history, etc.

[0116] 10. Marital and reproductive status: including whether the patient has a spouse, the date of marriage, the number of spouses, the number of children born, and the number of children conceived;

[0117] 11. Endowments: including time of birth, place of birth, birth order, etc.;

[0118] 12. Physical characteristics: Individual differences in innate or acquired physiological characteristics, common ones include Qi deficiency, blood deficiency, Yin deficiency, Yang deficiency, phlegm-dampness, etc.

[0119] 13. Daily habits: Long-term abnormal behaviors and routines that affect health;

[0120] 14. Occupation: refers to the patient's current or past work type;

[0121] 15. Emotional characteristics: a tendency towards excessive emotional expression and regulation;

[0122] 16. Food preferences: a preference for specific foods or flavors;

[0123] 17. Auxiliary diagnosis and treatment: refers to the use of external tools to assist in the evaluation, early warning, and diagnosis of results, including test results, examination results, etc.

[0124] 18. Symptoms / Signs: Information obtained through the four diagnostic methods of inspection, auscultation, inquiry, and palpation in clinical practice. This includes physical examination. (Includes additional limiting information such as time and location before the symptoms / signs).

[0125] 19. Previous medical treatment process: For the current illness, the patient's previous treatment history for the disease;

[0126] 20. Disease name: refers to the traditional Chinese medicine and Western medicine disease names marked in the medical records;

[0127] 21. Syndrome type: refers to the TCM syndrome type marked in the medical record;

[0128] 22. Treatment: refers to the elements included in the treatment process, including treatment principles and methods, prescriptions and medicines, massage, acupuncture, acupoints, guided exercises, and recuperation methods, etc.

[0129] 23. Number of visits: refers to the order of all treatments in this medical record;

[0130] 24. Efficacy evaluation: refers to the evaluation of treatment results, including evaluations by physicians and patients, and is seen in the improvement of symptoms, worsening or new symptoms, symptoms of disease elimination reaction and symptoms that have not been relieved, and the analysis of their causes;

[0131] 25. Compliance: Content in the medical records that reflects the patient's compliance;

[0132] 26. Patient's purpose of seeking medical treatment: including symptom relief, disease prevention, and rehabilitation;

[0133] 27. The purpose of a doctor's diagnosis and treatment includes diagnosing diseases, developing treatment plans, and evaluating treatment effectiveness.

[0134] Step 20103: Construct example prompt words, the specific content of which is as follows:

[0135] Example prompt = "Here is an example, original text:" + example original text + extraction results;

[0136] Example Text: "Treatment of Suspended Fluid Retention with Supporting the Body's Resistance and Expelling the Pathogens: Tuberculous Pericarditis with Pericardial Effusion, diagnosed as suspended fluid retention due to external wind-cold invasion and failure to expel it, resulting in internal retention of fluid. Treatment focuses on supporting the body's resistance and expelling the pathogens. Ms. Hu, female, 22 years old. Initial visit: September 21, 1981. She had experienced chest tightness and stabbing pain for over 3 months. She had been diagnosed with tuberculous pericarditis, pericardial effusion, and second-degree atrioventricular block at another hospital. She had been treated for 3 months with anti-tuberculosis drugs, hormones, and diuretics, but still experienced chest tightness and stabbing pain, sometimes radiating to her back, feeling as if a millstone was pressing on her chest. She also had persistent coughing and wheezing, a sallow complexion, cyanosis of the lips and fingers, palpitations, pitting edema of the lower extremities, a wiry and slow pulse of 52 beats per minute, a dark tongue with a white and greasy coating. Further questioning revealed that the patient had been diagnosed in 197..." Eight years ago, during high school, the patient suffered from tuberculous pleurisy. Despite more than six months of anti-tuberculosis treatment, it was not completely cured. The patient is pale and thin, extremely weak, and prone to catching colds, which are often lingering and difficult to cure. Currently, the patient still experiences frequent chills, heaviness in the shoulders and back, and aches and pains in the muscles and joints throughout the body. The condition is attributed to external wind-cold invasion, which failed to be relieved, leading to internal retention of fluids, which gradually penetrated deeper into the internal organs. Since the source of the infection has been cleared, the initial treatment plan is to strengthen the body's resistance and expel the pathogenic factors, allowing the deeply entrenched pathogens to be expelled. Traditional Chinese Medicine Diagnosis: Suspended phlegm, syndrome due to external wind-cold invasion and internal retention of fluids. Prescription: Red ginseng (separately decocted), 10g each of five-spice powder, 6g each of notopterygium root, angelica root, angelica dahurica root, bupleurum root, chuanxiong rhizome, immature bitter orange peel, and platycodon root, 12g of poria cocos, 10g each of peach kernel and apricot kernel, 3g of mint, 5g of prepared licorice root, 3 slices of fresh ginger, and 4 jujubes. Decoct in water and take warm.

[0137] Example extraction result = "

[0138] 1. Spacetime dimension

[0139] a. Date of visit: September 21, 1981

[0140] b. Seasonal climate:

[0141] c. Location of treatment:

[0142] 2. Subject of the act

[0143] a. Physician: Li Ke

[0144] b. Other personnel:

[0145] c. Patient Name: Hu

[0146] d. Patient's gender: Female

[0147] e. Age: 22 years old

[0148] f. Previous illness: Upon further inquiry into the medical history, it was learned that the patient had tuberculous pleurisy when he was in high school in 1978. After more than half a year of anti-tuberculosis treatment, it could not be cured.

[0149] g. Marital and reproductive status:

[0150] h. Endowment status:

[0151] i. Physical characteristics:

[0152] j. Daily habits:

[0153] k. Occupation:

[0154] m. Occupation:

[0155] n. Emotional characteristics:

[0156] 1. Dietary preferences:

[0157] 3. Clinical decision-making

[0158] a. Auxiliary diagnostic and treatment tools:

[0159] b. Symptoms / Signs: A feeling of tightness and stabbing pain in the precordial region for over 3 months. Persistent coughing and wheezing, sallow complexion, cyanosis of the lips and fingers, palpitations, pitting edema of the lower extremities, a wiry and slow pulse (52 beats per minute), a dark tongue with a white, greasy coating. The patient is sallow-faced, emaciated, and extremely susceptible to colds, which are often prolonged and difficult to cure. Currently, the patient still experiences intermittent chills, heaviness in the shoulders and back, and general muscle and joint pain.

[0160] c. Previous medical treatment: The patient was diagnosed with tuberculous pericarditis, pericardial effusion, and second-degree atrioventricular block at a certain hospital. He had been treated for three months with anti-tuberculosis drugs, hormones, and diuretics, but still felt a dull, stabbing pain in the precordial region, sometimes radiating to the back, and felt as if a millstone was pressing on his chest.

[0161] d. Disease name: Traditional Chinese medicine diagnosis: Suspended phlegm.

[0162] e. Syndrome type: The syndrome is due to external wind-cold invasion and internal retention of water and fluid.

[0163] f. Treatment: Prescription: 10g each of red ginseng (stewed separately) and five-spice powder, 6g each of notopterygium root, angelica root, angelica dahurica root, bupleurum root, chuanxiong rhizome, immature bitter orange peel, and platycodon root, 12g of poria cocos, 10g each of peach kernel and apricot kernel, 3g of mint, 5g of prepared licorice root, 3 slices of fresh ginger, and 4 jujubes. Decocted in water and taken warm.

[0164] g. Number of visits: 1

[0165] 4. Doctor-patient interaction

[0166] a. Evaluation of therapeutic effect: The patient's mother reported that after taking the medicine, she felt very comfortable with a full-body sweat. All external symptoms disappeared, her chest felt more open, her pulse was wiry and slow at 60 beats per minute, and there was no longer any throbbing. The greasy coating on her tongue had mostly disappeared. Moreover, since sweating, her urination had increased, and her cough and wheezing had subsided.

[0167] b. Compliance:

[0168] c. Patient's purpose for seeking medical treatment:

[0169] d. Doctor's purpose of diagnosis and treatment:

[0170] "

[0171] Step 20104: Concatenate the guiding prompt, the extracted format prompt, and the example prompt in sequence to obtain the merged prompt, Prompt.

[0172] Step 20105: Concatenate the ancient and modern TCM medical records according to the format [{"role": "system", "content": Prompt}, {"role": "user", "content": TCM medical records to be structured}] to obtain the preprocessed ancient and modern TCM medical records.

[0173] Among them, the fusion prompt word Prompt is a prompt word applicable to the text structuring module, used to guide the instruction model; the TCM medical record to be structured represents the input ancient or modern TCM medical record; role, system, content, user, and content are all input format guide words of the text structuring module;

[0174] The following is an example of the "prompt word + TCM medical record" format:

[0175] [{“role”: “system”,

[0176] "content": (i.e., the prompt word part)

[0177] You are a TCM expert. Please strictly follow the given elements and element definitions to extract the elements that meet the definitions from the following TCM medical case. If certain elements are not present in the medical case, the content corresponding to those elements will be empty.

[0178] The following are the elements and their definitions:

[0179] ;

[0180] in, It is a key dimension of TCM context assessed by TCM experts, including spatiotemporal dimensions, actors, clinical decision-making, and doctor-patient interaction. These are the key sub-dimensions corresponding to the key macro-dimensions of TCM context as evaluated by TCM experts. These include: time of consultation, season and climate, location of treatment, physician, other personnel, patient name, patient gender, age, previous illnesses, marital and reproductive status, endowment, physical characteristics, daily habits, occupation, emotional characteristics, dietary preferences, auxiliary treatments, symptoms / signs, previous medical treatment process, disease name, syndrome type, treatment, number of consultations, efficacy evaluation, compliance, patient's purpose of medical treatment, and physician's purpose of treatment. For each subdivision, a clear definition is provided;

[0181] The specific representation format of the key macro-dimensional and key micro-dimensional aspects of the TCM context is as follows:

[0182] ;

[0183] The three key contexts of TCM medical cases in the spatiotemporal dimension are reading, namely the time of consultation, the season and climate, and the location of treatment.

[0184] ;

[0185] The number of key contextual dimensions in TCM medical cases under the subject of the action is as follows: doctor, other personnel, patient name, patient gender, age, previous illness, marital and reproductive status, endowment, physical characteristics, living habits, occupation, emotional characteristics, and dietary preferences.

[0186] ;

[0187] The seven key context dimensions of TCM medical cases under clinical decision-making are: auxiliary diagnosis and treatment, symptoms / signs, previous treatment process, disease name, syndrome type, treatment, and number of visits.

[0188] ;

[0189] The four key context dimensions of TCM medical cases under doctor-patient interaction are efficacy evaluation, compliance, patient's purpose of seeking medical treatment, and doctor's purpose of diagnosis and treatment.

[0190]

[0191] Clear definition of each subdimension as follows:

[0192] 1. Timing of consultation: The time when TCM diagnosis and treatment activities occur, including the historical stage and the influence of seasonal changes, diurnal rhythm factors, etc. on the diagnosis and treatment process and efficacy;

[0193] 2. Seasonal climate: refers to the phenomena of weather changes and the states and patterns of organisms that change with the weather;

[0194] 3. Location of diagnosis and treatment: The location where TCM diagnosis and treatment activities take place and the influence of its geographical and social environment on the diagnosis and treatment process and efficacy (east, south, west, north, and center);

[0195] 4. Physician: Record the physician's name to determine the impact of factors such as school of thought, clinical experience, and professional knowledge on the physician's clinical diagnosis and treatment.

[0196] 5. Other personnel: In addition to doctors and patients, other medical personnel and family members who may affect the diagnosis and treatment;

[0197] 6. Patient Name: Record the patient's name;

[0198] 7. Patient gender: refers to the patient's gender, divided into male and female;

[0199] 8. Age: refers to the patient's specific age or a certain stage of life;

[0200] 9. Pre-existing conditions: including past medical history, allergy history, family history, menstrual history, etc.

[0201] 10. Marital and reproductive status: including whether the patient has a spouse, the date of marriage, the number of spouses, the number of children born, and the number of children conceived;

[0202] 11. Endowments: including time of birth, place of birth, birth order, etc.;

[0203] 12. Physical characteristics: Individual differences in innate or acquired physiological characteristics, common ones include Qi deficiency, blood deficiency, Yin deficiency, Yang deficiency, phlegm-dampness, etc.

[0204] 13. Daily habits: Long-term abnormal behaviors and routines that affect health;

[0205] 14. Occupation: refers to the patient's current or past work type;

[0206] 15. Emotional characteristics: a tendency towards excessive emotional expression and regulation;

[0207] 16. Food preferences: a preference for specific foods or flavors;

[0208] 17. Auxiliary diagnosis and treatment: refers to the use of external tools to assist in the evaluation, early warning, and diagnosis of results, including test results, examination results, etc.

[0209] 18. Symptoms / Signs: Information obtained through the four diagnostic methods of inspection, auscultation, inquiry, and palpation in clinical practice. This includes physical examination. (Includes additional limiting information such as time and location before the symptoms / signs).

[0210] 19. Previous medical treatment process: For the current illness, the patient's previous treatment history for the disease;

[0211] 20. Disease name: refers to the traditional Chinese medicine and Western medicine disease names marked in the medical records;

[0212] 21. Syndrome type: refers to the TCM syndrome type marked in the medical record;

[0213] 22. Treatment: refers to the elements included in the treatment process, including treatment principles and methods, prescriptions and medicines, massage, acupuncture, acupoints, guided exercises, and recuperation methods, etc.

[0214] 23. Number of visits: refers to the order of all treatments in this medical record;

[0215] 24. Efficacy evaluation: refers to the evaluation of treatment results, including evaluations by physicians and patients, and is seen in the improvement of symptoms, worsening or new symptoms, symptoms of disease elimination reaction and symptoms that have not been relieved, and the analysis of their causes;

[0216] 25. Compliance: Content in the medical records that reflects the patient's compliance;

[0217] 26. Patient's purpose of seeking medical treatment: including symptom relief, disease prevention, and rehabilitation;

[0218] 27. The purpose of a doctor's diagnosis and treatment includes diagnosing diseases, developing treatment plans, and evaluating treatment effectiveness.

[0219] Here is an example, from the original text:

[0220] Example Text: "Treatment of Suspended Fluid Retention with Supporting the Body's Resistance and Expelling the Pathogens: Tuberculous Pericarditis with Pericardial Effusion, diagnosed as suspended fluid retention due to external wind-cold invasion and failure to expel it, resulting in internal retention of fluid. Treatment focuses on supporting the body's resistance and expelling the pathogens. Ms. Hu, female, 22 years old. Initial visit: September 21, 1981. She had experienced chest tightness and stabbing pain for over 3 months. She had been diagnosed with tuberculous pericarditis, pericardial effusion, and second-degree atrioventricular block at another hospital. She had been treated for 3 months with anti-tuberculosis drugs, hormones, and diuretics, but still experienced chest tightness and stabbing pain, sometimes radiating to her back, feeling as if a millstone was pressing on her chest. She also had persistent coughing and wheezing, a sallow complexion, cyanosis of the lips and fingers, palpitations, pitting edema of the lower extremities, a wiry and slow pulse of 52 beats per minute, a dark tongue with a white and greasy coating. Further questioning revealed that the patient had been diagnosed in 197..." Eight years ago, during high school, the patient suffered from tuberculous pleurisy. Despite more than six months of anti-tuberculosis treatment, it was not completely cured. The patient is pale and thin, extremely weak, and prone to catching colds, which are often lingering and difficult to cure. Currently, the patient still experiences frequent chills, heaviness in the shoulders and back, and aches and pains in the muscles and joints throughout the body. The condition is attributed to external wind-cold invasion, which failed to be relieved, leading to internal retention of fluids, which gradually penetrated deeper into the internal organs. Since the source of the infection has been cleared, the initial treatment plan is to strengthen the body's resistance and expel the pathogenic factors, allowing the deeply entrenched pathogens to be expelled. Traditional Chinese Medicine Diagnosis: Suspended phlegm, syndrome due to external wind-cold invasion and internal retention of fluids. Prescription: Red ginseng (separately decocted), 10g each of five-spice powder, 6g each of notopterygium root, angelica root, angelica dahurica root, bupleurum root, chuanxiong rhizome, immature bitter orange peel, and platycodon root, 12g of poria cocos, 10g each of peach kernel and apricot kernel, 3g of mint, 5g of prepared licorice root, 3 slices of fresh ginger, and 4 jujubes. Decoct in water and take warm.

[0221] Example extraction result = "

[0222] 1. Spacetime dimension

[0223] a. Date of visit: September 21, 1981

[0224] b. Seasonal climate:

[0225] c. Location of treatment:

[0226] 2. Subject of the act

[0227] a. Physician: Li Ke

[0228] b. Other personnel:

[0229] c. Patient Name: Hu

[0230] d. Patient's gender: Female

[0231] e. Age: 22 years old

[0232] f. Previous illness: Upon further inquiry into the medical history, it was learned that the patient had tuberculous pleurisy when he was in high school in 1978. After more than half a year of anti-tuberculosis treatment, it could not be cured.

[0233] g. Marital and reproductive status:

[0234] h. Endowment status:

[0235] i. Physical characteristics:

[0236] j. Daily habits:

[0237] k. Occupation:

[0238] m. Occupation:

[0239] n. Emotional characteristics:

[0240] 1. Dietary preferences:

[0241] 3. Clinical decision-making

[0242] a. Auxiliary diagnostic and treatment tools:

[0243] b. Symptoms / Signs: A feeling of tightness and stabbing pain in the precordial region for over 3 months. Persistent coughing and wheezing, sallow complexion, cyanosis of the lips and fingers, palpitations, pitting edema of the lower extremities, a wiry and slow pulse (52 beats per minute), a dark tongue with a white, greasy coating. The patient is sallow-faced, emaciated, and extremely susceptible to colds, which are often prolonged and difficult to cure. Currently, the patient still experiences intermittent chills, heaviness in the shoulders and back, and general muscle and joint pain.

[0244] c. Previous medical treatment: The patient was diagnosed with tuberculous pericarditis, pericardial effusion, and second-degree atrioventricular block at a certain hospital. He had been treated for three months with anti-tuberculosis drugs, hormones, and diuretics, but still felt a dull, stabbing pain in the precordial region, sometimes radiating to the back, and felt as if a millstone was pressing on his chest.

[0245] d. Disease name: Traditional Chinese medicine diagnosis: Suspended phlegm.

[0246] e. Syndrome type: The syndrome is due to external wind-cold invasion and internal retention of water and fluid.

[0247] f. Treatment: Prescription: 10g each of red ginseng (stewed separately) and five-spice powder, 6g each of notopterygium root, angelica root, angelica dahurica root, bupleurum root, chuanxiong rhizome, immature bitter orange peel, and platycodon root, 12g of poria cocos, 10g each of peach kernel and apricot kernel, 3g of mint, 5g of prepared licorice root, 3 slices of fresh ginger, and 4 jujubes. Decocted in water and taken warm.

[0248] g. Number of visits: 1

[0249] 4. Doctor-patient interaction

[0250] a. Evaluation of therapeutic effect: The patient's mother reported that after taking the medicine, she felt very comfortable with a full-body sweat. All external symptoms disappeared, her chest felt more open, her pulse was wiry and slow at 60 beats per minute, and there was no longer any throbbing. The greasy coating on her tongue had mostly disappeared. Moreover, since sweating, her urination had increased, and her cough and wheezing had subsided.

[0251] b. Compliance:

[0252] c. Patient's purpose for seeking medical treatment:

[0253] d. Doctor's purpose of diagnosis and treatment:

[0254] ”},

[0255] {"role": "user",

[0256] "content": (i.e., the part of traditional Chinese medicine medical records)

[0257] The syndrome of constipation due to spleen yang deficiency is caused by the failure of the middle yang to promote digestion, the loss of the function of transportation and transformation, and the failure of water and fluid to be distributed. It is treated with modified Lizhong Decoction to warm and promote the spleen yang.

[0258] Zhang, male, 70 years old. Medical record number: 008Q180.

[0259] First diagnosis: April 1, 2009.

[0260] The stool was dry and constipated for more than two months.

[0261] The patient自诉 that in the past two months, the stool has been dry, once every 3 - 4 days, accompanied by continuous dull pain in the epigastrium. Taking Maren Zipi Pills and Sanhuang Tablets by himself can relieve it slightly, but it persists. Therefore, he came to our hospital today. Symptoms: The stool is dry, once every 3 - 4 days, abdominal distension, continuous dull pain in the epigastrium, liking warmth and pressure, afraid of cold, the limbs are not warm, the tongue is pale, plump with tooth marks, the tongue coating is white and slippery, the pulse is deep, slow and weak, and the urine is short. Gastroscopy shows: Chronic gastritis. Denied a history of chronic diseases such as hypertension, diabetes, coronary heart disease, etc., denied a history of infectious diseases such as hepatitis, tuberculosis, etc., denied a history of blood transfusion, denied a history of drug and food allergies, and the vaccination history is unknown. Diagnosed as constipation, belonging to the syndrome of spleen yang deficiency. This is due to the failure of the middle yang of the spleen to promote digestion, the loss of the function of transportation and transformation, the failure of water and fluid to be distributed, and the failure of the fluid to descend, so the stool is constipated. When the spleen yang is deficient and weak, the transportation and transformation function fails, resulting in abdominal distension; when yang deficiency fails to promote transportation, cold is generated internally, cold coagulates qi and stagnates, resulting in continuous dull pain in the epigastrium, liking warmth and pressure; when the spleen yang is deficient and weak, the warming function fails, resulting in being afraid of cold and the limbs are not warm. When the spleen yang is deficient and weak, water and dampness cannot be transformed, resulting in short urine; when yang deficiency fails to nourish qi and blood, and water qi overflows upward, resulting in a pale face without luster. The tongue coating and pulse are all caused by yang deficiency and the failure of transportation. It is advisable to warm and promote the spleen yang, and formulate a prescription of modified Lizhong Decoction. Prescription:

[0262] Radix Pseudostellariae 30g, Atractylodes macrocephala 15g, Dry Ginger 10g, Prepared Licorice Root 6g, Semen Amomi Rotundus 10g, Aucklandia lappa Decne. 10g, Pinellia ternata (Thunb.) Breit. 10g, Pericarpium Citri Reticulatae 10g, Fructus Citri Sarcodactylis 10g. Decoct in water for oral administration, 1 dose per day, take continuously for 7 days. Instruct the patient to avoid eating cold and cool foods.

[0263] [[ID=24}};

[0264] Step 202, input the pre - processed ancient traditional Chinese medicine medical records and modern traditional Chinese medicine medical records into the text structuring module respectively, and train the text structuring module through the method of parameter fine - tuning with low - rank adaptation and fine - tuning based on autoregressive loss. The specific steps are as follows:

[0265] Step 20201: Utilize the locally deployed general-purpose large language model Qwen3-8B as the text structuring module. Use preprocessed ancient and modern TCM medical records as the model's training dataset. Employ autoregressive loss as the training loss function. The autoregressive loss is used to determine the difference between the predicted probability of the next character and the target character, following the model pre-training paradigm to train the text structuring module. The specific formula for the autoregressive loss is as follows:

[0266] ;

[0267] ;

[0268] Among them, input For tokenized preprocessed text, For the current moment, Let be the entire probability distribution output by the model at time t. For the model at time step Predict the next preprocessed text The probability, Let be the prediction loss at time t. For autoregressive loss, This represents the total number of time steps.

[0269] Step 20202: Using the preprocessed ancient and modern TCM medical records as training datasets respectively, the text structuring module is fine-tuned using a low-rank adaptation method, with the specific formula as follows:

[0270]

[0271] in, For the input model, preprocessed text that is not tokenized, It is the original parameter matrix. It is a reduced-rank matrix. It is an increasing-rank matrix. As a response Additional adjustment items, overall weight During training, only updates are performed. and The parameters, Keep frozen.

[0272] Step 203: Use the fine-tuned text structuring module to extract key dimension information from ancient and modern TCM medical records and transform it into corresponding structured contextual text to jointly construct a structured medical record database.

[0273] Specifically, in step 4, 100 samples are first collected from the structured TCM medical record database through the sampling module, with at least 2 samples for each disease name. Then, the semantic features of all samples are extracted by the semantic feature extraction module according to the dimension. The semantic features include 4 local tensor representations and 1 global tensor representation. Finally, the local tensor representations and the global tensor representations are fused to obtain the global-local representation.

[0274] The system comprises 27 sub-dimensions for each sample, including the time of consultation, season and climate, location of treatment, physician, other personnel, patient name, patient gender, age, previous patients, marital and reproductive status, endowment, physical characteristics, living habits, occupation, emotional characteristics, dietary preferences, auxiliary treatments, symptoms / signs, previous medical treatment process, disease name, syndrome type, treatment, number of visits, efficacy evaluation, compliance, patient's purpose of medical treatment, and physician's purpose of treatment. Local tensor representations of each sample are extracted according to the major dimensions to which each sub-dimension belongs, namely, the spatiotemporal dimension, the behavioral subject, clinical decision-making, and doctor-patient interaction. Global tensor representations are then extracted from the original medical records of the samples. Finally, each sample is fused to obtain a global-local representation.

[0275] Furthermore, the specific implementation steps of step 4 in this example are as follows:

[0276] Step 401: First, classify the cases by disease name and collect 100 samples from the structured TCM medical record database through the sampling module, with at least 2 samples extracted from each category;

[0277] Step 402: The locally deployed general text representation model Qwen3-Embedding is used as the semantic feature extraction module;

[0278] Step 403: Extract semantic features of each sample by dimension through the semantic feature extraction module. The semantic features of each sample include a 1×4×d local tensor representation and a 1×1×d global tensor representation, where d is the output dimension of the text representation model Qwen3-Embedding. The global tensor representation and the local tensor representation are fused into a 1×5×d global-local representation, so that the features of each sample not only contain the details of each dimension, but also the information in the global context of the entire sample, which greatly improves the representation ability of the final features.

[0279] In this example, we limit the maximum text length to 3072. Samples exceeding 3072 were removed; this applies to text length... For the sample, we add a size of () to the text length. A zero tensor of 0 × d, whose dimensions are from ×d becomes 3072×d, and a mask with a corresponding dimension of 3072×1 is generated. This mask is then... The element has a value of 1, then Each element has a value of 0, so that the attention layer in subsequent steps only considers the previous elements. One valid value;

[0280] Specifically, in step 5, the global-local representations of all samples are input into the semantic similarity analysis module, and the semantic similarity analysis module is trained using a deep metric learning method based on differential proxy loss.

[0281] Furthermore, the specific implementation steps of step 5 in this example are as follows:

[0282] Step 501: Input the 100×5×d global-local representations of the above 100 samples into the multilayer perceptron in the semantic similarity analysis module. Establish the association between the local tensor representation and the global tensor representation one by one through the cross-attention mechanism in the multilayer perceptron. The specific formula is as follows:

[0283]

[0284] in, Here, represents the query matrix, key matrix, and value matrix in the cross-attention function, respectively; is the transpose of the key matrix. The dimension of the key vector; It is an activation function;

[0285] Step 502: Perform a normalized inner product on each of the 100×5×d global-local representations of the 100 associated samples. The formula for the normalized inner product is as follows:

[0286]

[0287] in, , Let be any two vectors;

[0288] Step 503: Construct the differentiated proxy loss function, the specific formula of which is as follows:

[0289]

[0290] in, For differentiated proxy loss function; For batches of Zhengzheng agents; For negative agents in batches; This represents the global-local representation of all positive samples in the batch. This represents the global-local representation of all samples in the batch. A global-local representation of a single sample; For the global-local representation of a single sample With the learnable representation of the disease name category The normalized inner product between; Is a scaling factor to control the sensitivity of the similarity to the loss impact; the boundary threshold Define the similarity boundaries for positive and negative sample pairs;

[0291] Step 504, freeze all the parameters of the semantic similarity analysis module, and train the semantic similarity analysis module based on the differential proxy loss. The specific steps are as follows:

[0292] Perform a normalized inner product on each of the associated 100×5×d global-local representations to calculate the normalized inner product similarity , update the parameters using the AdamW optimizer according to the differential proxy loss. As shown in Figure 3 of the attached drawings, for positive sample pairs, use a proxy-centered method to make all samples of the same category closely cluster around the positive proxy, enhancing the within-class compactness. For negative sample pairs, use a sample-centered method to make each sample far away from all negative proxies, improving the sample-level discrimination and avoiding inter-class confusion;

[0293] At the same time, the trained semantic similarity analysis module can achieve high-precision semantic comparison. Therefore, using the semantic similarity analysis module, it is possible to search for ancient similar medical records from modern medical records and modern similar medical records from ancient medical records, bridging the semantic gap between ancient and modern Chinese medicine, and solving the semantic heterogeneity problems caused by language changes (classical Chinese and vernacular Chinese), term differences (such as "depressive syndrome" and "depression"), and the implicitization of diagnosis and treatment logic in ancient and modern medical records, achieving precise alignment of cross-era medical records in key dimensions (disease / syndrome / symptom / method / prescription / herb), and supporting the two-way mapping of ancient and modern diagnosis and treatment experiences.

[0294] Specifically, in step 6, use the trained structured network of ancient and modern Chinese medical records to transform ancient Chinese medical records and modern Chinese medical records into structured context texts respectively, extract the global-local representations through the semantic feature extraction module, and construct an index database for modern Chinese medical records and an index database for ancient Chinese medical records, and use the semantic similarity analysis module to search for ancient similar medical records from modern medical records and modern similar medical records from ancient medical records.

[0295] Furthermore, the specific implementation steps of step 6 in this example are as follows:

[0296] Step 601, input the ancient Chinese medical record into the trained structured network of ancient and modern Chinese medical records and transform it into a structured context text;

[0297] Step 602, extract the global-local representation of the structured context text through the semantic feature extraction module and construct an index database for ancient Chinese medical records;

[0298] Step 603: Input modern Chinese medicine medical records into the trained structured network of ancient and modern Chinese medicine medical records and convert them into structured scenario texts;

[0299] Step 604: Extract the global-local representation of the structured scenario text through the semantic feature extraction module and construct an index database of modern Chinese medicine medical records;

[0300] Step 605: Given a modern Chinese medicine medical record, input it into the structured network of ancient and modern Chinese medicine medical records to convert it into a structured scenario text, input the structured scenario text into the semantic alignment network of ancient and modern Chinese medicine medical records, extract the global-local representation through the semantic feature extraction module, calculate the semantic similarity with the ancient Chinese medicine medical records in the ancient Chinese medicine medical record index database using the semantic similarity analysis module, retrieve similar ancient medical records from the ancient Chinese medicine medical record index database, and select the top K results in the descending order of similarity as the output to achieve searching for similar ancient medical records using modern medical records;

[0301] Step 606: Given an ancient Chinese medicine medical record, input it into the structured network of ancient and modern Chinese medicine medical records to convert it into a structured scenario text, input the structured scenario text into the semantic alignment network of ancient and modern Chinese medicine medical records, extract the global-local representation through the semantic feature extraction module, calculate the semantic similarity with the modern Chinese medicine medical records in the modern Chinese medicine medical record index database using the semantic similarity analysis module, retrieve similar modern medical records from the modern Chinese medicine medical record index database, and select the top K results in the descending order of similarity as the output to achieve searching for similar modern medical records using ancient medical records.

[0302] In this invention, the maximum text length is 3072, the batch size for collecting the number of Chinese medicine scenario texts is 100, the general large language model is Qwen3-8B, the general text representation model is Qwen3-Embedding, and the AdamW optimizer is used to train the semantic alignment network of ancient and modern Chinese medicine medical records.

[0303] In summary, this invention discloses a method for comparing ancient and modern Chinese medicine scenarios based on proxy loss for retrieving similar ancient and modern medical records. This method first extracts key dimension information from Chinese medicine medical records through the text structuring module and converts it into structured scenario texts, extracts the semantic features of each scenario text by dimension through the semantic feature extraction module, trains the semantic alignment network of ancient and modern Chinese medicine medical records based on the deep metric learning method with differential proxy loss to achieve high-precision scenario semantic comparison, solves the semantic heterogeneity problems caused by language changes (classical Chinese and vernacular Chinese), term differences (such as "depressive syndrome" and "depression"), and implicit diagnosis and treatment logic between ancient and modern medical records, and realizes the accurate two-way mapping and intelligent inheritance of cross-era Chinese medicine diagnosis and treatment experience.

[0304] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this invention.

[0305] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0306] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disks, optical discs, computer memory, random access memory, USB flash drives, portable hard drives, etc.) containing computer-usable program code.

[0307] The above description is merely a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any equivalent substitutions or modifications made by those skilled in the art within the scope disclosed in the present invention, based on the technical solution and inventive concept of the present invention, shall fall within the scope of protection of the present invention.

Claims

1. A method for comparing ancient and modern contexts in Traditional Chinese Medicine based on proxy loss, characterized in that, Includes the following steps: Step 1: Construct a structured network of ancient and modern Chinese medicine medical records, including a data preprocessing module and a text structuring module. Step 2: Input ancient and modern Chinese medicine medical records into the structured network, extract key dimensional information using the data preprocessing module and the trained text structuring module, and transform it into structured contextual text to construct a structured medical record database. Step 3: Construct a semantic alignment network of ancient and modern Chinese medicine medical records, including a sampling module, a semantic feature extraction module, and a semantic similarity analysis module. Step 4: Collect several samples from the structured Chinese medicine medical record database using the sampling module, and extract global-local representations from each sample according to each dimension using the semantic feature extraction module. Step 5: Input each global-local representation into the semantic similarity analysis module, and train the semantic similarity analysis module using a deep metric learning method based on differential proxy loss. Step 6: Use the trained structured network and semantic alignment network of ancient and modern Chinese medicine medical records to achieve high-precision contextual semantic comparison. Step 2's specific steps are as follows: Step 201, preprocess the ancient and modern TCM medical records using the data preprocessing module, converting them into a prompt word-TCM medical record format; Step 202, input the preprocessed ancient and modern TCM medical records into the text structuring module, and train the text structuring module using a low-rank adaptive parameter fine-tuning method and autoregressive loss fine-tuning; Step 203, use the fine-tuned text structuring module to extract key dimension information from the ancient and modern TCM medical records and convert it into corresponding structured contextual text to jointly construct a structured medical record database; Step 201's specific steps are as follows: Step 20101, construct guiding prompt words; Step 20102, construct extraction format prompt words; Step 20103, construct example prompt words; Step 20104, concatenate the guiding prompt words, extraction format prompt words, and example prompt words in sequence to obtain the fused prompt word Prompt; Step 20105, according to the format [{"role": The concatenation of `{"system", "content": Prompt},{"role": "user","content": TCM medical record to be structured}` yields preprocessed ancient and modern TCM medical records; where "TCM medical record to be structured" represents the input ancient or modern TCM medical record; `role`, `system`, `content`, `user`, and `content` are all input format guide words for the text structuring module.

2. The method for comparing ancient and modern contexts of traditional Chinese medicine based on proxy loss according to claim 1, characterized in that, Step 20102 includes the following: ;in, It is a key dimension of TCM context evaluated by TCM experts, including the spatiotemporal dimension, the actor, clinical decision-making, and doctor-patient interaction; These are key sub-dimensions corresponding to the key macro-dimensions of TCM context as evaluated by TCM experts. These include: Spatiotemporal dimensions (time of consultation, season, climate, and location); Subjective factors (doctor, other personnel, patient name, gender, age, previous illnesses, marital status, constitution, physical characteristics, daily habits, occupation, emotional characteristics, and dietary preferences); Clinical decision-making (auxiliary treatment, symptoms / signs, previous treatment process, disease name, syndrome type, treatment, and number of visits); and Doctor-patient interaction (efficacy evaluation, compliance, patient's purpose of seeking medical treatment, and doctor's purpose of treatment). A clear definition for each key sub-dimension; This indicates the number of the key subdimensions.

3. The method for comparing ancient and modern contexts of traditional Chinese medicine based on proxy loss according to claim 1, characterized in that, The specific steps of step 202 are as follows: Step 20201, using the locally deployed general-purpose large language model as the text structuring module, and the preprocessed ancient and modern Chinese medicine medical records as the training dataset of the model, the training loss function adopts autoregressive loss, and the difference between the predicted probability of the next character and the target is judged by the autoregressive loss, following the model pre-training paradigm to train the text structuring module; the specific formula of autoregressive loss is as follows: ; Among them, input For tokenized preprocessed text, For the current moment, Let be the entire probability distribution output by the model at time t. For the model at time step Predict the next preprocessed text The probability, Let be the prediction loss at time t. For autoregressive loss, The total number of time steps; Step 20202, using the preprocessed ancient and modern TCM medical records as training datasets respectively, fine-tunes the text structuring module using a low-rank adaptation method, with the specific formula as follows: ;in, For the input model, preprocessed text that is not tokenized, It is the original parameter matrix. It is a reduced-rank matrix. It is an increasing-rank matrix. As a response Additional adjustment items, overall weight During training, only updates are performed. and The parameters, Keep frozen.

4. The method for comparing ancient and modern contexts of traditional Chinese medicine based on proxy loss according to claim 1, characterized in that, The specific steps of step 4 are as follows: Step 401, firstly, classify the categories by disease name, and collect several samples from the structured TCM medical record database through the sampling module, extracting at least 2 samples for each category; Step 402, use a locally deployed general text representation model as the semantic feature extraction module. Step 403: Extract the semantic features of each sample by dimension through the semantic feature extraction module. The semantic features of each sample include local tensor representation and global tensor representation. The global tensor representation and local tensor representation are fused into a global-local representation.

5. The method for comparing ancient and modern contexts of traditional Chinese medicine based on proxy loss according to claim 1, characterized in that, The specific steps of step 5 are as follows: Step 501, input the global-local representations of all samples into the multilayer perceptron in the semantic similarity analysis module, and establish the association between the local tensor representation and the global tensor representation one by one through the cross-attention mechanism in the multilayer perceptron, as shown in the following formula: ;in, Cross-attention functions The query matrix, key matrix, and value matrix are defined in the matrix; is the transpose of the key matrix. The dimension of the key vector; It is an activation function; step 502, perform normalized inner product on each of the global-local representations in the associated samples, the normalized inner product formula is... as follows: ;in, 、 Let the vectors be any two vectors; Step 503, construct the differentiated proxy loss function, the specific formula of which is as follows: ;in, For differentiated proxy loss function; For batches of Zhengzheng agents; For negative agents in batches; This represents the global-local representation of all positive samples in the batch. This represents the global-local representation of all samples in the batch. A global-local representation of a single sample; Global-local representation of a single sample Learnable representations of disease categories The normalized inner product between them; A scaling factor to control the sensitivity of similarity to the loss; a boundary threshold. Define the similarity boundaries for positive and negative sample pairs; Step 504: Freeze all parameters of the semantic similarity analysis module and train the semantic similarity analysis module based on differential proxy loss.

6. The method for comparing ancient and modern contexts of traditional Chinese medicine based on proxy loss according to claim 1, characterized in that, The specific steps of step 6 are as follows: Step 601, input ancient Chinese medicine medical records into the trained ancient and modern Chinese medicine medical record structured network and transform it into structured contextual text; Step 602, extract global-local representations of the structured contextual text through the semantic feature extraction module and construct an ancient Chinese medicine medical record index database; Step 603, input modern Chinese medicine medical records into the trained ancient and modern Chinese medicine medical record structured network and transform it into structured contextual text; Step 604, extract global-local representations of the structured contextual text through the semantic feature extraction module and construct a modern Chinese medicine medical record index database; Step 605, given a modern Chinese medicine medical record, input it into the ancient and modern Chinese medicine medical record structured network and transform it into structured contextual text, input the structured contextual text into the ancient and modern Chinese medicine medical record semantic alignment network, extract global-local representations through the semantic feature extraction module, and utilize... The semantic similarity analysis module calculates the semantic similarity with ancient Chinese medicine medical records in the ancient Chinese medicine medical record index database, retrieves similar ancient medical records from the ancient Chinese medicine medical record index database, and selects the top K results in descending order of similarity as output, realizing the search for similar ancient medical records using modern medical records; Step 606: Given an ancient Chinese medicine medical record, input the structured network of ancient and modern Chinese medicine medical records into a structured contextual text, input the structured contextual text into the semantic alignment network of ancient and modern Chinese medicine medical records, extract global-local representations through the semantic feature extraction module, use the semantic similarity analysis module to calculate the semantic similarity with modern Chinese medicine medical records in the modern Chinese medicine medical record index database, retrieves similar modern medical records from the modern Chinese medicine medical record index database, and selects the top K results in descending order of similarity as output, realizing the search for similar modern medical records using ancient medical records.

Citation Information

Patent Citations

  • Precise structured representation and semantic comparison method for traditional Chinese medicine situation information

    CN119943435A

  • Traditional Chinese medicine case text-oriented hierarchical vector processing method and device, equipment and storage medium

    CN120218013A