快捷方式

torcheval.metrics.functional.word_information_preserved

torcheval.metrics.functional.word_information_preserved(input: str | List[str], target: str | List[str]) Tensor

计算预测词序列相对于参考词序列的词信息保留分数。它的类版本是 torcheval.metrics.WordInformationPreserved

参数:
  • input (str, List[str]) – 作为字符串或字符串列表的预测词序列。

  • target (str, List[str]) – 作为字符串或字符串列表的参考词序列。

示例

>>> import torch
>>> from torcheval.metrics.functional import word_information_preserved
>>> input = ["hello world", "welcome to the facebook"]
>>> target = ["hello metaverse", "welcome to meta"]
>>> word_information_preserved(input, target)
tensor(0.3)
>>> input = ["this is the prediction", "there is an other sample"]
>>> target = ["this is the reference", "there is another one"]
>>> word_information_preserved(input, target)
tensor(0.3472)

文档

访问 PyTorch 的全面开发者文档

查看文档

教程

获取适合初学者和高级开发者的深入教程

查看教程

资源

查找开发资源并获得问题的解答

查看资源