Patient large model classification method and system based on memory and retrieval enhancement
By adopting a large-scale patient model classification method based on memory and retrieval enhancement in patient management, using knowledge examples and gating mechanisms in the knowledge base, the problem of insufficient patient classification accuracy in the prior art is solved, and more accurate and personalized .
Patent Information
- Application Number
- CN202411158833.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-22
- Publication Date
- 2024-12-17
- Estimated Expiration
- 2044-08-22
AI Technical Summary
The existing patient management methods fail to make full use of existing knowledge resources, and the single classification model lacks multi-dimensional information reference when dealing with complex conditions, resulting in insufficient patient classification accuracy.
Using a large-scale patient model classification method based on memory and search enhancement, by obtaining patient information, using the search module to extract relevant knowledge instances from the knowledge base, and incorporate them into the large language model through encoder and gating mechanism, dynamically adjusting knowledge instances weights to generate more accurate classification results.
It significantly improves the accuracy of patient classification, can provide personalized treatment suggestions based on the patient's specific condition, and uses multi-dimensional information reference to provide more effective and accurate treatment plans when dealing with complex conditions.
Smart Images

Figure CN119150066A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a patient large model classification method and system based on memory and retrieval enhancement. Background Art
[0002] In the field of patient management, the main goal of accurately classifying patients is to automatically assign patients to appropriate treatment or management pathways based on given patient information (including condition description, examination results, etc.). However, the current methods fail to fully utilize existing knowledge resources, and a single classification model lacks multi-dimensional information reference when dealing with complex conditions. Summary of the invention
[0003] Based on the technical problems existing in the background technology, the present invention proposes a patient large model classification method and system based on memory and retrieval enhancement, which can dynamically adjust the knowledge instances used according to the patient's specific condition, thereby significantly improving the accuracy of patient classification.
[0004] The patient macro-model classification method based on memory and retrieval enhancement proposed in the present invention inputs the current patient information into the trained medical macro-model to output the classification result of the patient information;
[0005] The training process of the medical big model is as follows:
[0006] Step 1: Obtain information of different patients to construct a training data set, and retrieve the corresponding knowledge instance s for the i-th data in the training data set through the retrieval module n ;
[0007] Step 2: Each knowledge instance n The latent representation of the knowledge instance is obtained by encoding with the encoder, and the latent representation of the knowledge instance is mapped to the key representation and the value representation through the key matrix and the value matrix. The latent representation of the i-th data is used as the query, and the weight of the knowledge instance corresponding to the i-th data is calculated based on the inner product between the key representation, the value representation and the query, and the weight of the knowledge instance is applied to the value representation to obtain the knowledge instance representation corresponding to the i-th data;
[0008] Step 3: Input the i-th data into the large language model, and use the gating mechanism to incorporate the knowledge instance representation corresponding to the i-th data into the information flow of the large language model, so as to output the classification result of the i-th data; construct a loss function based on the classification results of all data to adjust the trainable parameters in the medical large model.
[0009] Furthermore, in step 2, the knowledge instance corresponding to the i-th data is represented by a i,S The calculation is as follows:
[0010]
[0011]
[0012] Among them, p i,{n} represents the weight of the knowledge instance corresponding to the i-th data, Indicates the key representation corresponding to the i-th data, Indicates the value corresponding to the i-th data, h i,{X} represents the potential representation of the i-th data, * represents the vector inner product operation, S n Represents the retrieved knowledge instance.
[0013] Furthermore, in step three, the knowledge instance representation corresponding to the i-th data is incorporated into the information flow of the large language model using a gating mechanism, specifically:
[0014] The i-th data is encoded through the Transformer layer in the large language model;
[0015] The gating mechanism is used to incorporate the knowledge instance representation into the standard Transformer decoding process. The reset gate based on the gating mechanism balances the information in the large language model and the incorporated knowledge instance representation. The output of the last layer of Transformer passes through the fully connected layer and the softmax classifier in turn to output the classification result.
[0016] Among them, during the decoding process, the gating mechanism between the lth layer and the l+1th layer Transformer is calculated by the following formula to reset the gate:
[0017]
[0018] in, represents the reset gate of the lth layer corresponding to the i-th data, sigma represents the sigmoid function, represents the output of the lth layer Transformer, and is the trainable parameter of the lth layer Transformer, a i,S Represents the knowledge instance representation corresponding to the i-th data.
[0019] Furthermore, the reset gate based on the gating mechanism balances the information in the large language model and the representation of the incorporated knowledge instances, specifically:
[0020]
[0021] in, is the output of the l-th layer Transformer; 1 is a matrix with the same dimensions as the reset gate, and all values are 1, Represents the input of the l+1th layer Transformer.
[0022] Based on the patient big model classification system enhanced by memory and retrieval, the current patient information is input into the trained medical big model to output the classification result of the patient information;
[0023] The training process of the medical big model is as follows:
[0024] Step 1: Obtain information of different patients to construct a training data set, and retrieve the corresponding knowledge instance for the i-th data in the training data set through a retrieval module;
[0025] Step 2: Encode each knowledge instance through the encoder to obtain the potential representation of the knowledge instance, map the potential representation of the knowledge instance to the key representation and value representation through the key matrix and the value matrix, take the potential representation of the i-th data as the query, calculate the weight of the knowledge instance corresponding to the i-th data based on the inner product between the key representation, the value representation and the query, and apply the weight of the knowledge instance to the value representation to obtain the knowledge instance representation corresponding to the i-th data;
[0026] Step 3: Input the i-th data into the large language model, and use the gating mechanism to incorporate the knowledge instance representation corresponding to the i-th data into the information flow of the large language model, so as to output the classification result of the i-th data; construct a loss function based on the classification results of all data to adjust the trainable parameters in the medical large model.
[0027] Furthermore, in step three, the knowledge instance representation corresponding to the i-th data is incorporated into the information flow of the large language model using a gating mechanism, specifically:
[0028] The i-th data is encoded through the Transformer layer in the large language model;
[0029] The gating mechanism is used to incorporate the knowledge instance representation into the standard Transformer decoding process. The reset gate based on the gating mechanism balances the information in the large language model and the incorporated knowledge instance representation. The output of the last layer of Transformer passes through the fully connected layer and the softmax classifier in turn to output the classification result.
[0030] Among them, during the decoding process, the gating mechanism between the lth layer and the l+1th layer Transformer is calculated by the following formula to reset the gate:
[0031]
[0032] in, represents the reset gate of the lth layer, sigma represents the sigmoid function, represents the output of the lth layer Transformer, and is the trainable parameter of the lth layer Transformer, a i,S Represents the knowledge instance representation corresponding to the i-th data;
[0033] Furthermore, the reset gate based on the gating mechanism balances the information in the large language model and the representation of the incorporated knowledge instances, specifically:
[0034]
[0035] in, is the output of the lth layer Transformer and the input of the l+1th layer Transformer; 1 is a matrix with the same dimension as the reset gate, and all values are 1.
[0036] The advantages of the patient large model classification method and system based on memory and retrieval enhancement provided by the present invention are: the patient large model classification method and system based on memory and retrieval enhancement provided in the structure of the present invention, (1) improve the accuracy of patient classification: this embodiment uses a memory plug-in to extract relevant knowledge instances from the knowledge base, and combines comparative learning to optimize the knowledge encoding and modeling process of the memory plug-in, so that LLM can better utilize new knowledge. Compared with the traditional single classification model, this embodiment can dynamically adjust the knowledge instances used according to the patient's specific condition, thereby significantly improving the accuracy of patient classification; (2) provide personalized treatment suggestions: the present invention introduces a gating mechanism in LLM, so that it can generate classification results by comprehensively weighting the knowledge instances. This not only improves the performance of the medical large model, but also enables it to provide more personalized treatment suggestions based on the patient's specific situation. Compared with traditional methods, this embodiment can better utilize multi-dimensional information references, thereby providing more effective and accurate treatment plans when dealing with complex conditions. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] Figure 1 It is a structural schematic diagram of the present invention;
[0038] Figure 2 Training flowchart for medical large models. DETAILED DESCRIPTION
[0039] Below, the technical solution of the present invention is described in detail through specific embodiments. Many specific details are set forth in the following description to facilitate a full understanding of the present invention. However, the present invention can be implemented in many other ways different from those described herein, and those skilled in the art can make similar improvements without violating the connotation of the present invention. Therefore, the present invention is not limited to the specific implementation disclosed below.
[0040] The medical big model of this embodiment is built based on the big language model (LLM) and the memory plug-in, so that the trained medical big model can use the memory plug-in to extract and encode relevant knowledge instances from the knowledge base, thereby making better use of new knowledge. At the same time, LLM combines the gating mechanism to generate classification results by comprehensively weighting the knowledge instances. This embodiment not only improves the accuracy of patient classification, but also provides personalized treatment recommendations based on the patient's specific condition, as described in detail below.
[0041] like Figure 1 and 2 As shown, the patient big model classification method based on memory and retrieval enhancement proposed by the present invention inputs the current patient information into the trained medical big model to output the classification result of the patient information;
[0042] The training process of the medical big model is as follows:
[0043] Step 1: Obtain information of different patients to construct a training data set, and retrieve the corresponding knowledge instance for the i-th data in the training data set through a retrieval module;
[0044] The retrieval module obtains the knowledge instance corresponding to the i-th data from existing resources, that is, using the existing toolkit to extract knowledge instances based on the input and knowledge base (e.g., Wikipedia), where these knowledge instances can guide the LLM to generate the correct response. This makes the classification results generated by the medical big model more consistent with the existing classification rules and reduces the misclassification results.
[0045] Step 2: Each knowledge instance n The latent representation of the knowledge instance is obtained by encoding with the encoder, and the latent representation of the knowledge instance is mapped to the key representation and the value representation through the key matrix and the value matrix. The latent representation of the i-th data is used as the query, and the weight of the knowledge instance corresponding to the i-th data is calculated based on the inner product between the key representation, the value representation and the query, and the weight of the knowledge instance is applied to the value representation to obtain the knowledge instance representation corresponding to the i-th data;
[0046] In order to better utilize these knowledge instances in step 1 and incorporate them into LLM, this embodiment proposes a memory plug-in, which includes a knowledge encoder and a memory mechanism. First, a knowledge encoder (for example, a Transformer encoder) is used to extract their potential representations. Specifically, each knowledge instance s i,n The input is passed to the encoder and its latent representation is calculated through the final encoding layer:
[0047]
[0048] in, Knowledge Instancesi,n The potential representation of s i,n is the knowledge instance corresponding to the i-th data, f {KE} For the encoder.
[0049] Based on the memory mechanism, knowledge instances i,n Potential representation of Further data processing: For each knowledge instance, its extracted latent representation is mapped to the key representation using the key matrix and value matrix Sum value representation Then, using the latent representation h of the input i,{X} as the query, and calculate the weight of each knowledge instance based on their inner product:
[0050]
[0051] Among them, p i,{n} represents the weight of the knowledge instance corresponding to the i-th data, The key indicates that, Indicates the value, h i,{X} represents the potential representation of the i-th data, and * represents the vector inner product operation.
[0052] It should be noted that h i,{X} represents the potential representation of the i-th data, that is, the potential representation corresponding to the input, and is the potential representation of the knowledge instance, that is, it corresponds to the knowledge instance S retrieved by the retrieval module based on the input as the index. i,n The corresponding potential representations, the process of obtaining the potential representations is the same for both, both are implemented through encoders, but the input of the encoding is different.
[0053] In addition, when the i-th data is used as input, the number of knowledge instances retrieved by the retrieval module is one or more. The multiple knowledge representations corresponding to the same input can be distinguished by different values of n. That is, when the same input corresponds to 4 knowledge instances, n = 1, 2, 3, 4, corresponding to s i,1 ,s i,2 ,s i,3 ,s i,4 , for each knowledge instance, just follow steps 2 and 3 in sequence.
[0054] The obtained weight p i,{n} Applied to the corresponding value representation, and the knowledge instance representation a is obtained by the following formula i,S :
[0055]
[0056] Among them, sum is the total.
[0057] Through step 2, different knowledge instances are assigned different weights according to the input. Therefore, knowledge instances that are critical to modeling the input receive higher weights than those that are less important. The weighted knowledge instance representation contains key information for generating input responses and is incorporated in the subsequent LLM processing, thereby improving the classification accuracy of the medical large model.
[0058] Step 3: Input the i-th data into the large language model, and use the gating mechanism to incorporate the knowledge instance representation corresponding to the i-th data into the information flow of the large language model, so as to output the classification result of the i-th data; construct a loss function based on the classification results of all data to adjust the trainable parameters in the medical large model.
[0059] Hints to LLM have a significant impact on the performance of LLM. Therefore, once knowledge instances are encoded and weighted, how the resulting knowledge representation is incorporated into LLM plays an important role in guiding LLM to generate responses. Intuitively, the contribution of knowledge information in different contexts may be different. For example, knowledge obtained from the memory module may be less important in the case that LLM has already learned such knowledge. Therefore, it is crucial to balance the contribution of knowledge information when incorporating it into LLM.
[0060] This embodiment proposes to use a gating module to control the information flow when incorporating knowledge information into the LLM. Specifically, the input text is first input into the LLM and encoded through the Transformer layers in the LLM. For each pair of connected Transformer layers in the LLM, a gating mechanism is used to incorporate the knowledge instance representation into the standard Transformer decoding process. The gating mechanism between the lth layer and the l+1th layer Transformer is calculated by the following formula to reset the gate:
[0061]
[0062] in, represents the reset gate of the lth layer corresponding to the i-th data, sigma represents the sigmoid function, represents the output of the lth layer Transformer, and is the trainable parameter of the lth layer Transformer, a i , S represents the knowledge instance representation corresponding to the i-th data.
[0063] The reset gate based on the gating mechanism balances the information in the large language model and the representation of the incorporated knowledge instances, specifically:
[0064]
[0065] in, is the output of the lth layer Transformer and the input of the l+1th layer Transformer; 1 is a matrix with the same dimension as the reset gate, and all values are 1.
[0066] at last, The input is fed into the next Transformer layer, and the output of the last Transformer layer is obtained by following the standard decoding process. According to the convention of the standard Transformer decoder, the last hidden vector of the matrix is fed into a fully connected layer and the output tag is predicted by a softmax classifier to form the output.
[0067] Through steps one to three, this embodiment aims to generate a response (e.g., an answer) based on a given input text (e.g., a question) by utilizing a list of knowledge instances obtained from existing resources (e.g., an information retrieval system). The entire method architecture includes two parts, namely a memory plug-in and a gated large model (LLM). The memory plug-in uses the knowledge encoding process to extract the potential features of the knowledge instances, and then uses the memory module to weight these encoded knowledge instances according to their contribution to solving the test examples; the LLM prompting process uses the encoded and weighted knowledge to generate output, thereby obtaining a medical large model that can accurately classify the input.
[0068] Whether this embodiment is suitable for the classification of different levels or directions of diseases, such as liver disease and mental illness, inputting training data sets for different diseases to obtain medical large models for different diseases, this embodiment has the following advantages:
[0069] (1) Improving the accuracy of patient classification: This embodiment uses a memory plug-in to extract relevant knowledge instances from the knowledge base, and combines contrastive learning to optimize the knowledge encoding and modeling process of the memory plug-in, so that the LLM can better utilize new knowledge. Compared with the traditional single classification model, this embodiment can dynamically adjust the knowledge instances used according to the specific condition of the patient, thereby significantly improving the accuracy of patient classification.
[0070] (2) Providing personalized treatment suggestions: The present invention introduces a gating mechanism into the LLM, which enables it to generate classification results by integrating weighted knowledge instances. This not only improves the performance of the medical large model, but also enables it to provide more personalized treatment suggestions based on the patient's specific situation. Compared with traditional methods, this embodiment can better utilize multi-dimensional information references, thereby providing more effective and accurate treatment plans when dealing with complex diseases.
[0071] The above description is only a preferred specific implementation manner of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can make equivalent replacements or changes according to the technical scheme and inventive concept of the present invention within the technical scope disclosed by the present invention, which should be covered by the protection scope of the present invention.
Claims
1. A patient large model classification method based on memory and retrieval enhancement, characterized in that: Input the current patient information into the trained medical model to output the classification result of the patient information; The training process of the medical big model is as follows: Step 1: Obtain information of different patients to construct a training data set, and retrieve the corresponding knowledge instance for the i-th data in the training data set through a retrieval module; Step 2: Encode each knowledge instance through the encoder to obtain the potential representation of the knowledge instance, map the potential representation of the knowledge instance to the key representation and value representation through the key matrix and the value matrix, take the potential representation of the i-th data as the query, calculate the weight of the knowledge instance corresponding to the i-th data based on the inner product between the key representation, the value representation and the query, and apply the weight of the knowledge instance to the value representation to obtain the knowledge instance representation corresponding to the i-th data; Step 3: Input the i-th data into the large language model, and use the gating mechanism to incorporate the knowledge instance representation corresponding to the i-th data into the information flow of the large language model, thereby outputting the classification result of the i-th data; A loss function is constructed based on the classification results of all data to adjust the trainable parameters in the medical big model.
2. The patient large model classification method based on memory and retrieval enhancement according to claim 1 is characterized in that: In step 2, the knowledge instance corresponding to the i-th data is represented by a i,S The calculation is as follows: Among them, p i,{n} represents the weight of the knowledge instance corresponding to the i-th data, Indicates the key representation corresponding to the i-th data, Indicates the value corresponding to the i-th data, h i,{X} represents the potential representation of the i-th data X, * represents the vector inner product operation, S n Represents the retrieved knowledge instance.
3. The patient large model classification method based on memory and retrieval enhancement according to claim 1 is characterized in that: In step 3, the knowledge instance representation corresponding to the i-th data is incorporated into the information flow of the large language model using the gating mechanism, specifically: The i-th data is encoded through the Transformer layer in the large language model; The gating mechanism is used to incorporate the knowledge instance representation into the standard Transformer decoding process. The reset gate based on the gating mechanism balances the information in the large language model and the incorporated knowledge instance representation. The output of the last layer of Transformer passes through the fully connected layer and the softmax classifier in turn to output the classification result. Among them, during the decoding process, the gating mechanism between the lth layer and the l+1th layer Transformer is calculated by the following formula to reset the gate: in, represents the reset gate of the lth layer corresponding to the i-th data, sigma represents the sigmoid function, represents the output of the lth layer Transformer, and is the trainable parameter of the lth layer Transformer, a i,S Represents the knowledge instance representation corresponding to the i-th data.
4. The patient large model classification method based on memory and retrieval enhancement according to claim 3 is characterized in that: The reset gate based on the gating mechanism balances the information in the large language model and the representation of the incorporated knowledge instances, specifically: in, is the output of the l-th layer Transformer; 1 is a matrix with the same dimensions as the reset gate, and all values are 1, Represents the input of the l+1th layer Transformer.
5. A patient model classification system based on memory and retrieval enhancement, characterized in that: Input the current patient information into the trained medical model to output the classification result of the patient information; The training process of the medical big model is as follows: Step 1: Obtain information of different patients to construct a training data set, and retrieve the corresponding knowledge instance for the i-th data in the training data set through a retrieval module; Step 2: Encode each knowledge instance through the encoder to obtain the potential representation of the knowledge instance, map the potential representation of the knowledge instance to the key representation and value representation through the key matrix and the value matrix, take the potential representation of the i-th data as the query, calculate the weight of the knowledge instance corresponding to the i-th data based on the inner product between the key representation, the value representation and the query, and apply the weight of the knowledge instance to the value representation to obtain the knowledge instance representation corresponding to the i-th data; Step 3: Input the i-th data into the large language model, and use the gating mechanism to incorporate the knowledge instance representation corresponding to the i-th data into the information flow of the large language model, thereby outputting the classification result of the i-th data; A loss function is constructed based on the classification results of all data to adjust the trainable parameters in the medical big model.
6. The patient large model classification system based on memory and retrieval enhancement according to claim 5 is characterized in that: In step 3, the knowledge instance representation corresponding to the i-th data is incorporated into the information flow of the large language model using the gating mechanism, specifically: The i-th data is encoded through the Transformer layer in the large language model; The gating mechanism is used to incorporate the knowledge instance representation into the standard Transformer decoding process. The reset gate based on the gating mechanism balances the information in the large language model and the incorporated knowledge instance representation. The output of the last layer of Transformer passes through the fully connected layer and the softmax classifier in turn to output the classification result. Among them, during the decoding process, the gating mechanism between the lth layer and the l+1th layer Transformer is calculated by the following formula to reset the gate: in, represents the reset gate of the lth layer, sigma represents the sigmoid function, represents the output of the lth layer Transformer, and is the trainable parameter of the lth layer Transformer, a i,S Represents the knowledge instance representation corresponding to the i-th data.
7. The patient large model classification system based on memory and retrieval enhancement according to claim 6 is characterized in that: The reset gate based on the gating mechanism balances the information in the large language model and the representation of the incorporated knowledge instances, specifically: in, is the output of the lth layer Transformer and the input of the l+1th layer Transformer; 1 is a matrix with the same dimension as the reset gate, and all values are 1.
Citation Information
Patent Citations
Medical large model question and answer method based on memory and reinforcement learning optimization
CN118428412A
Methods and apparatus for a knowledge-based deep learning refactoring model with tightly integrated functional nonparametric memory
US20220101096A1
