Datasets:
Download examples/quickstart.py from uwm-software-engineering/complexity-kink-research: direct link, hf CLI and curl.
- Browser
- Download file 4.59 kB
-
https://huggingface.co/datasets/uwm-software-engineering/complexity-kink-research/resolve/main/examples/quickstart.py
- Command line
-
hf download hf://datasets/uwm-software-engineering/complexity-kink-research/examples/quickstart.py
-
curl -L -o quickstart.py https://huggingface.co/datasets/uwm-software-engineering/complexity-kink-research/resolve/main/examples/quickstart.py
4.59 kB
| """Explore the released benchmark without generating or executing model code. | |
| Install: python -m pip install pandas pyarrow | |
| Run: python quickstart.py | |
| For a local release: python quickstart.py --local-release /path/to/release | |
| """ | |
| from pathlib import Path | |
| import argparse | |
| import json | |
| import pandas as pd | |
| REPO = 'uwm-software-engineering/complexity-kink-research' | |
| REVISION = '1d1f538301d98c6e775e2ef12d9630b3b6bfd61d' | |
| def load_tables(local_release=None): | |
| """Select just the columns used by this example, from a pinned public revision.""" | |
| wanted = { | |
| 'prompts': ['prompt_id', 'ens_composite', 'construction_frame', 'task_type', | |
| 'mean_pass_rate', 'mean_harness_pass_rate'], | |
| 'generations': ['prompt_id', 'model_key', 'pass_rate', 'pass_rate_reviewed', | |
| 'harness_pass_rate'], | |
| } | |
| tables = {} | |
| for config, columns in wanted.items(): | |
| suffix = f'{config}/test-00000-of-00001.parquet' | |
| source = str(Path(local_release) / suffix) if local_release else ( | |
| f'https://huggingface.co/datasets/{REPO}/resolve/{REVISION}/{suffix}') | |
| tables[config] = pd.read_parquet(source, columns=columns) | |
| return tables['prompts'], tables['generations'] | |
| def analyze(prompts, generations): | |
| assert prompts['prompt_id'].is_unique | |
| assert not generations.duplicated(['prompt_id', 'model_key']).any() | |
| assert len(prompts) == 5000 and len(generations) == 105000 | |
| assert generations['model_key'].nunique() == 21 | |
| assert generations.groupby('prompt_id')['model_key'].nunique().eq(21).all() | |
| joined = generations.merge(prompts[['prompt_id', 'construction_frame']], | |
| on='prompt_id', how='left', validate='many_to_one') | |
| assert joined['construction_frame'].notna().all() | |
| # These are descriptive means under the historical benchmark protocol. | |
| # The primary outcome includes an LLM auditor; it is not infallible ground truth. | |
| outcomes = generations.groupby('model_key', sort=True).agg( | |
| generations=('prompt_id', 'size'), | |
| audited_primary=('pass_rate', 'mean'), | |
| reviewed_version=('pass_rate_reviewed', 'mean'), | |
| raw_harness=('harness_pass_rate', 'mean')) | |
| outcomes['primary_minus_harness_pp'] = ( | |
| outcomes['audited_primary'] - outcomes['raw_harness']) * 100 | |
| p = prompts.copy() | |
| # 14.0 is the paper's reported pooled threshold, not a new fitted model. | |
| p['above_reported_threshold'] = p['ens_composite'] > 14.0 | |
| frame = p.groupby(['construction_frame', 'above_reported_threshold']).agg( | |
| prompts=('prompt_id', 'size'), | |
| mean_index=('ens_composite', 'mean'), | |
| audited_primary=('mean_pass_rate', 'mean'), | |
| raw_harness=('mean_harness_pass_rate', 'mean')) | |
| inventory = {'prompts': len(prompts), 'generations': len(generations), | |
| 'evaluated_models': int(generations['model_key'].nunique()), | |
| 'mean_audited_primary': float(generations['pass_rate'].mean()), | |
| 'mean_reviewed_version': float(generations['pass_rate_reviewed'].mean()), | |
| 'mean_raw_harness': float(generations['harness_pass_rate'].mean())} | |
| return inventory, outcomes, frame | |
| def main(): | |
| parser = argparse.ArgumentParser(description=__doc__) | |
| parser.add_argument('--local-release', type=Path) | |
| parser.add_argument('--output', type=Path) | |
| args = parser.parse_args() | |
| inventory, outcomes, frame = analyze(*load_tables(args.local_release)) | |
| print('BENCHMARK INVENTORY\n' + json.dumps(inventory, indent=2)) | |
| print('\nOUTCOME DEFINITIONS BY MODEL (alphabetical, not a current leaderboard)') | |
| print(outcomes.round(4).to_string()) | |
| print('\nCONSTRUCTION FRAME AND THE REPORTED POOLED THRESHOLD (descriptive)') | |
| print(frame.round(4).to_string()) | |
| print('\nInterpretation: differences can reflect test quality, task mix, model settings,') | |
| print('and generation runs. They do not establish causal effects, a universal failure') | |
| print('threshold, or reliability on an unseen customer task. No generated code was run.') | |
| if args.output: | |
| result = {'inventory': inventory, | |
| 'model_outcome_definitions': outcomes.reset_index().to_dict('records'), | |
| 'frame_summary': frame.reset_index().to_dict('records'), | |
| 'public_dataset_revision': REVISION, | |
| 'loaded_from': str(args.local_release) if args.local_release else 'public pinned release'} | |
| args.output.write_text(json.dumps(result, indent=2) + '\n') | |
| if __name__ == '__main__': | |
| main() | |