Instructions to use LoxleyLabs/Qwen3-4B-Thinking-Concise 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 LoxleyLabs/Qwen3-4B-Thinking-Concise 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 LoxleyLabs/Qwen3-4B-Thinking-Concise:Q4_K_M # Run inference directly in the terminal: llama cli -hf LoxleyLabs/Qwen3-4B-Thinking-Concise:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf LoxleyLabs/Qwen3-4B-Thinking-Concise:Q4_K_M # Run inference directly in the terminal: llama cli -hf LoxleyLabs/Qwen3-4B-Thinking-Concise: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 LoxleyLabs/Qwen3-4B-Thinking-Concise:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama cli -hf LoxleyLabs/Qwen3-4B-Thinking-Concise:Q4_K_M
Use Docker
docker model run hf.co/LoxleyLabs/Qwen3-4B-Thinking-Concise:Q4_K_M
- Llama new
- LM Studio
- Jan
- vLLM
How to use LoxleyLabs/Qwen3-4B-Thinking-Concise with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "LoxleyLabs/Qwen3-4B-Thinking-Concise" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "LoxleyLabs/Qwen3-4B-Thinking-Concise", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/LoxleyLabs/Qwen3-4B-Thinking-Concise:Q4_K_M
- Ollama
How to use LoxleyLabs/Qwen3-4B-Thinking-Concise with Ollama:
ollama run hf.co/LoxleyLabs/Qwen3-4B-Thinking-Concise:Q4_K_M
- Unsloth Desktop
- Pi
How to use LoxleyLabs/Qwen3-4B-Thinking-Concise with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf LoxleyLabs/Qwen3-4B-Thinking-Concise: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": "LoxleyLabs/Qwen3-4B-Thinking-Concise:Q4_K_M" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Docker Model Runner
How to use LoxleyLabs/Qwen3-4B-Thinking-Concise with Docker Model Runner:
docker model run hf.co/LoxleyLabs/Qwen3-4B-Thinking-Concise:Q4_K_M
- Lemonade
How to use LoxleyLabs/Qwen3-4B-Thinking-Concise with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull LoxleyLabs/Qwen3-4B-Thinking-Concise:Q4_K_M
Run and chat with the model
lemonade run user.Qwen3-4B-Thinking-Concise-Q4_K_M
List all available models
lemonade list
- Hermes Agent
How to use LoxleyLabs/Qwen3-4B-Thinking-Concise with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf LoxleyLabs/Qwen3-4B-Thinking-Concise: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 LoxleyLabs/Qwen3-4B-Thinking-Concise:Q4_K_M
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use LoxleyLabs/Qwen3-4B-Thinking-Concise with OpenClaw:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf LoxleyLabs/Qwen3-4B-Thinking-Concise: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 "LoxleyLabs/Qwen3-4B-Thinking-Concise: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 code/h5_route.py from LoxleyLabs/Qwen3-4B-Thinking-Concise: direct link, hf CLI and curl.
- Browser
- Download file 4.79 kB
-
https://huggingface.co/LoxleyLabs/Qwen3-4B-Thinking-Concise/resolve/main/code/h5_route.py
- Command line
-
hf download hf://LoxleyLabs/Qwen3-4B-Thinking-Concise/code/h5_route.py
-
curl -L -o h5_route.py https://huggingface.co/LoxleyLabs/Qwen3-4B-Thinking-Concise/resolve/main/code/h5_route.py
4.79 kB
| #!/usr/bin/env python3 | |
| """H5 step 4: route the long-budget test questions (GSM8K 300, MATH test 50, hard maths 96, hard logic 200) through | |
| the dial and router retrained on the 32k pool. As H4: the hypernetwork's 37 dials per question are grouped by k-means | |
| (K=4, no labels) into profiles; a profile whose middle layers average above 0.5 thinks, and runs with its early | |
| layers at full (the H4b rule). Question vectors (Instruct layer 18) are cached in hyper/c32/x.pt. | |
| Writes hyper/h5/profiles.json, hyper/h5/routes.json, hyper/h5/ids_<model>.json, and hyper/h5/ids_dial75x.json (the | |
| 0.75 answers the new router needs that the long-budget test did not already produce).""" | |
| import collections | |
| import json | |
| import os | |
| import sys | |
| import torch | |
| sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) | |
| from cutconfig import INSTRUCT_DIR, ROOT # noqa: E402 | |
| H5 = f"{ROOT}/hyper/h5" | |
| TASKS = ("gsm8k", "math", "mathhard", "bbhhard") | |
| K = 4 | |
| def vectors(): | |
| f = f"{ROOT}/hyper/c32/x.pt" | |
| if os.path.exists(f): | |
| return torch.load(f, weights_only=True) | |
| from transformers import AutoModelForCausalLM, AutoTokenizer | |
| import step4_eval as s4 | |
| items = [it for t in TASKS for it in s4.items_for(t)] | |
| dev = torch.device(os.environ.get("EMBED_DEVICE", "cuda:0" if torch.cuda.is_available() else "cpu")) | |
| hf = INSTRUCT_DIR | |
| tok = AutoTokenizer.from_pretrained(hf) | |
| model = AutoModelForCausalLM.from_pretrained(hf, dtype=torch.bfloat16).to(dev).eval() | |
| xs = [] | |
| with torch.no_grad(): | |
| for it in items: | |
| enc = tok(f"<|im_start|>user\n{it['msg']}<|im_end|>\n", add_special_tokens=False, return_tensors="pt").to(dev) | |
| xs.append(model.model(**enc, output_hidden_states=True).hidden_states[18][0].float().mean(0).cpu()) | |
| del model | |
| torch.cuda.empty_cache() | |
| out = dict(ids=[it["id"] for it in items], x=torch.stack(xs)) | |
| torch.save(out, f) | |
| return out | |
| def main(): | |
| from h4_train import HyperNet | |
| v = vectors() | |
| ids, X = v["ids"], v["x"] | |
| r2 = torch.load(f"{H5}/router_v2.pt", map_location="cpu", weights_only=True) | |
| Z = ((X - r2["mu"]) / r2["sd"]) @ r2["proj"] | |
| P = torch.stack([torch.sigmoid(Z @ w + b) for w, b in (r2["models"][k] for k in range(3))], 1) | |
| tokc = torch.tensor([r2["mean_tokens"][k] for k in range(3)]) | |
| v2_l0, v2_l01 = P.argmax(1).tolist(), (P - 0.01 * tokc / 1000).argmax(1).tolist() | |
| sd = torch.load(f"{H5}/hypernet.pt", map_location="cpu", weights_only=True) | |
| hyper = HyperNet(sd["mu"], sd["sd"], sd["proj"]) | |
| hyper.load_state_dict(sd) | |
| with torch.no_grad(): | |
| B = hyper(X) | |
| g = torch.Generator().manual_seed(0) | |
| C = B[torch.randperm(len(B), generator=g)[:K]].clone() | |
| for _ in range(100): | |
| a = torch.cdist(B, C).argmin(1) | |
| C = torch.stack([B[a == k].mean(0) if (a == k).any() else C[k] for k in range(K)]) | |
| a = torch.cdist(B, C).argmin(1).tolist() | |
| think = sorted(k for k in range(K) if float(C[k][12:24].mean()) > 0.5) | |
| json.dump(dict(K=K, centroids=C.tolist(), sizes=[a.count(k) for k in range(K)], thinking_profiles=think), | |
| open(f"{H5}/profiles.json", "w")) | |
| name = {k: f"h5-prof{k}-early1" if k in think else f"h5-prof{k}" for k in range(K)} | |
| routes = {i: dict(v2_l0=v2_l0[n], v2_l01=v2_l01[n], h5=a[n], model=name[a[n]], beta_mid=float(B[n, 12:24].mean()), | |
| beta_early=float(B[n, :12].mean())) for n, i in enumerate(ids)} | |
| json.dump(dict(routes=routes, thinking_profiles=think), open(f"{H5}/routes.json", "w")) | |
| for k in range(K): | |
| json.dump([i for i, r in routes.items() if r["h5"] == k], open(f"{H5}/ids_{name[k]}.json", "w")) | |
| # ids already answered at 0.75 in the first long-budget run; optional, an absent file means none were | |
| f75 = f"{ROOT}/hyper/c32/ids_dial75.json" | |
| old75 = set(json.load(open(f75))) if os.path.exists(f75) else set() | |
| json.dump([i for i, r in routes.items() if 1 in (r["v2_l0"], r["v2_l01"]) and i not in old75], | |
| open(f"{H5}/ids_dial75x.json", "w")) | |
| for k in range(K): | |
| c = C[k] | |
| print(f"profile {k} ({name[k]}): {a.count(k)} questions; early {float(c[:12].mean()):.2f} mid " | |
| f"{float(c[12:24].mean()):.2f} late {float(c[24:36].mean()):.2f} emb {float(c[36]):.2f}", flush=True) | |
| task_of = lambda i: i.split("-", 1)[0] # noqa: E731 | |
| for t in TASKS: | |
| rs = [r for i, r in routes.items() if task_of(i) == t] | |
| print(f"{t}: n {len(rs)} | dial profiles {dict(sorted(collections.Counter(r['h5'] for r in rs).items()))} | " | |
| f"v2 l0 {dict(sorted(collections.Counter(r['v2_l0'] for r in rs).items()))} | " | |
| f"v2 l0.01 {dict(sorted(collections.Counter(r['v2_l01'] for r in rs).items()))}", flush=True) | |
| if __name__ == "__main__": | |
| main() | |