Cholangiocarcinoma prediction method and system based on iterative self-consistency and large model calibration
By employing iterative self-consistency and large model validation methods, we generate biliary tract cancer prediction results that incorporate medical logic, thus addressing the lack of interpretability in existing models and improving the accuracy and reliability of predictions.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- THE AFFILIATED HOSPITAL OF QINGDAO UNIV
- Filing Date
- 2026-03-20
- Publication Date
- 2026-05-29
AI Technical Summary
Existing biliary tract cancer prediction models fail to provide medical logic and reasoning, resulting in a lack of interpretability in the prediction results, making them difficult for clinicians to accept and adopt.
The method employs iterative self-consistency and large model validation. By constructing a structured prompt word sequence, an independent set of reasoning paths is generated. A majority voting mechanism is used to select positive samples, and a large language model is introduced to verify the logical rationality. Through multiple rounds of iterative optimization by optimizing the comparative loss function, a thought chain reasoning result containing medical logic is generated.
It improves the diagnostic accuracy and reliability of biliary tract cancer prediction, provides interpretable medical logic support, and enhances clinicians' confidence.
Smart Images

Figure CN122117335A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of artificial intelligence technology, and in particular to a method and system for predicting biliary tract cancer based on iterative self-consistency and large model validation. Background Technology
[0002] Gallbladder cancer and hilar cholangiocarcinoma, among other malignant tumors of the biliary system, are digestive tract tumors with extremely poor clinical prognosis. Due to their deep anatomical location, insidious onset, and complex anatomical structure, they are easily confused with benign diseases such as bile duct stones and sclerosing cholangitis, leading to difficulties in early diagnosis and a very high misdiagnosis rate. With the continuous development of medical and health information technology, hospitals' electronic medical record systems have accumulated massive amounts of longitudinal patient diagnosis and treatment data, including complex diagnostic descriptions, lifestyle habits, and specific laboratory test indicators. In existing auxiliary diagnostic technology systems, recurrent neural networks and long short-term memory network architectures are commonly used for modeling. The working principle of these methods is to map the patient's biochemical test indicators at different time points into a high-dimensional feature vector sequence, and use the internal recurrent structure and gating mechanism of the model to update the hidden layer state to capture the dynamic evolution of clinical indicators over time. The model finally inputs the extracted temporal features into a fully connected layer and outputs a probability score of the patient's liver cancer through classification or regression algorithms. The above-mentioned existing technologies have two insurmountable defects in practical clinical applications.
[0003] The model can only output a probability value, but cannot provide the medical logic and thought process that leads to the result. Due to the lack of specific reasoning data and evidence, doctors find it difficult to understand which clinical features the model is based on to make the judgment. As a result, the prediction results lack interpretability in serious medical decision-making and are difficult for clinicians to believe and adopt. Current cutting-edge technologies often attempt to introduce reinforcement learning algorithms to optimize large models, but the methods are difficult to train models with true expert-level thinking ability due to the lack of sufficient high-quality training data.
[0004] To address the aforementioned technical shortcomings, a solution is proposed. Summary of the Invention
[0005] This invention employs the following technical solution: a method for predicting biliary tract cancer based on iterative self-consistency and large model validation, characterized by comprising the following steps:
[0006] The electronic medical record text data of the patient to be predicted is obtained, and a longitudinal clinical text sequence containing timestamp information is constructed. The longitudinal clinical text sequence is concatenated with the patient's static features to construct a structured prompt word sequence that conforms to the input of a large language model. The prompt word sequence also contains task instructions.
[0007] The prompt word sequence is input into the current base large language model. A random decoding strategy is adopted, the sampling temperature is set, and an independent set of inference paths is generated in parallel. Each inference path contains intermediate inference steps and the final diagnostic conclusion.
[0008] The frequency of diagnostic conclusions in all reasoning paths is counted. A majority voting mechanism is used to select the reasoning path with the highest frequency of diagnosis and high confidence as a positive sample, and the path with inconsistent diagnostic conclusions is selected as a negative sample to construct candidate data pairs.
[0009] A validation large language model is introduced to verify the medical logic rationality of positive samples. If the validation passes, the positive samples are included in the training set for this round of fine-tuning. The current base large language model is then fine-tuned under supervision. By optimizing the contrastive loss function, the updated base large language model is obtained. Multiple rounds of iterative optimization are performed until the preset convergence condition is met, and the final base large language model is obtained.
[0010] The electronic medical record data of new patients to be diagnosed is constructed into a structured cue word sequence, which is then input into the final base large language model. A greedy decoding strategy is adopted to generate the optimal reasoning path and diagnostic conclusion, and output the thought chain reasoning result containing medical logic.
[0011] Furthermore, a longitudinal clinical text sequence containing timestamp information is constructed. This sequence is then concatenated with the patient's static features to create a structured cue word sequence that conforms to the input of a large language model. The cue word sequence also contains task instructions. The specific construction process is as follows:
[0012] Extract patients' static characteristics from electronic medical records and perform structured language conversion, including characteristics that do not change over time and are stable over a long period of time, such as gender, age, smoking history, and drinking history.
[0013] Extracting the patient's medical records from the electronic medical records, sorting all events by the date of visit from earliest to latest, and forming the patient's longitudinal clinical time series;
[0014] The longitudinal events are converted into a coherent sequence of clinical text. Based on the input specifications of the large language model, a structured prompt word template is designed, including a system role layer, a patient temporal information layer, and a task instruction layer. These are then spliced and combined to form a complete structured prompt word sequence.
[0015] Furthermore, the prompt word sequence is input into the current base large language model, a random decoding strategy is adopted, the sampling temperature is set, and independent inference path sets are generated in parallel. Each inference path includes intermediate inference steps and the final diagnostic conclusion. The specific process is as follows:
[0016] Load the base large language model for the current iteration, set random decoding parameters, enable random sampling strategy, and set sampling temperature parameters;
[0017] The structured prompt word sequence is input into the base large language model of the current iteration in parallel. Under the random sampling mechanism, K different output sequences are generated independently, and the joint log probability of each sequence is recorded as the basis for confidence.
[0018] Each generated text sequence is parsed, and intermediate reasoning steps and final diagnostic conclusions are separated according to a preset format. The K paths and probability information are organized into a set of structured reasoning paths.
[0019] Furthermore, a majority voting mechanism is employed to select the reasoning path with the highest frequency and confidence as the positive sample, and to select paths from the set of inconsistent diagnostic conclusions as the negative sample, thus constructing candidate data pairs. The specific process is as follows:
[0020] The frequency of the final diagnosis conclusion in all reasoning paths is counted, and the conclusion with the highest frequency is selected as the majority conclusion. From all paths that output the majority conclusion, the reasoning path with the highest generation probability is selected as the positive sample candidate.
[0021] From the remaining paths, all paths whose final diagnostic conclusions are inconsistent with the majority conclusions are selected to form a set of opposing conclusion paths. From this set, one reasoning path is randomly selected as a negative sample.
[0022] The original structured cue word sequence, positive samples, and negative samples are combined to form candidate data pairs in the form of triplets.
[0023] Furthermore, a validation large language model is introduced to verify the medical logic rationality of positive samples. If the validation passes, the positive samples are included in the training set for this round of fine-tuning. The specific process is as follows:
[0024] Another general-purpose large language model for validation will be introduced. As a validator, it verifies the selected positive samples. The medical logic rationality verification is performed, and the verification process is as follows: enter Determine whether the reasoning chain conforms to medical standards, identify logical contradictions in the diagnostic conclusion, and verify the function. Defined as:
[0025]
[0026] Only when At that time, the corresponding prompt word sequence, positive sample, and negative sample are combined into a triplet and included in the training set for this round of fine-tuning. Conversely, if the result is invalid, it will be considered invalid and discarded.
[0027] Furthermore, supervised fine-tuning is performed on the current base-based large language model. By optimizing the contrastive loss function, an updated base-based large language model is obtained. The specific process is as follows:
[0028] Using the constructed training set The base large language model for the current iteration round Supervised fine-tuning was performed to obtain the next-generation base-based large language model. To maximize the generation of logically correct positive samples in medical practice using a large base language model. The probability of generating logically flawed negative samples is minimized. The probability is used to optimize the base language model (specifically, direct preference optimization) loss function is as follows:
[0029]
[0030] in, This represents a fine-tuned training set containing cue word sequences and positive / negative inference sample pairs. This represents the calculation of the expected value of the sample distribution within the training set. This indicates the function used for nonlinear mapping. The hyperparameter representing the strength of the bias control in the adjustment model is... This represents the current iteration round of the base large language model. Generate positive samples The strategy probability, Represents the model in the current iteration round. Generate negative samples The strategy probability, This indicates that the reference model generated positive samples in the previous round. The baseline probability, This indicates that the previous reference model generated negative samples. The baseline probability.
[0031] Furthermore, multiple rounds of iterative optimization are performed until the preset convergence condition is met, resulting in the final base large language model. The specific iterative optimization process is as follows:
[0032] The contrastive loss function is applied to the parameter update process of the base large language model. The specific training implementation process is as follows:
[0033] In the In each iteration, based on the current base large language model parameters Perform forward propagation to obtain the predicted probabilities of positive and negative samples, and calculate the loss function with respect to the parameters. The gradient is calculated using an optimizer that updates the parameters according to the formula. Fine-tuning the model yields the next-generation foundational large language model. After completing one round of parameter updates, As a new foundational large language model, the update steps are re-executed, and the iterative process continues until the preset convergence condition is met.
[0034] Furthermore, the optimal reasoning path and diagnostic conclusion are generated, and the reasoning results containing medical logic are output. The specific process is as follows:
[0035] Using the final base language model trained through multiple rounds of iterative self-evolution, when making clinical diagnostic inferences for new patients, the electronic medical record data of the patients to be diagnosed is constructed into a structured prompt word sequence, which is then input into the final base language model with fixed parameters. A greedy decoding strategy is adopted to find the sequence with the highest generation probability as the output, which is the process of finding the optimal inference path and maximizing the joint probability of the diagnostic conclusion.
[0036] A biliary tract cancer prediction system based on iterative self-consistency and large model validation includes the following modules:
[0037] The data acquisition module acquires the electronic medical record text data of the patients to be predicted, constructs a longitudinal clinical text sequence containing timestamp information, concatenates the longitudinal clinical text sequence with the static features of the patients, and constructs a structured prompt word sequence that conforms to the input of the large language model. The prompt word sequence also contains task instructions.
[0038] The sample generation module inputs the prompt word sequence into the current base large language model, adopts a random decoding strategy, sets the sampling temperature, and generates an independent set of inference paths in parallel. Each inference path contains intermediate inference steps and the final diagnostic conclusion.
[0039] The sample screening module counts the frequency of diagnostic conclusions in all reasoning paths, uses a majority voting mechanism to select the reasoning path with the highest frequency of conclusions and high confidence as a positive sample, and selects paths from the set of paths with inconsistent diagnostic conclusions as negative samples to construct candidate data pairs.
[0040] The logic verification module introduces a large language model to verify the medical logic rationality of positive samples. If the verification passes, the positive samples are included in the training set for this round of fine-tuning. The current base large language model is then fine-tuned under supervision. By optimizing the contrast loss function, the updated base large language model is obtained. Multiple rounds of iterative optimization are performed until the preset convergence condition is met, and the final base large language model is obtained.
[0041] The reasoning application module constructs a structured prompt word sequence from the electronic medical record data of new patients to be diagnosed, inputs it into the final base large language model, adopts a greedy decoding strategy to generate the optimal reasoning path and diagnostic conclusion, and outputs the thought chain reasoning result containing medical logic.
[0042] In summary, due to the adoption of the above technical solution, the beneficial effects of the present invention are:
[0043] This method and system for predicting biliary tract cancer based on iterative self-consistency and large model validation generates an independent set of reasoning paths by inputting a sequence of prompt words into a current base large language model. Each reasoning path includes intermediate reasoning steps and a final diagnostic conclusion. The frequency of the diagnostic conclusions in all reasoning paths is statistically analyzed. A majority voting mechanism is used to select the reasoning path with the highest frequency and confidence as a positive sample. Paths with inconsistent diagnostic conclusions are selected as negative samples to construct candidate data pairs. A validation large language model is then introduced to verify the medical logical rationality of the positive samples through a dual mechanism. To ensure diagnostic quality and improve the accuracy and reliability of diagnostic reasoning, if the verification passes, positive samples are included in the training set for this round of fine-tuning. The current base language model is then fine-tuned under supervision. By optimizing the contrastive loss function, an updated base language model is obtained. Multiple rounds of iterative optimization are performed until the preset convergence condition is met, thus achieving continuous iterative optimization of the diagnostic logic. The electronic medical record data of new patients to be diagnosed is constructed into a structured prompt word sequence and input into the final base language model. A greedy decoding strategy is adopted to generate the optimal reasoning path and diagnostic conclusion, and output the thought chain reasoning result containing medical logic. Attached Figure Description
[0044] Figure 1 A schematic diagram of the method flow structure of the present invention is shown;
[0045] Figure 2 A schematic diagram of the overall system structure of the present invention is shown;
[0046] Figure 3 A schematic diagram showing the comparison of the effects of the base language large model and the non-inference model of the present invention is illustrated. Detailed Implementation
[0047] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0048] Example 1:
[0049] like Figure 1-3 As shown, the biliary tract cancer prediction method based on iterative self-consistency and large model validation includes the following steps:
[0050] The electronic medical record text data of the patient to be predicted is obtained, and a longitudinal clinical text sequence containing timestamp information is constructed. The longitudinal clinical text sequence is concatenated with the patient's static features to construct a structured prompt word sequence that conforms to the input of a large language model. The prompt word sequence also contains task instructions.
[0051] The prompt word sequence is input into the current base large language model. A random decoding strategy is adopted, the sampling temperature is set, and an independent set of inference paths is generated in parallel. Each inference path contains intermediate inference steps and the final diagnostic conclusion.
[0052] The frequency of diagnostic conclusions in all reasoning paths is counted. A majority voting mechanism is used to select the reasoning path with the highest frequency of diagnosis and high confidence as a positive sample, and the path with inconsistent diagnostic conclusions is selected as a negative sample to construct candidate data pairs.
[0053] A validation large language model is introduced to verify the medical logic rationality of positive samples. If the validation passes, the positive samples are included in the training set for this round of fine-tuning. The current base large language model is then fine-tuned under supervision. By optimizing the contrastive loss function, the updated base large language model is obtained. Multiple rounds of iterative optimization are performed until the preset convergence condition is met, and the final base large language model is obtained.
[0054] The electronic medical record data of new patients to be diagnosed is constructed into a structured cue word sequence, which is then input into the final base large language model. A greedy decoding strategy is adopted to generate the optimal reasoning path and diagnostic conclusion, and output the thought chain reasoning result containing medical logic.
[0055] Extract patients' static characteristics from electronic medical records and perform structured language conversion, including characteristics that do not change over time and are stable over a long period of time, such as gender, age, smoking history, and drinking history.
[0056] Extracting the patient's medical records from the electronic medical records, sorting all events by the date of visit from earliest to latest, and forming the patient's longitudinal clinical time series;
[0057] The longitudinal events are converted into a coherent sequence of clinical text. Based on the input specifications of the large language model, a structured prompt word template is designed, including a system role layer, a patient temporal information layer, and a task instruction layer. These are then spliced and combined to form a complete structured prompt word sequence.
[0058] Load the base large language model for the current iteration, set random decoding parameters, enable random sampling strategy, and set sampling temperature parameters;
[0059] The structured prompt word sequence is input into the base large language model of the current iteration in parallel. Under the random sampling mechanism, K different output sequences are generated independently. At the same time, the joint log probability of each sequence is recorded as the confidence level. K is a constant representing the number of output sequences.
[0060] Each generated text sequence is parsed, and intermediate reasoning steps and final diagnostic conclusions are separated according to a preset format. The K paths and probability information are organized into a set of structured reasoning paths.
[0061] The frequency of the final diagnosis conclusion in all reasoning paths is counted, and the conclusion with the highest frequency is selected as the majority conclusion. From all paths that output the majority conclusion, the reasoning path with the highest generation probability is selected as the positive sample candidate.
[0062] From the remaining paths, all paths whose final diagnostic conclusions are inconsistent with the majority conclusions are selected to form a set of opposing conclusion paths. From this set, one reasoning path is randomly selected as a negative sample.
[0063] The original structured cue word sequence, positive samples, and negative samples are combined to form candidate data pairs in the form of triplets.
[0064] Another general-purpose large language model for validation will be introduced. As a validator, it verifies the selected positive samples. The medical logic rationality verification is performed, and the verification process is as follows: enter Determine whether the reasoning chain conforms to medical standards, identify logical contradictions in the diagnostic conclusion, and verify the function. Defined as:
[0065]
[0066] Only when At that time, the corresponding prompt word sequence, positive sample, and negative sample are combined into a triplet and included in the training set for this round of fine-tuning. Conversely, if the result is invalid, it will be considered invalid and discarded.
[0067] Using the constructed training set The base large language model for the current iteration round Supervised fine-tuning was performed to obtain the next-generation base-based large language model. To maximize the generation of logically correct positive samples in medical practice using a large base language model. The probability of generating logically flawed negative samples is minimized. The probability is used to optimize the base language model (specifically, direct preference optimization) loss function is as follows:
[0068]
[0069] in, This represents a fine-tuned training set containing cue word sequences and positive / negative inference sample pairs. This represents the calculation of the expected value of the sample distribution within the training set. This indicates the function used for nonlinear mapping. The hyperparameter representing the strength of the bias control in the adjustment model is... This represents the current iteration round of the base large language model. Generate positive samples The strategy probability, Represents the model in the current iteration round. Generate negative samples The strategy probability, This indicates that the reference model generated positive samples in the previous round. The baseline probability, This indicates that the previous reference model generated negative samples. The baseline probability.
[0070] Multiple rounds of iterative optimization are performed until the preset convergence condition is met, resulting in the final base large language model. The specific iterative optimization process is as follows:
[0071] The contrastive loss function is applied to the parameter update process of the base large language model. The specific training implementation process is as follows:
[0072] In the In each iteration, based on the current base large language model parameters Perform forward propagation to obtain the predicted probabilities of positive and negative samples, and calculate the loss function with respect to the parameters. The gradient is calculated using an optimizer that updates the parameters according to the formula. Fine-tuning the model yields the next-generation foundational large language model. After completing one round of parameter updates, As a new foundational large language model, the update steps are re-executed, and the iterative process continues until the preset convergence condition is met. The formula for determining the convergence condition is:
[0073]
[0074] in, Indicates the first The weight parameters of the base large language model during round iteration. This represents the learning rate hyperparameter. The gradient vector of the loss function. Indicates the updated number Wheel model parameters, This represents the accuracy metric of the model on the validation set. This represents the preset convergence threshold. Through multiple rounds of iterative optimization, the underlying large language model is finally obtained. ;
[0075] The optimal reasoning path and diagnostic conclusion are generated, and the reasoning result containing medical logic is output. The specific process is as follows:
[0076] Utilizing the self-evolutionary training after multiple rounds of iteration When making clinical diagnostic inferences for new patients, the electronic medical record data of the patients to be diagnosed is constructed into a structured cue word sequence. Input to parameters with fixed values In this process, a greedy decoding strategy is employed to find the sequence with the highest generation probability as the output, thereby finding the optimal inference path. Diagnostic conclusion The joint probability maximization process is expressed by the prediction formula as follows:
[0077]
[0078] in, This represents a thought process reasoning path that incorporates medical causal logic. This indicates the final risk level or diagnostic conclusion. This represents a structured prompt sequence that conforms to input specifications, constructed based on the new medical record. This represents the final, fixed parameters of the base large language model after training. Indicates the total word length of the reasoning sequence. Indicates in The lexical units generated at each moment, Indicates from 1 to 1 A sequence of historical contexts composed of lexical elements This represents the conditional generation probability of the current word given the input and historical prediction sequences, and the final output is a thought chain containing rigorous medical logic. and a clear risk level and diagnostic results The system extracts key identification points to generate natural language reports, providing doctors with highly interpretable auxiliary decision-making support.
[0079] The specific experimental procedure is as follows:
[0080] Input Prompt: The system prompt indicates that you, as a senior oncology specialist, need to carefully analyze the electronic medical record information of the following patient to assess whether the patient has gallbladder cancer, which includes gallbladder cancer or bile duct cancer. Please provide a predictive conclusion based on the patient's diagnostic history, laboratory test results, medical history, and other relevant information.
[0081] Input: The patient is a 51-year-old female who presented on January 18th with a diagnosis of type 2 diabetes. Her liver, gallbladder, and pancreas-related diagnoses also included type 2 diabetes.
[0082] The patient, aged 51, visited the clinic on February 3rd and was diagnosed with diabetes. The diagnosis related to the liver, gallbladder, and pancreas was also diabetes.
[0083] The patient, aged 51, presented on February 15th and was diagnosed with abnormal liver function, type 2 diabetes, and cervical spondylosis. The liver, gallbladder, and pancreas-related diagnosis was type 2 diabetes.
[0084] The patient, aged 51, visited the hospital on March 4 and was diagnosed with abnormal liver function.
[0085] The patient, aged 51, visited the hospital on March 21 and was diagnosed with abnormal liver function.
[0086] A 51-year-old patient presented on March 22nd with the following blood test results: alanine aminotransferase 31.0 U / L, neutrophil percentage 56.4%, triglycerides 0.69 mmol / L, low-density lipoprotein 3.26 mmol / L, lymphocyte percentage 31.6%, aspartate aminotransferase 32.0 U / L, platelet count 386.0 × 10^9 / L, cholesterol 6.24 mmol / L, white blood cell count 6.61 × 10^9 / L, glycated hemoglobin A1c 7.2%, and hemoglobin 92.0 g / L. Abnormal blood test values were: cholesterol 6.24 mmol / L, glycated hemoglobin A1c 7.2%, platelet count 386.0 × 10^9 / L, and hemoglobin 92.0 g / L.
[0087] The patient, aged 51, visited the hospital on March 28 and was diagnosed with physical discomfort.
[0088] The patient is 51 years old and presented on April 18th. She was diagnosed with type 2 diabetes, and her liver, gallbladder, and pancreas-related diagnoses were also type 2 diabetes.
[0089] The patient, aged 51, visited the hospital on April 19 and was diagnosed with physical discomfort.
[0090] The patient, aged 52, presented on May 16 and was diagnosed with type 2 diabetes. The diagnosis related to the liver, gallbladder, and pancreas was also type 2 diabetes.
[0091] The patient, a 52-year-old woman, presented on June 20th with the following blood test results: hemoglobin 85.0 g / L, white blood cell count 8.0 × 10^9 / L, lymphocyte percentage 27.2%, platelet count 331.0 × 10^9 / L, and neutrophil percentage 64.0%. Abnormal blood test values included platelet count 331.0 × 10^9 / L and hemoglobin 85.0 g / L. She was diagnosed with type 2 diabetes, and a related diagnosis for the liver, gallbladder, and pancreas was also confirmed as type 2 diabetes.
[0092] The patient is 52 years old and presented on July 27th. She was diagnosed with type 2 diabetes, and her liver, gallbladder and pancreas-related diagnoses were also type 2 diabetes.
[0093] The patient, aged 52, presented on August 22nd and was diagnosed with type 2 diabetes. The liver, gallbladder, and pancreas-related diagnoses were also type 2 diabetes.
[0094] The patient, aged 52, presented on September 26 and was diagnosed with type 2 diabetes. The liver, gallbladder, and pancreas-related diagnoses were also type 2 diabetes.
[0095] The patient, aged 52, presented on October 24th and was diagnosed with general malaise and type 2 diabetes. The liver, gallbladder, and pancreas-related diagnosis was also type 2 diabetes.
[0096] A 52-year-old patient presented on October 25th with the following blood test results: Gamma-glutamyl transferase (GGT) 10.0 U / L, white blood cell count 6.57 × 10^9 / L, alanine aminotransferase (ALT) 19.0 U / L, platelet count 315.0 × 10^9 / L, neutrophil percentage 54.9%, potassium 4.19 mmol / L, sodium 143.0 mmol / L, cholesterol 6.62 mmol / L, low-density lipoprotein (LDL) 3.49 mmol / L, and triglycerides 1.12 mmol / L. The following blood test results were observed: total bilirubin 9.2 μmol / L, aspartate aminotransferase 25.0 U / L, uric acid 168.0 μmol / L, creatinine 38.0 μmol / L, high-density lipoprotein 1.96 mmol / L, glycated hemoglobin A1c 6.9%, lymphocyte percentage 37.1%, albumin 40.18 g / L, magnesium 0.9 mmol / L, alkaline phosphatase 80.0 U / L, hemoglobin 117.0 g / L, and chloride 105.0 mmol / L. Abnormal blood test results included: low-density lipoprotein 3.49 mmol / L, platelet count 315.0 × 10^9 / L, glycated hemoglobin A1c 6.9%, cholesterol 6.62 mmol / L, and uric acid 168.0 μmol / L.
[0097] The patient, aged 52, presented on November 28th and was diagnosed with type 2 diabetes. The liver, gallbladder, and pancreas-related diagnoses were also type 2 diabetes.
[0098] The patient, a 52-year-old woman, presented on December 26th with the following blood test results: uric acid 179.0 μmol / L, aspartate aminotransferase 17.0 U / L, high-density lipoprotein 1.9 mmol / L, triglycerides 0.72 mmol / L, creatinine 39.0 μmol / L, gamma-glutamyl transferase 14.0 U / L, low-density lipoprotein 3.26 mmol / L, albumin 37.93 g / L, alanine aminotransferase 23.0 U / L, and cholesterol 5.59 mmol / L. Abnormal values in the blood tests included: cholesterol 5.59 mmol / L, albumin 37.93 g / L, and uric acid 179.0 μmol / L.
[0099] The patient, aged 52, presented on December 29th and was diagnosed with type 2 diabetes. Hepatobiliary and pancreatic related diagnoses also included type 2 diabetes.
[0100] The patient, aged 52, presented on January 11 and was diagnosed with chronic gastritis, nodular goiter, and Helicobacter pylori infection.
[0101] The patient, aged 52, presented on January 17th with a diagnosis of cough, breast hyperplasia, and vulvitis.
[0102] The patient, aged 52, presented on January 19th with cerebral arteriosclerosis, chest pain, coronary atherosclerotic heart disease, and internal carotid artery atherosclerosis. The hepatobiliary and pancreatic related diagnosis was coronary atherosclerotic heart disease.
[0103] The patient, aged 52, presented on January 20 and was diagnosed with a lung shadow.
[0104] The patient, aged 52, presented on January 23 and was diagnosed with nodular goiter.
[0105] The patient, aged 52, presented on February 17th and was diagnosed with type 2 diabetes, cerebral arteriosclerosis, and coronary atherosclerotic heart disease. The liver, gallbladder, and pancreas-related diagnoses were also type 2 diabetes and coronary atherosclerotic heart disease.
[0106] The patient, aged 52, presented on February 27th and was diagnosed with coronary atherosclerotic heart disease. The hepatobiliary and pancreatic related diagnoses were also coronary atherosclerotic heart disease.
[0107] Based on the above medical record information, please assess whether the patient has a risk of gallbladder cancer or bile duct cancer, and output "risk of gallbladder cancer" or "no risk of gallbladder cancer", and explain in detail the basis for the judgment.
[0108] Based on preliminary, fine-tuned model inferences, there is a risk of gallbladder cancer:
[0109] The patient had visited the hospital multiple times in the past year, and the medical records repeatedly showed abnormal liver function on February 15, March 4, and March 21. Blood test results showed that alanine aminotransferase (ALT) was 31.0 U / L and aspartate aminotransferase (AST) was 32.0 U / L. Although the values were slightly elevated, they persisted. The patient complained of discomfort on March 28 and April 19, which are early nonspecific symptoms of potential malignancy.
[0110] The patient has a long history of type 2 diabetes. Medical research shows that diabetes is one of the high-risk factors for biliary system cancer. Long-term high blood sugar can cause chronic inflammation. Combined with the patient's repeated abnormal liver function indicators, it cannot be ruled out that this is due to malignant lesions in the biliary system, such as tumor growth causing bile duct compression, which in turn causes liver cell damage and elevated enzyme levels.
[0111] Given that the patient is 52 years old, which is a high-risk age for cancer, and has a long history of metabolic diseases, along with persistent abnormal liver function indicators and unexplained physical discomfort, although jaundice was not explicitly mentioned in the medical record, occult bile duct cancer often does not present obvious early symptoms.
[0112] Based on the inference results of the final foundational language model, there is no risk of gallbladder cancer.
[0113] 1. The patient's medical history shows that he / she has a long-term type 2 diabetes, and the main reason for seeking medical treatment is diabetes and its complications. He / she does not show any symptoms or signs that are clearly related to gallbladder cancer or bile duct cancer, such as typical symptoms such as jaundice, abdominal pain, and rapid weight loss.
[0114] 2. Laboratory test results showed abnormal liver function, such as mild elevation of aspartate aminotransferase (AST) and alanine aminotransferase (ALT), but these abnormalities did not involve specific indicators of the gallbladder or bile duct, such as alkaline phosphatase (ALP) and gamma-glutamyl transferase (GGT).
[0115] 3. Cholesterol and uric acid levels fluctuate, but no obvious abnormalities are found in the biliary system. Total bilirubin and bile acid levels are normal or within the normal range, and no obvious signs of biliary obstruction or dysfunction are found.
[0116] 4. Previous diagnoses were mainly type 2 diabetes and cardiovascular disease, and no high-risk factors related to gallbladder cancer, such as chronic cholecystitis, gallstones, or family history, were found.
[0117] The non-inference model only outputs "no risk of gallbladder cancer":
[0118] The black-box nature of these models leads to a lack of interpretability. These models are black-box models, which can usually only output a result but cannot provide the medical logic or thought process that led to that result. Due to the lack of specific reasoning data and supporting evidence, doctors find it difficult to know which clinical features the model is based on to make the judgment.
[0119] It is difficult to be adopted clinically and has low credibility. Because the logic behind the prediction cannot be explained, its predictive results lack transparency in serious medical decision-making, making it difficult to gain the trust and adoption of clinicians. What doctors need is diagnostic evidence, not just a result.
[0120] Example 2:
[0121] like Figure 3 As shown, the biliary tract cancer prediction system based on iterative self-consistency and large model validation includes the following modules:
[0122] The data acquisition module acquires the electronic medical record text data of the patients to be predicted, constructs a longitudinal clinical text sequence containing timestamp information, concatenates the longitudinal clinical text sequence with the static features of the patients, and constructs a structured prompt word sequence that conforms to the input of the large language model. The prompt word sequence also contains task instructions.
[0123] The sample generation module inputs the prompt word sequence into the current base large language model, adopts a random decoding strategy, sets the sampling temperature, and generates an independent set of inference paths in parallel. Each inference path contains intermediate inference steps and the final diagnostic conclusion.
[0124] The sample screening module counts the frequency of diagnostic conclusions in all reasoning paths, uses a majority voting mechanism to select the reasoning path with the highest frequency of conclusions and high confidence as a positive sample, and selects paths from the set of paths with inconsistent diagnostic conclusions as negative samples to construct candidate data pairs.
[0125] The logic verification module introduces a large language model to verify the medical logic rationality of positive samples. If the verification passes, the positive samples are included in the training set for this round of fine-tuning. The current base large language model is then fine-tuned under supervision. By optimizing the contrast loss function, the updated base large language model is obtained. Multiple rounds of iterative optimization are performed until the preset convergence condition is met, and the final base large language model is obtained.
[0126] The reasoning application module constructs a structured prompt word sequence from the electronic medical record data of new patients to be diagnosed, inputs it into the final base large language model, adopts a greedy decoding strategy to generate the optimal reasoning path and diagnostic conclusion, and outputs the thought chain reasoning result containing medical logic.
[0127] The size of the interval and threshold is set to facilitate comparison. The size of the threshold depends on the amount of sample data and the number of bases set by those skilled in the art for each set of sample data; as long as it does not affect the ratio between the parameter and the quantized value.
[0128] The above formulas are all dimensionless calculations. The formulas are derived from software simulations based on a large amount of collected data to obtain the most recent real-world results. The preset parameters in the formulas are set by those skilled in the art according to the actual situation.
[0129] In the two embodiments provided in this application, it should be understood that the disclosed apparatus and system can be implemented in other ways; for example, the apparatus embodiments described above are merely illustrative, and the division of modules is merely a logical functional division. In actual implementation, there may be other division methods, such as multiple modules or components can be combined or integrated into another system, or some features can be ignored or not executed; furthermore, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces, and the indirect coupling or communication connection of the apparatus or module may be electrical, mechanical or other forms.
[0130] The above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention in any way. Although the present invention has been disclosed above with reference to preferred embodiments, it is not intended to limit the present invention. Any person skilled in the art can make some modifications or alterations to the above-disclosed technical content to create equivalent embodiments without departing from the scope of the present invention. Any simple modifications, equivalent changes and alterations made to the above embodiments based on the technical essence of the present invention without departing from the scope of the present invention shall still fall within the scope of the present invention.
Claims
1. A method for predicting biliary tract cancer based on iterative self-consistency and large model validation, characterized in that, Includes the following steps: The electronic medical record text data of the patient to be predicted is obtained, and a longitudinal clinical text sequence containing timestamp information is constructed. The longitudinal clinical text sequence is concatenated with the patient's static features to construct a structured prompt word sequence that conforms to the input of a large language model. The prompt word sequence also contains task instructions. The prompt word sequence is input into the current base large language model. A random decoding strategy is adopted, the sampling temperature is set, and an independent set of inference paths is generated in parallel. Each inference path contains intermediate inference steps and the final diagnostic conclusion. The frequency of diagnostic conclusions in all reasoning paths is counted. A majority voting mechanism is used to select the reasoning path with the highest frequency of diagnosis and high confidence as a positive sample, and the path with inconsistent diagnostic conclusions is selected as a negative sample to construct candidate data pairs. A validation large language model is introduced to verify the medical logic rationality of positive samples. If the validation passes, the positive samples are included in the training set for this round of fine-tuning. The current base large language model is then fine-tuned under supervision. By optimizing the contrastive loss function, the updated base large language model is obtained. Multiple rounds of iterative optimization are performed until the preset convergence condition is met, and the final base large language model is obtained. The electronic medical record data of new patients to be diagnosed is constructed into a structured cue word sequence, which is then input into the final base large language model. A greedy decoding strategy is adopted to generate the optimal reasoning path and diagnostic conclusion, and output the thought chain reasoning result containing medical logic.
2. The method and system for predicting biliary tract cancer based on iterative self-consistency and large model validation according to claim 1, characterized in that, A longitudinal clinical text sequence containing timestamp information is constructed. This sequence is then concatenated with the patient's static features to create a structured cue word sequence that conforms to the input of a large language model. This cue word sequence also contains task instructions. The specific construction process is as follows: Extract patients' static characteristics from electronic medical records and perform structured language conversion, including characteristics that do not change over time and are stable over a long period of time, such as gender, age, smoking history, and drinking history. Extracting the patient's medical records from the electronic medical records, sorting all events by the date of visit from earliest to latest, and forming the patient's longitudinal clinical time series; The longitudinal events are converted into a coherent sequence of clinical text. Based on the input specifications of the large language model, a structured prompt word template is designed, including a system role layer, a patient temporal information layer, and a task instruction layer. These are then spliced and combined to form a complete structured prompt word sequence.
3. The method and system for predicting biliary tract cancer based on iterative self-consistency and large model validation according to claim 1, characterized in that, The prompt word sequence is input into the current base large language model. A random decoding strategy is adopted, the sampling temperature is set, and independent inference path sets are generated in parallel. Each inference path includes intermediate inference steps and the final diagnostic conclusion. The specific process is as follows: Load the base large language model for the current iteration, set random decoding parameters, enable random sampling strategy, and set sampling temperature parameters; The structured prompt word sequence is input into the base large language model of the current iteration in parallel. Under the random sampling mechanism, K different output sequences are generated independently, and the joint log probability of each sequence is recorded as the basis for confidence. Each generated text sequence is parsed, and intermediate reasoning steps and final diagnostic conclusions are separated according to a preset format. The K paths and probability information are organized into a set of structured reasoning paths.
4. The method and system for predicting biliary tract cancer based on iterative self-consistency and large model validation according to claim 1, characterized in that, Using a majority voting mechanism, the reasoning path with the highest frequency and confidence in the conclusion is selected as the positive sample, and paths from the set of inconsistent diagnostic conclusions are selected as the negative sample to construct candidate data pairs. The specific process is as follows: The frequency of the final diagnosis conclusion in all reasoning paths is counted, and the conclusion with the highest frequency is selected as the majority conclusion. From all paths that output the majority conclusion, the reasoning path with the highest generation probability is selected as the positive sample candidate. From the remaining paths, all paths whose final diagnostic conclusions are inconsistent with the majority conclusions are selected to form a set of opposing conclusion paths. From this set, one reasoning path is randomly selected as a negative sample. The original structured cue word sequence, positive samples, and negative samples are combined to form candidate data pairs in the form of triplets.
5. The method for predicting biliary tract cancer based on iterative self-consistency and large model validation according to claim 1, characterized in that, A validation language model is introduced to verify the medical logic rationality of positive samples. If the validation passes, the positive sample is included in the training set for this round of fine-tuning. The specific process is as follows: Another general-purpose large language model for validation will be introduced. As a validator, it verifies the selected positive samples. The medical logic rationality verification is performed, and the verification process is as follows: enter Determine whether the reasoning chain conforms to medical standards, identify logical contradictions in the diagnostic conclusion, and verify the function. Defined as: Only when At that time, the corresponding prompt word sequence, positive sample, and negative sample are combined into a triplet and included in the training set for this round of fine-tuning. Conversely, if the result is invalid, it will be considered invalid and discarded.
6. The method for predicting biliary tract cancer based on iterative self-consistency and large model validation according to claim 1, characterized in that, Supervised fine-tuning of the current base-based large language model is performed. By optimizing the contrastive loss function, an updated base-based large language model is obtained. The specific process is as follows: Using the constructed training set The base large language model for the current iteration round Supervised fine-tuning was performed to obtain the next-generation base-based large language model. To maximize the generation of logically correct positive samples in medical practice using a large base language model. The probability of generating logically flawed negative samples is minimized. The probability is used to optimize the base language model (specifically, direct preference optimization) loss function is as follows: in, This represents a fine-tuned training set containing cue word sequences and positive / negative inference sample pairs. This represents the calculation of the expected value of the sample distribution within the training set. This indicates the function used for nonlinear mapping. The hyperparameter representing the strength of the bias control in the adjustment model is... This represents the current iteration round of the base large language model. Generate positive samples The strategy probability, Represents the model in the current iteration round. Generate negative samples The strategy probability, This indicates that the reference model generated positive samples in the previous round. The baseline probability, This indicates that the previous reference model generated negative samples. The baseline probability.
7. The method for predicting biliary tract cancer based on iterative self-consistency and large model validation according to claim 1, characterized in that, Multiple rounds of iterative optimization are performed until the preset convergence condition is met, resulting in the final base large language model. The specific iterative optimization process is as follows: The contrastive loss function is applied to the parameter update process of the base large language model. The specific training implementation process is as follows: In the In each iteration, based on the current base large language model parameters Perform forward propagation to obtain the predicted probabilities of positive and negative samples, and calculate the loss function with respect to the parameters. The gradient is calculated using the optimizer and the parameter update formula. Fine-tuning the model yields the next-generation foundational large language model. After completing one round of parameter updates, As a new foundational large language model, the update steps are re-executed, and the iterative process continues until the preset convergence condition is met.
8. The method for predicting biliary tract cancer based on iterative self-consistency and large model validation according to claim 1, characterized in that, The optimal reasoning path and diagnostic conclusion are generated, and the reasoning result containing medical logic is output. The specific process is as follows: Using the final base language model trained through multiple rounds of iterative self-evolution, when making clinical diagnostic inferences for new patients, the electronic medical record data of the patients to be diagnosed is constructed into a structured prompt word sequence, which is then input into the final base language model with fixed parameters. A greedy decoding strategy is adopted to find the sequence with the highest generation probability as the output, which is the process of finding the optimal inference path and maximizing the joint probability of the diagnostic conclusion.
9. A biliary tract cancer prediction system based on iterative self-consistency and large model validation, used in the biliary tract cancer prediction method based on iterative self-consistency and large model validation as described in any one of claims 1-8, characterized in that, Includes the following modules: The data acquisition module acquires the electronic medical record text data of the patients to be predicted, constructs a longitudinal clinical text sequence containing timestamp information, concatenates the longitudinal clinical text sequence with the static features of the patients, and constructs a structured prompt word sequence that conforms to the input of the large language model. The prompt word sequence also contains task instructions. The sample generation module inputs the prompt word sequence into the current base large language model, adopts a random decoding strategy, sets the sampling temperature, and generates an independent set of inference paths in parallel. Each inference path contains intermediate inference steps and the final diagnostic conclusion. The sample screening module counts the frequency of diagnostic conclusions in all reasoning paths, uses a majority voting mechanism to select the reasoning path with the highest frequency of conclusions and high confidence as a positive sample, and selects paths from the set of paths with inconsistent diagnostic conclusions as negative samples to construct candidate data pairs. The logic verification module introduces a large language model to verify the medical logic rationality of positive samples. If the verification passes, the positive sample is included in the training set for this round of fine-tuning. The current base language model is then fine-tuned under supervision. By optimizing the contrastive loss function, an updated base language model is obtained. Multiple rounds of iterative optimization are performed until the preset convergence condition is met, resulting in the final base language model. The reasoning application module constructs a structured prompt word sequence from the electronic medical record data of new patients to be diagnosed. This sequence is input into the final base language model. A greedy decoding strategy is used to generate the optimal reasoning path and diagnostic conclusion, and outputs the thought chain reasoning result containing medical logic.