Spaces:
Runtime error
Runtime error
A newer version of the Gradio SDK is available:
5.4.0
metadata
title: Token Edit Distance
emoji: 🐠
colorFrom: pink
colorTo: yellow
sdk: gradio
sdk_version: 3.42.0
app_file: app.py
pinned: true
Token Edit Distance
This is an NLP evaluation metric that records the minimum number of token edits (insertions, deletions, and replacements, all weighted equally) to the prediction string in order to make it exactly match the reference string. Uses identical logic to Levenshtein Edit Distance, except applied to tokens (i.e. individual ints in a list) as opposed to individual characters in a string.
Args:
- predictions:
List[List[Int]]
, list of predictions to score.- Each prediction should be tokenized into a list of tokens.
- references:
List[List[Int]]
, list of references/ground truth output to score against.- Each reference should be tokenized into a list of tokens.
Returns:
- "avg_token_edit_distance":
Float
, average Token Edit Distance for all inputted predictions and references - "token_edit_distances":
List[Int]
, the Token Edit Distance for each inputted prediction and reference
Examples:
>>> token_edit_distance_metric = datasets.load_metric('Token Edit Distance')
>>> references = [[15, 4243], [100, 10008]]
>>> predictions = [[15, 4243], [100, 10009]]
>>> results = token_edit_distance_metric.compute(predictions=predictions, references=references)
>>> print(results)
{'avg_token_edit_distance': 0.5, 'token_edit_distances': array([0. 1.])}