ACL2020 Contextual Embeddings When Are They Worth It 精讀

Arxiv連接ui

上下文嵌入(Bert詞向量): 何時值得用?設計

ACL 20183d

預訓練詞向量 (上下文嵌入Bert,上下文無關嵌入Glove, 隨機)詳細分析文章blog

1 背景


圖1 Bert
優勢 效果顯著
缺點 成本昂貴 (Memory,Time,  Money) (GPT-3,1700億的參數量)
困惑 線上環境,資源受限(內存 CPU GPU) bert不必定是最佳 選擇
用word2vec, glove等詞向量有時候也能取得近似效果
但何時能夠近似,須要實驗說明,因而做者設計了實驗

2 三種詞向量


圖2 三種詞向量
類型 說明 實驗
上下文詞嵌入 BERT XLNet 做者實驗中選BERT 768維
上下文詞無關嵌入 Glove Word2Vec FastText 做者實驗中選Glove 300維
隨機嵌入 n*d矩陣 (n是詞彙量, d是嵌入維度) 做者實驗中選循環隨機嵌入 800維, 空間複雜度O(nd) => O(n)

3 實驗和結論

任務 模型
命名實體識別 (NER) BiLSTM
情感分析 (sentiment analysis) TextCNN

3.1 影響因素一:訓練數據規模


圖3 影響因素一:訓練數據規模 01

圖4 影響因素一:訓練數據規模 02

在許多任務中,供充足的數據,GloVe這些詞向量可匹配BERTtoken

3.2 影響因素二:語言的特性

3.2.1 Complexity of setence structure

NER: 實體佔據幾個token (George Washington)內存


圖5 NER中的句子複雜度

Sentiment analysis:句子依存分析中依賴標記對之間的平均距離資源


圖6 Sentiment analysis中的句子複雜度

3.2.2 Ambiguity in word usage

NER: 實體有幾個標籤(George Washington能夠做爲人名、地名、組織名)get


圖7 NER中的句子模糊度

Sentiment analysis:
\begin{array}{l}
H\left( {\frac{1}{{\left| S \right|}}\sum\limits_{w \in S} {p\left( { + 1\left| w \right.} \right)} } \right) \
{\rm{where }}H\left( p \right) = - p{\log _2}\left( p \right) - \left( {1 - p} \right){\log _2}\left( {1 - p} \right) \
\end{array}it


圖8 Sentiment analysis中的句子模糊度

3.2.3 Prevalence of unseen words

NER: token出現次數得倒數table


圖9 NER中的未登陸詞流行度

Sentiment analysis:
給定一個句子,句子中未在訓練集中出現token佔比


圖10 Sentiment analysis中未登陸詞流行度

圖11 Bert和隨機向量對比

圖12 Bert和Glove對比

文本結構複雜度高和單詞歧義性方面: BERT更好

未登陸詞方面: GloVe 更好

總結

大量訓練數據和簡單語言的任務中,考慮算力和設備等,GloVe 表明的 Non-Contextual embeddings 是個不錯的選擇

對於文本複雜度高和單詞語義歧義比較大的任務,BERT表明的 Contextual embeddings 有明顯的優點。

未登陸詞方面: GloVe 更好

相關文章
相關標籤/搜索