有监督的关系抽取任务之PCNN
有监督的关系抽取任务:
PCNN的实现过程:
1)数据预处理:首先对数据进行位置编码,按句子中各个词离entity的距离进行编码。 例如:“As we known,Steve Jobs was the co-founder of Apple Inc which is a great company in America.” 由于句子中有两个entity,所以这条句子就会产生两个和句子长度相同的编码。 pos_1:[-4,-3,-2,-1,0,1,2,3......] ,其中0就是Steve Jobs的位置。 pos_2:[-9,-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3......] 其中0就是Apple Inc的位置。
2)切分句子:其中最主要的就是将一条文本数据在两个entity处各切一刀将文本且成了3段。 比如 As we known,Steve Jobs was the co-founder of Apple Inc which is a great company in America,将被切成: 1. As we known,Steve Jobs 2. Steve Jobs was the co-founder of Apple Inc 3. Apple Inc which is a great company in America. 注意,位置向量也同样进行了切分操作。
3)特征提取:将位置特征和文本特征拼接之后,然后将上面三个数据分别通过CNN提取特征;
4)关系分类:提取出来的特征通过maxpooling层之后进行拼接后送入softmax层,最终得到relation的分类;