Download tinyquery/manual_eval.py from karmx/TinyQuery-140M: direct link, hf CLI and curl.
- Browser
- Download file 5.39 kB
-
https://huggingface.co/karmx/TinyQuery-140M/resolve/main/tinyquery/manual_eval.py
- Command line
-
hf download hf://karmx/TinyQuery-140M/tinyquery/manual_eval.py
-
curl -L -o manual_eval.py https://huggingface.co/karmx/TinyQuery-140M/resolve/main/tinyquery/manual_eval.py
5.39 kB
| """Independently authored phrasings held out from teacher generation and training.""" | |
| import json | |
| from pathlib import Path | |
| from tinyquery.data import serialize | |
| PHRASES={ | |
| 'all':['I need everything in {table}.','all {table} pls','{table} का सारा डेटा चाहिए।','{table} ka sara data chahiye'], | |
| 'project':['Just the {column} values from {table}, please.','{table} only {column} show','{table} से सिर्फ {column} दिखाना।','bas {table} ke {column} dikha do'], | |
| 'project_eq':['In {table}, give me {column} for {category} {value}.','{table} {category} {value} only {column}','{table} में {category} {value} हो तो उनका {column} बताओ।','{table} me {category} {value} walon ka {column} batao'], | |
| 'gt':['Which {table} entries have {numeric} above {number}?','{table} {numeric} more than {number}','{table} में किनका {numeric} {number} से ज़्यादा है?','{table} me {numeric} {number} se upar wale kaun hain'], | |
| 'gte':['Include {table} records at {number} or above in {numeric}.','{table} {numeric} minimum {number} include same','{table} में {numeric} कम से कम {number} होना चाहिए।','{table} me {numeric} kam se kam {number} ho'], | |
| 'lt':['Find {table} records below {number} in {numeric}.','{table} {numeric} less {number}','{table} में {numeric} {number} से कम वाले रिकॉर्ड लाओ।','{table} me {numeric} {number} se kam wale lao'], | |
| 'lte':['From {table}, include {numeric} values up to and including {number}.','{table} {numeric} max {number} equal also','{table} में {numeric} {number} या उससे कम हो।','{table} me {numeric} {number} ya usse kam ho'], | |
| 'count':['How big is {table}, measured in rows?','{table} total rows how much','{table} में कुल कितनी पंक्तियाँ हैं?','{table} me total kitni rows hain'], | |
| 'sum':['Add up {numeric} across {table}.','{table} {numeric} all add','{table} के {numeric} का जोड़ बताओ।','{table} ke {numeric} ka jod batao'], | |
| 'avg':['What does {numeric} average out to in {table}?','{table} avg {numeric} tell','{table} में {numeric} का औसत क्या है?','{table} me {numeric} ka average kya hai'], | |
| 'top':['Give me {limit} entries in {table} with the largest {numeric}, largest first.','{table} top {limit} by {numeric} big first','{table} में सबसे ज़्यादा {numeric} वाली {limit} पंक्तियाँ घटते क्रम में दिखाओ।','{table} me sabse bade {numeric} wali {limit} rows descending dikhao'], | |
| 'group_count':['Break down the number of {table} rows by {category}.','{table} count per {category}','{table} में हर {category} की गिनती अलग-अलग बताओ।','{table} me har {category} ki count alag batao'], | |
| 'distinct':['Which different {category} values occur in {table}?','{table} {category} unique only','{table} में {category} के अलग-अलग मान कौन से हैं?','{table} me {category} ki unique values kya hain'], | |
| 'null':['Find {table} records with no {column} value (NULL).','{table} {column} null records','{table} में जिनका {column} NULL है वे रिकॉर्ड दिखाओ।','{table} me jinka {column} NULL hai wo dikhao'], | |
| 'list_tables':['What tables can I query here?','tables here list','यहाँ कौन-कौन सी टेबल हैं?','yahan kaunsi tables hain'], | |
| 'ambiguous':['Pick the best entries in {table}.','{table} best ones','{table} में सबसे अच्छे रिकॉर्ड चुनो।','{table} me best records chun lo'], | |
| 'weather':['What is the weather like in {city}? Use {unit}.','{city} weather {unit} pls','{city} का मौसम {unit} में बताओ।','{city} ka weather {unit} me batao'], | |
| 'read_file':['Open {path} and read its text.','{path} read pls','{path} फ़ाइल पढ़कर दिखाओ।','{path} file padh kar dikhao'], | |
| 'search':['Find documentation about {query}.','docs find {query}','{query} के बारे में दस्तावेज़ खोजो।','{query} ke bare me docs dhundho'], | |
| 'ticket':['Fetch the details for ticket {ticket_id}.','ticket {ticket_id} details','टिकट {ticket_id} का विवरण लाओ।','ticket {ticket_id} ki details lao'], | |
| } | |
| def main(): | |
| base=Path('data/tinyquery'); cases={} | |
| for line in (base/'test.jsonl').read_text().splitlines(): | |
| r=json.loads(line) | |
| key=(r['operation'],r['language'],r['backend']) | |
| if r['operation'] in PHRASES and key not in cases: cases[key]=r | |
| with (base/'manual.jsonl').open('w') as stream: | |
| for (op,lang,backend),r in cases.items(): | |
| index=['en','noisy_en','hi','hinglish'].index(lang) | |
| r['question']=PHRASES[op][index].format(**r['slots']) | |
| r['prompt']=serialize(r['context'],r['question']); r['id']='manual_'+r['id'] | |
| r['provenance']='Assistant-authored held-out phrasing; never sent to teacher or used in training' | |
| stream.write(json.dumps(r,ensure_ascii=False)+'\n') | |
| print('manual cases',len(cases)) | |
| if __name__=='__main__': main() | |