我正在使用Vowpal Wabbit的python来训练命名的实体识别分类器,以从短句子中检测人员、组织和位置的名称。我编制了一个IPython笔记本,详细说明了数据、模型是如何培训的,以及评估语句中识别的实体。培训数据来自阿提斯和CONLL 2003数据集。
我的Vowpal Wabbit SearchTask类的设置(基于本教程):
class SequenceLabeler(pyvw.SearchTask):
def __init__(self, vw, sch, num_actions):
pyvw.SearchTask.__init__(self, vw, sch, num_actions)
sch.set_options( sch.AUTO_HAMMING_LOSS | sch.AUTO_CONDITION_FEATURES )
def _run(self, sentence):
output = []
for n in range(len(sentence)):
pos,word = sentence[n]
with self.vw.example({'w': [word]}) as ex:
pred = self.sch.predict(examples=ex, my_tag=n+1, oracle=pos, condition=[(n,'p'), (n-1, 'q')])
output.append(pred)
return output
示范培训:
vw = pyvw.vw(search=num_labels, search_task='hook', ring_size=1024)
#num_labels = 3 ('B'eginning entity, 'I'nside entity, 'O'ther)
sequenceLabeler = vw.init_search_task(SequenceLabeler)
sequenceLabeler.learn(training_set)
该模型在训练数据中显示的命名实体(精确的字符串匹配)上表现很好,但是对于使用相同结构的新示例来说,效果很差。也就是说,分类器将从训练数据中识别句子中的实体,但当我只更改名称时,它们的表现就很差。
sample_sentences = ['new york to las vegas on sunday afternoon',
'chennai to mumbai on sunday afternoon',
'lima to ascuncion on sunday afternoon']
当运行分类器时它的输出:
new york to las vegas on sunday afternoon
locations - ['new york', 'las vegas']
chennai to mumbai on sunday afternoon
locations - []
lima to ascuncion on sunday afternoon
locations - []
这表明,即使句子保持不变:“周日下午a
to b
”,但该模型无法识别新的位置,可能是因为它已经记住了培训示例?
同样的结果也适用于organisation
和person
分类器。这些可以在我的Github中找到。
我的问题是-
ring_size
和search_task
https://stackoverflow.com/questions/43490440
复制相似问题