0.总结
- 使用transition-based model。这种model 使用传统数据结构(stack )作为基础,自定义栈的操作类型,从而达到一个
entity recognization
的效果 - 如果需要本文对应的ppt,可以从我的GitHub中获取哇~
- 文章来源:CSDN@LawsonAbs
本博客分成三部分:
- part1是论文笔记,主要是概括论文的主要内容;
- part2采用问答的方式来解答可能对论文产生疑问的地方;
- part3部分是对如何实现论文的细节探讨。
PART1论文笔记
这意思就是:可以通过添加细粒度的实体,从而将一个discontinuous NER 问题转换成一个 nested NER 问题。下面以文中的例子来说明这个问题:
重新添加:Body Location
General Feeling
两个细粒度的实体,加上原本的Adverse drug event
实体名,那么就可以将之前单纯的Discontinuous NER
变成了一个Nested NER
问题。这也就说明二者本质上是可以相互转换的(作者应该就是想表示这个意思)
这里先假设向量
c
i
c_i
ci的维度是n。
下面详细说一下
s
i
a
=
s
o
f
t
m
a
x
(
s
i
T
W
i
a
B
)
B
s_i^a = softmax(s_i^TW_i^aB)B
sia=softmax(siTWiaB)B 公式中各个变量的含义:
- s i s_i si is the vector representation of a span, so you can imagine s i ∈ R d s_i \in R^d si∈Rd.
- B B B is a sequence of vectors, each of which represents a token in the buffer. so the shape is B ∈ R d × l B \in R^{d \times l} B∈Rd×l 【那么这里的 l l l就是buffer 中tokens 的个数】
- the W a W_a Wa has the shape of R d × d R^{d \times d} Rd×d, the formula S i T W a B S_i^T W_aB SiTWaB part will get the annotation weights, whose shape is R 1 × l R^{1 \times l} R1×l.
- And the final s a s_a sa has the shape of R 1 × d R^{1 \times d} R1×d.
作者站在attention的角度描述了一下上面这个公式,如下文:
An alternative explanation if you are familiar with attention:
you can imagine s i s_i si is the query vector, B plays the role of both key vectors and value vectors.
and the s a s_a sa is the weighted sum of B (value vectors), whose weights are calculated based on the correlation between key ( s i s_i si) and query vector (B).
PART2疑问
1. 该用什么数据集?什么部分?
下载得到的 CADEC,解压后得到的文件夹如下所示:
那么是用v1,还是v2?
- 使用CADEC.v2文件夹中的数据即可。
- 但是即使在上述的文件夹中的数据仍然数据量比较大,所以作者只取了ADE的部分
但是不清楚是否是因为typo,原作者写成了 ADR。
2.预处理数据的作用是什么?效果是什么?
待更新~
3.其它准备工作
主要是语料库的下载。
-
需要下载elmo 模型和训练结果,下载地址为:https://allennlp.org/elmo。主要是下载weights 和options 两个文件
将下载得到的文件放到目录:/data/dai031/Corpora/ELMo/elmo_2x4096_512_2048cnn_2xhighway_5.5B 下。 -
需要下载glove算法预训练得到的embedding信息,也就是文件glove.6B.100d.txt:可以在 https://www.kaggle.com/danielwillgeorge/glove6b100dtxt 中下载得到。
PART3代码实现
在加载文件 glove.6B.100d.txt 时不动代码卡住不动了:
这个问题该怎么解决呢?
发现自己的确是个zz(原作者也不按常理出牌啊),把日志直接写到文件中了,而没有在窗口中输出。
文件地址如下:
日志输出过程(训练有点儿慢)如下: