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"
Download artifacts/m15_scripts/surgery3.py from tchbcb/samai-9b: direct link, hf CLI and curl.
- Browser
- Download file 3.58 kB
-
https://huggingface.co/tchbcb/samai-9b/resolve/main/artifacts/m15_scripts/surgery3.py
- Command line
-
hf download hf://tchbcb/samai-9b/artifacts/m15_scripts/surgery3.py
-
curl -L -o surgery3.py https://huggingface.co/tchbcb/samai-9b/resolve/main/artifacts/m15_scripts/surgery3.py
3.58 kB
| #!/usr/bin/env python3 | |
| # -*- coding: utf-8 -*- | |
| """surgery3.py — 手术 III: qwen35.attention.recurrent_layers BOOL 数组 33→32 (Colab 版) | |
| 沿袭 R10 s8_f16_surgery2.py 实战逻辑: 删末元素(幻影 nextn 层旗标)+计数 33→32+头部左移 1, | |
| align32 padding 吸收位移 → 张量数据区起点不变。 | |
| 前置: r12_surgery.py 已完成 (bc=32, nx=0) | |
| 产物: SURGERY3_DONE""" | |
| import struct, os, sys | |
| PATH = sys.argv[1] if len(sys.argv) > 1 else "/content/k8b/base_f16.gguf" | |
| KEY = "qwen35.attention.recurrent_layers" | |
| SZ = {0: 1, 1: 1, 2: 2, 3: 2, 4: 4, 5: 4, 6: 4, 7: 1, 10: 8, 11: 8, 12: 8} | |
| def walk_header(fh): | |
| fh.seek(0) | |
| assert fh.read(4) == b"GGUF" | |
| ver, n_ten, n_kv = struct.unpack("<IQQ", fh.read(20)) | |
| def rstr(): | |
| n = struct.unpack("<Q", fh.read(8))[0] | |
| return fh.read(n).decode("utf-8", "replace") | |
| hits = {} | |
| for _ in range(n_kv): | |
| key = rstr() | |
| vtype = struct.unpack("<I", fh.read(4))[0] | |
| if vtype == 8: | |
| rstr(); continue | |
| if vtype == 9: | |
| etype = struct.unpack("<I", fh.read(4))[0] | |
| cnt_off = fh.tell() | |
| cnt = struct.unpack("<Q", fh.read(8))[0] | |
| data_off = fh.tell() | |
| if etype == 8: | |
| for _ in range(cnt): | |
| ln = struct.unpack("<Q", fh.read(8))[0] | |
| fh.seek(ln, 1) | |
| else: | |
| fh.seek(cnt * SZ[etype], 1) | |
| if key == KEY: | |
| hits[key] = (vtype, etype, cnt, cnt_off, data_off) | |
| continue | |
| fh.seek(SZ[vtype], 1) | |
| for _ in range(n_ten): | |
| rstr() | |
| n_dims = struct.unpack("<I", fh.read(4))[0] | |
| fh.seek(8 * n_dims, 1) | |
| fh.seek(4 + 8, 1) | |
| head_end = fh.tell() | |
| data_start = (head_end + 31) // 32 * 32 | |
| return hits, head_end, data_start, n_ten | |
| def main(): | |
| sz = os.path.getsize(PATH) | |
| with open(PATH, "r+b") as fh: | |
| hits, head_end, data_start, n_ten = walk_header(fh) | |
| if KEY not in hits: | |
| print("SKIP: %s absent (maybe already 32 or not present)" % KEY) | |
| print("SURGERY3_DONE") | |
| return | |
| vtype, etype, cnt, cnt_off, data_off = hits[KEY] | |
| print("found: etype=%d count=%d cnt_off=%d data_off=%d head_end=%d data_start=%d filesize=%d" | |
| % (etype, cnt, cnt_off, data_off, head_end, data_start, sz), flush=True) | |
| if cnt == 32: | |
| print("SKIP: already 32") | |
| print("SURGERY3_DONE") | |
| return | |
| assert etype == 7 and cnt == 33, "expect BOOL array of 33, got %d/%d" % (etype, cnt) | |
| fh.seek(0) | |
| hdr = bytearray(fh.read(data_start)) | |
| struct.pack_into("<Q", hdr, cnt_off, 32) | |
| del hdr[data_off + 32] | |
| assert len(hdr) == data_start - 1 | |
| hdr.append(0) | |
| assert len(hdr) == data_start | |
| fh.seek(0) | |
| fh.write(hdr) | |
| fh.flush() | |
| os.fsync(fh.fileno()) | |
| print("bytes rewritten:", data_start, flush=True) | |
| with open(PATH, "rb") as fh: | |
| hits2, head_end2, data_start2, n_ten2 = walk_header(fh) | |
| print("VERIFY recount=%d head_end=%d data_start=%d (expect unchanged %d)" | |
| % (hits2[KEY][2], head_end2, data_start2, data_start), flush=True) | |
| assert hits2[KEY][2] == 32 and data_start2 == data_start | |
| import gguf | |
| r = gguf.GGUFReader(PATH) | |
| print("VERIFY reader: tensors=%d block_count=%s" % ( | |
| len(r.tensors), int(r.fields["qwen35.block_count"].parts[-1][0])), flush=True) | |
| print("SURGERY3_DONE", flush=True) | |
| if __name__ == "__main__": | |
| main() | |