Download analysis/common/_synth_paths.py from sciminds/same-words-different-judgements: direct link, hf CLI and curl.
- Browser
- Download file 1.79 kB
-
https://huggingface.co/datasets/sciminds/same-words-different-judgements/resolve/main/analysis/common/_synth_paths.py
- Command line
-
hf download hf://datasets/sciminds/same-words-different-judgements/analysis/common/_synth_paths.py
-
curl -L -o _synth_paths.py https://huggingface.co/datasets/sciminds/same-words-different-judgements/resolve/main/analysis/common/_synth_paths.py
1.79 kB
| """ | |
| Shared resolution of per-rater synthetic-ratings tables. | |
| Every analysis that consumes synthetic ratings takes a `--model <slug>` and | |
| routes through here, so adding a rater never means editing a hardcoded path. | |
| data/main_study/synth_long_{audio,text}_table_<slug>.csv | |
| `gpt4o` falls back to the unsuffixed tables the paper was written against, so | |
| running any of these scripts with no arguments reproduces the published | |
| numbers exactly. | |
| """ | |
| from __future__ import annotations | |
| from pathlib import Path | |
| import pandas as pd | |
| STUDY = Path("data/main_study") | |
| DEFAULT_MODEL = "gpt4o" | |
| def synth_path(model: str, modality: str) -> Path: | |
| """Path to one rater's long table. modality in {'audio', 'text'}.""" | |
| path = STUDY / f"synth_long_{modality}_table_{model}.csv" | |
| if path.exists(): | |
| return path | |
| fallback = STUDY / f"synth_long_{modality}_table.csv" | |
| if model == DEFAULT_MODEL and fallback.exists(): | |
| return fallback | |
| raise FileNotFoundError( | |
| f"{path} not found. Generate it with:\n" | |
| f" python analysis/01_data_prep/03_synth_to_long_csv_multi.py " | |
| f"--model {model}" | |
| ) | |
| def load_synth(model: str, modality: str) -> pd.DataFrame: | |
| return pd.read_csv(synth_path(model, modality)) | |
| def add_model_arg(parser) -> None: | |
| parser.add_argument( | |
| "--model", default=DEFAULT_MODEL, | |
| help=f"synthetic rater slug (default: {DEFAULT_MODEL}, the published run)", | |
| ) | |
| def tag(model: str) -> str: | |
| """ | |
| Filename suffix for outputs. | |
| Empty for the default rater so the published artifacts keep their names and | |
| are overwritten in place; '_<slug>' for anything else so a new rater cannot | |
| silently clobber the paper's figures. | |
| """ | |
| return "" if model == DEFAULT_MODEL else f"_{model}" | |