Datasets:
Download scripts/score_guarded.py from Lilambd/empire-eval: direct link, hf CLI and curl.
- Browser
- Download file 877 Bytes
-
https://huggingface.co/datasets/Lilambd/empire-eval/resolve/main/scripts/score_guarded.py
- Command line
-
hf download hf://datasets/Lilambd/empire-eval/scripts/score_guarded.py
-
curl -L -o score_guarded.py https://huggingface.co/datasets/Lilambd/empire-eval/resolve/main/scripts/score_guarded.py
877 Bytes
| """score.py with one guard: a gold/prediction pair that makes score.py raise | |
| (e.g. string gold '111.242.222' vs a numeric prediction -> ValueError in | |
| float(gold)) is counted as wrong instead of crashing. Everything else, including | |
| the score.json format, is score.py unchanged. Same arguments as score.py. | |
| Used by run_baselines.sh only as a fallback when score.py itself crashes. | |
| """ | |
| import os, sys | |
| sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) | |
| import score # noqa: E402 | |
| _correct = score.correct | |
| def guarded(item, pred, lenient=False): | |
| try: | |
| return _correct(item, pred, lenient) | |
| except (ValueError, TypeError): | |
| print(f"score_guarded: {item['id']}: score.py raised on pred {pred!r}; counted wrong", file=sys.stderr) | |
| return False | |
| score.correct = guarded | |
| if __name__ == '__main__': | |
| score.main() | |