Medical term identification method, system and equipment and medium

By generating multi-level semantic representation vectors through character-level word segmentation and pre-trained language models, and combining them with location detection networks and medical domain rules, nested and non-continuous entities in medical texts are identified and structured. This solves the problems of boundary recognition errors and loss of semantic associations in traditional methods, and achieves more efficient medical information processing.

CN121809470APending Publication Date: 2026-04-07PUKANG (HANGZHOU) HEALTH TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-10
Publication Date
2026-04-07

AI Technical Summary

Technical Problem

Traditional medical terminology recognition methods suffer from boundary recognition errors and loss of semantic associations when dealing with nested entities and non-continuous entities, especially sequence labeling models which struggle to handle complex medical texts.

Method used

Character-level word segmentation and pre-trained language models are used to generate multi-level semantic representation vectors. Entity boundary detection is performed through a location detection network. Nested entities are identified by combining hierarchical region exhaustion and nesting constraint rules in the medical field. A virtual nested structure is constructed through semantic relevance evaluation, transforming non-continuous segments into nested forms. A gating attention mechanism is used for semantic aggregation and verification, and finally, an entity hierarchy graph is constructed.

Benefits of technology

It achieves accurate identification and structured representation of nested and discontinuous entities in medical texts, improving the accuracy and completeness of medical information processing and solving the problems of boundary identification errors and loss of semantic associations in traditional methods.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121809470A_ABST
    Figure CN121809470A_ABST
Patent Text Reader

Abstract

The invention relates to a medical term identification method, system and device and a medium. According to the method, a multi-level semantic representation vector is generated through character-level word segmentation and a pre-training language model, entity boundary detection is carried out based on the multi-level semantic representation vector by utilizing a position detection network to obtain an entity boundary relation matrix, and then nested entities are filtered and recognized through hierarchical region exhaustion and medical field rules. Constructing a virtual nested entity structure through semantic correlation evaluation to convert the discontinuous fragments into a nested form, performing semantic aggregation and verification by adopting a gating attention mechanism to obtain discontinuous entities, and finally constructing an entity hierarchy diagram and converting the entity hierarchy diagram into a structured medical entity list. Therefore, accurate recognition and structured representation of the nested entities and the discontinuous entities in the medical text are realized, the problems of boundary recognition errors and semantic association loss when a traditional sequence labeling model processes complex medical terms are effectively solved, and the accuracy and integrity of medical information processing are remarkably improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The application belongs to the technical field of medical information processing, and particularly relates to a medical term recognition method, system, device and medium. BACKGROUND

[0002] Medical texts, as an important carrier of medical knowledge, are characterized by containing a large number of professional terms, complex language structures and non-standardized expressions. In these texts, the ubiquitous existence of nested entities and non-continuous entities constitutes a unique technical challenge. Nested entities refer to a situation where the boundary of one entity completely contains the boundary of another entity, for example, in the phrase "left lung upper lobe small cell carcinoma", "left lung upper lobe" is an anatomical site entity, while the entire phrase is a disease entity, forming a multi-level nested structure. Non-continuous entities refer to a situation where a complete semantic entity is divided into discontinuous fragments by other words, for example, in "lung cancer with liver metastasis", "lung cancer" and "liver metastasis" together constitute a complete disease entity, but are separated by the word "with". These complex language phenomena greatly limit the application effect of traditional named entity recognition technology in the medical field.

[0003] Current mainstream medical term recognition methods are mainly based on sequence labeling models such as BiLSTM-CRF (Bidirectional Long Short-Term Memory Network-Conditional Random Field) and BERT-CRF. The basic principle of this kind of method is to assign a label (such as B-I-O annotation system) to each character in the text to identify the boundary and type of the entity. However, when facing nested entities, the structural limitations of sequence labeling models become apparent - each character can only be assigned one label and cannot belong to multiple entities of different granularities at the same time. For non-continuous entities, traditional sequence labeling models are also difficult to establish semantic associations between scattered fragments, resulting in boundary recognition errors and loss of semantic associations. SUMMARY

[0004] Therefore, it is necessary to provide a medical term recognition method, system, device and medium to solve the above technical problems.

[0005] In a first aspect, the application provides a medical term recognition method, comprising:

[0006] S1, performing character-level segmentation on a medical text to generate a character sequence; processing the character sequence through a pre-trained language model to generate semantic representation vectors representing the context representation at the character level; using an attention weighting fusion mechanism to integrate the semantic representation vectors output by each layer of the language model to generate multi-level semantic representation vectors;

[0007] S2, based on the multi-level semantic representation vector, the probability of each character as the starting position and the ending position of the entity is predicted by the position detection network composed of a full connection layer and a sigmoid activation function, and the starting position probability distribution and the ending position probability distribution are obtained; based on the starting position probability distribution and the ending position probability distribution, the entity boundary detection is performed to generate an entity boundary relationship matrix;

[0008] S3, according to the entity boundary relationship matrix, a candidate nested entity set is generated by a hierarchical region exhaustive strategy, and the candidate nested entity set is filtered based on the nested constraint rules in the medical field to output a nested entity with a type label;

[0009] S4, according to the continuous entity segments in the nested entity, the semantic correlation scores between different segments are evaluated; a virtual nested entity structure is constructed according to the semantic correlation scores, and the non-continuous segments are converted into a nested form through the virtual nested entity structure to obtain an initial non-continuous entity;

[0010] S5, a gating attention mechanism is used to perform semantic aggregation on the discrete segments of the initial non-continuous entity to generate a non-continuous entity overall semantic representation; based on the non-continuous entity overall semantic representation, the non-continuous entity is classified by type and verified for semantic integrity to output a verified non-continuous entity with a type label;

[0011] S6, an entity hierarchical graph is constructed with all the recognized nested entities and the verified non-continuous entity as nodes, and the entity hierarchical graph is converted into a structured medical entity list.

[0012] In a second aspect, the application also provides a medical term recognition system for implementing the method described in the first aspect, which comprises:

[0013] A context semantic deep representation module is configured to perform character-level tokenization on the medical text to generate a character sequence, process the character sequence through a pre-trained language model to generate a semantic representation vector representing the context representation at the character level, and integrate the semantic representation vectors output by each layer of the language model using an attention weighted fusion mechanism to generate a multi-level semantic representation vector.

[0014] A boundary accurate positioning module is configured to predict the probability of each character as the starting position and the ending position of the entity based on the multi-level semantic representation vector through a position detection network composed of a full connection layer and a sigmoid activation function to obtain the starting position probability distribution and the ending position probability distribution; and perform entity boundary detection based on the starting position probability distribution and the ending position probability distribution to generate an entity boundary relationship matrix.

[0015] The nested entity intelligent generation module is configured to generate a candidate nested entity set by a hierarchical region exhaustive strategy according to the entity boundary relation matrix, filter the candidate nested entity set based on nested constraint rules in the medical field, and output the nested entity with a type label.

[0016] The non-continuous entity reconstruction module is configured to evaluate semantic correlation scores between different segments according to continuous entity segments in the nested entity, construct a virtual nested entity structure according to the semantic correlation scores, convert the non-continuous segments into a nested form through the virtual nested entity structure, and obtain an initial non-continuous entity.

[0017] The non-continuous entity verification module is configured to perform semantic aggregation on discrete segments of the initial non-continuous entity by using a gated attention mechanism, generate a non-continuous entity overall semantic representation, perform type classification and semantic integrity verification on the non-continuous entity based on the non-continuous entity overall semantic representation, and output the non-continuous entity with a type label after verification.

[0018] The entity knowledge structuring module is configured to construct an entity hierarchical graph with all the recognized nested entities and the non-continuous entity after verification as nodes, and convert the entity hierarchical graph into a structured medical entity list.

[0019] In a third aspect, the present application also provides a computer device, including a memory and a processor, the memory stores a computer program, and the processor implements the medical term recognition method in the first aspect when executing the computer program.

[0020] In a fourth aspect, the present application also provides a computer readable storage medium, which stores a computer program, and the computer program is executed by a processor to implement the medical term recognition method in the first aspect.

[0021] The medical term recognition method, system, device and medium described above generate multi-level semantic representation vectors through character-level segmentation and a pre-trained language model, detect entity boundaries by using a position detection network based on the semantic representation vectors to obtain an entity boundary relation matrix, identify nested entities by a hierarchical region exhaustive strategy and medical field rule filtering, convert non-continuous segments into a nested form by constructing a virtual nested entity structure based on semantic correlation evaluation, perform semantic aggregation and verification by using a gated attention mechanism to obtain non-continuous entities, and finally construct an entity hierarchical graph to convert into a structured medical entity list, thereby realizing accurate recognition and structured representation of nested entities and non-continuous entities in medical texts, effectively solving the boundary recognition errors and semantic correlation loss problems of traditional sequence labeling models in processing complex medical terms, and significantly improving the accuracy and integrity of medical information processing. BRIEF DESCRIPTION OF DRAWINGS

[0022] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related art, the following will briefly introduce the drawings needed to be used in the embodiments or the related art description. Obviously, the drawings in the following description only some embodiments of the present application, and for those skilled in the art, other drawings can also be obtained without creative labor on the basis of these drawings.

[0023] Figure 1 The flowchart of the medical term recognition method provided by the present application is shown in the figure.

[0024] Figure 2 The flowchart of generating an entity boundary relation matrix in an alternative embodiment of the present application is shown in the figure.

[0025] Figure 3 The structural diagram of the medical term recognition system provided by the present application is shown in the figure. DETAILED DESCRIPTION

[0026] In order to make the purpose, technical solutions and advantages of the present application more clear, the following will further describe the present application in combination with the drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application, and are not used to limit the present application.

[0027] REFERENCE Figure 1 The flowchart of the medical term recognition method provided by the present application is shown in the figure, which comprises the following steps:

[0028] S1, character-level segmentation of medical text is performed to generate a character sequence; the character sequence is processed by a pre-trained language model to generate a semantic representation vector representing the context representation at the character level; an attention weighted fusion mechanism is used to integrate the semantic representation vectors output by each layer of the language model to generate a multi-level semantic representation vector.

[0029] Specifically, when performing character-level segmentation of medical text, each character of the input medical text is traversed, and no traditional word-level segmentation operation is performed, each character is directly taken as an independent segmentation unit to generate a character sequence. The core reason for using character-level segmentation is that there are a large number of rare characters, abbreviations and nested structures in medical terms, and word-level segmentation is prone to entity boundary segmentation errors, while character-level segmentation can completely preserve the original character information of the text, providing a basis for subsequent entity boundary detection.

[0030] When processing the character sequence by the pre-trained language model, the pre-trained language model based on medical field fine-tuning is adopted. First, the character sequence is preprocessed, a specific start mark is added at the start position of the sequence, a specific end mark is added at the end position, and then each character is mapped to a corresponding vocabulary index (the vocabulary is expanded based on a medical corpus, and contains medical professional characters and symbols). The preprocessed index sequence is input into the pre-trained language model, and the context dependency between characters is captured through the multi-head self-attention mechanism of each layer encoder. The semantic representation vector output by each layer encoder is denoted as .

[0031] When integrating the semantic representation vectors of each layer by using the attention weighted fusion mechanism, first, the global mean vector of each layer output vector is calculated, and the mean vectors of each layer are spliced to form a feature matrix. Each mean vector is converted by a single-layer neural network, and then an output dimension of 1 full connection layer is used to calculate the attention weight of each layer , and the calculation of the attention weight satisfies the following relationship:

[0032]

[0033] wherein, is a softmax activation function, ensuring that the sum of all layer attention weights is 1, W is a weight matrix of the full connection layer, U is a weight matrix of the feature conversion, is the global mean vector of the output vector of the kth layer, is a bias term of the feature conversion, is a bias term of the full connection layer.

[0034] Finally, the multi-level semantic representation vector is generated by weighted summation, and the calculation formula is:

[0035]

[0036] wherein, H is a multi-level semantic representation vector, is the attention weight of the kth layer, is the semantic representation vector output by the kth layer encoder, which integrates the bottom layer syntax features and high layer semantic features, and provides more comprehensive semantic support for subsequent entity recognition.

[0037] S2, based on the multi-level semantic representation vector, the probability of each character as the start position and end position of the entity is predicted by a position detection network composed of a full connection layer and a sigmoid activation function, to obtain a start position probability distribution and an end position probability distribution; based on the start position probability distribution and the end position probability distribution, the entity boundary detection is performed to generate an entity boundary relationship matrix.

[0038] Specifically, a position detection network is constructed based on the multi-level semantic representation vector H, which consists of two fully connected layers and sigmoid activation functions. The first fully connected layer maps the feature dimension of H, adopts a ReLU activation function for nonlinear transformation, and outputs a feature matrix . The second fully connected layer maps the feature dimension of to 2 dimensions (corresponding to the start position and end position, respectively), and outputs a matrix . After sigmoid activation function processing, the start position probability and the end position probability of each character are obtained, forming the start position probability distribution S and the end position probability distribution E, where S consists of the start position probabilities of all characters, and E consists of the end position probabilities of all characters.

[0039] When performing entity boundary detection, a probability threshold is first set (the optimal value is determined through cross-validation), and for each character i, if the start position probability of the character is greater than or equal to the threshold, it is marked as a potential start position, and if the end position probability of the character is greater than or equal to the threshold, it is marked as a potential end position. An n x n dimensional entity boundary relation matrix M corresponding to the length of the character sequence is constructed, and the definition of matrix element M[i][j] is as follows: if i is a potential start position, j is a potential end position, and i ≤ j, then M[i][j] = 1; otherwise, M[i][j] = 0. This matrix directly represents all possible entity boundary combinations, where the positions with M[i][j] = 1 correspond to the start character i and the end character j of a candidate entity.

[0040] In the model training phase, a binary cross-entropy loss function is used to optimize the position detection network parameters, and the calculation formula of the loss function is as follows:

[0041]

[0042] where L is the loss function value, is the label of whether character i is a real start position (taking values of 0 or 1, with 1 indicating a real start position and 0 indicating not a real start position), is the predicted start position probability of character i, is the label of whether character i is a real end position (taking values of 0 or 1, with 1 indicating a real end position and 0 indicating not a real end position), is the predicted end position probability of character i, and n is the total length of the character sequence. The optimization process uses an optimizer suitable for deep learning models, and a weight decay strategy is used to avoid overfitting.

[0043] S3, generating a candidate nested entity set according to the entity boundary relation matrix through a hierarchical region exhaustive strategy, filtering the candidate nested entity set based on medical field nested constraint rules, and outputting a nested entity with a type label.

[0044] Specifically, according to the entity boundary relation matrix M, a hierarchical region exhaustive strategy is used to generate a candidate nested entity set. The hierarchical strategy is divided into multiple levels according to the entity length k (k is the number of characters contained in the entity, that is, the difference between the end character position and the start character position plus 1), and traversed layer by layer from the smallest entity length. For each level k, all (i,j) pairs that satisfy the end character position equal to the start character position plus k minus 1 and M[i][j]=1 are traversed, and the corresponding character sequence is taken as a candidate entity. Through hierarchical exhaustive strategy, all possible nested entities can be covered, avoiding missing multi-layer nested structure, even complex entity combination containing relationship can be completely extracted through layer-by-layer traversal.

[0045] The candidate nested entity set is filtered based on the medical field nested constraint rules. The constraint rules are based on the semantic logic and structural characteristics of medical entities, and specifically include type constraints, semantic consistency constraints, and overlap constraints. Type constraints refer to the nested relationship between different types of medical entities that need to comply with medical common sense, for example, anatomical site entities can be nested by disease entities and examination entities, but cannot be nested in the opposite direction. Semantic consistency constraints refer to the need for semantic dependency between nested entities, which is achieved by calculating the semantic similarity of inner and outer entities. If the similarity is lower than the set standard, the candidate entity is removed. The overlap constraint refers to the fact that candidate entities with non-nested relationships cannot have partial overlap. If there is partial overlap, the entity with lower semantic relevance is removed.

[0046] After filtering, an entity type classifier is used to assign a type label to the candidate entity. The classifier takes the multi-level semantic vector segment corresponding to the candidate entity (i.e., the average vector of the multi-level semantic vector of the characters contained in the candidate entity) as input, and uses two fully connected layers and a Softmax output layer. The first fully connected layer performs feature dimension conversion and introduces nonlinearity through the ReLU activation function, and the second fully connected layer maps the features to a dimension corresponding to the number of medical entity types. The Softmax output layer converts the features into a probability distribution of the entity belonging to each type, and takes the type corresponding to the maximum probability as the label of the candidate entity. Finally, a set of nested entities with type labels is output, and each element in the set contains the text segment, start position, end position, and type label of the entity.

[0047] S4, according to the continuous entity segments in the nested entity, evaluating the semantic relevance scores between different segments; constructing a virtual nested entity structure according to the semantic relevance scores, converting non-continuous segments into nested form through the virtual nested entity structure, and obtaining initial non-continuous entities.

[0048] Specifically, when evaluating the semantic relevance between continuous entity segments in a nested entity, first, potential segments of non-continuous entities are extracted from the identified nested entity, which are continuous entities separated by other characters but semantically related. To evaluate the semantic relevance, the semantic similarity between different segments is calculated, and the cosine similarity based on semantic vectors is used as the scoring indicator, and the calculation formula is:

[0049]

[0050] wherein score is the semantic relevance score of the two segments, is the average semantic vector of the first segment (i.e., the average value of the multi-level semantic vectors of the characters in the segment), is the average semantic vector of the second segment, and “・” represents the dot product operation of the vectors, represents the L2 norm of (i.e., the square root of the sum of squares of the elements of the vector), represents the L2 norm. To improve the scoring accuracy, a medical field semantic knowledge base (based on an authoritative medical terminology base) is introduced, and the segment text is matched with the entities in the knowledge base. If both segments belong to the same upper concept, a correction value is added based on the cosine similarity, and the size of the correction value is determined according to the semantic association strength of the upper concept.

[0051] According to the semantic relevance score, a virtual nested entity structure is constructed, and a scoring threshold is set (determined by optimizing the validation set). If the semantic relevance score of the two segments is greater than or equal to the threshold, the latter segment is considered as a virtual sub-entity of the former segment, and a virtual nested relationship is constructed. Through this virtual nested relationship, the non-continuous segments originally separated by other characters are integrated into a continuous virtual entity boundary, which covers all related segments and separation characters. Thus, an initial non-continuous entity is obtained, which includes the integrated text segments, the starting position and the ending position corresponding to the virtual boundary, and the temporary type label as a candidate.

[0052] For cases containing multiple segments (three or more), the semantic relevance scores between all pairs of segments are calculated, and a scoring matrix is constructed, with the elements of the matrix being the semantic relevance scores of the corresponding two segments. Based on the scoring matrix, a hierarchical clustering method is used to determine the nesting order between the segments. In the hierarchical clustering process, the semantic relevance score is used as the similarity indicator, and the segments with higher scores are preferentially clustered into a class and their nesting relationship is determined. A multi-level virtual nested structure is gradually constructed to ensure that all semantically related segments are integrated into the same virtual entity boundary, forming an initial non-continuous entity containing all related segments.

[0053] S5, adopting a gated attention mechanism to perform semantic aggregation on the discrete segments of the initial discontinuous entity to generate an overall semantic representation of the discontinuous entity; performing type classification and semantic integrity verification on the discontinuous entity based on the overall semantic representation of the discontinuous entity to output a verified discontinuous entity with a type label.

[0054] Specifically, the gated attention mechanism is used to perform semantic aggregation on the discrete segments of the initial discontinuous entity, which is composed of a gating unit and an attention unit, and can adaptively filter and weight the effective semantic information of each segment. Let the initial discontinuous entity contain k discrete segments, and the semantic vector corresponding to each segment be (t from 1 to k), first calculate the gating coefficient of each segment through the gating unit, and the calculation formula of the gating coefficient is:

[0055]

[0056] wherein, is the gating coefficient of the tth segment (the value range is 0 to 1, and the closer to 1 indicates that the information transmission of the segment is more sufficient), is the weight matrix of the gating unit, is the semantic vector of the tth segment (i.e. the average semantic vector of the segment), is the bias term of the gating unit, and sigmoid is the activation function, which maps the calculation result to the range of 0 to 1.

[0057] Then calculate the attention weight of each segment through the attention unit. First, map the semantic vector of each segment to the attention space to obtain the mapped feature vector , and the calculation formula is:

[0058]

[0059] wherein, is the mapped feature vector of the tth segment, is the mapping weight matrix of the attention unit, is the semantic vector of the tth segment, is the mapping bias term of the attention unit.

[0060] Based on the mapped feature vector, the attention score is calculated, and the calculation formula is:

[0061]

[0062] wherein, is the attention score of the tth segment, is the weight vector of attention scores, tanh is the hyperbolic tangent activation function, which is used to perform nonlinear transformation on the mapped feature vector. The attention scores of all segments are normalized by the softmax function to obtain the attention weights , and the calculation formula is:

[0063]

[0064] wherein, is the attention weight of the t-th segment (the sum of the attention weights of all segments is 1), exp is the exponential function, and k is the total number of discrete segments.

[0065] Finally, the overall semantic representation of the non-continuous entity is generated by weighted summation, and the calculation formula is:

[0066]

[0067] wherein, is the overall semantic representation of the non-continuous entity, is the gating coefficient of the t-th segment, is the attention weight of the t-th segment, is the semantic vector of the t-th segment, k is the total number of discrete segments, and the vector integrates the effective semantic information of each discrete segment, realizing the semantic unification of the non-continuous segment.

[0068] Based on the overall semantic representation , type classification and semantic integrity verification are performed. The type classification adopts the same classifier structure as the nested entity, taking as the input, and outputting the probability distribution of the entity belonging to each medical entity type. The type with the maximum probability is taken as the final type label of the non-continuous entity. The semantic integrity verification is based on the medical entity semantic template library and knowledge base. The template library contains typical structures of various non-continuous entities (such as “disease + separator word + metastatic lesion”, “drug + separator word + drug”, etc.). First, the text structure of the initial non-continuous entity is matched with the structures in the template library. If the matching is successful, it is preliminarily determined to be semantically complete. Then, the average semantic similarity of with the same entity in the knowledge base is calculated. If the similarity is greater than or equal to the set threshold, it is confirmed to be semantically complete, otherwise it is considered to be semantically incomplete and is rejected. Finally, the verified non-continuous entity with type label is output.

[0069] S6, all identified nested entities and verified non-continuous entities are taken as nodes to construct an entity hierarchical graph, and the entity hierarchical graph is converted into a structured medical entity list.

[0070] Specifically, an entity hierarchy graph is constructed with all identified nested entities and verified non-continuous entities as nodes, the node attributes of the graph include entity text, start position, end position and type label, and the edges represent the nesting relationship between entities (i.e. the containing relationship between parent nodes and child nodes). The construction process is as follows: first, traverse all entities, sort them in descending order according to their end positions (prefer to process entities with larger coverage), for each entity A, traverse all other entities B, if the start position of entity A is less than or equal to the start position of entity B and the end position of entity A is greater than or equal to the end position of entity B (i.e. the text range of entity A completely contains the text range of entity B), add a directed edge between entity A and entity B, the direction is from entity A to entity B, and mark the edge as indicating the "contain" relationship. In this way, all entities are connected according to the containing relationship to form a clear entity hierarchy graph, the top-level nodes in the graph are entities that are not contained by other entities, and the bottom-level nodes are entities that do not contain other entities.

[0071] When converting the entity hierarchy graph into a structured medical entity list, a breadth-first traversal strategy is used to traverse the hierarchy graph. The traversal starts from the top-level entity and successively visits all child entities (i.e. the lower-level entities connected to the entity through the "contain" edge) of each entity, recording the complete attribute information of each entity and the information of the child entities belonging to it. The structured list adopts a tree structure format, each entity entry contains five fields: "entity text", "start position", "end position", "type label" and "child entity list". The "child entity list" field recursively contains the entries of all child entities of the entity, and if the entity has no subordinate entities, the "child entity list" is an empty list. This structured list clearly presents the hierarchical relationship between entities and the detailed attributes of each entity, facilitating subsequent medical information processing tasks such as electronic medical record structuring and medical knowledge graph construction, and also providing convenience for medical personnel to quickly obtain key medical terms and relationships in the text.

[0072] The above-mentioned medical term recognition method generates multi-level semantic representation vectors through character-level segmentation and pre-trained language models, uses a position detection network to detect entity boundaries based on the semantic representation vectors to obtain an entity boundary relationship matrix, then identifies nested entities through hierarchical region enumeration and medical field rule filtering, converts non-continuous segments into nested form by constructing a virtual nested entity structure based on semantic correlation evaluation, and finally obtains non-continuous entities through semantic aggregation and verification using a gated attention mechanism, and finally constructs an entity hierarchy graph to convert it into a structured medical entity list, thereby achieving accurate recognition and structured representation of nested entities and non-continuous entities in medical text, effectively solving the boundary recognition errors and semantic association loss problems of traditional sequence labeling models when processing complex medical terms, and significantly improving the accuracy and integrity of medical information processing.

[0073] ReferenceFigure 2 In an optional embodiment, the entity boundary detection based on the start position probability distribution and the end position probability distribution generates an entity boundary relation matrix, including the following steps:

[0074] S11, filtering the start position probability distribution according to a preset first probability threshold, retaining positions with probability values exceeding the first probability threshold, and generating a candidate start position set; filtering the end position probability distribution according to a preset second probability threshold, retaining positions with probability values exceeding the second probability threshold, and generating a candidate end position set.

[0075] Specifically, this step processes the probability distributions of the start position and the end position by differentiated probability thresholds to adapt to the different characteristics of the two types of positions in semantic representation.

[0076] First, the first probability threshold and the second probability threshold are set, which can be determined by cross-validation of a medical field validation set, and can be dynamically adjusted according to the density of entities in the text. For example, in entity-intensive medical text (such as the diagnosis part of the medical record), the threshold can be appropriately lowered to avoid missing potential entities; in entity-sparse text (such as the medical history description part), the threshold can be appropriately increased to reduce invalid candidates.

[0077] When filtering the start position probability distribution, the probability value corresponding to each position in the distribution is traversed, and positions with probability values exceeding the first probability threshold are extracted to form a candidate start position set. Each element in the set records the index of the position and the corresponding probability value, which is convenient for subsequent tracing and verification. Similarly, when filtering the end position probability distribution, the probability value of each position is traversed, and positions exceeding the second probability threshold are retained to generate a candidate end position set.

[0078] The reason for using differentiated thresholds is that the semantic features of the start position characters in medical text are often more hidden (such as "left" as the start character of "left lung", which has lower semantic recognition than "cancer" as the end character). By setting independent thresholds, the screening accuracy of the two types of positions can be optimized respectively, and the problem of missing start positions or misselecting end positions caused by a single threshold can be reduced.

[0079] S12, for each position i in the candidate start position set and each position j in the candidate end position set, when i≤j, the type association degree between position i and position j is calculated by a bi-affine classifier; the calculation formula of the bi-affine classifier is:

[0080]

[0081] wherein, and respectively represent the multi-level semantic representation vectors of position i and position j, U is a bilinear transformation matrix, W is a linear transformation matrix, b is a bias vector, and [;] represents a vector splicing operation; represents the type probability distribution of the entity segment composed of position i to position j, as the type relevance.

[0082] Specifically, this step calculates the type relevance of the candidate start-end position pair through a bi-affine classifier. The core is to capture the interaction features of the two position semantic vectors through a bi-affine mechanism, and to fuse the global features after vector splicing, so as to realize accurate evaluation of the type relevance of the position pair.

[0083] For each position i in the candidate start position set, it is matched with each position j in the candidate end position set one by one. Only when i≤j (to ensure logical reasonableness of the positions and avoid invalid combinations where the start position is after the end position), the calculation of the bi-affine classifier is triggered.

[0084] In the calculation formula of the bi-affine classifier, represents the multi-level semantic representation vector of position i, that is, the vector corresponding to position i in the multi-level semantic vector generated by attention weighted fusion in step S1, which contains the context semantic information of position i; represents the multi-level semantic representation vector of position j, which is the same as The dimensions of the semantic features are consistent and the representation logic is unified; U is a bilinear transformation matrix with dimensions of multi-level semantic vector dimensions x multi-level semantic vector dimensions, and its core role is to capture the second-order interaction features between For example, through matrix multiplication, the semantic association of the two vectors is converted into numerical features, highlighting the semantic synergy between positions i and j; W is a linear transformation matrix with dimensions of entity type number x (2 x multi-level semantic vector dimensions), which is used for linear feature conversion of the spliced vector, where “2 x multi-level semantic vector dimensions” corresponds to the dimension of [;] represents a vector splicing operation, that is, the splicing of and in the column direction to form a new vector, which retains the independent semantic features of the two positions); b is a bias vector with dimensions of entity type number, which is used to adjust the baseline of the overall calculation result and compensate for the deviation in the feature conversion process; Softmax is an activation function, which is used to convert the previous calculation result (the superposition value of linear and bilinear features) into a probability distribution, ensuring that each element in takes a value between 0 and 1 and the sum of all elements is 1; The type probability distribution of the entity segment formed by the position i to the position j, each element corresponds to the probability of a medical entity type (such as an anatomical site, a disease, a drug, etc.), and the probability distribution is directly used as the type association degree of the position i and the position j. The higher the probability is, the stronger the possibility of the position to form the entity of the corresponding type is.

[0085] S13, based on the type association degrees of all candidate start position-candidate end position pairs, constructing an entity boundary relation matrix containing all candidate entities and corresponding type probabilities.

[0086] Specifically, based on the type association degrees of all valid candidate start-end position pairs, a structured entity boundary relation matrix is constructed, and the core is to integrate the boundary information and the type association information of the position pair into the matrix element, forming a matrix structure with boundary positioning and type prediction functions.

[0087] The row index of the entity boundary relation matrix corresponds to the position sequence number in the candidate start position set, and the column index corresponds to the position sequence number in the candidate end position set. The size of the matrix is the number of candidate start positions x the number of candidate end positions. For each element in the matrix (corresponding to the combination of candidate start position i and candidate end position j), its storage content contains two parts: one is the boundary identification of the position pair, that is, the character position index of i and j in the original medical text is recorded, which identifies the boundary range of the entity segment corresponding to the element; the other is the type association degree of the position pair, that is, the type probability distribution information is completely retained. If a position pair (i, j) does not satisfy the logical condition i≤j (that is, the start position is after the end position), the matrix element is marked as invalid state, and the boundary and type information is not stored, so as to avoid invalid data interference in subsequent processing.

[0088] Through this construction method, the entity boundary relation matrix not only can intuitively present all potential entity boundary combinations, but also can predict the entity type possibility corresponding to each boundary combination through the type association degree, which provides a direct basis for subsequent candidate entity screening (such as threshold screening based on type probability), compared with the matrix containing only boundary identification in S2, the information dimension of the matrix is richer, which can significantly improve the efficiency and accuracy of subsequent entity recognition.

[0089] In an optional embodiment, according to the entity boundary relation matrix, a candidate nested entity set is generated through a hierarchical region exhaustive strategy, the candidate nested entity set is filtered based on the nested constraint rules in the medical field, and a nested entity with a type label is output, including the following steps:

[0090] S21, based on the entity boundary relation matrix, extracting all candidate start position and end position pairs with type probability exceeding a preset threshold to form an initial candidate entity set.

[0091] Specifically, the core of this step is to extract initial candidate entities from the entity boundary relation matrix, and the key is to filter out location pairs with higher type credibility through a preset threshold, laying a high-quality data foundation for subsequent processing.

[0092] The value logic of the preset threshold is as follows: the threshold needs to be determined based on the cross-validation of the medical field annotation data set, and the F1 value inflection point of entity type recognition can be referred to. For example, in a verification set containing multiple types of entities such as anatomical sites, diseases, and drugs, by adjusting the threshold to observe the recognition accuracy of each type of entity, the threshold that makes the overall F1 value highest is selected as the final preset threshold, and fine-tuning for different entity types is allowed (such as disease entities, which have more significant semantic characteristics, so the threshold can be slightly higher than that of anatomical site entities to reduce misselection).

[0093] During the extraction process, all valid elements (i.e. candidate starting position i-candidate end position j pairs that meet i≤j) in the entity boundary relation matrix are traversed, and the type probability distribution stored by each element is read When the maximum probability value in the distribution exceeds the preset threshold, the position pair is included in the initial candidate entity set. The core information recorded in each initial candidate entity in the set includes: the character index of the candidate starting position i in the original medical text, the character index of the candidate end position j in the original medical text, the corresponding entity text segment (composed of characters from i to j), the type probability distribution and the candidate type determined by the maximum probability value (as a temporary type label), ensuring that the position, semantic and type credibility information of the entity can be traced back in subsequent steps.

[0094] S22, the initial candidate entity set is layered according to the entity length, and for each candidate entity in the layer, the type probability is sorted from high to low to generate a sorted candidate entity list.

[0095] Specifically, the step optimizes the processing order of the candidate entities by entity length layering and type probability sorting, reduces the computational complexity of subsequent compatibility checking, and prioritizes high-confidence entities. The calculation method of entity length is "entity end position j-entity start position i+1" (i.e., the total number of characters included in the entity), and the layering rules can be set in combination with the common length characteristics of entities in medical text, such as dividing the length into short entity layer (length 1-3 characters, such as "left lung", "liver cancer"), medium entity layer (length 4-8 characters, such as "left lung upper lobe", "small cell lung cancer"), and long entity layer (length 9 characters and above, such as "left lung upper lobe small cell carcinoma", "chronic obstructive pulmonary disease"). The core purpose of layering is that entities of different lengths usually exhibit the rule of "long entity containing short entity" in nested relationships. Processing by layer can focus on horizontal comparison between entities of the same length and vertical nested verification between entities of different lengths, avoiding the inefficiency caused by unordered comparison across lengths.

[0096] For each candidate entity within a level, the maximum probability value in the type probability distribution is sorted from high to low to generate a sorted candidate entity list. The essence of the sorting logic is "confidence first". When there is an entity overlap conflict, the high-confidence entity with a high ranking is prioritized, reducing the interference of low-confidence entities on the final result. For example, in the short entity layer, "liver cancer" (type probability 0.92) will be placed before "liver" (type probability 0.78). If there is boundary overlap between the two, the nested reasonableness of "liver cancer" will be prioritized.

[0097] S23, based on the medical field nested constraint rules, the candidate entities in the candidate entity list with overlapping regions are subjected to compatibility checking; wherein the medical field nested constraint rules include type compatibility rules and boundary inclusion rules, the type compatibility rules define allowed entity type combinations for nesting, and the boundary inclusion rules define boundary constraint conditions for nested entities.

[0098] Specifically, this step performs compatibility checking through medical field nested constraint rules, the core of which is to eliminate candidate entities that do not conform to the nesting rules based on medical semantic logic and entity boundary characteristics, ensuring the reasonableness of the nested relationship.

[0099] The type compatibility rule defines the allowed nested type combinations based on the semantic subordination of medical entities, which can be formulated in combination with an authoritative medical terminology system (e.g., UMLS), for example, to allow nested combinations of "anatomical site entity (ANAT) -> disease entity (DIS)" (e.g., "left upper lobe of lung" is contained in "left upper lobe of lung small cell carcinoma"), "anatomical site entity (ANAT) -> examination entity (EXAM)" (e.g., "coronary artery" is contained in "coronary artery CT angiography"), and "drug component entity (DRUG_COMP) -> drug entity (DRUG)" (e.g., "aspirin" is contained in "aspirin enteric-coated tablets"), and to prohibit reverse nesting (e.g., "left upper lobe of lung small cell carcinoma" cannot be contained in "left upper lobe of lung") and type combinations without semantic association (e.g., "drug entity (DRUG) -> examination entity (EXAM)").

[0100] The boundary inclusion rule defines the boundary constraint conditions of nested entities, and clearly defines the boundary relationship between the "parent entity" and the "child entity": if entity A is the parent entity of entity B (A contains B), then the "start position of entity A <= start position of entity B" and "end position of entity A >= end position of entity B" must be met, and "partial overlap" (i.e., start position of entity B < start position of entity A <= end position of entity B < end position of entity A, or start position of entity A < start position of entity B < end position of entity A < end position of entity B) is prohibited, and only "complete inclusion" or "no overlap" is allowed.

[0101] The implementation process of the compatibility check is as follows: the candidate entity list is traversed in order from the long entity layer to the short entity layer, and for each current entity, the entities in the "to-be-kept set" are compared pairwise, first the type combination is checked for compliance with the type compatibility rule, and then the boundary relationship is checked for compliance with the boundary inclusion rule, if both are met, it is determined to be "compatible", the current entity is kept and the to-be-kept set is updated; if any one is not met, it is determined to be "incompatible", and the current entity is marked as to-be-removed.

[0102] S24, remove the candidate entities that do not meet the medical field nested constraint rules, generate a filtered candidate nested entity set; perform boundary optimization processing on the filtered candidate nested entity set to merge adjacent entities with high overlap, and output the nested entities with type labels.

[0103] Specifically, the step generates the final nested entity with type label by removing incompatible entities and boundary optimization, further improving the accuracy and integrity of entity boundary. The removal operation is based on the compatibility check result of S23, and the candidate entity marked as "to be removed state" is deleted from the list, and the remaining entities constitute the filtered candidate nested entity set. The removal reason (such as type incompatibility, boundary partial overlap) is recorded during the removal process, which facilitates the analysis of error sources during subsequent model optimization.

[0104] The boundary optimization process focuses on merging adjacent entities with high overlap. The calculation method of overlap can use character-level overlap rate as the evaluation index, and the calculation formula is:

[0105]

[0106] wherein, overlap is the overlap of two adjacent entities A and B, represents the set of identical characters in the entity text segment of A and B, len(·) represents the character length of the set or text segment, and min(·) represents the smaller value of the lengths of the two entities.

[0107] When the overlap exceeds the preset overlap threshold, it is determined as "high overlap adjacent entity" and merging is performed. The starting position of the merged entity takes the smaller value of the starting positions of the two entities, the ending position takes the larger value of the ending positions of the two entities, the entity text segment is the character sequence corresponding to the merged boundary, the type probability distribution takes the weighted average of the type probability distributions of the two entities (the weight is the maximum type probability of each), and the merged candidate type is determined by the maximum probability value of the probability distribution after weighted average. For example, the overlap of entity A ("left upper lobe", starting 1-4, type probability 0.91) and entity B ("left upper lobe small", starting 1-5, type probability 0.85) is 4 / 4=1.0, which exceeds the threshold and is merged into entity C ("left upper lobe small", starting 1-5, type probability weighted average is (0.91x0.91+0.85x0.85) / (0.91+0.85)≈0.88, and the candidate type is still anatomical site).

[0108] Finally, for each entity in the optimized candidate nested entity set, confirm its type label (i.e. the entity type corresponding to the maximum probability of the probability distribution after weighted average), output the nested entity with type label containing "entity text segment, starting position, ending position, type label, type probability", and the entity set is used for subsequent non-continuous entity processing or entity hierarchy graph construction.

[0109] In an alternative embodiment, the semantic correlation scores between different segments are evaluated according to the continuous entity segments in the nested entity; a virtual nested entity structure is constructed according to the semantic correlation scores, and the non-continuous segments are converted into a nested form through the virtual nested entity structure to obtain the initial non-continuous entity, including the following steps:

[0110] S31, based on the continuous entity segments, extract all non-continuous entity segment combinations within the semantic distance threshold range to form a candidate non-continuous entity set.

[0111] Specifically, this step focuses on the extraction of candidate non-continuous entity segment combinations, and the core is to filter out continuous entity segments with potential association based on semantic distance, thereby narrowing the scope for subsequent semantic correlation evaluation.

[0112] The source of the continuous entity segment is the nested entity identified in S1 (such as the complete and boundary continuous nested entity "lung cancer", "liver metastasis"), which is a key semantic unit separated by other characters (such as conjunctions such as "with", "and", etc.) in medical text. The semantic distance threshold is determined by the distance measure (such as Euclidean distance or cosine distance) of the multi-level semantic representation vector, which is determined by statistical analysis of the medical corpus, and its role is to filter out segment combinations with very low semantic relevance (for example, "lung cancer" and "blood routine" have no direct semantic association).

[0113] In implementation, first extract all continuous segments corresponding to the nested entity, then calculate the semantic distance (based on the aggregated representation vector of the segment) of any two segments, and include the segment combination with a semantic distance less than the preset threshold in the candidate non-continuous entity set. Each element in the set records the text content, original position and semantic distance value of the two (or multiple) segments. The advantage of using semantic distance pre-screening is that it can exclude obviously irrelevant segment combinations in advance, reduce the redundancy of subsequent semantic correlation score calculation, and improve the overall processing efficiency.

[0114] S32, for each candidate non-continuous entity in the candidate non-continuous entity set, calculate the semantic correlation score between the discrete segments contained in the candidate non-continuous entity through semantic association degree evaluation; the calculation formula of the semantic association degree evaluation is:

[0115]

[0116] wherein, and represent the discrete segments of different candidate non-continuous entities; and respectively represent the aggregated representations of and , which are extracted from the multi-level semantic representation vector through attention pooling operation; denotes the semantic correlation score between two segments, and λ is a preset balancing parameter, denotes the semantic correlation score between two segments, and .

[0117] Specifically, the semantic correlation score between discrete segments is calculated by the semantic correlation evaluation formula, and the core is to fuse the cosine similarity of semantic vectors and the domain correlation information of the medical knowledge base to realize more accurate correlation quantification. This step calculates the semantic correlation score between each two segments in the candidate non-continuous entity set containing multiple discrete segments (such as the candidate entity containing “lung cancer”, “liver metastasis” two segments) one by one.

[0118] In the formula of semantic correlation evaluation, and respectively denote two different discrete segments in the candidate non-continuous entity, which are derived from the continuous entity segments screened in the S31 step and are the core semantic units constituting the non-continuous entity; and are the aggregate representations of and , and the acquisition method is to extract from the multi-level semantic representation vector through attention pooling operation. Specifically, for the multi-level semantic vector corresponding to all characters (such as “lung cancer” contains character positions 1-2) contained in the segment , the attention weight of each character (based on the contribution of the character to the overall semantic of the segment) is calculated, and then the weighted sum is obtained to get the overall aggregate representation of the segment , which ensures that can completely represent the semantic information of the segment; is the cosine similarity between and , which is used to quantify the similarity of the two segments in the semantic vector space. The higher the similarity, the closer the semantic of the segment; is the correlation score of the two segment types calculated based on the medical knowledge base. The medical knowledge base can use authoritative libraries such as UMLS (Unified Medical Language System), and the correlation score of the two segments is calculated by querying the segments and The semantic relationship of the corresponding medical concept in the knowledge base (such as belonging to a disease category, having a causal relationship, etc.), the relationship strength is converted into a score in the interval [0, 1] (for example, “lung cancer” and “liver metastasis” belong to “malignant tumor related lesions”, the score is close to 1; “cold” and “fracture” have no correlation, the score is close to 0); λ is a preset balance parameter, whose value range is [0, 1], which adjusts the weight of the cosine similarity (semantic vector level) and the knowledge base relevance score (domain knowledge level) in the total score, avoiding the deviation caused by single dimension evaluation (for example, when the semantic vectors of the segments are similar but the domain correlation is weak, the influence of the cosine similarity is reduced through λ); That is, the final semantic relevance score, the higher the score, the stronger the possibility that the two segments constitute the same non-continuous entity.

[0119] S33, when the semantic relevance score exceeds a preset threshold, it is determined that the corresponding discrete segments belong to the same non-continuous entity, and an effective non-continuous entity set is generated.

[0120] Specifically, the effective non-continuous entity is screened based on the semantic relevance score, and the core is to determine whether the segments belong to the same non-continuous entity through the preset threshold, and to form an accurate effective entity set. The semantic relevance score threshold can be determined through multiple rounds of experiments on the medical field verification set, and the recall rate and precision rate need to be considered (for example, if the threshold is too high, some weakly correlated but real non-continuous entities may be missed, and if the threshold is too low, irrelevant segments may be introduced). When implementing, for each candidate non-continuous entity in the candidate non-continuous entity set, check the semantic relevance score between any two segments included in the candidate non-continuous entity. Whether the score exceeds the preset threshold: if the scores of all pairs of segments exceed the threshold, it is determined that these segments belong to the same non-continuous entity, and the candidate entity is included in the effective non-continuous entity set; if the score of at least one pair of segments does not exceed the threshold, it is determined that the candidate entity contains irrelevant segments and is excluded. For candidate entities containing three or more segments, it is necessary to ensure that all segments form a “connected” association relationship (i.e. the scores of segments A and B, B and C, and A and C all exceed the threshold), to avoid the contradictory situation that “segment A is related to B, B is related to C, but A is not related to C”, and to ensure that the non-continuous entity segments in the effective set have consistent semantic relevance.

[0121] S34, a virtual outer boundary is constructed for the effective non-continuous entity, and a virtual nested entity is obtained; the virtual nested entity is subjected to nested entity recognition, and a non-continuous entity recognition result containing a type label is obtained as an initial non-continuous entity; wherein the virtual outer boundary completely contains all discrete segments of the effective non-continuous entity.

[0122] Specifically, the step is to obtain the initial non-continuous entity by constructing a virtual outer boundary and type identification, and the core is to convert the scattered discrete fragments into a structured virtual nested form, laying a foundation for subsequent semantic aggregation.

[0123] First, a virtual outer boundary is constructed. For all discrete fragments in the effective non-continuous entity, the minimum starting position (i.e., the minimum value of all fragment starting positions) and the maximum ending position (i.e., the maximum value of all fragment ending positions) of these fragments in the original medical text are extracted. The minimum starting position is taken as the starting point of the virtual boundary, and the maximum ending position is taken as the ending point of the virtual boundary to form a virtual outer boundary that completely contains all discrete fragments. For example, the effective non-continuous entity contains fragments "lung cancer" (position 1-2) and "liver metastasis" (position 4-6), and the starting position of the virtual outer boundary is 1 and the ending position is 6, covering the entire text range of "lung cancer with liver metastasis".

[0124] Then, the virtual nested entity is identified. The text fragment corresponding to the virtual outer boundary (containing all discrete fragments and intermediate separator characters) is taken as a whole, and a nested entity type classifier model (two fully connected layers + Softmax output layer) is used for type judgment. The input is the aggregated representation of the multi-level semantic representation vector of all characters within the virtual boundary, and the output is the type probability distribution of the virtual entity. The type corresponding to the maximum probability value is taken as the label, and finally the non-continuous entity recognition result containing "virtual boundary range, discrete fragment list, type label" is formed. This result is the initial non-continuous entity.

[0125] The significance of constructing a virtual outer boundary is to convert the originally scattered non-continuous fragments into a "whole structure" similar to a nested entity, which not only preserves the original semantic information of the fragments, but also provides a unified processing object for subsequent semantic aggregation of the gating attention mechanism, ensuring that the overall semantic of the non-continuous entity can be effectively captured.

[0126] In an optional embodiment, a gating attention mechanism is used to perform semantic aggregation on the discrete fragments of the initial non-continuous entity to generate a non-continuous entity overall semantic representation, including the following steps:

[0127] S41, extract the semantic representation of all discrete fragments of the initial non-continuous entity to form a fragment semantic representation set.

[0128] Specifically, the initial non-continuous entity is derived from the entity containing multiple discrete segments constructed by the virtual nested structure in the foregoing step (such as the initial non-continuous entity corresponding to “lung cancer with liver metastasis”, containing two discrete segments “lung cancer” and “liver metastasis”). The “semantic representation of the discrete segment” refers to the high-level semantic vector corresponding to each segment. For each discrete segment (such as the text position 1-2 corresponding to “lung cancer”), a multi-level semantic vector of all characters in the coverage range of the segment is extracted, and a unified semantic representation of the segment (denoted as ) is obtained through an attention pooling operation (calculating the contribution weight of each character to the semantic of the segment and weighted summation), which contains the core semantic features of the segment and has the same dimension as the multi-level semantic representation vector. In implementation, the semantic representation of each segment is extracted one by one by traversing all discrete segments contained in the initial non-continuous entity 、 、…、 (k is the total number of segments), and these vectors are integrated to form a segment semantic representation set, each element in the set corresponding to a discrete segment, clearly recording the semantic information of each segment, laying a foundation for subsequent weight calculation and semantic fusion.

[0129] S42, based on the segment semantic representation set, the contribution weight of each segment to the overall semantic representation is calculated using a gated attention mechanism as the gated attention weight; the calculation formula of the gated attention weight is:

[0130]

[0131] wherein, represents the semantic representation of the i-th discrete segment of the initial non-continuous entity; is a gating network composed of two fully connected networks and a ReLU activation function; represents the gated attention weight of the i-th discrete segment of the initial non-continuous entity, and k represents the number of discrete segments of the initial non-continuous entity.

[0132] Specifically, the contribution weight of each segment (i.e., the gated attention weight) is calculated by the gated attention mechanism in this step, and the core is to use the gating network to adaptively identify the importance of the segment to the overall semantic, avoiding the interference of irrelevant or secondary segments to the overall semantic expression.

[0133] In the calculation formula of the gated attention weight, represents the semantic representation of the i-th discrete segment in the initial non-continuous entity, which is directly derived from the segment semantic representation set constructed in the S41 step and is the input basis of the gating network; (the gating network) is the core component for realizing weight calculation, which is composed of two fully connected networks and a ReLU activation function. The first fully connected network maps The dimension of the second layer is mapped to the preset hidden layer dimension (the hidden layer dimension is determined by optimizing the medical field validation set, and the calculation efficiency and semantic capture ability need to be balanced), a nonlinear transformation is introduced through a ReLU activation function to enhance the expression ability of complex semantic features; the second layer full connection network maps the hidden layer features to 1 dimension and outputs a scalar value, which quantifies the potential contribution of the contained semantic information to the overall semantics; the numerator part converts the output of the gating network into a positive value through an exponential function, amplifying the contribution difference between different segments; the denominator part is the sum of the exponential operations of the gating network output values of all k discrete segments, serving as a normalization factor; , i.e., the gating attention weight of the ith discrete segment, whose value range is between (0, 1), and the sum of the weights of all segments is 1 (0 ), the greater the weight, the more significant the contribution of the segment to the overall semantics of the non-continuous entity (such as "lung cancer with liver metastasis", the of "lung cancer" and "liver metastasis" is much greater than the of the auxiliary segment "with" if it exists).

[0134] S43, based on the gating attention weight, the semantic representations of all discrete segments of the initial non-continuous entity are weighted and summed to generate the overall semantic representation of the non-continuous entity; the expression of the weighted sum is:

[0135]

[0136] wherein, represents the overall semantic representation of the non-continuous entity, represents the gating attention weight of the ith discrete segment of the initial non-continuous entity, and k represents the number of discrete segments.

[0137] Specifically, based on the gating attention weight, the semantic representations of all discrete segments are weighted and summed to finally generate the overall semantic representation of the non-continuous entity, realizing the organic integration of the semantic of discrete segments.

[0138] In the weighted sum formula, represents the overall semantic representation of the non-continuous entity, which is the core input for subsequent type classification and semantic integrity verification, and its dimension is consistent with the semantic representation of the discrete segment , ensuring that it can be directly adapted to the subsequent classification model; is the gating attention weight of the i-th discrete segment calculated in the S42 step, used to control the proportion of the segment semantics in the overall semantics, realizing the adaptive integration of "important segment contributes more and secondary segment contributes less"; k represents the total number of discrete segments contained in the initial discontinuous entity, and the summation range covers all segments to ensure that no semantic information is missed; the weighted summation process is essentially to superimpose the semantic vectors of each segment in proportion to the contribution, forming a unified vector that integrates all effective semantic information. For example, "lung cancer with liver metastasis" , will focus on integrating the semantic features of "lung cancer" and "liver metastasis" , while weakening the influence of the intermediate auxiliary character segment, so that can accurately reflect the core semantics of "malignant tumor with metastatic lesions".

[0139] Through the dynamic weight distribution of the gating attention mechanism, the accuracy and relevance of the overall semantic representation are effectively improved, which is more suitable for the semantic complexity of non-continuous entities in medical terminology.

[0140] The above-mentioned medical term recognition method generates multi-level semantic representation vectors through character-level segmentation and pre-trained language models, detects entity boundary relationships based on this using a position detection network to obtain an entity boundary relationship matrix, and then identifies nested entities through hierarchical region enumeration and medical field rule filtering. Then, through semantic correlation evaluation, a virtual nested entity structure is constructed to convert non-continuous segments into nested form, and a gating attention mechanism is used for semantic aggregation and verification to obtain non-continuous entities. Finally, an entity hierarchy graph is constructed to convert into a structured medical entity list, thereby realizing accurate recognition and structured representation of nested entities and non-continuous entities in medical text, effectively solving the boundary recognition errors and semantic association loss problems of traditional sequence labeling models when processing complex medical terminology, and significantly improving the accuracy and integrity of medical information processing.

[0141] It should be understood that although each step in the flowchart involved in each embodiment as described above is displayed in sequence according to the direction of the arrow, these steps are not necessarily executed in sequence according to the direction of the arrow. Unless otherwise specified herein, there is no strict order limitation for the execution of these steps, and these steps can be executed in other orders. Moreover, at least part of the steps in the flowchart involved in each embodiment as described above can include multiple steps or stages, which are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily sequential, but can be executed in rotation or alternation with at least part of other steps or steps or stages in other steps.

[0142] Based on the same inventive concept, the embodiments of the present application also provide a system for implementing the medical term recognition method described above. The system provides a solution to the implementation similar to the implementation described in the above method, so the specific limitations in one or more medical term recognition system embodiments provided below can refer to the limitations of the medical term recognition method described above, which will not be repeated here.

[0143] In one exemplary embodiment, as shown in Figure 3 A medical term recognition system 30 is provided for implementing the method in each of the method embodiments described above, which includes:

[0144] A context semantic deep representation module 31 is configured to perform character-level segmentation on the medical text to generate a character sequence, process the character sequence through a pre-trained language model to generate semantic representation vectors representing the context representation at the character level, and integrate the semantic representation vectors output by each layer of the language model using an attention weighting fusion mechanism to generate multi-level semantic representation vectors.

[0145] A boundary accurate positioning module 32 is configured to predict the probability of each character as the starting position and ending position of an entity based on the multi-level semantic representation vectors through a position detection network composed of a fully connected layer and a sigmoid activation function, to obtain a starting position probability distribution and an ending position probability distribution, and to perform entity boundary detection based on the starting position probability distribution and the ending position probability distribution to generate an entity boundary relationship matrix.

[0146] A nested entity intelligent generation module 33 is configured to generate a candidate nested entity set through a hierarchical region exhaustive strategy based on the entity boundary relationship matrix, filter the candidate nested entity set based on nested constraint rules in the medical field, and output nested entities with type labels.

[0147] A non-continuous entity reconstruction module 34 is configured to evaluate the semantic correlation scores between different segments based on continuous entity segments in the nested entities, construct a virtual nested entity structure based on the semantic correlation scores, convert non-continuous segments into nested form through the virtual nested entity structure, and obtain initial non-continuous entities.

[0148] A non-continuous entity verification module 35 is configured to perform semantic aggregation on discrete segments of the initial non-continuous entities using a gated attention mechanism to generate a non-continuous entity overall semantic representation, perform type classification and semantic integrity verification on the non-continuous entities based on the non-continuous entity overall semantic representation, and output verified non-continuous entities with type labels.

[0149] An entity knowledge structuring module 36 is configured to construct an entity hierarchy graph with all recognized nested entities and verified non-continuous entities as nodes, and convert the entity hierarchy graph into a structured medical entity list.

[0150] Embodiments of the present application also provide a computer device comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the method embodiments as described above when executing the computer program.

[0151] Embodiments of the present application also provide a computer readable storage medium, which stores a computer program, and the computer program is executed by a processor to implement the steps of the method embodiments as described above.

[0152] For the device embodiments, since they basically correspond to the method embodiments, the relevant parts are described in the part of the method embodiments. The device embodiments described above are merely illustrative, wherein the components described as separate components can or can not be physically separated, and the components displayed as units can or can not be physical units, i.e., they can be located in one place or distributed on multiple network units. Part or all of the modules can be selected to achieve the purpose of the present application according to actual needs. Those skilled in the art can understand and implement it without creative labor.

[0153] The above embodiments only express several implementation manners of the embodiments of the present application, and the description is more specific and detailed, but it should not be understood as a limitation on the patent scope of the embodiments of the present application. It should be pointed out that, for those skilled in the art, without departing from the concept of the embodiments of the present application, several modifications and improvements can be made, which are all within the protection scope of the embodiments of the present application.

Claims

1. A method for identifying medical terminology, characterized in that, The method includes: S1. Perform character-level word segmentation on the medical text to generate character sequences; process the character sequences through a pre-trained language model to generate semantic representation vectors that represent character-level contextual representations; integrate the semantic representation vectors output by each layer of the language model using an attention-weighted fusion mechanism to generate multi-level semantic representation vectors. S2. Based on the multi-level semantic representation vector, a position detection network composed of a fully connected layer and a sigmoid activation function is used to predict the probability of each character as the start and end position of an entity, respectively, to obtain the start position probability distribution and the end position probability distribution; based on the start position probability distribution and the end position probability distribution, entity boundary detection is performed to generate an entity boundary relationship matrix; S3. Based on the entity boundary relationship matrix, generate a candidate nested entity set through a hierarchical region exhaustive strategy, filter the candidate nested entity set based on the nesting constraint rules in the medical field, and output the nested entities with type labels. S4. Based on the continuous entity fragments in the nested entity, evaluate the semantic relevance score between different fragments; construct a virtual nested entity structure based on the semantic relevance score, and use the virtual nested entity structure to transform non-continuous fragments into nested forms to obtain the initial non-continuous entity; S5. Use a gated attention mechanism to perform semantic aggregation on the discrete fragments of the initial discontinuous entity to generate a holistic semantic representation of the discontinuous entity; based on the holistic semantic representation of the discontinuous entity, perform type classification and semantic integrity verification on the discontinuous entity, and output the verified discontinuous entity with type label; S6. Construct an entity hierarchy graph using all identified nested entities and verified non-continuous entities as nodes, and transform the entity hierarchy graph into a structured list of medical entities.

2. The method according to claim 1, characterized in that, The step of detecting entity boundaries based on the probability distribution of the starting position and the probability distribution of the ending position, and generating an entity boundary relationship matrix, includes: S11. Filter the probability distribution of the starting position according to a preset first probability threshold, retain positions whose probability values ​​exceed the first probability threshold, and generate a candidate starting position set; filter the probability distribution of the ending position according to a preset second probability threshold, retain positions whose probability values ​​exceed the second probability threshold, and generate a candidate ending position set. S12. For each position i in the candidate starting position set and each position j in the candidate ending position set, when i ≤ j, the type association degree between position i and position j is calculated using a dual affine classifier; the calculation formula for the dual affine classifier is: in, and Let U and W represent the multi-level semantic representation vectors at positions i and j, respectively. U is a bilinear transformation matrix, W is a linear transformation matrix, b is a bias vector, and [;] represents a vector concatenation operation. The probability distribution of the types of entity fragments formed by positions i to j is used as the type correlation degree. S13. Based on the type correlation of all candidate start position-candidate end position pairs, construct the entity boundary relationship matrix containing all candidate entities and their corresponding type probabilities.

3. The method according to claim 1, characterized in that, The process involves generating a candidate nested entity set based on the entity boundary relationship matrix using a hierarchical region exhaustive search strategy, filtering the candidate nested entity set based on medical domain nesting constraint rules, and outputting nested entities with type labels, including: S21. Based on the entity boundary relationship matrix, extract all candidate start and end position pairs whose probability exceeds a preset threshold to form an initial candidate entity set; S22. The initial candidate entity set is divided into layers according to the entity length. For the candidate entities in each layer, they are sorted from high to low according to the type probability to generate a sorted candidate entity list. S23. Based on the nesting constraint rules in the medical field, perform a compatibility check on candidate entities in the candidate entity list that have overlapping areas; wherein, the nesting constraint rules in the medical field include type compatibility rules and boundary inclusion rules, the type compatibility rules define the allowed combinations of entity types for nesting, and the boundary inclusion rules define the boundary constraint conditions of nested entities; S24. Remove candidate entities that do not meet the nesting constraint rules of the medical field, and generate a filtered set of candidate nested entities; perform boundary optimization processing on the filtered set of candidate nested entities to merge adjacent entities with high overlap, and output the nested entities with type labels.

4. The method according to claim 1, characterized in that, The process involves evaluating the semantic relevance scores between different segments based on continuous entity segments within the nested entity; constructing a virtual nested entity structure based on the semantic relevance scores; and using the virtual nested entity structure to transform non-continuous segments into a nested form to obtain an initial non-continuous entity, including: S31. Based on the continuous entity fragments, extract all combinations of non-continuous entity fragments within the semantic distance threshold range to form a candidate non-continuous entity set; S32. For each candidate non-continuous entity in the candidate non-continuous entity set, which contains multiple discrete segments, the semantic relevance score between the discrete segments is calculated through semantic relevance evaluation; the formula for calculating the semantic relevance evaluation is: in, and Representing discrete segments of different candidate discontinuous entities; and They represent and The aggregated representation is extracted from the multi-level semantic representation vector through attention pooling operations; This represents the relevance score between two fragment types calculated based on a medical knowledge base, where λ is a preset balancing parameter. Representing fragments and The semantic relevance score; S33. When the semantic relevance score exceeds a preset threshold, the corresponding discrete segments are determined to belong to the same non-continuous entity, and a valid set of non-continuous entities is generated. S34. Construct a virtual outer boundary for the effective discontinuous entity to obtain a virtual nested entity; perform nested entity recognition on the virtual nested entity to obtain a discontinuous entity recognition result containing type labels, which is used as the initial discontinuous entity; wherein, the virtual outer boundary completely contains all discrete segments of the effective discontinuous entity.

5. The method according to any one of claims 1 to 4, characterized in that, The step of employing a gated attention mechanism to semantically aggregate discrete fragments of the initial discontinuous entity to generate a holistic semantic representation of the discontinuous entity includes: S41. Extract the semantic representations of all discrete fragments of the initial non-continuous entity to form a fragment semantic representation set; S42. Based on the set of segment semantic representations, a gated attention mechanism is used to calculate the contribution weight of each segment to the overall semantic representation, which is then used as the gated attention weight; the formula for calculating the gated attention weight is as follows: in, The semantic representation of the i-th discrete segment of the initial non-continuous entity; It is a gated network, consisting of two fully connected layers and a ReLU activation function; The gated attention weight represents the i-th discrete segment of the initial non-continuous entity, and k represents the number of discrete segments of the initial non-continuous entity; S43. Based on the gated attention weights, the semantic representations of all discrete fragments of the initial discontinuous entity are weighted and summed to generate the overall semantic representation of the discontinuous entity; the expression for the weighted summation is: in, This represents the overall semantic representation of the non-continuous entity. The gating attention weight represents the i-th discrete segment of the initial non-continuous entity, and k represents the number of discrete segments.

6. A medical terminology recognition system for implementing the method according to any one of claims 1 to 5, characterized in that, The system includes: The contextual semantic deep representation module is used to perform character-level word segmentation on medical text and generate character sequences; the character sequences are processed by a pre-trained language model to generate semantic representation vectors that represent character-level contextual representations; and the semantic representation vectors output by each layer of the language model are integrated using an attention-weighted fusion mechanism to generate multi-level semantic representation vectors. The boundary precision localization module is used to predict the probability of each character as the start and end position of an entity based on the multi-level semantic representation vector through a position detection network composed of a fully connected layer and a sigmoid activation function, thereby obtaining the start position probability distribution and the end position probability distribution; and to perform entity boundary detection based on the start position probability distribution and the end position probability distribution to generate an entity boundary relationship matrix. The nested entity intelligent generation module is used to generate a candidate nested entity set based on the entity boundary relationship matrix through a hierarchical region exhaustive strategy, filter the candidate nested entity set based on the nesting constraint rules in the medical field, and output nested entities with type labels. The discontinuous entity reconstruction module is used to evaluate the semantic relevance score between different segments based on the continuous entity segments in the nested entity; construct a virtual nested entity structure based on the semantic relevance score; and convert the discontinuous segments into a nested form through the virtual nested entity structure to obtain the initial discontinuous entity. The discontinuous entity verification module is used to perform semantic aggregation on the discrete fragments of the initial discontinuous entity using a gated attention mechanism to generate an overall semantic representation of the discontinuous entity; based on the overall semantic representation of the discontinuous entity, it performs type classification and semantic integrity verification on the discontinuous entity, and outputs the verified discontinuous entity with type label; The entity knowledge structuring module is used to construct an entity hierarchy graph with all identified nested entities and verified non-continuous entities as nodes, and to transform the entity hierarchy graph into a structured list of medical entities.

7. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the method of any one of claims 1 to 5.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the method of any one of claims 1 to 5.