Download model/ceiling.py from MSkilll/Etra: direct link, hf CLI and curl.
- Browser
- Download file 618 Bytes
-
https://huggingface.co/MSkilll/Etra/resolve/main/model/ceiling.py
- Command line
-
hf download hf://MSkilll/Etra/model/ceiling.py
-
curl -L -o ceiling.py https://huggingface.co/MSkilll/Etra/resolve/main/model/ceiling.py
618 Bytes
| # ceiling.py: how often does any passage contain a gold answer? | |
| import json | |
| from datasets import load_dataset | |
| from metrics import contains | |
| cache = json.load(open("/content/drive/MyDrive/Transformers/Alpha/hits_cache.json")) | |
| ds = load_dataset("mandarjoshi/trivia_qa", "rc.nocontext", split="validation").shuffle(seed=0).select(range(1000)) | |
| rows = [(ex, cache[ex["question"].strip()]) for ex in ds if ex["question"].strip() in cache] | |
| hit = [contains(" ".join(p for p, _ in h), [ex["answer"]["value"]] + ex["answer"]["aliases"]) for ex, h in rows] | |
| print(f"gold in passages: {sum(hit)/len(hit):.3f} of {len(hit)}") |