Try  HackMD Logo HackMD

Automated Concatenation of Embeddings for Structured Prediction

acl2021
https://aclanthology.org/2021.acl-long.206/

  • 把一堆 embedding 串一起然後輸入 LSTM 來分類 NER label,取得 SOTA 成績
  • 但用了一大堆模型 的 embedding,感覺只是用來拚榜而已

Introduction

  • word embeddings 對於下游任務影響很深,像是 ELMO, Flair, BERT, XLM-R 都取得了 SOTA 成績,而 embedding 的串接也能產生更好的效果
  • Neural architecture search (NAS) 是一種能自動尋找最好模型架構 (排列組合) 的方法,並且在 image classification / semantic segmentation / object detection 任務都有背應用上

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

  • 結合以上想法,本文提出 Automated Concatenation of Embeddings 來找出最好的 word embedding 串接方式,策略為去優化 reinforcement learning 架構中的 controller,並在 6 tasks and 21 dataset 上取得了 SOTA 成績

  • 在每次的 STEP 中,controller 根據 belief model 選出 word embedding 串接方式,用這些參數訓練完模型後取得 accuracy 當作 reward,並去更新 belief model

    • 專注在挑選 embedding 串接方式
    • 新穎的 controller 設計和 reward function
    • efficient and practical(實際的)

Task model

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

我們的任務為給定

x ,輸出每個
y
類別的機率 (其實就是 softmax 分類)

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

任務模型有兩種,一種是基於 sequence,另一種基於 graph

Sequence

  • BiLSTM-CRF model
  • Xuezhe Ma and Eduard Hovy. 2016. End-to-end sequence labeling via bi-directional LSTM-CNNsCRF

Graph

  • BiLSTM-Biaffine
  • Timothy Dozat and Christopher D. Manning. 2018. Simpler but more accurate semantic dependency parsing

輸入 n 個字,在經過

L 個模型 embedd 後的詞向量序列為
V

  • d 為所有模型 hidden size 加總
  • vil
    代表由第
    l
    個模型產生的第
    i
    個字的 embedding,
  • vi
    是由多個模型的第
    i
    個字串接而成
    V=[v1;;Vn],VRd×nvil=embedil(x); vi=[vi1;vi2;viL]

在給予輸入

x 後產生
y
的機率
Pseq(y|x)=BiLSTMCRF(V,y)Pgraph(y|x)=BiLSTMBiaffine(V,y)







structs

V=[v1;...;Vn]


struct1

v1^1

v1^2

v1^3



struct2

v2^1

v2^2

v2^3



struct1:f0->struct2:f0





struct3

v3^1

v3^2

v3^3



struct2:f0->struct3:f0





Search Space Design

  • L 個模型所能組成的 embeddings 有
    2L
  • binary variable
    ai
    能控制 embedding 要不要被選用,類似 mask 的概念
    vi=[vi1a1;;vilal;viLaL]

Searching in the Space

  • 我們用參數
    θ=[θ1;θ2;;θL]
    來當作 controller 變數
  • P(a;θ)
    代表在給定變數
    θ
    下產生
    a
    的機率
  • 選擇 concatenation
    a
    的機率分佈 (
    為連乘)

Pctrl(a;θ)=l=1LPlctrl(al;θl)

  • Plctrl
    為 Bernoulli distribution,σ is the sigmoid function
    Image Not Showing Possible Reasons
    • The image file may be corrupted
    • The server hosting the image is unavailable
    • The image path is incorrect
    • The image format is not supported
    Learn More →

直觀解釋: 假設我們用了 ELMO 和 BERT,用

θ1 控制選擇 ELMO 的機率,用
θ2
控制選擇 ELMO 的機率。啟用 ELMO embedding (
a1=1
) 的機率為
σ(θ1)
,不啟用的機率為
1σ(θ1)

Train loop

在訓練過程中,先選擇好 mask,接著依照這個 mask 去訓練模型,並在 development set 上測試得到 accuracy R 當作 reward

由於 R 不能微分計算 gradient,因此根據 policy gradient method,controller 的目標為最大化

J(θ)=EPctrl(a;θ)[R]

為了訓練效率的提升,一次只選擇一種

θ 來去計算,而不是把所有的
θ
可能性都嘗試

  • b
    是 baseline function (通常選擇最高的 accuracy)

θJ(θ)l=1LθlogPlctrl(al;θl)(Rb)

Reward
用 binary vector

|atai| 來代表 embedding 選擇的變化

  • at
    是在 time step
    t
    的 embedding 選擇
  • ai
    是在 time step
    i
    的 embedding 選擇
  • rt
    是長度為
    L
    的 vector,表示了每個 embedding 得到的 reward
    rt=i=1t1(RtRi)|atai|

在以上的基礎,考慮到越遠的 timestep 影響力應該要更小,因此加入縮放因子

γ(0,1)

rt=i=1t1(RtRi)γHamm(atai)1|atai|
重寫式子
θJt(θ)l=1LθlogPlctrl(alt;θl)rlt

Training

用字典

D 來存 串接方式驗證分數的對應

在 t=1 時候,所有的 embedding 都啟用

t >= 2

  1. sample
    at
  2. 依照
    at
    訓練 task model ,得到 accuracy R
  3. at
    Rt
    加入
    D
    , 讓 t = t+1
  • 在選擇
    at
    時,避免選擇
    at1
    全零的 vector
  • at
    存在於字典,替換為更高的 R

embeddings

用超多的

  • ELMo
  • Flair
  • base BERT
  • GloVe word embeddings
  • fastText word embeddings
  • noncontextual character embeddings (Lample et al.,2016)
  • multilingua Flair (M-Flair)
  • M-BERT
  • XLM-R embeddings.

Result

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →