pytorch_lightning.metrics.functional.nlp module¶
-
pytorch_lightning.metrics.functional.nlp.
_count_ngram
(ngram_input_list, n_gram)[source]¶ Counting how many times each word appears in a given text with ngram
-
pytorch_lightning.metrics.functional.nlp.
bleu_score
(translate_corpus, reference_corpus, n_gram=4, smooth=False)[source]¶ Calculate BLEU score of machine translated text with one or more references
- Parameters
- Return type
- Returns
Tensor with BLEU Score
Example
>>> translate_corpus = ['the cat is on the mat'.split()] >>> reference_corpus = [['there is a cat on the mat'.split(), 'a cat is on the mat'.split()]] >>> bleu_score(translate_corpus, reference_corpus) tensor(0.7598)