Link Prediction for Wikipedia Articles as a Natural Language Inference Task

Chau-Thang Phan, Quoc-Nam Nguyen, Kiet Van Nguyen

Abstract

Link prediction is a fundamental task in network analysis, particularly for knowledge bases like Wikipedia. This paper presents a novel approach by reformulating link prediction as a Natural Language Inference (NLI) task. By treating article content as premises and hypotheses, we leverage the semantic reasoning capabilities of the XLM-RoBERTa model. Our approach, combined with rigorous text preprocessing to remove Wikipedia-specific markup noise, achieved a perfect Macro F1-score of 1.00000 on the DSAA-2023 competition private test set.

1. Introduction

Wikipedia serves as a critical repository of human knowledge, yet its internal structure—the hyperlinks connecting related concepts—is often incomplete. Traditional link prediction methods typically rely on graph topology (analyzing the "shape" of the network) or surface-level textual similarity. While effective for structural patterns, these methods often fail to capture the deep semantic nuances that justify a connection between two distinct topics.

This study explores the hypothesis that a link between two Wikipedia articles represents a logical or contextual entailment. By framing link prediction as a Natural Language Inference (NLI) problem, we can utilize state-of-the-art transformer models to determine if the content of a source article (the premise) logically supports the existence of a link to a target article (the hypothesis).

2. Problem Definition

The objective is to predict whether a directed link exists between two nodes, $A$ and $B$, in a graph where each node is associated with a textual description. In the context of the DSAA-2023 "Efficient and Effective Link Prediction" competition, this is treated as a binary classification task. Given a pair of articles, the model must output a label $y \in \{0, 1\}$, where 1 indicates a valid relationship and 0 indicates no relationship.

3. Methodology

The proposed system, developed by team UIT-NLP, rests on two primary components: a semantic NLI formulation and a robust data cleaning pipeline.

3.1 NLI-based Formulation

We cast link prediction as a Sentence Pair Classification (SPC) task. In standard NLI, a model evaluates the relationship between a premise and a hypothesis. We adapt this by treating the text of Article A as the premise and Article B as the hypothesis. This allows the model to move beyond keyword matching and instead learn the underlying semantic connectivity required for a hyperlink to be contextually appropriate.

3.2 Data Preprocessing

Wikipedia's raw data is heavily laden with CSS, HTML-like markup, and template syntax (e.g., double curly braces). Such noise can obscure semantic meaning and degrade transformer performance. Our preprocessing pipeline included:

  • Balancing Curly Braces: Ensuring text segments are not truncated mid-expression.
  • Template Removal: Stripping double curly braces and their contents, which often contain non-semantic metadata.
  • Normalization: Using regular expressions to remove excessive punctuation and redundant whitespace.

3.3 Model Architecture

We utilized the XLM-RoBERTa architecture, a multilingual variant of RoBERTa pre-trained on a massive corpus. A linear classification layer was added on top of the transformer's pooled output to generate the final link probability.

4. Experiments and Results

4.1 Dataset

The study used the DSAA-2023 Competition Dataset, consisting of:

  • Training Set: 948,233 node pairs.
  • Testing Set: 238,265 node pairs.
  • Distribution: The training data was relatively balanced (54.03% non-related, 45.97% related).

4.2 Performance

The model was trained for four hours on a single NVIDIA RTX 4090 GPU. The impact of preprocessing was profound: without cleaning, the Macro F1-score was approximately 0.976. With the full preprocessing pipeline, the model achieved:

  • Public Test Set: 0.99996 Macro F1 (ranked 8th).
  • Private Test Set: 1.00000 Macro F1 (ranked 3rd, tied for highest).

5. Discussion and Limitations

The near-perfect performance on the competition dataset suggests that for well-structured knowledge bases like Wikipedia, semantic entailment is a highly effective proxy for link existence. However, several limitations remain:

  • Context Window: The model used a maximum token length of 128. For longer articles, critical context located beyond the introduction might be lost.
  • Computational Complexity: While training is efficient, performing inference on all possible pairs in a large-scale graph (millions of nodes) using a transformer is computationally prohibitive compared to heuristic-based graph methods.
  • Generalization: The effectiveness of this NLI approach on less structured domains, such as social media graphs or citation networks with sparse text, remains to be validated.

6. Conclusion

By reimagining link prediction as a natural language inference task, we demonstrated that deep semantic understanding can virtually eliminate errors in identifying Wikipedia article relationships. The success of the XLM-RoBERTa model in this context highlights the importance of both advanced transformer architectures and meticulous data cleaning in processing large-scale knowledge graphs.

Summary updated

BibTeX
@inproceedings{phan2023link,
  author = {Chau-Thang Phan and Quoc-Nam Nguyen and Kiet Van Nguyen},
  title = {{Link Prediction for Wikipedia Articles as a Natural Language Inference Task}},
  booktitle = {DSAA},
  year = {2023},
  doi = {10.1109/dsaa60987.2023.10302560},
}
Figure