Introduction
Pre-trained language models (PLMs) like BERT have revolutionized Natural Language Processing by learning implicit semantic relationships from massive text corpora. However, these models often struggle with "rare word blindness"—a failure to comprehend infrequent or technical terms—and inefficient knowledge infusion, which typically requires expensive re-training or bulky adapter modules.
To address these challenges, we present KAM-BERT (Knowledge-assisted Attention Maps for BERT), a framework that explicitly guides a model's attention mechanism using external knowledge. By treating attention maps as an interface for knowledge injection, KAM-BERT offers a "plug-and-play" solution that enhances reasoning without the need for training from scratch.
Methodology
The core innovation of KAM-BERT is the introduction of Semantic Attention Maps. These maps act as auxiliary channels that highlight specific linguistic and factual relationships within an input sentence, effectively telling the model which token relationships deserve more focus.
Semantic Attention Maps
KAM-BERT utilizes three distinct types of knowledge-driven maps:
- Entity Map: This map explicitly links tokens belonging to the same named entity (e.g., "Fred" and "Meyer"), ensuring the model treats them as a single semantic unit.
- Phrase Segmentation Map: By highlighting words within the same syntactic phrase, this map preserves local structural information that might be lost in standard self-attention.
- Term Correlation Map: Leveraging Pointwise Mutual Information (PMI) from a large web corpus, this map connects semantically related words (e.g., "glipizide" and "pharmacy") even if they are distant in the sentence or rare in the pre-training data.
Multi-Channel Fusion
These semantic maps are concatenated with the "vanilla" self-attention map. A 2D-convolutional layer then fuses these channels, capturing spatial patterns in the attention matrix to produce a single, knowledge-enriched attention map. This approach allows the model to "nudge" its attention scores based on explicit facts while maintaining the strengths of the original pre-trained weights.
Experimental Results
KAM-BERT was evaluated across several benchmarks, demonstrating significant performance gains over standard PLMs with minimal additional parameters.
- GLUE Benchmark: KAM-BERT-Base improved the average GLUE score from 77.5 to 78.7, with a notable 3.6-point jump in the CoLA (linguistic acceptability) task.
- Question Answering: On the CosmosQA dataset, KAM-BERT-Large achieved a 10.6% accuracy improvement over BERT-Large, indicating a superior grasp of commonsense reasoning.
- Efficiency: The framework achieves these results with very few extra parameters compared to "Adapter" based methods, making it computationally efficient during inference.
Industry Applications
The practical utility of KAM-BERT is most evident in specialized domains where rare terms are common. In a large-scale Query-Ad Relevance task for a commercial search engine, the model significantly improved AUC (Area Under Curve).
In this context, the Term Correlation map is particularly valuable. It prevents the model from "getting lost" when encountering rare product or drug names by statistically linking them to more common, related terms, thereby improving the relevance of search results.
Conclusion and Future Work
KAM-BERT demonstrates that the attention map is an ideal location for knowledge injection. While the current implementation relies on external pre-processing tools for NER and syntax parsing, future iterations could incorporate more complex structures such as full Knowledge Graphs or hierarchical taxonomies. By providing a flexible, plug-and-play mechanism for knowledge infusion, KAM-BERT paves the way for more robust and domain-aware language models.
Summary updated