{ "cells": [ { "id": "title", "cell_type": "markdown", "metadata": {}, "source": "# Evaluate TheSystem\nCompare Probe-256, LoRA and original Qwen on the same five benchmarks, then check `` routing and generation preservation. No training is performed.\n" }, { "id": "prerequisites", "cell_type": "markdown", "metadata": {}, "source": "## Before you start\nChoose **Runtime → Change runtime type** and select a GPU with native BF16 support, such as **L4** or **A100**. Use Python 3.12 or 3.13. Have a Hugging Face read token for both model repositories and `TheSystem-Data` ready.\n" }, { "id": "prepare-intro", "cell_type": "markdown", "metadata": {}, "source": "## 1. Prepare runtime\nRun this cell and enter your read token. If setup asks for a restart, choose **Runtime → Restart session**. When Colab reconnects, click **Run all**. If you see **READY**, continue to step 2.\n" }, { "id": "prepare-runtime", "cell_type": "code", "metadata": { "cellView": "form", "jupyter": { "source_hidden": true } }, "source": "# @title Prepare runtime\nRUNTIME_READY = OUTPUT_READY = RESOURCES_READY = False\nimport getpass, hashlib, json, os, sys\nfrom pathlib import Path\nfrom urllib.request import Request, urlopen\nfrom urllib.error import HTTPError, URLError\n\nPREPARE = {'repo_id': 'Lbuk/TheSystem-9B-Probe-256', 'revision': 'd66b3452f760f9efa5ba8ffecfb6b1759a94f9ff', 'sha256': 'f2a68dee15d95d2a9bda090e69c50232b1fb245da6e68b49ea4dd7f9d938f1b5'}\nif not globals().get(\"RESTART_PENDING\", False):\n if sys.version_info[:2] not in ((3, 12), (3, 13)):\n raise RuntimeError(\"Use Python 3.12 or 3.13: Colab Runtime → Change runtime type → the latest runtime version.\")\n os.environ[\"HF_TOKEN\"] = getpass.getpass(\"Hugging Face read token (hidden; Enter only for public access): \").strip()\n print(\"Downloading setup…\", flush=True)\n url = f\"https://huggingface.co/{PREPARE['repo_id']}/resolve/{PREPARE['revision']}/prepare_evaluation.py\"\n headers = {\"Authorization\": f\"Bearer {os.environ['HF_TOKEN']}\"} if os.environ[\"HF_TOKEN\"] else {}\n try:\n with urlopen(Request(url, headers=headers), timeout=30) as response:\n helper = response.read()\n except HTTPError as error:\n raise RuntimeError(\"Setup download failed. For HTTP 401/403, rerun this cell and paste a valid read token for this private repository. \"\n f\"HTTP status: {error.code}. Your browser login is separate from Colab.\") from None\n except (URLError, TimeoutError) as error:\n raise RuntimeError(\"Setup helper download failed or timed out. Check the connection and rerun Prepare runtime.\") from None\n if hashlib.sha256(helper).hexdigest() != PREPARE[\"sha256\"]:\n raise RuntimeError(\"Setup helper checksum mismatch. Stop and obtain a fresh release notebook.\")\n _setup = {\"__name__\": \"thesystem_evaluation_setup\"}\n exec(compile(helper, \"prepare_evaluation.py\", \"exec\"), _setup)\n visible_progress = _setup[\"visible_progress\"]\n RUNTIME_READY = _setup[\"prepare_runtime\"]()\n RESTART_PENDING = not RUNTIME_READY\n\nif RESTART_PENDING:\n from IPython.display import Markdown, clear_output, display\n clear_output(wait=True)\n display(Markdown(\"**Setup saved. Choose Runtime → Restart session.** \\nAfter Colab reconnects, click **Run all**.\"))\n", "execution_count": null, "outputs": [] }, { "id": "storage-intro", "cell_type": "markdown", "metadata": {}, "source": "## 2. Choose run and save location\nLeave `SMOKE = False` for the full evaluation; `True` runs a small mechanics check in a separate `-smoke` folder. Results default to **Colab local storage**; no Drive access is requested unless you select `USE_DRIVE = True`.\n\nLocal Colab files disappear when the runtime is deleted. Download your results in step 5 before confirming shutdown; optional Drive storage preserves progress across sessions. All model weights and datasets come from Hugging Face.\n" }, { "id": "configure-job", "cell_type": "code", "metadata": { "cellView": "form", "jupyter": { "source_hidden": true } }, "source": "# @title Choose run and save location\nRUN_NAME = \"release-evaluation-rc4\" # @param {type:\"string\"}\nSMOKE = False # @param {type:\"boolean\"}\nUSE_DRIVE = False # @param {type:\"boolean\"}\n\nif not globals().get(\"RESTART_PENDING\", False):\n if not globals().get(\"RUNTIME_READY\", False):\n raise RuntimeError(\"Run Prepare runtime until it reports READY first.\")\n OUTPUT_READY = RESOURCES_READY = False\n from datetime import datetime, timezone\n from thesystem.evaluation import evaluate\n if SMOKE:\n RUN_NAME += \"-smoke\"\n OUTPUT, CACHE, IN_COLAB, runtime = _setup[\"prepare_output\"](RUN_NAME, USE_DRIVE)\n def run_job():\n return evaluate(RESOURCE_ROOT, OUTPUT, cache=CACHE, smoke=SMOKE)\n OUTPUT_READY = True\n print(\"Selected:\", \"QUICK CHECK — not benchmark scores\" if SMOKE else \"FULL EVALUATION — all 1,648 benchmark examples per model\")\n", "execution_count": null, "outputs": [] }, { "id": "data-intro", "cell_type": "markdown", "metadata": {}, "source": "## 3. Download resources\nDownload and checksum-verify the exact model assets, tokenizer and datasets. Downloads stay on local runtime disk, while new results go to the output folder chosen above; the pinned Qwen backbone loads when evaluation starts.\n" }, { "id": "release-resources", "cell_type": "code", "metadata": { "cellView": "form", "jupyter": { "source_hidden": true } }, "source": "# @title Download resources\nif not globals().get(\"RESTART_PENDING\", False):\n if not globals().get(\"RUNTIME_READY\", False) or not globals().get(\"OUTPUT_READY\", False):\n raise RuntimeError(\"Complete Prepare runtime and Choose run and save location first.\")\n RESOURCES_READY = False\n from thesystem.artifacts import resolve_release_resources\n with visible_progress(\"Download and verify release resources\"):\n RESOURCE_ROOT = resolve_release_resources()\n print(\"Verified release resources:\", RESOURCE_ROOT)\n RESOURCES_READY = True\n", "execution_count": null, "outputs": [] }, { "id": "run-intro", "cell_type": "markdown", "metadata": {}, "source": "## 4. Run evaluation and view results\nModels run one at a time with live logs and heartbeats. The table below follows the website: Benchmark, `` + LoRA, `` + Probe-256, Bespoke-Nimble-9B and Jev 1.13.0; original Qwen, routing and generation details remain in the downloaded report.\n\nResults and status are saved locally even after a handled failure. **This cell never shuts down the runtime.** After a failure, run step 5 to download partial results and logs.\n" }, { "id": "run-and-shutdown", "cell_type": "code", "metadata": { "cellView": "form", "jupyter": { "source_hidden": true } }, "source": "# @title Run evaluation and save results\nif not globals().get(\"RESTART_PENDING\", False):\n if not all(globals().get(name, False) for name in (\"RUNTIME_READY\", \"OUTPUT_READY\", \"RESOURCES_READY\")):\n raise RuntimeError(\"Complete steps 1–3 before running evaluation.\")\n status = \"failed\"\n started = datetime.now(timezone.utc).isoformat()\n try:\n RESULT_ROOT = run_job()\n summary_path = Path(RESULT_ROOT) / \"SUMMARY.json\"\n summary = json.loads(summary_path.read_text())\n if not summary.get(\"complete\"):\n raise RuntimeError(\"The workflow did not report complete; inspect saved logs before claiming success.\")\n status = \"completed\"\n print(\"Completed. Results and logs are saved in:\", RESULT_ROOT)\n print(\"Run type:\", \"SMOKE CHECK — not full results\" if SMOKE else \"FULL EVALUATION\")\n print(\"Report:\", Path(RESULT_ROOT) / \"REPORT.html\")\n print(\"Score table:\", Path(RESULT_ROOT) / \"comparison.csv\")\n print(\"Summary:\", summary_path)\n finally:\n # If this persistent write fails, do not disconnect the runtime.\n record = {\"status\": status, \"started_utc\": started,\n \"finished_utc\": datetime.now(timezone.utc).isoformat(),\n \"run_name\": RUN_NAME, \"output\": str(OUTPUT)}\n with (OUTPUT / \"notebook-status.json\").open(\"w\") as handle:\n json.dump(record, handle, indent=2)\n handle.flush()\n os.fsync(handle.fileno())\n\n _setup[\"show_results\"](OUTPUT)\n", "execution_count": null, "outputs": [] }, { "id": "finish-intro", "cell_type": "markdown", "metadata": {}, "source": "## 5. Download results and finish\nClick **Download results ZIP** and open it on your computer. Then tick the confirmation and click **Shut down runtime**. If the buttons are missing, use the [download instructions](https://github.com/bqpro1/TheSystem/blob/main/docs/REPRODUCIBILITY.md#evaluation-results-and-storage).\n" }, { "id": "download-and-finish", "cell_type": "code", "metadata": { "cellView": "form" }, "execution_count": null, "outputs": [], "source": "# @title Download results and finish\nif globals().get(\"RESTART_PENDING\", False):\n print(\"Paused at step 1. Choose Runtime → Restart session, then Run all.\")\nelse:\n if not globals().get(\"OUTPUT_READY\", False):\n raise RuntimeError(\"Choose an output folder first.\")\n finish_controls = _setup[\"finish_controls\"](OUTPUT)\n" }, { "id": "results-guide", "cell_type": "markdown", "metadata": {}, "source": "## Reading your results\nThe full run measures VitaminC (599), PAWS (250), SQuAD2 answerability (299), Aegis2 (250) and PubMedQA (250), plus the 4,000-request internal routing test, external routing checks and 45 writing prompts. Automatic accuracy counts routing errors; generation checks compare output tokens with original Qwen and report truncation.\n\nNimble/Jev scores are published references with different prompt wrappers; internal tests were inspected during development, and PubMedQA uses the publisher's subset rather than the official leaderboard split. See the [evaluation guide](https://github.com/bqpro1/TheSystem/blob/main/docs/EVALUATION.md) for interpretation; a quick check is not a full benchmark result.\n" } ], "metadata": { "kernelspec": { "display_name": "Python 3 (Linux NVIDIA GPU)", "language": "python", "name": "python3" }, "language_info": { "name": "python", "version": "3.12" }, "thesystem": { "release": "0.1.0rc4", "gpu_required": true, "private_staging": true, "bootstrap_finalized": true }, "colab": { "name": "03-Reproduce-Evaluation.ipynb", "provenance": [] } }, "nbformat": 4, "nbformat_minor": 5 }