文献阅读 - Bidirectional LSTM-CRF Models for Sequence Tagging
Bidirectional LSTM-CRF Models for Sequence Tagging
Z. H. Huang, W. Xu, K. Yu, Bidirectional LSTM-CRF Models for Sequence Tagging, (2015)
摘要
基于长矩时记忆网络(long short-term memory,LSTM)的序列标注模型:LSTM、双向LSTM(bidirectional
LSTM,BI-LSTM)、条件随机场LSTM(LSTM with a conditional random field layer,LSTM-CRF)、双向(bidirectional LSTM with a conditional random field layer,BI-LSTM-CRF)
BI-LSTM-CRF模型:BI-LSTM能够充分使用输入特征的历史及未来信息(past and future input features);CRF能够使用语义层面的标签信息(sentence level tag information)
1 引言
序列标注(sequence tagging)包括词性标注(part of speech tagging,POS)、组块分析(chunking)和命名实体识别(named entity recognition,NER)
现有序列标注模型多数为线性统计模型(linear statistical models),如:隐马尔科夫模型(Hidden Markov Models,HMM)、最大熵马尔科夫模型(Maximum entropy Markov models,MEMMs)、条件随机场(Conditional Random Fields,CRF)
本文给出四种序列标注模型:LSTM、BI-LSTM、LSTM-CRF、BI-LSTM-CRF,
-
BI-LSTM使用输入特征的历史及未来信息;CRF使用语义层面的标签信息
-
BI-LSTM-CRF鲁棒性(robust)高,且与词嵌入相关小(less dependence on word embedding)
2 模型
LSTM、BI-LSTM、LSTM-CRF、BI-LSTM-CRF
2.1 LSTM网络(LSTM Networks)
循环神经网络(recurrent neural networks,RNN):保留关于历史信息的记忆(a memory based on history information),能够根据相隔很远的特征预测当前输出(predict the current output conditioned on long distance features);网络结构包括输入层(input layer)、隐含层(hidden layer)、输出层(output layer)。
-
输入层表示时间步的特征,与输入特征维度相同(an input layer has the same dimensionality as feature size);
-
输出层表示时间步标签的概率分布(a probability distribution over labels),其维度与标签尺寸相同(the same dimensionality as size of labels);
RNN引入前一时间步隐状态与当前时间步隐状态的连接(a RNN introduces the connection between the previous hidden state and current hidden state),即循环层权值参数(the recurrent layer weight parameters)。循环层用于存储历史信息(recurrent layer is designed to store history information)。
其中,、、表示连接权值(在训练过程中计算),、分别表示sigmoid与softmax**函数。
LSTM(Long Short-Term Memory)网络:用记忆单元(purpose-built memory cells)代替隐含层(hidden layer)更新,以抽取数据的远距离相关性(long range dependencies in the data)。
■图2结构不准确,如并未反馈至各门输入。■
LSTM记忆单元(memory cell):
其中,表示逻辑函数(logistic sigmoid function);、、、、分别表示输入门向量(input gate vector)、遗忘门向量(forget gate vector)、输出门向量(output gate vector)、记忆向量(cell vector)、隐含向量(hidden vector),所有向量维数相同;的下标表示对应的向量。单元向量到门向量的权值矩阵(the weight matrices from the cell to gate vectors),如,为对角矩阵(diagonal),即门向量的第个元素仅与单元向量的第个元素相关。
2.2 双向LSTM网络(Bidirectional LSTM Networks)
双向LSTM网络(bidirectional LSTM network):在给定时间步上,同时使用历史特征(正向状态)和未来特征(反向状态)(make use of past features (via forward states) and future features (via backward states) for a specific time frame)。
训练过程采用时域反向传播(back-propagation through time,BPTT),在各句起始处,隐状态设置为(do forward and backward for whole sentences and we only need to reset the hidden states to 0 at the begging of each sentence)。
2.3 CRF网络(CRF Networks)
根据近邻标签信息预测当前标签(make use of neighbor tag information in predicting current tags)的方式:
(1)预测各时间步(time step)标签分布,并使用集束解码(beam-like decoding)查找最优标签序列(optimal tag sequences),如最大熵分类器(maximum entropy classifier)、最大熵马尔科夫模型(Maximum entropy Markov models,MEMMs)
(2)关注语句层面而非单个词条(focus on sentence level instead of individual positions),如条件随机场(Conditional Random Fields,CRF)模型,输入输出直接相连(inputs and outputs are directly connected)
2.4 LSTM-CRF网络(LSTM-CRF Networks)
LSTM-CRF网络使用LSTM层处理历史输入特征,CRF层处理语句层面标签信息(sentence level tag information)。
CRF层的参数为状态转移矩阵(A CRF layer has a state transition matrix as parameters),该层根据历史和未来标签预测当前标签(use past and future tags to predict the current tag)。
网络输出为分值矩阵(matrix of scores),矩阵元素表示参数为的网络预测语句(sentence)中第个词条标签为的输出分值(the element of the matrix is the score output by the network with parameters , for the sentence and for the -th tag, at the -th word)。转移分值(transition score)表示相邻时间步从标签至的转移(a transition score to model the transition from -th state to -th for a pair of consecutive time steps)。转移矩阵与时间步无关(transition matrix is position independent)。
将网络参数重写为:,则语句沿标签路径(along with a path of tags)的分值为转移分值与网络分值之和(sum of transition scores and network scores):
和推理最优标签序列(optimal tag sequences for inference)可由动态规化(dynamic programming)求解。
■■
方程(5)中,
:时间步,
:LSTM网络输入语句序列,
:LSTM-CRF的输出标签序列,。其中,的取值为所有可能标签
:LSTM网络输出的分值
:标签转移至标签的CRF输出分值,该分值与时间步无关。
:给定序列,LSTM-CRF输出的总分值
在时间步上,LSTM-CRF输出的分值为(CRF的输出分值与时间步有关,LSTM的输出分值与时间步有关)
■
2.5 双向LSTM-CRF网络(BI-LSTM-CRF Networks)
BI-LSTM-CRF同时处理历史与未来输入特征。
3 训练过程
模型训练:前向、后向随机梯度下降(a SGD forward and backward training procedure)
4 实验
POS:为每个词条标注语法角色(POS assigns each word with a unique tag that indicates its syntactic role)
组块分析:为每个词条标注短语类型(chunking, each word is tagged with its phrase type)
命名实体识别:为每个词条标注实体类型,人物、地点、组织或其他(NER task, each word is tagged with other or one of four entity types: Person, Location, Organization, or Miscellaneous)
组块分析和命名实体识别采用BIO2注释标准(annotation standard)
4.1 数据
4.2 特征(Features)
4.2.1 拼写特征(Spelling features)
4.2.2 上下文特征(Context features)
uni-gram、bi-gram特征
4.2.3 词嵌入(Word embedding)
50维词嵌入向量(a 50-dimensional embedding vector)
4.2.4 特征连接技巧(Features connection tricks)
4.3 结果
初始词向量(initialize word embedding):随机、Senna
模型训练:学习率(learning rate),隐层单元数量(hidden layer size),模型性能对隐层单元数量不敏感。
POS指标:词条准确率(per-word accuracy);组块分析和NER指标:名词词组的分值(F1 scores over chunks)
4.3.1 与Cov-CRF比较
CRF为最佳基线模型(CRF forms strong baselines)
4.3.2 模型鲁棒性(robustness)
去除拼写和上下文特征,仅保留词条特征