【问题标题】:Using huggingface fill-mask pipeline to get the "score" for a result it didn't suggest使用 huggingface 填充蒙版管道来获得它不建议的结果的“分数”
【发布时间】:2020-07-24 20:50:24
【问题描述】:

我一直在使用 huggingface 来预测蒙面标记,效果很好。我注意到,对于每个预测,它都会给出一个“分数”,并希望为一些它没有预测但我提供的令牌给出“分数”。

例如,如果我的句子是 "I ate bacon and <mask> for breakfast",我可以使用 pipeline('fill-mask') 来获取预测及其分数,例如它可能会还给我 ["eggs", 0.1]。但我想做的是提供我自己的猜测,然后取回它分配给我自己猜测的分数。例如我可能想知道在这种情况下它对“煎饼”这个词的评分。

这可能吗?

【问题讨论】:

    标签: python neural-network nlp huggingface-transformers spacy-transformers


    【解决方案1】:

    您可以为此使用目标。

    pipe = pipeline('fill-mask', model = model, tokenizer=tokenizer)
    result = pipe('I ate bacon and <mask> for breakfast', targets= ['milk'])
    

    【讨论】:

      【解决方案2】:

      您可以使用 bert-as-service 来完成此任务。 请参考此library

      你也可以使用 fill_mask() 方法 参考这个link

      【讨论】:

        猜你喜欢
        • 2023-04-02
        • 2014-04-15
        • 2020-07-22
        • 2021-12-28
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-04-09
        • 1970-01-01
        相关资源
        最近更新 更多