Liver cancer prediction method and system based on improved sampling strategy of large language model

By combining improved sampling strategies and gamma distribution models, and utilizing large language models to generate and filter high-quality inference paths in parallel, the interpretability and training cost issues of deep learning models in liver cancer prediction are solved, achieving high-precision and low-cost liver cancer risk warning.

CN121885162BActive Publication Date: 2026-05-19QINGDAO UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
QINGDAO UNIV
Filing Date
2026-03-20
Publication Date
2026-05-19

AI Technical Summary

Technical Problem

Existing deep learning models for liver cancer prediction suffer from a lack of interpretability and high training costs, limiting their clinical application.

Method used

An improved sampling strategy is adopted. By constructing a target distribution model that follows a gamma distribution and an importance sampling algorithm, multiple inference paths are generated in parallel using a pre-trained large language model. Combining logical consistency and medical evidence matching scores, the path with the highest weight is selected as the final diagnostic basis.

Benefits of technology

It achieves interpretability and high accuracy in liver cancer prediction, reduces training costs and deployment barriers, and is suitable for medical institutions with limited computing resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121885162B_ABST
    Figure CN121885162B_ABST
Patent Text Reader

Abstract

The application discloses a large language model liver cancer prediction method and system based on an improved sampling strategy, relates to the technical field of artificial intelligence medical diagnosis, and comprises the following steps: acquiring patient electronic medical records and performing time series reconstruction to construct structured prompt words; inputting the structured prompt words into a general large language model with parameter freezing, using a random decoding strategy to generate multiple reasoning paths in parallel; constructing a target distribution model based on a gamma distribution, and using an importance sampling algorithm to calculate the normalized weight of each path to suppress low-quality paths and amplify the weight of paths conforming to medical logic; finally, the diagnostic conclusion is weighted and aggregated based on the weight to obtain a prediction result, and the reasoning process with the highest weight is output as an explainability report. The application can significantly improve the accuracy of liver cancer prediction and the transparency of clinical decision-making without model fine-tuning.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of artificial intelligence medical diagnostic technology, specifically to a method and system for predicting liver cancer based on a large language model with an improved sampling strategy. Background Technology

[0002] Primary liver cancer is a malignant tumor with an extremely high mortality rate worldwide. Due to its insidious onset, most patients are diagnosed at an advanced stage, missing the optimal treatment window. With the advancement of healthcare information technology, hospital electronic medical record systems have accumulated massive amounts of longitudinal patient data, covering demographic characteristics, past medical history, and long-term laboratory test indicators. Effectively utilizing computer technology to deeply explore the potential correlations within this multimodal data to achieve early screening and risk warning for high-risk groups of liver cancer is of great significance for reducing liver cancer mortality.

[0003] In existing assisted diagnostic technologies, time series analysis methods based on deep learning have been widely applied to process electronic medical record data. These methods typically employ architectures such as recurrent neural networks or long short-term memory networks to map a patient's biochemical test indicators, diagnostic codes, and medication records at different time points into a high-dimensional feature vector sequence. This type of method utilizes the recurrent structure within the model to capture the dynamic evolution of clinical indicators over time, and then inputs the extracted time-series features into a classifier, ultimately outputting a probability score indicating that the patient has a specific disease, thereby achieving automated assisted diagnosis.

[0004] For example, existing methods for multimodal cancer data detection using LSTM combined with Monte Carlo simulation, or personal panoramic health record systems that focus on data aggregation, have failed to fundamentally solve the problems of lack of medical logical explanation in the model reasoning process and excessively high cost of large model applications.

[0005] However, the aforementioned existing technologies suffer from insufficient interpretability in practical clinical applications. Models based on traditional deep learning architectures typically only output a final probability value when making predictions, failing to demonstrate the medical logic or thought process leading to that result. Lacking concrete reasoning, clinicians struggle to understand which key clinical features the model bases its judgments on, and cannot verify whether the model has considered relevant confounding factors or excluded nonspecific symptoms. This inability to provide clear diagnostic justification makes it difficult for doctors to fully trust and adopt the model's predictive recommendations when facing serious medical decisions, thus limiting the practical application of this technology in clinical diagnosis and treatment. Furthermore, with the explosive growth in the number of parameters in large language models, fine-tuning or reinforcement learning training for specific medical domains often requires extremely expensive computing resources and massive amounts of high-quality labeled data, resulting in highly unstable training processes. This significantly limits its deployment and application in ordinary medical institutions. Summary of the Invention

[0006] To address the shortcomings of existing technologies, this invention provides a method and system for predicting liver cancer using a large language model based on an improved sampling strategy. This solves the problems of lack of interpretability in deep learning models and high cost and instability in fine-tuning training of large models in existing technologies.

[0007] To achieve the above objectives, the present invention provides the following technical solution: The first aspect of the present invention provides a method for predicting liver cancer using a large language model based on an improved sampling strategy, comprising the following steps:

[0008] Step S1: Obtain the electronic medical record text data of the patient to be predicted. The electronic medical record text data consists of the patient's static features and dynamic diagnosis and treatment records. Perform time-series reconstruction on the electronic medical record text data to form a vertical clinical text sequence containing timestamp information. Combine the vertical clinical text sequence with task instructions to construct a structured prompt word sequence that conforms to the input specifications of the large language model.

[0009] Step S2: Input the structured prompt word sequence into the pre-trained general large language model; while keeping the parameters of the general large language model frozen, use a random decoding strategy to generate multiple independent inference path sets in parallel, and obtain the original joint probability of each inference path generated by the general large language model as the proposal distribution probability.

[0010] Step S3: Construct a target distribution that follows a gamma distribution; use a scoring function to score each generated inference path to obtain a quality score value, and calculate the target probability density of the inference path based on the gamma distribution probability density function.

[0011] Step S4: Using the importance sampling algorithm, calculate the normalized weight of each inference path based on the target probability density and the proposal distribution probability.

[0012] Step S5: Based on the normalized weights, perform weighted aggregation on the final diagnostic conclusions corresponding to multiple inference paths; select the category with the largest weighted sum as the final prediction result, and select the inference process in the inference path with the largest normalized weight as the interpretable medical report for output.

[0013] Further, the step of using the importance sampling algorithm to calculate the normalized weight of each inference path includes: calculating the original importance weight, which is defined as the ratio of the target probability density to the proposal distribution probability; normalizing the original importance weights of all parallel-generated inference paths by dividing the original importance weight of a single inference path by the sum of the original importance weights of all inference paths to obtain the normalized weight.

[0014] Furthermore, the construction of the target distribution following a gamma distribution includes: defining the target distribution as a probability density representing a reasoning path that conforms to ideal medical logic, based on the long-tail distribution characteristics exhibited by the medical diagnostic reasoning quality; the unnormalized density of the target distribution is proportional to the probability density function of the gamma distribution; and scoring each generated reasoning path using a scoring function includes: scoring the reasoning path for logical consistency and medical evidence matching using the scoring function to obtain the quality score value.

[0015] Furthermore, the scoring function is calculated by constructing assessment prompts and using the large language model itself for scoring; specifically, it includes: constructing assessment instructions that include whether the assessment reasoning path references exact data in the electronic medical record and whether the reasoning logic conforms to medical guidelines; inputting the generated reasoning path back into the general large language model or the auxiliary model, and having the general large language model or the auxiliary model output a confidence score or obtain a value through keyword matching, and using the value as the quality score.

[0016] Furthermore, the probability density function of the gamma distribution includes a shape parameter and a scale parameter; the method for determining the shape parameter and the scale parameter includes: selecting a validation dataset containing high-quality inference path samples with expert annotations; fitting the sample distribution characteristics in the validation dataset using the maximum likelihood estimation method, and calculating the shape parameter value and scale parameter value that fit the current electronic medical record data distribution characteristics.

[0017] Furthermore, the step of weighted aggregation of the final diagnostic conclusions corresponding to multiple inference paths based on the normalized weights includes: setting a diagnostic conclusion space; calculating the weighted sum of the normalized weights of all inference paths corresponding to each category option in the diagnostic conclusion space; and selecting the category option with the largest weighted sum as the final prediction result.

[0018] Furthermore, the static features include gender, age, smoking history, and drinking history; the dynamic medical records include blood test results, disease diagnosis codes, and medication records from each visit arranged in chronological order; the temporal reconstruction of the electronic medical record text data includes arranging the dynamic medical records in chronological order to form the vertical clinical text sequence containing timestamp information.

[0019] Furthermore, the construction of the structured prompt word sequence that conforms to the input specifications of the large language model includes: concatenating the vertical clinical text sequence with the static features, and concatenating the task instruction; the task instruction is used to instruct the general large language model to analyze the risk of liver cancer based on time-series medical records and output the corresponding judgment reason.

[0020] Furthermore, the step of generating multiple independent inference path sets in parallel using a random decoding strategy includes: generating inference paths that include intermediate inference processes and final diagnostic conclusions; the step of obtaining the original joint probability of each inference path generated by the general large language model as the proposal distribution probability includes: calculating the joint probability of the general large language model generating complete inference paths in an autoregressive manner under the given structured prompt word sequence.

[0021] A second aspect of the present invention provides a large language model-based liver cancer prediction system based on an improved sampling strategy, the system comprising:

[0022] Memory, used to store computer programs and electronic medical record text data to be processed;

[0023] A processor, coupled to the memory, is used to execute the computer program to implement the large language model liver cancer prediction method based on an improved sampling strategy as described in the first aspect of the present invention.

[0024] This invention provides a method and system for predicting liver cancer using a large language model based on an improved sampling strategy. It has the following beneficial effects:

[0025] 1. This invention utilizes the generative capabilities of large language models to construct multiple independent reasoning paths in parallel, including intermediate reasoning processes. It also combines a weighted screening mechanism based on importance sampling to lock the path with the highest normalized weight from the candidate set as the final diagnostic basis. This invention effectively overcomes the shortcomings of traditional deep learning models that can only output numerical results without logical support. It realizes the transformation of electronic medical record data into interpretable reports with clear medical logic chains, thereby significantly improving the transparency and credibility of intelligent diagnostic systems in clinical decision-making while assisting doctors in understanding the basis of model judgment.

[0026] 2. This invention employs a strategy of freezing the parameters of a general large language model during the inference phase, combined with random decoding and statistical sampling algorithms to uncover the model's potential medical reasoning capabilities. This invention avoids the training instability and high computational resource consumption caused by supervised fine-tuning or reinforcement learning training of large models in existing technologies. It enables high-precision disease prediction tasks to be completed without the need to build large-scale labeled datasets or high-end training hardware support, thereby significantly reducing the system's development cost and deployment threshold, which is conducive to the promotion and application of this technology in medical institutions with limited computing resources.

[0027] 3. This invention introduces a target distribution model that follows a gamma distribution to characterize the long-tail distribution characteristics of medical inference quality, and uses an importance sampling algorithm to calculate the ratio of the target distribution to the proposal distribution to obtain the normalized weight of each inference path. This invention can automatically identify and suppress low-quality or hallucinatory inference paths generated by the model, while amplifying the contribution of high-quality paths that conform to rigorous medical logic to the final result. It achieves effective correction and optimization of the randomly generated results of general large models, thereby ensuring the accuracy and robustness of liver cancer risk prediction results in clinical diagnosis and treatment scenarios. Attached Figure Description

[0028] Figure 1 This is an overall flowchart of the present invention;

[0029] Figure 2 This is a comparison chart of the ROC performance of the improved sampling strategy model and the baseline model of this invention. Detailed Implementation

[0030] The technical solutions in 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.

[0031] Please see Figure 1 This invention provides a method for predicting liver cancer using a large language model based on an improved sampling strategy, comprising the following steps:

[0032] Step S1: Acquisition and temporal construction of EHR data.

[0033] Obtain electronic medical record text data of patients to be predicted ,data It consists of the patient's static characteristics and dynamic medical records. Static characteristics include gender, age, and smoking and drinking history; dynamic medical records include blood test results from each visit, disease diagnosis codes, and medication records. [Data...] A temporal reconstruction is performed, arranging dynamic medical records in chronological order to form a vertical clinical text sequence containing timestamp information. This vertical clinical text sequence is then concatenated with static features and combined with task instructions. A structured prompt word sequence conforming to the input specifications of a large language model is constructed. .

[0034] Step S2: Parallel generation of inference paths based on a general large model.

[0035] Structured prompt word sequence Input to pre-trained general large language model General Large Language Model The parameters remain frozen during inference. A stochastic decoding strategy is employed, based on a structured cue word sequence. Parallel generation A set of independent reasoning paths Each reasoning path Includes intermediate reasoning process and final diagnosis At the same time, obtain the model. Generate each inference path The original joint probability, i.e., the proposal distribution probability. .

[0036] Steps S3 to S4: Target quality modeling and importance sampling weight calculation based on gamma distribution.

[0037] To address the long-tail distribution characteristics exhibited by medical diagnostic inference quality, a target distribution following a gamma distribution is constructed. This is used to characterize the probability density of an ideal reasoning path that conforms to medical logic. A scoring function is then used. For each generated inference path Logical consistency and matching degree with medical evidence are scored, and the target probability density is calculated based on the gamma distribution probability density function. Then, an importance sampling algorithm is used to calculate the probability density of each reasoning path. Importance weights. Among them, the original weights... Calculated as the target distribution With the proposed distribution The ratio, and the original weights Normalization is performed to obtain normalized weights. This step reduces the weight of low-quality or medically illogical reasoning paths and increases the weight of medically illogical reasoning paths.

[0038] Step S5: Weighted aggregation and output of diagnostic results.

[0039] Based on normalized weights ,right The final diagnostic conclusions corresponding to each reasoning path Perform weighted voting. Calculate the weighted sum of each diagnostic conclusion category, and select the category with the largest weighted sum as the final prediction result. In addition, the path with the highest weight is selected. The reasoning process The diagnosis will be output as an interpretable medical report.

[0040] In step S1, the acquisition and time-series construction of EHR data are performed. The specific implementation process includes the following sub-steps:

[0041] Step S11: Obtain the electronic medical record text data of the patient to be predicted. Electronic medical record text data It includes the patient's static characteristics and dynamic medical records. Specifically, static characteristics include: gender, age, smoking history, and alcohol consumption history; dynamic medical records include: blood test results from each visit (including biochemical indicators and coagulation function indicators) and disease diagnosis (ICD code).

[0042] Step S12: Process the electronic medical record text data A temporal reconstruction was performed. The patient's blood test results, diagnostic codes, and medication records from each visit were arranged in chronological order to form a vertical clinical text sequence containing timestamp information.

[0043] Step S13: Construct a structured prompt word sequence that conforms to the input specifications of a large language model The sequence of longitudinal clinical text is concatenated with the patient's static features, and task instructions are included. (For example: "Based on the above timeline medical records, please infer and analyze the patient's risk of liver cancer").

[0044] In this embodiment, the structured prompt word sequence The specific configuration details are as follows:

[0045] The system prompt is set as follows: "You are a senior hepatologist. Please carefully analyze the electronic medical records of the following patients and predict whether liver cancer will develop."

[0046] Task Instructions The specific setting is: "Based on the above electronic medical record information, please predict whether this patient has a risk of liver cancer. If yes, output 'Risk of liver cancer'; if no, output 'No risk of liver cancer', and provide the corresponding reasoning."

[0047] In step S2, parallel generation of inference paths based on a general large model is performed. The specific implementation process includes the following sub-steps:

[0048] Step S21: Model input and parameter settings.

[0049] The structured cue word sequence constructed in step S1 Input to pre-trained general large language model In this embodiment, the general large language model The Qwen2.5-7B model was selected. During the reasoning process, the general large language model was maintained. The parameters are in a frozen state.

[0050] Step S22: Parallel generation of inference paths.

[0051] Using a stochastic decoding strategy, based on structured cue word sequences Parallel generation A set of independent reasoning paths Each reasoning path Includes intermediate reasoning process and final diagnosis .

[0052] Step S23: Calculate the probability distribution of the proposal.

[0053] Get the model Generate each inference path The original joint probability, i.e., the proposal distribution probability. .

[0054] Proposed distribution overview The calculation formula is as follows:

[0055]

[0056] In the formula:

[0057] The model generates the first The probability distribution of the proposed reasoning paths;

[0058] This refers to the structured cue word sequence containing the patient's temporal medical history and static features constructed in step S1;

[0059] The model generates the first A complete reasoning path;

[0060] This indicates the reasoning path. Total token length;

[0061] Indicating the reasoning path The first in Each word element;

[0062] Indicates that in generating the first All historical word sequences preceding each word (including the input) (and the generated prefix);

[0063] Representation of the base large language model A conditional probability function for predicting the next word given a context.

[0064] In steps S3 and S4, target quality modeling and importance sampling weight calculation based on gamma distribution are performed. The specific implementation process includes the following sub-steps:

[0065] Step S3: Construct the target distribution model based on the gamma distribution.

[0066] Based on the long-tail distribution characteristics of medical diagnostic inference quality, namely that most inference paths contain some valid information and a very small number of paths are accurate and rigorous, this embodiment uses the Gamma Distribution to model the potential quality score of the inference path.

[0067] Specifically, using a scoring function Reasoning path Logical consistency and matching with medical evidence are scored to obtain a quality score.

[0068] In a specific embodiment of the present invention, the scoring function The calculation is achieved by constructing evaluation prompts and using a large language model to score them. Specifically, an evaluation instruction containing "Please evaluate whether the above reasoning path references exact data in the electronic medical record" and "Does the reasoning logic conform to medical guidelines" is constructed, and the generated reasoning path is then evaluated. Input the model M or another auxiliary model again. The model outputs a confidence score (e.g., a floating-point number between 0 and 1) or a normalized value obtained through keyword matching (e.g., calculating the coverage rate of keywords from the original medical record in the path), and uses this value as the quality score. .

[0069] Define target distribution To characterize the probability density of a reasoning path that conforms to ideal medical logic. Target distribution. The unnormalized density is proportional to the probability density function of the gamma distribution:

[0070]

[0071] In the formula:

[0072] Indicates the first The reasoning path conforms to the target probability density of ideal medical logic;

[0073] This represents the quality score obtained after scoring the path;

[0074] The shape parameter represents the gamma distribution and is used to control the skewness of the distribution curve.

[0075] The scale parameter represents the gamma distribution and is used to control the degree of dispersion of the distribution;

[0076] This represents the standard gamma function, used for normalization calculations.

[0077] Furthermore, shape parameters and scale parameters The method for determining the optimal dataset is as follows: A small-scale validation dataset is selected, containing high-quality inference path samples with expert annotations. Maximum Likelihood Estimation (MLE) is used to fit the sample distribution characteristics of this validation dataset, thereby calculating the optimal dataset that best fits the current distribution characteristics of liver cancer electronic medical record data. Value and Value. In the experimental setup of this embodiment, the value is set as follows: =2.0, =1.5 (This value is for example only and should be dynamically adjusted according to the data distribution in actual applications).

[0078] Step S4: Calculate the importance weight of the inference path.

[0079] An importance sampling algorithm is used, based on the target distribution. With the proposed distribution Calculate the weights of the inference paths.

[0080] First, calculate the original importance weights. Original importance weights Defined as the ratio of the target probability distribution to the proposal probability distribution, the calculation formula is as follows:

[0081]

[0082] In the formula, Indicates the first The original importance weights of each reasoning path.

[0083] Then, the normalized weights are calculated. .right The original importance weights of the inference paths are normalized, and the calculation formula is as follows:

[0084]

[0085] In the formula:

[0086] This indicates the normalized result of the first... The final weight of each reasoning path;

[0087] This represents the total number of inference paths generated;

[0088] Indicates the first The original importance weights of each reasoning path.

[0089] Based on this normalized weight This assigns higher weights to high-quality paths that conform to medical logic, while suppressing the weights of low-quality illusory paths generated by the model.

[0090] In step S5, weighted aggregation and diagnostic results are output. The specific implementation process includes the following sub-steps:

[0091] Step S5: Calculate and output the final prediction result based on the normalized weights.

[0092] First, define the diagnostic conclusion space. In this embodiment, the diagnostic conclusion space Includes: {hepatocellular carcinoma, intrahepatic cholangiocarcinoma, benign nodules, others}.

[0093] Next, based on normalized weights ,right The final diagnostic conclusions corresponding to each reasoning path Weighted voting is performed to calculate the final prediction result. .

[0094] Final prediction results The calculation formula is as follows:

[0095]

[0096] In the formula:

[0097] Indicates the final diagnostic prediction category output by the system;

[0098] Representing the diagnostic conclusion space A specific category option;

[0099] Indicates the total number of reasoning paths;

[0100] This indicates the result of step S4. Normalized weights of each inference path;

[0101] Indicates the first The diagnostic conclusions contained in the reasoning path;

[0102] For indicator functions, when the condition inside the parentheses... The value is 1 if the condition is true, and 0 otherwise.

[0103] This indicates selecting the category that maximizes the value of the subsequent summation term. As the output.

[0104] Finally, select the path with the highest weight. The reasoning process This serves as an interpretable medical report for the diagnosis.

[0105] The path with the highest weight The selection formula is as follows:

[0106] The system outputs the final prediction result. and output the path corresponding to Reasoning process .

[0107] To verify the practical application effect of the large language model liver cancer prediction method and system based on the improved sampling strategy proposed in this invention, this embodiment selects specific clinical case data for comparative testing.

[0108] In this embodiment, the electronic medical record data of the patient to be predicted is input into the system as follows:

[0109] Patient information: Male.

[0110] Medical Record 1: Age 46, visited on June 27th. Blood test results: LDL cholesterol 2.0 mmol / L, uric acid 381.0 μmol / L, total bilirubin 12.74 μmol / L, creatinine 68.0 μmol / L, alanine aminotransferase 61.0 U / L, glucose 5.0 mmol / L, aspartate aminotransferase 45.0 U / L, cholesterol 3.88 mmol / L, triglycerides 0.67 mmol / L, albumin 44.78 g / L.

[0111] Medical Record 2: Age 46, visited on December 10th. Blood test results: Triglycerides 0.88 mmol / L, total bilirubin 21.44 μmol / L, gamma-glutamyl transferase 58.0 U / L, aspartate aminotransferase 42.0 U / L, glucose 5.19 mmol / L, albumin 41.7 g / L, alkaline phosphatase 68.0 U / L, creatinine 70.0 μmol / L, alanine aminotransferase 48.0 U / L, cholesterol 4.47 mmol / L.

[0112] Medical Record 3: Age 46, visited on December 12th. Diagnosis: Discomfort. Medications: Etomidate emulsion injection (once daily), Ondansetron injection (twice daily), Dezocine injection (once daily), Propofol emulsion injection (once daily), 0.9% sodium chloride injection (once daily).

[0113] Medical Record 4: Age 46, visited on April 1st. Medication: Iohexol injection (once daily).

[0114] Medical Record 5: Age 46, visited on April 2nd. Blood test results: Alanine aminotransferase 48.0 U / L, cholesterol 4.18 mmol / L, uric acid 403.0 μmol / L, albumin 42.84 g / L, triglycerides 0.84 mmol / L, gamma-glutamyl transferase 54.0 U / L, high-density lipoprotein 1.24 mmol / L, glucose 5.58 mmol / L, low-density lipoprotein 1.81 mmol / L, aspartate aminotransferase 43.0 U / L.

[0115] Medical Record 6: Age 47, visited on October 9th. Diagnosis: Abnormal alpha-fetoprotein. Medication: Gadoxate disodium injection (once daily).

[0116] Clinical diagnosis result (true value): Risk of liver cancer.

[0117] Based on the above input data, compare the prediction results and inference content of the three different models:

[0118] (a) Models without improved sampling strategies (i.e., no importance sampling is performed, and voting is directly performed on the N paths of random decoding)

[0119] Prediction result: No risk of liver cancer (false negative).

[0120] The reasons for the output judgment include:

[0121] 1. The patient had mildly elevated alanine aminotransferase (ALT) and aspartate aminotransferase (AST) levels in multiple blood tests, which is usually associated with fatty liver, mild chronic hepatitis or drug metabolism, and no indicators of severe liver failure were found.

[0122] 2. The patient had previously used propofol, etomidate, and other intravenous anesthetic drugs due to "discomfort," which is presumably due to a routine painless endoscopy or minor surgery, and is not directly related to malignant tumors.

[0123] 3. Although the last diagnosis was "abnormal alpha-fetoprotein", alpha-fetoprotein levels may fluctuate during the active phase of benign liver disease. Before a clear pathological diagnosis is made, the model tends to diagnose common benign liver lesions.

[0124] (II) Model of the Improved Sampling Strategy of the Invention

[0125] Prediction result: Risk of liver cancer (true positive).

[0126] The reasons for the output judgment (i.e., the reasoning path with the highest weight) include:

[0127] 1. Persistent signs of liver parenchymal damage: In multiple blood tests spanning more than a year, the patient's ALT, AST, and gamma-glutamyl transferase (GGT) levels remained abnormally high, indicating chronic progressive liver damage, which is an important pathological basis for the development of hepatocellular carcinoma (HCC).

[0128] 2. A significant escalation in imaging history: The patient received iohexol injection (routinely used for contrast-enhanced CT scans) in April, followed by gadoxetate disodium injection in October. Gadoxetate disodium is a liver-specific MRI contrast agent, clinically used for the differential diagnosis of early-stage hepatocellular carcinoma (small hepatocellular carcinoma). This unusual medication history strongly suggests that clinicians are investigating for a space-occupying lesion in the liver.

[0129] 3. Confirmation by core tumor markers: The last medical visit clearly diagnosed "abnormal alpha-fetoprotein (AFP) levels." AFP is a highly specific tumor marker for primary liver cancer. The combination of persistent liver damage, liver-specific MRI contrast agents, and abnormal AFP levels forms an extremely dangerous chain of evidence suggesting liver cancer, indicating a very high risk of liver cancer in this patient.

[0130] (iii) Traditional non-inference models (such as LSTM classifiers)

[0131] Prediction result: Only "No risk of liver cancer" was output (false negative).

[0132] Model defect analysis:

[0133] 1. The model cannot provide a logical chain of evidence, making verification difficult. It only outputs a probability value and cannot demonstrate the reasoning process. Doctors cannot determine whether the model associates highly specific contrast agents such as gadoxetate disodium with liver cancer screening.

[0134] 2. Extremely low utilization of unstructured text information. Traditional models mainly rely on continuous test values ​​(such as transaminase) for pattern recognition, making it difficult to deeply understand complex semantic logic. In this case, "gadoxetine disodium" and "abnormal alpha-fetoprotein" are decisive high-weight text features, and the model is prone to missing high-risk patients because it cannot understand the clinical severity of these text signals.

[0135] See attached document Figure 2 , Figure 2 The graph shows a comparison of the receiver operating characteristic (ROC) curve performance of the improved sampling strategy model and the baseline model in this embodiment of the invention on a real electronic medical record test set containing 6,543 patients (41 of whom were diagnosed with liver cancer) for a liver cancer risk prediction task.

[0136] like Figure 2 As shown, the horizontal axis represents the false positive rate (FPR), and the vertical axis represents the true positive rate (TPR). The graph contains three performance curves and a baseline:

[0137] (1) Improved sampling strategy model (orange curve): corresponds to the model applying the method described in the embodiments of the present invention;

[0138] (2) Model without improved sampling strategy (green curve): corresponds to the large language model without applying target quality modeling and importance sampling;

[0139] (3) Non-inference model (blue curve): corresponds to the traditional deep learning model based on numerical features (such as LSTM);

[0140] (4) Random guess (gray dashed line): baseline, AUC=0.500.

[0141] according to Figure 2 Quantitative data:

[0142] The area under the curve (AUC) of the improved sampling strategy model (orange curve) proposed in this invention is 0.929. The AUC of the model without the improved sampling strategy (green curve) is 0.903. The AUC of the non-inference model (blue curve) is 0.813.

[0143] Comparing the above data, we can see that:

[0144] First, the model of this invention (AUC=0.929) significantly outperforms the traditional non-inference model (AUC=0.813). This indicates that, compared to relying solely on time series numerical values ​​for pattern recognition, introducing a large language model to perform logical reasoning on unstructured text in electronic medical records can more accurately capture pathological features.

[0145] The model of this invention (AUC=0.929) outperforms the model without improved sampling strategy (AUC=0.903), with an AUC improvement of approximately 2.6%. This indicates that by constructing a target distribution model based on gamma distribution and utilizing importance sampling to calculate weights, this invention can effectively correct inference biases, suppress low-quality paths, and amplify the weights of paths that conform to medical logic, thereby improving prediction accuracy.

[0146] Based on the above technical solution, the embodiments of the present invention have the following advantages compared with the prior art:

[0147] 1. Strong interpretability. Existing RNN or LSTM models can only output probability values ​​and cannot demonstrate the reasoning process, resulting in a lack of interpretability in clinical applications. This invention, through the weighted filtering mechanism in steps S2 to S5, can output a logically rigorous natural language reasoning path with the highest weight as a diagnostic basis, thus solving the "black box" problem of traditional models.

[0148] 2. No training required, reducing computational costs and deployment barriers. Existing technologies typically rely on supervised fine-tuning or reinforcement learning (RL) training on large-scale labeled data, which suffers from training instability and high computational consumption. This invention utilizes a general-purpose large language model and keeps parameters frozen during inference, eliminating the need for parameter updates or fine-tuning. High-precision predictions can be achieved through sampling strategy optimization. This approach avoids expensive training costs and is suitable for deployment in medical institutions with limited computing resources.

[0149] Furthermore, embodiments of the present invention also provide a liver cancer prediction system based on a large language model with an improved sampling strategy. This system includes, at the hardware level:

[0150] Memory and processor.

[0151] Memory, used to store computer programs and electronic medical record text data to be processed;

[0152] The processor, coupled to the memory, is used to execute a computer program to implement the large language model liver cancer prediction method based on the improved sampling strategy described in steps S1 to S5 above.

[0153] In specific applications, the processor can be a general-purpose central processing unit (CPU), a graphics processing unit (GPU), or a dedicated artificial intelligence acceleration chip (such as an NPU) to meet the high-concurrency computing requirements of large language model inference.

[0154] Although embodiments of the invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the appended claims and their equivalents.

Claims

1. A method for predicting liver cancer using a large language model based on an improved sampling strategy, characterized in that, Includes the following steps: Step S1: Obtain the electronic medical record text data of the patient to be predicted. The electronic medical record text data consists of the patient's static features and dynamic diagnosis and treatment records. Perform time-series reconstruction on the electronic medical record text data to form a vertical clinical text sequence containing timestamp information. Combine the vertical clinical text sequence with task instructions to construct a structured prompt word sequence that conforms to the input specifications of the large language model. Step S2: Input the structured prompt word sequence into the pre-trained general large language model. While keeping the parameters of the general large language model frozen, use a random decoding strategy to generate multiple independent inference path sets in parallel, and obtain the original joint probability of each inference path generated by the general large language model as the proposal distribution probability. Step S3: Construct a target distribution that follows a gamma distribution, use a scoring function to score each generated inference path to obtain a quality score, and calculate the target probability density of the inference path based on the gamma distribution probability density function; The construction of the target distribution following a gamma distribution includes: defining the target distribution as a probability density representing a reasoning path that conforms to ideal medical logic, taking into account the long-tail distribution characteristics exhibited by medical diagnostic reasoning quality; the unnormalized density of the target distribution is proportional to the probability density function of the gamma distribution. The step of scoring each generated reasoning path using a scoring function includes: using the scoring function to score the logical consistency and medical evidence matching degree of the reasoning path to obtain the quality score value; The step of scoring each generated inference path using a scoring function includes: constructing an evaluation instruction based on objective fact-checking criteria, wherein the evaluation instruction includes evaluating whether the inference path accurately references the exact data in the electronic medical record and whether the inference logic conforms to pre-established medical guidelines; inputting the generated inference path back into the general large language model, wherein the general large language model outputs a confidence score or obtains a value through keyword matching, and using the value as the quality score; Step S4: Using an importance sampling algorithm, calculate the normalized weight of each inference path based on the target probability density and the proposal distribution probability; Step S5: Based on the normalized weights, the final diagnostic conclusions corresponding to multiple inference paths are weighted and aggregated, the category with the largest weighted sum is selected as the final prediction result, and the inference process in the inference path with the largest normalized weight is selected as the interpretable medical report for output.

2. The liver cancer prediction method based on a large language model with an improved sampling strategy according to claim 1, characterized in that, The static characteristics include gender, age, smoking history, and drinking history; the dynamic medical records include blood test results, disease diagnosis codes, and medication records from each visit, arranged in chronological order. The temporal reconstruction of the electronic medical record text data includes: arranging the dynamic diagnosis and treatment records in chronological order to form the vertical clinical text sequence containing timestamp information.

3. The liver cancer prediction method based on a large language model with an improved sampling strategy according to claim 1, characterized in that, The construction of the structured prompt word sequence that conforms to the input specifications of the large language model includes: concatenating the vertical clinical text sequence with the static features and concatenating the preset task instructions; the task instructions are used to instruct the general large language model to analyze the risk of liver cancer based on time-series medical records and output the corresponding judgment reasons.

4. The liver cancer prediction method based on a large language model with an improved sampling strategy according to claim 1, characterized in that, The method of generating multiple independent inference path sets in parallel using a random decoding strategy includes: generating inference paths that include intermediate inference processes and final diagnostic conclusions; The step of obtaining the original joint probability of each inference path generated by the general large language model as the proposal distribution probability includes: calculating the joint probability of the general large language model generating a complete inference path in an autoregressive manner under the given structured prompt word sequence.

5. The liver cancer prediction method based on a large language model with an improved sampling strategy according to claim 1, characterized in that, The probability density function of the gamma distribution includes shape parameters and scale parameters; The method for determining the shape parameter and the scale parameter includes: selecting a validation dataset containing high-quality inference path samples with expert annotations; The maximum likelihood estimation method is used to fit the sample distribution characteristics in the validation dataset, and the shape parameter values ​​and scale parameter values ​​that fit the current electronic medical record data distribution characteristics are calculated.

6. The liver cancer prediction method based on a large language model with an improved sampling strategy according to claim 1, characterized in that, The step of using an importance sampling algorithm to calculate the normalized weight of each inference path includes: calculating the original importance weight, which is defined as the ratio of the target probability density to the proposal distribution probability; The original importance weights of all parallel-generated inference paths are normalized by dividing the original importance weight of a single inference path by the sum of the original importance weights of all inference paths to obtain the normalized weight.

7. The liver cancer prediction method based on a large language model with an improved sampling strategy according to claim 1, characterized in that, The step of weighted aggregation of the final diagnostic conclusions corresponding to multiple inference paths based on the normalized weights includes: setting a diagnostic conclusion space; Calculate the weighted sum of the normalized weights of all inference paths corresponding to each category option in the diagnostic conclusion space; The category with the largest weighted sum is selected as the final prediction result.

8. A liver cancer prediction system based on a large language model with an improved sampling strategy, characterized in that, include: Memory, used to store computer programs and electronic medical record text data to be processed; A processor, coupled to the memory, is used to execute the computer program to implement the large language model liver cancer prediction method based on an improved sampling strategy as described in any one of claims 1-7.