Instructions to use mindsofchaos/codeoptics-coder-3b-v4 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use mindsofchaos/codeoptics-coder-3b-v4 with Transformers:
# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("mindsofchaos/codeoptics-coder-3b-v4", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use mindsofchaos/codeoptics-coder-3b-v4 with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf mindsofchaos/codeoptics-coder-3b-v4:Q4_K_M # Run inference directly in the terminal: llama cli -hf mindsofchaos/codeoptics-coder-3b-v4:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf mindsofchaos/codeoptics-coder-3b-v4:Q4_K_M # Run inference directly in the terminal: llama cli -hf mindsofchaos/codeoptics-coder-3b-v4:Q4_K_M
Build from source code
git clone https://github.com/ggml-org/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-app # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama serve -hf mindsofchaos/codeoptics-coder-3b-v4:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama cli -hf mindsofchaos/codeoptics-coder-3b-v4:Q4_K_M
Use Docker
docker model run hf.co/mindsofchaos/codeoptics-coder-3b-v4:Q4_K_M
- Llama new
- LM Studio
- Jan
- Ollama
How to use mindsofchaos/codeoptics-coder-3b-v4 with Ollama:
ollama run hf.co/mindsofchaos/codeoptics-coder-3b-v4:Q4_K_M
- Unsloth Desktop
- Pi
How to use mindsofchaos/codeoptics-coder-3b-v4 with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf mindsofchaos/codeoptics-coder-3b-v4:Q4_K_M
Configure the model in Pi
# Install Pi: npm install -g @earendil-works/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "llama-cpp": { "baseUrl": "http://localhost:9931/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "mindsofchaos/codeoptics-coder-3b-v4:Q4_K_M" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Docker Model Runner
How to use mindsofchaos/codeoptics-coder-3b-v4 with Docker Model Runner:
docker model run hf.co/mindsofchaos/codeoptics-coder-3b-v4:Q4_K_M
- Lemonade
How to use mindsofchaos/codeoptics-coder-3b-v4 with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull mindsofchaos/codeoptics-coder-3b-v4:Q4_K_M
Run and chat with the model
lemonade run user.codeoptics-coder-3b-v4-Q4_K_M
List all available models
lemonade list
- Hermes Agent
How to use mindsofchaos/codeoptics-coder-3b-v4 with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf mindsofchaos/codeoptics-coder-3b-v4:Q4_K_M
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:9931/v1 hermes config set model.default mindsofchaos/codeoptics-coder-3b-v4:Q4_K_M
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use mindsofchaos/codeoptics-coder-3b-v4 with OpenClaw:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf mindsofchaos/codeoptics-coder-3b-v4:Q4_K_M
Configure OpenClaw
# Install OpenClaw: npm install -g openclaw@latest # Register the local server and set it as the default model: openclaw onboard --non-interactive --mode local \ --auth-choice custom-api-key \ --custom-base-url http://127.0.0.1:9931/v1 \ --custom-model-id "mindsofchaos/codeoptics-coder-3b-v4:Q4_K_M" \ --custom-provider-id llama-cpp \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
Upload codeoptics_v4_training_and_benchmark.ipynb with huggingface_hub
Browse files
codeoptics_v4_training_and_benchmark.ipynb
CHANGED
|
@@ -7,11 +7,14 @@
|
|
| 7 |
"# CodeOptics-Coder v4.0: Unified Dual-Mode Architecture\n",
|
| 8 |
"### Complete End-to-End Pipeline: SFT Training -> GGUF Quantization -> Master 4-Suite Benchmark\n",
|
| 9 |
"\n",
|
| 10 |
-
"**
|
| 11 |
-
"
|
| 12 |
-
"
|
| 13 |
-
"
|
| 14 |
-
"
|
|
|
|
|
|
|
|
|
|
| 15 |
]
|
| 16 |
},
|
| 17 |
{
|
|
@@ -20,30 +23,38 @@
|
|
| 20 |
"metadata": {},
|
| 21 |
"outputs": [],
|
| 22 |
"source": [
|
|
|
|
| 23 |
"# Cell 1: Environment Preflight & Dependencies\n",
|
|
|
|
| 24 |
"import os, sys, subprocess, torch\n",
|
| 25 |
"\n",
|
| 26 |
"print('=' * 75)\n",
|
| 27 |
"print('[1/5] Setting up Environment & Verifying GPU Acceleration')\n",
|
| 28 |
"print('=' * 75)\n",
|
| 29 |
"\n",
|
| 30 |
-
"assert torch.cuda.is_available(), 'ERROR: GPU is not active! Enable T4 GPU in Kaggle
|
| 31 |
-
"
|
|
|
|
|
|
|
| 32 |
"\n",
|
| 33 |
-
"# System dependencies\n",
|
| 34 |
-
"
|
| 35 |
-
"subprocess.run(
|
|
|
|
|
|
|
|
|
|
| 36 |
"\n",
|
| 37 |
"# Authenticate Hugging Face\n",
|
| 38 |
"hf_token = os.environ.get('HF_TOKEN') or ('hf_' + 'PuuhhOzcLmUwKcBfgCPGdZxUawMQKEAOJk')\n",
|
| 39 |
"os.environ['HF_TOKEN'] = hf_token\n",
|
| 40 |
"os.environ['HUGGING_FACE_HUB_TOKEN'] = hf_token\n",
|
| 41 |
"\n",
|
| 42 |
-
"#
|
| 43 |
"os.chdir('/kaggle/working')\n",
|
| 44 |
-
"
|
|
|
|
| 45 |
"subprocess.run('tar -xzf codeoptics_benchmark_suite.tar.gz -C /kaggle/working/', shell=True, check=True)\n",
|
| 46 |
-
"print('[+] Environment ready and CodeOptics suite unpacked!')\n"
|
| 47 |
]
|
| 48 |
},
|
| 49 |
{
|
|
@@ -52,11 +63,13 @@
|
|
| 52 |
"metadata": {},
|
| 53 |
"outputs": [],
|
| 54 |
"source": [
|
| 55 |
-
"#
|
|
|
|
|
|
|
| 56 |
"import subprocess, sys, time\n",
|
| 57 |
"\n",
|
| 58 |
"print('=' * 75)\n",
|
| 59 |
-
"print('[2/5] Commencing CodeOptics-Coder v4.0 SFT Training')\n",
|
| 60 |
"print('=' * 75)\n",
|
| 61 |
"\n",
|
| 62 |
"t0 = time.time()\n",
|
|
@@ -79,11 +92,13 @@
|
|
| 79 |
"metadata": {},
|
| 80 |
"outputs": [],
|
| 81 |
"source": [
|
|
|
|
| 82 |
"# Cell 3: Weight Merge & GGUF Q4_K_M Quantization\n",
|
|
|
|
| 83 |
"import subprocess, sys, time\n",
|
| 84 |
"\n",
|
| 85 |
"print('=' * 75)\n",
|
| 86 |
-
"print('[3/5] Merging Weights
|
| 87 |
"print('=' * 75)\n",
|
| 88 |
"\n",
|
| 89 |
"t0 = time.time()\n",
|
|
@@ -97,7 +112,9 @@
|
|
| 97 |
"metadata": {},
|
| 98 |
"outputs": [],
|
| 99 |
"source": [
|
|
|
|
| 100 |
"# Cell 4: Ollama GPU Setup & Model Registration\n",
|
|
|
|
| 101 |
"import os, sys, subprocess, time, urllib.request\n",
|
| 102 |
"\n",
|
| 103 |
"print('=' * 75)\n",
|
|
@@ -128,7 +145,7 @@
|
|
| 128 |
" f.write(modelfile_content)\n",
|
| 129 |
"\n",
|
| 130 |
"subprocess.run(['ollama', 'create', 'codeoptic-coder:v4.0', '-f', 'Modelfile.v4'], check=True)\n",
|
| 131 |
-
"print('[+] Model codeoptic-coder:v4.0 registered successfully!')\n"
|
| 132 |
]
|
| 133 |
},
|
| 134 |
{
|
|
@@ -137,7 +154,9 @@
|
|
| 137 |
"metadata": {},
|
| 138 |
"outputs": [],
|
| 139 |
"source": [
|
| 140 |
-
"#
|
|
|
|
|
|
|
| 141 |
"import os, sys, time, subprocess\n",
|
| 142 |
"\n",
|
| 143 |
"print('=' * 75)\n",
|
|
@@ -152,6 +171,10 @@
|
|
| 152 |
}
|
| 153 |
],
|
| 154 |
"metadata": {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 155 |
"language_info": {
|
| 156 |
"name": "python"
|
| 157 |
}
|
|
|
|
| 7 |
"# CodeOptics-Coder v4.0: Unified Dual-Mode Architecture\n",
|
| 8 |
"### Complete End-to-End Pipeline: SFT Training -> GGUF Quantization -> Master 4-Suite Benchmark\n",
|
| 9 |
"\n",
|
| 10 |
+
"**Hardware Acceleration**: Free Tesla T4 GPU (or Dual T4 / P100) on Kaggle\n",
|
| 11 |
+
"\n",
|
| 12 |
+
"**Pipeline Stages**:\n",
|
| 13 |
+
"1. **Preflight**: Verify GPU, install modern compilation tools (`cmake`, `zstd`, `pciutils`) and unpack benchmark suite\n",
|
| 14 |
+
"2. **SFT Training (v4.0)**: LoRA r=16, alpha=32 on all 7 linear projections with completion-only loss across 350 balanced samples\n",
|
| 15 |
+
"3. **Weight Merge & GGUF Quantization**: Merge LoRA into base weights, build `llama.cpp` via CMake, verify RoPE 1,000,000, quantize to `q4_k_m`\n",
|
| 16 |
+
"4. **Ollama GPU Deployment**: Start Ollama daemon, build Modelfile, register `codeoptic-coder:v4.0`\n",
|
| 17 |
+
"5. **Master 4-Suite Benchmark**: Harvard CS50-10, CEB-15, HumanEval-164, and ClassEval\n"
|
| 18 |
]
|
| 19 |
},
|
| 20 |
{
|
|
|
|
| 23 |
"metadata": {},
|
| 24 |
"outputs": [],
|
| 25 |
"source": [
|
| 26 |
+
"# ==============================================================================\n",
|
| 27 |
"# Cell 1: Environment Preflight & Dependencies\n",
|
| 28 |
+
"# ==============================================================================\n",
|
| 29 |
"import os, sys, subprocess, torch\n",
|
| 30 |
"\n",
|
| 31 |
"print('=' * 75)\n",
|
| 32 |
"print('[1/5] Setting up Environment & Verifying GPU Acceleration')\n",
|
| 33 |
"print('=' * 75)\n",
|
| 34 |
"\n",
|
| 35 |
+
"assert torch.cuda.is_available(), 'ERROR: GPU is not active! Enable T4 GPU in Kaggle Notebook Settings (right sidebar -> Accelerator -> GPU T4 x2 or GPU T4).'\n",
|
| 36 |
+
"gpu_name = torch.cuda.get_device_name(0)\n",
|
| 37 |
+
"gpu_mem = torch.cuda.get_device_properties(0).total_memory / (1024**3)\n",
|
| 38 |
+
"print(f'[+] GPU Active: {gpu_name} ({gpu_mem:.1f} GB VRAM)')\n",
|
| 39 |
"\n",
|
| 40 |
+
"# System dependencies (including cmake for llama.cpp compilation)\n",
|
| 41 |
+
"print('[*] Installing system packages (cmake, zstd, pciutils, build-essential)...')\n",
|
| 42 |
+
"subprocess.run('apt-get update -qq && apt-get install -y -qq cmake zstd pciutils git curl make build-essential', shell=True, check=True)\n",
|
| 43 |
+
"\n",
|
| 44 |
+
"print('[*] Installing Python ML dependencies...')\n",
|
| 45 |
+
"subprocess.run([sys.executable, '-m', 'pip', 'install', '-q', '--upgrade', 'transformers', 'peft', 'trl', 'accelerate', 'datasets', 'huggingface_hub', 'gguf'], check=True)\n",
|
| 46 |
"\n",
|
| 47 |
"# Authenticate Hugging Face\n",
|
| 48 |
"hf_token = os.environ.get('HF_TOKEN') or ('hf_' + 'PuuhhOzcLmUwKcBfgCPGdZxUawMQKEAOJk')\n",
|
| 49 |
"os.environ['HF_TOKEN'] = hf_token\n",
|
| 50 |
"os.environ['HUGGING_FACE_HUB_TOKEN'] = hf_token\n",
|
| 51 |
"\n",
|
| 52 |
+
"# Unpack master benchmark suite\n",
|
| 53 |
"os.chdir('/kaggle/working')\n",
|
| 54 |
+
"print('[*] Pulling CodeOptics master benchmark suite and dataset...')\n",
|
| 55 |
+
"subprocess.run('wget -q -O codeoptics_benchmark_suite.tar.gz https://huggingface.co/mindsofchaos/codeoptics-coder-3b-v4/resolve/main/codeoptics_benchmark_suite.tar.gz', shell=True, check=True)\n",
|
| 56 |
"subprocess.run('tar -xzf codeoptics_benchmark_suite.tar.gz -C /kaggle/working/', shell=True, check=True)\n",
|
| 57 |
+
"print('[+] Environment ready and CodeOptics suite unpacked successfully!\\n')\n"
|
| 58 |
]
|
| 59 |
},
|
| 60 |
{
|
|
|
|
| 63 |
"metadata": {},
|
| 64 |
"outputs": [],
|
| 65 |
"source": [
|
| 66 |
+
"# ==============================================================================\n",
|
| 67 |
+
"# Cell 2: Execute LoRA Fine-Tuning v4.0 (Dual-Mode SFT)\n",
|
| 68 |
+
"# ==============================================================================\n",
|
| 69 |
"import subprocess, sys, time\n",
|
| 70 |
"\n",
|
| 71 |
"print('=' * 75)\n",
|
| 72 |
+
"print('[2/5] Commencing CodeOptics-Coder v4.0 SFT Training (350 Unified Samples)')\n",
|
| 73 |
"print('=' * 75)\n",
|
| 74 |
"\n",
|
| 75 |
"t0 = time.time()\n",
|
|
|
|
| 92 |
"metadata": {},
|
| 93 |
"outputs": [],
|
| 94 |
"source": [
|
| 95 |
+
"# ==============================================================================\n",
|
| 96 |
"# Cell 3: Weight Merge & GGUF Q4_K_M Quantization\n",
|
| 97 |
+
"# ==============================================================================\n",
|
| 98 |
"import subprocess, sys, time\n",
|
| 99 |
"\n",
|
| 100 |
"print('=' * 75)\n",
|
| 101 |
+
"print('[3/5] Merging Weights, Compiling llama.cpp via CMake & Quantizing to Q4_K_M')\n",
|
| 102 |
"print('=' * 75)\n",
|
| 103 |
"\n",
|
| 104 |
"t0 = time.time()\n",
|
|
|
|
| 112 |
"metadata": {},
|
| 113 |
"outputs": [],
|
| 114 |
"source": [
|
| 115 |
+
"# ==============================================================================\n",
|
| 116 |
"# Cell 4: Ollama GPU Setup & Model Registration\n",
|
| 117 |
+
"# ==============================================================================\n",
|
| 118 |
"import os, sys, subprocess, time, urllib.request\n",
|
| 119 |
"\n",
|
| 120 |
"print('=' * 75)\n",
|
|
|
|
| 145 |
" f.write(modelfile_content)\n",
|
| 146 |
"\n",
|
| 147 |
"subprocess.run(['ollama', 'create', 'codeoptic-coder:v4.0', '-f', 'Modelfile.v4'], check=True)\n",
|
| 148 |
+
"print('[+] Model codeoptic-coder:v4.0 registered successfully with Ollama GPU runtime!')\n"
|
| 149 |
]
|
| 150 |
},
|
| 151 |
{
|
|
|
|
| 154 |
"metadata": {},
|
| 155 |
"outputs": [],
|
| 156 |
"source": [
|
| 157 |
+
"# ==============================================================================\n",
|
| 158 |
+
"# Cell 5: Execute the Full Master Benchmark Suite (4 Benchmarks)\n",
|
| 159 |
+
"# ==============================================================================\n",
|
| 160 |
"import os, sys, time, subprocess\n",
|
| 161 |
"\n",
|
| 162 |
"print('=' * 75)\n",
|
|
|
|
| 171 |
}
|
| 172 |
],
|
| 173 |
"metadata": {
|
| 174 |
+
"accelerator": "GPU",
|
| 175 |
+
"colab": {
|
| 176 |
+
"gpuType": "T4"
|
| 177 |
+
},
|
| 178 |
"language_info": {
|
| 179 |
"name": "python"
|
| 180 |
}
|