Shortcuts

torcheval.metrics.functional.word_information_preserved

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

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

Parameters:
  • 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)