Download code/scripts/ft_eval_artifacts.py from Arushhh/amlc-work: direct link, hf CLI and curl.
- Browser
- Download file 1.54 kB
-
https://huggingface.co/datasets/Arushhh/amlc-work/resolve/main/code/scripts/ft_eval_artifacts.py
- Command line
-
hf download hf://datasets/Arushhh/amlc-work/code/scripts/ft_eval_artifacts.py
-
curl -L -o ft_eval_artifacts.py https://huggingface.co/datasets/Arushhh/amlc-work/resolve/main/code/scripts/ft_eval_artifacts.py
1.54 kB
| """Stage the embed_eval artifacts for an HF-job evaluation (the L4 box is gone). | |
| Reproduces embed_f05.py's singleton sample (duckdb hash order) from parquet/{s1,gt}.parquet and checks that this duckdb | |
| build reproduces the archived eval-query selection of embed_eval.py (same hash function => same singleton sample).""" | |
| import duckdb, pandas as pd, json | |
| E = '/data/amlc/ft/eval'; P = '/data/amlc/parquet' | |
| con = duckdb.connect(); con.execute("SET threads=2; SET memory_limit='6GB'") | |
| ev = pd.read_parquet(f'{E}/embed_eval_set.parquet') | |
| out = {'duckdb': duckdb.__version__} | |
| for c in ['US', 'India']: | |
| q = con.execute(f"""SELECT s1.entity_id FROM read_parquet('{P}/s1.parquet') s1 SEMI JOIN read_parquet('{P}/pairs.parquet') p | |
| ON p.a = s1.entity_id WHERE s1.country = ? ORDER BY hash(s1.entity_id || ?) LIMIT ?""", [c, 'q42', 6000]).df() | |
| arch = set(ev.entity_id[(ev.role == 'query') & (ev.eval_country == c)]) | |
| out[f'eval_query_reproduced_{c}'] = f"{len(set(q.entity_id) & arch)}/{len(arch)}" | |
| sing = con.execute(f"""SELECT x.entity_id, x.business_name, x.business_address, x.country | |
| FROM read_parquet('{P}/gt.parquet') g JOIN read_parquet('{P}/s1.parquet') x ON x.entity_id = g.source1_entity_id | |
| WHERE g.matched_entity_ids = '' AND x.country IN ('US','India') | |
| QUALIFY row_number() OVER (PARTITION BY x.country ORDER BY hash(x.entity_id || 'sing7')) <= 400""").df() | |
| sing.to_parquet(f'{E}/f05_singletons.parquet', index=False) | |
| out['singletons'] = sing.country.value_counts().to_dict() | |
| print(json.dumps(out), flush=True) | |