Relationship triple extraction method based on supervised comparative learning and multi-task learning

Through supervised comparative learning and multi-task learning methods, the embedding space and bidirectional prediction of the Transformer model are optimized, and the error propagation and entity overlap problems in relational triple extraction are solved, which improves the extraction efficiency and accuracy, and adapts to complex scenarios.

CN120508663APending Publication Date: 2025-08-19UNIV OF ELECTRONICS SCI & TECH OF CHINA
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510585883.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-08
Publication Date
2025-08-19

AI Technical Summary

Technical Problem

The prior art has error propagation, information loss, entity overlapping problems and insufficient distinction ability of entities similar in relational triple extraction, resulting in low extraction efficiency and poor accuracy.

Method used

Using a method based on supervised contrast learning and multi-task learning, a context embedding representation is generated through a Transformer pre-trained model, and the embedding space is optimized by combining head and tail entity similarity punishment, and two-way prediction is performed through a multi-task learning framework to integrate head entities, tail entities and relationship prediction.

Benefits of technology

The accuracy and robustness of relational triple extraction were improved, and the F1 score increased by 5%-10% on the NYT, NYT*, WebNLG and WebNLG* datasets, and the Spearman correlation coefficient reached 86.70% and 81.95% on the STS-B and SICK-R datasets, which was better than the existing models.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120508663A_ABST
    Figure CN120508663A_ABST
Patent Text Reader

Abstract

The invention discloses a relation triple extraction method based on supervised comparative learning and multi-task learning, and the method comprises the following steps: S1, obtaining an unstructured text, inputting the unstructured text into a pre-training large model based on Transform, and generating context embedding representation; s2, based on the context embedding representation, applying supervised comparative learning in combination with head and tail entity similarity punishment to optimize an embedding space, and generating an optimized embedding representation; and S3, inputting the optimized embedded representation into a multi-task learning framework, integrating head entity annotation, tail entity annotation, relation prediction, relation specific head entity annotation and relation specific tail entity annotation, and outputting a structured triple through a bidirectional prediction mechanism. According to the method, the accuracy of relation triple extraction is improved, the F1 score is increased by 5%-10% on NYT, NYT *, WebNLG and WebNLG * data sets, and the method is superior to models such as OneRel and TPLinker.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of structured relation triple prediction, and in particular relates to a relation triple extraction method based on supervised contrastive learning and multi-task learning. Background Art

[0002] With the rapid development of internet technology, unstructured text data (such as news reports, social media, and web content) has exploded in volume. Extracting structured information from this data, such as relation triplets (headentity, relation, and tail entity) in knowledge graphs, has become a core task in information extraction. Traditional relation triple extraction methods often use a pipelined architecture, separating named entity recognition (NER) and relation extraction (RE) into two independent steps. However, these methods suffer from the following issues:

[0003] 1. Error propagation: Errors in entity recognition will directly affect the accuracy of relation extraction, resulting in a decline in overall performance.

[0004] 2. Information loss: Independent processing ignores the semantic associations between entities and relations, making it difficult to capture cross-triplet dependencies in complex scenarios.

[0005] 3. Entity overlap problem: An entity in the same text may appear in multiple triples (such as entity pair overlap EPO or single entity overlap SEO), and the existing model has limited processing capabilities.

[0006] 4. Insufficient differentiation of similar entities: Existing methods do not adequately optimize the embedding space of semantically similar entities, resulting in weak model differentiation capabilities.

[0007] In recent years, end-to-end joint extraction methods have gradually emerged, attempting to simultaneously complete entity and relationship extraction through a single model. At the same time, pre-trained large models (such as BERT and RoBERTa) have shown significant advantages in NLP tasks due to their powerful semantic representation capabilities. However, when combined with large model technology, existing methods have not yet fully explored their potential in complex relationship modeling and embedding space optimization, especially when dealing with entity overlap and cross-triplet association scenarios. There are still limitations. Therefore, there is an urgent need for an innovative method that deeply integrates the semantic modeling capabilities of large models to solve the above problems and achieve efficient and accurate relation triple extraction. Summary of the Invention

[0008] In response to the above-mentioned deficiencies in the prior art, the relation triplet extraction method based on supervised contrastive learning and multi-task learning provided by the present invention solves the problems of low efficiency and poor accuracy of traditional relation triplet extraction methods.

[0009] In order to achieve the above-mentioned object of the invention, the technical solution adopted by the present invention is: a relation triple extraction method based on supervised contrastive learning and multi-task learning, comprising the following steps:

[0010] S1. Obtain unstructured text and input it into a large pre-trained model based on Transformer to generate contextual embedding representation;

[0011] S2. Based on the contextual embedding representation, supervised contrastive learning is applied in combination with head-tail entity similarity penalty to optimize the embedding space and generate the optimized embedding representation;

[0012] S3. Input the optimized embedding representation into a multi-task learning framework, integrate head entity labeling, tail entity labeling, relationship prediction, relationship-specific head entity labeling, and relationship-specific tail entity labeling, and output structured triples through a bidirectional prediction mechanism.

[0013] Furthermore, in S1, the method for generating context-aware embedding representation is as follows:

[0014] S11. Use a word segmenter to decompose the unstructured text into word or subword sequences, add special tags, and generate an initial input sequence;

[0015] S12. Input the initial input sequence into the Transformer-based pre-trained large model to generate an initial embedding vector;

[0016] S13. Based on the initial embedding vector, the Transformer's multi-layer self-attention mechanism is used to capture the long-range dependencies between words and generate context-aware hidden layer representations.

[0017] S14. Extract the last hidden state of each word as the context embedding representation.

[0018] Furthermore: in S12, the initial embedding vector includes word embedding, position embedding and segment embedding.

[0019] Furthermore: In S2, the joint optimization loss L of the embedding space is optimized contrastive The specific expression is:

[0020] L contrastive =L CL +λ1L penalty

[0021] Where, L CL is the supervised contrastive learning loss function, L penalty is the head-tail entity similarity penalty loss function, and λ1 is the first hyperparameter.

[0022] Further: Supervised contrastive learning loss function L CLThe specific expression is:

[0023]

[0024] Where Sim(·) is the cosine similarity, P(i) is the positive sample set, N(i) is the negative sample set, is a positive sample, is a negative sample, τ is the temperature parameter, e i For entities, H is the context embedding representation.

[0025] Furthermore: In S2, the method for generating positive samples through supervised contrastive learning is specifically:

[0026] Based on the contextual embedding representation and annotated data, the annotated data includes training samples of head entities, tail entities, and relations. Entity pairs with similar semantics are selected to generate positive samples. The entity pairs with similar semantics include:

[0027] Entity pairs consisting of the head and tail entities in the same triple;

[0028] Extract contextual semantics from the contextual embedding representation and identify semantically similar entity pairs;

[0029] Group entities by type and build pairs of entities of the same type;

[0030] The method of generating negative samples through supervised contrastive learning is specifically: selecting semantically different entity pairs or irrelevant entity pairs to generate negative samples.

[0031] The beneficial effect of the above further scheme is: through the positive and negative sample design of structural information, entity description information and entity type information, combined with the head and tail entity similarity penalty, the embedding discriminability is significantly enhanced.

[0032] Further: In S2, the head-tail entity similarity penalty loss function L penalty The specific expression is:

[0033] L penalty =max(0,Sim(e h ,e t )-δ)

[0034] Where δ is the similarity threshold, e h is the head entity, e t is the tail entity;

[0035]

[0036] Where ||·|| is the modulus of the vector.

[0037] Furthermore: In S3, the tasks of the multi-task learning framework include:

[0038] Head entity labeling: Based on the optimized embedding representation, through the fully connected layer and classifier, it predicts whether each word is a head entity and outputs the label sequence of the head entity labeling;

[0039] Tail entity annotation: Based on the optimized embedding representation, predict the label sequence of the tail entity annotation;

[0040] Relationship prediction: Based on the head and tail entity embeddings in the optimized embedding representation, the relationship type is predicted through a bilinear layer and the predicted relationship label type is output;

[0041] Relation-specific head entity labeling: Based on the predicted relationship label type, predict the tail entity from the head entity, refine the label sequence of the head entity labeling, and output the first label sequence;

[0042] Relation-specific tail entity labeling: Based on the predicted relation label type, the head entity is predicted from the tail entity, the label sequence of the tail entity labeling is refined, and a second label sequence is output.

[0043] Furthermore: In S3, the total loss function L of the multi-task learning framework is expressed as follows:

[0044] L=L MT +λ2L CL

[0045] Where λ2 is the second hyperparameter, L MT The loss of each task in the multi-task learning framework;

[0046] L MT =L h +L t +L r +L rsh +L rst

[0047] Where, L h is the head entity labeling loss, L t is the tail entity labeling loss, L r is the relationship prediction loss, L rsh For relation-specific head entity labeling loss, L rst Specific tail entity labeling loss for relations.

[0048] Furthermore: In S3, the method for outputting structured triples through the bidirectional prediction mechanism is specifically as follows:

[0049] The tail entity is predicted from the head entity according to the obtained first label sequence, and the head entity is predicted from the tail entity according to the obtained second label sequence, and the final triplet is output.

[0050] The beneficial effects of the present invention are as follows: the present invention provides a relation triple extraction method based on supervised contrastive learning and multi-task learning, which has the following effects compared with the prior art:

[0051] Efficiency: For the first time, the semantic encoding of a large pre-trained model is combined with supervised contrastive learning, and the contextual representation of the Transformer is used to optimize the embedding space, improving the ability to model complex relationships and avoiding the error propagation of pipelined methods.

[0052] Accuracy: This paper improves the accuracy of relation triple extraction, improving the F1 score by 5%-10% on the NYT, NYT*, WebNLG, and WebNLG* datasets, outperforming models such as OneRel and TPLinker.

[0053] Robustness: Supervised contrastive learning and head-tail entity similarity penalty are used to enhance the ability to distinguish semantically similar entities, adapt to complex scenarios, and incorporate a bidirectional prediction mechanism from head to tail entities and from tail to head entities into the multi-task framework to solve the problems of entity overlap and cross-triplet association, thereby improving model robustness.

[0054] Practicality: On the STS-B and SICK-R datasets, the Spearman correlation coefficients are 86.70% and 81.95% respectively, which are better than methods such as SimCSE. BRIEF DESCRIPTION OF THE DRAWINGS

[0055] Figure 1 This is a flow chart of the relation triple extraction method based on supervised contrastive learning and multi-task learning of the present invention. DETAILED DESCRIPTION

[0056] The specific embodiments of the present invention are described below to facilitate understanding of the present invention by those skilled in the art. However, it should be clear that the present invention is not limited to the scope of the specific embodiments. For those skilled in the art, as long as various changes are within the spirit and scope of the present invention as defined and determined by the appended claims, these changes are obvious, and all inventions and creations utilizing the concepts of the present invention are protected.

[0057] like Figure 1 As shown, in one embodiment of the present invention, a relation triple extraction method based on supervised contrastive learning and multi-task learning includes the following steps:

[0058] S1. Obtain unstructured text and input it into a large pre-trained model based on Transformer to generate contextual embedding representation;

[0059] S2. Based on the contextual embedding representation, supervised contrastive learning is applied in combination with head-tail entity similarity penalty to optimize the embedding space and generate the optimized embedding representation;

[0060] S3. Input the optimized embedding representation into a multi-task learning framework, integrate head entity labeling, tail entity labeling, relationship prediction, relationship-specific head entity labeling, and relationship-specific tail entity labeling, and output structured triples through a bidirectional prediction mechanism.

[0061] In S1, the method for generating context-aware embedding representation is as follows:

[0062] S11. Use a word segmenter to decompose the unstructured text into word or subword sequences, add special tags, and generate an initial input sequence;

[0063] S12. Input the initial input sequence into the Transformer-based pre-trained large model to generate an initial embedding vector;

[0064] S13. Based on the initial embedding vector, the Transformer's multi-layer self-attention mechanism is used to capture the long-range dependencies between words and generate context-aware hidden layer representations.

[0065] S14. Extract the last hidden state of each word as the context embedding representation.

[0066] In this example, the BERT word segmenter is selected as the word segmenter, the BERT pre-trained model is selected as the pre-trained large model, the unstructured text is such as "Barack Obama, born in Hawaii, served as the President of the United States", and the special tags are such as [CLS] and [SEP]. The generated context embedding representation is used as the basic feature of the subsequent task. The context embedding representation H = {h1,h2,...,h n},in is the d-dimensional embedding vector of the l-th word, l = 1,…,n, and n is the total number of words.

[0067] In S12, the initial embedding vector includes word embedding, position embedding, and segment embedding.

[0068] In S2, the joint optimization loss L of the optimized embedding space is optimized contrastive The specific expression is:

[0069] L contrastive =L CL +λ1L penalty

[0070] Where, L CL is the supervised contrastive learning loss function, L penalty is the head-tail entity similarity penalty loss function, and λ1 is the first hyperparameter.

[0071] The optimized embedding representation H'={h'1,h'2,...,h' n}, semantically similar entities are closer in the embedding space, and the head and tail entities have higher discrimination, where h' l is the optimized d-dimensional embedding vector of the i-th word, l = 1,…,n, and n is the total number of words.

[0072] Supervised contrastive learning loss function L CL The specific expression is:

[0073]

[0074] Where Sim(·) is the cosine similarity, P(i) is the positive sample set, N(i) is the negative sample set, is a positive sample, is a negative sample, τ is the temperature parameter, e i For entities, H is the context embedding representation.

[0075] In this embodiment, the goal of supervised contrastive learning is to make the embeddings of positive sample pairs closer together and the embeddings of negative sample pairs farther apart.

[0076] In S2, the method for generating positive samples through supervised contrastive learning is as follows:

[0077] Based on the contextual embedding representation and annotated data, the annotated data includes training samples of head entities, tail entities, and relations. Entity pairs with similar semantics are selected to generate positive samples. The entity pairs with similar semantics include:

[0078] An entity pair consisting of the head and tail entities in the same triple; for example, "Barack Obama" and "Hawaii" in the "bornin" relation.

[0079] Extract contextual semantics from the contextual embedding representation and identify semantically similar entity pairs; such as "Beijing" and "Shanghai" as place names.

[0080] Group entities based on their type (e.g., names of people, places), and construct pairs of entities of the same type;

[0081] The method of generating negative samples through supervised contrastive learning is specifically: selecting semantically different entity pairs or irrelevant entity pairs to generate negative samples.

[0082] In this embodiment, for entity e i , the positive and negative sample pairs are represented as in is a positive sample, is a negative sample.

[0083] In S2, the head-tail entity similarity penalty loss function L penalty The specific expression is:

[0084] L penalty =max(0,Sim(e h ,e t )-δ)

[0085] Where δ is the similarity threshold, e h is the head entity, e t is the tail entity;

[0086]

[0087] Where ||·|| is the modulus of the vector.

[0088] The head-tail entity similarity penalty loss function is used to impose penalties on excessively high similarities to ensure the accuracy of subsequent entity labeling.

[0089] In S3, the tasks of the multi-task learning framework include:

[0090] Head entity labeling: Based on the optimized embedding representation, through the fully connected layer and classifier, predict whether each word is a head entity, and output the label sequence Y of the head entity labeling h ;

[0091] Tail entity annotation: Based on the optimized embedding representation, predict the label sequence Y of the tail entity annotation t ;

[0092] Relationship prediction: Based on the head and tail entity embeddings in the optimized embedding representation, the relationship type is predicted through a bilinear layer, and the predicted relationship label type Y is output. r ;

[0093] Relation-specific head entity labeling: Based on the predicted relationship label type, predict the tail entity from the head entity, refine the label sequence of the head entity labeling, and output the first label sequence Y rsh ;

[0094] Relation-specific tail entity labeling: Based on the predicted relationship label type, predict the head entity from the tail entity, refine the label sequence of the tail entity labeling, and output the second label sequence Y rst .

[0095] In S3, the total loss function L of the multi-task learning framework is expressed as follows:

[0096] L=L MT +λ2L CL

[0097] Where λ2 is the second hyperparameter, L MTThe loss of each task in the multi-task learning framework;

[0098] In this embodiment, the present invention adopts five tasks to jointly optimize and utilizes the semantic association between tasks to improve the generalization ability.

[0099] L MT =L h +L t +L r +L rsh +L rst

[0100] Where, L h is the head entity labeling loss, L t is the tail entity labeling loss, L r is the relationship prediction loss, L rsh For relation-specific head entity labeling loss, L rst Specific tail entity labeling loss for relations.

[0101] In S3, the method of outputting structured triples through the bidirectional prediction mechanism is as follows:

[0102] According to the first tag sequence obtained, the tail entity is predicted from the head entity, and according to the second tag sequence obtained, the head entity is predicted from the tail entity, and the final triple is output. The final triple T'={(e h ,r,e t )}, suitable for complex relationship extraction.

[0103] In this embodiment, the bidirectional prediction mechanism enhances the model's ability to handle entity overlap (EPO and SEO) by sharing H'. For example, in "Barack Obama, born in Hawaii, served as the President of the United States," the forward prediction identifies "Hawaii" and "born in" from "Barack Obama," while the backward prediction verifies "Barack Obama" from "Hawaii," ensuring triple consistency.

[0104] The process of the method of the present invention is specifically as follows:

[0105] Step 1: Semantic encoding of the Transformer-based pre-trained large model;

[0106] Use BERT to encode the text and generate the contextual embedding HH, which captures the semantic relationship between "Barack Obama", "Hawaii" and "United States" to generate H.

[0107] Step 2: Apply supervised contrastive learning combined with head-tail entity similarity penalty to optimize the embedding space;

[0108] Based on H, construct positive samples such as "Beijing" and "Shanghai", and construct negative samples such as "Beijing" and "Obama".

[0109] Calculate the similarity between the head and tail entities, apply penalties, and generate H'.

[0110] Step 3: Multi-task learning and bidirectional prediction:

[0111] Based on H', head entity tagging, tail entity tagging, relation prediction, relation-specific head entity tagging, and relation-specific tail entity tagging are performed.

[0112] Bidirectional prediction: Forwardly identify "Hawaii" and "born in" from "Barack Obama", and reversely verify "Barack Obama" from "Hawaii"; forwardly identify "United States" and "served as" from "Barack Obama", and reversely verify "Barack Obama" from "United States".

[0113] Output triples:

[0114] (Barack Obama, born in, Hawaii)

[0115] (Barack Obama,served as,President of the United States)

[0116] The implementation effects of the method of the present invention are as follows:

[0117] On the NYT, NYT*, WebNLG, and WebNLG* datasets, the F1 score outperforms the baseline model, with an improvement of 5%-10% in complex scenarios.

[0118] On the STS-B and SICK-R datasets, the Spearman correlation coefficients are 86.70% and 81.95% respectively, which are better than methods such as SimCSE.

[0119] Ablation experiments show that large models and contrastive learning contribute 10%-15% performance improvement.

[0120] In experiments on relation triple extraction, the MTBR-CL model (this model) performed exceptionally well on four datasets: NYT*, NYT, WebNLG*, and WebNLG. MTBR-CL offers significant advantages over traditional models. NovelTagging transforms extraction into sequence tagging, relying on a BiLSTM encoder, but its performance is limited for complex relations. CopyRE generates triples through a copying mechanism, but struggles with scenarios involving deep semantic dependencies. In contrast, MTBR-CL optimizes semantic modeling through contrastive learning, achieving F1 scores generally exceeding 92.7%.

[0121] Recent state-of-the-art models such as TPLinker, which uses three-way annotation to address entity overlap, and OneRel, which uses a scoring classifier to extract triplets in a single step, have made progress, but their overall performance still falls short of MTBR-CL. While CGT incorporates generative contrastive learning, its dynamic masking design limits recall. PRGC, which handles relation and entity alignment in steps, is susceptible to pruning errors. MTBR-CL, however, achieves a better balance between precision and recall.

[0122] Judging from the characteristics of the datasets, NYT primarily uses single relations with little entity overlap, while WebNLG has a wide variety of relations and a high degree of overlap, resulting in most models performing poorly on the latter. For example, RSAN uses Attention to capture entity information, but struggles to adapt to the complexity of WebNLG. MTBR-CL, however, maintains stable F1 scores on both datasets, with F1 scores of 93.3% and 92.7%, respectively, thanks to contrastive learning that improves adaptability to diverse relations. SOIRP addresses the nesting problem through table completion and iterative reasoning, achieving performance close to MTBR-CL but slightly inferior in cross-dataset robustness.

[0123] In the semantic text similarity (STS) task, the MTBR-CL model demonstrated excellent performance on the STS-B and SICK-R datasets, surpassing several existing methods. MTBR-CL incorporates a new supervised contrastive learning module that optimizes the embedding space using a positive and negative sample strategy. MTBR-CL achieved 86.70% on STS-B and 81.95% on SICK-R, with an average score of 84.33%, significantly outperforming baselines and other state-of-the-art models. This demonstrates that contrastive learning effectively enhances the model's ability to capture semantic relationships.

[0124] Compared to traditional sentence embedding models, MTBR-CL performs particularly well. InferSent, based on BiLSTM and trained using NLI data, can capture basic semantic relationships but is limited in deep semantic modeling, achieving an average score of only 66.84%. USE, combining the Transformer and DAN with multi-task learning, generates universal embeddings, achieving a score of 75.81%, but lacks targeted optimization. SBERT improves performance to 74.97% through BERT fine-tuning, but relies on post-processing to compensate for pre-training biases. In contrast, MTBR-CL directly optimizes the embedding space through contrastive learning, significantly improving the quality of semantic representation.

[0125] Among recent state-of-the-art models, CT proposed self-supervised noise contrastive learning to mitigate bias in Transformer tasks, achieving an average score of 78.94%. SimCSE utilizes NLI data to construct contrastive objectives and optimize BERT / RoBERTa embeddings, achieving an average score of 82.45%, making it a leader among supervised methods. However, MTBR-CL, through a multi-level positive and negative sample strategy (based on structure, description, and type), further narrows the distance between similar entities and pushes the distance between dissimilar entities apart, surpassing SimCSE's performance. It achieved a 2.2% improvement on STS-B and a 1.56% improvement on SICK-R, demonstrating stronger semantic modeling capabilities. From the perspective of its positive and negative sample strategies, MTBR-CL's design fully leverages the triplet nature of the corpus. The structure-based strategy enhances cross-triplet correlation and is suitable for scenarios with strong relational consistency; the description-based strategy exploits semantic similarity and improves comprehension of complex sentences; and the type-based strategy enforces type consistency and adapts to diverse entity pairs. These strategies work together to ensure MTBR-CL's robustness on STS tasks, and its performance is particularly stable on the semantically diverse SICK-R dataset.

[0126] After removing the contrastive learning module, the performance of the MTBR-CL model generally deteriorated, with the F1 score dropping to 93.8% on NYT* and 92.5% on WebNLG. This indicates that the supervised contrastive learning module is crucial for optimizing the embedding space and improving triple extraction capabilities, although the impact on WebNLG* is smaller (the F1 score remains unchanged), likely because the diversity of the dataset's relations is already fully captured by the MTBR framework.

[0127] In the ablation of positive and negative sample strategies, removing the structure-based strategy caused a 0.2% and 0.1% drop in F1 scores for NYT* and WebNLG*, respectively. This result validates the role of structured knowledge in enhancing cross-triplet relevance, especially on single-relation datasets such as NYT*.

[0128] After removing the entity description-based strategy, the F1 scores of NYT* and WebNLG* dropped by 0.3% and 0.2%, respectively. This shows that description embeddings contribute more to complex semantic scenes, especially on the WebNLG dataset with high entity diversity.

[0129] Removing the entity type-based strategy also leads to a decrease in F1 score of 0.3% and 0.2% for NYT* and WebNLG*, and 0.2% and 0.2% for NYT and WebNLG, respectively. The strengthening effect of type consistency on semantic representation is reflected in all datasets.

[0130] In the description of the present invention, it should be understood that the terms "center", "thickness", "upper", "lower", "horizontal", "top", "bottom", "inner", "outer", "radial", etc., indicating the orientation or positional relationship, are based on the orientation or positional relationship shown in the accompanying drawings, and are only for the convenience of describing the present invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operate in a specific orientation, and therefore cannot be understood as limiting the present invention. In addition, the terms "first", "second", and "third" are used for descriptive purposes only and cannot be understood as indicating or implying the relative importance or the number of technical features implicitly specified. Therefore, the features defined by "first", "second", and "third" may explicitly or implicitly include one or more of such features.

Claims

1. A relation triplet extraction method based on supervised contrastive learning and multi-task learning, characterized by: The following steps are involved: S1. Obtain unstructured text and input it into a large pre-trained model based on Transformer to generate contextual embedding representation; S2. Based on the contextual embedding representation, supervised contrastive learning is applied in combination with head-tail entity similarity penalty to optimize the embedding space and generate the optimized embedding representation; S3. Input the optimized embedding representation into a multi-task learning framework, integrate head entity labeling, tail entity labeling, relationship prediction, relationship-specific head entity labeling, and relationship-specific tail entity labeling, and output structured triples through a bidirectional prediction mechanism.

2. The relation triple extraction method based on supervised contrastive learning and multi-task learning according to claim 1, characterized in that: In S1, the method for generating context-aware embedding representation is as follows: S11. Use a word segmenter to decompose the unstructured text into word or subword sequences, add special tags, and generate an initial input sequence; S12. Input the initial input sequence into the Transformer-based pre-trained large model to generate an initial embedding vector; S13. Based on the initial embedding vector, the Transformer's multi-layer self-attention mechanism is used to capture the long-range dependencies between words and generate context-aware hidden layer representations. S14. Extract the last hidden state of each word as the context embedding representation.

3. The relation triple extraction method based on supervised contrastive learning and multi-task learning according to claim 2 is characterized in that: In S12, the initial embedding vector includes word embedding, position embedding, and segment embedding.

4. The relation triple extraction method based on supervised contrastive learning and multi-task learning according to claim 1, characterized in that: In S2, the joint optimization loss L of the optimized embedding space is optimized contrastive The specific expression is: L contrastive =L CL +λ1L penalty Where, L CL is the supervised contrastive learning loss function, L penalty is the head-tail entity similarity penalty loss function, and λ1 is the first hyperparameter.

5. The method for extracting relation triples based on supervised contrastive learning and multi-task learning according to claim 4, characterized in that: Supervised contrastive learning loss function L CL The specific expression is: Where Sim(·) is the cosine similarity, P(i) is the positive sample set, N(i) is the negative sample set, is a positive sample, is a negative sample, τ is the temperature parameter, e i For entity, e i , H is the context embedding representation.

6. The method for extracting relation triples based on supervised contrastive learning and multi-task learning according to claim 5, characterized in that: In S2, the method for generating positive samples through supervised contrastive learning is as follows: Based on the contextual embedding representation and annotated data, the annotated data includes training samples of head entities, tail entities, and relations. Entity pairs with similar semantics are selected to generate positive samples. The semantically similar entity pairs selected include: Entity pairs consisting of the head and tail entities in the same triple; Extract contextual semantics from the contextual embedding representation and identify semantically similar entity pairs; Group entities by type and build pairs of entities of the same type; The method of generating negative samples through supervised contrastive learning is specifically: selecting semantically different entity pairs or irrelevant entity pairs to generate negative samples.

7. The method for extracting relation triples based on supervised contrastive learning and multi-task learning according to claim 5, characterized in that: In S2, the head-tail entity similarity penalty loss function L penalty The specific expression is: L penalty =max(0,Sim(e h ,and t )-δ) Where δ is the similarity threshold, e h is the head entity, e t is the tail entity; Where ||·|| is the modulus of the vector.

8. The method for extracting relation triples based on supervised contrastive learning and multi-task learning according to claim 7, characterized in that: In S3, the tasks of the multi-task learning framework include: Head entity labeling: Based on the optimized embedding representation, through the fully connected layer and classifier, it predicts whether each word is a head entity and outputs the label sequence of the head entity labeling; Tail entity annotation: Based on the optimized embedding representation, predict the label sequence of the tail entity annotation; Relationship prediction: Based on the head and tail entity embeddings in the optimized embedding representation, the relationship type is predicted through a bilinear layer and the predicted relationship label type is output; Relation-specific head entity labeling: Based on the predicted relationship label type, predict the tail entity from the head entity, refine the label sequence of the head entity labeling, and output the first label sequence; Relation-specific tail entity labeling: Based on the predicted relation label type, the head entity is predicted from the tail entity, the label sequence of the tail entity labeling is refined, and a second label sequence is output.

9. The method for extracting relation triples based on supervised contrastive learning and multi-task learning according to claim 8, characterized in that: In S3, the total loss function L of the multi-task learning framework is expressed as follows: L=L MT +λ2L CL Where λ2 is the second hyperparameter, L MT The loss of each task in the multi-task learning framework; L MT =L h +L t +L r +L rsh +L rst Where, L h is the head entity labeling loss, L t is the tail entity labeling loss, L r is the relationship prediction loss, L rsh For relation-specific head entity labeling loss, L rst Specific tail entity labeling loss for relations.

10. The method for extracting relation triples based on supervised contrastive learning and multi-task learning according to claim 9, characterized in that: In S3, the method of outputting structured triples through the bidirectional prediction mechanism is as follows: The tail entity is predicted from the head entity according to the obtained first label sequence, and the head entity is predicted from the tail entity according to the obtained second label sequence, and the final triplet is output.