Shortcuts

torcheval.metrics.functional.word_information_preserved

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

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)

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources