Text Generation
GGUF
inkling2_loop
weight-space-programming
mechanistic-interpretability
lora
dynamic-lora
llama-cpp
inkling2
Mixture of Experts
looped-transformer
reasoning
tool-calling
agent
terminal-bench
nl2bash
gsm8k
stem
math-500
mmlu-pro
conversational
modelopt
imatrix
Instructions to use jstarks/Inkling-2-Mini-Weight-Space-Programming with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use jstarks/Inkling-2-Mini-Weight-Space-Programming 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 jstarks/Inkling-2-Mini-Weight-Space-Programming:UD-IQ3_XXS # Run inference directly in the terminal: llama cli -hf jstarks/Inkling-2-Mini-Weight-Space-Programming:UD-IQ3_XXS
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf jstarks/Inkling-2-Mini-Weight-Space-Programming:UD-IQ3_XXS # Run inference directly in the terminal: llama cli -hf jstarks/Inkling-2-Mini-Weight-Space-Programming:UD-IQ3_XXS
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 jstarks/Inkling-2-Mini-Weight-Space-Programming:UD-IQ3_XXS # Run inference directly in the terminal: ./build/bin/llama cli -hf jstarks/Inkling-2-Mini-Weight-Space-Programming:UD-IQ3_XXS
Use Docker
docker model run hf.co/jstarks/Inkling-2-Mini-Weight-Space-Programming:UD-IQ3_XXS
- Llama new
- LM Studio
- Jan
- vLLM
How to use jstarks/Inkling-2-Mini-Weight-Space-Programming with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "jstarks/Inkling-2-Mini-Weight-Space-Programming" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "jstarks/Inkling-2-Mini-Weight-Space-Programming", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/jstarks/Inkling-2-Mini-Weight-Space-Programming:UD-IQ3_XXS
- Ollama
How to use jstarks/Inkling-2-Mini-Weight-Space-Programming with Ollama:
ollama run hf.co/jstarks/Inkling-2-Mini-Weight-Space-Programming:UD-IQ3_XXS
- Unsloth Desktop
- Pi
How to use jstarks/Inkling-2-Mini-Weight-Space-Programming with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf jstarks/Inkling-2-Mini-Weight-Space-Programming:UD-IQ3_XXS
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": "jstarks/Inkling-2-Mini-Weight-Space-Programming:UD-IQ3_XXS" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Docker Model Runner
How to use jstarks/Inkling-2-Mini-Weight-Space-Programming with Docker Model Runner:
docker model run hf.co/jstarks/Inkling-2-Mini-Weight-Space-Programming:UD-IQ3_XXS
- Lemonade
How to use jstarks/Inkling-2-Mini-Weight-Space-Programming with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull jstarks/Inkling-2-Mini-Weight-Space-Programming:UD-IQ3_XXS
Run and chat with the model
lemonade run user.Inkling-2-Mini-Weight-Space-Programming-UD-IQ3_XXS
List all available models
lemonade list
- Hermes Agent
How to use jstarks/Inkling-2-Mini-Weight-Space-Programming with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf jstarks/Inkling-2-Mini-Weight-Space-Programming:UD-IQ3_XXS
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 jstarks/Inkling-2-Mini-Weight-Space-Programming:UD-IQ3_XXS
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use jstarks/Inkling-2-Mini-Weight-Space-Programming with OpenClaw:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf jstarks/Inkling-2-Mini-Weight-Space-Programming:UD-IQ3_XXS
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 "jstarks/Inkling-2-Mini-Weight-Space-Programming:UD-IQ3_XXS" \ --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"
Download run_inkling2_lite.py from jstarks/Inkling-2-Mini-Weight-Space-Programming: direct link, hf CLI and curl.
- Browser
- Download file 16.7 kB
-
https://huggingface.co/jstarks/Inkling-2-Mini-Weight-Space-Programming/resolve/main/run_inkling2_lite.py
- Command line
-
hf download hf://jstarks/Inkling-2-Mini-Weight-Space-Programming/run_inkling2_lite.py
-
curl -L -o run_inkling2_lite.py https://huggingface.co/jstarks/Inkling-2-Mini-Weight-Space-Programming/resolve/main/run_inkling2_lite.py
16.7 kB
| """Standalone OpenAI-compatible HTTP proxy & CLI launcher for Inkling-2-Mini Lightweight 2-Adapter WSP. | |
| Launches `llama-server` on an internal backend port with: | |
| - Base GGUF: `unsloth/Inkling-2-Mini-GGUF` (`Inkling-2-Mini-UD-IQ3_XXS.gguf`, auto-downloaded if missing) | |
| - 2 rank=8 GGUF LoRAs (`6.32 MB` total): | |
| * `adapters_lite/wsp_lite_think_close.gguf` (Phase 1 think-closure) | |
| * `adapters_lite/wsp_lite_term_action.gguf` (Phase 2 terminal/shell action) | |
| Usage: | |
| python run_inkling2_lite.py # Start OpenAI proxy on http://127.0.0.1:8080/v1 | |
| python run_inkling2_lite.py --chat # Interactive CLI chat session | |
| python run_inkling2_lite.py --mode base # Toggle Base parity mode (scales=0.0) | |
| """ | |
| from __future__ import annotations | |
| import argparse | |
| import atexit | |
| import json | |
| import shutil | |
| import signal | |
| import subprocess | |
| import sys | |
| import threading | |
| import time | |
| import urllib.request | |
| from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer | |
| from pathlib import Path | |
| from typing import Any, Dict, List, Optional | |
| ROOT = Path(__file__).resolve().parent | |
| if str(ROOT) not in sys.path: | |
| sys.path.insert(0, str(ROOT)) | |
| from inkling2_lite_router import ( # noqa: E402 | |
| LITE_ADAPTER_DIR, | |
| LITE_ADAPTER_NAMES, | |
| Inkling2LiteRouter, | |
| LitePreset, | |
| ) | |
| UPSTREAM_GGUF_REPO = "unsloth/Inkling-2-Mini-GGUF" | |
| DEFAULT_GGUF_NAME = "Inkling-2-Mini-UD-IQ3_XXS.gguf" | |
| SERVED_MODEL_ID = "inkling2-mini-wsp-lite" | |
| FALLBACK_PRESET = LitePreset("lite_gentle", s_think=0.65, s_stem=0.50, s_term=0.80) | |
| def load_winning_preset() -> LitePreset: | |
| for cand in ( | |
| ROOT / "val24_lite_results.json", | |
| ROOT / "adapters_lite" / "val24_lite_results.json", | |
| ROOT / "benchmarks" / "val24_lite_results.json", | |
| ): | |
| if cand.exists(): | |
| try: | |
| data = json.loads(cand.read_text(encoding="utf-8")) | |
| if isinstance(data.get("selected_preset"), dict): | |
| return LitePreset(**data["selected_preset"]) | |
| except Exception: | |
| pass | |
| return FALLBACK_PRESET | |
| def resolve_llama_server(explicit_path: Optional[str]) -> Path: | |
| if explicit_path: | |
| p = Path(explicit_path).expanduser().resolve() | |
| if not p.exists(): | |
| raise FileNotFoundError(f"--llama-server not found: {p}") | |
| return p | |
| for cand in ( | |
| ROOT / "llama.cpp" / "llama-server.exe", | |
| ROOT / "llama.cpp" / "llama-server", | |
| ROOT / "llama-server.exe", | |
| ROOT / "llama-server", | |
| ): | |
| if cand.exists(): | |
| return cand | |
| which = shutil.which("llama-server") or shutil.which("llama-server.exe") | |
| if which: | |
| return Path(which) | |
| raise FileNotFoundError( | |
| "Could not find `llama-server` on PATH or in ./llama.cpp/. Pass --llama-server /path/to/llama-server." | |
| ) | |
| def resolve_gguf_path(explicit_path: Optional[str], no_download: bool) -> Path: | |
| if explicit_path: | |
| p = Path(explicit_path).expanduser().resolve() | |
| if p.exists(): | |
| return p | |
| if no_download: | |
| raise FileNotFoundError(f"--gguf not found: {p}") | |
| for cand in ( | |
| ROOT / "gguf" / DEFAULT_GGUF_NAME, | |
| ROOT / DEFAULT_GGUF_NAME, | |
| ): | |
| if cand.exists(): | |
| return cand | |
| if no_download: | |
| raise FileNotFoundError( | |
| f"Missing {DEFAULT_GGUF_NAME} and --no-download is set. Download from {UPSTREAM_GGUF_REPO}." | |
| ) | |
| try: | |
| from huggingface_hub import hf_hub_download | |
| except ImportError as exc: | |
| raise ImportError( | |
| "Install `huggingface_hub` (`pip install huggingface_hub`) to auto-download the base GGUF, or pass --gguf." | |
| ) from exc | |
| dst_dir = ROOT / "gguf" | |
| dst_dir.mkdir(parents=True, exist_ok=True) | |
| print(f"Downloading {DEFAULT_GGUF_NAME} from {UPSTREAM_GGUF_REPO} to {dst_dir}...", flush=True) | |
| downloaded = hf_hub_download( | |
| repo_id=UPSTREAM_GGUF_REPO, | |
| filename=DEFAULT_GGUF_NAME, | |
| local_dir=str(dst_dir), | |
| ) | |
| return Path(downloaded) | |
| class BackendProcess: | |
| def __init__( | |
| self, | |
| llama_server: Path, | |
| gguf_path: Path, | |
| backend_port: int, | |
| n_cpu_moe: int, | |
| ctx_size: int, | |
| log_path: Path, | |
| ): | |
| self.llama_server = llama_server | |
| self.gguf_path = gguf_path | |
| self.backend_port = backend_port | |
| self.base_url = f"http://127.0.0.1:{backend_port}" | |
| self.n_cpu_moe = n_cpu_moe | |
| self.ctx_size = ctx_size | |
| self.log_path = log_path | |
| self.proc: Optional[subprocess.Popen] = None | |
| self.fp = None | |
| self.adapters: List[Dict[str, Any]] = [] | |
| def start(self) -> List[int]: | |
| lite_paths = [LITE_ADAPTER_DIR / f"{n}.gguf" for n in LITE_ADAPTER_NAMES] | |
| missing = [str(p) for p in [self.llama_server, self.gguf_path, *lite_paths] if not p.exists()] | |
| if missing: | |
| raise FileNotFoundError(f"Missing required files: {missing}") | |
| cmd = [ | |
| str(self.llama_server), | |
| "-m", str(self.gguf_path), | |
| "--host", "127.0.0.1", | |
| "--port", str(self.backend_port), | |
| "--jinja", | |
| "-np", "1", | |
| "-c", str(self.ctx_size), | |
| "-ctk", "q8_0", | |
| "-ctv", "q8_0", | |
| "-ngl", "99", | |
| "--n-cpu-moe", str(self.n_cpu_moe), | |
| "--fit", "off", | |
| "--lora-init-without-apply", | |
| "--lora", ",".join(str(p) for p in lite_paths), | |
| ] | |
| self.fp = open(self.log_path, "w", encoding="utf-8", errors="replace") | |
| self.proc = subprocess.Popen(cmd, stdout=self.fp, stderr=subprocess.STDOUT) | |
| deadline = time.time() + 180.0 | |
| while time.time() < deadline: | |
| if self.proc.poll() is not None: | |
| self.fp.flush() | |
| tail = self.log_path.read_text(encoding="utf-8", errors="replace")[-1500:] | |
| raise RuntimeError(f"llama-server exited rc={self.proc.returncode}:\n{tail}") | |
| try: | |
| with urllib.request.urlopen(f"{self.base_url}/health", timeout=2.0) as r: | |
| if json.loads(r.read().decode()).get("status") == "ok": | |
| with urllib.request.urlopen(f"{self.base_url}/lora-adapters", timeout=10.0) as ra: | |
| self.adapters = json.loads(ra.read().decode()) | |
| id_by_name = {Path(a["path"]).stem: int(a["id"]) for a in self.adapters} | |
| return [id_by_name[n] for n in LITE_ADAPTER_NAMES] | |
| except Exception: | |
| pass | |
| time.sleep(0.4) | |
| self.stop() | |
| raise TimeoutError("Timed out waiting for llama-server /health.") | |
| def stop(self) -> None: | |
| if self.proc is not None and self.proc.poll() is None: | |
| self.proc.terminate() | |
| try: | |
| self.proc.wait(timeout=8) | |
| except subprocess.TimeoutExpired: | |
| self.proc.kill() | |
| self.proc.wait(timeout=5) | |
| if self.fp is not None: | |
| try: | |
| self.fp.close() | |
| except Exception: | |
| pass | |
| self.fp = None | |
| def make_handler( | |
| router: Inkling2LiteRouter, | |
| infer_lock: threading.Lock, | |
| default_mode: str, | |
| default_effort: float, | |
| ): | |
| class ProxyHandler(BaseHTTPRequestHandler): | |
| protocol_version = "HTTP/1.1" | |
| def log_message(self, fmt: str, *args: Any) -> None: | |
| return | |
| def _send_json(self, status: int, payload: Dict[str, Any]) -> None: | |
| raw = json.dumps(payload, ensure_ascii=False).encode("utf-8") | |
| self.send_response(status) | |
| self.send_header("Content-Type", "application/json; charset=utf-8") | |
| self.send_header("Content-Length", str(len(raw))) | |
| self.send_header("Connection", "close") | |
| self.end_headers() | |
| self.wfile.write(raw) | |
| def do_GET(self) -> None: # noqa: N802 | |
| path = self.path.split("?", 1)[0] | |
| if path == "/health": | |
| self._send_json(200, {"status": "ok", "model": SERVED_MODEL_ID, "mode": default_mode}) | |
| return | |
| if path in ("/v1/models", "/models"): | |
| self._send_json( | |
| 200, | |
| { | |
| "object": "list", | |
| "data": [ | |
| { | |
| "id": SERVED_MODEL_ID, | |
| "object": "model", | |
| "created": int(time.time()), | |
| "owned_by": "local-wsp-lite", | |
| } | |
| ], | |
| }, | |
| ) | |
| return | |
| self._send_json(404, {"error": f"Unknown path: {path}"}) | |
| def do_POST(self) -> None: # noqa: N802 | |
| path = self.path.split("?", 1)[0] | |
| if path not in ("/v1/chat/completions", "/chat/completions"): | |
| self._send_json(404, {"error": f"Unsupported endpoint: {path}"}) | |
| return | |
| try: | |
| length = int(self.headers.get("Content-Length", "0")) | |
| body = json.loads(self.rfile.read(length).decode("utf-8")) | |
| messages = body.get("messages") or [] | |
| tools = body.get("tools") or None | |
| max_tokens = int(body.get("max_tokens") or 1024) | |
| temperature = float(body.get("temperature") or 0.0) | |
| ct_kwargs = body.get("chat_template_kwargs") or {} | |
| eff = float( | |
| body.get("reasoning_effort") | |
| if body.get("reasoning_effort") is not None | |
| else ( | |
| ct_kwargs.get("reasoning_effort") | |
| if ct_kwargs.get("reasoning_effort") is not None | |
| else default_effort | |
| ) | |
| ) | |
| mode = str(body.get("mode") or default_mode) | |
| seed = int(body.get("seed") if body.get("seed") is not None else 42) | |
| with infer_lock: | |
| res = router.chat_completion( | |
| messages=messages, | |
| tools=tools, | |
| max_tokens=max_tokens, | |
| temperature=temperature, | |
| reasoning_effort=eff, | |
| mode=mode, | |
| seed=seed, | |
| ) | |
| msg_out: Dict[str, Any] = { | |
| "role": "assistant", | |
| "content": res["content"], | |
| "reasoning_content": res["reasoning"], | |
| "tool_calls": res["tool_calls"], | |
| } | |
| prompt_tok = int(res.get("prompt_tok") or 0) | |
| comp_tok = int(res["comp_tok"]) | |
| resp_payload = { | |
| "id": f"chatcmpl-wsp-lite-{int(time.time() * 1000)}", | |
| "object": "chat.completion", | |
| "created": int(time.time()), | |
| "model": body.get("model") or SERVED_MODEL_ID, | |
| "choices": [ | |
| { | |
| "index": 0, | |
| "message": msg_out, | |
| "finish_reason": res["finish_reason"], | |
| } | |
| ], | |
| "usage": { | |
| "prompt_tokens": prompt_tok, | |
| "completion_tokens": comp_tok, | |
| "total_tokens": prompt_tok + comp_tok, | |
| }, | |
| "wsp_meta": { | |
| "regime": res["regime"], | |
| "p1_scales": res["p1_scales"], | |
| "p2_scales": res["p2_scales"], | |
| "server_decode_tps": res["server_decode_tps"], | |
| "p1_tok": res["p1_tok"], | |
| "p2_tok": res["p2_tok"], | |
| "p1_natural_close": res["p1_natural_close"], | |
| "infer_ms": res["infer_ms"], | |
| }, | |
| } | |
| self._send_json(200, resp_payload) | |
| except Exception as e: | |
| self._send_json(500, {"error": str(e)}) | |
| return ProxyHandler | |
| def run_interactive_chat(router: Inkling2LiteRouter, mode: str, effort: float) -> None: | |
| history: List[Dict[str, Any]] = [] | |
| print(f"Interactive Inkling-2-Mini WSP Lite chat (mode={mode}, effort={effort}). Type '/reset' or 'exit'.", flush=True) | |
| while True: | |
| try: | |
| user_in = input("\nYou> ").strip() | |
| except (EOFError, KeyboardInterrupt): | |
| print() | |
| break | |
| if not user_in: | |
| continue | |
| if user_in.lower() in ("exit", "quit"): | |
| break | |
| if user_in.lower() == "/reset": | |
| history.clear() | |
| print("[History cleared]", flush=True) | |
| continue | |
| history.append({"role": "user", "content": user_in}) | |
| res = router.chat_completion( | |
| messages=history, | |
| tools=None, | |
| max_tokens=1024, | |
| temperature=0.0, | |
| reasoning_effort=effort, | |
| mode=mode, | |
| ) | |
| print(f"\n[regime={res['regime']} | p1={res['p1_tok']} p2={res['p2_tok']} tok | {res['server_decode_tps']} tok/s]", flush=True) | |
| if res["reasoning"]: | |
| print(f"<think>\n{res['reasoning']}\n</think>", flush=True) | |
| print(f"Assistant> {res['content']}", flush=True) | |
| history.append({"role": "assistant", "content": res["content"], "reasoning_content": res["reasoning"]}) | |
| def main() -> None: | |
| parser = argparse.ArgumentParser(description="Standalone OpenAI Proxy for Inkling-2-Mini Lightweight 2-Adapter WSP.") | |
| parser.add_argument("--host", default="127.0.0.1") | |
| parser.add_argument("--port", type=int, default=8080) | |
| parser.add_argument("--backend-port", type=int, default=8092) | |
| parser.add_argument("--gguf", default=None, help="Path to Inkling-2-Mini-UD-IQ3_XXS.gguf (auto-downloads if missing)") | |
| parser.add_argument("--llama-server", default=None, help="Path to llama-server binary (auto-detected if omitted)") | |
| parser.add_argument("--no-download", action="store_true", help="Do not auto-download missing base GGUF from HF") | |
| parser.add_argument("--n-cpu-moe", type=int, default=4) | |
| parser.add_argument("--ctx", type=int, default=8192) | |
| parser.add_argument("--mode", choices=("wsp", "base"), default="wsp") | |
| parser.add_argument("--reasoning-effort", type=float, default=0.2) | |
| parser.add_argument("--chat", action="store_true", help="Run interactive terminal chat instead of HTTP server") | |
| args = parser.parse_args() | |
| llama_server = resolve_llama_server(args.llama_server) | |
| gguf_path = resolve_gguf_path(args.gguf, no_download=args.no_download) | |
| preset = load_winning_preset() | |
| backend = BackendProcess( | |
| llama_server=llama_server, | |
| gguf_path=gguf_path, | |
| backend_port=args.backend_port, | |
| n_cpu_moe=args.n_cpu_moe, | |
| ctx_size=args.ctx, | |
| log_path=ROOT / f"proxy_backend_{args.backend_port}.log", | |
| ) | |
| atexit.register(backend.stop) | |
| def _sig_handler(signum, frame): # noqa: ARG001 | |
| backend.stop() | |
| sys.exit(0) | |
| signal.signal(signal.SIGINT, _sig_handler) | |
| signal.signal(signal.SIGTERM, _sig_handler) | |
| if hasattr(signal, "SIGBREAK"): | |
| signal.signal(signal.SIGBREAK, _sig_handler) | |
| print(f"Starting llama-server ({llama_server.name}) on {backend.base_url} with 2 adapters_lite ({preset.name})...", flush=True) | |
| aids = backend.start() | |
| router = Inkling2LiteRouter(backend.base_url, aids, preset=preset, root=ROOT) | |
| print(f"Backend ready | gguf={gguf_path.name} | adapters={LITE_ADAPTER_NAMES} | preset={preset}", flush=True) | |
| if args.chat: | |
| try: | |
| run_interactive_chat(router, mode=args.mode, effort=args.reasoning_effort) | |
| finally: | |
| backend.stop() | |
| return | |
| infer_lock = threading.Lock() | |
| handler_cls = make_handler(router, infer_lock, default_mode=args.mode, default_effort=args.reasoning_effort) | |
| httpd = ThreadingHTTPServer((args.host, args.port), handler_cls) | |
| print(f"OpenAI proxy listening on http://{args.host}:{args.port}/v1 (model={SERVED_MODEL_ID}, mode={args.mode})", flush=True) | |
| try: | |
| httpd.serve_forever() | |
| except KeyboardInterrupt: | |
| pass | |
| finally: | |
| httpd.server_close() | |
| backend.stop() | |
| print("Proxy and llama-server shut down cleanly.", flush=True) | |
| if __name__ == "__main__": | |
| main() | |