A patient personalized rehabilitation diagnosis and treatment model construction method

By constructing a personalized rehabilitation diagnosis and treatment model using the Transformer-Encoder architecture and Q-learning algorithm, the problems of time-consuming and inefficient traditional manual analysis are solved, enabling rapid and accurate personalized treatment plan recommendations.

CN123033647APending Publication Date: 2026-11-03AIR FORCE MEDICAL CENT PLA
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510119731.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-24
Publication Date
2026-11-03

AI Technical Summary

Technical Problem

Traditional manual analysis methods are time-consuming and inefficient, leading to a "one-size-fits-all" approach to treatment that fails to address individual patient differences and affects the effectiveness and safety of treatment.

Method used

A rehabilitation diagnosis and treatment model is built using the Transformer-Encoder architecture. Combining multi-head attention mechanism and Q-learning algorithm, patient data is computed in parallel through self-attention mechanism. A reward function is designed to comprehensively evaluate the treatment effect. Reinforcement learning is used to update the Q value and recommend the optimal treatment program.

Benefits of technology

It improves the accuracy and efficiency of treatment plans, can quickly process large-scale medical data, capture long-term dependencies, provide personalized treatment strategies, and reduce the time spent on manual analysis.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123033647A_ABST
    Figure CN123033647A_ABST
Patent Text Reader

Abstract

The application discloses a kind of patient personalized rehabilitation diagnosis and treatment model construction method, this method is by collecting about patient related data, determine action space, pre-processing, screen out target feature and construct input sequence into target feature, build the Encoder part model architecture based on Transform, respectively set embedding mode for each type of feature in input sequence, configure multi-head attention mechanism in each layer of Transform-Encoder, divide into training set, validation set and test set, define loss function and optimizer, carry out the training of the rehabilitation diagnosis and treatment model, carry out model evaluation to obtain final rehabilitation diagnosis and treatment model etc. Step, using Q-learning algorithm to recommend optimal treatment project, different patients can recommend suitable treatment project, short time is needed, work efficiency is high, solve the technical problems existing in artificial analysis mode, long time consumption, low efficiency, cause "one size fits all" treatment mode etc.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of medical technology, specifically to a method for constructing a personalized rehabilitation treatment model for patients. Background Technology

[0002] With the popularization and rapid development of medical informatization, current medical data is characterized by large volume, many types, high value, low value density, rapid generation, and rapid processing. Data analysis mainly relies on traditional manual analysis.

[0003] Typically, doctors and researchers in large hospitals or medical research institutions have to complete a large amount of work every day. For example, doctors in hospital clinical departments need to study, analyze, and make decisions based on the medical data collected daily. The massive amounts of patient information include basic information, symptom and diagnostic data, and treatment history data. Traditional manual analysis methods are time-consuming and inefficient, making it difficult to efficiently extract valuable diagnostic and treatment clues. Furthermore, due to significant individual differences among patients, even those with the same disease can have vastly different responses to treatment and prognoses due to factors such as age, gender, genes, and lifestyle habits. Manual analysis can sometimes lead to a "one-size-fits-all" approach to treatment, thus affecting the effectiveness and safety of treatment. Summary of the Invention

[0004] This invention provides a method for constructing a personalized rehabilitation treatment model for patients, aiming to solve the technical problems of manual analysis methods, such as long time consumption, low efficiency, and "one-size-fits-all" treatment methods.

[0005] The technical solution provided by this invention is as follows:

[0006] A method for constructing a personalized rehabilitation treatment model for patients includes the following steps:

[0007] Collect first data about the patient, including the patient's clinical data, lifestyle data, environmental factors data, and genetic data;

[0008] The set of available treatment options defines the action space, with each treatment option corresponding to a discrete action.

[0009] The first collected data is preprocessed;

[0010] Target features are selected from the preprocessed first data, and the target features are used to construct an input sequence that meets the input requirements of Transformer-Encoder;

[0011] The model architecture is built based on the Transformer Encoder part, and the embedding method is set for each type of feature in the input sequence. A multi-head attention mechanism is configured in each layer of the Transformer-Encoder to realize the construction of a rehabilitation diagnosis and treatment model based on Transformer-Encoder.

[0012] The preprocessed first data is divided into a training set, a validation set, and a test set according to a certain ratio. A loss function and an optimizer are defined to train the rehabilitation diagnosis and treatment model and obtain the current optimal model.

[0013] The optimal model is used to predict and recommend treatment items on the test set. Performance indicators are calculated based on the reward function and Q-learning algorithm, and the model is evaluated and validated. The model evaluation and validation includes clinical usability indicators, long-term effect tracking, multi-center validation, and validation in simulated real-world scenarios.

[0014] Based on the evaluation results, the model is optimized and adjusted to obtain the final rehabilitation treatment model. The expression for the reward function is:

[0015] R(s,a)=α×E+β×C+γ×U+δ×L+ε×M) where R(s,a) is used to measure the reward brought about by taking therapeutic action a when the patient is in state s;

[0016] R is the reward value, used to evaluate the overall effectiveness of the treatment plan recommended by the model;

[0017] E is a treatment efficacy evaluation indicator, which measures the degree to which the treatment plan improves the patient's condition;

[0018] C represents the evaluation of the patient's physical and psychological comfort.

[0019] U is a resource utilization efficiency indicator, which considers the efficiency of treatment plans in the use of medical resources;

[0020] L represents the long-term effect tracking indicator;

[0021] M represents the model's performance metrics in multi-center validation and real-world scenario validation.

[0022] α, β, γ, δ, and ε are weighting coefficients used to adjust the relative importance of each indicator in the reward function;

[0023] The expression for the Q-learning algorithm is:

[0024]

[0025] Where Q(s) t α t) is in state s t Take action α t The value of α is the learning rate, and r is the learning rate. t+1 Is taking action α t The immediate reward received afterward, where γ is the discount factor. It represents the maximum value among all possible actions taken in the next state.

[0026] Secondary data from other patients is collected and preprocessed, then input into the final rehabilitation model, which outputs the corresponding patient's treatment prediction results and a list of recommended optimal treatment items.

[0027] Furthermore, the preprocessing of the collected first data specifically includes:

[0028] The collected first data is subjected to data cleaning, noise reduction, data standardization / normalization, and data encoding.

[0029] Furthermore, the process of cleaning, denoising, standardizing / normalizing, and encoding the collected first data includes the following steps:

[0030] Check whether there are missing values, duplicate values, or erroneous values ​​in the first data collected. If there are missing values, fill them in; if there are duplicate values, remove duplicates; if there are erroneous values, correct or remove them.

[0031] Noise removal is performed on the text data in the first data to make the text more concise, clear and easy to understand;

[0032] For numerical data of different magnitudes in the first data, standardization or normalization methods are used to transform them to the same scale range to facilitate subsequent model training and computation.

[0033] For the categorical data in the first data, an encoding method is used to convert it into a numerical form that a computer can recognize and process.

[0034] Furthermore, the target features include at least features related to diagnosis and treatment prediction and treatment items;

[0035] The target features are constructed into an input sequence that meets the input requirements of Transformer-Encoder. Specifically, the features are arranged in the order of the patient's basic information, current symptoms, examination results, and past treatments. The feature vectors corresponding to each part are then concatenated to form a complete input sequence with a temporal or logical order.

[0036] Furthermore, the Transformer-based Encoder part constructs the model architecture, sets embedding methods for various features in the input sequence, and configures a multi-head attention mechanism in each layer of the Transformer-Encoder to realize the construction of a rehabilitation diagnosis and treatment model based on Transformer-Encoder, including the following steps:

[0037] The core model architecture is built based on the Encoder part of Transformer. The number of layers in the model, the number of hidden units in each layer, and the number of heads in the multi-head attention mechanism are determined and adjusted reasonably according to specific computing resources and task complexity.

[0038] Set appropriate embedding methods for each type of feature in the input sequence, and transform discrete feature values ​​or classification codes into low-dimensional continuous vector representations so that they can be better learned and processed by the model;

[0039] In each layer of the Transformer-Encoder, a multi-head attention mechanism is configured appropriately to enable it to focus on different parts of the input sequence, capture the long-term and short-term dependencies between features, and optimize its ability to extract information from the input sequence by adjusting the relevant parameters of the attention mechanism. This ensures that the model can extract key diagnosis and treatment related information from complex patient data. The relevant parameters include the weight initialization of the attention head and the scaling factor.

[0040] Further, the step of dividing the preprocessed first data into a training set, a validation set, and a test set according to a certain ratio, defining a loss function and an optimizer, and training the rehabilitation diagnosis and treatment model to obtain the current optimal model includes the following steps:

[0041] The preprocessed first data is divided into training set, validation set and test set in a ratio of 8:1:1 or 7:2:1 to ensure the randomness of the partitioning process and the consistency of data distribution, so that each set can reasonably reflect the characteristics of the overall data for model training, parameter adjustment and performance evaluation.

[0042] Based on the nature of the diagnosis and treatment prediction and treatment item recommendation tasks, select the loss function and optimizer to update the model parameters, set the optimizer parameters, and make appropriate adjustments according to the training situation;

[0043] The training set is used as input to train the Transformer-Encoder-based rehabilitation model iteratively multiple times. In each iteration, the model output is calculated through forward propagation, the loss value is calculated according to the defined loss function, and then the optimizer is used for backpropagation to update the model's parameters, thereby gradually reducing the loss value and improving the model's ability to predict patient conditions and the accuracy of treatment recommendations. During training, the Transformer-Encoder-based rehabilitation model is periodically evaluated using a validation set to monitor changes in the model's performance metrics on the validation set, preventing overfitting. When the validation set performance no longer improves or shows a downward trend, training is stopped, and the current optimal model is saved.

[0044] Furthermore, the selection of the loss function based on the nature of the diagnosis and treatment prediction and treatment item recommendation task is specifically as follows:

[0045] Based on the multi-class treatment item recommendation task, the cross-entropy loss function is used, and the formula for the cross-entropy loss function is as follows:

[0046]

[0047] Among them, y i It's a real label. These are the predicted values, and N is the number of samples.

[0048] Based on the predicted continuous treatment outcome indicators, the mean squared error loss function is selected.

[0049] Furthermore, the process of using the optimal model to predict and recommend treatment items on the test set, calculating performance indicators and evaluating the model, and optimizing and adjusting the model based on the evaluation results to obtain the final rehabilitation treatment model includes the following steps:

[0050] The optimal model is used to predict diagnosis and treatment items on the test set, and the corresponding performance indicators are calculated. The performance indicators include the accuracy of predicting diagnosis and treatment results and the matching degree between the predicted treatment items and the actual best treatment items. The model's generalization ability and practical application effect on unseen data are comprehensively evaluated.

[0051] Based on the evaluation results of the test set, the shortcomings of the model are analyzed, and optimization measures are taken, including increasing the amount of training data, adjusting the model's hyperparameters, improving the selection and combination of input features, and trying different embedding methods or attention mechanism variants. Then, the model is retrained and evaluated to continuously optimize its performance until the final rehabilitation diagnosis and treatment model is obtained.

[0052] Furthermore, the calculation formula for the self-attention mechanism of the Transformer-Encoder-based rehabilitation diagnosis and treatment model is as follows:

[0053]

[0054] Where Q, K, and V are the query vector, key vector, and value vector, respectively, and d k It is the dimension of the key vector.

[0055] Furthermore, the action space treats various treatment items as discrete actions, numbered as follows:

[0056] Different exercise therapies, physical therapies, and equipment used in physical therapy correspond to different action numbers;

[0057] In drug therapy, each drug can correspond to an action number, and different dosages and courses of treatment can serve as different parameters for that action;

[0058] In surgical treatment, each type of surgical procedure corresponds to an action number;

[0059] In traditional Chinese medicine rehabilitation therapy, acupuncture, moxibustion, and massage each correspond to an action number.

[0060] Different types of psychotherapy correspond to different action numbers.

[0061] Compared with the prior art, the beneficial effects of the present invention are:

[0062] 1. Unlike traditional recurrent neural networks (RNNs), the self-attention mechanism in the Transformer-Encoder architecture employed in this invention enables the model to compute representations at each position in a sequence in parallel. In the self-attention layer, the computation at each position does not depend on the sequential computation of the previous position. For example, when processing a medical data sequence containing multiple time points, such as patient symptom records at different times, the Transformer-Encoder can process data from all time points simultaneously. This parallel computing capability significantly improves training and inference speed. For long-sequence data, such as long-term patient medical histories, it can utilize computing resources more efficiently and reduce training time. Compared to RNNs and their variants (such as LSTM and GRU), the Transformer-Encoder does not need to process elements in the sequence sequentially, especially when dealing with large-scale data, enabling faster computational tasks.

[0063] 2. The Transformer-Encoder model used in this invention, through its self-attention mechanism, can directly capture the dependencies between any two positions in a sequence, regardless of sequence length or distance. When calculating attention scores, elements at each position interact with elements at all other positions. For example, when analyzing a patient's medical records over many years, it can easily correlate potential relationships between disease diagnoses from years ago and current symptoms. For long-sequence data commonly found in fields such as medicine, such as long-term medical records and rehabilitation process tracking data, the Transformer-Encoder can better uncover long-term dependencies. This helps discover patterns hidden deep within the data, such as long-term disease development trends and long-term changes in treatment effects, thus providing stronger support for precision medicine.

[0064] 3. The multi-head self-attention layer in the Transformer-Encoder architecture used in this invention can learn features from different representation subspaces. Each head can focus on different aspects of the input sequence, and by concatenating and linearly transforming the outputs of multiple heads, these different feature representations can be synthesized. For example, when processing medical data containing basic patient information, symptoms, and examination results, different heads can focus on age-gender correlations in the basic information, correlations between symptoms, and the relationship between examination results and symptoms, etc. This multi-dimensional feature extraction method can learn richer and more complex features. In medical scenarios, it can uncover potential correlations between different types of medical data, such as the relationship between patients' lifestyle habits and disease development, and the synergistic or antagonistic effects between different treatment methods, providing a more comprehensive basis for medical decision-making.

[0065] 4. The Transformer-Encoder architecture adopted in this invention has excellent versatility and can be applied to various types of sequence data tasks, such as machine translation and text generation in natural language processing, as well as medical record analysis and disease prediction in the medical field. Its structure is relatively regular and easy to modify and extend. For example, the number of layers or heads can be easily increased or decreased to adjust the model's complexity to adapt to data of different scales and properties. In the era of big data in healthcare, the types and scales of data are constantly changing. The versatility and scalability of the Transformer-Encoder enable it to flexibly address various medical data processing needs. Whether processing small-scale clinical research data or large-scale regional medical data centers, effective data mining and analysis can be achieved by appropriately adjusting the model parameters.

[0066] 5. This invention provides a method for constructing a personalized rehabilitation treatment model for patients. By designing a reward function, feedback data can be comprehensively considered to provide a quantitative reward value to measure the merits of the selected treatment strategy. By continuously repeating the process of strategy selection, implementation, feedback data collection, and reward calculation, reinforcement learning methods such as Q-learning are used to update the Q value. Finally, the optimal treatment strategy is recommended based on the comparison of Q values. That is, for a given patient state s, the action α that maximizes Q is selected as the optimal treatment strategy recommended to the patient. This solves the technical problems of long time consumption, low efficiency, and "one-size-fits-all" treatment methods in manual analysis. Attached Figure Description

[0067] Figure 1 This is a flowchart illustrating the method for constructing a personalized rehabilitation treatment model for patients provided by the present invention. Detailed Implementation

[0068] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the embodiments described below are only some embodiments of this application, and not all embodiments.

[0069] like Figure 1 As shown, the present invention provides a method for constructing a personalized rehabilitation treatment model for patients, comprising the following steps:

[0070] S1. Collect primary data about the patient, including clinical data (basic information, symptoms, examination results, past treatment records), lifestyle data (daily diet, exercise habits, sleep quality, and other daily tracking information), environmental data (living environment and residential environment), and genetic data (genetic data).

[0071] In step S1, basic information, symptoms, examination results, and past treatment records of patients are collected from multiple channels such as the Hospital Information System (HIS) and Electronic Medical Record System (EMR), and data from wearable devices, such as smart bracelets or smartwatches, are also included.

[0072] Basic information includes age, gender, past medical history, family medical history, and allergy history. This information is organized into a structured data format for easier subsequent processing. The patient's basic information (such as age and gender) is coded as follows:

[0073] For example, age can be normalized to fall within the interval [0,1], and gender can be represented by 0 or 1. Assuming age is 'age', the normalized age is...

[0074] Various symptoms can be quantified into feature vectors. For example, for pain symptoms, a pain score (e.g., 0-10 points) can be used as part of the vector; for swelling, the degree of swelling (e.g., measuring the diameter of the swelling in centimeters) can be used as another dimension.

[0075] Various test results, such as blood test indicators (blood glucose, blood pressure, blood lipids, inflammatory markers, etc.), are standardized. For example, for blood glucose, the standardized blood glucose level is... Among them, glucose mean and glucose std It represents the mean and standard deviation of blood glucose levels for all patients.

[0076] Past treatment records include physical therapy, physiotherapy, use of medical equipment, medication, surgery, and psychotherapy.

[0077] For physical therapy, past exercise therapy data is converted into vector elements, such as encoding the angle range of joint range of motion, number of repetitions, and movement speed. For example, the range of joint range of motion can be represented as [min_angle, max_angle], and then normalized or standardized.

[0078] For physiotherapy, data such as electrotherapy, thermotherapy, ultrasound, and magnetotherapy are encoded. For example, the intensity, frequency, and treatment time of electrical stimulation can be used as different dimensions, and they also need to be normalized or standardized.

[0079] For the use of treatment equipment, the equipment parameters, such as treadmill speed and incline, are converted into vector elements and processed.

[0080] For drug treatment, information such as drug name, dosage, and course of treatment are encoded. For example, unique encoding can be used to represent drug name (assuming there are n drugs in total, when drug i is used, the position corresponding to that drug is 1, and the rest are 0). Drug dosage and course of treatment are normalized.

[0081] For surgical treatment, information such as surgical name, surgical time, duration, and anesthesia method are encoded. For example, surgical types are uniquely encoded (assuming there are m surgical types in total), and surgical duration can be normalized.

[0082] For TCM rehabilitation treatment, information such as acupuncture points, needle retention time and frequency, and massage techniques and intensity are encoded into vector elements.

[0083] For psychotherapy, information such as the type, duration, frequency, and psychological assessment indicators (e.g., anxiety and depression scale scores) are coded.

[0084] Current health status assessment: A comprehensive health score (e.g., based on a doctor's assessment, represented by a score of 0-100, where 0 is the worst and 100 is the best) can be used as a dimension of the state vector.

[0085] S2. Determine the action space from the set of selectable treatment items in the first data, with each treatment item corresponding to a discrete action.

[0086] The action space is a set of selectable treatment strategies. The method provided by this invention covers various types of treatment programs, such as different exercise therapies in physical therapy (e.g., joint mobilization, muscle strength training), various rehabilitation training tasks in occupational therapy (e.g., fine motor skills training, activities of daily living training), and language rehabilitation training programs in speech therapy. It clearly defines the difficulty level of each training task and the specific operational steps for each task. Each treatment program has its specific parameters and implementation methods; for example, the intensity, frequency, and duration of movement in physical therapy, all of which constitute the specific action options in the action space.

[0087] S3. Preprocess the first collected data.

[0088] Specifically, for the aforementioned first set of data, uniform data preprocessing is required to ensure that data from different dimensions are of the same magnitude, avoiding excessive influence of certain dimensions on model training. Standardization or normalization methods can be used, with one-hot encoding or label encoding used for categorical data. Before standardization or normalization, the data should be cleaned to remove outliers and erroneous data; for missing data, mean imputation or deletion operations can be performed, or estimation imputation can be performed using data from similar patients.

[0089] S4. Select target features from the preprocessed first data and construct an input sequence that meets the input requirements of Transformer-Encoder based on the target features.

[0090] S5. Based on the Transformer Encoder part, build the model architecture, set the embedding method for each type of feature in the input sequence, configure the multi-head attention mechanism in each layer of the Transformer-Encoder, and realize the construction of the rehabilitation diagnosis and treatment model based on the Transformer-Encoder.

[0091] S6. Divide the preprocessed first data into training set, validation set and test set according to a certain ratio, define loss function and optimizer, train the rehabilitation diagnosis and treatment model, and obtain the current optimal model.

[0092] S7. Use the optimal model to predict and recommend treatment items on the test set, calculate performance indicators based on the reward function and Q-learning algorithm, and evaluate and validate the model.

[0093] Model evaluation and validation include clinical usability indicators, long-term efficacy tracking, multi-center validation, and real-world scenario validation (using virtual simulation technology to simulate the disease progression and treatment process of different patients, and to identify potential problems and shortcomings of the model by simulating various complex and extreme situations).

[0094] Specifically, based on the patient's current condition information, the optimal model initially selects a treatment strategy from the test set and implements it in the treatment area. For example, for a young patient with limited mobility due to a knee injury, the initial strategy might be to select some relatively gentle joint mobility training programs as the initial treatment strategy, based on their age and physical condition.

[0095] After implementing the initial treatment strategy, feedback data was collected from various sources, including:

[0096] Patient's immediate response: Changes in pain perception and comfort level during treatment. If the patient experiences excessive pain or discomfort during treatment, it may indicate that the treatment strategy needs adjustment.

[0097] Short-term treatment effect assessment: By measuring and comparing key indicators such as joint range of motion and muscle strength before and after treatment, the effectiveness of the treatment strategy in improving patients' symptoms and functions in the short term is evaluated.

[0098] Mid-term and long-term treatment efficacy assessment: Long-term follow-up of patients to assess the impact of treatment on indicators such as patients' quality of life, disease recurrence rate, and readmission rate.

[0099] Resource utilization: This includes the usage time of treatment equipment and the working hours of therapists. If a treatment program strategy leads to excessive resource consumption or waste, this will also affect its reward value.

[0100] The reward function R(s,a) is designed to take into account these feedback data and give a quantitative reward value to measure the quality of the selected treatment strategy.

[0101] The expression for the reward function is:

[0102] R(s,a)=α×E+β×C+γ×U+δ×L+ε×M) (1)

[0103] (1) In the formula, R is the reward value, which is used to evaluate the overall effect of the treatment plan recommended by the model.

[0104] E is a treatment efficacy evaluation indicator, which measures the degree to which the treatment plan improves the patient's condition.

[0105] C represents the evaluation of the patient's physical and psychological comfort.

[0106] U is a resource utilization efficiency indicator, which measures the efficiency of treatment plans in the use of medical resources (such as drugs, equipment, and medical staff time).

[0107] L represents long-term efficacy tracking indicators, such as disease recurrence rate and long-term health stability after recovery, reflecting the long-term effectiveness of the treatment plan.

[0108] M represents the model's performance metrics in multi-center validation and real-world scenario simulation, such as its universality score across different medical centers, and its accuracy and stability assessment results in simulating various complex and extreme disease progression and treatment processes.

[0109] α, β, γ, δ, and ε are weight coefficients;

[0110] By repeatedly going through the processes of strategy selection, implementation, feedback data collection, and reward calculation, reinforcement learning methods such as Q-learning are used to update the Q-value. The Q-value Q(s, α) represents the long-term expected reward of taking action α in state s. After multiple iterations, the Q-value for different actions α can be calculated for each state s. Finally, the optimal treatment strategy is recommended based on the comparison of Q-values; that is, for a given patient state s, the action α that maximizes Q(s, α) is selected as the optimal treatment strategy recommended to the patient.

[0111] The expression for the Q-learning algorithm is:

[0112]

[0113] (2) In the formula, Q(s) t α t ) is in state s t Take action α t The value of α is the learning rate, and r is the learning rate. t+1 Is taking action α t The immediate reward received afterward, where γ is the discount factor. It represents the greatest value among all possible actions taken in the next state.

[0114] S8. Optimize and adjust the model based on the evaluation results, especially by introducing mid-term and long-term treatment effect evaluations and adjusting the acceptability and compliance of treatment items to obtain the final rehabilitation treatment model.

[0115] S9 collects secondary data from other patients and preprocesses it, then inputs it into the final rehabilitation treatment model. It outputs the corresponding treatment prediction results and a list of recommended optimal treatment items for each patient, making personalized treatment decisions.

[0116] It provides clinicians with explanatory information on recommended treatment programs, such as which key patient characteristics the model bases its recommendations on (which can be uncovered by analyzing the weights of attention mechanisms, etc.), helping doctors better understand and refer to the model's recommendations, and combine them with their own professional knowledge and clinical experience to make final personalized treatment decisions, thereby improving the accuracy and efficiency of diagnosis and treatment.

[0117] In summary, this invention constructs a personalized patient diagnosis and treatment data model (i.e., a rehabilitation diagnosis and treatment model based on Transformer-Encoder) using the above methods. This model integrates multifaceted patient data, including but not limited to:

[0118] (1) Basic information: such as age, gender, height, weight, medical history, and genetic testing data. This information can provide a basis for initially assessing the patient's health status and potential risks. For example, certain high-intensity rehabilitation programs may need to be carefully selected for elderly patients or patients with a history of cardiovascular disease.

[0119] (2) Symptoms and Diagnostic Data: Detailed records of the patient's current symptoms, such as pain level, range of motion limitations, and type of motor dysfunction, as well as accurate diagnostic results obtained through various medical examinations (such as imaging and laboratory tests). For example, for fracture patients, diagnostic data will clearly identify the location, type, and severity of the fracture, thus providing crucial information for developing appropriate treatment plans.

[0120] (3) Treatment history data: This includes all treatment records the patient has received in the past, including treatment items, treatment duration, and treatment effect evaluation. If the patient has previously tried a certain physical therapy but with poor results, the recommendation of subsequent treatment items may consider avoiding the use of that item again or adjusting and optimizing it.

[0121] (4) Dynamic data updates and real-time performance: Patient data is continuously collected and updated to ensure its timeliness and effectiveness. For patients with chronic diseases, such as diabetes, blood glucose data is acquired in real time through a continuous glucose monitoring system (CGM) and fed back into the model in a timely manner to allow for timely adjustments to the treatment plan, such as adjusting insulin dosage or dietary plans. For patients with cardiovascular diseases, wearable devices are used to monitor heart rate, blood pressure, and blood oxygen saturation. Once abnormal data is detected, the model is immediately triggered to reassess and adjust the treatment plan to ensure the patient's health and safety.

[0122] (5) Interdisciplinary integration and analysis of data, while integrating basic medical research findings: Integrating patient data with epidemiological data to analyze the occurrence and development patterns of diseases at the population level. For example, for patients in a specific region, combining local epidemiological information to understand the incidence trends and influencing factors of common diseases in the region, such as the disease prevalence spectrum and the association between environmental pollutants and diseases, provides broader background information for personalized diagnosis and treatment of patients. Applying the latest research results in molecular biology, genetics, and cell biology to the analysis of patient data. For example, for cancer patients, combining the latest research on tumor driver genes and signaling pathways, and screening for possible targeted therapeutic targets based on the patient's gene data, provides a more precise basis for personalized treatment.

[0123] (6) Innovation in personalized treatment decision-making, integrating virtual treatment simulation technology: Utilizing artificial intelligence algorithms and clinical guidelines, a treatment decision support system is developed. This system not only considers traditional clinical indicators but also incorporates individual patient differences and preferences to recommend personalized treatment plans. Simultaneously, before implementing a treatment plan, virtual treatment simulations are used to assess the potential impact of different treatment options on the patient. For example, for patients undergoing joint replacement surgery, virtual surgical simulations can predict the surgical outcome and potential complications, allowing for proactive measures to improve surgical success rates and rehabilitation outcomes.

[0124] (7) Mid- to long-term rehabilitation effect assessment and follow-up: Through regular follow-up and re-examination, mid- to long-term rehabilitation information of patients is collected. For patients after rehabilitation treatment, such as those recovering from joint injuries, the long-term stability of joint function and the risk of re-injury are monitored for several months to several years after rehabilitation. For patients recovering from chronic diseases, such as diabetic patients, long-term monitoring of blood glucose control and the occurrence of complications is conducted to assess the long-term effect of the treatment plan. This information is then fed back into the model to further optimize the model and treatment plan.

[0125] Through in-depth analysis and mining of this data, key features and patterns related to patients' treatment needs and prognosis can be extracted. By continuously updating the Q-value and model parameters, the model can learn to select the optimal treatment items for patients in different states, thereby providing patients with personalized treatment plans.

[0126] Optionally, in step S3, the collected first data is preprocessed, specifically as follows:

[0127] S301. Perform data cleaning, noise reduction, data standardization / normalization, and data encoding on the collected first data.

[0128] Optionally, step S301 involves data cleaning, noise reduction, data standardization / normalization, and data encoding of the collected first data, including the following steps:

[0129] S3011. Check whether there are missing values, duplicate values ​​or erroneous values ​​in the collected first data. If there are missing values, fill them in; if there are duplicate values, remove duplicates; if there are erroneous values, correct or remove them.

[0130] Specifically, check the collected initial data for missing, duplicate, or erroneous values. For missing values, use appropriate imputation methods based on the characteristics and importance of the data, such as mean imputation (for numerical data, such as certain values ​​of laboratory indicators), mode imputation (for categorical data, such as gender), or imputation using predicted values ​​based on other relevant data. For duplicate values, perform deduplication. For obviously erroneous data (such as test values ​​that do not conform to common sense), correct or remove them based on professional knowledge and the logical relationships of the data.

[0131] S3012. Noise removal is performed on the text data in the first data to make the text more concise, clear and easy to understand.

[0132] Specifically, noise removal is performed on text data (such as symptom descriptions, diagnostic reports, etc.), such as removing irrelevant punctuation marks, special characters, and redundant expressions, to make the text more concise, clear, and easy to understand.

[0133] S3013. For numerical data of different magnitudes in the first dataset, use standardization or normalization methods to transform them to the same scale range to facilitate subsequent model training and computation.

[0134] Specifically, for numerical data of different magnitudes, such as the values ​​of various examination indicators and age, standardization or normalization methods are used to transform them to the same scale range to facilitate subsequent model training and computation. A commonly used standardization method is Z-score standardization, with the formula: (Where z is the standardized value, x is the original value, μ is the mean of the data, and σ is the standard deviation of the data); the normalization method can be min-max normalization, as shown in the formula: (where x) max x min and are the maximum and minimum values ​​in the data, respectively.

[0135] S3014. For the categorical data in the first data, use an encoding method to convert it into a numerical form that can be recognized and processed by a computer.

[0136] Specifically, for categorical data (such as gender, past medical history category, etc.), one-hot encoding or other suitable encoding methods are used to convert them into a numerical form that computers can recognize and process. For example, for the categorical variable of gender (male, female), one-hot encoding can represent it as [1,0] (representing male) and [0,1] (representing female).

[0137] Optionally, the target features in step S4 shall include at least features related to diagnosis and treatment prediction and treatment items. The target features shall be constructed into an input sequence that meets the input requirements of Transformer-Encoder, specifically by arranging them in the order of the patient's basic information, current symptoms, examination results, and past treatments, and concatenating the feature vectors corresponding to each part in sequence to form a complete input sequence with a temporal or logical order.

[0138] From the preprocessed patient data (i.e., the first set of data), features closely related to diagnosis and treatment prediction and recommendations are selected. For example, age, key test results, and current major symptom feature vectors are combined to form a comprehensive input feature vector. Valuable features can be selected using domain knowledge and feature importance analysis methods (such as feature importance assessment based on decision trees and correlation analysis).

[0139] The selected features are constructed into an input sequence according to a certain logical order, so that it meets the input requirements of the Transformer-Encoder. For example, the patient's basic information, current symptoms, examination results, and past treatment can be arranged in the order of patient basic information, current symptoms, examination results, and past treatment. The feature vectors corresponding to each part can be concatenated in sequence to form a complete input sequence with a time or logical order, so that the model can easily capture the correlation and dependency between different features.

[0140] Optionally, in step S5, the model architecture is built based on the Transformer Encoder part, the embedding method is set for each type of feature in the input sequence, and a multi-head attention mechanism is configured in each layer of the Transformer-Encoder to realize the construction of a rehabilitation diagnosis and treatment model based on the Transformer-Encoder, including the following steps:

[0141] S501. Based on the Encoder part of Transformer, build the core model architecture, determine the number of layers of the model, the number of hidden units in each layer, and the number of heads in the multi-head attention mechanism, and make reasonable adjustments according to specific computing resources and task complexity.

[0142] In step S501, the core model architecture is built based on the Encoder part of the Transformer, and hyperparameters such as the number of model layers, the number of hidden units in each layer, and the number of heads in the multi-head attention mechanism are determined. For example, the model is set to contain N Encoder layers, the number of hidden units in each layer is d_model, and the number of heads in the multi-head attention mechanism is h, which are then adjusted reasonably according to specific computing resources and task complexity.

[0143] S502. Set appropriate embedding methods for each type of feature in the input sequence, and transform discrete feature values ​​or classification codes into low-dimensional continuous vector representations so that they can be better learned and processed by the model.

[0144] Specifically, appropriate embedding methods are set for each type of feature in the input sequence, transforming discrete feature values ​​or classification codes into low-dimensional continuous vector representations, enabling them to be better learned and processed by the model. For example, for symptom description text features, word embedding techniques (such as fine-tuning pre-trained word embedding models like Word2Vec and BERT, or training word embeddings from scratch) can be used to map words in the text to a vector space; for numerical features, simple linear embeddings can be used, or specific embedding mapping functions can be designed based on their distribution characteristics.

[0145] S503. In each layer of the Transformer-Encoder, a multi-head attention mechanism is configured appropriately to enable it to focus on different parts of the input sequence, capture the long-term and short-term dependencies between features, and optimize its ability to extract information from the input sequence by adjusting the relevant parameters of the attention mechanism. This ensures that the model can extract key diagnosis and treatment related information from complex patient data. The relevant parameters include the weight initialization of the attention head and the scaling factor.

[0146] Optionally, in step S6, the preprocessed first data is divided into a training set, a validation set, and a test set according to a certain ratio. A loss function and an optimizer are defined to train the rehabilitation diagnosis and treatment model and obtain the current optimal model. This includes the following steps:

[0147] S601. Divide the preprocessed first data into training set, validation set and test set according to the ratio of 8:1:1 or 7:2:1 to ensure the randomness of the partitioning process and the consistency of data distribution, so that each set can reasonably reflect the characteristics of the overall data and be used for model training, parameter adjustment and performance evaluation.

[0148] In this step, the dataset can also be divided into training set, validation set, and test set according to other commonly used proportions.

[0149] S602. Based on the nature of the diagnosis and treatment prediction and treatment item recommendation tasks, select the loss function and optimizer to update the model parameters, set the optimizer parameters, and make appropriate adjustments according to the training situation.

[0150] Specifically, an appropriate loss function should be selected based on the nature of the diagnosis and treatment prediction and recommendation tasks. For example, for multi-class treatment recommendation tasks, the cross-entropy loss function can be used; for predicting continuous treatment effect indicators (such as numerical values ​​of symptom relief), the mean squared error loss function can be chosen. Simultaneously, a suitable optimizer (such as Adam or Adagrad) should be selected to update the model parameters, setting parameters such as the optimizer's learning rate and weight decay, and making appropriate adjustments based on the training progress.

[0151] S603. The training set is input into the Transformer-Encoder-based rehabilitation diagnosis and treatment model for multiple iterations of training. In each iteration, the model output is calculated through forward propagation, the loss value is calculated according to the defined loss function, and then the optimizer is used for backpropagation to update the various parameters of the model, so as to gradually reduce the loss value and improve the model's ability to predict the patient's diagnosis and treatment situation and the accuracy of treatment program recommendations. During the training process, the Transformer-Encoder-based rehabilitation diagnosis and treatment model is evaluated periodically using the validation set. The changes in the model's performance indicators (such as accuracy, recall, F1 score, etc., depending on the specific task) on the validation set are monitored to prevent overfitting. When the performance on the validation set no longer improves or shows a downward trend, training is stopped and the current optimal model is saved.

[0152] Optionally, in step S602, a loss function is selected based on the nature of the diagnosis and treatment prediction and treatment item recommendation task, specifically as follows:

[0153] Based on the multi-class treatment item recommendation task, the cross-entropy loss function is used. The formula for the cross-entropy loss function is as follows:

[0154]

[0155] (3) In the formula, y i It's a real label. is the predicted value, and N is the sample size.

[0156] Based on the predicted continuous treatment outcome indicators, the mean squared error loss function is selected.

[0157] Optionally, in step S7, the optimal model is used to predict and recommend treatment items for the test set, calculate performance indicators and evaluate the model, and optimize and adjust the model based on the evaluation results to obtain the final rehabilitation treatment model, including the following steps:

[0158] S701. Use the optimal model to predict diagnosis and treatment and recommend treatment items on the test set, and calculate the corresponding performance indicators. The performance indicators include the accuracy of predicting diagnosis and treatment results, the matching degree between predicted treatment items and the actual best treatment items, the judgment of clinical experts or reference to clinical guidelines, and comprehensively evaluate the model's generalization ability and practical application effect on unseen data.

[0159] The optimal model saved in step S603 is used to predict and recommend treatment items on the test set data. The corresponding performance indicators are calculated, such as the accuracy of predicting treatment results and the matching degree between the predicted treatment items and the actual best treatment items (the accuracy of the recommendation can be measured by indicators such as accuracy, recall, and F1 score). The model's generalization ability and practical application effect on unseen data are comprehensively evaluated.

[0160] S702. Based on the evaluation results of the test set, analyze the shortcomings of the model and take optimization measures, including increasing the amount of training data, adjusting the model's hyperparameters, improving the selection and combination of input features, and trying different embedding methods or attention mechanism variants. Then, retrain and evaluate the model to continuously optimize its performance until the final rehabilitation diagnosis and treatment model is obtained.

[0161] Specifically, based on the evaluation results of the test set, analyze the shortcomings of the model, such as whether it over-relies on certain features or has inaccurate predictions for specific types of patients. To address these issues, various optimization measures can be taken, such as increasing the amount of training data (especially data for patient types that perform poorly), adjusting the model's hyperparameters (e.g., increasing the number of model layers, changing the number of hidden units), improving the selection and combination of input features, and trying different embedding methods or attention mechanism variants. Then, retrain and evaluate the model, continuously optimizing its performance until satisfactory results are achieved.

[0162] Optionally, the formula for calculating the self-attention mechanism in the Transformer-Encoder-based rehabilitation diagnosis and treatment model is as follows:

[0163]

[0164] Where Q, K, and V are the query vector, key vector, and value vector, respectively, and d k It is the dimension of the key vector.

[0165] Optionally, in step S2, the action space treats various treatment items as discrete actions, numbered as follows:

[0166] Different exercise therapies, physical therapies, and equipment used in physical therapy correspond to different action numbers;

[0167] In drug therapy, each drug can correspond to an action number, and different dosages, routes of administration, and courses of treatment can serve as different parameters for that action;

[0168] In surgical treatment, each type of surgical procedure corresponds to an action number;

[0169] In traditional Chinese medicine rehabilitation therapy, acupuncture, moxibustion, and massage each correspond to an action number.

[0170] Different types of psychotherapy correspond to different action numbers.

[0171] Example 1

[0172] A patient presented with pain in their left knee. The above method was used to recommend a personalized treatment plan, which included the following steps:

[0173] I. Patient Information Collection

[0174] Basic information:

[0175] Mr. Li, male, 50 years old, 175cm tall, weighing 85kg, with a BMI of 28.1, is overweight. He has a history of hypertension, his father has heart disease, and genetic testing shows several gene mutations related to cardiovascular disease, such as a positive APOE ε4 allele, suggesting a potentially high risk of cardiovascular disease. Furthermore, Mr. Li is in middle age, and age-related physiological changes, such as a gradual decline in muscle strength and a slowing metabolism, will also influence treatment decisions.

[0176] Symptoms and diagnostic data:

[0177] Mr. Li recently experienced pain and limited range of motion in his left knee. The pain worsened during exercise, scoring 7 out of 10, and improved to 3 after rest. His knee's range of motion was limited, with flexion and extension angles of [30°, 90°], while a normal knee's range of motion is typically around [0°, 135°]. An MRI revealed a mild tear in the meniscus, accompanied by a small amount of effusion, and signs of cartilage wear.

[0178] In addition, Mr. Li occasionally experienced heart palpitations, especially after prolonged walking or climbing stairs. Further electrocardiogram (ECG) examination revealed mild myocardial ischemia, which may be associated with his hypertension and underlying cardiovascular disease risk. Dynamic data on symptom changes showed that his knee pain and limited mobility gradually worsened over the past three months, while his heart palpitations became more frequent over the past six months.

[0179] Treatment history data:

[0180] He had previously received some treatment. He tried physical therapy, including applying heat to his knee and simple muscle stretching exercises three times a week for two months, but the knee pain and limited mobility only slightly improved. Regarding medication, he had been taking amlodipine to control his blood pressure at around 140 / 90 mmHg, but it was still not within the ideal range (<130 / 80 mmHg). During treatment, Mr. Li experienced mild headaches and ankle swelling, which are common side effects of amlodipine.

[0181] II. Model Application and Analysis

[0182] 1. Data preprocessing and model input:

[0183] The information provided by Mr. Li was collected, organized, and preprocessed. For example, basic information such as age, gender, BMI, and gene mutation information was encoded and normalized; symptom and diagnostic data such as knee pain score, range of motion, and MRI results were converted into feature vectors; and the type, frequency, effectiveness, and adverse reactions of past treatments were also encoded. This data was then integrated into an input sequence that met the requirements of the Transformer-Encoder.

[0184] 2. Model training and prediction:

[0185] After receiving Mr. Li's data, the Transformer-Encoder-based rehabilitation model analyzed it in conjunction with a large amount of data from similar patients in the training set. During training, the model considered the relationships between different patient characteristics and treatment programs, capturing the correlations between various pieces of information through a multi-head attention mechanism. For example, for patients like Mr. Li who are overweight, have a history of cardiovascular disease, and knee problems, the model comprehensively considers the potential links between knee injury and weight, cardiovascular disease, as well as the effects and adverse reactions of past treatments.

[0186] The action space includes various treatment options, such as continued physical therapy (adjusting exercise methods and intensity), drug therapy (adjusting antihypertensive medication or adding other drugs), surgical treatment (such as knee arthroscopy), and traditional Chinese medicine rehabilitation therapy (such as acupuncture and external application of Chinese herbal medicine). The model makes predictions based on the knowledge gained from training and Mr. Li's data.

[0187] 3. Personalized treatment recommendations and adjustments:

[0188] A. Recommended Treatment Programs:

[0189] Given Mr. Li's overweight condition, the model might recommend incorporating weight management as a crucial part of his rehabilitation, including developing a personalized diet and exercise plan. Based on Mr. Li's knee injury, physical therapy programs, such as aquatic rehabilitation exercises, might be recommended, as the buoyancy of water can reduce stress on the knee joint. This could be combined with joint mobilization and balance training to improve knee function. For his blood pressure medication, the treatment might be adjusted to an ACE inhibitor (such as enalapril), as this type of medication may be more suitable for his condition and reduce the side effect of ankle edema.

[0190] B. Long-term effect evaluation:

[0191] The model predicts Mr. Li's potential outcomes after undergoing the aforementioned treatment by tracking and analyzing the long-term effects on similar patients. For example, it predicts that if Mr. Li follows the recommended treatment plan, his knee pain may be relieved to below 3 points within 3 months, his knee range of motion may recover to approximately [0°, 120°] within 6 months, and his blood pressure is expected to be controlled below 130 / 80 mmHg.

[0192] C. Treatment adjustments and optimizations:

[0193] Taking into account Mr. Li's genetic information and history of hypertension, the model will continuously monitor data during treatment, such as changes in blood pressure and knee joint function. If blood pressure is poorly controlled or knee pain is not effectively improved, the treatment program will be adjusted promptly based on Mr. Li's symptoms and treatment response. For example, if knee pain continues to worsen, arthroscopic surgery may be considered to repair meniscus damage. The impact of the surgery on the cardiovascular system will be closely monitored, as the surgery may cause certain cardiovascular stress responses.

[0194] III. Continuous Evaluation and Optimization

[0195] Throughout Mr. Li's treatment, real-time feedback was continuously collected, including data on pain perception, blood pressure changes, and knee range of motion. Based on this feedback, the model reassessed the effectiveness of the treatment program and made adjustments using a reward function (which comprehensively considers treatment efficacy, patient comfort, resource utilization efficiency, long-term effects, and multi-center validation) and a Q-learning algorithm. For example, if Mr. Li felt comfortable during aquatic exercise rehabilitation training and his knee function improved, the model would continue to recommend the treatment program and might appropriately increase the training intensity based on his recovery. If Mr. Li experienced adverse reactions such as coughing after changing his antihypertensive medication (a common adverse reaction to ACEI drugs), the model would consider adjusting the medication or dosage to achieve the best treatment effect.

[0196] The above description is merely the preferred embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions within the technical scope disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. A method for constructing a personalized rehabilitation treatment model for patients, characterized in that, Includes the following steps: Collect first data about the patient, including the patient's clinical data, lifestyle data, environmental factors data, and genetic data; The set of available treatment options defines the action space, with each treatment option corresponding to a discrete action. The first collected data is preprocessed; Target features are selected from the preprocessed first data, and the target features are used to construct an input sequence that meets the input requirements of Transformer-Encoder; The model architecture is built based on the Transformer Encoder part, and the embedding method is set for each type of feature in the input sequence. A multi-head attention mechanism is configured in each layer of the Transformer-Encoder to realize the construction of a rehabilitation diagnosis and treatment model based on Transformer-Encoder. The preprocessed first data is divided into a training set, a validation set, and a test set according to a certain ratio. A loss function and an optimizer are defined to train the rehabilitation diagnosis and treatment model and obtain the current optimal model. The optimal model is used to predict and recommend treatment items on the test set. Performance indicators are calculated based on the reward function and Q-learning algorithm, and the model is evaluated and validated. The model evaluation and validation includes clinical usability indicators, long-term effect tracking, multi-center validation, and validation in simulated real-world scenarios. Based on the evaluation results, the model is optimized and adjusted to obtain the final rehabilitation treatment model. The expression for the reward function is: R(s,a)=α×E+β×C+γ×U+δ×L+ε×M) where R(s,a) is used to measure the reward brought about by taking therapeutic action a when the patient is in state s; R is the reward value, used to evaluate the overall effectiveness of the treatment plan recommended by the model; E is a treatment efficacy evaluation indicator, which measures the degree to which the treatment plan improves the patient's condition; C represents the evaluation of the patient's physical and psychological comfort. U is a resource utilization efficiency indicator, which considers the efficiency of treatment plans in the use of medical resources; L represents the long-term effect tracking indicator; M represents the model's performance metrics in multi-center validation and real-world scenario validation. α, β, γ, δ, and ε are weighting coefficients used to adjust the relative importance of each indicator in the reward function; The expression for the Q-learning algorithm is: Where Q(s) t α t ) is in state s t Take action α t The value of α is the learning rate, and r is the learning rate. t+1 Is taking action α t The immediate reward received afterward, where γ is the discount factor. It represents the maximum value among all possible actions taken in the next state. Secondary data from other patients are collected and preprocessed, then input into the final rehabilitation model, which outputs the corresponding patient's treatment prediction results and a list of recommended optimal treatment items.

2. The method for constructing a personalized rehabilitation treatment model for patients according to claim 1, characterized in that, The preprocessing of the collected first data specifically includes: The collected first data is subjected to data cleaning, noise reduction, data standardization / normalization, and data encoding.

3. The method for constructing a personalized rehabilitation treatment model for patients according to claim 2, wherein the step of performing data cleaning, noise reduction, data standardization / normalization, and data encoding on the collected first data includes the following steps: Check whether there are missing values, duplicate values, or erroneous values ​​in the first data collected. If there are missing values, fill them in; if there are duplicate values, remove duplicates; if there are erroneous values, correct or remove them. Noise removal is performed on the text data in the first data set to make the text more concise, clear, and easier to understand. For numerical data of different magnitudes in the first data, standardization or normalization methods are used to transform them to the same scale range to facilitate subsequent model training and computation. For the categorical data in the first data, an encoding method is used to convert it into a numerical form that a computer can recognize and process.

4. The method for constructing a personalized rehabilitation treatment model for patients according to claim 1, characterized in that: The target features include at least those related to diagnosis and treatment prediction and treatment programs; The target features are constructed into an input sequence that meets the input requirements of Transformer-Encoder. Specifically, the features are arranged in the order of the patient's basic information, current symptoms, examination results, and past treatments. The feature vectors corresponding to each part are then concatenated to form a complete input sequence with a temporal or logical order.

5. The method for constructing a personalized rehabilitation treatment model for patients according to claim 1, characterized in that, The Transformer-based Encoder part builds the model architecture, sets embedding methods for various features in the input sequence, and configures a multi-head attention mechanism in each layer of the Transformer-Encoder to realize the construction of a rehabilitation diagnosis and treatment model based on Transformer-Encoder, including the following steps: The core model architecture is built based on the Encoder part of Transformer. The number of layers in the model, the number of hidden units in each layer, and the number of heads in the multi-head attention mechanism are determined and adjusted reasonably according to specific computing resources and task complexity. Set appropriate embedding methods for each type of feature in the input sequence, and transform discrete feature values ​​or classification codes into low-dimensional continuous vector representations so that they can be better learned and processed by the model; In each layer of the Transformer-Encoder, a multi-head attention mechanism is configured appropriately to enable it to focus on different parts of the input sequence, capture the long-term and short-term dependencies between features, and optimize its ability to extract information from the input sequence by adjusting the relevant parameters of the attention mechanism. This ensures that the model can extract key diagnosis and treatment related information from complex patient data. The relevant parameters include the weight initialization of the attention head and the scaling factor.

6. The method for constructing a personalized rehabilitation treatment model for patients according to claim 1, characterized in that, The process of dividing the preprocessed first data into a training set, a validation set, and a test set according to a certain ratio, defining a loss function and an optimizer, and training the rehabilitation diagnosis and treatment model to obtain the current optimal model includes the following steps: The preprocessed first data is divided into training set, validation set and test set in a ratio of 8:1:1 or 7:2:1 to ensure the randomness of the partitioning process and the consistency of data distribution, so that each set can reasonably reflect the characteristics of the overall data for model training, parameter adjustment and performance evaluation. Based on the nature of the diagnosis and treatment prediction and treatment item recommendation tasks, select the loss function and optimizer to update the model parameters, set the optimizer parameters, and make appropriate adjustments according to the training situation; The training set is used as input to train the Transformer-Encoder-based rehabilitation model iteratively multiple times. In each iteration, the model output is calculated through forward propagation, the loss value is calculated according to the defined loss function, and then the optimizer is used for backpropagation to update the model's parameters, thereby gradually reducing the loss value and improving the model's ability to predict patient conditions and the accuracy of treatment recommendations. During training, the Transformer-Encoder-based rehabilitation model is periodically evaluated using a validation set to monitor changes in the model's performance metrics on the validation set, preventing overfitting. When the validation set performance no longer improves or shows a downward trend, training is stopped, and the current optimal model is saved.

7. The method for constructing a personalized rehabilitation treatment model for patients according to claim 6, characterized in that, The loss function is selected based on the nature of the diagnosis and treatment prediction and treatment item recommendation tasks, specifically as follows: Based on the multi-class treatment item recommendation task, the cross-entropy loss function is used, and the formula for the cross-entropy loss function is as follows: Among them, y i It's a real label. These are the predicted values, and N is the number of samples. Based on the predicted continuous treatment outcome indicators, the mean squared error loss function is selected.

8. The method for constructing a personalized rehabilitation treatment model for patients according to claim 1, characterized in that, The process of using the optimal model to predict and recommend treatment items on the test set, calculating performance indicators and evaluating the model, and optimizing and adjusting the model based on the evaluation results to obtain the final rehabilitation treatment model includes the following steps: The optimal model is used to predict diagnosis and treatment and recommend treatment items on the test set. The corresponding performance indicators are calculated. The performance indicators include the accuracy of predicting diagnosis and treatment results, the matching degree between predicted treatment items and the actual best treatment items, the judgment of clinical experts or reference to clinical guidelines, and a comprehensive evaluation of the model's generalization ability and practical application effect on unseen data. Based on the evaluation results of the test set, the shortcomings of the model are analyzed, and optimization measures are taken, including increasing the amount of training data, adjusting the model's hyperparameters, improving the selection and combination of input features, and trying different embedding methods or attention mechanism variants. Then, the model is retrained and evaluated to continuously optimize its performance until the final rehabilitation diagnosis and treatment model is obtained.

9. The method for constructing a personalized rehabilitation treatment model for patients according to any one of claims 1-8, characterized in that: The formula for calculating the self-attention mechanism in the Transformer-Encoder-based rehabilitation model is as follows: Where Q, K, and V are the query vector, key vector, and value vector, respectively, and d k It is the dimension of the key vector.

10. The method for constructing a personalized rehabilitation treatment model for patients according to claim 9, characterized in that: The action space treats various treatment items as discrete actions, numbered as follows: Different exercise therapies, physical therapies, and equipment used in physical therapy correspond to different action numbers; In drug therapy, each drug can correspond to an action number, and different dosages, routes of administration, and courses of treatment can serve as different parameters for that action; In surgical treatment, each type of surgical procedure corresponds to an action number; In traditional Chinese medicine rehabilitation therapy, acupuncture, moxibustion, and massage each correspond to an action number. Different types of psychotherapy correspond to different action numbers.