torcheval.metrics.functional.word_information_preserved¶
- torcheval.metrics.functional.word_information_preserved(input: str | List[str], target: str | List[str]) Tensor ¶
Compute the word information preserved score of the predicted word sequence(s) against the reference word sequence(s). Its class version is
torcheval.metrics.WordInformationPreserved
.- Parameters:
input (str, List[str]) – Predicted word sequence(s) to score as a string or list of strings.
target (str, List[str]) – Reference word sequence(s) as a string or list of strings.
Examples
>>> 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)