DeBERTa
Decoding-enhanced BERT with disentangled attention
He et al., Microsoft, 2020 — arXiv:2006.03654
前身:ELECTRA — 解決 attention 中 content 與 position 混在一起的問題
動機
標準 Transformer attention 的問題:
Attention(Q, K) = (content + position) · (content + position)
位置資訊和語意內容混合計算,模型難以分別學習「這個詞是什麼」和「它在哪裡」。
方法
1. Disentangled Attention(解耦注意力)
每個 token 用兩個向量表示:content 和 position
計算 attention 時展開成 4 個矩陣:
| attention 類型 | 計算 |
|---|---|
| content-to-content | H_i · H_j^T |
| content-to-position | H_i · P_{i|j}^T(相對位置) |
| position-to-content | P_{j|i} · H_j^T |
| 捨棄(實驗顯示無益) |
使用相對位置編碼(而非絕對位置)
2. Enhanced Mask Decoder(EMD)
fine-tune 時在最後幾層加入絕對位置資訊,補回相對位置的限制
效果
DeBERTa-xxlarge 在 2021 年以單一模型首次在 SuperGLUE 超越人類基準(89.9 vs 89.8)
| 模型 | SuperGLUE |
|---|---|
| BERT-large | 71.5 |
| RoBERTa-large | 84.6 |
| ELECTRA-large | 88.8 |
| DeBERTa-xxlarge | 89.9 |
| Human baseline | 89.8 |
優點 / 缺點
| 說明 | |
|---|---|
| ✅ | 位置與語意分離,各自學習更充分 |
| ✅ | 多項 NLU benchmark SOTA |
| ✅ | DeBERTa-v3 進一步結合 ELECTRA-style 訓練 |
| ❌ | 架構複雜,理解與實作成本高 |
| ❌ | 大模型(xxlarge)推論仍慢 |
DeBERTa-v3(延伸)
結合 ELECTRA 的 replaced token detection + DeBERTa 的 disentangled attention,效率與效果雙提升。