Entity relationship identification method and device, computer equipment and medium

By employing feature representation, convolutional enhancement, and contextual enhancement in the entity relationship extraction model, the problems of entity boundary error propagation and long-distance relationship recognition are solved, improving the accuracy and efficiency of entity relationship recognition, especially demonstrating outstanding performance in high-precision scenarios in the medical field.

CN121525673APending Publication Date: 2026-02-13CHENGDU HARIT MEDICAL TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511702359.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-19
Publication Date
2026-02-13

AI Technical Summary

Technical Problem

Existing technologies for entity relationship recognition suffer from problems such as entity boundary error propagation, lack of explicit modeling of entity internal lexical dependencies, and the submergence of long-distance relationship signals in long sentences, making it difficult to meet the requirements of high-precision scenarios.

Method used

An entity relationship extraction model is adopted. The feature representation network generates full-text feature vectors, the transformation network constructs entity feature vectors, the convolutional network performs convolutional enhancement processing, the attention network performs context enhancement, and finally the classification network determines the entity relationship data.

Benefits of technology

It significantly improves the accuracy and robustness of entity feature representation, enhances the ability to capture long-distance relationship signals in complex text, solves the error propagation problem in traditional methods, and achieves efficient and accurate entity relationship recognition.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121525673A_ABST
    Figure CN121525673A_ABST
Patent Text Reader

Abstract

The invention relates to an entity relationship recognition method and device, computer equipment and a medium, the method applies an entity relationship extraction model to recognize entity relationship data for a target text, and the method comprises the following steps: a feature representation network performs feature representation on a word segmentation sequence of the target text of a to-be-recognized entity relationship to generate a full-text feature vector; a conversion network performs entity classification based on the full-text feature vectors to obtain entity boundary information, and word element vector segments of all entities in the full-text feature vectors are constructed into entity feature vectors; performing convolution enhancement processing on the entity feature vector by a convolution network to obtain a structure enhancement vector; the attention network performs context enhancement processing on the structure enhancement vector by using the full-text feature vector to generate an entity enhancement vector; and determining entity relationship data between every two entities contained in the target text by the classification network according to the entity enhancement vectors. According to the method, the entity feature representation precision and breadth can be improved, and the accuracy and efficiency of relation extraction are remarkably improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of artificial intelligence, and in particular to a method and apparatus for identifying entity relationships, as well as computer equipment and media. Background Technology

[0002] In the field of artificial intelligence involving natural language processing, information extraction technology is a frequently used application. The traditional approach generally adopts a pipeline architecture that first identifies entities and then identifies the relationships between entities.

[0003] Taking medical information extraction as an example, the Named Entity Recognition (NER) task first scans the unstructured medical records and outputs entity boundaries and types. Then, the Relation Extraction (RE) task pairs candidate entities according to their boundaries and feeds them into a relation classifier to determine if a predefined relationship exists. This process is intuitive and simple to implement, and therefore was widely adopted in early systems.

[0004] However, the pipeline approach completely decouples NER from RE, causing downstream relationship judgment to be highly dependent on the accuracy of upstream entity boundary identification. Any boundary error will be directly propagated to the relationship stage, and the entity boundary cannot be corrected by using relationship labels.

[0005] While joint models proposed in recent years have mitigated the aforementioned shortcomings by sharing BERT-like encoding layers, they still remain at a shallow stage of sharing parameters and simple pooling at the feature interaction level. First, entity representation usually takes entity boundary information (span) directly as the basis for relation recognition tasks, lacking explicit modeling of the dependencies of lexical units within the entity, making it difficult to characterize the fine semantics of multi-word medical terms such as "aspirin".

[0006] Secondly, the relation recognition task only uses the original context and entity boundary information of the shared encoder to interact, lacking dynamic focus on the entity and its contextual relationship in the original text, which causes long-distance relation signals in long sentences to be submerged.

[0007] In addition, existing joint frameworks generally lack task-level control mechanisms. When multiple medical sub-tasks such as "patient information extraction" and "medication record extraction" need to be completed simultaneously, they can only be sequentially or hard-switched, and cannot activate the corresponding parameters as needed in a single forward propagation, resulting in a waste of computing power.

[0008] This shows that traditional pipeline solutions and existing joint models still have significant shortcomings and are unable to meet the stringent requirements of high-precision scenarios such as electronic medical record structuring and clinical decision support. Summary of the Invention

[0009] The primary objective of this application is to solve at least one of the above-mentioned problems by providing a method, apparatus, computer equipment, and medium for identifying entity relationships.

[0010] To achieve the various objectives of this application, the following technical solution is adopted: An entity relationship identification method provided for one of the purposes of this application includes the following steps: The feature representation network in the entity relation extraction model is applied to perform feature representation on the word segmentation sequence of the target text to be identified, generating a full-text feature vector; The entity boundary information obtained by entity classification based on the full-text feature vector is obtained by the transformation network in the model, and the word vector segments of each entity in the full-text feature vector are constructed as entity feature vectors. The convolutional network in the model performs convolutional enhancement processing on the entity feature vector to obtain a structure enhancement vector; The attention network in the model uses the full-text feature vector to perform context enhancement processing on the structure enhancement vector to generate the entity enhancement vector; The classification network in the model determines the entity relationship data between each pair of entities contained in the target text based on the entity augmentation vector.

[0011] An entity relationship identification apparatus, proposed to meet one of the purposes of this application, comprises: The feature representation module is configured to apply the feature representation network in the entity relation extraction model to perform feature representation on the word segmentation sequence of the target text to be identified, and generate full-text feature vectors. The conversion processing module is configured to use the conversion network in the model to construct entity feature vectors from the word vector segments of each entity in the full-text feature vector based on the entity boundary information obtained by entity classification from the full-text feature vector. The structure enhancement module is configured to perform convolution enhancement processing on the entity feature vector using the convolutional network in the model to obtain the structure enhancement vector; The full-text enhancement module is configured to use the attention network in the model to perform context enhancement processing on the structure enhancement vector using the full-text feature vector to generate the entity enhancement vector; The relationship recognition module is configured to use the classification network in the model to determine the entity relationship data between each pair of entities contained in the target text based on the entity augmentation vector.

[0012] In another aspect, a computer device provided for one of the purposes of this application includes a processor and a memory, wherein the processor invokes and runs a computer program in the memory to perform the steps of the entity relationship identification method.

[0013] On another aspect, a computer-readable storage medium is provided to suit another purpose of this application, which stores in the form of computer-readable instructions a computer program implemented according to the entity relationship identification method, which, when called by a computer, executes the steps included in the corresponding method.

[0014] Compared to traditional techniques, this application converts the entity boundary information output by the entity recognition task into entity feature vectors in the entity relationship extraction model. Based on this, it performs deep interaction of convolutional enhancement processing and context enhancement processing, and then directly determines entity relationship data using the entity enhancement vectors obtained from this process. Compared to the traditional method of directly relying on entity boundary information for entity relationship inference, this significantly improves the accuracy and robustness of entity feature representation. It not only deepens the understanding of the internal textual structure relationships of entities, but also improves the model's ability to capture long-distance relationship signals in complex texts. This effectively solves many problems existing in traditional methods and provides a more efficient and accurate solution for high-precision professional needs scenarios such as medical information extraction. Attached Figure Description

[0015] The above and / or additional aspects and advantages of this application will become apparent and readily understood from the following description of the embodiments taken in conjunction with the accompanying drawings, wherein: Figure 1 This is a schematic diagram of the network architecture of the entity relation extraction model in this application during the training phase; Figure 2 This is a flowchart illustrating a typical embodiment of the entity relationship identification method of this application; Figure 3 This is a schematic block diagram of the entity relationship identification device of this application; Figure 4 This is a schematic diagram of the structure of a computer device used in this application. Detailed Implementation

[0016] In the field of natural language processing, entity relation recognition is a crucial task in information extraction, with broad application prospects, particularly in professional fields such as medicine, finance, and law. Taking the medical field as an example, tasks such as structured processing of electronic medical records, clinical decision support systems, and the construction of medical knowledge graphs all rely on efficient entity relation recognition technology. This application proposes an innovative entity relation recognition method and apparatus, aiming to improve the accuracy and efficiency of entity relation recognition through deep learning technology, especially demonstrating outstanding performance in handling complex text and multi-task scenarios.

[0017] Figure 1This paper demonstrates the network architecture of the entity relation extraction model implemented in this application. The architecture consists of multiple modules, including a feature representation network, a transformation network, a convolutional network, an attention network, and a classification network. These modules work together to achieve efficient transformation from the original input target text to entity relation data. Specifically, the feature representation network is responsible for converting the word segmentation sequence of the input text into a full-text feature vector; the transformation network performs entity classification based on the full-text feature vector to determine the corresponding entity boundary information, and then extracts the corresponding word vector segments of each entity from the full-text feature vector based on the entity boundary information, constructing entity feature vectors; the convolutional network performs convolutional enhancement processing on the entity feature vector to generate structure enhancement vectors; the attention network uses the full-text feature vector to perform context enhancement processing on the structure enhancement vector to generate entity enhancement vectors; finally, the classification network determines the relationship data between entities based on the entity enhancement vectors.

[0018] In practical applications, the entity relationship extraction model of this application can be deployed on various computer devices, such as cloud servers, high-performance workstations, edge computing devices, personal computers, and mobile terminals. These devices execute the entity relationship recognition method of this application by calling computer programs stored in memory. For example, in the medical field, this model can be applied to electronic medical record management systems to automatically extract key information from medical records, such as patient information, disease diagnosis, treatment plans, and drug usage, providing auxiliary decision support for medical professionals. Furthermore, this model can be combined with a medical knowledge base to generate structured medical information summaries, further enhancing the intelligence level of medical information processing.

[0019] To better understand the technical solution of this application, the following will be combined with Figure 1 The network architecture of the entity relationship extraction model of this application is described in detail, and the explanation of each embodiment is carried out step by step.

[0020] Please see Figure 2 In some embodiments, the entity relationship identification method of this application can be implemented as a computer program and run in a computer device. The method includes: Step S3100: Apply the feature representation network in the entity relationship extraction model to perform feature representation on the word segmentation sequence of the target text to be identified, and generate the full-text feature vector; When entity relationship recognition is required for target text, the user or system can call the corresponding interface of the entity relationship recognition model of this application and pass the target text of the entity relationship to be recognized. This interface first preprocesses the target text to generate a corresponding word segmentation sequence, including multiple lexical units. The generation of the word segmentation sequence can be achieved in various ways, including but not limited to rule-based segmentation, statistical segmentation, and deep learning-based segmentation methods. For example, in medical text, a word segmentation tool specifically optimized for medical terminology can be used to ensure accurate segmentation of professional terms such as "aspirin".

[0021] Subsequently, the word segmentation sequence is encoded using the dictionary employed by the entity relation extraction model of this application to obtain an encoded vector. The dictionary may include pre-trained word embedding models such as Word2Vec, GloVe, or BERT, which can map the lexical units in the word segmentation sequence to a high-dimensional vector space, thus preserving the semantic information of the lexical units. Furthermore, the encoding process can incorporate positional encoding to retain the sequential information of the lexical units in the text, which is crucial for understanding the context of the text.

[0022] After obtaining the encoded vector, the feature representation network in the entity relation extraction model is applied to represent the word segmentation sequence of the target text to be identified, based on the encoded vector, generating a full-text feature vector. The feature representation network can employ various architectures, such as Transformer-based architectures like ALBERT or BERT. These architectures can capture long-distance dependencies in the text and generate context-rich feature representations as the full-text feature vector. The full-text feature vector not only contains the semantic information of each word in the target text but also integrates the contextual relationships between words, which can be shared by the transformation network and attention network in this application.

[0023] The entity relation extraction model used in this application can be either trained for a single task or for multiple tasks. For the former, no task type needs to be specified; for the latter, a task type can be specified along with the target text input, allowing the model to invoke weight parameters related to the task type to perform the corresponding entity relation recognition process. The model can activate the corresponding model data based on the task mask corresponding to the specified task type, ensuring accurate and complete entity relation recognition for the corresponding task objective.

[0024] Step S3200: Using the transformation network in the model, based on the entity boundary information obtained by entity classification from the full-text feature vector, construct the word vector segments of each entity in the full-text feature vector as entity feature vectors. The feature representation network outputs a full-text feature vector, which first enters the entity classifier of the transformation network for entity classification. The role of the entity classifier is to identify entities and their types in the target text based on the full-text feature vector, and to determine the boundary locations of these entities.

[0025] Specifically, entity boundary information is obtained by classifying and predicting the full-text feature vector using an entity classifier. Each word in the segmented sequence is classified, labeling whether it belongs to a specific entity and the type of that entity. For example, in medical text, the entity classifier can identify entities such as "patient," "disease," and "drug," and label their start and end positions in the text using a correspondence between type labels and word positions.

[0026] Entity boundary information can be labeled using ordered positional relationships to tag the entity type labels corresponding to each lexical unit. For example, the BIO (Begin, Inside, Outside) or BIOES labeling scheme can be used, where "B" represents the beginning of the entity, "I" represents the inside of the entity, and "O" represents a non-entity part. In this way, the entity classifier can accurately label the boundary position of each entity.

[0027] After obtaining entity boundary information, based on the full-text feature vector, the word vector segments of each entity in the full-text feature vector are constructed into entity feature vectors. Specifically, this involves extracting the word vector segments of the corresponding entities from the full-text feature vector and concatenating these word vector segments into the entity feature vector. For example, suppose the target text is "Patients take aspirin to treat headaches.", and the word segmentation sequence is ["patient", "take", "aspirin", "treat", "headache"]. The entity classifier identifies "patient", "aspirin", and "headache" as entities and marks their boundary positions. Based on these boundary positions, the corresponding word vector segments are extracted from the full-text feature vector to construct the entity feature vector.

[0028] There are various specific implementations for constructing entity feature vectors. For example, one can simply concatenate the word vector segments corresponding to the entity, or generate entity feature vectors through some aggregation operation (such as average pooling or max pooling). These specific implementations can be selected and adjusted according to different application scenarios and requirements.

[0029] Step S3300: The convolutional network in the model performs convolutional enhancement processing on the entity feature vector to obtain the structure enhancement vector; By using an entity relation extraction model to perform convolutional enhancement on entity feature vectors, structure-enhanced vectors can be generated. Specifically, this is achieved by setting up a convolutional network in the model. The purpose is to further explore the dependencies between terms within an entity by performing convolution operations on the entity feature vectors, thereby generating more accurate and robust entity feature representations.

[0030] Specifically, the convolutional network first unfolds the entity feature vector into an input feature vector along the entity dimension, enabling the convolution operation to be performed on an entity-by-entity basis to better capture the local features within each entity. Subsequently, the input feature vector is sequentially convolved through multiple one-dimensional convolutional layers in the network. Each convolutional layer is responsible for extracting local features from the input feature vector, using a convolution kernel to slide across the feature vector and perform weighted summation to generate a convolutional augmentation vector. These augmented convolutional vectors reflect the local combination features between terms within an entity, helping to improve the representational power of entity features.

[0031] To further enhance the robustness of entity features, the pooling layers in the convolutional network perform mean pooling on the convolutional enhancement vectors of the first and last convolutional layers to obtain a structure enhancement vector. Pooling reduces the dimensionality of the feature vector through downsampling while preserving important feature information. Mean pooling, by averaging the elements of the convolutional enhancement vectors, generates a structure enhancement vector that effectively removes noise and retains the main information of entity features, thus generating a more stable entity feature representation.

[0032] After the aforementioned convolutional enhancement processing, the model can fully exploit the dependencies between terms within entities, generating more accurate and robust entity feature representations. This not only improves the representational power of entity features but also provides a high-quality feature foundation for subsequent relation extraction tasks. For example, when processing medical text, for the multi-word medical term "aspirin," the convolutional operation can capture the local combined features between "aspirin" and "pillin," thereby generating a more discriminative entity feature vector and providing more accurate information for subsequent relation extraction.

[0033] In specific embodiments, convolutional networks can employ various architectures and parameter settings. For example, the number of convolutional layers can be one or more, the size of the convolutional kernels can be adjusted according to the average length of the entities, and the pooling operation can employ mean pooling, max pooling, or other types of pooling methods. These specific embodiments can be selected and adjusted according to different application scenarios and requirements to achieve the best feature enhancement effect.

[0034] Step S3400: Using the attention network in the model, the full-text feature vector is used to perform context enhancement processing on the structure enhancement vector to generate the entity enhancement vector; After the convolutional network outputs the structure-enhanced vector, the attention network in the entity relation extraction model uses the full-text feature vector to perform context-enhanced processing on the structure-enhanced vector, generating the entity-enhanced vector. The entity-enhanced vector significantly improves the representational ability of entity features by introducing contextual information from the full-text feature vector on top of the structure-enhanced vector.

[0035] Specifically, the attention network enables the model to dynamically focus on important contextual information relevant to the current entity. In this process, the structural augmentation vector serves as the query vector, while the full-text feature vector is input to the attention network as the key and value vectors. Attention weights are generated by calculating the similarity between the query and key vectors. These weights reflect the relevance of contextual information at different locations to the current entity. Subsequently, the value vectors are weighted and summed according to the attention weights to obtain the entity augmentation vector. This vector not only contains the entity's own feature information but also incorporates important contextual information related to it, thus providing a richer semantic background for subsequent relation extraction.

[0036] In specific implementations, the attention mechanism can take various forms. For example, a scaled dot product attention mechanism can be used, where the dot product of the query vector and the key vector is scaled and then normalized using a softmax function to obtain the attention weights. Alternatively, a multi-head attention mechanism can be employed, decomposing the query, key, and value vectors into multiple heads, calculating attention weights for each head separately, and then concatenating and linearly transforming them to capture features from different subspaces. These specific implementations can be selected and adjusted according to different application scenarios and requirements to achieve the best context enhancement effect.

[0037] Through contextual enhancement, the model can better understand the semantic roles and relationships of entities within text. For example, in medical text, for the entity "aspirin," the model can not only identify its characteristics as a drug but also understand its role in treating a specific disease through contextual information. This enhanced entity feature representation provides a solid foundation for subsequent relation extraction, enabling the model to more accurately determine the relationships between entities, such as "drug-treatment-disease" relationships.

[0038] Step S3500: The classification network in the model determines the entity relationship data between each pair of entities contained in the target text based on the entity augmentation vector.

[0039] The classification network in the entity relationship extraction model of this application plays a role in determining the relationship data between entities in the target text based on the entity augmentation vectors. Specifically, the classification network first utilizes the information in the entity augmentation vectors, which integrate the entity's own features and related contextual information. The classification network further processes the entity augmentation vectors through internal linear layers or other neural network structures to extract features related to entity relationships. These features are then used to calculate the strength of the relationship between entities, typically through dot product operations or other calculation methods such as Euclidean distance, cosine similarity, Pearson coefficient, Minkowski distance, Jaccard algorithm, etc. For example, for the augmentation vectors of two entities... and It can be calculated To measure the strength of the relationship between them.

[0040] To determine the specific type of relationship between entities, classification networks can employ various implementations. One implementation inputs the calculated relationship strength into a relationship classifier, which can be a simple linear classifier or a complex neural network. The relationship classifier categorizes the relationship strength based on patterns learned during training, thereby determining the type of relationship between entities. For example, in medical text, a relationship classifier can identify relationship types such as "drug-treatment-disease" and "patient-has-disease".

[0041] Furthermore, classification networks can enhance the accuracy of relationship recognition by incorporating additional contextual information. For example, they can combine entity type information, location information, or other semantic features to gain a more comprehensive understanding of the relationships between entities. This information can be achieved by combining additional feature vectors with entity augmentation vectors, or by designing more complex network structures.

[0042] In practical implementation, the design of classification networks can have various variations. For example, a multilayer perceptron (MLP) structure can be used, stacking multiple fully connected layers to learn complex patterns of entity relationships. Alternatively, an attention-based classifier can be employed, dynamically focusing on the features most relevant to relationship judgment to improve classification accuracy. These specific implementations can be selected and adjusted according to different application scenarios and requirements to achieve the best relationship recognition results.

[0043] Thus, the classification network of this application can accurately determine the relationship type between entities without prior distinction between subject and object relationships. This approach not only improves the flexibility of relationship recognition but also adapts to various complex text scenarios, providing strong technical support for information extraction tasks in fields such as healthcare, finance, and law.

[0044] As can be seen from the above embodiments, this application effectively solves many problems existing in traditional entity relationship recognition methods through innovative technical means, significantly improving the model's performance in complex text scenarios, especially in scenarios with high accuracy requirements such as the medical field, where it has significant application value. Specifically, the beneficial effects and technical advantages of this application are mainly reflected in the following aspects: First, the entity relation extraction model in this application introduces entity feature vectors to replace entity boundary information after entity classification and before entity relation identification. These vectors are then enhanced through convolution to generate structure-enhanced vectors, which fully exploit the dependencies between words within an entity, thus generating more accurate and robust entity feature representations. Compared to traditional techniques that directly extract entity boundary information (span) as the basis for relation recognition, this application can better characterize the fine semantics of multi-word professional terms, such as the multi-word medical term "aspirin." Through convolution operations, the model can capture the local combination features of words within an entity before identifying entity relations, thereby generating more discriminative entity feature vectors and providing a high-quality foundation for subsequent relation extraction.

[0045] Secondly, after convolutional enhancement, this application further utilizes the shared full-text feature vectors from entity classification and relationship recognition tasks to perform contextual enhancement processing on the structural enhancement vectors. This allows the feature vectors of each entity to dynamically focus on their contextual information in the original text, thereby achieving dynamic modeling of the relationship between the entity and its context, resulting in entity enhancement vectors. Compared to traditional techniques where relationship recognition tasks only use the original context and entity boundary information from a shared encoder, this application significantly improves the model's ability to capture long-distance relationship signals in long sentences. In complex professional texts, this dynamic focusing mechanism ensures that the model does not miss important contextual information, thereby improving the accuracy of relationship extraction.

[0046] Furthermore, this application achieves a one-stop conversion by directly inferring entity relationship data from entity augmentation vectors in the classification network. This not only improves model efficiency but also avoids the error propagation problem caused by the decoupling of NER and RE tasks in traditional pipeline architectures. By completing entity recognition and relationship extraction in a single forward propagation, the model can fully utilize the inherent correlation and information complementarity between the two tasks, thereby achieving deep-level dialogue. In addition, this design also provides possibilities for future task-level control mechanisms, enabling the model to more flexibly activate corresponding parameters on demand when facing multiple sub-tasks, thus improving computational efficiency.

[0047] Based on any embodiment of the method in this application, entity boundary information obtained by entity classification based on the full-text feature vector is used to construct entity feature vectors for each corresponding entity from the word vector segments in the full-text feature vector, including: Step S3210: Perform entity classification on the full-text feature vector to obtain entity boundary information; Entity classification is a fundamental step in entity relation extraction models. In this application, its role is to classify entities from the full-text feature vector to obtain the boundary information of each entity in the target text. Specifically, it is achieved through an entity classifier implicit in the transformation network of the model. Its core is to use the semantic information in the full-text feature vector to accurately mark the position and type of each entity in the text.

[0048] Specifically, the entity classifier receives a full-text feature vector as input, which contains the semantic information of each word in the target text and the contextual relationships between words. The task of the entity classifier is to classify these words, determining whether each word belongs to a certain entity and the type of that entity. For example, in medical text, the entity classifier can identify entities such as "patient," "drug," and "disease" and mark their locations in the text.

[0049] There are various ways to implement entity classifiers. One implementation uses neural network-based classifiers, such as linear classification layers or fully connected layers. These classifiers learn patterns in the training data and can automatically identify the feature representations of entities. For example, the softmax function can be used to normalize the classifier's output, thus obtaining the probability distribution of each word belonging to different entity types. By setting a threshold or selecting the category with the highest probability, the entity type of each word can be determined.

[0050] In another embodiment, the entity classifier can also incorporate other techniques to improve classification accuracy. For example, a Conditional Random Field (CRF) layer can be used to consider dependencies between lemmas, thereby better capturing entity boundary information. The CRF layer can model label dependencies in a sequence of lemmas, making entity classification more accurate.

[0051] Entity boundary information is obtained by classifying and predicting the full-text feature vector using an entity classifier. It labels whether each lexical element in the segmented sequence belongs to a certain entity and the type of that entity. For example, in medical text, the entity classifier can identify entities such as "patient," "drug," and "disease" and label their positions in the text. This boundary information is usually output as a sequence, where the label for each position indicates whether that position belongs to a certain entity and the type of that entity. For example, when using the BIO annotation scheme, the label can be "B-PER" (indicating the beginning of an entity, type "person's name"), "I-PER" (indicating the interior of an entity, type "person's name"), or "O" (indicating a non-entity part). In this way, the entity classifier can accurately label the boundary information of each entity in the target text, determining the entity boundary information and providing a foundation for subsequent entity feature vector construction.

[0052] Step S3220: Decode the entity boundary information to determine the start and end position indices of each entity in the target text; Based on entity boundary information, the decoding process involves parsing these label sequences and determining the start and end indexes of each entity. The decoding algorithm converts the label sequences into entity boundary information, enabling subsequent steps to extract corresponding word vector segments from the full-text feature vector. For example, suppose the target text is "Patients take aspirin to treat headaches.", and the word segmentation sequence is ["patient", "take", "aspirin", "treat", "headache"]. The entity classifier identifies "patient", "aspirin", and "headache" as entities and labels their boundary positions. The decoding algorithm parses this labeling information into start and end indexes for the entities; for example, the start and end indexes for "patient" are 0 and 0 respectively; the start and end indexes for "aspirin" are 2 and 2 respectively; and the start and end indexes for "headache" are 4 and 4 respectively.

[0053] Decoding algorithms correspond to the labeling schemes used, and their implementation can take many forms. One approach is to use rule-based decoding algorithms, directly parsing the entity boundary information from the label sequence. Another approach is to use probabilistic model-based decoding algorithms, such as Hidden Markov Models (HMMs) or Conditional Random Fields (CRFs). These models can consider the transition probabilities between labels, thus more accurately parsing the entity boundary information. For example, a CRF layer can model label dependencies in a word sequence, making entity classification more accurate and the decoding process more robust.

[0054] In practical applications, the output of the decoding algorithm is the start and end position indices of the entity, which directly specify the entity's position in the full-text feature vector. Using these indices, subsequent steps can extract the corresponding word vector segments from the full-text feature vector, providing a foundation for constructing the entity feature vector.

[0055] Step S3230: Extract the corresponding entity word vector segments from the full-text feature vector according to the start and end position index, and concatenate the word vector segments into an entity feature vector.

[0056] Based on the obtained start and end position indices, the token vector segments corresponding to each entity can be accurately extracted from the full-text feature vector. Continuing with the previous example, for the target text "The patient took aspirin to treat the headache.", the word segmentation sequence is ["patient", "take", "aspirin", "treat", "headache"]. After entity classification and decoding, it is known that "patient", "aspirin", and "headache" are entities, with start and end position indices of 0, 2, and 4, respectively. Based on these indices, the corresponding entity token vector segments are extracted from the full-text feature vector.

[0057] After extracting the word vector segments, these segments need to be converted into entity feature vectors. This process can be achieved in several ways. One implementation is to simply concatenate the word vector segments to form a long vector as the entity feature vector. For example, if the word vector segments for "aspirin" are... If the word vectors are not fully understood, they can be directly concatenated into an entity feature vector. Another approach is to compress the word vector segments into a fixed-length vector through aggregation operations, such as average pooling or max pooling. For example, performing average pooling on the word vector segment of "aspirin" yields a feature vector representing that entity. These aggregation operations can preserve the key information of the word vector segments while reducing the dimensionality of the vectors and improving computational efficiency.

[0058] In other embodiments, other techniques can be combined to enhance the representational power of entity feature vectors. For example, in one embodiment, positional encoding of lexical units can be introduced, incorporating the positional information of lexical units into the entity feature vector, thereby preserving the order information of entities in the text. Positional encoding can be combined with lexical vectors through simple addition or more complex functions. For example, for each lexical vector... You can add a position code. The enhanced word vectors are obtained. Then perform splicing or aggregation operations.

[0059] In the above embodiments, by converting entity boundary information into entity feature vectors, the technical effect of replacing entity boundary information with entity feature vectors is achieved. This eliminates the need to determine the subject-object relationship between pairs of entities at this stage before proceeding with subsequent relationship recognition processing, representing a significant improvement. Specifically, by extracting the corresponding entity's word vector segments from the full-text feature vector and concatenating or aggregating these word vector segments into entity feature vectors, not only is the semantic information of the entity itself preserved, but contextual information is also initially integrated, enabling the model to more comprehensively understand the roles and relationships of entities within the text. Compared to traditional methods that directly use entity boundary information for relationship recognition, this embodiment avoids pre-determining the subject-object relationship during the entity recognition stage, thereby improving the model's flexibility and adaptability, particularly excelling in handling complex text and multi-task scenarios. Furthermore, by using entity feature vectors for relationship recognition, the model can more accurately capture complex relationships between entities, significantly improving the accuracy and efficiency of entity relationship recognition, providing a more efficient and accurate solution for high-precision scenarios such as medical information extraction.

[0060] Based on any embodiment of the method in this application, the entity feature vector is subjected to convolution enhancement processing to obtain a convolution enhancement vector, including: Step S3310: Expand the entity feature vector into an input feature vector according to the entity dimension; Entity feature vectors contain semantic information about the entity itself, as well as contextual information. In this step, these entity feature vectors are expanded along the entity dimension to form input feature vectors, allowing each entity's feature vector to be independently processed by the convolutional network. For example, suppose there are multiple entities in the target text, and the feature vector of each entity has a length of... The number of entities is Then the dimension of the expanded input feature vector can be expressed as: This unfolding method allows convolutional networks to extract features on an entity-by-entity basis, thereby better capturing the local features within each entity.

[0061] Step S3320: The input feature vector is sequentially convolved through multiple single-dimensional convolutional layers in the convolutional network to obtain the convolutional enhancement vector corresponding to each convolutional layer; In a convolutional network, each convolutional layer is connected in series, sequentially performing convolution operations on the input feature vector to extract local features. During each convolution operation, the kernel slides across the feature vector and performs a weighted sum, generating a corresponding convolutional augmentation vector. The subsequent convolutional layer uses this augmented vector as input, processing the input feature vector sequentially. These augmented vectors reflect the local combination features between words within an entity, helping to improve the representational power of entity features.

[0062] In implementation, a convolutional network can contain multiple convolutional layers, each with different kernel sizes and numbers. For example, the first convolutional layer can use a 3x3 kernel, and the second convolutional layer can use a 5x5 kernel. The kernel size can be adjusted based on the average length of the entity to better capture local features within the entity. Furthermore, convolutional operations can employ different padding methods (such as "same" or "valid") to control the dimensionality of the output feature vector.

[0063] The generation of convolutional augmentation vectors can be implemented in several ways. One embodiment uses a one-dimensional convolution operation, where the convolution kernel slides across the feature vector of each entity, generating a new feature representation. For example, for a feature vector of length... The entity feature vector is used to perform a convolution operation with a convolution kernel of size 3*3, which can generate a new feature vector whose length may be the same as or different from the original feature vector, depending on the parameter settings of the convolution operation.

[0064] Furthermore, convolutional networks can employ multi-layer convolutional structures to progressively extract more complex features. For example, the first convolutional layer can extract shallow local features, while subsequent convolutional layers can build upon this to extract deeper features. This multi-layer convolutional structure is better able to capture the complex dependencies between terms within an entity.

[0065] In practical implementation, the design of convolutional networks can be adjusted according to different application scenarios and needs. For example, when processing medical text, for the multi-word medical term "aspirin," convolutional operations can capture the local combined features between "aspirin" and "pillin," thereby generating more discriminative entity feature vectors. In this way, convolutional networks can effectively enhance the representation ability of entity features, providing a high-quality feature foundation for subsequent relation extraction tasks.

[0066] Step S3330: The convolution enhancement vectors of the first and last convolutional layers are averaged by the pooling layer in the convolutional network to obtain the structure enhancement vector.

[0067] Regardless of the number of convolutional layers, the convolutional augmentation vectors from the first and last two convolutional layers can be obtained from the convolutional network. These augmentation vectors, processed by multiple convolutional layers, already contain rich local feature information. Mean pooling generates a structure augmentation vector by averaging the elements of these augmentation vectors. This pooling method effectively removes noise while preserving the main information of entity features, thus generating a more stable feature representation.

[0068] In practice, pooling operations can employ not only mean pooling but also other types of pooling methods, such as max pooling or adaptive pooling. Max pooling preserves the most salient features by selecting the maximum value in the convolutional augmentation vector, while adaptive pooling dynamically adjusts the size of the pooling window based on the target dimension. These different pooling methods can be selected and adjusted according to specific application scenarios and requirements to achieve the best feature augmentation effect.

[0069] For example, when processing medical text, for the multi-word medical term "aspirin," the convolutional network has already extracted local combined features between "aspirin" and "pillin" through multiple convolutional layers. Through mean pooling, the model can further compress these features, generating more representative structure-enhanced vectors. These structure-enhanced vectors not only preserve the local combined features between terms within an entity but also remove noise through pooling, improving the robustness of the features.

[0070] This embodiment significantly improves the representational power and robustness of entity features by performing convolutional enhancement processing on entity feature vectors. Specifically, the entity feature vectors are first expanded into input feature vectors along the entity dimension, allowing each entity's feature vector to be processed independently in the convolutional network. Then, multiple single-dimensional convolutional layers are used to convolve the input feature vectors, extracting local combination features between words within the entity and generating convolutional enhancement vectors. This process not only captures complex dependencies within entities but also progressively extracts deeper features. Finally, mean pooling is performed on the convolutional enhancement vectors from the first and last convolutional layers to generate structure enhancement vectors. This pooling operation removes noise, retains key feature information, and further improves feature stability. Compared to traditional methods, this embodiment, through convolutional enhancement processing, not only deepens the representation of entity features but also provides a high-quality feature foundation for subsequent relation extraction tasks, significantly improving the accuracy and efficiency of entity relation recognition, especially performing exceptionally well in handling complex text and multi-task scenarios.

[0071] Based on any embodiment of the method in this application, the structure enhancement vector is subjected to context enhancement processing using the full-text feature vector to generate an entity enhancement vector, including: Step S3410: Input the structure enhancement vector as the query vector and the full-text feature vector as the key vector and value vector into the attention network; Use structural enhancement vectors as query vectors The full-text feature vector serves as the key vector. Sum value vector The purpose of feeding this information into the attention network is to enable the model to dynamically adjust the level of attention given to each entity based on global contextual information. For example, when processing medical text, if the current entity is "aspirin", the model will search for the contextual information most relevant to "aspirin" through the interaction of query vectors and key vectors, such as the feature vectors of words like "treatment" and "headache".

[0072] Step S3420: In the attention network, calculate the similarity between the query vector and the key vector to generate attention weights; In attention networks, the similarity between the query vector and the key vector is calculated to generate attention weights. This can be achieved through a scaled dot product attention mechanism, as shown in the following formula: in, It is a query vector. It is a key vector. It is a value vector. This is the dimension of the key vector, used as a scaling factor to prevent gradient instability caused by excessively large inner products. The query vector is calculated... With key vector By using the dot product, the model can quantify the relevance of each word to the current entity and generate an attention weight matrix. .

[0073] Step S3430: Based on the attention weights, the attention network performs a weighted summation of the value vectors to obtain the entity augmentation vector.

[0074] Based on the generated attention weight matrix The attention weights in the network are used to perform a weighted summation of the value vectors to obtain the entity augmentation vector. This process can be represented as: in, It is the attention weight matrix. It is a value vector matrix. This is the final generated entity augmentation vector. In this way, the model can aggregate the most relevant contextual information to the current entity into the entity features, thereby generating entity augmentation vectors that are more semantically rich and context-aware.

[0075] In practical implementation, attention mechanisms can take various forms. Besides the scaled dot product attention mechanism mentioned above, a multi-head attention mechanism can also be used. This involves decomposing the query, key, and value vectors into multiple heads, calculating attention weights for each head, and then concatenating and linearly transforming them to capture features from different subspaces. Furthermore, positional encoding can be introduced to incorporate word position information into the attention calculation, further enhancing the model's ability to perceive context.

[0076] The above embodiments significantly improve the semantic richness and context awareness of entity features by applying an attention mechanism and using full-text feature vectors to perform context enhancement processing on the structure enhancement vectors. Specifically, by inputting the structure enhancement vector as the query vector and the full-text feature vector as the key and value vectors into the attention network, the model can dynamically adjust the degree of attention to each entity based on global context information. This process is achieved through a scaled dot product attention mechanism, which calculates the similarity between the query vector and the key vector, generates attention weights, and then performs a weighted summation of the value vectors to generate the entity enhancement vector. This context enhancement processing not only captures the most relevant context information to the current entity but also further enhances the model's ability to perceive context through the attention mechanism. Compared with traditional methods, this embodiment achieves dynamic focusing on entity features and deep integration of context information through the attention mechanism, significantly improving the accuracy and efficiency of entity relationship recognition, especially performing well in handling complex text and multi-task scenarios.

[0077] Based on any embodiment of the method in this application, determining the entity relationship data between each pair of entities contained in the target text according to the entity augmentation vector includes: Step S3510: The first linear layer in the classification network combines the absolute position encoding of each entity with the entity augmentation vector to generate a first feature vector for each entity. The first feature vector is used to represent the main role feature of the entity in the relationship. The first feature vector represents the entity's primary role in the relation. It can be generated using the first linear layer based on the entity augmentation vector combined with absolute position encoding. Assuming the entity augmentation vector is... The absolute position encoding is Then the output of the first linear layer can be expressed as: in, and These are the weight matrix and bias vector of the first linear layer, respectively, learned during model training. In this way, the model considers not only the features of the entity itself but also its absolute position information within the text, thereby generating a first feature vector that represents the characteristics of the main character. .

[0078] In practical implementation, absolute position encoding Positional encoding can be generated in various ways. For example, it can be generated using sine and cosine functions. This method effectively incorporates positional information into the feature vector, enabling the model to perceive the position of words in the text.

[0079] Furthermore, the specific implementation of the first linear layer can have various variations. For example, a multilayer perceptron (MLP) architecture can be used, stacking multiple fully connected layers to learn more complex feature representations. Activation functions such as ReLU or GELU can also be introduced to increase non-linearity. These design choices can be tailored to specific application scenarios and requirements to achieve optimal feature enhancement results.

[0080] Step S3520: The second linear layer in the classification network combines the absolute position encoding of each entity with the entity augmentation vector to generate a second feature vector for each entity. The second feature vector is used to represent the object role feature of the entity in the relationship. The second feature vector represents the object role of an entity in a relation. Its generation mechanism corresponds to that of the first feature vector, together forming a symmetrical representation of the subject-object roles in relation classification. The second feature vector is generated through a second linear layer, and the network structure of the second linear layer can be implemented in the same way as the first linear layer.

[0081] The second linear layer is independent of the first linear layer and has its own weight matrix. and bias vector These parameters are learned through gradient descent during model training to ensure that semantic patterns specific to the object character can be captured, distinguishing them from the characteristics of the subject character.

[0082] The process of generating the second eigenvector can be formally represented as: in, The entity augmentation vector obtained from the aforementioned steps contains the semantics of the entity itself and its deep interaction information with the context; This is for absolute position encoding.

[0083] By adding the positional encoding to the entity augmentation vector and then performing a linear transformation, the model can incorporate the absolute positional context of an entity into its feature representation, thereby distinguishing the role the same entity plays as an object in different relations. For example, in the sentence "Aspirin relieved the patient's headache," "aspirin" is the subject of the "relief" relation, and "headache" is the object of the "relief" relation. Their absolute positional information at the beginning and end of the sentence can serve as important features to distinguish their roles.

[0084] Step S3530: Calculate the dot product of the first and second eigenvectors corresponding to each pair of entities, and represent all dot product results as a dot product matrix. Each element of the dot product matrix represents the strength of the relationship between the two entities. After generating first and second feature vectors representing the subject's role and the object's role, respectively, the model quantifies the strength of the relationship between entities by calculating the dot product of their feature vectors. Utilizing the geometric properties of the vector dot product—that is, the result of the dot product of two vectors reflects the directional similarity between the two entities in the vector space—the closer the directions of the two vectors are, the larger their dot product value, indicating a higher potential relationship strength between them.

[0085] Specifically, for any two entities, the first feature vector of one entity is multiplied by the second feature vector of the other entity. The resulting scalar value initially represents the probability that the former is the subject and the latter is the object, forming a relation pair. The results of the multiplications between all entity pairs are systematically organized into a multiplication matrix, which forms the basis for the relation classifier's final decision.

[0086] The dot product matrix is ​​a square matrix whose rows and columns correspond to the entity sequences identified in the text. The element in the i-th row and j-th column is defined by the dot product of the first feature vector of the i-th entity and the second feature vector of the j-th entity. Its value intuitively reflects the strength signal of the specific relationship direction with the i-th entity as the subject and the j-th entity as the object. This matrix representation condenses the pairwise relationship information between global entities into a structured data object, facilitating efficient and unified processing by the subsequent relationship classifier.

[0087] Step S3540: The dot product matrix is ​​classified by the relation classifier in the classification network to determine the entity relationship data between entities in the target text.

[0088] After the dot product matrix is ​​constructed, the relation classifier in the classification network performs the final relation type determination on the dot product matrix. The relation classifier is responsible for mapping the abstract relation strength scalar represented by each element in the dot product matrix to a predefined set of relation categories, thereby outputting structured entity relation data and realizing the key transformation from numerical signals to semantic labels.

[0089] Relation classifiers can be implemented as various classification network structures. A typical implementation uses one or more fully connected layers combined with a Softmax activation function. The dot product matrix is ​​first flattened into a feature vector containing global information about the relationship strength between all entity pairs in the text. This feature vector is then fed into the fully connected layer for a non-linear transformation to learn the complex mapping pattern between relationship strength and specific relationship categories. Finally, the Softmax function outputs the probability distribution of each entity pair belonging to each relationship type, and the type with the highest probability is taken as the final relationship determination for that entity pair.

[0090] The output of the relation classifier is the entity relation data of the target text, typically represented as a set of triples, such as (entity A, relation type, entity B). Each triple explicitly represents a specific type of relationship between entity A and entity B. For example, in the medical text "The patient takes aspirin to treat a headache," the model might ultimately output structured triples such as (aspirin, treatment, headache) and (patient, taking, aspirin). This data can be directly used to build knowledge graphs, support clinical decision-making, or populate databases, achieving an end-to-end transformation from unstructured text to structured knowledge.

[0091] The above embodiments significantly enhance the technical solution of this application by introducing absolute position encoding in the subject-object role feature generation stage and employing an asymmetric dot product interaction mechanism in relation strength calculation. Specifically, by fusing the absolute position context information of an entity with its deeply enhanced semantic representation, the generated first and second feature vectors not only contain the semantics of the entity itself and its interaction information with the full text, but also embed its structural priors in the text sequence. This allows for a more refined distinction between the subject or object roles played by the same entity in different relation pairs. This symmetrical and differentiated role representation strategy, combined with the efficient measurement of vector space directional similarity by the dot product operation, enables the dot product matrix to more accurately capture the directionality and strength of potential relations between entities, providing input features with higher information density and stronger discriminative power for subsequent relation classifiers. Ultimately, this series of processes ensures that the model can more reliably identify the specific type and direction of entity relations in complex contexts when outputting structured triples, especially when dealing with long sentences with multiple entities and multiple relations commonly found in medical texts, demonstrating significant progress in accuracy and robustness compared to traditional methods.

[0092] Based on any embodiment of the method in this application, before applying the feature representation network in the entity relation extraction model, the method includes: Step S2100: After encoding the word segmentation sequences of text data containing multiple different task types in the training samples, input them into the entity relation extraction model for training. Before a model is put into practical use, it needs to be trained sufficiently to optimize its parameters. The training process begins with data preparation and loading, which involves collecting labeled corpora from different domains or for different information extraction needs to construct training samples. These training samples contain text data of multiple different task types. For example, in the medical field, task types may include "discharge record information extraction," "admission record information extraction," or "laboratory report information extraction," to indicate different task objectives. Each sample contains the original text, character-level or word-level entity annotations, relationship annotations between entities, and a clear task type label.

[0093] Furthermore, the text data in the training samples can be preprocessed, including word segmentation, to transform the text into a segmented sequence that the model can process. The word segmentation process can employ methods including, but not limited to, dictionary-based matching, statistical model-based methods, or deep learning-based methods. Subsequently, according to the specifications of the selected pre-trained model (such as ALBERT), the segmented sequence is uniformly truncated or padded to a fixed length, such as 512 tokens, and converted into corresponding token ID sequences and attention masks. The encoding process maps the segmented sequence into a numerical vector representation. This encoding can rely on a predefined dictionary or vocabulary, transforming each token into a unique identifier.

[0094] After combining the encoded word segmentation sequences and their corresponding task type labels, entity labels, and relation labels into batches, they can be input into the entity relation extraction model for training. Batch processing improves training efficiency by processing multiple samples simultaneously through a single forward and backward propagation. The composition of the training samples ensures that the model can learn common features and unique patterns across different tasks, laying a data foundation for subsequent multi-task joint learning. For example, a batch may contain samples from discharge records and test reports, with task type labels "discharge_report" and "diagnose_report" respectively. The model will learn to adapt to the characteristics of these two types of text.

[0095] Step S2200: During the training process, the model generates a task mask for each task type, and controls the activation state of the corresponding task type module according to the task mask to complete the entity recognition task and relation extraction task of the target text. During training, the model dynamically generates a task mask based on the task type labels of the samples in each batch. This task mask is a matrix or vector composed of binary values ​​(0 or 1), and its dimension is related to the batch size or the number of tasks. The task mask acts as a controller, precisely managing the activation state of different task-specific modules (such as task-type NER classifiers and RE classifiers) during the model's forward propagation and loss calculation phases.

[0096] For each task in the task type set, the model generates a corresponding mask vector. The value of each element in this mask vector depends on whether the corresponding sample in the batch belongs to that task. Specifically, if the task label of the i-th sample in the batch is the current task t, then its corresponding mask value is set to 1; otherwise, it is set to 0. This mechanism ensures that when calculating the loss for a specific task, only samples belonging to that task contribute to the parameter gradient of the corresponding task-specific classifier, while samples from other tasks are effectively masked, thus achieving efficient utilization of parameters and on-demand allocation of computational resources.

[0097] The specific application of task masks is reflected in the controlled computation path of the model's forward propagation. After the input batch data obtains a global context representation through the shared coding layer, the model does not simultaneously activate all task heads for prediction. Instead, based on the instructions of the task mask, it selectively allows only the task heads corresponding to samples in the current batch to participate in the computation. For example, in a mixed batch containing samples of two tasks, "discharge record" and "test report," when the computation flow points to the "discharge record" task, the task mask ensures that only samples labeled "discharge record" will flow through the NER and RE classifiers customized for that task, while the computation of "test report" samples on this path is skipped. This design simulates the time-sharing multiplexing strategy in multi-task parallel processing, allowing the model to process different tasks involved in a batch sequentially in a single forward propagation, without having to run the entire model separately for each task, significantly improving training efficiency.

[0098] The task mask generation logic can be flexibly implemented, including but not limited to pre-computing at the data loader level, or dynamically generating it based on the batch metadata of the input at the start of model forward propagation. Essentially, it establishes a data-dependent control flow that dynamically associates the task attributes of the samples with the model's computational graph.

[0099] Step S2300: Calculate the loss of entity recognition task and relation extraction task respectively according to the corresponding labels in the training samples, and weight the entity recognition loss and relation extraction loss of the corresponding task type through the task mask; After completing the forward propagation and obtaining controlled computation results based on the task mask, the model evaluates the prediction errors of the entity recognition task and the relation extraction task respectively based on the pre-labeled real labels in the training samples, and uses the task mask mechanism to finely weight the loss, and finally implements joint supervision.

[0100] The loss calculation for entity recognition tasks is based on the output of the basic NER recognition module and the ground truth labels of entity boundaries in the samples. Specifically, for each lemma position, the model outputs a logits vector representing the entity category (e.g., categories under the BIO annotation system), indicating the entity boundary information. The loss function quantifies the prediction error by comparing the difference between this logits vector and the ground truth label. A typical implementation uses the cross-entropy loss function, which is effective in handling multi-class classification problems.

[0101] The loss calculation for relation extraction is performed on all possible entity pairs. The model compares the relation strength signal (dot product matrix) generated from the entity augmentation vectors and the output of the relation classifier with the labeled true relation triples in the samples. The relation extraction loss can also use the cross-entropy loss function, which aims to maximize the probability of the correct relation type and minimize the probability of the incorrect type.

[0102] The task mask plays a crucial role at this stage, being used to weight the raw losses calculated above. For a specific task type being processed in the current batch, its corresponding task mask vector is multiplied by the loss value of each sample. Specifically, if a sample belongs to the current task, its loss is multiplied by the mask value of 1 and included in the total loss; if the sample does not belong to the current task, its loss is multiplied by the mask value of 0 and ignored.

[0103] This weighting method ensures that when optimizing classifier parameters for a specific task, the gradient only comes from samples relevant to that task, thus avoiding interference between samples from different tasks and guaranteeing that the model can learn specific, discriminative feature patterns for different domains or needs. For example, when optimizing the RE classifier for the "discharge record" task, only the relation extraction loss generated by samples labeled "discharge record" is accumulated, while the relation extraction loss of "test report" samples in the same batch is masked.

[0104] Step S2400: Summarize the weighted losses of all task types and implement joint supervision of the entity recognition task and relation extraction task.

[0105] After obtaining the entity recognition loss and relation extraction loss weighted by task masks respectively, the model summarizes the weighted losses of all task types to form the final total loss. The total loss is the weighted sum of the losses of all activated tasks in the current training batch (i.e., samples with a value of 1 in their mask vectors). The formula for calculating the total loss can be expressed as the sum of the products of each task loss and its weight hyperparameter. This total loss is the objective function for optimizing the model parameters. The gradient is calculated using the backpropagation algorithm, and all parameters in the model, including the parameters of the shared encoding layer and the parameters of each independent multi-task head, are updated using gradient descent or its variants (such as the Adam optimizer).

[0106] The above embodiments implement joint supervision based on task masks, enabling the model to learn multiple related but different information extraction tasks simultaneously in a single training iteration. This achieves a balance between parameter sharing and task specificity, effectively improving the model's generalization ability and training efficiency.

[0107] Based on any embodiment of the method in this application, after determining the entity relationship data between each pair of entities contained in the target text according to the entity augmentation vector, the method includes: Step S4100: Based on the preset medical knowledge base, filter out the entity relationship data belonging to the medical knowledge items to form a basic information set; After obtaining the structured entity relation data output by the entity relation extraction model, this embodiment introduces a post-processing and analysis workflow to further enhance its application value in professional fields (such as clinical medicine). This workflow first performs an information filtering step, that is, it verifies and filters the entity relation data output by the model based on a preset medical knowledge base.

[0108] The medical knowledge base here is a pre-built structured database containing authoritative medical knowledge entries. Its content can cover various medical concepts and their standard relationships, such as diseases, symptoms, drugs, laboratory tests, and treatment procedures. The purpose of filtering is to identify and retain entity relationship data that conforms to the standard medical concepts defined in the knowledge base from the raw results output by the model. This constitutes a purified and standardized basic information set, effectively filtering out non-standard or erroneous information that may arise from model misjudgment or textual ambiguity.

[0109] For example, for the triple (aspirin, treatment, headache) output by the model, the triple is included in the basic information set after verifying whether "aspirin" and "headache" exist in the drug and disease list of the knowledge base, and whether the "treatment" relationship conforms to the standard relationship type defined in the knowledge base.

[0110] Step S4200: Combine the basic information set with the prompt template corresponding to the task type to which the target text belongs to obtain the corresponding prompt text; After constructing the basic information set, it can be transformed into an input format suitable for downstream medical information analysis models to understand. Specifically, this can be achieved by combining the basic information set with a prompt template corresponding to the task type of the target text.

[0111] The prompt template is a predefined text framework whose structure is specifically designed according to different information extraction task objectives (such as "medication record summary" or "diagnosis information extraction"). The template contains fixed guiding text and variable placeholders. During operation, structured data (such as entity relation triples) from the basic information set are filled into the corresponding placeholders in the prompt template, thereby generating a coherent and semantically rich prompt text.

[0112] For example, for the "Medication Record Summary" task, the prompt template might be: "Generate a summary based on the following medication information: The patient used [medication] at a dose of [dosage] to treat [disease]." After filling in the basic information set (aspirin, dose, 100mg) and (aspirin, treatment, headache), the resulting prompt text might be: "Generate a summary based on the following medication information: The patient used aspirin at a dose of 100mg to treat headache." It is evident that this templated approach organizes discrete structured data into natural language descriptions, providing a high-quality instruction context for medical information analysis models based on large language models.

[0113] Step S4300: Input the prompt text into a preset medical information analysis model to generate medical analysis result information for the basic information set.

[0114] Finally, the generated prompt text is input into a preset medical information analysis model, which then generates medical analysis results for the basic information set.

[0115] Medical information analysis models are models with powerful natural language understanding and generation capabilities. For example, large language models that have been fine-tuned based on massive amounts of medical literature and clinical guidelines can be used. Various existing mature large language models can be adopted, or fine-tuned models obtained by training on a small number of samples based on these large language models can also be used.

[0116] After receiving prompt text, the medical information analysis model can understand the semantics of the medical data contained therein and perform specific analysis tasks. The generated analysis results are diverse in form, including but not limited to generating patient medical record summaries, providing clinical decision support suggestions, judging the rationality of medication, identifying potential drug interaction risks, or generating standardized medical report paragraphs.

[0117] For example, regarding the aforementioned prompt text about aspirin, the medical information analysis model might output the following analysis result: "The medication record shows that the patient used 100mg of aspirin to treat headaches. This regimen conforms to the routine symptomatic treatment principles for mild to moderate headaches. It is recommended to pay attention to whether the patient has adverse reactions such as gastrointestinal discomfort." This step transforms the results of the previous information extraction into insightful analytical conclusions that can directly assist medical practice, realizing a value loop from raw text to intelligent decision support.

[0118] The above embodiments, by combining the entity relationship extraction results with the domain knowledge base and medical information analysis model, significantly deepen the application level of the technical solution of this application and achieve positive comprehensive technical effects. Specifically, this embodiment constructs a complete technical closed loop from accurate information extraction to intelligent decision support, with positive effects manifested in multiple aspects: First, by introducing a medical knowledge base to screen and verify the original extraction results, the accuracy and professionalism of the output information are effectively improved, noise and ambiguous data are filtered out, ensuring the high quality and reliability of the basic information set, and solving the credibility problem that pure data-driven models may encounter in professional fields; Second, by using task-adaptive prompt templates to transform structured data into semantically rich natural language instructions, the understanding ability and task adaptability of downstream analysis models are greatly enhanced, enabling general information extraction results to seamlessly connect with diverse professional analysis needs, and improving the flexibility and scalability of the technical solution; Finally, by generating clinically insightful analysis results through the medical information analysis model, basic structured data is transformed into in-depth information that can directly assist in diagnosis and treatment decisions, such as medication rationality assessment and risk warning, thereby improving the automation level of information processing while greatly enhancing the practical value and action guidance significance of the final output results, realizing a technological leap from perception and understanding to analysis and decision-making.

[0119] Please see Figure 3This application provides an entity relationship recognition device, which is a functional embodiment of the entity relationship recognition method of this application. The device includes a feature representation module 3100, a conversion processing module 3200, a structure enhancement module 3300, a full-text enhancement module 3400, and a relationship recognition module 3500. The feature representation module 3100 is configured to apply the feature representation network in the entity relationship extraction model to perform feature representation on the word segmentation sequence of the target text to be identified, generating a full-text feature vector. The conversion processing module 3200 is configured to perform entity classification based on the full-text feature vector using the conversion network in the model. The entity boundary information is used to construct entity feature vectors from the word vector segments of each entity in the full-text feature vector; the structure enhancement module 3300 is configured to perform convolution enhancement processing on the entity feature vector using the convolutional network in the model to obtain a structure enhancement vector; the full-text enhancement module 3400 is configured to perform context enhancement processing on the structure enhancement vector using the attention network in the model and the full-text feature vector to generate entity enhancement vectors; the relationship recognition module 3500 is configured to determine the entity relationship data between each pair of entities contained in the target text based on the entity enhancement vector using the classification network in the model.

[0120] Based on any embodiment of the apparatus in this application, the conversion processing module 3200 includes: a boundary determination module, configured to perform entity classification on the full-text feature vector to obtain entity boundary information; an index determination module, configured to decode the entity boundary information to determine the start and end position indices of each entity in the target text; and a word extraction construction module, configured to extract the corresponding entity word vector segments from the full-text feature vector according to the start and end position indices, and concatenate the word vector segments into an entity feature vector.

[0121] Based on any embodiment of the device in this application, the structure enhancement module 3300 includes: a dimension unrolling module, configured to unroll the entity feature vector into an input feature vector according to the entity dimension; a multi-round convolution module, configured to sequentially convolve the input feature vector through multiple single-dimensional convolutional layers in the convolutional network to obtain convolution enhancement vectors corresponding to each convolutional layer; and a skip pooling module, configured to perform mean pooling on the convolution enhancement vectors of the first and last convolutional layers by pooling layers in the convolutional network to obtain a structure enhancement vector.

[0122] Based on any embodiment of the apparatus in this application, the full-text enhancement module 3400 includes: a vector input module, configured to input the structure enhancement vector as a query vector and the full-text feature vector as a key vector and a value vector into an attention network; an interactive attention module, configured to calculate the similarity between the query vector and the key vector in the attention network and generate attention weights; and a weighted summation module, configured to perform a weighted summation of the value vector by the attention network according to the attention weights to obtain the entity enhancement vector.

[0123] Based on any embodiment of the device in this application, the relationship recognition module 3500 includes: a subject mapping module, configured to generate a first feature vector for each entity by combining the absolute position encoding of each entity and the entity enhancement vector from the first linear layer in the classification network, wherein the first feature vector is used to represent the subject role feature of the entity in the relationship; an object mapping module, configured to generate a second feature vector for each entity by combining the absolute position encoding of each entity and the entity enhancement vector from the second linear layer in the classification network, wherein the second feature vector is used to represent the object role feature of the entity in the relationship; a dot product operation module, configured to calculate the dot product result of the corresponding first feature vector and second feature vector between any two entities, and represent all dot product results as a dot product matrix, wherein each element of the dot product matrix represents the relationship strength between the two entities; and a classification output module, configured to classify the dot product matrix by the relationship classifier in the classification network to determine the entity relationship data between the entities in the target text.

[0124] Based on any embodiment of the device in this application, prior to the feature representation module 3100, the device further includes: a sample input module, configured to encode the word segmentation sequences of text data containing multiple different task types in the training samples, and then input them into the entity relation extraction model for training; a training execution module, configured to generate a task mask corresponding to each task type by the model during the training process, and control the activation state of the corresponding task type module according to the task mask to complete the entity recognition task and relation extraction task of the target text; a loss calculation module, configured to calculate the loss of the entity recognition task and the relation extraction task respectively according to the corresponding labels in the training samples, and weight the entity recognition loss and relation extraction loss of the corresponding task type through the task mask; and a training supervision module, configured to summarize the weighted losses of all task types to implement joint supervision of the entity recognition task and the relation extraction task.

[0125] Based on any embodiment of the device in this application, following the relationship identification module 3500, the device further includes: a data filtering module, configured to filter out entity relationship data belonging to medical knowledge entries according to a preset medical knowledge base to form a basic information set; a prompt construction module, configured to combine the basic information set with a prompt template corresponding to the task type to which the target text belongs to obtain a corresponding prompt text; and an analysis and processing module, configured to input the prompt text into a preset medical information analysis model to generate medical analysis result information for the basic information set.

[0126] To address the aforementioned technical problems, embodiments of this application also provide a computer device. For example... Figure 4 The diagram shows the internal structure of a computer device. The computer device includes a processor, a computer-readable storage medium, a memory, a network interface, and various communication components connected via a system bus. The computer-readable storage medium stores an operating system, a database, and computer-readable instructions. The database may store a sequence of control information. When the computer-readable instructions are executed by the processor, the processor can implement an entity relationship recognition method. The processor of the computer device provides computing and control capabilities, supporting the operation of the entire computer device. The memory of the computer device may store computer-readable instructions. When these computer-readable instructions are executed by the processor, the processor can execute the entity relationship recognition method of this application. The network interface of the computer device is used for communication with a terminal. Those skilled in the art will understand that… Figure 4 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0127] In this embodiment, the processor is used to execute... Figure 3 The system defines the specific functions of each module and its sub-modules. The memory stores the program code and various data required to execute these modules or sub-modules. The network interface is used for data transmission between the user terminal and the server. In this embodiment, the memory stores the program code and data required to execute all modules / sub-modules in the entity relationship identification device of this application. The server can call the server's program code and data to execute the functions of all sub-modules.

[0128] This application also provides a storage medium storing computer-readable instructions, which, when executed by one or more processors, cause the one or more processors to perform the steps of the entity relationship identification method of any embodiment of this application.

[0129] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments of this application can be implemented by a computer program instructing related hardware. This computer program can be stored in a computer-readable storage medium, and when executed, it can include the processes of the embodiments of the methods described above. The aforementioned storage medium can be a magnetic disk, optical disk, read-only memory (ROM), or random access memory (RAM), etc.

[0130] Those skilled in the art will understand that the steps, measures, and solutions in the various operations, methods, and processes discussed in this application can be alternated, modified, combined, or deleted. Furthermore, other steps, measures, and solutions in the various operations, methods, and processes discussed in this application can also be alternated, modified, rearranged, decomposed, combined, or deleted. Furthermore, steps, measures, and solutions in the prior art that are similar to those in the open-source operations, methods, and processes of this application can also be alternated, modified, rearranged, decomposed, combined, or deleted.

[0131] The above description is only a partial embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.

Claims

1. A method for identifying entity relationships, characterized in that, include: The feature representation network in the entity relation extraction model is applied to perform feature representation on the word segmentation sequence of the target text to be identified, generating a full-text feature vector; The entity boundary information obtained by entity classification based on the full-text feature vector is obtained by the transformation network in the model, and the word vector segments of each entity in the full-text feature vector are constructed as entity feature vectors. The convolutional network in the model performs convolutional enhancement processing on the entity feature vector to obtain a structure enhancement vector; The attention network in the model uses the full-text feature vector to perform context enhancement processing on the structure enhancement vector to generate the entity enhancement vector; The classification network in the model determines the entity relationship data between each pair of entities contained in the target text based on the entity augmentation vector.

2. The entity relationship identification method according to claim 1, characterized in that, Based on the entity boundary information obtained from entity classification using the full-text feature vector, the word vector segments of each corresponding entity in the full-text feature vector are constructed as entity feature vectors, including: Entity classification is performed on the full-text feature vectors to obtain entity boundary information; The entity boundary information is decoded to determine the start and end position indices of each entity in the target text; Based on the start and end position indices, extract the corresponding entity word vector segments from the full-text feature vector, and concatenate the word vector segments into an entity feature vector.

3. The entity relationship identification method according to claim 1, characterized in that, The entity feature vector is subjected to convolution enhancement processing to obtain a convolution enhancement vector, including: Expand the entity feature vector into an input feature vector according to the entity dimension; The input feature vector is sequentially convolved through multiple single-dimensional convolutional layers in the convolutional network to obtain the convolutional enhancement vector corresponding to each convolutional layer. The convolutional enhancement vectors of the first and last convolutional layers are average-pooled by the pooling layers in the convolutional network to obtain the structural enhancement vector.

4. The entity relationship identification method according to claim 1, characterized in that, The structure enhancement vector is subjected to context enhancement processing using the full-text feature vector to generate an entity enhancement vector, including: The structure enhancement vector is used as the query vector, and the full-text feature vector is used as the key vector and value vector, which are then input into the attention network. In the attention network, the similarity between the query vector and the key vector is calculated to generate attention weights; Based on the attention weights, the attention network performs a weighted summation of the value vectors to obtain the entity augmentation vector.

5. The entity relationship identification method according to claim 1, characterized in that, Based on the entity augmentation vector, the entity relationship data between each pair of entities contained in the target text is determined, including: The first feature vector of each entity is generated by combining the absolute position encoding of each entity and the entity augmentation vector in the first linear layer of the classification network. The first feature vector is used to represent the main role feature of the entity in the relationship. The second linear layer in the classification network combines the absolute position encoding of each entity with the entity augmentation vector to generate a second feature vector for each entity. The second feature vector is used to represent the object role feature of the entity in the relationship. Calculate the dot product of the first and second eigenvectors corresponding to each pair of entities, and represent all dot product results as a dot product matrix, where each element of the dot product matrix represents the strength of the relationship between the two entities. The dot product matrix is ​​classified by the relation classifier in the classification network to determine the entity relationship data between various entities in the target text.

6. The entity relationship identification method according to any one of claims 1 to 5, characterized in that, Before applying the feature representation network in the entity relation extraction model, the following steps are included: After encoding the word segmentation sequences of text data containing multiple different task types in the training samples, they are input into the entity relation extraction model for training. During training, the model generates a task mask for each task type, and controls the activation state of the corresponding task type module according to the task mask to complete the entity recognition and relation extraction tasks of the target text. Based on the corresponding labels in the training samples, the losses for entity recognition and relation extraction tasks are calculated respectively, and the entity recognition loss and relation extraction loss for the corresponding task type are weighted by the task mask. The weighted loss of all task types is aggregated to implement joint supervision of the entity recognition task and the relation extraction task.

7. The entity relationship identification method according to claim 6, characterized in that, After determining the pairwise entity relationship data between each entity contained in the target text based on the entity augmentation vector, the process includes: Based on a pre-set medical knowledge base, the entity relationship data belonging to medical knowledge items are filtered out to form a basic information set; By combining the basic information set with the prompt template corresponding to the task type to which the target text belongs, the corresponding prompt text is obtained; The prompt text is input into a preset medical information analysis model to generate medical analysis results information for the basic information set.

8. An entity relationship recognition device, characterized in that, include: The feature representation module is configured to apply the feature representation network in the entity relation extraction model to perform feature representation on the word segmentation sequence of the target text to be identified, and generate full-text feature vectors. The conversion processing module is configured to use the conversion network in the model to construct entity feature vectors from the word vector segments of each entity in the full-text feature vector based on the entity boundary information obtained by entity classification from the full-text feature vector. The structure enhancement module is configured to perform convolution enhancement processing on the entity feature vector using the convolutional network in the model to obtain the structure enhancement vector; The full-text enhancement module is configured to use the attention network in the model to perform context enhancement processing on the structure enhancement vector using the full-text feature vector to generate the entity enhancement vector; The relationship recognition module is configured to use the classification network in the model to determine the entity relationship data between each pair of entities contained in the target text based on the entity augmentation vector.

9. A computer device comprising a processor and a memory, characterized in that, The processor invokes and runs a computer program in the memory to perform the steps of the entity relationship identification method as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, It stores, in the form of computer-readable instructions, a computer program implemented according to any one of claims 1 to 7, which, when invoked by a computer, executes the steps included in the corresponding method.