本文介绍了Spacy 3 命名实体识别的置信度评分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要获得 NER 'de_core_news_lg' 模型预测的标签的置信度分数.在 Spacy 2 中有一个众所周知的解决方案:

I need to get a confidence score for the tags predicted by NER 'de_core_news_lg' model. There was a well known solution to the problem in the Spacy 2:

nlp = spacy.load('de_core_news_lg')
doc = nlp('ich möchte mit frau Mustermann in der Musterbank sprechen')
text = content
doc = nlp.make_doc(text)
beams = nlp.entity.beam_parse([doc], beam_width=16, beam_density=0.0001)
for score, ents in nlp.entity.moves.get_beam_parses(beams[0]):
    print (score, ents)
    entity_scores = defaultdict(float)
    for start, end, label in ents:
        # print ("here")
        entity_scores[(start, end, label)] += score
        print ('entity_scores', entity_scores)

但是,在 Spacy 3 中我收到以下错误:

However, in Spacy 3 I get the following error:

AttributeError: 'German' object has no attribute 'entity'

显然 language 对象不再具有 entity 属性.有谁知道如何在 Spacy 3 中获得置信度分数?

Obviously language object does not have entity attribute anymore.Does anyone know how to get the confidence scores in Spacy 3?

推荐答案

目前没有一个好的方法来获得 spaCy v3 中 NER 分数的信心.但是,有一个正在开发中的 SpanCategorizer 组件可以使这变得容易.不确定,但我们希望在下一个次要版本中发布它.您可以在该功能的 PR 中关注开发,或阅读更多相关信息这里.

There is currently not a good way to get the confidence for NER scores in spaCy v3. However, there's a SpanCategorizer component in development that will make this easy to do. It's not certain but we hope to release it in the next minor version. You can follow development in the PR for the feature or read more about it here.

这篇关于Spacy 3 命名实体识别的置信度评分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-13 13:40