{ "nbformat": 4, "nbformat_minor": 5, "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "name": "python" } }, "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Explore Complexity Kink in a few minutes\n", "\n", "Michael Hernandez and Tian Zhao. Dataset: https://huggingface.co/datasets/uwm-software-engineering/complexity-kink-research\n", "\n", "Paper: https://arxiv.org/abs/2609.19616\n", "\n", "Start with three questions: what is in the benchmark, how do outcome definitions differ, and how does construction frame affect a pooled pattern? These examples use existing results. They do not call an LLM or execute generated code.\n", "\n", "Install dependencies in your notebook environment with `%pip install pandas pyarrow` before running. The public loader downloads just the prompts and generations tables at a pinned revision.\n" ], "id": "kink-start-00" }, { "cell_type": "code", "metadata": {}, "source": [ "from pathlib import Path\n", "import argparse\n", "import json\n", "import pandas as pd\n", "\n", "REPO = 'uwm-software-engineering/complexity-kink-research'\n", "REVISION = '1d1f538301d98c6e775e2ef12d9630b3b6bfd61d'\n", "\n", "\n", "def load_tables(local_release=None):\n", " \"\"\"Select just the columns used by this example, from a pinned public revision.\"\"\"\n", " wanted = {\n", " 'prompts': ['prompt_id', 'ens_composite', 'construction_frame', 'task_type',\n", " 'mean_pass_rate', 'mean_harness_pass_rate'],\n", " 'generations': ['prompt_id', 'model_key', 'pass_rate', 'pass_rate_reviewed',\n", " 'harness_pass_rate'],\n", " }\n", " tables = {}\n", " for config, columns in wanted.items():\n", " suffix = f'{config}/test-00000-of-00001.parquet'\n", " source = str(Path(local_release) / suffix) if local_release else (\n", " f'https://huggingface.co/datasets/{REPO}/resolve/{REVISION}/{suffix}')\n", " tables[config] = pd.read_parquet(source, columns=columns)\n", " return tables['prompts'], tables['generations']\n", "\n" ], "execution_count": null, "outputs": [], "id": "kink-start-01" }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 1. Load a fixed release\n", "\n", "Use the public dataset by default. If you already have that release locally, pass its root directory to `load_tables(local_release=...)`.\n" ], "id": "kink-start-02" }, { "cell_type": "code", "metadata": {}, "source": [ "prompts, generations = load_tables()\n", "print(len(prompts), \"prompts;\", len(generations), \"generations\")\n" ], "execution_count": null, "outputs": [], "id": "kink-start-03" }, { "cell_type": "code", "metadata": {}, "source": [ "def analyze(prompts, generations):\n", " assert prompts['prompt_id'].is_unique\n", " assert not generations.duplicated(['prompt_id', 'model_key']).any()\n", " assert len(prompts) == 5000 and len(generations) == 105000\n", " assert generations['model_key'].nunique() == 21\n", " assert generations.groupby('prompt_id')['model_key'].nunique().eq(21).all()\n", " joined = generations.merge(prompts[['prompt_id', 'construction_frame']],\n", " on='prompt_id', how='left', validate='many_to_one')\n", " assert joined['construction_frame'].notna().all()\n", " # These are descriptive means under the historical benchmark protocol.\n", " # The primary outcome includes an LLM auditor; it is not infallible ground truth.\n", " outcomes = generations.groupby('model_key', sort=True).agg(\n", " generations=('prompt_id', 'size'),\n", " audited_primary=('pass_rate', 'mean'),\n", " reviewed_version=('pass_rate_reviewed', 'mean'),\n", " raw_harness=('harness_pass_rate', 'mean'))\n", " outcomes['primary_minus_harness_pp'] = (\n", " outcomes['audited_primary'] - outcomes['raw_harness']) * 100\n", " p = prompts.copy()\n", " # 14.0 is the paper's reported pooled threshold, not a new fitted model.\n", " p['above_reported_threshold'] = p['ens_composite'] > 14.0\n", " frame = p.groupby(['construction_frame', 'above_reported_threshold']).agg(\n", " prompts=('prompt_id', 'size'),\n", " mean_index=('ens_composite', 'mean'),\n", " audited_primary=('mean_pass_rate', 'mean'),\n", " raw_harness=('mean_harness_pass_rate', 'mean'))\n", " inventory = {'prompts': len(prompts), 'generations': len(generations),\n", " 'evaluated_models': int(generations['model_key'].nunique()),\n", " 'mean_audited_primary': float(generations['pass_rate'].mean()),\n", " 'mean_reviewed_version': float(generations['pass_rate_reviewed'].mean()),\n", " 'mean_raw_harness': float(generations['harness_pass_rate'].mean())}\n", " return inventory, outcomes, frame\n", "\n" ], "execution_count": null, "outputs": [], "id": "kink-start-04" }, { "cell_type": "code", "metadata": {}, "source": [ "inventory, outcome_definitions, frame_summary = analyze(prompts, generations)\n", "inventory\n" ], "execution_count": null, "outputs": [], "id": "kink-start-05" }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 2. Compare definitions, rather than assuming every test verdict is ground truth\n", "\n", "`pass_rate` is the camera-ready audited primary outcome, with harness fallback for uncertain or unparseable audits. `pass_rate_reviewed` records the reviewed version. `harness_pass_rate` is the original test-execution fraction. Neither the harness nor the LLM auditor is infallible. The table is alphabetical and is not a current model leaderboard.\n" ], "id": "kink-start-06" }, { "cell_type": "code", "metadata": {}, "source": [ "outcome_definitions.round(4)\n" ], "execution_count": null, "outputs": [], "id": "kink-start-07" }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 3. Inspect construction frame\n", "\n", "The 14.0 split comes from the paper; this example does not estimate a new breakpoint. Source frames differ in task mix, test quality, and generation runs. These descriptive groups do not isolate causal effects or establish a universal failure threshold.\n" ], "id": "kink-start-08" }, { "cell_type": "code", "metadata": {}, "source": [ "frame_summary.round(4)\n" ], "execution_count": null, "outputs": [], "id": "kink-start-09" }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Try your own question\n", "\n", "Compare another prompt-side metric, inspect task types, or study auditor/harness disagreements. Use independent development and held-out partitions for any learned predictor; group related tasks before splitting. Historical scores do not validate reliability on a new customer task.\n", "\n", "This is an evaluation dataset. Follow the dataset card's evaluation-only scope and provider terms, and do not execute released model-generated code outside an isolated sandbox. Cite the paper and OpenCodeInstruct as described in the dataset card.\n", "\n", "Verification: the companion Python analysis was run on local Parquet files whose SHA-256 hashes match the pinned public release. This notebook is supplied with empty outputs so readers can run it in their own environment.\n" ], "id": "kink-start-10" } ] }