Abstract
We study how to enhance text representation via textual commonsense. We point out that commonsense has the nature of domain discrepancy. Namely, commonsense has different data formats and is domain-independent from the downstream task. This nature brings challenges to introducing commonsense in general text understanding tasks. A typical method of introducing textual knowledge is continuing pre-training over the commonsense corpus. However, it will cause catastrophic forgetting to the downstream task due to the domain discrepancy. In addition, previous methods of directly using textual descriptions as extra input information cannot apply to large-scale commonsense. In this paper, we propose to use large-scale out-of-domain commonsense to enhance text representation. In order to effectively incorporate the commonsense, we proposed OK-Transformer (Out-of-domain Knowledge enhanced Transformer). OK-Transformer effectively integrates commonsense descriptions and enhances them to the target text representation. In addition, OK-Transformer can adapt to the Transformer-based language models (e.g. BERT, RoBERTa) for free, without pre-training on large-scale unsupervised corpora. We have verified the effectiveness of OK-Transformer in multiple applications such as commonsense reasoning, general text classification, and low-resource commonsense settings.
Introduction
Large language models like BERT and RoBERTa excel at general language tasks but often lack the explicit causal and factual knowledge humans call "commonsense." For instance, understanding that "comforting" someone implies they are "crying" or "sad" is intuitive for humans but difficult for models to infer from general corpora alone.
A common approach to address this is "continued pre-training" on commonsense knowledge bases. However, this often leads to domain discrepancy and catastrophic forgetting, where the model's performance on general tasks degrades as it overfits to the specific format of the commonsense data.
The OK-Transformer Architecture
To overcome these challenges, we propose the OK-Transformer (Out-of-domain Knowledge enhanced Transformer). This architecture allows for "plug-and-play" integration of large-scale commonsense without requiring expensive retraining of the base model's weights.
The system utilizes three primary components:
- Knowledge Enhancement Module (Transformer¹): Processes the input text and introduces a specialized
[k]token. This token serves as a latent representation that aggregates external knowledge. - Knowledge Integration Module (Transformer²): Encodes textual descriptions retrieved from the ATOMIC2020 knowledge graph.
- Integration Layer (Transformer³): Employs a cross-attention mechanism to select relevant commonsense facts and inject them into the
[k]token's representation.
By initializing the OK-Transformer with pre-trained weights from models like BERT or RoBERTa, the system gains access to external facts while maintaining its original linguistic capabilities.
Experimental Results
We evaluated OK-Transformer on several benchmarks, including the Winograd Schema Challenge (WSC273) and the GLUE benchmark.
- Commonsense Reasoning: OK-RoBERTa achieved a state-of-the-art accuracy of 91.58% on WSC273, significantly outperforming the base RoBERTa model.
- General Text Classification: On the SST-2 sentiment analysis task, the model reached 96.10% accuracy.
- Robustness to Forgetting: Unlike continued pre-training (BERT-continue), which saw performance drops on general tasks, OK-BERT consistently improved or maintained performance across all benchmarks.
- Low-Resource Scenarios: The model proved particularly effective when training data was scarce, demonstrating that external commonsense can effectively bridge the gap in task-specific knowledge.
Conclusion
The OK-Transformer provides a scalable, efficient way to inject large-scale commonsense into language models. By treating knowledge as a dynamic input rather than static weights, it avoids the pitfalls of catastrophic forgetting and offers a flexible "plug-and-play" solution for enhancing text representation. Future work will focus on reducing the computational overhead associated with encoding multiple knowledge descriptions.
Summary updated