Introduction
In Natural Language Processing (NLP), researchers typically navigate a trade-off between three primary neural network architectures:
- CNNs excel at capturing local patterns (n-grams) but often fail to model long-distance dependencies and lose sequence information during pooling.
- RNNs handle sequential data effectively but suffer from slow training due to their non-parallelizable nature.
- Transformers provide superior global context modeling but are computationally intensive, data-hungry, and may "blur" critical local n-gram relationships by averaging attention across entire sequences.
The Attentive Convolutional Transformer (ACT) addresses these limitations by bridging the gap between the local feature extraction of CNNs and the global dependency modeling of Transformers. ACT captures local n-grams as effectively as a CNN while maintaining the parallelizable power of a Transformer, resulting in a lightweight model optimized for real-world deployment.
Methods: The Attentive Convolution Mechanism
The core innovation of ACT is the Attentive Convolution Mechanism, which replaces standard self-attention. While standard Transformers calculate relationships between every word pair, ACT shifts the focus to learned semantic filters.
The process involves several key steps:
- Filters as Semantic Keys: Convolutional filters serve as "keys" and "values" in the attention mechanism. These filters are learned during training to represent invariant semantic patterns, such as specific keywords or phrases.
- Feature Mapping: The model performs an n-gram convolution to generate a feature map. This map acts as attention weights, which are then used to combine the convolutional filters, transforming text from a word-embedding space into a structured "convolutional filter space."
- Dual Representation: ACT generates a local representation that preserves sequence order and a global representation (via max-pooling) that captures the most salient features across the document.
- Global Attention: A final global attention layer synthesizes local features, global features, and position embeddings into a single vector for classification.
The architecture is multi-head and multi-layer, allowing it to learn diverse n-gram features in parallel subspaces, mirroring the multi-head approach of standard Transformers.
Datasets and Evaluation
ACT was evaluated on six benchmarks across three tasks:
- Sentiment Analysis: Yelp Review Polarity and Yelp Review Full.
- Topic Categorization: AG’s News and DBPedia.
- Relation Extraction: TACRED and SemEval2010-task8.
These datasets range from 8,000 to 650,000 training samples with varying document lengths, providing a comprehensive test of the model's versatility.
Key Insights
- Efficiency through Simplification: By attending to global filters rather than every other word, ACT simplifies the optimization landscape, leading to more stable training and improved keyword extraction.
- Sequence Preservation: Unlike traditional CNNs that discard positional information early via pooling, ACT’s local representation maintains the sequence, enabling the global attention layer to make more context-aware decisions.
- Parameter Efficiency: ACT achieves high performance without the massive parameter counts of BERT-style models by focusing on n-gram relevance and filtering out the "noise" often found in standard self-attention.
Results
ACT consistently outperformed CNNs, RNNs, and standard Transformers:
- Accuracy: It achieved top accuracy on 5 out of 6 datasets. Notably, on Yelp Full, it reached 68.16% accuracy, surpassing the standard Transformer's 65.34%.
- Speed and Size: ACT is significantly more efficient, featuring 56% fewer parameters and running 2.7 times faster during inference (0.07s vs. 0.19s per batch) compared to standard Transformers.
- Ablation Study: Removing the "attentive" component of the convolution resulted in a nearly 2% performance drop, validating the importance of the novel mechanism.
Limitations and Future Work
While highly effective for classification, ACT's current optimization is task-specific. Future research will explore its application in machine translation and summarization. Additionally, the "attentive convolution" concept could be adapted for speech recognition and computer vision.
A notable challenge is hyper-parameter sensitivity. On smaller datasets like TACRED, the model performs best with a single layer, as deeper stacks can lead to overfitting. Balancing depth and data size remains a key area for refinement.
Summary updated