论文阅读《Enriching Pre-trained Language Model with Entity Information forRelation Classifification》
Author
Shanchan Wu
Alibaba Group (U.S.) Inc., Sunnyvale, CA
Yifan He
Alibaba Group (U.S.) Inc., Sunnyvale, CA
Task
Given a sequence of text (usually a sentence) s and a pair of nominals e1 and e2, the objective is to identify the relation between e1 and e2。
Method
输入句子:
[CLS] The $$$ kitchen $$$ is the last renovated part of the # \# #house # \# #
标签:
xxx
基于BERT预训练模型
步骤:
- 分词:from bert import tokenization
- 填充:from tensorflow.keras.preprocessing.sequence import pad_sequences
- 将数据转化为数字,并补零统一维度
- 标签转换为数字:from sklearn.preprocessing import LabelEncoder
- 模型:
-
加载BERT
-
H t H_t Ht为输入句子经BERT模型第t个位置的输出
-
H 1 ‘ , H 2 ‘ H_1^`,H_2^` H1‘,H2‘为对应关系实体位置值相加再经前馈网络的输出
-
-
H 0 ‘ H_0^` H0‘为[CLS] 经BERT模型的输出
-
-
最后将以上三者拼接线性变换后输出即为所有可能关系的概率向量
-
- 损失函数:交叉熵损失函数
- 评价指标:F1值
Experiment
dataset:
- the SemEval-2010 Task 8 dataset
result
- R-BERT(the proposed model): F1 value: 89.25