Learning from Context or Names? An Empirical Study on Neural Relation Extraction

Hao Peng, Tianyu Gao, Xu Han, Yankai Lin, Peng Li, Zhiyuan Liu, Maosong Sun, Jie Zhou

Introduction

Relation Extraction (RE) is a fundamental task in Natural Language Processing (NLP) aimed at identifying semantic relationships between entities in text. For instance, in the sentence "SpaceX was founded by Elon Musk," a model should extract the triplet (SpaceX, founded_by, Elon Musk). While modern neural models achieve impressive scores on benchmarks, a critical question remains: are they truly understanding the linguistic context, or are they exploiting statistical shortcuts related to entity names?

The "Name Bias" Problem

Researchers have identified a potential "Clever Hans" effect in RE models. If a dataset frequently associates "Elon Musk" with the "founded by" relation, a model might learn to predict that relation whenever it sees his name, regardless of the sentence's actual meaning.

To quantify this, a pilot study was conducted using models like CNN and BERT on the TACRED dataset under various constraints:

  • Only Context (OnlyC): Entities are replaced with generic tokens.
  • Only Mention (OnlyM): Only entity names are provided.
  • Only Type (OnlyT): Only entity types (e.g., Person, Org) are provided.

The results indicated that models perform remarkably well using only entity names, suggesting that benchmarks may leak shallow heuristics that allow for high accuracy without deep linguistic understanding.

Proposed Method: Contrastive Pre-training (CP)

To mitigate name bias and encourage the learning of contextual patterns, the authors propose an Entity-Masked Contrastive Pre-training (CP) framework.

The Contrastive Pre-training (CP) framework uses entity masking and a contrastive loss to align sentences expressing the same relation with different entity pairs.

The CP framework consists of two main components:

  1. Entity Masking: During pre-training, entity mentions are randomly replaced with a special [BLANK] token. This prevents the model from memorizing specific names and forces it to focus on the surrounding text.
  2. Contrastive Learning: Using distant supervision from Wikidata, the model is trained to recognize that two different sentences (with different entity pairs) express the same relation. The contrastive loss pulls these "relational neighbors" closer in the representation space while pushing unrelated sentences apart.

Results and Discussion

The CP framework was evaluated across several benchmarks, including TACRED, SemEval, Wiki80, and ChemProt.

Performance comparison of BERT, MTB, and the proposed CP model across various datasets and data availability levels.

The results demonstrate that CP consistently outperforms standard BERT and the previous state-of-the-art Matching the Blanks (MTB) model. Key findings include:

  • Low-Resource Efficiency: In settings with only 1% of training data, CP shows dramatic improvements (e.g., from 0.211 to 0.485 F1 on TACRED).
  • Generalization: CP performs better on the biomedical ChemProt dataset despite being pre-trained on general Wikipedia text, indicating it learns robust, domain-agnostic relational patterns.
  • Few-Shot Learning: On the FewRel benchmark, CP achieved a significant lead over baseline models, reaching 91.2% accuracy in 10-way 1-shot settings.

Conclusion

This study highlights the over-reliance of current RE models on entity names. By introducing entity masking and a novel contrastive pre-training objective, the proposed CP framework forces models to prioritize textual context. This leads to better generalization and significantly higher performance, particularly when labeled data is scarce.

Summary updated

BibTeX
@inproceedings{peng2020learning,
  author = {Hao Peng and Tianyu Gao and Xu Han and Yankai Lin and Peng Li and Zhiyuan Liu and Maosong Sun and Jie Zhou},
  title = {{Learning from Context or Names? An Empirical Study on Neural Relation Extraction}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2020},
  doi = {10.18653/v1/2020.emnlp-main.298},
}
Figure