Skip to content

Sentence CHRF silently accepts single reference as string #121

@bricksdont

Description

@bricksdont

Hi Matt, all

While trying to debug an issue related to sentence-level CHRF, I noticed that the compat function sentence_chrf expects a list of references as input, but happily accepts a single string (a list of characters). But then only uses the first character as the reference:

>>> from sacrebleu import sentence_chrf
>>> sentence_chrf("hi there", "hi there")
chrF2 = 0.455
>>> sentence_chrf("hi there", "h")
chrF2 = 0.455

While the sentence_score function for BLEU intercepts strings instead of lists of strings:

assert not isinstance(references, str), "sentence_score needs a list of references, not a single string"

the one for CHRF does not:

def sentence_score(self, hypothesis: str, references: List[str]) -> CHRFScore:

Could this perhaps be changed / standardized for all metrics?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions