torcheval.metrics.functional.word_error_rate¶
- torcheval.metrics.functional.word_error_rate(input: str | List[str], target: str | List[str]) Tensor ¶
计算预测词序列与参考词序列的词错误率。其类版本为
torcheval.metrics.WordErrorRate
。- 参数:
input (str, List[str]) – 作为字符串或字符串列表的要评分的预测词序列。
target (str, List[str]) – 作为字符串或字符串列表的参考词序列。
示例
>>> import torch >>> from torcheval.metrics.functional import word_error_rate >>> input = ["hello world", "welcome to the facebook"] >>> target = ["hello metaverse", "welcome to meta"] >>> word_error_rate(input, target) tensor(0.6) >>> input = ["this is the prediction", "there is an other sample"] >>> target = ["this is the reference", "there is another one"] >>> word_error_rate(input, target) tensor(0.5)