天天看點

Deep contextualized word representations (ELMo) 閱讀筆記雙向語言模型ELMo

ELMo (Embeddings from Language Models)

引入了一種新的深度上下文單詞表示,不僅能對單詞使用的複雜特征(如文法和語義)進行模組化,還能根據上下文語境的不同做出改變(一詞多義)。

與傳統的單詞類型嵌入不同,每一個token的表示是整個輸入句子的函數。它們是在帶有字元卷積的兩層biLMs上計算的

雙向語言模型

給定N個token的序列,(t1,t2,……,tN),對于前向語言模型(forward language model)來說,tk是由前面的token計算出來的:

Deep contextualized word representations (ELMo) 閱讀筆記雙向語言模型ELMo

後向語言模型(backward language model)是這樣的:

Deep contextualized word representations (ELMo) 閱讀筆記雙向語言模型ELMo

biLM就是結合了上述兩種模型,最大化前向和後向的對數似然:

Deep contextualized word representations (ELMo) 閱讀筆記雙向語言模型ELMo

兩個方向的

Deep contextualized word representations (ELMo) 閱讀筆記雙向語言模型ELMo

是獨立的,

Deep contextualized word representations (ELMo) 閱讀筆記雙向語言模型ELMo

就是一開始輸入的詞向量,

Deep contextualized word representations (ELMo) 閱讀筆記雙向語言模型ELMo

就是softmax層參數。

ELMo

對于token tk,L層的biLM可以計算出2L+1個表達:

Deep contextualized word representations (ELMo) 閱讀筆記雙向語言模型ELMo
Deep contextualized word representations (ELMo) 閱讀筆記雙向語言模型ELMo

是輸入的token層,

Deep contextualized word representations (ELMo) 閱讀筆記雙向語言模型ELMo
Deep contextualized word representations (ELMo) 閱讀筆記雙向語言模型ELMo

對于下遊的具體任務,ELMo把所有層的

Deep contextualized word representations (ELMo) 閱讀筆記雙向語言模型ELMo

壓縮在一起形成一個單獨的vector:

Deep contextualized word representations (ELMo) 閱讀筆記雙向語言模型ELMo

其中,γ可以對特定任務的模型的ELMo向量進行大小縮放,s是softmax-normalized權重。

将ELMo用于下遊任務supervised model時,首先固定biLM的權重,把

Deep contextualized word representations (ELMo) 閱讀筆記雙向語言模型ELMo

與Xk結合,得到ELMo enhanced representation [Xk;

Deep contextualized word representations (ELMo) 閱讀筆記雙向語言模型ELMo

],輸入NLP 模型中。

繼續閱讀