Early screening model temperature parameter dynamic adjustment method and device, equipment and storage medium
By dynamically adjusting the attention temperature parameter and combining medical features and loss function optimization, the problem of insufficient accuracy and robustness of existing attention mechanisms in multimodal recognition tasks is solved. This achieves effective focusing on key lesions and context awareness, improving the accuracy and adaptability of stroke recognition.
Patent Information
- Application Number
- CN202511555416.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-29
- Publication Date
- 2026-02-27
- Estimated Expiration
- 2045-10-29
AI Technical Summary
Existing attention mechanisms suffer from unexplained temperature regulation, lack of input adaptation, and absence of statistical driving mechanisms in early identification tasks such as stroke, resulting in insufficient accuracy and robustness of the models in multimodal information fusion.
By dynamically adjusting the attention temperature parameter based on medical features such as lesion coverage, lesion focus intensity, multimodal conflict index, and diagnostic confidence entropy, and combining this with a loss function for joint optimization, dynamic adjustment of the attention score can be achieved.
It significantly improves the model's performance in multimodal tasks, enhances its ability to focus on key lesions and its context awareness, improves the accuracy and robustness of early identification, and adapts to the feature differences of different inputs.
Smart Images

Figure CN121034649B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of large model, in particular, relates to an early screening model temperature parameter dynamic adjustment method and device, equipment and storage medium. BACKGROUND
[0002] In recent years, deep neural networks based on Transformer have achieved great success in natural language processing, computer vision, and multi-modal learning tasks. The core of Transformer lies in the self-attention mechanism, in which the similarity between Query and Key is calculated and the attention score is obtained through softmax operation, so as to realize the weighted modeling of different position features.
[0003] At present, in the intelligent auxiliary diagnosis task of early identification such as stroke, the model needs to process multiple modal information such as image (such as head CT / MRI), text (medical record description), and structured indicators (such as blood pressure, blood sugar, etc.). There is heterogeneity and feature sparsity among these modalities, which puts higher requirements on the attention mechanism of the model: on the one hand, it needs to focus on key lesion areas or symptom descriptions to ensure the accuracy of prediction; on the other hand, it needs to flexibly integrate information among different modalities to improve the generalization ability. This requires the attention mechanism to have controllability, interpretability, and input adaptability.
[0004] In order to regulate the distribution of attention scores, traditional methods usually introduce a fixed scaling factor (such as ) before softmax, or add a temperature parameter T, such as , to control the steepness of the softmax output. However, in most existing methods, the value of this temperature parameter is either globally fixed or introduced as a learnable scalar parameter per layer or per attention head, and optimized during training through backpropagation. Although this "independent learnable temperature per head" method improves the model performance and attention expression ability to some extent, it still has the following shortcomings:
[0005] 1. No interpretability: although the learnable parameter is trained end-to-end, there is no clear optimization direction, and the parameter update is not guided by the specific optimization direction;
[0006] 2. Lack of input adaptability: the temperature parameter is learned only through model training, and cannot be dynamically adjusted according to the specific characteristics of the input sample or attention distribution, making it difficult to adapt to the feature differences between different inputs and lacking robustness;
[0007] 3. No statistical quantity driven mechanism: existing methods do not have a statistical quantity driven mechanism for the attention score matrix (such as lack of explicit modeling and regulation of attention distribution structure, which may limit the accuracy of model training; because the single learnable parameter has a dimension of 1, it is difficult to capture the corresponding information and update it appropriately; there is no statistical quantity driving, or simple statistical quantities such as mean and variance are used as input, which is too simple and cannot fully measure the uncertainty of the attention matrix;
[0008] 4. Not optimized with loss function: temperature regulation is usually only used as an intermediate module in forward propagation and is not included in the loss function for joint optimization, which limits the performance upper limit under task target constraints;
[0009] 5. The temperature adaptive coefficient does not combine the unique needs of the medical scene, such as the small size of the lesion area and the small pixel ratio.
[0010] Therefore, in the task background of stroke recognition, which requires high precision, diversity, heterogeneous fusion, and sparse information perception, there is an urgent need for a temperature adaptive, statistically driven, hierarchical control, and medical scene picture feature compatible attention regulation mechanism. SUMMARY
[0011] The present application provides a method for dynamically adjusting the temperature parameters of an early screening model, which solves the technical problems of uninterpretable temperature regulation, lack of input adaptability, and lack of statistical driving mechanism in existing attention mechanisms.
[0012] The present application is implemented by the following scheme:
[0013] The method for dynamically adjusting the temperature parameters of an early screening model includes the following steps:
[0014] S1, obtaining key medical features including lesion coverage, lesion focus intensity, multi-modal conflict index, and diagnosis confidence entropy according to the attention score matrix A of the large model and the lesion mask graph M based on the features of the medical picture;
[0015] S2, dynamically calculating and outputting the final value of the temperature parameter of each attention head in each multi-head attention module of the large model using the lesion coverage, lesion focus intensity, multi-modal conflict index, and diagnosis confidence entropy as input features;
[0016] S3, scaling the original attention score of each attention head in the corresponding multi-head attention module according to the final value of the calculated temperature parameter to realize dynamic adjustment of the attention score of each layer.
[0017] Further, in step S1,
[0018] An attention score matrix A ∈ R {dimension n × n}, a lesion mask map M ∈ {0, 1} {dimension n × n} generated by a lightweight segmentation network;
[0019] The lesion coverage refers to the proportion of attention in the lesion area, and is expressed as:
[0020] Cover = ∑ (A ⊙ M) / ∑ A;
[0021] The lesion focus intensity refers to the maximum attention difference between the lesion and the non-lesion, and is expressed as:
[0022] Focus = max (A ⊙ M) - max (A ⊙ (1-M));
[0023] The multi-modal conflict index refers to the difference in attention entropy between image and text modalities, and is expressed as:
[0024]
[0025] H(•) represents the entropy of the attention distribution, A img represents the attention score matrix of the image modality; A text represents the attention score matrix of the text modality;
[0026] The diagnostic confidence entropy refers to the uncertainty measure of the lesion probability distribution labeled by the doctor, and the higher the entropy value, the more dispersed the lesion distribution labeled by the doctor, and is expressed as:
[0027]
[0028] wherein, is the lesion probability distribution labeled by the doctor.
[0029] Further, the step S2 specifically comprises the steps of:
[0030] S21, determining the corresponding base temperature according to the value of the lesion coverage T base
[0031] S22, inputting the lesion coverage Cover, the lesion focus intensity Focus, and the multi-modal conflict index Conflict into a small neural network to output a temperature adjustment amount T adj Then, the temporary temperature value is calculated as:
[0032]
[0033] wherein, the small neural network comprises an MLP, a 1D convolutional network (1D-CNN), and a gated linear unit, and α is a learnable parameter with an initial value of 0.1.
[0034] S23, diagnose confidence constraint, obtain doctor diagnosis confidence entropy As a constraint, the final temperature value T is calculated:
[0035] ;
[0036] S24, output the final temperature value T to the attention module, and ensure that the T value is in the valid range of [0.3, 2.0].
[0037] Further, in step S21, when the lesion coverage is greater than 0.25, the base temperature T base is set to [0.3, 0.7], and when the lesion coverage is less than or equal to 0.25, the base temperature T base is set to [1.0, 1.4].
[0038] Further, in the step S3, the original attention score of each attention head in the corresponding multi-head attention module is scaled according to the final value of the temperature parameter calculated, specifically:
[0039] ;
[0040] ;
[0041] Wherein, A i,j is the original attention score matrix of each attention head in the multi-head attention module of each layer, i represents the layer index of the multi-head attention module, j represents the index of the multi-head attention head in the layer, and comes from QK T , which has not been processed by softmax; T i,j is the final temperature value of the jth attention head in the ith multi-head attention module calculated, which is used to scale the attention score; is the attention score matrix after temperature scaling; Attention i,j is the attention score of the jth attention head in the ith multi-head attention module after softmax processing, which is used to control the output attention distribution, and the larger the temperature, the more gentle the distribution; the smaller the temperature, the more concentrated the distribution.
[0042] Further, it further comprises the following steps:
[0043] S4, combined with the loss function or the regularization term, the rationality of the temperature and the target task performance are jointly modeled through the loss function, the temperature regularization term or the distribution preference constraint of the attention distribution is added, the model performance is improved, and the training stability is enhanced.
[0044] Further, the step S4 specifically comprises the steps of:
[0045] S41, by temperature offset regularization term L temp Constraining the temperature parameter to limit the change amplitude, promoting training stability:
[0046] ;
[0047] Wherein, T0 is the expected temperature value for constraining temperature offset; λ is the regularization term weight, which is a hyperparameter, used to control the weight of the temperature offset regularization term, λ∈[0.001, 0.1], dynamically adjusted according to training stability; L temp Is the temperature offset regularization term, used to limit the offset of the temperature parameter, prevent the temperature from being too high / low out of control, and promote the stable convergence of the model within a reasonable temperature range;
[0048] S42, by distribution structure constraint term L atten-structure Encourage the generated attention distribution to have a more reasonable entropy value or rank structure:
[0049] ;
[0050] Wherein: H(Attention i,j ) is the entropy of the attention distribution after softmax, used to measure the dispersion degree of the distribution; H0 is the target entropy, set according to the task; γ is a hyperparameter, controlling the influence weight of this term in the total loss function; L atten-structure Control the structure of the attention distribution output by the model, suppress the attention collapse phenomenon, and enhance the ability to adapt to different tasks;
[0051] S43, fusion with the main task loss to get the final training target overall loss function:
[0052] ;
[0053] Wherein, L task Is the loss function of the main task text generation; α and β are key adjustment factors, with a value range of [0.01, 0.5], used to balance the optimization process between the task target and the rationality of the attention distribution.
[0054] Another aspect of the present application also provides an early screening model temperature parameter dynamic adjustment device, comprising:
[0055] A key medical feature acquisition module is configured to obtain key medical features including lesion coverage, lesion focus intensity, multi-modal conflict index, and diagnosis confidence entropy, according to an attention score matrix A of a large model and a lesion mask graph M obtained based on medical picture features.
[0056] a temperature parameter dynamic calculation module, configured to dynamically calculate and output final values of temperature parameters of each attention head in each multi-head attention module of the large model, with the lesion coverage, the lesion focus intensity, the multi-modal conflict index, and the diagnostic confidence entropy as input features;
[0057] a dynamic attention score adjustment module, configured to scale original attention scores of each attention head in each multi-head attention module according to the final values of the temperature parameters, to realize dynamic adjustment of the attention scores of each layer.
[0058] In another aspect, the present application also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the early screening model temperature parameter dynamic adjustment method when executing the computer program.
[0059] In another aspect, the present application also provides a storage medium, comprising a stored program, wherein the program controls the device where the storage medium is located to perform the steps of the early screening model temperature parameter dynamic adjustment method when the program is executed.
[0060] Compared with the prior art, the present application has the following beneficial effects:
[0061] 1. Improved flexibility and expressiveness of attention mechanism: the present application dynamically analyzes the attention score matrix and adaptively adjusts the attention temperature according to the actual input content, which significantly enhances the adaptation ability of the model under different inputs and different modalities, and avoids excessive concentration or dispersion of attention distribution;
[0062] 2. Good interpretability and controllability: unlike the traditional use of fixed temperature or learnable temperature parameters, the value of the temperature parameter of the present application is guided and updated by the information defined by the medical image features, which is helpful for model visualization and reviewability in medical tasks;
[0063] 3. Significantly improved performance of the model in multi-modal tasks: in medical tasks such as stroke recognition, which are multi-modal, feature sparse, and high-precision, the model can flexibly adapt to the differences in information fusion between images and texts, so that the model can focus on key lesions and maintain sufficient perception of context clues, thereby effectively improving the accuracy and robustness of early identification;
[0064] 4. Enhanced robustness and reliability of the model in real medical scenarios: for heterogeneous inputs (such as medical record texts and image features) and abnormal samples (such as stroke boundary fuzzy samples), the adaptive temperature adjustment mechanism can automatically adjust the attention range and focusing ability, reduce the model misjudgment rate, and improve the clinical applicability in actual deployment.
[0065] In addition to the purposes, features and advantages described above, the present application has other purposes, features and advantages. The present application will be described in further detail below with reference to the drawings. BRIEF DESCRIPTION OF DRAWINGS
[0066] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and serve to explain the principles of the present application, together with the description.
[0067] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the drawings required to be used in the embodiments or prior art description will be briefly introduced as follows. Obviously, for those of ordinary skill in the art, other drawings can also be obtained based on these drawings without any creative effort.
[0068] Figure 1 is a flow chart of a method for dynamically adjusting temperature parameters of an early screening model according to a preferred embodiment of the present application;
[0069] Figure 2 is a schematic diagram of a device module for dynamically adjusting temperature parameters of an early screening model according to a preferred embodiment of the present application;
[0070] Figure 3 is a schematic block diagram of an electronic device according to a preferred embodiment of the present application;
[0071] Figure 4 is an internal structure diagram of a computer device according to a preferred embodiment of the present application. DETAILED DESCRIPTION
[0072] It should be understood that the specific embodiments described herein are merely intended to explain the technical solutions of the present application, and are not intended to limit the present application.
[0073] In order to better understand the technical solutions of the present application, the present application will be described in detail below with reference to the drawings and specific embodiments.
[0074] It should be noted that the execution subject of the present embodiment can be a computing service device with data processing, network communication and program running functions, such as a tablet computer, a personal computer, a mobile phone, etc., or an early screening model temperature parameter dynamic adjustment device capable of realizing the above functions. The following will take the early screening model temperature parameter dynamic adjustment device as an example to describe the present embodiment and the following embodiments.
[0075] As shown in Figure 1 , the preferred embodiment of the present application provides a method for dynamically adjusting temperature parameters of an early screening model, comprising the steps of:
[0076] S1, obtain key medical features including lesion coverage, lesion focus intensity, multi-modal conflict index, and diagnosis confidence entropy from the attention score matrix A of the large model and the features based on the medical picture to obtain a lesion mask picture M;
[0077] S2, use the lesion coverage, lesion focus intensity, multi-modal conflict index, and diagnosis confidence entropy as input features to dynamically calculate and output the final value of the temperature parameter of each attention head in each multi-head attention module of the large model;
[0078] S3, scale the original attention score of each corresponding attention head in each corresponding multi-head attention module according to the final value of the calculated temperature parameter to achieve dynamic adjustment of the attention score of each layer.
[0079] The prior art is either a simple statistical quantity or an meaningless updated parameter, without combining the features of medical pictures. The present embodiment strongly correlates the features with the anatomical characteristics of the lesion, i.e., by using statistical quantities with clear physical meaning as input features, the meaning and direction of parameter optimization can be explicitly specified. In addition, the present embodiment introduces multi-modal conflict detection (a unique challenge in stroke), which changes the simple temperature self-adaptive mechanism into a "clinically lesion-driven" dynamic decision module. For the first time, "lesion coverage, lesion focus intensity, multi-modal conflict index, and diagnosis confidence entropy" are used as direct inputs of the temperature network, with good interpretability and controllability. In addition, the large model has a temperature parameter when generating content. When the temperature parameter is high, the output content is more creative but less accurate. When the temperature parameter is low, the accuracy is higher and the certainty is higher. In the prior art, this temperature parameter generally refers to a temperature parameter when the token is output by the last Transformer module. The present embodiment is more detailed in the control of each layer in the model, i.e., there is a temperature parameter in each Transformer module and it is dynamically adjusted, rather than only a temperature parameter when the token is output by the last Transformer module.
[0080] Compared with the prior art, the early screening model temperature parameter dynamic adjustment method provided by the present embodiment has the following advantages:
[0081] 1. Improve the flexibility and expressiveness of the attention mechanism: by dynamically analyzing the attention score matrix and adaptively adjusting the attention temperature according to the actual input content, the present embodiment significantly enhances the model's adaptability to different inputs and different modalities, avoiding excessive concentration or dispersion of attention distribution;
[0082] 2. Good interpretability and controllability: Unlike traditional fixed temperature or learnable temperature parameters, the value of the temperature parameter in the present embodiment is guided by the information defined by the medical image features to update, which helps to visualize the model and improve the reviewability in medical tasks;
[0083] 3. Significantly improve the performance of the model in multi-modal tasks: In this embodiment, in medical tasks such as stroke recognition, which are multi-modal, feature sparse, and require high precision, the model can flexibly adapt to the differences in information fusion between images and text, focusing on key lesions while maintaining sufficient perception of contextual clues, thereby effectively improving the accuracy and robustness of early recognition.
[0084] 4. Enhance the robustness and reliability of the model in real medical scenarios: For heterogeneous inputs (such as medical records and image features) and abnormal samples (such as stroke boundary ambiguous samples), the adaptive temperature adjustment mechanism can automatically adjust the attention range and focusing ability, reducing the model's misjudgment rate and improving the clinical applicability in actual deployment.
[0085] Specifically, in step S1, the attention score matrix A ∈ R{dimension n × n}, and the lesion mask M ∈ {0, 1}{dimension n × n} are generated by a lightweight segmentation network, such as a commonly used U-Net segmentation network.
[0086] The lesion coverage refers to the proportion of attention in the lesion area, represented as:
[0087] Cover = ∑(A ⊙ M) / ∑A;
[0088] The lesion focusing intensity refers to the maximum attention difference between the lesion and non-lesion, represented as:
[0089] Focus = max(A ⊙ M) - max(A ⊙ (1-M));
[0090] The multi-modal conflict index refers to the difference in attention entropy between image and text modalities, represented as:
[0091] ;
[0092] H(•) represents the entropy of the attention distribution, with the specific formula: , A img Aimg represents the attention score matrix of the image modality. A text Atext represents the attention score matrix of the text modality. The diagnosis confidence entropy refers to the uncertainty measure of the physician's labeled lesion probability distribution. The higher the entropy value, the more dispersed the physician's labeled lesion distribution (the higher the diagnostic uncertainty), represented as:
[0093] ;
[0094] where, is the physician's labeled lesion probability distribution.
[0095] The embodiment obtains a lesion mask map M according to the attention score matrix A of the large model and the features based on the medical picture to obtain key medical features to guide the update of the temperature parameter value, including lesion coverage, lesion focus intensity, multi-modal conflict index, diagnosis confidence entropy, etc. Unlike the traditional use of fixed temperature or learnable temperature parameters, the value of the temperature parameter of the embodiment is guided to update by the information defined by the medical image features, which helps the model visualization and the reviewability in the medical task, and has good explainability and controllability.
[0096] Preferably, the step S2 specifically comprises the steps of:
[0097] S21, determining a corresponding base temperature according to the value of the lesion coverage T base , for example, when the lesion coverage is greater than 0.25, the base temperature is set to T base [0.3, 0.7], wherein the lower limit 0.3 can enhance the lesion focusing ability (suitable for small lesions), and the upper limit 0.7 prevents feature loss caused by excessive focusing, and the embodiment preferably sets the base temperature T base to 0.5; when the lesion coverage is less than or equal to 0.25, the base temperature is set to T base [1.0, 1.4], and the embodiment preferably sets the base temperature T base to 1.2.
[0098] S22, inputting the lesion coverage Cover, the lesion focus intensity Focus, and the multi-modal conflict index Conflict into a small neural network to output a temperature adjustment amount T adj , and then calculating a temporary temperature value:
[0099] ;
[0100] , wherein the small neural network includes MLP, 1D convolution network (1D-CNN), Gated Linear Unit (GLU), etc., and the embodiment adopts MLP, and α is a learnable parameter with an initial value of 0.1;
[0101] S23, diagnosis confidence constraint, obtaining a doctor's diagnosis confidence entropy as a constraint, to calculate a final temperature value T:
[0102] ;
[0103] S24, output the final temperature value T to the attention module, and ensure that the T value is in the effective range of [0.3, 2.0].
[0104] After the small neural network MPL, the calculation formula of the final temperature T is (i.e. temperature mapping function):
[0105] ;
[0106] Wherein:
[0107] T base =0.5 (when Cover>0.25) or 1.2 (when Cover≤0.25);
[0108] MLP() is a small neural network, and the input is Cover, Focus, and Conflict, three medical features;
[0109] The final T value is constrained in the range of [0.3, 2.0].
[0110] The embodiment has the following advantages:
[0111] The clinical decision-making orientation is realized, and the embodiment switches between "focus mode" (0.5) and "search mode" (1.2) according to the lesion coverage, simulating the doctor's diagnosis thinking;
[0112] The medical feature driving is implemented, and the embodiment uses three exclusive medical features of lesion coverage (Cover), focus intensity (Focus), and multi-modal conflict (Conflict), which is helpful for model visualization and reviewability in medical tasks.
[0113] Professional constraint mechanism, the embodiment introduces the doctor's diagnosis confidence H diag As the upper limit of temperature, it ensures that it meets the medical judgment standard;
[0114] Lightweight and efficient design, the embodiment only needs a small MLP with 3 input features, the calculation cost is lower than that of traditional statistical methods, and the calculation efficiency is greatly improved.
[0115] Preferably, in the step S3, the original attention score of each attention head in the corresponding multi-head attention module is scaled according to the final value of the temperature parameter obtained by calculation, specifically:
[0116] ;
[0117] ;
[0118] Wherein, A i,jFor each layer of the multi-head attention module, the original attention score matrix of each attention head, i represents the layer index of the multi-head attention module, j represents the index of the multi-head attention head in the layer (head index), and QK T , no softmax processing; T i,j is the final temperature value of the jth attention head in the ith layer of the multi-head attention module calculated, which is used to scale the attention score; is the attention score matrix after temperature scaling; Attention i,j is the attention score of the jth attention head in the ith layer of the multi-head attention module after softmax processing, which is used to control the output attention distribution. The larger the temperature, the more gentle the distribution; the smaller the temperature, the more concentrated the distribution.
[0119] In another preferred embodiment of the present application, the early screening model temperature parameter dynamic adjustment method further comprises the steps of:
[0120] S4, combined with the loss function or the regularization term, the rationality of the temperature and the target task performance are jointly modeled through the loss function, the temperature regularization term or the distribution preference constraint of the attention distribution is added, the model performance is improved and the training stability is enhanced, specifically comprising the steps of:
[0121] S41, through the temperature offset regularization term L temp Constrain the temperature parameter, limit the change amplitude, and promote the training stability:
[0122] ;
[0123] Wherein, T0 is the expected temperature value for constraining the temperature offset; λ is the regularization term weight, which is a hyperparameter, used to control the weight of the temperature offset regularization term, λ∈[0.001, 0.1], dynamically adjusted according to the training stability; L temp is the temperature offset regularization term, used to limit the offset of the temperature parameter, prevent the temperature from being too high / low out of control, and promote the model to converge stably within a reasonable temperature range;
[0124] S42, through the distribution structure constraint term L atten-structure Encourage the generated attention distribution to have a more reasonable entropy value or rank structure:
[0125] ;
[0126] Where: H(Attention i,j ) is the entropy of the softmax attention distribution, which is used to measure the dispersion degree of the distribution; H0 is the target entropy, which is set according to the task; γ is a hyperparameter that controls the influence weight of the term in the total loss function; Latten-structure The attention distribution structure of the control model output is output, the attention collapse phenomenon is suppressed, and the ability to adapt to different tasks is enhanced;
[0127] S43, fusion with the main task loss, get the final training target overall loss function:
[0128] ;
[0129] Wherein, L task is the loss function of the main task text generation; and alpha and beta are key adjustment factors, the value range is [0.01, 0.5], which is used to balance the optimization process between the task target and the rationality of the attention distribution.
[0130] Although the joint loss function has been mentioned in the existing literature, in the stroke recognition model, or in the field of large models, the attention matrix is calculated separately first Some matrix statistics, such as the entropy of the function, the main reason for this situation is: no one has thought to guide the direction of updating the temperature coefficient; It is defaulted to have a dimension of 1 learnable parameter; The embodiment deeply studies the corresponding physical meaning of the temperature coefficient in the multi-modal cerebral apoplexy recognition model, extracts the matrix features of the corresponding matrix, on the one hand as the input of the above step S2 to get the physically meaningful trainable temperature coefficient, and at the same time also adds the entropy and other matrix information representing the dispersion degree of the matrix in the joint joint loss function, which is actually different from the purpose and means of other joint loss functions.
[0131] It can be seen that the embodiment supports joint optimization with the main task loss function: by introducing the temperature adjustment mechanism into the training target, combining the temperature regularization term and the attention distribution structure constraint, the temperature is no longer isolated from the parameter, but can realize global optimal learning under the task target (such as classification / generation) constraint, and improve the overall convergence stability of the model.
[0132] The early screening model temperature parameter dynamic adjustment method provided in the above embodiment is applied in a multi-modal cerebral apoplexy recognition model.
[0133] I. System overall architecture:
[0134] The early screening model temperature parameter dynamic adjustment method is embedded into the multi-modal cerebral apoplexy recognition model based on the Transformer in the embodiment, and the system input includes:
[0135] Modality one: head CT image sequence (encoded as image patch vector);
[0136] Modality two: medical record text (chief complaint, past history);
[0137] Modality three: structured check indicators (such as NIHSS score, blood pressure, blood sugar, etc.);
[0138] The three modalities are input into the multi-layer Transformer fusion module after being processed by independent encoders, and the final output is the stroke classification and severity prediction result.
[0139] II. Temperature regulation module structure and data flow explanation:
[0140] In the multi-head attention module of each layer, the attention score matrix A of each attention head is calculated as follows: i,j The following processing is introduced:
[0141] 1. Statistical feature extraction unit
[0142] Each attention score matrix is passed through a parallel feature extraction unit to obtain features containing medical image features through the calculation of lesion quantification indicators.
[0143] 2. Temperature mapping function design
[0144] The information from the above steps is calculated according to the temperature mapping function above to output the temperature value T of the jth head of the ith layer. i,j ∈[0.3,2.0];
[0145] 3. Attention score adjustment
[0146] The original attention score is scaled as follows:
[0147] ;
[0148] The smaller the temperature is attention tends to one-hot more focused; the larger the temperature is attention distribution is smoother aggregate context.
[0149] III. Temperature regularization and joint loss function design:
[0150] According to the above L task , L temp , L atten-structure , the overall loss function L total is calculated.
[0151] IV. Training and inference stage strategy:
[0152] Training stage:
[0153] Statistical attention distribution features are generated dynamically in each batch to generate temperature;
[0154] The temperature gradient can be optimized by MLP end-to-end back propagation;
[0155] Each layer / each head shares or independent temperature configurable.
[0156] Inference phase:
[0157] The input sample is calculated through forward pass attention feature;
[0158] Real-time calculation of temperature value T i,j , adjust the steepness of each layer softmax;
[0159] The attention distribution is adaptively controlled during inference, which improves the stability and generalization ability of the model.
[0160] In summary, the early screening model temperature parameter dynamic adjustment method proposed in the application is especially suitable for medical AI stroke tasks, and its core advantages include:
[0161] 1. Dynamic and statistical quantity: the application no longer depends on fixed or learnable temperature parameters, but analyzes the statistical characteristics (covariance, entropy, rank of matrix, etc.) of the attention score matrix in real time, which is used as input to guide a small neural network to set the temperature parameter of the current layer / head, which has significant input adaptability;
[0162] 2. High-order statistical quantity driven + temperature function mapping mechanism: the temperature parameter is dynamically generated by a mathematical function and learnable weight according to the statistical characteristics, so as to realize an interpretable and controllable temperature adjustment process, so that the attention distribution is more suitable for the current data structure. Compared with the previous method, the most learnable scalar updates the temperature weight, and the application controls the temperature parameter according to the self-defined function and guidance;
[0163] 3. The design of statistical quantity is also not seen in previous methods. The temperature coefficient in the prior art has a dimension of 1, which is difficult to accurately learn suitable features for adaptation. In order to change the shape of the output distribution probability of the current model, the original driving force should be that when the certainty is strong, the probability can be relatively concentrated, and when the certainty is weak, the probability is relatively dispersed. The application analyzes the attention matrix and extracts relevant features from multiple angles, does not use simple low-order information such as matrix mean and variance, and customizes several input features that guide the temperature coefficient according to the characteristics of medical images. Including lesion area mask, focus intensity, multi-modal conflict index, and diagnosis confidence entropy, the overall significant effect is the improvement of model accuracy.
[0164] 4. The application combines the special scene of small lesion area in medical pictures, combines the high-order features of attention matrix, and customizes the feature focusing module according to the characteristics of medical images.
[0165] 5. The application combines loss functions or regularization terms for joint optimization, models the rationality of temperature and target task performance through loss functions, adds temperature regularization terms or distribution preference constraints of attention distribution, and further improves model performance and enhances training stability.
[0166] As shown in Figure 2 Another preferred embodiment of the application also provides an early screening model temperature parameter dynamic adjustment device, which comprises:
[0167] A key medical feature acquisition module is configured to obtain key medical features including lesion coverage, lesion focus intensity, multi-modal conflict index, and diagnosis confidence entropy from a lesion mask map M based on an attention score matrix A of a large model and medical picture-based features.
[0168] A temperature parameter dynamic calculation module is configured to dynamically calculate and output final values of temperature parameters of each attention head in each multi-head attention module of the large model by taking the lesion coverage, lesion focus intensity, multi-modal conflict index, and diagnosis confidence entropy as input features.
[0169] An attention score dynamic adjustment module is configured to scale original attention scores of each attention head in each multi-head attention module according to the final values of the temperature parameters, so as to dynamically adjust the attention scores of each layer.
[0170] The application provides an early screening model temperature parameter dynamic adjustment device, which adopts the early screening model temperature parameter dynamic adjustment method in the above embodiments to solve the technical problems of uninterpretable temperature adjustment, lack of input adaptability, and lack of statistical driving mechanism in the existing attention mechanism. Compared with the prior art, the early screening model temperature parameter dynamic adjustment device provided by the application has the same beneficial effects as the early screening model temperature parameter dynamic adjustment method provided by the above embodiments, and other technical features in the early screening model temperature parameter dynamic adjustment device are the same as the features disclosed in the above method embodiments, which will not be repeated here. The early screening model temperature parameter dynamic adjustment device of the present embodiment can be integrated into a temperature adjustment module, which is located before the softmax after the multiplication and scaling of Query and Key. The temperature adjustment module dynamically calculates the required temperature coefficient T in the softmax according to the statistics of the current attention score matrix, so as to realize the adaptive adjustment of temperature.
[0171] As shown in Figure 3 The preferred embodiment of the application also provides an electronic device, which comprises a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the early screening model temperature parameter dynamic adjustment method in the above embodiments are implemented.
[0172] The electronic device provided in the application adopts the early screening model temperature parameter dynamic adjustment method in the above embodiment, and solves the technical problems of the existing attention mechanism, such as unexplainable temperature adjustment, lack of input adaptability, and lack of statistical driving mechanism. Compared with the prior art, the electronic device provided in the application has the same beneficial effects as the early screening model temperature parameter dynamic adjustment method provided in the above embodiment, and other technical features in the electronic device are the same as the features disclosed in the above embodiment method, which will not be repeated here.
[0173] As shown in Figure 4 The preferred embodiment of the application further provides a computer device, which can be a terminal or a living body detection server, and an internal structure diagram of the computer device can be as shown in Figure 4 The computer device includes a processor, a memory and a network interface connected through a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operating system and the computer program in the non-volatile storage medium to run. The network interface of the computer device is used to communicate with other computer devices outside through network connection. The computer program is executed by the processor to implement the steps of the above early screening model temperature parameter dynamic adjustment method.
[0174] Those skilled in the art can understand that Figure 4 The structure shown in the above embodiment is only a block diagram of part of the structure related to the scheme of the application, and does not constitute a limitation on the computer device to which the scheme of the application is applied. Specifically, the computer device can include more or fewer components than those shown in the figure, or combine certain components, or have a different component arrangement.
[0175] The computer device provided in the application adopts the early screening model temperature parameter dynamic adjustment method in the above embodiment, and solves the technical problems of the existing attention mechanism, such as unexplainable temperature adjustment, lack of input adaptability, and lack of statistical driving mechanism. Compared with the prior art, the electronic device provided in the application has the same beneficial effects as the early screening model temperature parameter dynamic adjustment method provided in the above embodiment, and other technical features in the electronic device are the same as the features disclosed in the above embodiment method, which will not be repeated here.
[0176] The preferred embodiment of the application further provides a storage medium, which includes a stored program. When the program runs, it controls the device where the storage medium is located to perform the steps of the early screening model temperature parameter dynamic adjustment method in the above embodiment.
[0177] It is to be understood that the steps illustrated in the flowchart of the drawings can be performed in a computer system such as a set of computer readable instructions executed by a computer system and while logic associated with the steps is being executed, processes can inadvertently be performed in an order other than that described herein. However, it is the results that are important for the aspects of the described embodiments, not the order.
[0178] If the functions described in the method of the embodiments are implemented in software, and the software is sold or used as an independent product, the software can be stored in one or more computer-readable storage media. Based on such an understanding, the part of the present application embodiments that contribute to the prior art or part of the technical solutions can be embodied in the form of a software product, which is stored in a storage medium, and includes a number of instructions for causing one or more computers to perform all or part of the steps of the methods described in the various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), magnetic disk or optical disk, and various other media that can store program codes.
[0179] Those skilled in the art should understand that the embodiments of the present application can be provided as a method, a system, or a computer program product. Therefore, the present application can take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code. The solutions in the embodiments of the present application can be implemented in various computer languages, such as object-oriented programming language C++ and embedded programming language C.
[0180] The present application is described with reference to flowcharts and / or block diagrams according to the methods, devices (systems), and computer program products of the embodiments of the present application. It should be understood that each flow and / or block in the flowcharts and / or block diagrams, and the combination of flows and / or blocks in the flowcharts and / or block diagrams can be implemented by computer program instructions. These computer program instructions can be provided to a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to produce a machine, so that the instructions executed by the computer or other programmable data processing devices produce a device that implements the functions specified in the flowcharts and / or block diagrams. Figure 1 The functions specified in one flow or multiple flows and / or blocks Figure 1 The device that implements the functions specified in one block or multiple blocks.
[0181] These computer program instructions can also be stored in a computer readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer readable memory produce an article of manufacture including instructions which implement the flow Figure 1 one or more flow or blocks and / or Figure 1 one or more blocks or blocks specified in the flow.
[0182] These computer program instructions can also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the flow Figure 1 one or more flow or blocks and / or Figure 1 one or more blocks or blocks specified in the flow.
[0183] The present application also provides a computer program product comprising a computer program which, when executed by a processor, implements the steps of the early screening model temperature parameter dynamic adjustment method as described above.
[0184] The computer program product provided by the present application can solve the technical problems of the prior early screening model temperature parameter dynamic adjustment method scheme, such as complexity, difficulty in implementation, large amount of calculation, and high requirement for computing power. Compared with the prior art, the beneficial effects of the computer program product provided by the present application are the same as those of the early screening model temperature parameter dynamic adjustment method provided by the above-mentioned embodiments, and will not be repeated here.
[0185] Although the preferred embodiments of the present application have been described, those skilled in the art can make further changes and modifications to these embodiments once they know the basic inventive concept. Therefore, the appended claims are intended to be interpreted as including all the preferred embodiments and all the changes and modifications falling within the scope of the present application.
[0186] Obviously, those skilled in the art can make various modifications and variations to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalent technologies, the present application also intends to include these modifications and variations.
Claims
1. A method for dynamically adjusting temperature parameters in an early screening model, characterized in that, Including the following steps: S1. Based on the attention score matrix A of the large model and the features based on medical images, the lesion mask map M is obtained to obtain key medical features, including lesion coverage, lesion focus intensity, multimodal conflict index, and diagnostic confidence entropy. Here, the attention score matrix A∈R{dimension n×n} and the lesion mask map M∈{0,1}{dimension n×n} are generated by a lightweight segmentation network. The lesion coverage rate refers to the proportion of attention focused on the lesion area, expressed as: Cover = ∑(A⊙M) / ∑A; Lesion focus intensity refers to the difference in maximum attention between lesions and non-lesions, expressed as: Focus=max(A⊙M)-max(A⊙(1-M)); The multimodal conflict index refers to the difference in attention entropy between image and text modalities, expressed as: ; H(•) represents the entropy of the attention distribution. A img The attention score matrix representing the image modality; A text The attention score matrix representing the text modality; Diagnostic confidence entropy is a measure of the uncertainty of the probability distribution of lesions labeled by doctors. A high entropy value indicates a dispersed distribution of lesions labeled by doctors, expressed as: ; in, The probability distribution of lesions labeled for doctors; S2. Using the lesion coverage, lesion focus intensity, multimodal conflict index, and diagnostic confidence entropy as input features, dynamically calculate and output the final values of the temperature parameters of each attention head in each layer of the large model's multi-head attention module. This specifically includes the following steps: S21. Determine the corresponding baseline temperature based on the lesion coverage rate. T base Among them, when the lesion coverage is greater than 0.25, the baseline temperature is set. T base The baseline temperature is set to [0.3, 0.7] when the lesion coverage is less than or equal to 0.
25. T base The value is [1.0, 1.4]. S22. Input the lesion coverage, lesion focus intensity, and multimodal conflict index into a small neural network, and output the temperature adjustment amount. T adj Then, the temporary temperature value is calculated: ; The small neural network includes an MLP, a 1D convolutional network (1D-CNN), and a gated linear unit. α is a learnable parameter with an initial value of 0.
1. S23. Diagnostic confidence constraints, obtaining the doctor's diagnostic confidence entropy. As a constraint, calculate the final temperature value T: ; S24. Output the final temperature value T to the attention module, and ensure that the T value is within the valid range of [0.3, 2.0]. S3. Based on the final value of the calculated temperature parameter, scale the original attention score of each attention head in the corresponding multi-head attention module of each layer to achieve dynamic adjustment of the attention score of each layer.
2. The method for dynamically adjusting the temperature parameters of the early screening model according to claim 1, characterized in that, In step S3, the original attention scores of each attention head in each layer of the multi-head attention module are scaled according to the final value of the calculated temperature parameter, specifically as follows: ; ; Among them, A i,j For each multi-head attention module in each layer, the original attention score matrix is provided, where i represents the layer index of the multi-head attention module, j represents the index of the multi-head attention head in that layer, and the matrix is derived from QK. T No softmax processing was performed; T i,j The final temperature value of the j-th attention head in the current i-th layer multi-head attention module is used to scale the attention score; The attention score matrix is scaled for temperature; Attention i,j This is the attention score of the j-th attention head in the i-th layer multi-head attention module after softmax processing. It is used to control the output attention distribution. The higher the temperature, the more even the distribution; the lower the temperature, the more concentrated the distribution.
3. The method for dynamically adjusting the temperature parameters of the early screening model according to claim 2, characterized in that, It also includes the following steps: S4. Combine loss function or regularization term for joint optimization. The reasonableness of temperature and the performance of the target task are jointly modeled through loss function. Temperature regularization term or distribution preference constraint of attention distribution are added to improve model performance and enhance training stability.
4. The method for dynamically adjusting the temperature parameters of the early screening model according to claim 3, characterized in that, Step S4 specifically includes the following steps: S41, via temperature offset regularization term L temp Imposing constraints on temperature parameters limits the range of variation and promotes training stability. ; Where T0 is the desired temperature value used to constrain temperature offset; λ is the weight of the regularization term, a hyperparameter used to control the weight of the temperature offset regularization term, λ∈[0.001,0.1], dynamically adjusted according to training stability; L temp It is a temperature offset regularization term, used to limit the offset of temperature parameters, prevent runaway due to excessively high or low temperatures, and promote stable convergence of the model within a reasonable temperature range; S42, Through the distributed structure constraint term L atten-structure Encourage the generation of attention distributions with more reasonable entropy values or rank structures: ; Where: H(Attention) i,j ) is the entropy of the attention distribution after softmax, used to measure the dispersion of this distribution; H0 is the target entropy, set according to the task; γ is a hyperparameter, controlling the weight of this term in the total loss function; L atten-structure Control the attention distribution structure of the model output, suppress attention collapse, and enhance the ability to adapt to different tasks; S43. Combine with the main task loss to obtain the final overall loss function for the training objective: ; Among them, L task The loss function is used for text generation as the main task; α and β are key adjustment factors with values ranging from [0.01, 0.5], used to balance the optimization process between the task objective and the rationality of the attention distribution.
5. A dynamic adjustment device for temperature parameters of an early screening model, characterized in that, include: The key medical feature acquisition module is used to obtain key medical features based on the attention score matrix A of the large model and the lesion mask map M based on the features of medical images. These features include lesion coverage, lesion focus intensity, multimodal conflict index, and diagnostic confidence entropy. The attention score matrix A ∈ R {dimension n × n} and the lesion mask map M ∈ {0, 1} {dimension n × n} are generated by a lightweight segmentation network. The lesion coverage rate refers to the proportion of attention focused on the lesion area, expressed as: Cover = ∑(A⊙M) / ∑A; Lesion focus intensity refers to the difference in maximum attention between lesions and non-lesions, expressed as: Focus=max(A⊙M)-max(A⊙(1-M)); The multimodal conflict index refers to the difference in attention entropy between image and text modalities, expressed as: ; H(•) represents the entropy of the attention distribution. A img The attention score matrix representing the image modality; A text The attention score matrix representing the text modality; Diagnostic confidence entropy is a measure of the uncertainty of the probability distribution of lesions labeled by doctors. A high entropy value indicates a dispersed distribution of lesions labeled by doctors, expressed as: ; in, The probability distribution of lesions labeled for doctors; The temperature parameter dynamic calculation module is used to dynamically calculate and output the final values of the temperature parameters of each attention head in the multi-head attention modules of each layer of the large model, using the lesion coverage, lesion focus intensity, multimodal conflict index, and diagnostic confidence entropy as input features. Specifically, it is used for: The corresponding baseline temperature is determined based on the lesion coverage rate. T base Among them, when the lesion coverage is greater than 0.25, the baseline temperature is set. T base The baseline temperature is set to [0.3, 0.7] when the lesion coverage is less than or equal to 0.
25. T base The value is [1.0, 1.4]. The lesion coverage, lesion focus intensity, and multimodal conflict index are input into a small neural network, which outputs the temperature adjustment amount. T adj Then, the temporary temperature value is calculated: ; The small neural network includes an MLP, a 1D convolutional network (1D-CNN), and a gated linear unit. α is a learnable parameter with an initial value of 0.
1. Diagnostic confidence constraints, obtaining the doctor's diagnostic confidence entropy As a constraint, calculate the final temperature value T: ; Output the final temperature value T to the attention module, and ensure that the T value is within the valid range of [0.3, 2.0]. The attention score dynamic adjustment module is used to scale the original attention score of each attention head in the corresponding multi-head attention module of each layer according to the final value of the calculated temperature parameter, so as to realize the dynamic adjustment of the attention score of each layer.
6. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the method for dynamically adjusting the temperature parameters of the early screening model as described in any one of claims 1 to 4.
7. A storage medium comprising a stored program, characterized in that, When the program is running, it controls the device containing the storage medium to perform the steps of the method for dynamically adjusting the temperature parameters of the early screening model as described in any one of claims 1 to 4.
Citation Information
Patent Citations
Medical diagnosis method and system based on big data analysis
CN119007979A
Cerebral stroke early diagnosis model construction method and device, electronic equipment and storage medium
CN120745732A