Download probes/tok_shape.py from Cion-lab/ounce100m-code: direct link, hf CLI and curl.
- Browser
- Download file 608 Bytes
-
https://huggingface.co/Cion-lab/ounce100m-code/resolve/main/probes/tok_shape.py
- Command line
-
hf download hf://Cion-lab/ounce100m-code/probes/tok_shape.py
-
curl -L -o tok_shape.py https://huggingface.co/Cion-lab/ounce100m-code/resolve/main/probes/tok_shape.py
608 Bytes
| import json | |
| d = json.load(open("tmp_tok.json", encoding="utf-8")) | |
| v = (d.get("model") or {}).get("vocab") or {} | |
| lt, gt = chr(60), chr(62) | |
| unk = lt + "unk" + gt | |
| endo = lt + "endoftext" + gt | |
| print("model type:", (d.get("model") or {}).get("type"), "| vocab size:", len(v)) | |
| print("added ids:", [t.get("id") for t in d.get("added_tokens", [])]) | |
| print("added:", [t.get("content") for t in d.get("added_tokens", [])]) | |
| print("unk in vocab:", unk in v, "| endoftext in vocab:", endo in v) | |
| print("id of endoftext:", v.get(endo)) | |
| print("contiguous 0..N-1:", sorted(int(i) for i in v.values()) == list(range(len(v)))) | |