File size: 1,498 Bytes
08a9326
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
"""Offline native-token and prompt checks before freezing the pilot."""
import json
from encoding_tax.common import ROOT,load_config,write_json,digest,now,READERS
from encoding_tax.data import load_rows
from encoding_tax.tokenization import tokenizer
from encoding_tax.prompts import serialize,continue_answer
from .design import HERE,cases,truth,body,case_id

def main():
    cfg=load_config(str(HERE/'config.json'));base=load_config()
    rows=load_rows({'datasets':{'synthetic':cfg['dataset']}},'synthetic','pilot')
    results={}
    for reader in READERS:
        p=base['models'][reader];tok=tokenizer(p['tokenizer_repo'],p['tokenizer_revision'])
        maxanswer=0;maxprompt=0
        for m in cases(rows,reader):
            text,_=body(m,base);raw=serialize(p,text,'scratchpad');count=tok.count(raw)
            maxprompt=max(maxprompt,count)
            assert count+m['budget']+48+64<p['context_length'],case_id(m)
            if m['mode']=='diagnostic':
                n=tok.count(json.dumps(truth(m),separators=(',',':')));maxanswer=max(maxanswer,n)
                assert n<=48,case_id(m)
        results[reader]={'samples':1824,'maximum_initial_prompt_tokens':maxprompt,'maximum_canonical_diagnostic_tokens':maxanswer,'answer_cap':48,'context_verified':True}
        print(reader,results[reader],flush=True)
    write_json(HERE/'validation.json',{'recorded_at':now(),'offline_only':True,'config_sha256':digest(HERE/'config.json'),'readers':results})
if __name__=='__main__':main()