{ "nbformat": 4, "nbformat_minor": 4, "metadata": { "colab": { "provenance": [], "gpuType": "T4" }, "kernelspec": { "name": "python3", "display_name": "Python 3" }, "language_info": { "name": "python" }, "accelerator": "GPU" }, "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# \ud83e\udde0 Cortex-System-One (0.574B) \u2014 Official Interactive Notebook\n", "**Developer**: Siddi Vinayaka ([Visthar Solutions](https://huggingface.co/siddiVinayaka/Cortex-System-One)) \n", "**Model**: `siddiVinayaka/Cortex-System-One` (0.574B parameters) \n", "**License**: CC-BY-NC-ND-4.0 \n\n", "This official interactive notebook demonstrates **Cortex-System-One**, an original from-scratch System-1 foundation architecture engineered for fast 41\u201350ms enterprise decision intelligence on commodity hardware (Tesla T4).\n\n", "---\n", "### \u26a1 Section 1: 1-Click Load & Single-Decision Inference\n", "Installs dependencies, pulls the calibrated model weights directly from Hugging Face into cache in ~15s, and runs instant inference on an enterprise invoice financial schema validation scenario." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# 1. Install dependencies\n", "!pip install -q torch tiktoken huggingface_hub\n\n", "# 2. Pull model directly from Hugging Face via repository name\n", "import sys, torch\n", "from huggingface_hub import snapshot_download\n\n", "# This pulls the architecture and full 2.21 GB weights via high-speed CDN in ~15-20s\n", "model_dir = snapshot_download(\"siddiVinayaka/Cortex-System-One\")\n", "sys.path.append(model_dir)\n\n", "from inference import load_cortex_model, predict_decision\n\n", "# 3. Load Model onto GPU\n", "device = torch.device(\"cuda\" if torch.cuda.is_available() else \"cpu\")\n", "model, calibration = load_cortex_model(model_dir, device=device)\n\n", "# 4. Run Instant Decision Inference (41\u201350ms on Tesla T4)\n", "prompt = (\n", " \"Workflow: Invoice Processing\\n\"\n", " \"Task State: {\\\"invoice_id\\\":\\\"INV-9421\\\",\\\"subtotal\\\":1000.0,\\\"tax\\\":180.0,\\\"total\\\":1500.0}\\n\\n\"\n", " \"Task: Determine invoice validation status.\\n\"\n", " \"Options:\\n\"\n", " \"(A) Flag total calculation mismatch for manual accounting review\\n\"\n", " \"(B) Approve payment immediately with automated clearance\\n\"\n", " \"(C) Mark invoice as duplicate submission\\n\\n\"\n", " \"Analyze the state and select the correct option.\\nAnswer:\"\n", ")\n\n", "options = [\n", " \"Flag total calculation mismatch for manual accounting review\",\n", " \"Approve payment immediately with automated clearance\",\n", " \"Mark invoice as duplicate submission\"\n", "]\n\n", "result = predict_decision(model, prompt, options, calibration=calibration, device=device)\n", "confidence = result.get('confidence', result['probabilities'][result['predicted_option']])\n", "latency = result.get('latency_ms', None)\n\n", "print(\"\\n\" + \"=\"*55)\n", "print(f\"\ud83c\udfaf Cortex-System-One Decision : {result['predicted_option']}\")\n", "print(f\"\u26a1 Decision Confidence Score : {confidence*100:.2f}%\")\n", "if latency is not None:\n", " print(f\"\u23f1\ufe0f Decision Latency : {latency:.2f} ms\")\n", "print(f\"\ud83d\udcca Full Distribution : {result['probabilities']}\")\n", "print(\"=\"*55)\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "---\n", "### \ud83c\udfc6 Section 2: Official S1MB Typed Decisions Benchmark Reproduction\n", "This cell executes the official **S1MB (System 1 Model Benchmark)** Typed Decisions suite (`laya__typed_decisions`) across all 100 interleaved cases (500 decisions) covering:\n", "1. **Choice** (148 decisions): Multi-option categorical selection\n", "2. **Noul** (152 decisions): Binary proposition verification & truth-value auditing\n", "3. **Score** (200 decisions): Continuous severity and risk valuation rating\n\n", "**Key Architectural Features Evaluated**:\n", "- **Continuous Neural Dynamic Memory**: 128 dynamic memory slots streamed across cross-layer bridges (Layers 3, 10, 17) to carry operational context across multi-step agent decisions.\n", "- **Decoupled Decision Heads**: Dedicated projection heads for Choice, Noul, and Score to eliminate cross-task gradient interference.\n\n", "Run the cell below to reproduce the verified **45.04% S1MB Task Average** (#2 globally) and **72.28% Raw Accuracy**." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# 1. Download official benchmark reproduction script\n", "from huggingface_hub import hf_hub_download\n\n", "script_path = hf_hub_download(repo_id=\"siddiVinayaka/Cortex-System-One\", filename=\"benchmark_s1mb_official.py\")\n\n", "# 2. Run benchmark with PYTHONPATH pointing to model cache\n", "!PYTHONPATH={model_dir} python {script_path} \\\n", " --checkpoint {model_dir}/ckpt_cortex_system_one_champion.pth \\\n", " --calibration {model_dir}/cortex_system_one_calibration.json \\\n", " --suite typed_decisions \\\n", " --device cuda\n" ] } ] }