Instructions to use tchbcb/samai-9b 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 tchbcb/samai-9b 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 tchbcb/samai-9b:Q4_K_M # Run inference directly in the terminal: llama cli -hf tchbcb/samai-9b:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf tchbcb/samai-9b:Q4_K_M # Run inference directly in the terminal: llama cli -hf tchbcb/samai-9b:Q4_K_M
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf tchbcb/samai-9b:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf tchbcb/samai-9b:Q4_K_M
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf tchbcb/samai-9b:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf tchbcb/samai-9b:Q4_K_M
Use Docker
docker model run hf.co/tchbcb/samai-9b:Q4_K_M
- LM Studio
- Jan
- Ollama
How to use tchbcb/samai-9b with Ollama:
ollama run hf.co/tchbcb/samai-9b:Q4_K_M
- Unsloth Desktop
- Pi
How to use tchbcb/samai-9b with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf tchbcb/samai-9b: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:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "tchbcb/samai-9b:Q4_K_M" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Docker Model Runner
How to use tchbcb/samai-9b with Docker Model Runner:
docker model run hf.co/tchbcb/samai-9b:Q4_K_M
- Lemonade
How to use tchbcb/samai-9b with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull tchbcb/samai-9b:Q4_K_M
Run and chat with the model
lemonade run user.samai-9b-Q4_K_M
List all available models
lemonade list
- Hermes Agent
How to use tchbcb/samai-9b with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf tchbcb/samai-9b: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:8080/v1 hermes config set model.default tchbcb/samai-9b:Q4_K_M
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use tchbcb/samai-9b with OpenClaw:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf tchbcb/samai-9b: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:8080/v1 \ --custom-model-id "tchbcb/samai-9b: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"
surgery v2 (public mirror for colab)
Browse files
artifacts/m15_scripts/r12_surgery.py
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
# -*- coding: utf-8 -*-
|
| 3 |
+
"""r12_surgery.py — f16 元数据手术 v2 路线 (坑#58: 自写 walk 定位 + GGUFReader 复验双保险)
|
| 4 |
+
用法: python3 r12_surgery.py <f16_path>
|
| 5 |
+
补丁: qwen35.nextn_predict_layers -> 0, qwen35.block_count -> 32
|
| 6 |
+
产物标记: R12_SURGERY_V2_DONE"""
|
| 7 |
+
import struct, json, hashlib, sys
|
| 8 |
+
|
| 9 |
+
PATH = sys.argv[1] if len(sys.argv) > 1 else "/tmp/k8b/m13_r10_f16.gguf"
|
| 10 |
+
SZT = {0: 1, 1: 1, 2: 2, 3: 2, 4: 4, 5: 4, 6: 4, 7: 1, 10: 8, 11: 8, 12: 8}
|
| 11 |
+
FMT = {0: "<B", 1: "<b", 2: "<H", 3: "<h", 4: "<I", 5: "<i", 6: "<f", 7: "<B", 10: "<Q", 11: "<q", 12: "<d"}
|
| 12 |
+
T_STR, T_ARR = 8, 9
|
| 13 |
+
out = {"path": PATH}
|
| 14 |
+
|
| 15 |
+
def walk(fh):
|
| 16 |
+
fh.seek(0)
|
| 17 |
+
assert fh.read(4) == b"GGUF"
|
| 18 |
+
ver, n_ten, n_kv = struct.unpack("<IQQ", fh.read(20))
|
| 19 |
+
idx = {}
|
| 20 |
+
for _ in range(n_kv):
|
| 21 |
+
n = struct.unpack("<Q", fh.read(8))[0]
|
| 22 |
+
key = fh.read(n).decode("utf-8", "replace")
|
| 23 |
+
vtype = struct.unpack("<I", fh.read(4))[0]
|
| 24 |
+
if vtype == T_STR:
|
| 25 |
+
n2 = struct.unpack("<Q", fh.read(8))[0]
|
| 26 |
+
fh.seek(n2, 1); continue
|
| 27 |
+
if vtype == T_ARR:
|
| 28 |
+
etype = struct.unpack("<I", fh.read(4))[0]
|
| 29 |
+
cnt_off = fh.tell()
|
| 30 |
+
cnt = struct.unpack("<Q", fh.read(8))[0]
|
| 31 |
+
if etype == T_STR:
|
| 32 |
+
for _ in range(cnt):
|
| 33 |
+
ln = struct.unpack("<Q", fh.read(8))[0]
|
| 34 |
+
fh.seek(ln, 1)
|
| 35 |
+
else:
|
| 36 |
+
fh.seek(cnt * SZT[etype], 1)
|
| 37 |
+
idx[key] = (vtype, etype, cnt, cnt_off, fh.tell() if etype != T_STR else cnt_off)
|
| 38 |
+
continue
|
| 39 |
+
fh.seek(SZT[vtype], 1)
|
| 40 |
+
idx[key] = (vtype, None, None, None, fh.tell() - SZT[vtype])
|
| 41 |
+
return idx
|
| 42 |
+
|
| 43 |
+
fh = open(PATH, "r+b")
|
| 44 |
+
idx = walk(fh)
|
| 45 |
+
out["bc_found"] = "qwen35.block_count" in idx
|
| 46 |
+
out["nx_found"] = "qwen35.nextn_predict_layers" in idx
|
| 47 |
+
missing = [k for k in ("qwen35.block_count", "qwen35.nextn_predict_layers") if k not in idx]
|
| 48 |
+
if missing:
|
| 49 |
+
out["R12_SURGERY_V2_DONE"] = False
|
| 50 |
+
out["error"] = "keys absent: %s" % missing
|
| 51 |
+
print(json.dumps(out, ensure_ascii=False)); sys.exit(1)
|
| 52 |
+
for key, newv in (("qwen35.nextn_predict_layers", 0), ("qwen35.block_count", 32)):
|
| 53 |
+
vtype, _, _, _, off = idx[key]
|
| 54 |
+
fh.seek(off)
|
| 55 |
+
old = struct.unpack(FMT[vtype], fh.read(4))[0]
|
| 56 |
+
fh.seek(off)
|
| 57 |
+
fh.write(struct.pack(FMT[vtype], newv))
|
| 58 |
+
out["patch_" + key] = "%s->%s" % (old, newv)
|
| 59 |
+
fh.flush()
|
| 60 |
+
import os
|
| 61 |
+
os.fsync(fh.fileno())
|
| 62 |
+
fh.close()
|
| 63 |
+
|
| 64 |
+
import gguf
|
| 65 |
+
r = gguf.GGUFReader(PATH)
|
| 66 |
+
bcv = int(r.fields["qwen35.block_count"].parts[-1][0])
|
| 67 |
+
nxv = int(r.fields["qwen35.nextn_predict_layers"].parts[-1][0])
|
| 68 |
+
out["verify"] = "bc=%d nx=%d tensors=%d" % (bcv, nxv, len(r.tensors))
|
| 69 |
+
ok = bcv == 32 and nxv == 0 and len(r.tensors) > 400
|
| 70 |
+
out["R12_SURGERY_V2_DONE"] = bool(ok)
|
| 71 |
+
print(json.dumps(out, ensure_ascii=False))
|