Skip to content

Using Bleu for batch input #2178

@Ishan-Kumar2

Description

@Ishan-Kumar2

The example provided in docs for Bleu is for Single input. In that case the output from the engine should be in this format

def evaluate_step():
  ...
  predictions = "Predicted Sentence 1".split()
  references = ["Reference Sentence 1".split(), "Reference Sentence 1.2".split()]
  return (predictions, references)

When calculating Bleu score for a Batch what is the format for output from the engine?
It should be something like

#For a batch of size 2
predictions = ["Predicted Sentence 1".split(), "Predicted Sentence 2".split()]
references = [["Reference Sentence 1.1".split(), "Reference Sentence 1.2".split()], ["Reference Sentence 2.1".split(), "Reference Sentence 2.2".split()]]

Doing this gives an error.

TypeError: unhashable type: 'list'

The typing for update requires predictions to be a Sequence[Any] and References to be Sequence[Sequence[Any]]]. Does this mean the batch input is not possible?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions