Spaces:
Running
Running
bleu
#2
by
awais126
- opened
- README.md +13 -13
- requirements.txt +1 -1
README.md
CHANGED
|
@@ -4,7 +4,7 @@ emoji: 🤗
|
|
| 4 |
colorFrom: blue
|
| 5 |
colorTo: red
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version: 3.
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
tags:
|
|
@@ -48,9 +48,9 @@ This metric takes as input a list of predicted sentences and a list of lists of
|
|
| 48 |
```
|
| 49 |
|
| 50 |
### Inputs
|
| 51 |
-
- **predictions** (`list
|
| 52 |
-
- **references** (`
|
| 53 |
-
- **tokenizer** : approach used for standardizing `predictions` and `references`.
|
| 54 |
The default tokenizer is `tokenizer_13a`, a relatively minimal tokenization approach that is however equivalent to `mteval-v13a`, used by WMT.
|
| 55 |
This can be replaced by another tokenizer from a source such as [SacreBLEU](https://github.com/mjpost/sacrebleu/tree/master/sacrebleu/tokenizers).
|
| 56 |
|
|
@@ -93,15 +93,15 @@ Example where each prediction has 1 reference:
|
|
| 93 |
{'bleu': 1.0, 'precisions': [1.0, 1.0, 1.0, 1.0], 'brevity_penalty': 1.0, 'length_ratio': 1.0, 'translation_length': 7, 'reference_length': 7}
|
| 94 |
```
|
| 95 |
|
| 96 |
-
Example where the
|
| 97 |
```python
|
| 98 |
>>> predictions = [
|
| 99 |
-
... "hello there general kenobi",
|
| 100 |
-
... "foo bar foobar"
|
| 101 |
... ]
|
| 102 |
>>> references = [
|
| 103 |
-
... ["hello there general kenobi", "hello there!"],
|
| 104 |
-
... ["foo bar foobar"]
|
| 105 |
... ]
|
| 106 |
>>> bleu = evaluate.load("bleu")
|
| 107 |
>>> results = bleu.compute(predictions=predictions, references=references)
|
|
@@ -114,12 +114,12 @@ Example with the word tokenizer from NLTK:
|
|
| 114 |
>>> bleu = evaluate.load("bleu")
|
| 115 |
>>> from nltk.tokenize import word_tokenize
|
| 116 |
>>> predictions = [
|
| 117 |
-
... "hello there general kenobi",
|
| 118 |
-
... "foo bar foobar"
|
| 119 |
... ]
|
| 120 |
>>> references = [
|
| 121 |
-
... ["hello there general kenobi", "hello there!"],
|
| 122 |
-
... ["foo bar foobar"]
|
| 123 |
... ]
|
| 124 |
>>> results = bleu.compute(predictions=predictions, references=references, tokenizer=word_tokenize)
|
| 125 |
>>> print(results)
|
|
|
|
| 4 |
colorFrom: blue
|
| 5 |
colorTo: red
|
| 6 |
sdk: gradio
|
| 7 |
+
sdk_version: 3.0.2
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
tags:
|
|
|
|
| 48 |
```
|
| 49 |
|
| 50 |
### Inputs
|
| 51 |
+
- **predictions** (`list` of `str`s): Translations to score.
|
| 52 |
+
- **references** (`list` of `list`s of `str`s): references for each translation.
|
| 53 |
+
- ** tokenizer** : approach used for standardizing `predictions` and `references`.
|
| 54 |
The default tokenizer is `tokenizer_13a`, a relatively minimal tokenization approach that is however equivalent to `mteval-v13a`, used by WMT.
|
| 55 |
This can be replaced by another tokenizer from a source such as [SacreBLEU](https://github.com/mjpost/sacrebleu/tree/master/sacrebleu/tokenizers).
|
| 56 |
|
|
|
|
| 93 |
{'bleu': 1.0, 'precisions': [1.0, 1.0, 1.0, 1.0], 'brevity_penalty': 1.0, 'length_ratio': 1.0, 'translation_length': 7, 'reference_length': 7}
|
| 94 |
```
|
| 95 |
|
| 96 |
+
Example where the second prediction has 2 references:
|
| 97 |
```python
|
| 98 |
>>> predictions = [
|
| 99 |
+
... ["hello there general kenobi",
|
| 100 |
+
... ["foo bar foobar"]
|
| 101 |
... ]
|
| 102 |
>>> references = [
|
| 103 |
+
... [["hello there general kenobi"], ["hello there!"]],
|
| 104 |
+
... [["foo bar foobar"]]
|
| 105 |
... ]
|
| 106 |
>>> bleu = evaluate.load("bleu")
|
| 107 |
>>> results = bleu.compute(predictions=predictions, references=references)
|
|
|
|
| 114 |
>>> bleu = evaluate.load("bleu")
|
| 115 |
>>> from nltk.tokenize import word_tokenize
|
| 116 |
>>> predictions = [
|
| 117 |
+
... ["hello there general kenobi",
|
| 118 |
+
... ["foo bar foobar"]
|
| 119 |
... ]
|
| 120 |
>>> references = [
|
| 121 |
+
... [["hello there general kenobi"], ["hello there!"]],
|
| 122 |
+
... [["foo bar foobar"]]
|
| 123 |
... ]
|
| 124 |
>>> results = bleu.compute(predictions=predictions, references=references, tokenizer=word_tokenize)
|
| 125 |
>>> print(results)
|
requirements.txt
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
git+https://github.com/huggingface/evaluate@
|
|
|
|
| 1 |
+
git+https://github.com/huggingface/evaluate@4487d9d1e65216a36b4aa94e3396a570f44a1525
|