Spaces:
Sleeping
Sleeping
Download scripts/prepare_v2_training.py from xstard/decision-model: direct link, hf CLI and curl.
- Browser
- Download file 2.08 kB
-
https://huggingface.co/spaces/xstard/decision-model/resolve/main/scripts/prepare_v2_training.py
- Command line
-
hf download hf://spaces/xstard/decision-model/scripts/prepare_v2_training.py
-
curl -L -o prepare_v2_training.py https://huggingface.co/spaces/xstard/decision-model/resolve/main/scripts/prepare_v2_training.py
2.08 kB
| """Reuse audited train families; derive transparent, train-only contrasts.""" | |
| from pathlib import Path | |
| import shutil | |
| from decision_model.data import DecisionExample,read_jsonl,write_jsonl | |
| output=Path('data/v2');output.mkdir(exist_ok=True) | |
| train=[r for r in read_jsonl('data/processed/train.jsonl',DecisionExample) if r.reviewed and r.reviewer.strip()] | |
| derived=[] | |
| for row in train: | |
| if row.question.type=='noul' and row.demo: | |
| positive=row.gold==1 | |
| prefix=(('Верніть мені гроші, будь ласка. ' if positive else 'Я не прошу повертати гроші. ') if row.language=='uk' | |
| else ('Please send my money back. ' if positive else 'I am not asking for a refund. ')) | |
| derived.append(row.model_copy(update={'id':row.id+':refund_contrast','state':prefix+row.state,'demo':False, | |
| 'source':row.source+';derived-refund-polarity-contrast','reviewer':'Codex derived semantic contrast review (AI), 2026-11-24'})) | |
| if row.question.type=='score' and row.gold==0: | |
| # All source scales have gold=0 iff the underlying ticket is neutral. | |
| # Direct insult is aggression=4; retain the source family and main request. | |
| prefix='Ви шахраї! ' if row.language=='uk' else 'You are scammers! ' | |
| derived.append(row.model_copy(update={'id':row.id+':insult_contrast','state':prefix+row.state, | |
| 'gold':len(row.question.criteria)-1,'demo':False,'source':row.source+';derived-direct-insult', | |
| 'reviewer':'Codex derived semantic contrast review (AI), 2026-11-24'})) | |
| write_jsonl(output/'train.jsonl',train+derived) | |
| valid=[r for r in read_jsonl('data/processed/validation.jsonl',DecisionExample) | |
| if r.question.type!='score' or (r.reviewed and r.reviewer.strip())] | |
| write_jsonl(output/'validation.jsonl',valid) | |
| shutil.copyfile('data/processed/calibration.jsonl',output/'calibration.jsonl') | |
| print({'audited_training_questions':len(train),'derived_questions':len(derived),'train_total':len(train+derived), | |
| 'validation':len(valid),'test':'not generated/opened'}) | |