Abstract
Knowledge Graph (KG) embeddings typically struggle with "long-tail" entities—those with few connections—due to data sparsity. We present LMKE (Language Models as Knowledge Embeddings), a framework that integrates pretrained language models with graph structures. By treating entities and relations as special tokens and employing a contrastive learning objective (C-LMKE), our approach achieves state-of-the-art performance on link prediction and triple classification while remaining computationally efficient.
Introduction
Knowledge Graphs like WordNet or Freebase are foundational for AI but suffer from inherent sparsity. Existing embedding methods generally fall into two categories: structure-based and description-based. Structure-based methods (e.g., TransE, RotatE) rely on connectivity, failing for the "long tail" of entities with minimal links. Description-based methods leverage text but are often computationally prohibitive, requiring heavy Transformer encoding for every candidate entity during inference.
LMKE bridges this gap by creating a model that is as rich as a language model but as efficient as a graph model.
Methods: Contrastive Learning for Efficiency
LMKE introduces Unified Tokenization, treating every entity and relation as a unique "special token" alongside its textual description. This allows the model to contextualize an entity's meaning based on both its text and its graph neighborhood.
To address the efficiency bottleneck of previous text-based methods, the authors developed C-LMKE, which reformulates link prediction as a contrastive matching task.
C-LMKE uses a Query Encoder for the head entity and relation, and a Key Encoder for candidate tail entities. By using other entities within the same training mini-batch as negative samples, the model achieves "zero-cost" negative sampling, avoiding the expensive generation of fake triples. Furthermore, the model explicitly incorporates entity "degree" (number of connections) into the matching function to leverage statistical priors from the graph structure.
Key Results and Insights
The model was evaluated on standard benchmarks including FB15k-237, WN18RR, and UMLS. C-LMKE achieved a Hits@10 of 0.806 on WN18RR, a significant improvement over the previous state-of-the-art (0.704).
Dominating the Long Tail
A core strength of LMKE is its performance on sparse data. For entities with zero or one connection, textual descriptions provide a vital "cold start" solution.
As shown in the performance breakdown by entity degree, C-LMKE maintains high accuracy even for entities with very few connections, where traditional structure-based methods like TransE and RotatE struggle. On FB15k-237, C-LMKE outperformed traditional methods by a wide margin for the loneliest entities (degree 0-1), proving that language models are key to solving graph sparsity.
Conclusion
LMKE demonstrates that language models can serve as powerful, efficient knowledge embeddings. While BERT-based models still require more resources than simple vector math, the contrastive approach makes them viable for large-scale graphs. Future work will explore memory banks for larger negative sample pools and deeper investigations into capturing complex logical patterns like transitivity.
Summary updated