Knowledge and text bidirectional alignment medical text representation enhancement method
By constructing a two-way alignment method of text sequences and medical knowledge graph subgraphs, the deep integration of text representation and knowledge representation is solved, and a knowledge-enhanced text representation with more information and semantic accuracy is generated, which improves the accuracy and professionalism of subsequent tasks.
Patent Information
- Application Number
- CN202510616929.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-14
- Publication Date
- 2025-08-26
AI Technical Summary
It is difficult for the prior art to achieve deep semantic alignment and interactive integration between text representation and knowledge representation, resulting in the use of knowledge remaining in shallow layers, affecting the accuracy and professionalism of subsequent tasks.
By constructing input parameters, including text sequences, medical knowledge graph subgraphs, entity embedding search functions, text representation calculations, knowledge graph representation calculations, knowledge and text bidirectional attention calculations and attention-weighted fusion fusion instructions, generate deeply fusion knowledge-enhanced text representations.
The depth, two-way interaction and alignment between text information and external medical knowledge base is achieved, and knowledge-enhanced text representations with more information and semantic accuracy are generated, which improves the accuracy and professionalism of subsequent tasks.
Smart Images

Figure CN120541236A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of NLP, and in particular relates to a medical text representation enhancement method for bidirectional alignment of knowledge and text. Background Art
[0002] Existing technologies often struggle to achieve deep semantic alignment and interactive fusion between text representation and knowledge representation, resulting in superficial knowledge utilization and a failure to fully tap into the complex relationships and semantic information inherent in knowledge structures. Furthermore, text representations fail to effectively incorporate semantic information from related knowledge for enhancement, impacting the accuracy and professionalism of subsequent tasks (such as generation, question-answering, and summarization). Therefore, a fusion mechanism is urgently needed that enables deep, bidirectional interaction and alignment between medical text representation and medical knowledge representation to generate more informative and semantically accurate knowledge-enhanced text representations. This can address the technical issue of insufficient fusion of text information with external medical knowledge bases (such as knowledge graphs). Summary of the Invention
[0003] The purpose of this embodiment is to provide a medical text representation enhancement method with bidirectional alignment of knowledge and text, which is used to solve the technical problem of insufficient fusion of text information and external medical knowledge base (such as knowledge graph).
[0004] A medical text representation enhancement method for bidirectional alignment of knowledge and text, including:
[0005] S0: Construct input parameters, including:
[0006] Text sequence X;
[0007] Medical knowledge graph subgraph Gx;
[0008] Entity embedding lookup function;
[0009] S1: Execute a text representation calculation instruction according to the text sequence X to obtain a text representation sequence Hx; the text representation sequence Hx is a sequence that integrates text context and explicit entity information;
[0010] S2: Execute the knowledge graph representation calculation instructions to obtain the structure-aware representation sequence H E ;
[0011] S3: Based on the text representation sequence Hx and the structure perception representation sequence H E Execute the knowledge and text bidirectional attention calculation instructions to obtain the bidirectional attention weight matrices A and B;
[0012] S4: Perform attention weighted fusion and enhancement instructions according to the bidirectional attention weight matrices A and B to obtain the enhanced text representation H enhanced .
[0013] Preferably, the text representation calculation instruction includes:
[0014] S1.1: Input the text sequence X into a pre-trained medical language model to obtain an initial context hidden state sequence, wherein the pre-trained medical language model includes BERT;
[0015] S1.2: Execute entity recognition instructions according to the text sequence X to obtain an entity mention list, wherein the entity recognition instructions include MedicalNER, and the entity mention list is in is the identifier of the jth entity in the knowledge graph, i start and i end is the corresponding start and end position of the entity in the sequence X; optional, each word x i Corresponds to at most one entity e′ i ∈E X ∪{Null}, where Null indicates that the token does not correspond to any specific entity;
[0016] S1.3: Based on the initial context hidden state sequence H init , the identified entity correspondence e′ i (from the entity mention list E mention ), the entity embedding search function executes the entity information fusion instruction to obtain the final text representation sequence Hx; the entity information fusion instruction includes: for the initial context hidden state sequence H init Every vector in (i ranges from 1 to n), the fusion operation includes: if the word x i Corresponding to a non-empty entity e′ i , the fusion vector is calculated by the fusion formula; the fusion formula is: If the word x i does not correspond to the entity (i.e. e′ i =extNull), then The '+' in the fusion formula represents vector addition.
[0017] Preferably, the knowledge graph representation calculation instructions include:
[0018] S2.1: Based on the input entity set E X =[e1,e2,…,e m ] and the entity embedding lookup function executes the entity initial embedding instruction to obtain the entity initial embedding sequence The entity initial embedding instruction includes executing X Each entity e in j(j ranges from 1 to m), and uses the entity embedding lookup function to obtain its initial embedding vector Further, the initial embedding sequence of the entity is obtained based on the initial embedding vector;
[0019] S2.2: Execute the graph structure information propagation calculation instruction to obtain a structure-aware entity representation sequence, wherein the structure-aware entity representation sequence is a graph neural network (GNN); the graph structure information propagation calculation instruction includes: Knowledge graph subgraph G X As the initial node representation, it is input into a graph neural network (GNN) containing L layers. The further GNN is based on the knowledge graph subgraph G X The graph structure (including the connection relationship R between entities X ) executes an iterative instruction to iteratively aggregate the information of neighbor nodes in each layer to update the node representation, wherein the iterative instruction includes using a graph convolutional network (GCN) or a graph attention network (GAT); wherein the entity representation sequence expression is in It is entity e j The vector representation containing adjacency structure information is obtained after L-layer graph information propagation.
[0020] Preferably, the knowledge and text bidirectional attention calculation instructions include:
[0021] S3.1: Execute the text-to-knowledge attention calculation instruction to obtain the text-to-knowledge attention weight matrix A; the expression of the attention weight matrix A is: A=[a ij ] n X m ,in Represents the attention weight of text word i to knowledge entity j; including executing each attention head h (h from 1 to H) of the multi-head attention mechanism according to the final text representation sequence Hx and the final knowledge entity representation sequence, calculating the query key in is the learnable projection matrix of the head; the attention score is calculated as (d k is the key vector dimension); use the Softmax function to normalize according to the knowledge dimension (column) to obtain the attention weight matrix of the head And the weights of all heads are averaged; wherein the final text representation sequence Hx is expressed as H X =[h1,...,h n ], the final knowledge entity represents the sequence expression as
[0022] S3.2: Execute the knowledge-to-text attention calculation instruction to obtain the knowledge-to-text attention weight matrix B. The text attention weight matrix B is expressed as B=[β ji ] m X n ,in Represents the attention weight of knowledge entity j to text word i; the knowledge to text attention calculation instruction includes according to the text representation sequence H X The final knowledge entity representation sequence uses a multi-head attention mechanism to calculate the query key in is another set of projection matrices; calculate the attention score Use the Softmax function to normalize the text dimension (column) to obtain the attention weight matrix And combine the weights of all heads.
[0023] Preferably, the knowledge information weighted aggregation instruction includes:
[0024] S4.1: Execute the knowledge information weighted aggregation instruction to obtain the aggregated knowledge context sequence, according to the final knowledge entity representation sequence and the text to knowledge attention weight matrix A and the value projection matrix W v The value representation of the computational knowledge V=H E W v ; Further, for each text position i, according to the attention weight a ij Perform weighted summation on the knowledge value representation to obtain the aggregated knowledge context vector where v j is the jth row of V; where the aggregated knowledge context sequence expression is
[0025] S4.2: Execute the text representation preliminary enhancement instruction to obtain the preliminary knowledge enhanced text representation sequence, and integrate the aggregated knowledge information into the text representation according to the final text representation sequence Hx, the aggregated knowledge context sequence, and the fusion weight γ1; for each position i, calculate the preliminary enhanced text representation The aggregated knowledge context sequence expression is:
[0026] S4.3: Optionally, execute text information weighted aggregation and knowledge representation enhancement instructions to obtain a preliminary text enhanced knowledge representation sequence
[0027] S4.4: Execute interactive fusion network instructions to obtain the deep fusion representation H fusion; including a sequence of text representations enhanced according to said preliminary knowledge Preliminary Text Enhanced Knowledge Representation Sequence or the original H E or aggregated The two representation sequences are combined and executed; the combined representation is further input into one or more feed-forward network (FFN) layers and layer normalization (LayerNorm) layers for nonlinear transformation and stabilization training; the expression is H fusion =LayerNorm(FFN(H concat ));
[0028] S4.5: Execute the self-attention enhancement instruction to obtain the final knowledge-enhanced text representation sequence, where the knowledge-enhanced text representation sequence is expressed as The final self-attention enhancement instruction includes the following steps: fusion Input into a multi-head self-attention layer, further modeling and fusion represent the dependencies between internal elements, capturing high-order interaction information; its expression is H enhanced =extMultiHeadAttn(Q=H fusion ,K=H fusion ,V=H fusion ).
[0029] Preferably, the text sequence X is expressed as X=[x1, x2, ..., x n ], where x i Represents the i-th word in the text, and the medical knowledge graph subgraph Gx is expressed as G X =(E X ,R X ), where E X =[e1,e2,...,e m ] is a set of related entities, R X It is the set of relationships between these entities.
[0030] Preferably, the entity embedding lookup function is Embed(e).
[0031] Preferably, the initial context hidden state sequence expression is in is the corresponding word x i The initial vector representation, d model is the hidden layer dimension of the model.
[0032] Preferably, the entity initial embedding sequence expression is
[0033] Preferably, the projection matrix W vis the value projection matrix in multi-head attention.
[0034] The present invention provides a medical text representation enhancement method for bidirectional alignment of knowledge and text, which solves the technical problem of insufficient fusion of text information with external medical knowledge bases (such as knowledge graphs).
[0035] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, preferred embodiments are given below and described in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] Figure 1 : A step diagram of a medical text representation enhancement method for bidirectional alignment of knowledge and text provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0037] The technical solutions in the embodiments of the present invention will be described below with reference to the accompanying drawings in the embodiments of the present invention.
[0038] The present invention provides a method for enhancing the representation of medical texts by bidirectionally aligning knowledge and text (see Figure 1 ), used to generate knowledge-enhanced text representation; in specific implementation, Python language is used to implement specific implementation codes according to expressions and formulas; libraries for implementing operations include automodel, transformers, torch_geometric.nn, AutoTokenizer, AutoModel, etc.; in this embodiment, medical text representation and related medical knowledge graph subgraph representation are received as input, and the fused enhanced text representation is output; the steps include:
[0039] The input parameters for this embodiment include:
[0040] S0: Prepare input parameters, including:
[0041] Original medical text sequence: X=[x1,x2,...,x n ], where x i Represents the i-th word in the text.
[0042] Medical knowledge graph subgraph Gx:G related to text X X =(E X ,R X ), where E X =[e1,e2,...,e m ] is a set of related entities, R X It is the set of relationships between these entities.
[0043] Entity embedding lookup function: Embed(e), used to obtain the vector representation of entity e in the knowledge graph.
[0044] S1 executes text representation calculation instructions:
[0045] The goal of this step is to obtain a text representation sequence H that initially integrates text context and explicit entity information. X , including the steps of:
[0046] S1.1 executes context-aware encoding instructions:
[0047] Input: original text sequence X;
[0048] Processing: The sequence X is fed into a pre-trained medical language model (e.g., BERT). The model uses its internal mechanisms (e.g., multi-head self-attention) to capture the contextual dependencies between tokens in X.
[0049] Output: Get the initial context hidden state sequence in is the corresponding word x i The initial vector representation rich in context information, d model is the hidden layer dimension of the model.
[0050] S1.2 Execute entity recognition and linking instructions:
[0051] Input: Original text sequence X.
[0052] Perform processing: Apply medical entity recognition to X, including (MedicalNER) technology, to identify the medical entities mentioned in the text and their positions in the sequence.
[0053] Output: Get the list of entity mentions in is the identifier of the jth entity in the knowledge graph, i start and i end is the corresponding start and end position of the entity in the sequence X. To simplify the subsequent representation, we assume that each word x i Corresponds to at most one entity e′ i ∈E X ∪{Null}, where Null indicates that the token does not correspond to any specific entity.
[0054] S1.3 Execute entity information fusion instructions:
[0055] Input: Initial context hidden state sequence H init , the identified entity correspondence e′ i (From E mention ), entity embedding lookup function Embed(e).
[0056] Execute processing: For H init Every vector in (i ranges from 1 to n), perform the following fusion operations:
[0057] If the word x i Corresponding to a non-empty entity e′ i , then calculate the fusion vector
[0058] If the word x i does not correspond to the entity (i.e. e′ i =extNull), then The '+' in the formula refers to vector addition.
[0059] Output: Get the final text representation sequence H X =[h1,h2,...,h n ]. This sequence H X Each vector h in i Both integrate context information and corresponding medical entity information. X It will serve as the main text input for the subsequent bidirectional alignment module.
[0060] S2 executes the knowledge graph representation calculation instruction (Knowledge Graph Representation Calculation)
[0061] The goal of this step is to obtain the knowledge graph subgraph G X The structure-aware representation sequence H of entities in E ; comprising the steps of:
[0062] S2.1 Execute the entity initial embedding instruction to obtain the entity initial embedding sequence:
[0063] Input: Entity set E in the knowledge graph subgraph X =[e1,e2,…,e m ], entity embedding lookup function Embed(e).
[0064] Execute processing: For E X Each entity e in j (j ranges from 1 to m), and uses the entity embedding lookup function to obtain its initial embedding vector
[0065] Output: Get the entity initial embedding sequence based on the initial embedding vector
[0066] S2.2 performs graph structure information propagation calculations to obtain structure-aware entity representation sequences (GNN), including:
[0067] Input: Knowledge graph subgraph G X =(E X ,R X ), the entity initial embedding sequence
[0068] Execution processing: According to the entity initial embedding sequence As the initial node representation, it is input into a graph neural network (GNN) containing L layers. GNN is based on G X The graph structure (connection relationship R between entities X ), iteratively aggregates the information of neighbor nodes in each layer to update the node representation.
[0069] The specific implementation uses graph convolutional networks (GCN) or graph attention networks (GAT).
[0070] Output: Get structure-aware entity representation sequence in It is entity e j The vector representation containing adjacency structure information is obtained after L-layer graph information propagation.
[0071] S3 executes the knowledge-text bidirectional attention calculation instruction (Knowledge-Text BidirectionalAttention Calculation);
[0072] The goal is to calculate the bidirectional attention weight matrices A and B between text and knowledge representation, including the following steps:
[0073] S3.1 executes the text-to-knowledge attention calculation instruction to obtain the text-to-knowledge attention weight matrix A:
[0074] Input: Final text representation sequence H X =[h1,...,h n ], the final knowledge entity representation sequence
[0075] Execution processing: Use multi-head attention mechanism. For each attention head h (h from 1 to H), calculate the query key in is the learnable projection matrix of the head. Calculate the attention score (Take the scaled dot product as an example, d k is the key vector dimension). Apply the Softmax function to normalize by the knowledge dimension (column) to obtain the attention weight matrix of the head Average the weights of all heads (or other merging methods).
[0076] Output: Text to knowledge attention weight matrix A = [a ij ] n X m ,in Represents the attention weight of text word i to knowledge entity j. This A is used for subsequent aggregation of knowledge information.
[0077] S3.2 performs knowledge-to-text attention calculation:
[0078] Input: Final text representation sequence H X =[h1,...,h n ], the final knowledge entity representation sequence
[0079] Execution processing: similarly adopts multi-head attention mechanism. Calculate query key in Is another set of projection matrices. Calculate the attention score Apply the Softmax function to normalize by text dimension (column) to get the attention weight matrix of the head Combine weights from all heads.
[0080] Output: Get knowledge to text attention weight matrix B = [β ji ] m X n ,in Represents the attention weight of knowledge entity j to text word i. This B is used for subsequent aggregation of text information.
[0081] S4 performs attention weighted fusion and enhancement instructions (Attention Weighted Fusion and Enhancement)
[0082] This step uses the calculated attention weights A and B to X and H E Perform deep interactive fusion and finally generate enhanced text representation H enhanced ; comprising the steps of:
[0083] S4.1 executes the knowledge information weighted aggregation instruction:
[0084] Input: Final knowledge entity representation sequence Text to knowledge attention weight matrix A = [a ij ] n X m , value projection matrix W v(Often related to value projection in multi-head attention).
[0085] Processing: Calculate the value of knowledge V = H E W v For each text position i, according to the attention weight a ij Perform weighted summation on the knowledge value representation to obtain the aggregated knowledge context vector
[0086] where v j is the j-th row of V.
[0087] Output: Get aggregated knowledge context sequence This sequence represents a summary of the most relevant knowledge information for each text token.
[0088] S4.2 performs preliminary enhancement instructions for text representation:
[0089] Input: Final text representation sequence H X =[h1,...,h n ], aggregated knowledge context sequence Learnable fusion weight γ1.
[0090] Perform processing: Incorporate aggregated knowledge into text representation. For each position i, calculate the initial enhanced text representation
[0091] Output: Get a sequence of text representations enhanced with preliminary knowledge
[0092] S4.3 (This step is optional and can be symmetrical or for deeper fusion) Text information weighted aggregation and knowledge representation enhancement:
[0093] Input: Final text representation sequence H X , knowledge to text attention weight matrix B, value projection matrix W v′ The final knowledge entity representation sequence H E .
[0094] Execute processing: see steps 4.1 and 4.2, calculate the aggregated text context sequence And use it to update H E Get preliminary text-enhanced knowledge representation sequence (Use another weight γ2).
[0095] Output: preliminary text-enhanced knowledge representation sequence
[0096] S4.4 executes interactive fusion network instructions:
[0097] Input: Sequence of text representations augmented with preliminary knowledge (from 4.2), and (if 4.3 was performed) a preliminary text-enhanced knowledge representation sequence Or use the original H E or aggregated In this embodiment, the input is and
[0098] Perform processing: Combine the two representation sequences (e.g., concatenate in the sequence dimension) or other interactive methods). The combined representation is input into one or more feed-forward network (FFN) layers and layer normalization (LayerNorm) layers for nonlinear transformation and stable training. fusion =LayerNorm(FFN(H concat )).
[0099] Output: Get the deep fusion representation H fusion .
[0100] S4.5 performs the final self-attention enhancement instruction:
[0101] Input: Deep fusion representation H fusion .
[0102] Execution processing: According to H fusion Input into a multi-head self-attention layer, further modeling and fusion represent the dependencies between internal elements, capturing higher-order interaction information; H enhanced =extMultiHeadAttn(Q=H fusion ,K=H fusion ,V=
[0103] H fusion ).
[0104] Output: Get knowledge-enhanced text representation sequence (In the embodiment, the output sequence length N may be different from the input n, depending on the fusion method, but is usually designed to be the same as n). enhanced The output results are used for downstream tasks. In this embodiment, they are used as input to the dynamic knowledge-aware decoder, and can optionally be used for other medical NLP tasks that require deep understanding of the input text.
[0105] The present invention provides a medical text representation enhancement method with bidirectional alignment of knowledge and text, which solves the technical problem of insufficient fusion of text information with external medical knowledge base (such as knowledge graph).
[0106] The foregoing description is merely an embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Those skilled in the art will readily appreciate that the present invention is susceptible to various modifications and variations. Any modifications, equivalent substitutions, or improvements made within the spirit and principles of the present invention shall be included within the scope of protection of the present invention.
Claims
1. A medical text representation enhancement method for bidirectional alignment of knowledge and text, characterized by: include: S0: Construct input parameters, including: Text sequence X; Medical knowledge graph subgraph Gx; Entity embedding lookup function; S1: Execute a text representation calculation instruction according to the text sequence X to obtain a text representation sequence Hx; the text representation sequence Hx is a sequence that integrates text context and explicit entity information; S2: Execute the knowledge graph representation calculation instructions to obtain the structure-aware representation sequence H E ; S3: Based on the text representation sequence Hx and the structure perception representation sequence H E Execute the knowledge and text bidirectional attention calculation instructions to obtain the bidirectional attention weight matrices A and B; S4: Perform attention weighted fusion and enhancement instructions according to the bidirectional attention weight matrices A and B to obtain the enhanced text representation H enhanced .
2. The medical text representation enhancement method for bidirectional alignment of knowledge and text according to claim 1 is characterized in that: The text representation calculation instructions include: S1.1: Input the text sequence X into the pre-trained medical language model to obtain the initial context hidden state sequence H init , the pre-trained medical language model includes BERT; S1.2: Execute entity recognition instructions according to the text sequence X to obtain the entity mention list E mention , the entity recognition instruction includes MedicalNER, and the entity mention list is in is the identifier of the jth entity in the knowledge graph, i start and i end is the corresponding start and end position of the entity in the sequence X; optional, each word x i Corresponds to at most one entity e′ i ∈E X ∪{Null}, where Null indicates that the token does not correspond to any specific entity; S1.3: Based on the initial context hidden state sequence H init , the identified entity correspondence e′ i (from the entity mention list E mention ), the entity embedding search function executes the entity information fusion instruction to obtain the final text representation sequence Hx; the entity information fusion instruction includes: for the initial context hidden state sequence H init Every vector in (i ranges from 1 to n), the fusion operation includes: if the word x i Corresponding to a non-empty entity e′ i , the fusion vector is calculated by the fusion formula; the fusion formula is: If the word x i does not correspond to the entity (i.e. e′ i =extNull), then The '+' in the fusion formula represents vector addition.
3. The medical text representation enhancement method for bidirectional alignment of knowledge and text according to claim 1 is characterized in that: The knowledge graph represents the calculation instructions including: S2.1: Based on the input entity set E X =[e1, e2, ..., e m ] and the entity embedding lookup function executes the entity initial embedding instruction to obtain the entity initial embedding sequence The entity initial embedding instruction includes executing X Each entity e in j (j ranges from 1 to m), use the entity embedding lookup function to obtain the initial embedding vector Further obtain the entity initial embedding sequence according to the initial embedding vector S2.2: Execute the graph structure information propagation calculation instruction to obtain a structure-aware entity representation sequence, wherein the structure-aware entity representation sequence is a graph neural network (GNN); the graph structure information propagation calculation instruction includes: Knowledge graph subgraph G X As the initial node representation, it is input into a graph neural network (GNN) containing L layers. The further GNN is based on the knowledge graph subgraph G X The graph structure (including the connection relationship R between entities X ) executes an iterative instruction to iteratively aggregate the information of neighbor nodes in each layer to update the node representation, wherein the iterative instruction includes using a graph convolutional network (GCN) or a graph attention network (GAT); wherein the entity representation sequence expression is in It is entity e j The vector representation containing adjacency structure information is obtained after L-layer graph information propagation.
4. The medical text representation enhancement method for bidirectional alignment of knowledge and text according to claim 1 is characterized in that: The knowledge and text bidirectional attention calculation instructions include: S3.1: Execute the text-to-knowledge attention calculation instruction to obtain the text-to-knowledge attention weight matrix A; the expression of the attention weight matrix A is: A=[a ij ] nXm ,in Represents the attention weight of text word i to knowledge entity j; including executing each attention head h (h from 1 to H) of the multi-head attention mechanism according to the final text representation sequence Hx and the final knowledge entity representation sequence, calculating the query key in is the learnable projection matrix of the head; the attention score is calculated as (d k is the key vector dimension); use the Softmax function to normalize according to the knowledge dimension (column) to obtain the attention weight matrix of the head And the weights of all heads are averaged; wherein the final text representation sequence Hx is expressed as H X =[h1,…,h n ], the final knowledge entity represents the sequence expression as S3.2: Execute the knowledge-to-text attention calculation instruction to obtain the knowledge-to-text attention weight matrix B. The text attention weight matrix B is expressed as B=[β ji ] mXn ,in Represents the attention weight of knowledge entity j to text word i; the knowledge to text attention calculation instruction includes according to the text representation sequence H X The final knowledge entity representation sequence uses a multi-head attention mechanism to calculate the query key in is another set of projection matrices; calculate the attention score Use the Softmax function to normalize the text dimension (column) to obtain the attention weight matrix And combine the weights of all heads.
5. The medical text representation enhancement method for bidirectional alignment of knowledge and text according to claim 1 is characterized in that: The knowledge information weighted aggregation instruction includes: S4.1: Execute the knowledge information weighted aggregation instruction to obtain the aggregated knowledge context sequence, according to the final knowledge entity representation sequence and the text to knowledge attention weight matrix A and the value projection matrix W v The value representation of the computational knowledge V=H E W v ; Further, for each text position i, according to the attention weight a ij Perform weighted summation on the knowledge value representation to obtain the aggregated knowledge context vector where v j is the jth row of V; where the aggregated knowledge context sequence expression is S4.2: Execute the text representation preliminary enhancement instruction to obtain the preliminary knowledge enhanced text representation sequence, and integrate the aggregated knowledge information into the text representation according to the final text representation sequence Hx, the aggregated knowledge context sequence, and the fusion weight γ1; for each position i, calculate the preliminary enhanced text representation The aggregated knowledge context sequence expression is: S4.3: Optionally, execute text information weighted aggregation and knowledge representation enhancement instructions to obtain a preliminary text enhanced knowledge representation sequence S4.4: Execute interactive fusion network instructions to obtain the deep fusion representation H fusion ; including a sequence of text representations enhanced according to said preliminary knowledge Preliminary Text Enhanced Knowledge Representation Sequence or the original H E or aggregated The two representation sequences are combined and executed; the combined representation is further input into one or more feed-forward network (FFN) layers and layer normalization (LayerNorm) layers for nonlinear transformation and stabilization training; the expression is H fusion =LayerNorm(FFN(H concat )); S4.5: Execute the self-attention enhancement instruction to obtain the final knowledge-enhanced text representation sequence, where the knowledge-enhanced text representation sequence is expressed as The final self-attention enhancement instruction includes the following steps: fusion Input into a multi-head self-attention layer, further modeling and fusion represent the dependencies between internal elements, capturing high-order interaction information; its expression is H enhanced =extMultiHeadAttn(Q=H fusion , K=H fusion , V=H fusion ).
6. The medical text representation enhancement method for bidirectional alignment of knowledge and text according to claim 1 is characterized in that: The text sequence X is expressed as X=[x1, x2, ..., x n ], where x i Represents the i-th word in the text, and the medical knowledge graph subgraph Gx is expressed as G X =(E X , R X ), where E X =[e1, e2, ..., e m ] is a set of related entities, R X It is the set of relationships between these entities.
7. The medical text representation enhancement method for bidirectional alignment of knowledge and text according to claim 1, 2 or 3, characterized in that: The entity embedding lookup function is Embed(e).
8. The medical text representation enhancement method for bidirectional alignment of knowledge and text according to claim 2 or 3, characterized in that: The initial context hidden state sequence expression is: in is the corresponding word x i The initial vector representation, d model is the hidden layer dimension of the model.
9. The medical text representation enhancement method for bidirectional alignment of knowledge and text according to claim 3 is characterized in that: The entity initial embedding sequence expression is:
10. The medical text representation enhancement method for bidirectional alignment of knowledge and text according to claim 5, characterized in that: The value projection matrix W v is the value projection matrix in multi-head attention.
Citation Information
Cited By
Medical text decoding method based on dynamic knowledge perception
CN120706411A