Llm-based medical instrument data classification method
By constructing an LLM-based medical device data classification method, the need for refined anomaly identification in high-risk medical scenarios was addressed. This method enables refined modeling and stable discrimination of medical device data, thereby improving the stability and robustness of the classification results.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- HUAXIA CHENGHUANG (BEIJING) HEALTH TECH CO LTD
- Filing Date
- 2026-03-24
- Publication Date
- 2026-06-05
Smart Images

Figure CN122153656A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of medical device data technology, and more specifically to a medical device data classification method based on LLM. Background Technology
[0002] In high-risk medical scenarios (such as continuous hemodynamic monitoring equipment in ICUs), equipment logs and adverse event texts often contain millisecond-level transient perturbations and cross-sentence causal dependencies. Their semantics exhibit a non-stationary pattern of "abnormal triggering - brief recovery - re-shift," and there are implicit mapping differences in the descriptions of equipment from different manufacturers. Existing methods struggle to establish stable discrimination boundaries under extremely low-frequency boundary anomalies, especially for anomalous fragments with potential hidden risks, which are prone to semantic collapse or misclassification, making it difficult to meet the needs of refined risk identification. Summary of the Invention
[0003] The purpose of this invention is to provide a medical device data classification method based on LLM to address the shortcomings of the prior art.
[0004] To achieve the above objectives, the present invention provides the following technical solution: a medical device data classification method based on LLM, comprising: Obtain multi-source raw text data D of medical devices, and perform cross-sentence rearrangement and event-level alignment on D based on timestamps and equipment operation stages to obtain a serialized semantic unit set T. An abnormal trigger-recovery response bidirectional window is expanded for T to construct a semantic trajectory, and the trajectory feature vector E1 is encoded. Extract the device operation state transition relationship corresponding to the semantic trajectory, construct a state constraint graph G, and map E1 to G to perform path consistency constraints to obtain the fusion feature E2. We introduce the Wasserstein distance constraint algorithm based on optimal transmission theory into E2 to calculate the degree of distribution offset between different semantic trajectories, and generate alignment feature E3 through optimal transmission mapping; A multi-perspective prompt template containing counterfactual perturbations is constructed based on E3, and then input into LLM to obtain a set of multi-perspective classification results and a consistency measurement matrix; Semantic divergence regions are identified based on the consistency metric matrix, and the corresponding features are perturbed and inverted and then jointly discriminated and inferred with E3 to output the final classification result.
[0005] Preferably, the cross-sentence rearrangement and event-level alignment of D based on timestamps and device operation phases includes the following steps: The multi-source raw text data D of medical devices is timestamped and uniformly labeled to obtain standardized time series data D1; The standardized time series data D1 is sliced according to the equipment operation stage division rules to form a set of subsequences D2 with stage labels; Cross-sentence semantic association analysis is performed on the subsequence set D2. Dependency syntactic relations and contextual reference resolution techniques are used to identify associated text fragments and rearrange them to obtain the candidate event fragment set D3. Based on event trigger words and state transition constraint rules, the candidate event fragment set D3 is subjected to event-level alignment and merging processing to generate a serialized semantic unit set T.
[0006] Preferably, the construction of the semantic trajectory includes the following steps: The serialized semantic unit set T is scanned unit by unit based on the pre-constructed set of abnormal trigger words to identify target units containing abnormal trigger semantics and determine their index positions in the sequence, forming an abnormal anchor point set T1. Using each index position in the abnormal anchor point set T1 as the center, the semantic units before the abnormal trigger are traced back and the semantic units of the recovery response are expanded backward according to the preset window length to construct a bidirectional window sequence and obtain the semantic trajectory set T2. The semantic units in the semantic trajectory set T2 are subjected to position encoding and semantic embedding encoding fusion processing to form a trajectory representation sequence T3 containing time sequence and semantic information.
[0007] Preferably, the trajectory feature vector E1 is obtained by encoding the trajectory feature vector E1 by performing aggregation calculation on the trajectory representation sequence T3 based on the sequence modeling method.
[0008] Preferably, extracting the device operation state transition relationships corresponding to the semantic trajectory and constructing a state constraint graph G includes the following steps: The trajectory feature vector E1 is decoded using state semantics. Based on a predefined set of device state labels, the hidden representation of each time step is labeled with state to obtain the set of state sequences S1. The adjacent state pairs of the state sequence set S1 are statistically analyzed, the state transition frequency is calculated, and a weighted state transition matrix S2 is generated by combining the time interval information. Based on the weighted state transition matrix S2, a directed graph structure is constructed, with the device state as the node and the state transition relationship as the weighted directed edge. A transition probability threshold is introduced to prune low-confidence transitions, resulting in the initial state graph G1. Path consistency constraints are applied to the initial state graph G1. Abnormal paths that do not meet the physical operation logic of the device are detected, corrected, or deleted to form a state constraint graph G.
[0009] Preferably, the step of mapping E1 to G to perform path consistency constraints and obtain the fused feature E2 includes the following steps: The trajectory feature vector E1 is subjected to state-space projection processing. Based on the state embedding rules consistent with the state constraint graph G, the trajectory feature vector E1 is converted into the corresponding state representation sequence E1′. The state representation sequence E1′ is mapped to the node paths in the state constraint graph G. The corresponding path set is calculated according to the transition relationship between nodes, and a candidate path sequence set P1 is generated. The path consistency of the candidate path sequence set P1 is evaluated. The cumulative value of the transition probability of each path and the degree of matching with the preset physical constraint rules are calculated. Paths that meet the consistency threshold are selected to form the optimal path set P2. The path features in the optimal path set P2 are fused with the original trajectory feature vector E1, and a fused feature vector E2 is generated by weighted combination.
[0010] Preferably, the step of introducing the Wasserstein distance constraint algorithm based on optimal transport theory to E2 to calculate the distribution offset between different semantic trajectories includes the following steps: The fused feature vector E2 is processed by distribution modeling, and the feature representations corresponding to different semantic trajectories are constructed into a set of discrete probability distributions F1. Based on the discrete probability distribution set F1, a cost matrix is constructed, and the optimal transmission distance between different distributions is solved using the Wasserstein distance calculation method to obtain the distribution offset metric matrix F2. The optimal transmission mapping relationship is solved based on the distribution offset metric matrix F2, and the feature alignment mapping matrix F3 across semantic trajectories is generated. The fused feature vector E2 is reconstructed using the feature alignment mapping matrix F3 to obtain the aligned feature vector E3.
[0011] Preferably, obtaining the multi-view classification result set and consistency measurement matrix includes the following steps: Semantic deconstruction is performed on the aligned feature vector E3 to extract the core semantic elements and their corresponding contextual constraints, and to generate the basic cue representation set Q1. Based on the basic cue representation set Q1, a counterfactual perturbation strategy is introduced. By replacing, deleting or adjusting the intensity of key semantic elements, multiple perturbation cue sequences are constructed to form a multi-perspective cue template set Q2. The multi-view prompt template set Q2 is input one by one into the pre-trained large language model LLM to obtain the corresponding classification output results, forming a multi-view classification result set C1. A consistency analysis is performed on the multi-view classification result set C1 to calculate the similarity between results from different perspectives and construct a consistency metric matrix M.
[0012] Preferably, the step of identifying semantic divergence regions based on the consistency metric matrix, performing perturbation inversion on the corresponding features, and performing joint discriminative inference with E3 includes the following steps: performing threshold segmentation on the consistency metric matrix M, identifying element pairs with similarity lower than a preset consistency threshold, and locating the corresponding semantic divergence regions to form a divergence index set R1; performing perturbation inversion on the corresponding alignment feature vector E3 based on the divergence index set R1, constructing the minimum perturbation direction and generating an inversion feature set R2; jointly inputting the inversion feature set R2 and the original alignment feature vector E3, calculating the fusion discriminative score through a discriminant function to form a candidate classification result set R3; performing weighted decision-making on the candidate classification result set R3, and outputting the final classification result.
[0013] The technical effects and advantages provided by the present invention in the above technical solution are as follows: 1. This invention achieves refined modeling capabilities for low-frequency, hidden anomaly semantics in medical devices by constructing a multi-level processing chain of "semantic trajectory - state constraint graph - optimal transmission alignment - multi-perspective counterfactual reasoning". Compared to traditional methods based on single text representation or static feature classification, this invention introduces a state constraint graph to constrain the path consistency of semantic trajectories, effectively integrating the physical operation logic of the device with semantic expression information, thereby reducing the risk of misclassification caused by semantic ambiguity from the source. At the same time, it combines optimal transmission theory to align feature distributions across trajectories, making the anomaly expressions of different devices and scenarios comparable in a unified feature space, thus significantly improving the model's adaptability to distribution drift and cross-domain data.
[0014] 2. This invention constructs a multi-perspective prompt template containing counterfactual perturbations and combines consistency measurement and perturbation inversion strategies to specifically enhance the discrimination of semantic divergence regions. This effectively identifies boundary anomalies and pseudo-anomalies that are difficult for traditional methods to capture. This method not only improves the stability and robustness of classification results but also achieves adaptive optimization in low-confidence sample scenarios, reducing false positives and false negatives. It is particularly suitable for refined monitoring and anomaly early warning of high-risk medical equipment. Attached Figure Description
[0015] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in this invention. For those skilled in the art, other drawings can be obtained based on these drawings.
[0016] Figure 1 This is a flowchart of the method of the present invention. Detailed Implementation
[0017] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0018] For examples, please refer to Figure 1 As shown, the LLM-based medical device data classification method described in this embodiment includes: Obtain multi-source raw text data D of medical devices, and perform cross-sentence rearrangement and event-level alignment of D based on timestamps and equipment operation stages to obtain a serialized semantic unit set T.
[0019] In this embodiment, the original text data D from multiple sources of medical devices is timestamped and uniformly calibrated. Specifically, firstly, the time fields in different data sources are formatted, and regular expressions are used to match standard time formats (including "YYYY-MM-DD HH:MM:SS" and its variants), and they are converted into a unified time representation. Subsequently, using Coordinated Universal Time (UTC) as the reference, the clock offsets within different devices are corrected. The correction method is as follows: overlapping records of the same event in different data sources are selected, and the average time difference is calculated as the offset compensation value, thereby obtaining standardized time series data D1.
[0020] The standardized time series data D1 is processed by stage slicing. Specifically, a rule for dividing the equipment operation stages is predefined. The rule is constructed based on the equipment status field and key behavioral words, including the startup stage, stable operation stage, and abnormal response stage. Furthermore, the standardized time series data D1 is traversed using a sliding window method. When the status label within the window changes, it is divided into a new subsequence, thereby forming a set of subsequences D2 with stage labels. The window length is set to 5 to 10 records, determined based on the state transition frequency in historical statistics.
[0021] Cross-sentence semantic association analysis is performed on the subsequence set D2. Specifically, firstly, a dependency parsing model is constructed, which is trained based on a bidirectional long short-term memory network and an attention mechanism to identify subject-verb-object relationships within sentences. Secondly, a pronoun resolution algorithm is used to restore pronouns and omitted components in the text. The pronoun resolution is achieved by calculating the semantic similarity between candidate entities. The semantic similarity is calculated using cosine similarity, and entities with a similarity greater than 0.85 are identified as the same entity. Based on this, the text segments with semantic associations are rearranged to generate a candidate event segment set D3.
[0022] The candidate event fragment set D3 is subjected to event-level alignment and merging. Specifically, firstly, an event trigger word dictionary is constructed, which is obtained by statistically analyzing high-frequency verbs and abnormal descriptive words in historical medical device logs, and weights are assigned based on word frequency; secondly, in conjunction with state transition constraint rules, event boundary detection is performed on fragments containing trigger words, and merging is performed when adjacent fragments satisfy state continuity and the time interval is less than a preset threshold (the threshold is 2 to 5 seconds); finally, the merged event fragments are arranged in chronological order to generate a serialized semantic unit set T.
[0023] An abnormal trigger-recovery response bidirectional window is expanded for T to construct a semantic trajectory, which is then encoded to obtain the trajectory feature vector E1.
[0024] Anomaly trigger semantic recognition processing is performed on the serialized semantic unit set T. Specifically, firstly, an anomaly trigger word set is constructed. This set is obtained through statistical analysis of historical medical device text data. The importance weight of each term is calculated using the term frequency-inverse document frequency method, and terms with a weight greater than a preset threshold of 0.6 are selected as candidates. Further filtering is performed using manually annotated anomaly semantic samples to form the final anomaly trigger word set. Subsequently, each semantic unit in the serialized semantic unit set T is matched. When a semantic unit contains a term from the anomaly trigger word set and its cumulative weight is greater than 1.2, it is determined to be an anomaly trigger semantic unit, and its index position in the sequence is recorded, thus forming an anomaly anchor point set T1.
[0025] A bidirectional window sequence is constructed centered on the index position in the anomaly anchor set T1. Specifically, for each anomaly anchor, a preset number of semantic units are selected forward as the anomaly trigger context, and a preset number of semantic units are selected backward as the recovery response context. The forward window length is set to 3 to 5 semantic units, and the backward window length is set to 4 to 6 semantic units. This window length is determined by statistically analyzing the average duration span of historical anomaly events. During the window construction process, if the time interval between adjacent semantic units exceeds a preset threshold of 3 seconds, the expansion stops, thus obtaining the semantic trajectory set T2.
[0026] The semantic trajectory set T2 is encoded. Specifically, firstly, each semantic unit is represented by a semantic embedding, which is obtained through a pre-trained word vector model. This pre-trained word vector model is constructed using a continuous bag-of-words method based on a corpus in the medical device domain, and the word vector dimension is set to 256. Secondly, positional encoding is introduced for the position of the semantic unit in the trajectory. The positional encoding is generated by combining sine and cosine functions. The calculation method is as follows: for the i-th position, its encoding value is obtained by superimposing sine and cosine functions of different frequencies. Subsequently, the semantic embedding vector and the positional encoding vector are added element-wise to form the trajectory representation sequence T3.
[0027] The trajectory representation sequence T3 is aggregated and calculated to obtain the trajectory feature vector E1. Specifically, a sequence modeling model based on a gated recurrent unit network is constructed. The gated recurrent unit network includes update gates and reset gates, and its parameters are trained by minimizing the classification cross-entropy loss function. The trajectory representation sequence T3 is input into the gated recurrent unit network in chronological order to obtain the hidden state vector at each time step. Finally, all hidden state vectors are weighted and summed. The weights are obtained through attention calculation. The attention weights are calculated by normalizing the dot product between the hidden state and the global context vector, thereby generating the trajectory feature vector E1. The specific steps are as follows: First, a gated recurrent unit network is constructed. Its computation process at time step t is defined as follows: Update gate: ; Reset gate: ; Candidate hidden state: ; Hidden state update: ; Where, represents the input vector of the trajectory representation sequence T3 at time step t, obtained by fusion of semantic embedding and positional encoding, with a dimension of 256; represents the hidden state vector at time step t-1; , , represent the input weight matrix, with a dimension of 128×256, used to map the input vector to the hidden space; , , represent the recurrent weight matrix, with a dimension of 128×128, used to characterize the history. The influence of the current state on the current state; , , are bias vectors with a dimension of 128, used to adjust the translation amount of the linear transformation; represents the Sigmoid function, used to compress the gate value to the interval between 0 and 1; is the hyperbolic tangent function, used to generate candidate hidden states; ⊙ is the element-wise multiplication operator, used to control the information flow; is the update gate vector, controlling the proportion of new information retained in the current hidden state; is the reset gate vector, controlling the degree of participation of historical information in the candidate state calculation; is the candidate hidden state, representing the intermediate state that integrates the current input and the filtered historical information.
[0028] Subsequently, after obtaining the set of hidden states for all time steps, where T is the total number of time steps, a global context vector is constructed: ; Attention weights are calculated for each time step: ; where represents the relevance score between the t-th hidden state and the global context vector, represents the normalized attention weight, and represents the transpose of the hidden state vector. Finally, all hidden states are weighted and aggregated to obtain the trajectory feature vector E1: ; Through the above calculation process, the trajectory feature vector E1, while maintaining the temporal series dependencies, assigns higher weights to key semantic nodes, thereby enhancing the representation ability of abnormal semantic evolution processes.
[0029] Extract the device operation state transition relationship corresponding to the semantic trajectory, construct a state constraint graph G, and map E1 to G to perform path consistency constraints to obtain the fusion feature E2.
[0030] In the process of constructing the state constraint graph G, the trajectory feature vector E1 is first subjected to state semantic decoding. Specifically, a set of device state labels is pre-constructed, which is determined based on medical device operation specifications and historical annotation data, including normal operation state, calibration state, abnormal warning state, and fault state. Then, a state decoding model is constructed. The state decoding model adopts a multilayer perceptron structure, whose input is the hidden representation of each time step in the trajectory feature vector E1, and whose output is the probability distribution of the corresponding state label. The state labeling is completed by taking the label corresponding to the maximum value of the probability distribution, thereby obtaining the state sequence set S1.
[0031] State transition statistics are performed on the state sequence set S1. Specifically, the state pairs of adjacent time steps in the state sequence set S1 are traversed, the frequency of each state pair is counted, and the corresponding time interval is recorded. Further, the state transition frequency is normalized to obtain the transition probability, and a time decay function is introduced to weight the time interval. The time decay function is defined as an exponential decay form, and its parameters are determined by fitting historical data, thereby generating a weighted state transition matrix S2.
[0032] An initial state graph G1 is constructed based on the weighted state transition matrix S2. Specifically, device state labels are used as graph nodes, state transition relationships are used as directed edges, and transition probabilities are used as edge weights. Then, a transition probability threshold is set, which is determined by taking the 75th quantile of the historical transition probability distribution. When the edge weight is lower than the threshold, the corresponding edge is deleted, thereby completing the pruning process and obtaining the initial state graph G1.
[0033] Path consistency constraints are applied to the initial state graph G1. Specifically, physical operation constraint rules for the equipment are pre-constructed. These rules define the legal order of state transitions based on the equipment's operational logic, for example, an abnormal warning state must occur before a fault state. Subsequently, all paths in the graph are traversed to detect whether any paths violate the constraint rules. For paths that violate the rules, the corresponding edges are deleted or the edge weights are readjusted according to the principle of minimum modification, thereby obtaining the state constraint graph G.
[0034] In the process of mapping and fusing trajectory feature vector E1, the trajectory feature vector E1 is first subjected to state space projection processing. Specifically, a state embedding rule is constructed to map each state label into a fixed-dimensional vector representation, which is obtained by one-hot encoding of the state label and then performing a linear transformation. Subsequently, the trajectory feature vector E1 is transformed into a vector space consistent with the state embedding through a linear mapping function to form the state representation sequence E1′.
[0035] The state representation sequence E1′ is mapped to the node paths in the state constraint graph G. Specifically, matching is performed based on the similarity between each vector in the state representation sequence E1′ and the graph node vectors. The similarity is calculated using the cosine similarity method, and a mapping relationship is established when the similarity is greater than 0.8. Subsequently, corresponding path combinations are generated based on the directed edge relationships between nodes in the graph, forming a candidate path sequence set P1.
[0036] A path consistency evaluation is performed on the candidate path sequence set P1. Specifically, for each path, the cumulative product of its edge weights is calculated as the cumulative transition probability value, and this value is compared with a preset consistency threshold, which is determined by subtracting a standard deviation from the mean of the historical path probability distribution. At the same time, the path is matched with the physical operation constraints of the equipment, and a matching score is calculated. When both the cumulative transition probability value and the matching score meet the threshold condition, the path is retained, forming the optimal path set P2.
[0037] Feature fusion calculation is performed on the optimal path set P2. Specifically, the node vectors corresponding to each path in the optimal path set P2 are weighted and summed, with the weights obtained by normalizing the cumulative transition probabilities of the paths. Subsequently, the weighted path feature vectors are concatenated with the original trajectory feature vector E1, and a nonlinear mapping is performed through a fully connected transformation function. The parameters of the transformation function are obtained by training by minimizing the classification error loss function, thereby generating the fused feature vector E2.
[0038] We introduce the Wasserstein distance constraint algorithm based on optimal transport theory into E2 to calculate the degree of distribution offset between different semantic trajectories, and generate alignment feature E3 through optimal transport mapping.
[0039] The fused feature vector E2 is processed through distribution modeling. Specifically, firstly, the fused feature vector E2 is grouped according to the source of the semantic trajectory, with each group corresponding to a feature set of a semantic trajectory; then, each feature set is normalized, mapping the values of each dimension of the feature vector to the interval between 0 and 1; further, the normalized features are binned using a histogram discretization method, with the number of bins set to 32 intervals, and the frequency of feature values appearing in each interval is counted; finally, the frequencies are normalized to satisfy the probability distribution constraints, thereby constructing a discrete probability distribution set F1.
[0040] A cost matrix is constructed based on the discrete probability distribution set F1, and the Wasserstein distance is calculated. Specifically, firstly, the element between any two distributions in the cost matrix is defined as the Euclidean distance between the corresponding bucket centers. Then, a linear programming method is used to solve the optimal transport problem, with the objective function being to minimize the total transport cost, and the constraint being that the marginal probabilities of the source and target distributions remain consistent. The linear programming is implemented iteratively, with the initial solution using a uniform distribution strategy, and the transport matrix is gradually updated until convergence. The convergence criterion is that the difference between two adjacent iterations is less than 0.001. Finally, the distribution offset metric matrix F2 is obtained.
[0041] The optimal transport mapping relationship is solved based on the distribution offset metric matrix F2. Specifically, the distribution pair with the smallest distance is selected from the distribution offset metric matrix F2 as the alignment reference; then, non-zero transport paths are extracted according to the corresponding optimal transport matrix to construct the mapping relationship between features; further, the mapping relationship is normalized so that the sum of the target feature weights corresponding to each source feature is 1, thereby generating the feature alignment mapping matrix F3.
[0042] The fused feature vector E2 is reconstructed using the feature alignment mapping matrix F3. Specifically, the fused feature vector E2 is multiplied by the feature alignment mapping matrix F3 to obtain the aligned feature representation. Subsequently, a smoothing constraint term is introduced to adjust the reconstruction result. The smoothing constraint term is implemented by calculating the sum of squared differences between adjacent feature vectors and is added as a regularization term to the optimization objective. Finally, the aligned feature vector E3 is obtained by minimizing the sum of the reconstruction error and the smoothing constraint term.
[0043] A multi-perspective cue template containing counterfactual perturbations is constructed based on E3, and then input into LLM to obtain a multi-perspective classification result set and a consistency measurement matrix.
[0044] Semantic deconstruction is performed on the alignment feature vector E3. Specifically, firstly, the alignment feature vector E3 is analyzed for dimensionality, dividing it into semantically dominant dimensions and context-constrained dimensions. The division is based on the gradient weights of each dimension's contribution to the classification results during the training phase. Subsequently, the top 30% of dimensions with the highest gradient weights are selected as core semantic elements, and the remaining dimensions are selected as context-constrained elements. Further, the core semantic elements are converted into readable text tags using a linear mapping function, while preserving the relationships between context-constrained elements, thereby generating the basic cue representation set Q1.
[0045] Counterfactual perturbations are constructed based on the basic cue representation set Q1. Specifically, counterfactual perturbation rules are first defined, including semantic substitution rules, semantic weakening rules, and semantic enhancement rules. The semantic substitution rules are implemented by constructing a synonym vector space, and the distance between synonyms is calculated using cosine similarity. Synonyms are considered as replacement candidates when the similarity is in the range of 0.7 to 0.9. The semantic weakening rules are implemented by scaling the weights of core semantic elements, with the scaling factor set to 0.5. The semantic enhancement rules are implemented by repeatedly encoding core semantic elements. Subsequently, the above perturbation operations are performed on each basic cue representation to generate multiple sets of perturbation cue sequences, forming a multi-view cue template set Q2.
[0046] The multi-view cue template set Q2 is input into a pre-trained large language model (LLM) for classification inference. Specifically, the pre-trained LLM is trained on a large-scale medical text corpus, and its training objective is to minimize the language modeling loss function. During inference, each cue template is used as an input sequence, and a contextual representation is obtained through self-attention calculation. At the output, the hidden representation is converted into a classification label probability distribution through a classification mapping layer. The label corresponding to the maximum probability is selected as the classification result of that cue template, thus forming a multi-view classification result set C1.
[0047] A consistency metric is calculated for the multi-view classification result set C1. Specifically, firstly, each classification result is converted into a probability vector representation; then, the similarity between any two probability vectors is calculated using the cosine similarity method; further, all pairwise similarity results are constructed into a matrix form to obtain the consistency metric matrix M; finally, the consistency metric matrix M is normalized so that its values are distributed in the interval between 0 and 1, which is used to characterize the degree of consistency between classification results from different perspectives.
[0048] Semantic divergence regions are identified based on the consistency metric matrix, and the corresponding features are perturbed and inverted and then jointly discriminated and inferred with E3 to output the final classification result.
[0049] Semantic divergence region identification is performed on the consistency metric matrix M. Specifically, firstly, each element in the consistency metric matrix M is traversed, where each element represents the similarity between two sets of classification results. Then, a consistency threshold is set, which is obtained through statistical analysis of historical consistency metric matrices, specifically by subtracting a standard deviation from the mean of all similarity values. When a matrix element value is lower than the consistency threshold, it is determined that there is semantic divergence. Further, based on the position of the elements below the threshold in the matrix, the original multi-view cue template index is mapped back to locate the corresponding semantic divergence region, thereby forming a divergence index set R1.
[0050] The aligned feature vector E3 corresponding to the divergence index set R1 is subjected to perturbation inversion processing. Specifically, firstly, the corresponding feature sub-vector is extracted for each divergence index; then, a perturbation inversion function is constructed, which is implemented based on the gradient backpropagation idea, and its goal is to minimize the difference between the perturbed features and the original classification result; specifically, the perturbation vector is initialized as a zero vector, and the perturbation vector is updated iteratively so that the classification loss function decreases in the opposite direction of the gradient, the iteration step size is set to 0.01, and the number of iterations is 50; after each iteration, the perturbation amplitude is constrained so that it does not exceed the preset perturbation threshold of 0.1, thereby obtaining the inverted feature set R2.
[0051] The inverted feature set R2 and the aligned feature vector E3 are jointly used for discriminative inference. Specifically, the inverted feature set R2 and the original aligned feature vector E3 are concatenated to form an extended feature representation. Then, a discriminant function is constructed, which adopts a two-layer nonlinear mapping structure. The first layer maps the input to the hidden space through a linear transformation, and the second layer outputs the classification score through an activation function. The discriminant function is trained by minimizing the cross-entropy loss function. The extended feature representation is input into the discriminant function to obtain the corresponding candidate classification result set R3.
[0052] A weighted decision process is performed on the candidate classification result set R3. Specifically, firstly, a weight is assigned to each candidate classification result. The weight is determined by the perturbation amplitude of the corresponding feature and the consistency measure, where the smaller the perturbation amplitude and the higher the original consistency, the greater the weight. The weight is calculated by taking the reciprocal of the perturbation amplitude, multiplying it by the consistency value, and then normalizing. Subsequently, all candidate classification results are summed according to their weights, and the classification label with the highest weighted score is selected as the final classification result.
[0053] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application.
Claims
1. A medical device data classification method based on LLM, characterized in that: include: Obtain multi-source raw text data D of medical devices, and perform cross-sentence rearrangement and event-level alignment on D based on timestamps and equipment operation stages to obtain a serialized semantic unit set T. An abnormal trigger-recovery response bidirectional window is expanded for T to construct a semantic trajectory, and the trajectory feature vector E1 is encoded. Extract the device operation state transition relationship corresponding to the semantic trajectory, construct a state constraint graph G, and map E1 to G to perform path consistency constraints to obtain the fusion feature E2. We introduce the Wasserstein distance constraint algorithm based on optimal transmission theory into E2 to calculate the degree of distribution offset between different semantic trajectories, and generate alignment feature E3 through optimal transmission mapping; A multi-perspective prompt template containing counterfactual perturbations is constructed based on E3, and then input into LLM to obtain a set of multi-perspective classification results and a consistency measurement matrix; Semantic divergence regions are identified based on the consistency metric matrix, and the corresponding features are perturbed and inverted and then jointly discriminated and inferred with E3 to output the final classification result.
2. The medical device data classification method based on LLM according to claim 1, characterized in that: The cross-sentence rearrangement and event-level alignment of D based on timestamps and device operation phases includes the following steps: The multi-source raw text data D of medical devices is timestamped and uniformly labeled to obtain standardized time series data D1; The standardized time series data D1 is sliced according to the equipment operation stage division rules to form a set of subsequences D2 with stage labels; Cross-sentence semantic association analysis is performed on the subsequence set D2. Dependency syntactic relations and contextual reference resolution techniques are used to identify associated text fragments and rearrange them to obtain the candidate event fragment set D3. Based on event trigger words and state transition constraint rules, the candidate event fragment set D3 is subjected to event-level alignment and merging processing to generate a serialized semantic unit set T.
3. The medical device data classification method based on LLM according to claim 1, characterized in that: The construction of the semantic trajectory includes the following steps: The serialized semantic unit set T is scanned unit by unit based on the pre-constructed set of abnormal trigger words to identify target units containing abnormal trigger semantics and determine their index positions in the sequence, forming an abnormal anchor point set T1. Using each index position in the abnormal anchor point set T1 as the center, the semantic units before the abnormal trigger are traced back and the semantic units of the recovery response are expanded backward according to the preset window length to construct a bidirectional window sequence and obtain the semantic trajectory set T2. The semantic units in the semantic trajectory set T2 are subjected to position encoding and semantic embedding encoding fusion processing to form a trajectory representation sequence T3 containing time sequence and semantic information.
4. The medical device data classification method based on LLM according to claim 3, characterized in that: The trajectory feature vector E1 is obtained by encoding, including: performing aggregation calculation on the trajectory representation sequence T3 based on the sequence modeling method to obtain the trajectory feature vector E1.
5. The medical device data classification method based on LLM according to claim 1, characterized in that: Extracting the device operation state transition relationships corresponding to the semantic trajectory and constructing a state constraint graph G includes the following steps: The trajectory feature vector E1 is decoded using state semantics. Based on a predefined set of device state labels, the hidden representation of each time step is labeled with state to obtain the set of state sequences S1. The adjacent state pairs of the state sequence set S1 are statistically analyzed, the state transition frequency is calculated, and a weighted state transition matrix S2 is generated by combining the time interval information. Based on the weighted state transition matrix S2, a directed graph structure is constructed, with the device state as the node and the state transition relationship as the weighted directed edge. A transition probability threshold is introduced to prune low-confidence transitions, resulting in the initial state graph G1. Path consistency constraints are applied to the initial state graph G1. Abnormal paths that do not meet the physical operation logic of the device are detected, corrected, or deleted to form a state constraint graph G.
6. The medical device data classification method based on LLM according to claim 5, characterized in that: The process of mapping E1 to G to perform path consistency constraints and obtaining the fused feature E2 includes the following steps: The trajectory feature vector E1 is subjected to state-space projection processing. Based on the state embedding rules consistent with the state constraint graph G, the trajectory feature vector E1 is converted into the corresponding state representation sequence E1′. The state representation sequence E1′ is mapped to the node paths in the state constraint graph G. The corresponding path set is calculated according to the transition relationship between nodes, and a candidate path sequence set P1 is generated. The path consistency of the candidate path sequence set P1 is evaluated. The cumulative value of the transition probability of each path and the degree of matching with the preset physical constraint rules are calculated. Paths that meet the consistency threshold are selected to form the optimal path set P2. The path features in the optimal path set P2 are fused with the original trajectory feature vector E1, and a fused feature vector E2 is generated by weighted combination.
7. The medical device data classification method based on LLM according to claim 1, characterized in that: The method of introducing the Wasserstein distance constraint algorithm based on optimal transmission theory into E2 to calculate the distribution offset between different semantic trajectories includes the following steps: The fused feature vector E2 is processed by distribution modeling, and the feature representations corresponding to different semantic trajectories are constructed into a set of discrete probability distributions F1. Based on the discrete probability distribution set F1, a cost matrix is constructed, and the optimal transmission distance between different distributions is solved using the Wasserstein distance calculation method to obtain the distribution offset metric matrix F2. The optimal transmission mapping relationship is solved based on the distribution offset metric matrix F2, and the feature alignment mapping matrix F3 across semantic trajectories is generated. The fused feature vector E2 is reconstructed using the feature alignment mapping matrix F3 to obtain the aligned feature vector E3.
8. The medical device data classification method based on LLM according to claim 1, characterized in that: Obtaining the multi-view classification result set and consistency metric matrix includes the following steps: Semantic deconstruction is performed on the aligned feature vector E3 to extract the core semantic elements and their corresponding contextual constraints, and to generate the basic cue representation set Q1. Based on the basic cue representation set Q1, a counterfactual perturbation strategy is introduced. By replacing, deleting or adjusting the intensity of key semantic elements, multiple perturbation cue sequences are constructed to form a multi-perspective cue template set Q2. The multi-view prompt template set Q2 is input one by one into the pre-trained large language model LLM to obtain the corresponding classification output results, forming a multi-view classification result set C1. A consistency analysis is performed on the multi-view classification result set C1 to calculate the similarity between results from different perspectives and construct a consistency metric matrix M.
9. The LLM-based medical device data classification method according to claim 1, characterized in that: The step of identifying semantic divergence regions based on the consistency metric matrix, performing perturbation inversion on the corresponding features, and conducting joint discriminative inference with E3 includes the following steps: threshold segmentation is performed on the consistency metric matrix M to identify element pairs with similarity below a preset consistency threshold, and the corresponding semantic divergence regions are located to form a divergence index set R1; perturbation inversion is performed on the corresponding aligned feature vector E3 based on the divergence index set R1 to construct the minimum perturbation direction and generate an inversion feature set R2; the inversion feature set R2 and the original aligned feature vector E3 are jointly input, and a fusion discriminative score is calculated through a discriminant function to form a candidate classification result set R3; a weighted decision is performed on the candidate classification result set R3 to output the final classification result.