Nous.Eval.Scorers.Similarity (nous v0.21.1)

Copy Markdown View Source

Scores the output's similarity to the expected text as a Levenshtein ratio over graphemes: 1 - distance / max(length), a float in 0.0..1.0.

{Nous.Eval.Scorers.Similarity, expected: "The capital is Paris", threshold: 0.9}

Options

  • :expected - the expected text; when absent, the case's expected["output"]
  • :threshold - passed? when the ratio is at least this (default 0.8)
  • :max_len - the longest text (in graphemes) compared, default 2_000. Levenshtein is quadratic, so a longer output or expectation is an :invalid_config error instead of a long stall
  • :case_sensitive (default true), :trim (default true), :collapse_whitespace (default false) - as in Nous.Eval.Scorers.Equals

A failed run fails with reason "run_failed"; non-text output is an :invalid_config error.