【问题标题】:Equivalent of allennlp.commands.elmo in Allennlp v0.8.4 for version 2.10.0等效于 Allennlp v0.8.4 中的 allennlp.commands.elmo 版本 2.10.0
【发布时间】:2022-10-13 06:44:46
【问题描述】:

我使用 Python 库作为我的应用程序的依赖项,该应用程序导入 Allennlp v0.8.4。该库使用ElmoEmbedder 类通过其batch_to_embeddings() 函数获取标记化词嵌入,如下所示:

 elmo = ElmoEmbedder(options, weight, cuda_device)
 embedding, mask = elmo.batch_to_embeddings(tokened_sentences)

由于使用旧版本的 Allennlp 会影响我的整个应用程序,因此我想修改导入的库以使其正常工作。那么,我怎样才能为 Allennlp v2.10.0 保留相同的功能呢?

【问题讨论】:

    标签: python allennlp


    【解决方案1】:

    恐怕没有 1:1 等效于该功能。您能做的最好的事情就是弄清楚https://demo.allennlp.org/reading-comprehension/bidaf-elmo 是如何做到的,并在您的代码中做同样的事情。

    该模型的配置将指定一些令牌索引器和嵌入器。如果要模拟 batch_to_embeddings() 的工作方式,可以直接在代码中指定相同的内容。您不必使用配置文件。

    【讨论】:

      猜你喜欢
      • 2011-08-22
      • 2021-03-06
      • 1970-01-01
      • 2020-05-08
      • 1970-01-01
      • 2018-05-26
      • 2018-10-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多