Traditional Chinese medicine prescription generation and dosage prediction method and system based on double-link diagnosis and treatment reasoning and mask linear topological constraint
By employing a dual-link diagnostic reasoning and masked linear topology constraint method, the shortcomings of traditional Chinese medicine prescription recommendation technology in terms of interpretability, safety, and dosage consistency are addressed. This method achieves stable and consistent output of herbal selection and dosage prediction, thereby improving the reliability of traditional Chinese medicine prescription generation in clinical applications.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- DALIAN UNIV
- Filing Date
- 2026-01-29
- Publication Date
- 2026-06-19
AI Technical Summary
Existing TCM prescription recommendation technologies have deficiencies in terms of reasoning interpretability, clinical safety, dosage consistency, and data modeling capabilities, making it difficult to meet the needs of clinical decision support. In particular, the output results are unstable in complex cases, data distribution deviations, or noisy recording scenarios, and there is a lack of effective compatibility safety constraints and dosage prediction consistency.
This method employs a dual-link diagnostic reasoning and masked linear topological constraints approach. By structurally modeling the diagnostic link and introducing a dual-link reasoning mechanism and topological prior constraints, it achieves integrated output for herbal selection and dosage prediction. This includes terminology standardization, frequency-aware denoising, type-separable hierarchical coding and hierarchical embedding fusion, dual-link diagnostic reasoning correction branch and element-driven herbal response enhancement branch, constructing a dialectical relationship graph aligned with multi-source knowledge, and simultaneously realizing multi-label classification and dosage regression of herbal medicines through a joint output head.
It improves the robustness and generalization ability of the model in scenarios with noise and terminology diversity in real medical records, enhances the interpretability of herbal medicine selection and the stability of dosage prediction, reduces the probability of unreasonable combinations and high-risk combinations, and ensures the safety and consistency of prescription generation.
Smart Images

Figure CN122245645A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of medical informatics and artificial intelligence, specifically to a method and system for generating and predicting traditional Chinese medicine prescriptions based on dual-link diagnostic reasoning and masked linear topological constraints. Background Technology
[0002] Traditional Chinese medicine (TCM) clinical prescription generation strictly follows the core diagnostic and treatment paradigm of "syndrome differentiation and treatment." It requires a progressive inference process, based on multi-source clinical information from the patient, from initial diagnosis, TCM diagnosis, syndrome identification to treatment principles and methods, ultimately forming a precise combination of herbs and dosage regimens. This process exhibits distinct hierarchical and causal chain characteristics. Subtle changes in the upstream diagnostic stage directly transmit and constrain the downstream treatment selection and prescription logic. Therefore, intelligent TCM prescription generation technology for real-world clinical applications not only needs to output a reasonable set of herbs but also needs to logically align with the entire diagnostic and treatment chain, providing verifiable reasoning and security constraint mechanisms.
[0003] However, existing TCM prescription recommendation technologies still have many shortcomings that urgently need to be addressed, making it difficult to meet the actual needs of clinical decision support: Firstly, existing technologies often employ a direct mapping model of "symptom-herbal medicine" or "diagnosis-herbal medicine," simplifying or implicitly absorbing key intermediate steps in the diagnostic process—"preliminary diagnosis—TCM diagnosis—syndrome—treatment principles and methods"—into black-box model parameters. For example, the Chinese patent application CN116246762A, entitled "Prescription Dosage Optimization Method, Device, Equipment and Medium Based on Artificial Intelligence," still relies on modeling the direct correlation between input features and output results. While such methods may achieve certain statistical results, the model reasoning process lacks traceability and auditability, making it difficult to align with the progressive logic of TCM syndrome differentiation and treatment. In complex cases, with data distribution deviations, or in noisy recording scenarios, the model is prone to learning shortcuts inconsistent with clinical reasoning, leading to unstable output results and failing to provide reliable support for clinical decision-making.
[0004] Secondly, the clinical usability of TCM prescriptions highly depends on compatibility safety and rule consistency. Even if the overall model performance is excellent, the occasional occurrence of herbal combinations that violate basic contraindications or common-sense safety rules can lead to serious clinical risks. Most existing data-driven methods lack an effective mechanism to inject clinical prior knowledge into the model structure as "hard constraints." They only learn associations through soft constraints at the loss function level or data co-occurrence patterns, which is insufficient to fundamentally limit the model's search space and parameter connectivity. This fails to effectively suppress the propagation of unreasonable associations in the inference chain, thereby affecting the safety and credibility of prescriptions.
[0005] Third, dosage is a core component of TCM prescriptions. Whether or not herbs are used and how much are used together determine the therapeutic boundary and medication safety. In existing technologies, dosage prediction is often ignored or only completed through simple rule post-processing, resulting in a lack of inherent consistency constraints between prescription generation and dosage estimation. This frequently leads to problems such as "mismatch between herb selection and dosage output" or unreasonable dosage fluctuations, significantly reducing the clinical usability of prescription plans.
[0006] Fourth, clinical electronic medical record data is characterized by multiple fields, multiple granularities, and the coexistence of noise and missing data. It includes diagnostic elements at different levels, such as preliminary diagnosis, traditional Chinese medicine diagnosis, syndrome differentiation, and treatment principles and methods. The semantic differences among these elements are significant and their relationships are complex. Existing methods mostly rely on end-to-end fitting models, lacking structured modeling and knowledge constraint mechanisms for diagnostic and treatment elements. This makes it difficult to effectively handle data heterogeneity and quality issues, easily leading to insufficient model generalization ability and poor adaptability in real and diverse clinical scenarios.
[0007] In summary, the shortcomings of existing TCM prescription recommendation technologies in terms of reasoning interpretability, clinical safety, dosage consistency, and data modeling capabilities limit their large-scale application in clinical decision support. Summary of the Invention
[0008] The purpose of this invention is to propose a method and system for generating and predicting traditional Chinese medicine prescriptions based on dual-link diagnostic reasoning and masked linear topological constraints. By structurally modeling the diagnostic link and introducing a dual-link reasoning mechanism and topological prior constraints, it achieves an integrated output of interpretable, highly secure, and consistent herbal selection and dosage prediction.
[0009] According to a first aspect of the embodiments of this disclosure, a method for generating and predicting traditional Chinese medicine prescriptions based on dual-link diagnostic reasoning and masked linear topological constraints is provided, comprising the following steps: The diagnostic elements in electronic medical records are standardized in terms of terminology, frequency-aware denoising, type-separable hierarchical coding, and hierarchical embedding fusion to generate a unified patient representation. The patient representation is input in parallel into the original semantic backbone branch, the dual-link diagnosis and treatment reasoning correction branch, and the element-driven herbal response enhancement branch. The original semantic features, reasoning correction features, and herbal enhancement features are extracted respectively, and multi-source feature fusion is completed. Herbal multi-label classification and dose regression are realized synchronously through the joint output head. At the same time, the classification results are used to generate a mask vector to perform gating constraints on the regression output. Based on the statistical analysis of co-occurrence relationships in clinical data, the structured extraction of authoritative TCM corpus, and the verification by TCM experts, a dialectical relationship graph with multi-source knowledge alignment is constructed to generate a topological prior matrix for link reasoning and mask constraint calculation, and inject hard constraints of clinical prior knowledge. A comprehensive evaluation system covering the performance of herbal recommendations, dosage prediction errors, and compatibility safety risks was established. A joint training strategy was adopted to optimize the classification and regression tasks, thereby realizing the generation of TCM prescriptions and dosage prediction.
[0010] In one embodiment, the diagnostic elements in the electronic medical record are subjected to terminology standardization, frequency-aware denoising, type-separable hierarchical coding, and hierarchical embedding fusion, specifically as follows: Terminology standardization: Map synonyms, alternative names and variant characters in electronic medical records to unified standard terms, extract key elements of preliminary diagnosis, TCM diagnosis, syndrome and treatment principles and methods according to the diagnosis and treatment chain, and standardize the coding of herbal entities; Frequency-aware noise reduction: Frequency statistics are performed on the four types of diagnostic elements and herbal entities to filter low-frequency entities and eliminate or reduce records with excessive noise or insufficient information. Type-separable hierarchical coding: Four types of dialectical elements are encoded using either one-hot or multi-hot methods, and mapped to a continuous vector space through a learnable word embedding table to construct a learnable embedding matrix. , , and The four types of dialectical elements are represented by multi-hot vectors, and the embedded representation is obtained through the embedding matrix: in, , , , Learnable embedding matrices corresponding to the four categories of diagnostic elements: "preliminary diagnosis, TCM diagnosis, syndrome, and treatment principles and methods"; , , , It refers to the number of entities corresponding to the dialectical elements. It is the dimension of the embedded vector; , , , These are the multi-hot vectors of the four types of dialectical elements. , , , These are continuous vector representations of the four types of dialectical elements obtained after embedding matrix mapping; Hierarchical embedding fusion: The embedding vectors of the four types of diagnostic elements are concatenated, and then subjected to linear mapping and random deactivation processing using a shallow multilayer perceptron to obtain the patient representation vector. : in, Indicates the activation function; This represents a vector concatenation operation; This represents a learnable embedding matrix.
[0011] In one embodiment, the original semantic backbone branch, the dual-link diagnostic reasoning correction branch, and the element-driven herbal response enhancement branch extract original semantic features, reasoning correction features, and herbal enhancement features, respectively, as follows: Original semantic backbone encoding: Input the patient representation into the Transformer encoder, retain the explicit semantic information of the electronic medical record, and obtain the original semantic features. ; Based on the topological prior matrix, a two-link reasoning process is employed: a forward "preliminary diagnosis → TCM diagnosis → syndrome → treatment principle and method" and a reverse "treatment principle and method → syndrome → TCM diagnosis → preliminary diagnosis". This process, combined with masked linear operations and a multilayer perceptron, generates reasoning correction features. This represents the perception of positive reasoning. Reverse reasoning perception representation, Presentation layer normalization operation, This represents the element-wise product of vectors. Element-driven herbal response enhancement: The embedding vectors of four types of dialectical elements are mapped to the herbal space respectively. The weighting coefficients of each element's response to the herbal response are learned by an enhanced multilayer perceptron to generate herbal enhancement features.
[0012] In one embodiment, during forward link reasoning, a masked feedforward neural network Masklinear(∙) is used to sequentially model hierarchical reasoning relationships, resulting in three types of forward relationship representations: in, , , Represents a linear mapping function between elements at different levels; , , The topological prior matrix of the corresponding hierarchical dialectical elements; , , These represent the forward inference relationship of "preliminary diagnosis → TCM diagnosis, TCM diagnosis → syndrome, syndrome → treatment principles and methods"; , , Represents the learnable weight matrix; By fusing forward reasoning information, we obtain a forward reasoning perceptual representation. : in, This represents the learnable weight matrix.
[0013] In one embodiment, in reverse link reasoning, the link matrix transpose is used to simulate reverse semantic transmission, resulting in three types of reverse relation representations: in, , , Represents a linear mapping function between elements at different levels; , This represents a reverse reasoning relationship: "treatment principles and methods → syndrome, syndrome → TCM diagnosis, TCM diagnosis → preliminary diagnosis"; , , Represents the learnable weight matrix; Integrating backward reasoning information to obtain backward reasoning perceptual representation : in, This represents the learnable weight matrix.
[0014] In one embodiment, the herbal enhancement features are generated by: processing the embedding representations of the four types of dialectical elements into a learnable embedding matrix. Mapping to the same semantic space yields , , , : Projected onto the herb dimension via a masked linear mapping function: in, Represents the learnable weight matrix; Weights are learned based on an attention-weighted mechanism. Generate herbal enhancement features : in, It enhances the representation of herbs by integrating data co-occurrence, semantic reasoning, and expert knowledge.
[0015] In one embodiment, multi-label classification and dose regression of herbal medicines are synchronously achieved through a joint output head. Simultaneously, a mask vector is generated using the classification results to apply gating constraints to the regression output. Specifically, the original semantic features, inference correction features, and herbal medicine enhancement features are transformed through a feedforward transformation function. Projecting the vectors onto the same dimension and concatenating them yields a fused feature vector. : Construct a two-layer linear structure for the classification head and regression head. The classification head extracts higher-order semantics and outputs the probability distribution using the following formula. : in, , , , For learnable parameters, Weighting coefficients for masking operations, The topological prior matrix among herbs The first-level linear transformation of the classification head and Activated intermediate features Higher-order semantic features after the second-level linear transformation of the classification head; This represents the multi-label probability vector for herbs. Predicted raw dose output from regression head: in, , The learnable weight matrix of the regression head. , For the learnable bias term of the regression head, These are intermediate features after the first linear transformation of the regression head and ReLU activation; The original dose prediction results output by the regression head.
[0016] According to a second aspect of the embodiments of this disclosure, a traditional Chinese medicine prescription generation and dosage prediction system based on dual-link diagnostic reasoning and masked linear topological constraints is provided, including: The diagnosis and treatment chain structured coding module performs terminology standardization, frequency-aware denoising, type-separable hierarchical coding, and hierarchical embedding fusion on the diagnostic elements in electronic medical records to generate a unified patient representation. The three-branch collaborative representation module takes the patient representation as parallel input to the original semantic backbone branch, the dual-link diagnosis and treatment reasoning correction branch, and the element-driven herbal response enhancement branch. It extracts the original semantic features, reasoning correction features, and herbal enhancement features respectively and completes multi-source feature fusion. Through the joint output head, it realizes multi-label classification and dose regression of herbal medicine. At the same time, it uses the classification results to generate a mask vector and performs gating constraints on the regression output. The topology prior construction module, based on the co-occurrence relationship statistics of clinical data, the structured extraction of authoritative TCM corpus and the verification by TCM experts, constructs a dialectical relationship graph with multi-source knowledge alignment, generates a topology prior matrix for link reasoning and mask constraint calculation, and injects hard constraints of clinical prior knowledge. The joint evaluation and training module establishes a comprehensive evaluation system covering the performance of herbal recommendations, dosage prediction errors, and compatibility safety risks. It adopts a joint training strategy to optimize classification and regression tasks, thereby enabling the generation of TCM prescriptions and dosage prediction.
[0017] According to a third aspect of the present disclosure, an electronic device is provided, including a memory, a processor, and a computer program stored in the memory and running on the memory. When the processor executes the program, it implements the method for generating and predicting traditional Chinese medicine prescriptions based on dual-link diagnostic reasoning and masked linear topological constraints.
[0018] According to a fourth aspect of the present disclosure, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the method for generating and predicting traditional Chinese medicine prescriptions based on dual-link diagnostic reasoning and masked linear topological constraints.
[0019] The advantages of the above technical solutions adopted in this invention compared with the prior art are as follows: (1) This invention closely aligns with the real TCM diagnosis and treatment process, implementing structured encoding of hierarchical diagnostic elements such as "preliminary diagnosis - TCM diagnosis - syndrome - treatment principles and methods" and integrating them into a patient representation. This allows the model to simultaneously retain the boundaries and semantic differences of information at different levels within a unified input space. Compared to solutions that simply splice together diagnostic and treatment elements and rely solely on the static association between "symptoms and herbs," this invention can more completely represent the clinical diagnostic logic, providing a stable, computable, and reproducible data flow entry point for subsequent reasoning and prescription generation. This, in turn, enhances robustness and generalization ability in scenarios with noise in real medical records and diverse terminology.
[0020] (2) This invention, while preserving the semantic information of the original electronic medical records, introduces bidirectional reasoning of the diagnosis and treatment chain with topological constraints to verify and correct potential human errors, missing elements, or hierarchical inconsistencies at the link level. At the same time, through an element-driven herbal response enhancement module, it learns the differentiated contributions of each diagnostic element to the herbal decision-making. This structure avoids the sensitivity of a single path to input noise, achieves a balance between "fidelity preservation" and "correction", and enhances the interpretability of the herbal spatial mapping, making the recommendation results more consistent with the clinical diagnostic reasoning process and the multi-element collaborative decision-making rules.
[0021] (3) This invention explicitly shrinks the model search space and suppresses the propagation of unreasonable associations by restricting connections that do not conform to prior relationships. Compared with schemes that only apply soft constraints in the loss layer and rely solely on data-driven learning, this invention enables the reasoning process to be traceable and verifiable, reducing the probability of erroneous inferences caused by accidental co-occurrence, thereby effectively reducing unreasonable combinations and high-risk combinations in prescription generation scenarios and improving clinical safety and controllability.
[0022] (4) This invention simultaneously realizes multi-label classification and dose regression of herbal medicines under a unified decoding framework, and uses the mask generated by the classification output to perform gating constraints on the regression output, ensuring a consistent output mechanism of "selecting medicines first and then quantifying". Compared with the scheme of separating the modeling of herbal medicine selection and dose estimation and directly regressing the dose to the whole herbal medicine space, this invention can suppress dose leakage and regression noise of unselected herbs, improve the stability and usability of dose prediction, and enhance the consistency and interpretability of prescription results in engineering deployment.
[0023] (5) This invention constructs a priori relation graph and priori matrix generation process based on "data co-occurrence relationship + structured extraction of authoritative TCM corpus + expert revision", and establishes a comprehensive evaluation system based on "effectiveness + dosage error + safety". This process makes the source of prior knowledge clear, verifiable and iteratively updated, and the evaluation indicators can be directly used for model training iteration and online acceptance, thereby improving the feasibility and regulatory compliance of this method in clinical decision support, prescription review, scientific research analysis and other scenarios. Attached Figure Description
[0024] The accompanying drawings, which form part of this application, are used to provide a further understanding of this application. The illustrative embodiments of this application and their descriptions are used to explain this application and do not constitute an undue limitation of this application.
[0025] Figure 1 A schematic diagram of the structural principle of the Traditional Chinese Medicine Prescription Generation and Dosage Prediction Model (TCDR). Figure 2 A schematic diagram illustrating the construction process, data statistics, and ethical governance of electronic health record datasets for traditional Chinese medicine; Figure 3This is a diagram illustrating the clinical safety validation of the Traditional Chinese Medicine Prescription Generation and Dosage Prediction (TCDR) model. Figure 4 Performance and hyperparameter test of the Traditional Chinese Medicine Prescription Generation and Dosage Prediction Model (TCDR); Figure 5 This is a case study diagram of the Traditional Chinese Medicine Prescription Generation and Dosage Prediction (TCDR) model. Detailed Implementation
[0026] The present disclosure will be further described below with reference to the accompanying drawings and embodiments.
[0027] It should be noted that the following detailed descriptions are exemplary and intended to provide further explanation of this application. Unless otherwise specified, 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 pertains.
[0028] It should be noted that the terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the exemplary embodiments according to this application. As used herein, the singular form is intended to include the plural form as well, unless the context clearly indicates otherwise. Furthermore, it should be understood that when the terms "comprising" and / or "including" are used in this specification, they indicate the presence of features, steps, operations, devices, components, and / or combinations thereof.
[0029] It should be noted that the flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of methods and systems according to various embodiments of this disclosure. It should be noted that each block in a flowchart or block diagram may represent a module, segment, or portion of code, which may include one or more executable instructions for implementing the logical functions specified in the various embodiments. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than that shown in the drawings. For example, two consecutively represented blocks may actually be executed substantially in parallel, or they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the flowcharts and / or block diagrams, and combinations of blocks in the flowcharts and / or block diagrams, may be implemented using a dedicated hardware-based system that performs the specified functions or operations, or using a combination of dedicated hardware and computer instructions.
[0030] Example 1: This embodiment provides a method for TCM prescription generation and dosage prediction based on dual-link diagnostic reasoning and masked linear topological constraints, such as... Figure 1 As shown, it includes the following steps: S1. Standardize the terminology, frequency-aware denoising, type-separable hierarchical coding, and hierarchical embedding fusion of the diagnostic elements in the electronic medical record to generate a unified patient representation; S11 performs terminology standardization and thesaurus unification on data from real electronic medical records, mapping synonyms, aliases, abbreviations and variant characters to unified standard terms, and extracting key diagnostic elements such as preliminary diagnosis, TCM diagnosis, syndrome and treatment principles according to the diagnosis and treatment chain level. At the same time, it standardizes the coding of herbal prescription entities so that the same semantic entity has a consistent identifier in the whole dataset. S12, after standardization, performs frequency statistics and low-frequency filtering on the four types of diagnostic elements and herbal entities, and optionally removes or reduces noise from records with excessive noise or insufficient information to reduce training interference caused by long-tail sparsity and accidental co-occurrence. S13, the preliminary diagnosis, TCM diagnosis, syndrome differentiation, and treatment principles and methods after screening are independently encoded using either single-hot or multi-hot encoding to form type-separable input vectors. These types of encodings are then mapped to a continuous vector space using a learnable word embedding table. To effectively utilize the TCM diagnostic information in electronic health records, this invention constructs learnable embedding matrices for each of the four diagnostic elements: preliminary diagnosis, TCM diagnosis, syndrome differentiation, and treatment principles and methods. , , and In a structured dataset, four types of dialectical elements are represented by multi-hot vectors, and their embedded representations can be obtained through an embedding matrix: S14 involves concatenating the embedding vectors of the four types of dialectical elements to obtain a unified patient input representation, which serves as the data flow entry point for subsequent model calculations, thus completing the closed-loop transformation of "data—structuring—encoding—embedding—patient representation". Specifically, the embedding vectors of the four types of dialectical elements are concatenated and embedded into a shallow MLP perceptron for linear mapping and random deactivation to obtain the patient representation vector. : in, Indicates the activation function; This represents a vector concatenation operation; This represents a learnable embedding matrix.
[0031] S2. The patient representation is input in parallel into the original semantic backbone branch, the dual-link diagnosis and treatment reasoning correction branch, and the element-driven herbal response enhancement branch. The original semantic features, reasoning correction features, and herbal enhancement features are extracted respectively, and multi-source feature fusion is completed. Herbal multi-label classification and dose regression are realized synchronously through the joint output head. At the same time, the classification results are used to generate a mask vector to perform gating constraints on the regression output to ensure the consistency of the clinical logic of "selecting drugs first and then quantifying". S21, The patient input representation obtained in step S1 is first input into the Transformer encoder to obtain the raw semantic features. The original semantic features are used to preserve the semantic information explicitly recorded in the electronic medical record to the greatest extent possible, serving as the semantic backbone of the model. S22, on the path parallel to the original semantic branch, the same patient input representation is sent to the link inference branch. Link inference calculation based on prior matrix constraints, combined with multilayer perceptron mapping, yields inference correction features. These features are used to correct and complete potential human errors, missing elements, or hierarchical inconsistencies in the original input at the link level, while preserving the structural consistency of the inference process. Specifically, this invention proposes a dual-link inference module for syndrome differentiation. Through forward and reverse links, mask information is transmitted and relationships are enhanced, enabling the model to simultaneously capture the implicit semantic connections between "preliminary diagnosis → treatment principles and methods" and its reverse process. First, the dialectical embedding of the original semantics is extracted. , , , In forward link reasoning, the link prior matrix is used as a mask constraint, and a masked feedforward neural network is used. By sequentially modeling the reasoning relationships from previous elements to subsequent elements, three types of positive relationship representations are obtained: in, , , Represents a linear mapping function between elements at different levels; , , Let the learnable weight matrix be represented; based on this, a dialectical representation incorporating forward inference information is defined: , , , Subsequently, the forward reasoning representations of the four elements are concatenated and input into a shallow multilayer perceptron for linear transformation and random deactivation to obtain the forward reasoning perceptual representation. : Similarly, in reverse link reasoning, this invention utilizes the transpose of the link matrix to simulate the reverse semantic transmission of "treatment principles and methods → preliminary diagnosis," and constructs three types of reverse relation representations. , , : in, , , Represents a linear mapping function between elements at different levels; , , , This represents a dialectical representation that integrates backward reasoning information. Furthermore, it utilizes an MLP for linear mapping and activation to obtain a backward reasoning perceptual representation. : Finally, by combining the semantic perception results of the forward and reverse links, a reasoning representation based on bidirectional link fusion is obtained. : in, Presentation layer normalization operation, This represents the element-wise product of vectors. This dual-link structure can capture the implicit dependencies between dialectical elements from both positive and negative directions, making the model more semantically consistent with the logical system of TCM syndrome differentiation and treatment.
[0032] S23, further construct a herbal enhancement branch on another parallel path, map each dialectical element to the herbal space and learn weighted coefficients by an enhanced multilayer perceptron, thereby obtaining enhanced features. These enhanced features characterize the differentiated contributions of different dialectical elements to the herbal response, making the herbal space representation have stronger interpretable mapping capabilities. In prediction tasks based on tabular data, the various table items often have semantic relationships. In the process of TCM prescription reasoning, the selection of herbs is influenced by the complex co-occurrence relationships between each dialectical element and the herbs. To enable the model to explicitly learn these multi-layered semantic relationships between the input dialectical elements and the herbs, this invention designs a herb response enhancement branch, aiming to semantically enhance and structurally awarely model the herb representation through multi-source co-occurrence knowledge.
[0033] This invention uses a learnable embedding matrix to represent the embedding of four types of dialectical elements. Mapping to the same semantic space yields , , , : And respectively through masked linear mapping functions , , , Project it into the herbal dimension: here, ; This represents a learnable weight matrix; the masking operation ensures that information is propagated only on verified semantic associations, preventing noise interference.
[0034] Subsequently, attention weights are obtained by integrating the semantic contributions of the four types of dialectical elements through an attention weighting mechanism. : in, This herbal enhancement representation integrates data co-occurrence, semantic reasoning, and expert knowledge, providing high-quality structured feature support for subsequent herbal recommendation and dosage prediction tasks.
[0035] S24, the original semantic features, inference correction features, and enhancement features are concatenated and fused to obtain a unified fused representation. A joint output head for classification and regression is then constructed on top of this fused representation. Both the classification head and the regression head are implemented using two linear layers. The classification head outputs the probability distribution of herbal recommendations to determine the herbal set, while the regression head outputs the predicted dosage values for the corresponding herbal medicines. Specifically, this invention first transforms the three categories separately through a feedforward transformation function... Projected onto a space of the same dimension and concatenated to obtain a fused feature vector. : S25, during inference and training, the herb selection results output by the classification head are used to generate a mask vector. This mask is then used to gate the regression head output, suppressing or zeroing the dosage predictions of unselected herbs. This ensures consistent output based on "selecting herbs first, then quantifying" and reduces unreasonable dosage noise. In the herb recommendation branch, the model extracts higher-order semantics through a two-layer fully connected network. here, , , , These are learnable parameters. To incorporate co-occurrence priors between herbs to enhance their compatibility, this invention... An enhancement term based on the co-occurrence matrix is applied, and then normalized to a probability vector. : in, It is an element-wise Sigmoid activation function. This is the herb-herb co-occurrence matrix. Model output results. The multi-label probability vector of herbs, after binarization, yields the herb classification result, such as... This indicates a recommendation for herbal remedies. Conversely, it indicates that it is not recommended.
[0036] In the dose regression branch, this invention first binarizes the classification probability using a threshold to obtain a mask for regression. The original dose prediction is then output through two fully connected layers: Finally, a mask is applied at the medicinal material level to remove noise from low-confidence herbs: S3. Based on the statistical analysis of co-occurrence relationships in clinical data, the structured extraction of authoritative TCM corpus, and the verification by TCM experts, a dialectical relationship graph with multi-source knowledge alignment is constructed, generating a topological prior matrix for link reasoning and mask constraint calculation, and injecting hard constraints of clinical prior knowledge. S31. Based on the TCM-EHR dataset, co-occurrence relationships are extracted, and the common occurrence patterns between diagnostic subjects in real cases are statistically analyzed. Based on this, a set of candidate relationship triples between diagnostic subjects is generated to characterize the data-driven association structure. S32 constructs a TCM corpus based on authoritative TCM classics and textbooks (including "Huangdi Neijing" and "TCM Diagnostics"), and uses a large model (ChatGPT) to perform structured extraction on the corpus to obtain another set of relation triples, thereby obtaining knowledge-driven relation candidates; S33. Find the intersection of the data-driven triple set and the corpus-extracted triple set. The consistent parts are directly identified as the edge set of the high-confidence relation graph. The remaining inconsistent candidate relations are submitted to TCM experts for revision and filtering. Relationships that do not conform to clinical common sense or lack sufficient evidence are deleted and necessary edges are added to form the final dialectical relation graph. S34, the relationship graph is further matrixed to generate a priori relationship matrix (which can be an adjacency matrix, a binary mask matrix, or a weighted matrix) for link reasoning and topological constraint calculation, and corresponding matrices are constructed for the relationships between entities at different levels to support hierarchical reasoning and constraint calculation.
[0037] S4. Establish a comprehensive evaluation system covering the performance of herbal recommendations, dosage prediction errors, and compatibility safety risks. Adopt a joint training strategy to optimize classification and regression tasks, ensuring the consistency between herbal selection and dosage prediction, improving model training stability and clinical application reliability, and achieving interpretable, safe, and highly controllable TCM prescription generation and dosage prediction.
[0038] S41 establishes an effectiveness index system for multi-label herbal medicine recommendation tasks, and preferentially uses Precision, Recall and F1 under different K values to evaluate the recommendation hit rate. The contribution of the original semantic branch, the link reasoning branch and the enhancement branch to the overall performance can be verified by ablation comparison.
[0039] S42. Establish an error index system for dose prediction, preferably only statistically analyze the dose error of herbs appearing in the actual prescription, use absolute error or mean square error index to measure the prediction accuracy, and evaluate the noise suppression effect of mask gating on the regression output to avoid non-zero dose output of unselected herbs.
[0040] S43 establishes a risk indicator system for clinical safety, statistically predicts the contraindication triggering of prescriptions based on a pre-set set of contraindication rules, and obtains indicators such as contraindication triggering rate or unreasonable compatibility rate, so that safety and effectiveness can be used together as the basis for model acceptance.
[0041] S44 employs a joint training strategy to simultaneously optimize classification and regression tasks. The classification loss is used to fit the herb selection, while the regression loss is calculated only for real herbs under mask constraints. In the inference phase, the classification output generates mask-gated regression results, thereby ensuring that the dosage output and herb selection are consistent and linked, and improving training stability.
[0042] The data used in this invention comes from the private dataset TCM-EHR, and its construction and data distribution can be found by referring to [reference needed]. Figure 2This invention references nine comparative models: BERT, SMGCN, KDHR, TCMPR, MLP, LEAP, RETAIN, PresRecST, and PresRecRF. The ablation experiments designed for this invention include: TCDR-G-GCN: a variant of this invention that limits graph representation learning on the knowledge graph to a GCN architecture within the framework of this invention, to verify the performance improvement of graph convolutional networks on dialectical element-herb matching; TCDR-G-GAT: replacing GCN with a graph attention network GAT, enhancing the weights of key relationships through a neighbor attention mechanism, thereby evaluating whether attention-based graph propagation brings benefits; TCDR-NoReason: an ablation version that removes the dual-link reasoning part in the syndrome module, used to examine the contribution of explicit dialectical reasoning mechanisms to the final recommendation and dose prediction performance; and TCDR-NoEncance: an ablation version that removes the mask enhancement mechanism in the herb representation enhancement module, retaining only the basic pathway, used to evaluate the benefits of the enhancement mechanism. TCDR-NoMask: An ablation version that removes the masking threshold suppression mechanism or related masking logic at the output end and replaces it with a simple linear layer to analyze the impact of the masking mechanism on dose regression and stability. TCDR-NoG-HH: An ablation version that removes the mapping of the herbal-herbal co-occurrence matrix in the classification results, aiming to verify the enhancing effect of herbal compatibility priors on model performance.
[0043] The control experiment and ablation experiment are shown in Table 1 and Table 2: Table 1 Table 2 The results in the table demonstrate the effectiveness of the proposed method.
[0044] Furthermore, in real-world clinical settings, even if a prescription model exhibits excellent overall performance, it is unacceptable if it occasionally generates herbal combinations that violate fundamental safety rules. For each trained model, this invention applies it to the TCM-EHR test set, which contains 116,800 outpatient records, to calculate the proportion of predicted prescriptions containing at least one contraindicated herbal combination. Figure 3As shown, traditional deep models such as BERT, SMGCN, and MLP have inconsistency rates of around 0.8%–0.9%, while the knowledge-enhanced baseline model PresRecST has a slightly lower inconsistency rate of 0.73%. KDHR heavily relies on co-occurrence-based symptom-herb graphs and lacks explicit diagnostic chain modeling, resulting in the highest inconsistency rate of 1.17%. This suggests that unconstrained co-occurrence graphs may propagate noise or clinically unsafe patterns from the training data. Introducing maskless topological constraint reasoning in TCDR-NoMask reduced the inconsistency rate to 0.44%, indicating that explicit modeling of the PTSM diagnostic chain is beneficial for improving safety. The full TCDR model further reduced the inconsistency rate to 0.08% (14 prescriptions), an order of magnitude lower than KDHR. These results confirm that the proposed expert-derived topological prior and MaskLinear-based masking mechanism provide effective structural safeguards, suppressing clinically unsafe herbal combinations. The topologically constrained neural symbolic reasoning directly contributes to the clinical effectiveness and credibility of TCDR in supporting TCM prescriptions where safety is paramount.
[0045] To enhance model validation, Figure 4 The performance of the model under different parameters and fusion methods was recorded separately. Figure 5 This demonstrates a comparison between the model and a general-purpose large model without training samples on the TCM drug recommendation task. It reveals the model's performance advantages and interpretable safety advantages.
[0046] Example 2: This embodiment provides a TCM prescription generation and dosage prediction system based on dual-link diagnostic reasoning and masked linear topological constraints, including: The diagnosis and treatment chain structured coding module performs terminology standardization, frequency-aware denoising, type-separable hierarchical coding, and hierarchical embedding fusion on the diagnostic elements in electronic medical records to generate a unified patient representation. The three-branch collaborative representation module takes the patient representation as parallel input to the original semantic backbone branch, the dual-link diagnosis and treatment reasoning correction branch, and the element-driven herbal response enhancement branch. It extracts the original semantic features, reasoning correction features, and herbal enhancement features respectively and completes multi-source feature fusion. Through the joint output head, it realizes multi-label classification and dose regression of herbal medicine. At the same time, it uses the classification results to generate a mask vector and performs gating constraints on the regression output. The topology prior construction module, based on the co-occurrence relationship statistics of clinical data, the structured extraction of authoritative TCM corpus and the verification by TCM experts, constructs a dialectical relationship graph with multi-source knowledge alignment, generates a topology prior matrix for link reasoning and mask constraint calculation, and injects hard constraints of clinical prior knowledge. The joint evaluation and training module establishes a comprehensive evaluation system covering the performance of herbal recommendations, dosage prediction errors, and compatibility safety risks. It adopts a joint training strategy to optimize classification and regression tasks, thereby enabling the generation of TCM prescriptions and dosage prediction.
[0047] The above modules can be deployed on the same device or distributed devices; the division of modules is only a functional logic description and does not limit the specific physical boundaries or implementation order.
[0048] Example 3: An electronic device is provided for running the aforementioned "Traditional Chinese Medicine Prescription Generation and Dosage Prediction Method Based on Dual-Link Diagnosis and Treatment Inference and Masked Linear Topological Constraints". The electronic device includes a processor, a memory, and optional communication interfaces / display devices / input devices, etc.; the memory stores a computer program that can run on the processor, and when the processor executes the program, it implements steps S1 to S4 of the method described in Embodiment 1, specifically including but not limited to: S1. Standardize the terminology, frequency-aware denoising, type-separable hierarchical coding, and hierarchical embedding fusion of the diagnostic elements in the electronic medical record to generate a unified patient representation; S2. The patient representation is input in parallel into the original semantic backbone branch, the dual-link diagnosis and treatment reasoning correction branch, and the element-driven herbal response enhancement branch. The original semantic features, reasoning correction features, and herbal enhancement features are extracted respectively, and multi-source feature fusion is completed. Herbal multi-label classification and dose regression are realized synchronously through the joint output head. At the same time, the classification results are used to generate a mask vector to perform gating constraints on the regression output to ensure the consistency of the clinical logic of "selecting drugs first and then quantifying". S3. Based on the statistical analysis of co-occurrence relationships in clinical data, the structured extraction of authoritative TCM corpus, and the verification by TCM experts, a dialectical relationship graph with multi-source knowledge alignment is constructed, generating a topological prior matrix for link reasoning and mask constraint calculation, and injecting hard constraints of clinical prior knowledge. S4. Establish a comprehensive evaluation system covering the performance of herbal recommendations, dosage prediction errors, and compatibility safety risks. Adopt a joint training strategy to optimize classification and regression tasks, ensuring the consistency between herbal selection and dosage prediction, improving model training stability and clinical application reliability, and achieving interpretable, safe, and highly controllable TCM prescription generation and dosage prediction.
[0049] The electronic device hardware can be one of a server, personal computer, workstation, industrial controller, edge computing device, or mobile terminal; the processor can be a general-purpose CPU, GPU, NPU, FPGA, or a combination thereof; the memory can be RAM, ROM, flash memory, or disk array. The device can interact with local / remote data storage (acquiring observation data and outputting inversion results) through a communication interface. The above hardware configuration does not constitute a limitation of the present invention.
[0050] Example 4: A computer-readable storage medium storing a computer program, which, when run on a processor of an electronic device, causes the program to perform the method steps S1 to S4 described in Embodiment 1; the storage medium may be a disk, optical disk, flash memory, solid-state drive, read-only memory, random access memory, or any combination of the above media.
[0051] Application Example 1: Traditional Chinese Medicine Prescription Generation and Dosage Prediction in Clinical Decision Support This invention can be applied to consultation and prescription decision support scenarios in traditional Chinese medicine clinics or internet hospitals. In specific implementation, it first collects hierarchical diagnostic elements such as preliminary diagnosis, TCM diagnosis, syndrome differentiation, and treatment principles from the patient's actual treatment process. Then, following step S1 of this invention, it completes terminology standardization, low-frequency denoising, hierarchical coding, and embedding fusion processing to generate a standardized patient input representation. Subsequently, following step S2, the patient input representation is input in parallel into the original semantic branch, the link reasoning correction branch, and the herbal enhancement branch. Through multi-source feature fusion, a unified representation is obtained, and finally, the herbal recommendation result and dosage prediction result are output. The classification output is used to generate a mask for gated regression output, strictly adhering to the clinical logic consistency of "selecting medicine first, then quantifying." Compared to traditional methods that rely solely on rule bases or static "symptom-herbal" mapping, this embodiment, while preserving the original semantic information, can perform structural consistency verification and correction on the diagnosis and treatment link. Simultaneously, under topological prior constraints, it suppresses the propagation of unreasonable associations, effectively improving the interpretability and controllability of prescription generation, reducing the risk of unreasonable combinations, and enhancing the stability of dosage output.
[0052] Application Example 2: Clinical Research and Knowledge Discovery: Therapeutic Chain Reasoning Analysis Scenario This invention is applicable to historical case mining and treatment pattern analysis scenarios in medical research institutions or medical data analysis centers. For large-scale clinical records, a topological prior matrix is first constructed according to step S3: on the one hand, candidate relation triples are generated based on data co-occurrence statistics; on the other hand, knowledge triples are structurally extracted from authoritative TCM corpora. Through intersection fusion and expert revision, the final diagnostic relationship diagram and its matrix representation are formed. Furthermore, this topological prior matrix is introduced into the calculation of link inference correction branches and topological mask constraints, making the model explicitly controlled by expert-verifiable relation structures during the learning process, thereby obtaining traceable inference paths and more stable association propagation results. This embodiment can not only realize prescription recommendation and dosage prediction, but also output the correlation strength between key elements of the treatment link, the difference analysis results before and after inference correction, and the contribution explanation of different diagnostic elements to herbal medicine decisions, providing solid data support for clinical pathway research, evidence-based analysis, and knowledge base iteration.
[0053] Application Example 3: Privacy Compliance and Remote Deployment of Prescription Review and Risk Warning Scenarios This invention can be deployed on intranet systems of medical institutions or remote collaborative diagnosis and treatment platforms that require data security and privacy protection. Through a localized deployment mode, patient data is processed locally, completing the structured encoding and model reasoning of diagnostic and treatment elements, thus preventing the leakage of sensitive information during network transmission. In the output stage, combined with the comprehensive evaluation system described in step S4 and the preset set of contraindication rules, the generated prescription undergoes contraindication combination detection and risk statistics, triggering alarms or interception strategies when necessary, providing technical support for prescription review and clinical risk control. This embodiment is particularly suitable for scenarios with limited physician resources, cross-regional collaborative diagnosis and treatment, or centralized prescription review. While ensuring the effectiveness of prescription recommendations, it enhances the safety and regulatory capacity of clinical applications and significantly reduces the burden of manual review.
[0054] Those skilled in the art will understand that the modules or steps described above can be implemented using general-purpose computer devices. Optionally, they can be implemented using computer-executable program code, which can then be stored in a storage device for execution by a computer device. Alternatively, they can be fabricated as separate integrated circuit modules, or multiple modules or steps can be fabricated as a single integrated circuit module. This disclosure is not limited to any particular combination of hardware and software.
[0055] The above description is merely a preferred embodiment of this application and is not intended to limit 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 protection scope of this application.
Claims
1. A method for TCM prescription generation and dosage prediction based on dual-link diagnostic reasoning and masked linear topological constraints, characterized in that, Includes the following steps: The diagnostic elements in electronic medical records are standardized in terms of terminology, frequency-aware denoising, type-separable hierarchical coding, and hierarchical embedding fusion to generate a unified patient representation. The patient representation is input in parallel into the original semantic backbone branch, the dual-link diagnosis and treatment reasoning correction branch, and the element-driven herbal response enhancement branch. The original semantic features, reasoning correction features, and herbal enhancement features are extracted respectively, and multi-source feature fusion is completed. Herbal multi-label classification and dose regression are realized synchronously through the joint output head. At the same time, the classification results are used to generate a mask vector to perform gating constraints on the regression output. Based on the statistical analysis of co-occurrence relationships in clinical data, the structured extraction of authoritative TCM corpus, and the verification by TCM experts, a dialectical relationship graph with multi-source knowledge alignment is constructed to generate a topological prior matrix for link reasoning and mask constraint calculation, and inject hard constraints of clinical prior knowledge. A comprehensive evaluation system covering the performance of herbal recommendations, dosage prediction errors, and compatibility safety risks was established. A joint training strategy was adopted to optimize the classification and regression tasks, thereby realizing the generation of TCM prescriptions and dosage prediction.
2. The method for generating and predicting traditional Chinese medicine prescriptions based on dual-link diagnostic reasoning and masked linear topological constraints according to claim 1, characterized in that, The diagnostic elements in electronic medical records undergo terminology standardization, frequency-aware denoising, type-separable hierarchical coding, and hierarchical embedding fusion, specifically as follows: Terminology standardization: Map synonyms, alternative names and variant characters in electronic medical records to unified standard terms, extract key elements of preliminary diagnosis, TCM diagnosis, syndrome and treatment principles and methods according to the diagnosis and treatment chain, and standardize the coding of herbal entities; Frequency-aware noise reduction: Frequency statistics are performed on the four types of diagnostic elements and herbal entities to filter low-frequency entities and eliminate or reduce records with excessive noise or insufficient information. Type-separable hierarchical coding: Four types of dialectical elements are encoded using either one-hot or multi-hot methods, and mapped to a continuous vector space through a learnable word embedding table to construct a learnable embedding matrix. , , and The four types of dialectical elements are represented by multi-hot vectors, and the embedded representation is obtained through the embedding matrix: in, , , , Learnable embedding matrices corresponding to the four categories of diagnostic elements: "preliminary diagnosis, TCM diagnosis, syndrome, and treatment principles and methods"; , , , It refers to the number of entities corresponding to the dialectical elements. It is the dimension of the embedded vector; , , , These are the multi-hot vectors of the four types of dialectical elements. , , , These are continuous vector representations of the four types of dialectical elements obtained after embedding matrix mapping; Hierarchical embedding fusion: The embedding vectors of the four types of diagnostic elements are concatenated, and then subjected to linear mapping and random deactivation processing using a shallow multilayer perceptron to obtain the patient representation vector. : in, Indicates the activation function; This represents a vector concatenation operation; This represents a learnable embedding matrix.
3. The method for generating and predicting traditional Chinese medicine prescriptions based on dual-link diagnostic reasoning and masked linear topological constraints according to claim 1, characterized in that, The original semantic backbone branch, the dual-link diagnostic reasoning correction branch, and the element-driven herbal response enhancement branch extract original semantic features, reasoning correction features, and herbal enhancement features, respectively, as follows: Original semantic backbone encoding: Input the patient representation into the Transformer encoder, retain the explicit semantic information of the electronic medical record, and obtain the original semantic features. ; Based on the topological prior matrix, a two-link reasoning process is employed: a forward "preliminary diagnosis → TCM diagnosis → syndrome → treatment principle and method" and a reverse "treatment principle and method → syndrome → TCM diagnosis → preliminary diagnosis". This process, combined with masked linear operations and a multilayer perceptron, generates reasoning correction features. This represents the perception of positive reasoning. Reverse reasoning perception representation, Presentation layer normalization operation, This represents the element-wise product of vectors. Element-driven herbal response enhancement: The embedding vectors of four types of dialectical elements are mapped to the herbal space respectively. The weighting coefficients of each element's response to the herbal response are learned by an enhanced multilayer perceptron to generate herbal enhancement features.
4. The method for generating and predicting traditional Chinese medicine prescriptions based on dual-link diagnostic reasoning and masked linear topological constraints according to claim 3, characterized in that, In forward link reasoning, the hierarchical reasoning relationship is modeled sequentially using a masked feedforward neural network Masklinear(∙), resulting in three types of forward relationship representations: in, , , A linear mapping function representing elements at different levels; , , The topological prior matrix of the corresponding hierarchical dialectical elements; , , These represent the forward inference relationship of "preliminary diagnosis → TCM diagnosis, TCM diagnosis → syndrome, syndrome → treatment principles and methods"; , , Represents the learnable weight matrix; By fusing forward reasoning information, we obtain a forward reasoning perceptual representation. : in, This represents the learnable weight matrix.
5. The method for generating and predicting traditional Chinese medicine prescriptions based on dual-link diagnostic reasoning and masked linear topological constraints according to claim 3, characterized in that, In reverse link reasoning, the transpose of the link matrix is used to simulate reverse semantic transmission, resulting in three types of reverse relation representations: in, , , A linear mapping function representing elements at different levels; , This represents a reverse reasoning relationship: "Treatment principles and methods → syndrome, syndrome → TCM diagnosis, TCM diagnosis → preliminary diagnosis"; , , Represents the learnable weight matrix; Integrating backward reasoning information to obtain backward reasoning perceptual representation : in, This represents the learnable weight matrix.
6. The method for generating and predicting traditional Chinese medicine prescriptions based on dual-link diagnostic reasoning and masked linear topological constraints according to claim 1, characterized in that, The method for generating herbal enhancement features is as follows: the embedding representations of the four types of dialectical elements are processed through a learnable embedding matrix. Mapping to the same semantic space yields , , , : Projected onto the herb dimension via a masked linear mapping function: in, Represents the learnable weight matrix; Weights are learned based on an attention-weighted mechanism. Generate herbal enhancement features : in, It enhances the representation of herbs by integrating data co-occurrence, semantic reasoning, and expert knowledge.
7. The method for generating and predicting traditional Chinese medicine prescriptions based on dual-link diagnostic reasoning and masked linear topological constraints according to claim 1, characterized in that, This method achieves simultaneous multi-label classification and dosage regression of herbal medicines through a joint output head. Simultaneously, it generates a mask vector using the classification results and applies gating constraints to the regression output. Specifically, it integrates the original semantic features, inference correction features, and herbal enhancement features through a feedforward transformation function. Projecting the vectors onto the same dimension and concatenating them yields a fused feature vector. : Construct a two-layer linear structure for the classification head and regression head. The classification head extracts higher-order semantics and outputs the probability distribution using the following formula. : in, , , , For learnable parameters, Weighting coefficients for masking operations, The topological prior matrix among herbs The first-level linear transformation of the classification head and Intermediate features after activation Higher-order semantic features after the second-level linear transformation of the classification head; This represents the multi-label probability vector for herbs. Predicted raw dose output from regression head: in, , The learnable weight matrix of the regression head. , For the learnable bias term of the regression head, These are intermediate features after the first linear transformation of the regression head and ReLU activation; The original dose prediction results output by the regression head.
8. A Traditional Chinese Medicine prescription generation and dosage prediction system based on dual-link diagnostic reasoning and masked linear topological constraints, characterized in that, include: The diagnosis and treatment chain structured coding module performs terminology standardization, frequency-aware denoising, type-separable hierarchical coding, and hierarchical embedding fusion on the diagnostic elements in electronic medical records to generate a unified patient representation. The three-branch collaborative representation module takes the patient representation as parallel input to the original semantic backbone branch, the dual-link diagnosis and treatment reasoning correction branch, and the element-driven herbal response enhancement branch. It extracts the original semantic features, reasoning correction features, and herbal enhancement features respectively and completes multi-source feature fusion. Through the joint output head, it realizes multi-label classification and dose regression of herbal medicine. At the same time, it uses the classification results to generate a mask vector and performs gating constraints on the regression output. The topology prior construction module, based on the co-occurrence relationship statistics of clinical data, the structured extraction of authoritative TCM corpus and the verification by TCM experts, constructs a dialectical relationship graph with multi-source knowledge alignment, generates a topology prior matrix for link reasoning and mask constraint calculation, and injects hard constraints of clinical prior knowledge. The joint evaluation and training module establishes a comprehensive evaluation system covering the performance of herbal recommendations, dosage prediction errors, and compatibility safety risks. It adopts a joint training strategy to optimize classification and regression tasks, thereby realizing the generation of TCM prescriptions and dosage prediction.
9. An electronic device, comprising a memory, a processor, and a computer program stored in the memory and running thereon, characterized in that, When the processor executes the program, it implements the method for generating and predicting traditional Chinese medicine prescriptions based on dual-link diagnostic reasoning and masked linear topological constraints as described in any one of claims 1-7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When executed by the processor, the program implements the method for generating and predicting traditional Chinese medicine prescriptions based on dual-link diagnostic reasoning and masked linear topological constraints as described in any one of claims 1-7.