CoLAKE: Contextualized Language and Knowledge Embedding

Tianxiang Sun, Yunfan Shao, Xipeng Qiu, Qipeng Guo, Yaru Hu, Xuanjing Huang, Zheng Zhang

Abstract

Large-scale pre-trained language models (PLMs) often lack deep factual knowledge, typically relying on static entity embeddings that fail to capture context-dependent relationships. We present CoLAKE (Contextualized Language and Knowledge Embedding), which integrates language and knowledge into a unified Word-Knowledge (WK) graph. By jointly training on text and structured knowledge using an extended Masked Language Model objective, CoLAKE learns contextualized representations for entities and relations. Experimental results show that CoLAKE significantly outperforms previous semi-contextualized models on knowledge-heavy tasks like relation extraction and entity typing while maintaining general language understanding.

Introduction

While models like BERT and RoBERTa excel at linguistic tasks, they often struggle with specific factual relationships. Traditional approaches to addressing this "knowledge-thin" nature involve "knowledge injection"—aligning pre-trained, static entity embeddings (e.g., from TransE) with PLMs. However, these methods suffer from three primary limitations: static embeddings that do not adapt to sentence context, shallow integration that ignores the rich neighborhood of entities in a Knowledge Graph (KG), and inflexibility toward KG updates.

CoLAKE addresses these issues by treating language and knowledge as a unified structure. Just as the word "bank" changes meaning based on context, an entity's relevance depends on its surroundings. In a family context, Harry Potter's "mother" relation is paramount; in a combat context, his "enemy" relation takes precedence. CoLAKE captures this dynamic "knowledge context" through a unified representation space.

Methodology

The core innovation of CoLAKE is the Word-Knowledge (WK) graph. Instead of processing a flat sequence of tokens, the model takes a graph as input. This graph is constructed by starting with a "word graph" derived from the input sentence, identifying "anchor nodes" (entities mentioned in the text), and "mosaicking" them with sub-graphs extracted from Wikidata.

Model Architecture

CoLAKE utilizes a modified Transformer architecture designed to function as a Graph Neural Network (GNN). The self-attention mechanism is constrained by a mask matrix, ensuring that nodes only aggregate information from their direct neighbors within the WK graph.

The CoLAKE architecture integrates word, entity, and relation embeddings into a unified Transformer encoder using a masked multi-head self-attention mechanism.

As shown in Figure 3, the input consists of token, type, and position embeddings. Type embeddings distinguish between words (WD), entities (ENT), and relations (REL). The model is pre-trained using an extended Masked Language Model (MLM) objective that randomly masks words, entities, and relations across the entire graph. To predict a masked element, the model must synthesize information from both the linguistic context and the structured KG neighborhood.

Experiments and Results

CoLAKE was pre-trained on English Wikipedia aligned with Wikidata5M. Evaluation spanned knowledge-heavy tasks (Open Entity, FewRel), factual probing (LAMA), and general NLU (GLUE).

Knowledge-Heavy Tasks

CoLAKE achieved state-of-the-art performance on relation extraction and entity typing. On the FewRel dataset, it reached an F1 score of 90.5, significantly surpassing previous models like ERNIE (88.3).

Performance comparison on Open Entity and FewRel datasets. CoLAKE achieves superior F1 scores, particularly on the FewRel relation extraction task.

Factual Recall and General NLU

On the LAMA-Google-RE probe, CoLAKE achieved a P@1 of 9.5, nearly doubling the 5.3 score of its base model, RoBERTa. Crucially, this gain in knowledge did not come at the cost of linguistic ability; CoLAKE maintained an average score of 86.3 on GLUE, comparable to RoBERTa's 86.4. This demonstrates that CoLAKE avoids the "knowledge curse" where factual injection degrades general language performance.

Conclusion

CoLAKE represents a shift from static knowledge injection to dynamic, contextualized knowledge integration. By unifying language and knowledge in a single graph-based representation space, it enables models to reason over both text and structured facts simultaneously. Future work will focus on reducing the computational complexity of managing millions of entity embeddings and developing more sophisticated masking strategies to further enhance inductive reasoning capabilities.

Summary updated

BibTeX
@inproceedings{sun2020colake,
  author = {Tianxiang Sun and Yunfan Shao and Xipeng Qiu and Qipeng Guo and Yaru Hu and Xuanjing Huang and Zheng Zhang},
  title = {{CoLAKE: Contextualized Language and Knowledge Embedding}},
  booktitle = {International Conference on Computational Linguistics},
  year = {2020},
  doi = {10.18653/v1/2020.coling-main.327},
}
Figure