Download render_scripts/lb_tok.py from jakeatx/llamampere-evalcache: direct link, hf CLI and curl.
- Browser
- Download file 1.06 kB
-
https://huggingface.co/datasets/jakeatx/llamampere-evalcache/resolve/main/render_scripts/lb_tok.py
- Command line
-
hf download hf://datasets/jakeatx/llamampere-evalcache/render_scripts/lb_tok.py
-
curl -L -o lb_tok.py https://huggingface.co/datasets/jakeatx/llamampere-evalcache/resolve/main/render_scripts/lb_tok.py
1.06 kB
| import json, subprocess, os, sys | |
| W=os.path.expanduser('~/evalhf_work') | |
| T=open(W+'/ds/0shot.txt',encoding='utf-8',newline='').read() | |
| d=json.load(open(W+'/ds/LongBench-v2/data.json',encoding='utf-8')) | |
| print(len(d), list(d[0].keys()), file=sys.stderr) | |
| def render(r): | |
| return T.replace('$DOC$',r['context'].strip()).replace('$Q$',r['question'].strip()).replace('$C_A$',r['choice_A'].strip()).replace('$C_B$',r['choice_B'].strip()).replace('$C_C$',r['choice_C'].strip()).replace('$C_D$',r['choice_D'].strip()) | |
| TOK='llama-tokenize' | |
| M=os.path.expanduser('~/qwen38-bench/models/swift15/ATX-Swift-1.5-Qwen3.8-27B-Uncensored-IQ4_XS-M.gguf') | |
| out={} | |
| for i,r in enumerate(d): | |
| p=render(r) | |
| if len(p)<400000 or len(p)>5_000_000: continue # 196K tokens needs >=~400K chars even for dense text? checked below via ratio | |
| o=subprocess.run([TOK,'-m',M,'--no-bos','--ids','--stdin'],input=p.encode(),capture_output=True) | |
| n=o.stdout.count(b',')+1 if o.stdout.strip() else -1 | |
| out[i]=n; print(i,len(p),n,flush=True) | |
| json.dump(out,open(W+'/lb_tok.json','w')) | |