A method and system for triple extraction for knowledge graph construction

By decoding entity boundaries and relationship types through multi-dimensional feature representation and multi-head cross-attention mechanism, and combining graph structure consistency verification, the problem of insufficient modeling in triple extraction in existing technologies is solved, and high-precision knowledge graph construction is achieved.

CN122133782APending Publication Date: 2026-06-02CHONGQING XIAOYI ZHILIAN INTELLIGENT TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
CHONGQING XIAOYI ZHILIAN INTELLIGENT TECH CO LTD
Filing Date
2026-03-03
Publication Date
2026-06-02

AI Technical Summary

Technical Problem

Existing technologies have insufficient modeling capabilities in scenarios such as entity overlap and relationship intertwining when extracting triples from unstructured text. This results in high redundancy and low confidence in the extraction results, making it difficult to meet the needs of high-precision knowledge graph construction.

Method used

We employ multi-dimensional feature representation learning to generate deep semantic embedding vectors, use a multi-head cross-attention mechanism to perceive the interaction between entities and relationships, and utilize a dual-pointer network to synchronously decode entity boundaries and relationship types. Combined with graph structure consistency verification and confidence calibration, we generate the final structured triple knowledge.

Benefits of technology

It improves the accuracy and reliability of triple extraction, provides an effective technical means for the automated construction of high-quality knowledge graphs, and enhances the accuracy and consistency of triple extraction in complex texts.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122133782A_ABST
    Figure CN122133782A_ABST
Patent Text Reader

Abstract

This invention discloses a method and system for extracting triples for knowledge graph construction. The method includes: learning multi-dimensional feature representations from input natural language text to generate deep semantic embedding vectors that integrate vocabulary, syntax, and discourse structure; dynamically generating relation-aware contextual feature representations based on the deep semantic embedding vectors; synchronously decoding entity boundaries and relation types using a dual-pointer network to output a preliminary set of candidate triples; performing graph structure consistency verification and conflict resolution on the candidate triple set, and calibrating confidence based on global knowledge distribution to generate final purified structured triple knowledge. Using this invention, the accuracy and reliability of triple extraction from complex text can be improved, providing an effective technical means for the automated construction of high-quality knowledge graphs.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of knowledge graph technology, and in particular to a method and system for extracting triples for knowledge graph construction. Background Technology

[0002] Knowledge graphs, as an important carrier of structured semantic knowledge, have been widely used in fields such as intelligent question answering and semantic search. The core of their construction is the automatic extraction of entities and their relationships from unstructured text, forming a triple structure of (head entity, relationship, tail entity). Current mainstream triple extraction methods are mainly divided into pipelined and joint extraction methods. Pipeline methods treat entity recognition and relationship classification as two independent steps, which easily leads to error accumulation and ignores the inherent connection between the two tasks. While joint extraction methods can alleviate this problem, they still generally suffer from insufficient modeling capabilities when dealing with scenarios such as entity overlap and relationship intertwining in complex sentences. Most existing methods rely on local word sequence information and lack effective modeling of textual discourse-level semantics and global consistency between triples, resulting in high redundancy and low confidence in the extraction results, making it difficult to directly meet the needs of high-precision knowledge graph construction. Therefore, there is an urgent need for a triple extraction method that can deeply integrate contextual semantics, achieve accurate joint decoding, and ensure global consistency. Summary of the Invention

[0003] The purpose of this invention is to provide a method and system for extracting triples for knowledge graph construction, so as to overcome the shortcomings of the prior art, improve the accuracy and reliability of triple extraction from complex text, and provide an effective technical means for the automated construction of high-quality knowledge graphs.

[0004] One embodiment of this application provides a triple extraction method for knowledge graph construction, the method comprising: Multi-dimensional feature representation learning is performed on the input natural language text to generate deep semantic embedding vectors that integrate vocabulary, syntax and discourse structure; Based on the deep semantic embedding vector, a multi-head cross-attention mechanism is used to perceive the interaction between entities and relationships, and to dynamically generate contextual feature representations for relationship perception. Using the relation-aware contextual feature representation, entity boundaries and relation types are synchronously decoded through a dual-pointer network to output a preliminary set of candidate triples; The candidate triple set is subjected to graph structure consistency verification and conflict resolution, and confidence calibration is performed based on the global knowledge distribution to generate the final purified structured triple knowledge.

[0005] Another embodiment of this application provides a triple extraction system for knowledge graph construction, the system comprising: The learning module is used to learn multi-dimensional feature representations of the input natural language text and generate deep semantic embedding vectors that integrate vocabulary, syntax and discourse structure. The perception module is used to perceive the interaction between entities and relationships based on the deep semantic embedding vector using a multi-head cross-attention mechanism, and dynamically generate contextual feature representations for relationship perception. The decoding module is used to utilize the relation-aware context feature representation to synchronously decode entity boundaries and relation types through a dual-pointer network, and output a preliminary set of candidate triples. The resolution module is used to perform graph structure consistency verification and conflict resolution on the candidate triple set, and to perform confidence calibration based on the global knowledge distribution to generate the final purified structured triple knowledge.

[0006] Another embodiment of this application provides a storage medium storing a computer program, wherein the computer program is configured to execute the method described in any of the preceding claims when running.

[0007] Another embodiment of this application provides an electronic device including a memory and a processor, wherein the memory stores a computer program and the processor is configured to run the computer program to perform the method described in any of the preceding claims.

[0008] Compared with existing technologies, the triple extraction method for knowledge graph construction provided by this invention can improve the accuracy and reliability of triple extraction from complex texts, and provide an effective technical means for the automated construction of high-quality knowledge graphs. Attached Figure Description

[0009] Figure 1 A hardware structure block diagram of a computer terminal for a triple extraction method for knowledge graph construction provided in an embodiment of the present invention; Figure 2 This is a flowchart illustrating a triple extraction method for knowledge graph construction provided in an embodiment of the present invention. Figure 3 This is a schematic diagram of a triplet extraction system for knowledge graph construction provided in an embodiment of the present invention. Detailed Implementation

[0010] The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and should not be construed as limiting the present invention.

[0011] This invention first provides a method for extracting triples for knowledge graph construction. This method can be applied to electronic devices, such as computer terminals, specifically ordinary computers.

[0012] The following detailed explanation uses a computer terminal as an example. Figure 1 This is a hardware structure block diagram of a computer terminal for a triple extraction method for knowledge graph construction, provided as an embodiment of the present invention. (See diagram below.) Figure 1 As shown, the computer device includes a processor, memory, and network interface connected via a system bus, wherein the memory may include non-volatile storage media and internal memory.

[0013] See Figure 2 The present invention provides a method for extracting triples for knowledge graph construction, which may include the following steps: S201 performs multi-dimensional feature representation learning on the input natural language text to generate a deep semantic embedding vector that integrates vocabulary, syntax and discourse structure; Specifically, the input natural language text can be segmented and labeled with parts of speech to generate a word sequence and a corresponding part-of-speech tag sequence as basic lexical features; The core of this step is to decompose continuous natural language text into discrete lexical units and label them with grammatical attributes, providing basic lexical support for subsequent semantic embedding. The specific implementation method is as follows: The input natural language text needs to be preprocessed to remove irrelevant characters (such as special symbols, redundant spaces, and meaningless interjections) while retaining the core semantic content. The length of the preprocessed text is controlled within 512 characters (to meet the input requirements of the subsequent pre-trained model). The word segmentation process adopts a strategy of bidirectional matching combined with ambiguity resolution. The text is scanned in both forward and backward directions simultaneously to generate candidate word segmentation results. For ambiguous segments (such as phrases composed of polysemous words), the optimal word segmentation method is determined by combining the semantic similarity of the context. The similarity calculation uses the cosine similarity formula, with a threshold set at 0.7. If the value is higher than the threshold, the word segmentation boundary is determined.

[0014] Part-of-speech tagging uses a general part-of-speech tagging set, covering 28 parts of speech, including nouns (n), verbs (v), adjectives (a), adverbs (d), and prepositions (p). The tagging process is based on statistical learning methods, combining the lexical context to correct the tagging results and avoid errors caused by isolated tagging. For example, given the input text "Artificial intelligence technology has developed rapidly in recent years, and its application in fields such as medicine and education is becoming increasingly widespread," after preprocessing and removing commas, the word segmentation results generate the following word sequence: [artificial intelligence, technology, in recent years, rapidly, development, it, in, medicine, education, etc., fields, of, application, increasingly, widespread].

[0015] During the generation of the corresponding part-of-speech tag sequence, "artificial intelligence" was tagged as a compound noun (n), "technology" as a noun (n), "in recent years" as an adverb of time (d), "rapidly" as an adjective (a), "development" as a verb (v), "it" as a personal pronoun (r), "at" as a preposition (p), "medical" as a noun (n), "education" as a noun (n), "etc." as an auxiliary word (u), "field" as a noun (n), "of" as an auxiliary word (u), "application" as a noun (n), "more and more" as an adverb (d), and "widespread" as an adjective (a).

[0016] The generated word sequences correspond one-to-one with the part-of-speech tag sequences, with each word bound to a unique part-of-speech tag, forming a basic vocabulary feature matrix. The matrix has dimensions [L,2], where L is the number of words after segmentation (L=15 in the example). The first column stores the word text, and the second column stores the corresponding part-of-speech tag. The basic vocabulary features need to undergo validity verification, removing meaningless words with a length ≤1 (such as isolated particles and modal particles; these should be judged in conjunction with the context and should not be blindly removed) to ensure the accuracy of subsequent feature learning and provide reliable input for context embedding representation and syntactic feature extraction.

[0017] Based on basic vocabulary features, a pre-trained language model is used to obtain the context-related embedding representation of each word. At the same time, a dependency parser is used to extract sentence-level dependency graphs and generate syntactic structure feature vectors. The core of this step is to extract lexical contextual semantic features and sentence syntactic structure features in parallel, constructing a two-dimensional feature system. The specific implementation method is as follows: The pre-trained language model uses a general-purpose model based on the Transformer architecture. The output context-related embedding representation is set to 768 dimensions, which balances semantic expressiveness and computational efficiency while avoiding redundancy caused by excessive dimensionality. The model takes a sequence of words from the basic vocabulary features as input and uses a multi-head attention mechanism to capture the semantic association between each word and all words in the context, generating a context-related embedding vector. Each dimension in the vector corresponds to a different semantic attribute (such as semantic role, sentiment tendency, and semantic relevance). In the example, the context embedding vector for "artificial intelligence" is a 768-dimensional real-number vector with values ​​ranging from -1 to 1. Dimensions related to "technology" and "application" have absolute values ​​close to 0.8, indicating strong semantic association; dimensions related to "medical" and "education" have absolute values ​​between 0.5 and 0.6, indicating domain relevance.

[0018] Simultaneously, a sentence-level dependency graph is extracted using a dependency parser. The parser first performs syntactic parsing on the sentence, identifying 12 core dependency relationships, including subject-verb, verb-object, attributive-head, adverbial-head, and coordinate relationships, and constructs an undirected dependency graph with words as nodes and dependency relationships as edges. For example, for the preprocessed sentence "Artificial intelligence technology has developed rapidly in recent years," the parsing yields the following dependency relationships: "development" (the core verb) and "technology" are subject-verb, "technology" and "artificial intelligence" are attributive-head, "development" and "rapidly" are adverbial-head, and "development" and "in recent years" are adverbial-head. Each dependency relationship edge is labeled with the relationship type and association strength (calculated based on syntactic distance, with values ​​ranging from 0 to 1, where closer the distance, the higher the strength).

[0019] The dependency graph is transformed into a syntactic structure feature vector. A node embedding and edge feature fusion approach is used, with each word's syntactic vector having a dimension of 256. 128 dimensions represent the node's own syntactic attributes (based on part-of-speech tag mapping), and 128 dimensions represent the dependency relationship features of adjacent nodes (obtained through weighted summation, with weights representing dependency relationship strength). For example, in the syntactic structure feature vector of "technology," the dimension corresponding to the nominative-head relation is 0.9 (associated with "artificial intelligence"), the dimension corresponding to the subject-verb relation is 0.85 (associated with "development"), and the dimensions of other irrelevant dependency relations are close to 0, ensuring that the syntactic features accurately reflect the grammatical roles and associations of words in the sentence.

[0020] Context-related embeddings and syntactic structure feature vectors are fused in a multimodal manner, and a gating attention mechanism is used to dynamically adjust the weights of the two features to generate an intermediate feature representation that fuses lexical and syntactic elements. The core of this step is to solve the problem of multimodal feature heterogeneity. It strengthens key features and filters redundant information through dynamic weight allocation to generate intermediate features with a unified dimension. The specific implementation method is as follows: Since the dimensions of the context-related embedding representation (768-dimensional) and the syntactic structure feature vector (256-dimensional) are inconsistent, the syntactic structure feature vector is first mapped to 768-dimensional through a linear transformation to ensure dimensional compatibility in the fusion process. The linear transformation formula is X_syn=W_syn×X_s+b_syn, where X_s is the original syntactic vector, W_syn is the 768×256 transformation matrix, and b_syn is the 768-dimensional bias vector. After the transformation, the syntactic vector retains the original syntactic semantic information and is consistent with the dimension of the context embedding.

[0021] A gated attention mechanism is employed to achieve dynamic weight adjustment. This mechanism comprises two core modules: an update gate and a reset gate. The sigmoid activation function outputs weight values ​​in the 0-1 range to adaptively adjust the contribution of the two features. The update gate controls the proportion of retained original feature information, while the reset gate controls the proportion of introduced new feature information. The core calculation formulas are: z = σ(W_z × [X_ctx, X_syn] + b_z), r = σ(W_r × [X_ctx, X_syn] + b_r), where z is the output of the update gate, r is the output of the reset gate, W_z and W_r are 768 × 1536 weight matrices, [X_ctx, X_syn] is the concatenated vector (1536-dimensional) of the context embedding and the transformed syntactic vector, σ is the sigmoid activation function, and b_z and b_r are 768-dimensional bias vectors.

[0022] Attention weights are calculated based on the gated output, and the fused features are updated with weights to obtain the intermediate feature representation X_mid=z×X_ctx+(1-z)×tanh(W_h×(r×X_syn)+b_h), where tanh is the activation function, W_h is a 768×768 weight matrix, and b_h is a 768-dimensional bias vector. In the example, for the verb "develop", the semantic association features in the context embedding are more important, so the gate output z=0.7 is updated, and 70% of the weight is allocated to the context embedding and 30% to the syntactic features; for the noun "artificial intelligence", the attributive-head relation features in the syntax are more critical, so the gate output z=0.3 is updated, and 30% of the weight is allocated to the context embedding and 70% to the syntactic features, achieving dynamic adaptation of feature weights.

[0023] The intermediate feature representation generated after fusion is still 768-dimensional, which not only preserves the contextual semantic association of words, but also incorporates syntactic structure information. Through validity verification (calculating the semantic similarity of features before and after fusion, with a threshold ≥0.85 for verification to pass), it is ensured that the fused features do not lose core information, laying the foundation for the subsequent integration of discourse structure features.

[0024] Text segmentation and referential resolution techniques are used to extract discourse structure information, and the discourse structure information is hierarchically aggregated with intermediate feature representations to finally generate a deep semantic embedding vector that integrates vocabulary, syntax and discourse structure.

[0025] The core of this step is to overcome the limitations of sentence-level features, extract semantic connections at the discourse level, achieve hierarchical aggregation of three layers of features, and generate comprehensive deep semantic embedding vectors. The specific implementation method is as follows: The text segmentation employs a semantic block partitioning strategy, rather than simply cutting by paragraph. By calculating the semantic similarity between sentences (based on cosine similarity of intermediate feature representations), sentences with a similarity ≥ 0.7 are grouped into the same semantic block. Each semantic block corresponds to a discourse semantic unit. After segmentation, a sequence of semantic blocks is generated, with each block containing 2-5 sentences (avoiding fragmentation of discourse information caused by single-sentence blocks or excessively long blocks). In the example, the input text contains three sentences: "Artificial intelligence technology has developed rapidly in recent years. Its application in fields such as medicine and education is becoming increasingly widespread. Related research results are constantly emerging." The similarity between sentence 1 and sentence 2 is 0.78, and the similarity between sentence 2 and sentence 3 is 0.72, both exceeding the threshold, and they are grouped into one semantic block. If a sentence has a similarity < 0.7 with all other sentences, it is treated as a separate semantic block and labeled as an isolated semantic unit.

[0026] The dereference resolution technique is used to extract referential association information in a text. It employs a context-based semantic matching method to identify pronouns (such as "it," "its," and "that") and their corresponding antecedents (such as previously mentioned nouns or noun phrases) in the text, constructing a referential chain. Specifically, the process involves: first, identifying all pronouns and candidate antecedents (nominal components within the three semantic blocks mentioned earlier); calculating the similarity of intermediate features between the pronouns and candidate antecedents; selecting the candidate with the highest similarity (≥0.8) as the antecedent, forming a referential pair; and concatenating multiple referential pairs to form a referential chain. In the example, the pronoun "it" has a similarity of 0.86 with the candidate antecedent "artificial intelligence technology," thus determining the referential relationship and constructing the referential chain "it → artificial intelligence technology," while simultaneously labeling the referential distance (one sentence interval) and the association strength (0.86).

[0027] The discourse structure information is represented by fusing semantic block relationships and referential chains to generate a discourse structure feature vector with a dimension of 768. Of these, 384 dimensions represent the relationships between semantic blocks (calculated based on the similarity of the average intermediate features of the semantic blocks), and 384 dimensions represent referential chain information (the referential chains are transformed into vector embeddings to reflect referential associations). For example, in the discourse structure vector of the semantic block mentioned above, the sentence association dimension within the semantic block takes a value of approximately 0.8, and the corresponding referential chain dimension takes a value of 0.86, reflecting the semantic coherence at the discourse level.

[0028] The hierarchical aggregation employs a sentence-to-text two-level aggregation strategy. First, average pooling is performed on the intermediate features of sentences within each semantic block to obtain semantic block-level features. Then, these semantic block-level features are concatenated with the text structure feature vector, and weighted fusion is achieved through an attention mechanism to generate a text-enhanced feature vector. Finally, residual connections are performed with the original sentence-level intermediate features to preserve sentence-level details, ultimately generating a 768-dimensional deep semantic embedding vector. This vector integrates discrete semantics at the lexical level, syntactic connections at the syntactic level, and semantic coherence at the text level. Each dimension carries multi-dimensional feature information. In the example, the deep semantic embedding vector for "artificial intelligence technology" reflects its own semantics at the lexical level, the attributive-head relationship at the syntactic level, and the referential association with "it" at the text level, providing comprehensive semantic support for subsequent entity and relation interaction perception.

[0029] S202, Based on the deep semantic embedding vector, a multi-head cross-attention mechanism is used to perceive the interaction between entities and relationships, and to dynamically generate contextual feature representations for relationship perception; Specifically, potential entity candidate fragments can be extracted from deep semantic embedding vectors, and a set of entity candidate fragments can be generated by scanning with a sliding window. The core of this step is to capture potential entity fragments based on the semantic relevance of deep semantic embedding vectors using a sliding window strategy, laying the foundation for subsequent entity and relationship interactions. The specific implementation method is as follows: The deep semantic embedding vector integrates lexical, syntactic, and discourse structure features, with a dimension of 768. First, the semantic saliency of the vector sequence is evaluated to select the positions of words rich in semantic information as the key areas for sliding window scanning. Semantic saliency is measured by vector magnitude, with a magnitude threshold set at 0.6 (range [-1,1]). Words with magnitudes below the threshold are considered semantically weak areas, which can reduce the priority of window dwell during scanning and reduce the generation of invalid candidates.

[0030] The sliding window employs a variable-length window strategy, with the window size set to 2-5 words in length to adapt to entities of different lengths (such as the two-word entity "medical", the three-word entity "artificial intelligence", and the multi-word entity "artificial intelligence technology"). The window step size is fixed at 1 word to ensure that all semantic regions are scanned without omission. During the scanning process, for each step the window moves, the average semantic similarity of the word embedding vectors within the window is calculated. Window segments with a similarity higher than 0.7 are considered semantically coherent and included in the candidate range; those with a similarity lower than 0.7 are considered semantically discrete and temporarily stored as low-priority candidates for secondary screening based on part-of-speech features.

[0031] Optimize the candidate segments by combining with the词性 tag sequence generated previously. Preferentially retain the segments containing entity - inclined词性 such as nouns (n), compound nouns (n), proper nouns (nr), etc., and filter out the segments composed entirely of adverbs (d), prepositions (p), and auxiliary words (u). In the example, for the sequence of deep semantic embedding vectors corresponding to the input text, after scanning with a sliding window, the initial candidate segments are generated: [Artificial Intelligence, Artificial Intelligence Technology, Technology, Medical, Education, Medical and Education, Field, Applications in the Field, Applications]. After词性 screening, "Applications in the Field" (including the auxiliary word "的", with discrete semantics and a similarity of 0.62) is removed, and the remaining segments are retained as potential entity candidates.

[0032] Perform deduplication and redundancy merging on the candidate segments. If two segments have an inclusion relationship (such as "Artificial Intelligence" and "Artificial Intelligence Technology"), both are retained as independent candidates (to avoid missing entities of different granularities); if two segments are exactly the same, only one is retained, and the occurrence position is marked. For the final set of entity candidate segments, each segment is bound to the corresponding deep semantic embedding vector (obtained by average pooling of the vocabulary vectors within the window, with a dimension of 768), start - end position indices, and semantic similarity scores. Example set of segments: {Segment 1: Artificial Intelligence, Vector: 768 - dimensional average vector, Position: 0 - 1, Similarity: 0.82; Segment 2: Artificial Intelligence Technology, Vector: 768 - dimensional average vector, Position: 0 - 2, Similarity: 0.88; Segment 3: Medical, Vector: 768 - dimensional average vector, Position: 7 - 7, Similarity: 0.75}.

[0033] Construct a relationship query vector, associate the predefined relationship categories with the entity candidate segments, and generate an initial relationship - entity association matrix; The core of this step is to establish an initial semantic association between the predefined relationships and the entity candidate segments. Through the interaction of relationship embeddings and entity embeddings, it provides a priori basis for attention calculation. The specific implementation method is as follows: The predefined relationship categories are set based on common relationship types in knowledge graphs and text domain characteristics, covering 15 core relationships such as "Applied to", "Belongs to", "Related to", "Developed in", etc. Each relationship corresponds to a unique relationship embedding vector, and the embedding dimension is set to 768, which is the same as the dimension of the entity candidate segment vectors to ensure compatibility of the association calculation. The relationship embedding vectors are generated by a pre - trained relationship embedding model. The model is trained based on large - scale knowledge graph triples, making the relationship embedding vectors with similar semantics closer. In the example, the cosine similarity of the relationship embeddings between "Applied to" and "Applicable to" is 0.83, indicating a strong semantic association.

[0034] When constructing relation query vectors, the embedding vectors of each predefined relation are first normalized using the formula R_norm=R / ||R||, where R is the original relation embedding vector and ||R|| is the L2 norm of the vector. This ensures that the vector magnitude is uniformly 1, avoiding the impact of scale differences between different relation embeddings on association calculation. Then, the normalized relation embedding vectors are used as query templates to perform semantic association calculations with entity candidate fragment vectors. The association strength is measured using cosine similarity, with the formula Sim(R_norm,E_cand)=(R_norm・E_cand) / (||R_norm||×||E_cand||), where E_cand is the entity candidate fragment vector.

[0035] An initial relation-entity association matrix is ​​generated, with dimensions [M×N], where M is the number of predefined relation categories (15 categories) and N is the number of candidate entity fragments (8 in this example). Each element in the matrix corresponds to the cosine similarity value between a certain relation and a certain candidate entity fragment, ranging from [-1, 1]. The closer the value is to 1, the stronger the semantic association between the two. In the example, the relation "applies to" has a similarity of 0.78 with the candidate entity fragment "artificial intelligence technology," 0.81 with "medical," and 0.65 with "technology"; the relation "belongs to" has a similarity of 0.52 with "medical" and 0.72 with "domain," forming the initial association matrix. The matrix element values ​​serve as prior weights for subsequent attention calculations, guiding the model to focus on highly associated entity-relation pairs.

[0036] The initial relation-entity association matrix is ​​threshold-filtered, with a similarity threshold of 0.5. Elements with values ​​below the threshold are set to 0, which are considered to have no semantic association, thus reducing unnecessary computation. At the same time, highly associated elements in the matrix (similarity ≥ 0.7) are labeled as the focus of subsequent multi-head cross-attention.

[0037] A multi-head cross-attention mechanism is adopted, using the initial relation-entity association matrix as the attention prior, with entity candidate fragments as keys and relation query vectors as values, to calculate the interaction weights between entities and relations and generate a relation-aware attention distribution; The core of this step is to enhance the perception of interaction between entities and relationships through a multi-head cross-attention mechanism. Combined with initial association priors, the interaction weights between the two are accurately calculated to form a differentiated attention distribution. The specific implementation method is as follows: The multi-head cross-attention mechanism breaks down attention computation into eight independent attention heads, each focusing on a different semantic dimension (such as semantic roles, domain attributes, and association strength). This avoids the semantic limitations of a single attention head and improves the comprehensiveness of interaction perception. Each attention head has a 768-dimensional input dimension, and through linear transformation, the key (entity candidate fragment vector), value (relationship query vector), and query (vector derived from the initial association matrix) are mapped to 96 dimensions (768 dimensions ÷ 8 heads), reducing the computational complexity of a single head.

[0038] Using entity candidate fragment vectors as keys (K), normalized relation query vectors as values ​​(V), and the initial relation-entity association matrix as attention priors (B), the core formula is Attention(Q,K,V,B)=Softmax((QK^T / √d_k)+B)×V, where Q is the query vector (generated by linear transformation of entity candidate fragment vectors), d_k is the dimension of the key vector (96 dimensions), √d_k is the scaling factor (approximately 9.8), used to alleviate the gradient vanishing problem caused by excessively large vector inner products. The Softmax function normalizes the weights to the 0-1 interval, and B is the prior weight matrix corresponding to the initial association matrix (with the same dimension as the attention weight matrix).

[0039] Each attention head independently calculates the interaction weight between entities and relations. In the example, one attention head focuses on the semantic dimension of "domain application." The initial prior association value between the relation "applies to" and the entity "artificial intelligence technology" is 0.78, which is amplified to 0.85 after attention calculation. The initial prior value between the same entity and the relation "belongs to" is 0.58, and the calculated interaction weight is 0.62, reflecting differentiated weight allocation. Another attention head focuses on the semantic dimension of "category affiliation." The interaction weight between the relation "belongs to" and the entity "medical" increases from the initial 0.52 to 0.71, while the weight with "artificial intelligence technology" decreases to 0.55, achieving targeted interactions across different semantic dimensions.

[0040] The calculation results from the eight attention heads are concatenated to obtain a 1536-dimensional fusion weight vector (8 heads × 96 dimensions). This vector is then mapped back to 768 dimensions through a linear transformation, generating a unified-dimensional relation-aware attention distribution. In this distribution, each entity candidate fragment corresponds to an interaction weight for different relations, forming an entity-relationship weight matrix. The higher the value of a matrix element, the stronger the semantic association between the corresponding entity and the relation, providing a precise basis for subsequent feature weighting fusion. Simultaneously, the effectiveness of the attention distribution is verified by calculating the entropy value of the weight matrix. An entropy value between 2 and 3 (range 0-4) is considered a reasonable distribution, ensuring that the weight allocation is discriminative and avoids semantic ambiguity caused by uniform distribution.

[0041] Based on relation-aware attention distribution, deep semantic embedding vectors are weighted and fused to generate dynamic relation-aware contextual feature representations.

[0042] The core of this step is to use relation-aware attention weights to specifically weight the original deep semantic embedding vectors, enhance the semantics of entity-relationship interactions, and generate contextual features that dynamically adapt to different relationships. The specific implementation method is as follows: The relation-aware attention distribution is an entity-relation weight matrix. First, the matrix weights are mapped to the deep semantic embedding vector of each word. A positional alignment strategy is used to assign the interaction weights of entity candidate segments to each word position they contain. The word weights of non-entity segments are calculated by interpolating the weights of adjacent entities, ensuring that the weights cover all words in the text without any weight gaps. In the example, the interaction weight of the entity candidate segment "artificial intelligence technology" corresponding to the relation "applied to" is 0.85. This weight is evenly distributed across the embedding vectors of the words "artificial intelligence" and "technology." The adjacent word "in recent years" receives a weight of 0.32 through interpolation, and "quickly" receives a weight of 0.28, achieving a smooth transition in weights.

[0043] A weighted summation method is used to fuse the deep semantic embedding vectors. The fusion formula is X_rel=Σ(W_er×X_ctx_i), where X_rel is the relation-aware context feature vector, W_er is the relation-aware attention weight (corresponding to the interaction weight of entity-relation pairs), and X_ctx_i is the deep semantic embedding vector of the i-th word. The summation range covers all words in the text. During the fusion process, different relations correspond to different weight matrices, generating different relation-aware feature vectors to achieve dynamic feature adaptation. In the example, the embedding vectors of words such as "applied to," "artificial intelligence technology," "medical," and "education" are given high weights (0.7-0.85) to strengthen the semantics of application scenarios; the weights of words such as "belong to" and "domain" are increased (0.65-0.75) to highlight the semantics of category affiliation.

[0044] A residual connection mechanism is introduced, which adds the residuals of the original deep semantic embedding vector and the weighted fused feature vector, using the formula X_final = X_rel + X_ctx, where X_final is the final relation-aware context feature vector and X_ctx is the original deep semantic embedding vector. This mechanism preserves the original semantic information, avoids the loss of core features caused by weighted fusion, and strengthens the entity-relation interaction semantics, thereby improving the expressive power of the features. In the example, after adding the residuals of the original embedding vector and the weighted vector for "artificial intelligence technology," the value of the application scenario-related dimension increases from 0.68 to 0.82, preserving lexical, syntactic, and discourse features while strengthening the interaction semantics with the "applied to" relationship.

[0045] The generated relation-aware context feature vectors remain 768-dimensional, with each vector corresponding to a predefined relation class, forming a relation-feature mapping set. The feature vectors corresponding to different relations in the set show significant differences, with entities and relations with strong semantic associations exhibiting higher similarity in their corresponding feature vectors. The feature vectors are normalized to ensure a uniform vector magnitude of 1, preventing scale differences between features of different relations from affecting subsequent decoding. Simultaneously, feature effectiveness is evaluated by calculating the cosine similarity of feature vectors corresponding to different relations. A similarity below 0.5 is considered good feature discriminative power, ensuring that dynamically generated features can accurately adapt to subsequent entity boundary decoding and relation type recognition, providing high-quality semantic feature support for triple extraction.

[0046] S203, using the relation-aware contextual feature representation, the entity boundary and relation type are synchronously decoded through a dual-pointer network to output a preliminary set of candidate triples; Specifically, based on relation-aware contextual feature representations, a start pointer network can be used to predict the probability distribution of the starting position of an entity boundary, thereby generating a candidate set of entity starting positions. The core of this step is to capture the semantic features of the entity's starting boundary through a starting pointer network, quantify the probability of each position as the entity's starting point, and filter out high-confidence starting positions to lay the foundation for locating the entity's complete boundary. The specific implementation method is as follows: The contextual features of relation awareness are represented as a 768-dimensional vector sequence, with each vector corresponding to a word position in the text. This feature sequence is first input into a start pointer network, which consists of a linear transformation layer and an activation function layer. The linear transformation layer maps the 768-dimensional feature vector to a 1-dimensional probability value. The transformation formula is P_start_i = W_start × X_rel_i + b_start, where X_rel_i is the relation awareness feature vector at the i-th position, W_start is a 768×1 weight matrix, and b_start is a 1-dimensional bias term. The output is processed by the sigmoid activation function to obtain the probability value P_start_i of each position as the start of an entity. The value ranges from 0 to 1, and the closer the value is to 1, the higher the confidence that the position is the start of an entity.

[0047] To adapt to multi-relation scenarios, the pointer network calculates the probability distribution separately for each type of predefined relation. For example, for the "applies to" relation, it emphasizes the semantic features related to the application scenario, significantly improving the probability of the corresponding entity's starting position. For the "belongs to" relation, it focuses on the semantics related to category affiliation, optimizing the probability prediction accuracy of the entity's starting position. Simultaneously, a positional attention mechanism is introduced, assigning attention weights (weight coefficient 1.2) to the beginning and end of the text, as well as positions with noun / proper noun parts of speech, guiding the network to focus on entity-preferred positions and reducing misjudgments of non-entity positions.

[0048] Taking the example text "Artificial intelligence technology has developed rapidly in recent years, and its application in fields such as medicine and education is becoming increasingly widespread" as an example, after the relation-aware feature sequence is processed by the starting pointer network, the probability distribution of each position is as follows: the probability of the first character position of "artificial intelligence" (index 0) is 0.89, the probability of the position of "technology" (index 1) is 0.32, the probability of the position of "medical" (index 7) is 0.85, the probability of the position of "education" (index 8) is 0.83, the probability of the position of "domain" (index 10) is 0.78, the probability of the position of "application" (index 12) is 0.72, and the probability of the remaining positions is all below 0.5. Setting the starting position probability threshold to 0.7, positions with probabilities higher than the threshold are selected as candidate starting positions, generating a candidate set of entity starting positions. The format of the set elements is (position index, corresponding probability value, association type). An example candidate set is: {(0,0.89,applied to),(0,0.87,belongs to),(7,0.85,applied to),(8,0.83,applied to),(10,0.78,belongs to),(12,0.72,applied to)}.

[0049] The candidate set is deduplicated and prioritized. If the probability of multiple relationships corresponding to the same position meets the standard, the relationship type with the highest probability is retained. The candidate positions are arranged in descending order of probability value, and the top 5 high-confidence starting positions are marked as key candidates. At the same time, duplicate candidates that are too close (interval < 1 position) are removed (if adjacent positions meet the standard, the one with the higher probability is retained) to ensure the validity and uniqueness of the starting position candidate set, and to provide accurate input for subsequent ending position pairing.

[0050] Based on relation-aware contextual feature representation, an end pointer network is used to predict the probability distribution of the end position of entity boundaries and generate a candidate set of entity end positions. The core of this step is to work with the start pointer network to predict the end boundary position of the entity. Through probability quantization and logical constraints, reasonable end positions are selected to form a candidate basis for the complete entity boundary. The specific implementation method is as follows: The end-pointer network structure is consistent with the start-pointer network, also employing a linear transformation + activation function architecture. However, the input features incorporate semantic association information from the start position, enabling collaborative prediction of start and end positions and avoiding boundary misalignment caused by isolated predictions. The network calculates the probability of each position being the end of an entity using the formula P_end_i = W_end × [X_rel_i, X_start_att] + b_end, where X_start_att is the attention feature vector of the candidate start position set (obtained by weighted summation of start position features), and W_end is a (768+768)×1 weight matrix, fusing current position features with start position association features to improve the accuracy of end position prediction.

[0051] After probability calculation, the output P_end_i (value 0-1) is activated by the sigmoid function. Logical constraints are added: the ending position index must be greater than or equal to the corresponding starting position index, and the entity length (ending index - starting index + 1) is controlled within the range of 2-8 words (adapting to common entity lengths and avoiding fragmentation of excessively short entities or semantic redundancy of excessively long entities). For each type of relation, a separate ending position probability distribution is generated, corresponding one-to-one with the starting position probability distribution. For example, under the relation "applied to," the ending position probabilities corresponding to starting position 0 (artificial intelligence) are: index 1 (technology) probability 0.82, index 2 (recent years) probability 0.21, therefore index 1 is preferentially matched as the ending position; the ending position probabilities corresponding to starting position 7 (medical) are: index 7 (medical) probability 0.86, index 8 (education) probability 0.35, therefore index 7 is matched as the ending position.

[0052] Using the example text above, the high-probability positions output by the end pointer network are as follows: starting position 0 corresponds to ending position 1 (probability 0.82), starting position 7 corresponds to ending position 7 (probability 0.86), starting position 8 corresponds to ending position 8 (probability 0.84), starting position 10 corresponds to ending position 10 (probability 0.80), and starting position 12 corresponds to ending position 12 (probability 0.79). Setting the end position probability threshold to 0.75, a candidate set of entity end positions is generated by filtering qualified positions. The format of the set elements is (position index, corresponding probability value, association type, matching starting position index). An example candidate set is: {(1,0.82,applies to, 0),(7,0.86,applies to, 7),(8,0.84,applies to, 8),(10,0.80,belongs to, 10),(12,0.79,applies to, 12)}.

[0053] The candidate set is logically verified, and candidates whose end position is earlier than the start position or whose entity length exceeds the limit are eliminated. At the same time, the probability product of the end position and the corresponding start position is calculated as the entity boundary confidence (e.g., the confidence of the (0,1) combination is 0.89×0.82=0.73). The candidates are sorted in descending order of confidence and the top 5 candidates are retained to ensure the accurate matching between the end position candidate set and the start position candidate set, thus providing support for the generation of complete entity boundaries.

[0054] The candidate set of entity start positions is paired with the candidate set of entity end positions, and combined with the relationship type predicted by the relationship type classifier, preliminary entity-relationship pairs are generated. The core of this step is to construct complete entities through location pairing, and combine this with a relationship classifier to accurately associate relationship types, forming entity-relationship pairs, thereby achieving synchronous binding of entities and relationships. The specific implementation method is as follows: The pairing of entity start and end positions follows strict association rules: only start and end positions of the same relation type are paired, and the end position index is greater than or equal to the start position index. The entity length is within the range of 2-8 words. Priority is given to matching the position combination with the highest confidence (probability product). The pairing process uses a greedy algorithm, first matching the top 1 start position with its corresponding top 1 end position. If a pairing is successful, it is marked as matched, and then subsequent candidates are matched sequentially to avoid duplicate pairings. In the example, under the "applies to" relationship, starting position 0 (probability 0.89) and ending position 1 (probability 0.82) are paired to form the entity "Artificial Intelligence Technology" (index 0-1); starting position 7 (probability 0.85) and ending position 7 (probability 0.86) are paired to form the entity "Medical" (index 7-7); starting position 8 (probability 0.83) and ending position 8 (probability 0.84) are paired to form the entity "Education" (index 8-8); starting position 12 (probability 0.72) and ending position 12 (probability 0.79) are paired to form the entity "Application" (index 12-12); under the "belongs to" relationship, starting position 10 (probability 0.78) and ending position 10 (probability 0.80) are paired to form the entity "Domain" (index 10-10).

[0055] The relation type classifier is used to accurately predict the relation type between paired entities. Based on the Transformer architecture, the classifier takes as input a fused feature vector of the paired entities (the relation-aware feature vectors of the two entities are concatenated, average pooled to obtain a 1536-dimensional vector, and then linearly transformed to 768 dimensions). Contextual features are also incorporated to improve classification accuracy. The classifier's output layer uses a softmax function to map the output to the probability distribution of each relation type, with the formula P_rel=Softmax(W_rel×X_ent+b_rel), where X_ent is the entity fused feature vector, W_rel is a 768×M weight matrix (M is the predefined number of relation categories, 15), and b_rel is an M-dimensional bias term. The relation type with the highest probability is used as the prediction result, and the prediction confidence must be higher than 0.6 (threshold); otherwise, the relation is marked as unknown.

[0056] In the example, after the fusion features of entities "artificial intelligence technology" and "medical" are processed by the classifier, the probability of the "applied to" relationship is 0.88, and the probabilities of the other relationships are all below 0.3, so the predicted relationship is "applied to", generating entity-relationship pairs (artificial intelligence technology, applied to, medical). In the classification results of entities "artificial intelligence technology" and "education", the probability of the "applied to" relationship is 0.85, generating pairs (artificial intelligence technology, applied to, education). In the classification results of entities "application" and "domain", the probability of the "belongs to" relationship is 0.81, generating pairs (application, belong to, domain). In the classification results of entities "medical" and "domain", the probability of the "belongs to" relationship is 0.79, generating pairs (medical, belong to, domain). The generated preliminary entity-relationship pairs are all bound to entity boundary information, relationship type, and predicted confidence, forming an entity-relationship pair set. Each element contains four core pieces of information: head entity, relationship type, tail entity, and confidence.

[0057] Redundancy filtering is performed on the entity-relation pair set. If the head entity, relation type, and tail entity of two pairs are completely identical, only the one with higher confidence is retained. If the head entity and tail entity are reversed but the relation type is symmetrical (such as "related to"), they are merged into one pair and labeled with a bidirectional relation to ensure that the set is free of redundancy.

[0058] Perform integrity checks on the initial entity-relation pairs, filter out candidates with invalid boundaries or conflicting relation types, and output an initial set of candidate triples.

[0059] The core of this step is to eliminate invalid candidates through multi-dimensional verification, ensuring that entity boundaries are legal and relationship types are reasonable, thereby generating a high-quality preliminary set of candidate triples. The specific implementation method is as follows: Integrity verification is divided into three dimensions: boundary validity verification, relation type conflict verification, and entity semantic rationality verification, filtering entity-relation pairs one by one. Boundary validity verification focuses on checking the logical consistency and integrity of entity boundaries: reconfirming that the end position index is greater than or equal to the start position index, and that the entity length is within the range of 2-8 words. It also verifies the parts of speech of the words contained in the entity. If the entity consists only of prepositions, auxiliary words, and adverbs (without noun components), it is directly eliminated. If the entity contains semantically contradictory words (such as "rapid medical treatment," an adjective + noun but semantically incoherent, with a similarity < 0.6), it is also eliminated. In the example, if the generated pair (rapid, applied to, medical treatment) fails the boundary verification because the head entity "rapid" is an adjective with no noun attribute, it is eliminated.

[0060] Relationship type conflict verification is based on predefined rules for matching relationships and entity types. A relationship-entity type matching table is constructed to clarify the entity types that can be associated with each type of relationship (e.g., for the "applies to" relationship, the head entity must be a technology or product term, and the tail entity must be a domain or scenario term; for the "belongs to" relationship, the head entity must be a specific concept, and the tail entity must be a higher-level category concept). If the entity type of an entity-relationship pair does not match the relationship type, it is considered a conflict candidate and is removed. In the example, if the generated pair (Recently, Belongs to, Time) has "Recently" as a time adverb, the entity type does not match the "specific concept" matching the "belongs to" relationship, and the conflict verification fails; in the pair (Artificial Intelligence Technology, Belongs to, Medical), the head entity is a technology term, and the tail entity is a domain term. The "belongs to" relationship requires the tail entity to be a higher-level category (e.g., "technology field"), which conflicts with "medical," so the verification fails and it is removed.

[0061] The entity semantic rationality verification uses semantic similarity calculation. Based on the relation-aware feature vector of the entity, the cosine similarity between the head entity and the tail entity is calculated. A similarity threshold of 0.5 is set; entities with similarities below the threshold are considered semantically irrelevant and are removed. In the example, the similarity between the head and tail entities of (artificial intelligence technology, applied to, development) is 0.42, which is below the threshold, indicating semantic incompatibility, and is therefore removed. The similarity of (medical, belongs to, field) is 0.71, which is above the threshold, and the verification passes. Simultaneously, the consistency between the relation type and the contextual semantics is verified. If the relation type contradicts the semantic expression of the text (e.g., the text does not mention the application scenario, but generates a "applied to" relation pair), the semantic conflict is determined by combining the text structure information, and the entity is removed.

[0062] After verification, all entity-relation pairs that pass the three checks are retained and converted into triples (head entity, relation, tail entity). Corresponding confidence levels, entity boundary indices, relation prediction probabilities, and other auxiliary information are then bound to generate a preliminary set of candidate triples. In the example, the triples that pass the checks include: (Artificial intelligence technology, applied to, healthcare), (Artificial intelligence technology, applied to, education), (Application, belongs to, domain), (Healthcare, belongs to, domain), (Education, belongs to, domain).

[0063] The candidate triplet set is then finalized, sorted in descending order of confidence, and the validation status and core information of each triplet are labeled. At the same time, the validation pass rate is calculated (80% in the example), providing high-quality input for subsequent graph structure consistency validation and conflict resolution.

[0064] S204, perform graph structure consistency verification and conflict resolution on the candidate triple set, and perform confidence calibration based on the global knowledge distribution to generate the final purified structured triple knowledge.

[0065] Specifically, the candidate triple set can be constructed into a temporary knowledge graph, and the degree distribution of entity nodes, the connectivity of relationship paths, and the logical consistency between triples in the graph are calculated to generate a graph structure consistency index. The core of this step is to transform discrete candidate triples into a structured graph, quantify the graph consistency through three dimensions, and provide a quantitative basis for subsequent conflict detection. The specific implementation method is as follows: After the candidate triple set passes the integrity check, a temporary knowledge graph is constructed with entities as nodes and relationships as directed edges. The node attributes include entity text, boundary index, and initial confidence. The edge attributes include relationship type, relationship prediction probability, and the confidence of the corresponding triple. In the example, based on the candidate triple set {(Artificial intelligence technology, applied to, medical), (Artificial intelligence technology, applied to, education), (Application, belongs to, field), (Medical, belongs to, field), (Education, belongs to, field), (Artificial intelligence technology, belongs to, field)}, a temporary graph is constructed. The nodes include "Artificial intelligence technology", "Medical", "Education", "Application", "Field", and the edges correspond to the relationship directions of each triple, forming a directed connected graph.

[0066] Calculate the degree distribution of entity nodes. The degree distribution includes in-degree (the number of edges pointing to the node) and out-degree (the number of edges starting from the node). By counting the in-degree value and out-degree value of each entity, a degree distribution vector is generated, and then the similarity comparison is made with the entity degree distribution of the global knowledge graph. The KL divergence (relative entropy) is used to measure the difference. The formula is KL(P||Q)=ΣP(i)ln(P(i) / Q(i)), where P is the entity degree distribution of the temporary graph, and Q is the average degree distribution of the same type of entities in the global graph. The value range of KL divergence is ≥0. The value closer to 0 indicates that the degree distribution is more consistent, and exceeding 0.3 is regarded as an abnormal distribution. In the example, the in-degree of the "Field" node is 4 and the out-degree is 0. The average in-degree of the same type of "category type entities" in the global graph is 2.5 and the out-degree is 0.2. The calculated KL divergence is 0.28, close to the threshold. If a new triple (Field, applied to, Artificial intelligence technology) is added, the out-degree of "Field" becomes 1, and the KL divergence rises to 0.35, triggering an abnormal distribution warning.

[0067] To calculate the connectivity of relational paths, for any two entity nodes in the temporary graph, all indirect relational paths of length 2-3 are mined (e.g., "AI technology - applied to - medical - belongs to - domain" is a path of length 2). The semantic coherence of relation types in the path is calculated using the cosine similarity of path vectors. The path vector is generated by the weighted sum of the embedding vectors of each relation on the path, with the weights being the relation prediction probabilities. If there are multiple indirect paths between two entities, the highest similarity value is taken as the connectivity score; a score below 0.6 is considered an abnormal connectivity. If there are no indirect paths and no direct paths between entities, they are marked as an isolated node pair with a connectivity score of 0. In the example, the indirect path between "AI technology" and "domain" is "AI technology - applied to - medical - belongs to - domain", with a path vector similarity of 0.72, indicating good connectivity. If (medical, belongs to, domain) is removed, this path is broken, leaving only the path "AI technology - applied to - education - belongs to - domain", with a similarity of 0.68, still satisfying the connectivity requirement.

[0068] The logical consistency between triples is calculated based on predefined relational logic rules (such as transitivity, mutual exclusion, and inverseness). Transitivity rules include "If A applies to B, and B belongs to C, then A applies to C"; mutual exclusion rules include "applies to" and "belongs to" cannot be inversely related (if A applies to B, then B cannot apply to A); and inverseness rules include "If A belongs to B, then B contains A". For each triple, it is checked whether it conforms to the rules with other triples in the graph. The percentage of triples that conform to the rules is the logical consistency score, ranging from 0 to 1. A score below 0.7 is considered a logical anomaly. In the example, the triples (AI technology, belongs to, domain) and (medical, belongs to, domain) have no logical conflict, resulting in a consistency score of 0.85. If a new triple (medical, applies to, AI technology) is added, violating the mutual exclusion rule with (AI technology, applies to, medical), the consistency score drops to 0.62, triggering a logical anomaly.

[0069] Based on the combined results from the three dimensions, a graph structure consistency index is generated. The index is a comprehensive score at the triple level, and the calculation formula is Score=0.3×(1-KL / 0.5)+0.4×path similarity+0.3×logic consistency score, with a value range of 0-1. The higher the value, the better the structural consistency of the triple in the graph, providing a quantitative basis for subsequent conflict detection.

[0070] Based on the graph structure consistency index, triples with distributional, connectivity, or logical conflicts are detected, and a list of conflicting triples is obtained. The core of this step is to accurately locate various conflicting triples by using consistency index thresholds, classify and label them according to conflict type, and provide clear targets for subsequent elimination and optimization. The specific implementation method is as follows: Conflict thresholds are set for each dimension and calibrated based on global knowledge graph training data to ensure both accuracy and fault tolerance: KL divergence threshold: 0.3 (exceeding this threshold indicates a distribution conflict); relation path connectivity score threshold: 0.6 (below this threshold indicates a connectivity conflict); logical consistency score threshold: 0.7 (below this threshold indicates a logical conflict); graph structure comprehensive score threshold: 0.65 (below this threshold indicates a comprehensive conflict). Conflict detection employs a "single-dimensional trigger + comprehensive verification" strategy. If any single-dimensional indicator exceeds the threshold, it is first marked as a candidate conflict triple. Then, it is verified by combining the comprehensive score. If the comprehensive score is also below 0.65, it is confirmed to be included in the conflict list.

[0071] To detect conflicting triples, for each entity node, if its degree distribution KL divergence exceeds 0.3, all associated triples are traced to analyze the reasons for the entity's excessively high or low in-degree / out-degree ratios, and to locate the core triple causing the distribution anomaly. In the example, the "Domain" node's KL divergence rises to 0.35 due to the addition of the triple (Domain, Applied to, Artificial Intelligence Technology). The associated triples include 4 in-degree triples and 1 out-degree triple. Analysis shows that the out-degree triple (Domain, Applied to, Artificial Intelligence Technology) is the cause of the anomaly because it breaks the global distribution pattern of "low out-degree for categorical entities," and is therefore marked as a conflicting triple.

[0072] Detecting conflicting triples: For entity paths with a connectivity score below 0.6, locate triples with key breaks or semantic incoherence in the path. For triples associated with isolated nodes, if connectivity cannot be completed by adding a new path, they are marked as conflicting. In the example, if (Medical, Belongs to, Domain) and (Education, Belongs to, Domain) are removed, "Artificial Intelligence Technology" and "Domain" have no indirect path, resulting in a connectivity score of 0. The associated triples (Artificial Intelligence Technology, Applied to, Medical) and (Artificial Intelligence Technology, Applied to, Education) are marked as conflicting triples because they cannot form a valid connected path. If only one of them is removed, the connectivity score is 0.68, and no conflict is triggered.

[0073] The system detects logically conflicting triples. For triples with a logical consistency score below 0.7, it uses predefined rules to identify the conflict type, such as transitive conflict, mutual exclusion conflict, and reverse conflict, and marks other related triples. In the example, the triples (medical, applied to, artificial intelligence technology) and (artificial intelligence technology, applied to, medical) violate the mutual exclusion rule and have a logical consistency score of 0.62, so both triples are marked as logically conflicting. The triples (artificial intelligence technology, belongs to, medical) and (medical, belongs to, domain) violate the transitivity rule (it should be that artificial intelligence technology belongs to the domain, not medical), and are also marked as logically conflicting.

[0074] For all confirmed conflicting triples, they are categorized and organized according to conflict type, generating a list of conflicting triples. Each list element contains four core pieces of information: triple text, conflict type, correlation index value, and associated triples. Example list snippet: {(Domain, Applied to, Artificial Intelligence Technology), Distributional Conflict, KL Divergence 0.35, Associated Node "Domain"; (Medical, Applied to, Artificial Intelligence Technology), Logical Conflict, Consistency Score 0.62, Associated Triple (Artificial Intelligence Technology, Applied to, Medical)}. Conflicting triples are also prioritized, with logical conflicts having the highest priority (easily leading to semantic confusion in the graph), followed by distributional conflicts, and connectivity conflicts having the lowest priority, providing a priority basis for subsequent processing.

[0075] Based on the prior probability of the global knowledge distribution, Bayesian inference is used to calibrate the confidence of each triple in the candidate triple set, generating a calibrated triple confidence score. The core of this step is to combine global prior knowledge with the consistency features of the temporary graph, and optimize the initial confidence through Bayesian inference to improve the reliability of the triple confidence. The specific implementation method is as follows: To obtain the prior probability of the global knowledge distribution, the prior probability is the probability of a triple of the same type appearing in the global knowledge graph, i.e., P(T) = number of triples of the same type / total number of triples globally. Triples of the same type are defined as triples with the same relation type and matching entity type. In the example, the triple with relation type "applies to", head entity is of the technology class, and tail entity is of the domain class accounts for 0.08 in the global graph, so the prior probability P(T) of the triple (AI technology, applies to, medical) is 0.08; the triple with relation type "belongs to", head entity is of the domain subclass, and tail entity is of the domain class accounts for 0.12 globally, so the prior probability P(T) of the triple (medical, belongs to, domain) is 0.12. Prior probabilities need to be smoothed to avoid rare triples having a prior probability of 0. The smoothing formula is P_smooth(T)=(n+1) / (N+M), where n is the number of triples of the same type, N is the total number of triples globally, and M is the number of predefined relation types (15 types).

[0076] The posterior probability is calculated using Bayesian inference and used as the calibrated confidence score. The Bayesian formula is P(T|S) = P(S|T) × P(T) / P(S), where T is the triplet occurrence event, S is the graph structure consistency index score event, P(S|T) is the likelihood probability (the probability of observing the current consistency score given that the triplet is true), and P(S) is the marginal probability (the total probability of observing the consistency score). The likelihood probability is generated based on the consistency score mapping: a score of 0.8-1 corresponds to P(S|T) = 0.9-1.0, a score of 0.65-0.8 corresponds to P(S|T) = 0.7-0.9, a score of 0.5-0.65 corresponds to P(S|T) = 0.4-0.7, and a score below 0.5 corresponds to P(S|T) = 0.1-0.4. Marginal probabilities are calculated using the law of total probability: P(S) = P(S|T) × P(T) + P(S|¬T) × P(¬T), where P(¬T) is the prior probability (1-P(T)) that the triplet is false, and P(S|¬T) is the probability of observing the score when the triplet is false. It is the inverse function of the likelihood probability (e.g., a score of 0.8 corresponds to P(S|¬T) = 0.2).

[0077] For each candidate triplet, the posterior probability is calculated, generating a calibrated confidence score ranging from 0 to 1. The difference between the initial confidence score and the calibrated score is also retained. If the absolute value of the difference exceeds 0.3, it is marked as an abnormal confidence fluctuation and requires secondary verification based on conflict detection results. After calibration, the triplets are sorted in descending order of confidence score to provide a basis for subsequent elimination operations, ensuring that triplets with high confidence and consistent structure are preferentially retained.

[0078] Based on the calibrated triple confidence scores, triples with confidence scores below the preset confidence threshold and all conflicting triples are removed from the candidate triple set, resulting in the remaining candidate triples, which serve as the final purified structured triple knowledge.

[0079] The core of this step is to eliminate invalid triples through a dual-screening mechanism, retaining high-quality, conflict-free triples to form structured knowledge that can be directly used for knowledge graph construction. The specific implementation method is as follows: A pre-set confidence threshold is used for calibration based on the accuracy requirements of the knowledge graph. A dynamic threshold strategy is adopted, which is set in combination with the distribution characteristics of the confidence scores of candidate triples. If the scores are normally distributed, the mean + 0.5 times the standard deviation is used as the threshold; if they are skewed, the median × 1.2 is used as the threshold. At the same time, a minimum threshold of 0.5 is set to ensure that low-confidence triples are eliminated. In the example, the confidence scores of candidate triples after calibration are distributed as [0.611, 0.582, 0.45, 0.52, 0.63, 0.41], with a mean of 0.534 and a standard deviation of 0.087. The dynamic threshold = 0.534 + 0.5 × 0.087 ≈ 0.577. The final threshold is set to 0.58, which eliminates low-confidence triples while retaining the core effective triples.

[0080] A double-removal operation is performed. First, all triples in the conflicting triple list are removed, regardless of their confidence scores, to prevent conflicting triples from affecting the consistency of the graph. Second, triples with a post-calibration confidence score below a threshold are removed, as even without conflict, low-confidence triples may still contain semantic bias. In the example, the conflicting triples (domain, applied to, artificial intelligence technology) and (medical, applied to, artificial intelligence technology) are directly removed. Triples with post-calibration confidence scores of 0.45, 0.52, and 0.41 (medical, belongs to, domain), (education, belongs to, domain), and (artificial intelligence technology, belongs to, domain) are below the threshold of 0.58 and are removed. The remaining triples (artificial intelligence technology, applied to, medical) (0.611) and (artificial intelligence technology, applied to, education) (0.63) all pass the screening.

[0081] The remaining triples after screening undergo final validation to check for potential conflicts (such as undetected logical conflicts) and whether the confidence fluctuations are reasonable. Simultaneously, the structured attributes of the triples are supplemented, including entity boundary information, relation type encoding, confidence score, and graph structure consistency score, forming standardized structured triple knowledge. In the example, the final purified triples are: (Artificial Intelligence Technology, applied to, Healthcare), confidence score 0.611, consistency score 0.82; (Artificial Intelligence Technology, applied to, Education), confidence score 0.63, consistency score 0.84.

[0082] The statistical purification effect metrics include triple retention rate (number of retained triples / number of candidates, 2 / 6 ≈ 33.3% in the example), conflict removal rate (number of conflicting triples removed / total number of conflicting lists, 2 / 2 = 100% in the example), and confidence level achievement rate (number of retained triples with confidence ≥ threshold / number of retained triples, 2 / 2 = 100% in the example). These metrics are incorporated into the knowledge graph construction log to provide data support for subsequent method optimization. The final generated structured triple knowledge can be directly imported into the knowledge graph storage system as the core data for graph nodes and edges, ensuring the semantic consistency, structural integrity, and data reliability of the knowledge graph.

[0083] Another embodiment of the present invention provides a triple extraction system for knowledge graph construction, see [link to relevant documentation]. Figure 3 The system may include: Learning module 301 is used to learn multi-dimensional feature representations of the input natural language text and generate deep semantic embedding vectors that integrate vocabulary, syntax and discourse structure. The perception module 302 is used to perceive the interaction between entities and relationships based on the deep semantic embedding vector using a multi-head cross-attention mechanism, and dynamically generate contextual feature representations for relationship perception. Decoding module 303 is used to utilize the relation-aware context feature representation to synchronously decode entity boundaries and relation types through a dual-pointer network, and output a preliminary set of candidate triples; The resolution module 304 is used to perform graph structure consistency verification and conflict resolution on the candidate triple set, and to perform confidence calibration based on the global knowledge distribution to generate the final purified structured triple knowledge.

[0084] This invention also provides a storage medium storing a computer program, wherein the computer program is configured to execute the steps in any of the above method embodiments when running.

[0085] This invention also provides an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to perform the steps in any of the above method embodiments.

[0086] The above description, based on the embodiments shown in the figures, details the structure, features, and effects of the present invention. The above description is only a preferred embodiment of the present invention, but the present invention is not limited to the scope of implementation shown in the figures. Any changes made in accordance with the concept of the present invention, or equivalent embodiments modified to have equivalent changes, that do not exceed the spirit covered by the specification and figures, should be within the protection scope of the present invention.

Claims

1. A method for extracting triples for knowledge graph construction, characterized in that, The method includes: Multi-dimensional feature representation learning is performed on the input natural language text to generate deep semantic embedding vectors that integrate vocabulary, syntax and discourse structure; Based on the deep semantic embedding vector, a multi-head cross-attention mechanism is used to perceive the interaction between entities and relationships, and to dynamically generate contextual feature representations for relationship perception. Using the relation-aware contextual feature representation, entity boundaries and relation types are synchronously decoded through a dual-pointer network to output a preliminary set of candidate triples; The candidate triple set is subjected to graph structure consistency verification and conflict resolution, and confidence calibration is performed based on the global knowledge distribution to generate the final purified structured triple knowledge.

2. The method according to claim 1, characterized in that, The process of learning multi-dimensional feature representations from the input natural language text to generate deep semantic embedding vectors that integrate vocabulary, syntax, and discourse structure includes: The input natural language text is segmented and part-of-speech tagged to generate a word sequence and a corresponding part-of-speech tag sequence, which serve as the basic lexical features; Based on basic vocabulary features, a pre-trained language model is used to obtain the context-related embedding representation of each word. At the same time, a dependency parser is used to extract sentence-level dependency graphs and generate syntactic structure feature vectors. Context-related embeddings and syntactic structure feature vectors are fused in a multimodal manner, and a gating attention mechanism is used to dynamically adjust the weights of the two features to generate an intermediate feature representation that fuses lexical and syntactic elements. Text segmentation and referential resolution techniques are used to extract discourse structure information, and the discourse structure information is hierarchically aggregated with intermediate feature representations to finally generate a deep semantic embedding vector that integrates vocabulary, syntax and discourse structure.

3. The method according to claim 2, characterized in that, The process of using a multi-head cross-attention mechanism to perceive the interaction between entities and relationships based on the deep semantic embedding vector, and dynamically generating contextual feature representations for relationship perception, includes: Extract potential entity candidate fragments from deep semantic embedding vectors, and generate a set of entity candidate fragments by scanning a sliding window; Construct a relation query vector, embed predefined relation categories and associate them with entity candidate fragments to generate an initial relation-entity association matrix; A multi-head cross-attention mechanism is adopted, using the initial relation-entity association matrix as the attention prior, with entity candidate fragments as keys and relation query vectors as values, to calculate the interaction weights between entities and relations and generate a relation-aware attention distribution; Based on relation-aware attention distribution, deep semantic embedding vectors are weighted and fused to generate dynamic relation-aware contextual feature representations.

4. The method according to claim 3, characterized in that, The context feature representation, utilizing the relationship awareness, synchronously decodes entity boundaries and relationship types through a dual-pointer network, outputting a preliminary set of candidate triples, including: Based on relation-aware contextual feature representation, a start pointer network is used to predict the probability distribution of the starting position of entity boundaries and generate a candidate set of entity starting positions. Based on relation-aware contextual feature representation, an end pointer network is used to predict the probability distribution of the end position of entity boundaries and generate a candidate set of entity end positions. The candidate set of entity start positions is paired with the candidate set of entity end positions, and combined with the relationship type predicted by the relationship type classifier, preliminary entity-relationship pairs are generated. Perform integrity checks on the initial entity-relation pairs, filter out candidates with invalid boundaries or conflicting relation types, and output an initial set of candidate triples.

5. The method according to claim 4, characterized in that, The process of performing graph structure consistency verification and conflict resolution on the candidate triplet set, and calibrating the confidence level based on the global knowledge distribution to generate the final purified structured triplet knowledge includes: The candidate triple set is constructed into a temporary knowledge graph. The degree distribution of entity nodes in the graph, the connectivity of relation paths, and the logical consistency between triples are calculated to generate a graph structure consistency index. Based on the graph structure consistency index, triples with distributional, connectivity, or logical conflicts are detected, and a list of conflicting triples is obtained. Based on the prior probability of the global knowledge distribution, Bayesian inference is used to calibrate the confidence of each triple in the candidate triple set, generating a calibrated triple confidence score. Based on the calibrated triple confidence scores, triples with confidence scores below the preset confidence threshold and all conflicting triples are removed from the candidate triple set, resulting in the remaining candidate triples, which serve as the final purified structured triple knowledge.

6. A triple extraction system for knowledge graph construction, characterized in that, The system includes: The learning module is used to learn multi-dimensional feature representations of the input natural language text and generate deep semantic embedding vectors that integrate vocabulary, syntax and discourse structure. The perception module is used to perceive the interaction between entities and relationships based on the deep semantic embedding vector using a multi-head cross-attention mechanism, and dynamically generate contextual feature representations for relationship perception. The decoding module is used to utilize the relation-aware context feature representation to synchronously decode entity boundaries and relation types through a dual-pointer network, and output a preliminary set of candidate triples. The resolution module is used to perform graph structure consistency verification and conflict resolution on the candidate triple set, and to perform confidence calibration based on the global knowledge distribution to generate the final purified structured triple knowledge.

7. The method according to claim 6, characterized in that, The learning module is specifically used for: The input natural language text is segmented and part-of-speech tagged to generate a word sequence and a corresponding part-of-speech tag sequence, which serve as the basic lexical features; Based on basic vocabulary features, a pre-trained language model is used to obtain the context-related embedding representation of each word. At the same time, a dependency parser is used to extract sentence-level dependency graphs and generate syntactic structure feature vectors. Context-related embeddings and syntactic structure feature vectors are fused in a multimodal manner, and a gating attention mechanism is used to dynamically adjust the weights of the two features to generate an intermediate feature representation that fuses lexical and syntactic elements. Text segmentation and referential resolution techniques are used to extract discourse structure information, and the discourse structure information is hierarchically aggregated with intermediate feature representations to finally generate a deep semantic embedding vector that integrates vocabulary, syntax and discourse structure.

8. The system according to claim 7, characterized in that, The sensing module is specifically used for: Extract potential entity candidate fragments from deep semantic embedding vectors, and generate a set of entity candidate fragments by scanning a sliding window; Construct a relation query vector, embed predefined relation categories and associate them with entity candidate fragments to generate an initial relation-entity association matrix; A multi-head cross-attention mechanism is adopted, using the initial relation-entity association matrix as the attention prior, with entity candidate fragments as keys and relation query vectors as values, to calculate the interaction weights between entities and relations and generate a relation-aware attention distribution; Based on relation-aware attention distribution, deep semantic embedding vectors are weighted and fused to generate dynamic relation-aware contextual feature representations.

9. A storage medium, characterized in that, The storage medium stores a computer program, wherein the computer program is configured to execute the method of any one of claims 1-5 when it is run.

10. An electronic device comprising a memory and a processor, characterized in that, The memory stores a computer program, and the processor is configured to run the computer program to perform the method of any one of claims 1-5.