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/h4_compose.py from LoxleyLabs/Qwen3-4B-Thinking-Concise: direct link, hf CLI and curl.
- Browser
- Download file 4.13 kB
-
https://huggingface.co/LoxleyLabs/Qwen3-4B-Thinking-Concise/resolve/main/code/h4_compose.py
- Command line
-
hf download hf://LoxleyLabs/Qwen3-4B-Thinking-Concise/code/h4_compose.py
-
curl -L -o h4_compose.py https://huggingface.co/LoxleyLabs/Qwen3-4B-Thinking-Concise/resolve/main/code/h4_compose.py
4.13 kB
| #!/usr/bin/env python3 | |
| """H4: the composed model with a per-layer deliberation dial. | |
| W_l(beta) = Thinking_l + (beta_l - 1) * P_l for the 36 decoder layers (all 7 matrices and the norm vectors in P); | |
| beta_36 drives the embedding table and the tied output head (they are one tensor in Qwen3-4B). | |
| beta = 1 everywhere is the Thinking model exactly; beta = 0 everywhere is D = Thinking - P. | |
| P is held factored (P x = A (B x)), so the extra cost is small. beta is read at call time from self.beta, so a | |
| hypernetwork's output (a tensor that requires grad) can be set before each forward and gradients reach it. | |
| """ | |
| import os | |
| import re | |
| import sys | |
| import torch | |
| import torch.nn.functional as F | |
| from safetensors import safe_open | |
| from transformers import AutoModelForCausalLM | |
| sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) | |
| from cutconfig import ROOT, THINKING_DIR as T_DIR # noqa: E402 | |
| N_LAYERS = 36 | |
| EMB = 36 # index of the embedding / output-head dial | |
| class Composed: | |
| def __init__(self, dev, checkpointing=True): | |
| self.dev = dev | |
| self.model = AutoModelForCausalLM.from_pretrained(T_DIR, dtype=torch.bfloat16).to(dev) | |
| self.model.config.use_cache = False | |
| for p in self.model.parameters(): | |
| p.requires_grad_(False) | |
| if checkpointing: | |
| # non-reentrant: gradients reach beta through the hooks even though every model weight is frozen | |
| self.model.gradient_checkpointing_enable(gradient_checkpointing_kwargs={"use_reentrant": False}) | |
| self.model.train() # HF checkpointing only runs in train mode; Qwen3 has no dropout | |
| else: | |
| self.model.eval() | |
| self.beta = torch.ones(N_LAYERS + 1, device=dev) | |
| P = safe_open(f"{ROOT}/hyper/P_q80.safetensors", framework="pt", device="cpu") | |
| keys = set(P.keys()) | |
| self.hooks = [] | |
| mods = dict(self.model.named_modules()) | |
| n_lin = n_norm = 0 | |
| for k in sorted(keys): | |
| if k.endswith(".A"): | |
| name = k[:-2] | |
| mod = mods[name[:-len(".weight")]] | |
| layer = int(re.search(r"layers\.(\d+)\.", name).group(1)) | |
| A = P.get_tensor(k).to(dev) | |
| B = P.get_tensor(name + ".B").to(dev) | |
| self.hooks.append(mod.register_forward_hook(self._lin_hook(layer, A, B))) | |
| n_lin += 1 | |
| elif not k.endswith(".B") and "layers." in k: # a norm vector | |
| mod = mods[k[:-len(".weight")]] | |
| layer = int(re.search(r"layers\.(\d+)\.", k).group(1)) | |
| self.hooks.append(mod.register_forward_hook(self._norm_hook(layer, P.get_tensor(k).to(dev)))) | |
| n_norm += 1 | |
| if "model.embed_tokens.weight" in keys: | |
| Pe = P.get_tensor("model.embed_tokens.weight").to(dev) | |
| self.hooks.append(self.model.model.embed_tokens.register_forward_hook(self._emb_hook(Pe))) | |
| self.hooks.append(self.model.lm_head.register_forward_hook(self._head_hook(Pe))) | |
| self.summary = f"hooks: {n_lin} matrices, {n_norm} norm vectors, embedding+head {'yes' if 'model.embed_tokens.weight' in keys else 'no'}" | |
| def _scale(self, i, dtype): | |
| return (self.beta[i] - 1.0).to(dtype) | |
| def _lin_hook(self, layer, A, B): | |
| def hook(mod, inp, out): | |
| x = inp[0] | |
| return out + self._scale(layer, out.dtype) * F.linear(F.linear(x, B), A) | |
| return hook | |
| def _norm_hook(self, layer, p): | |
| def hook(mod, inp, out): | |
| x = inp[0] | |
| h = x.float() | |
| h = h * torch.rsqrt(h.pow(2).mean(-1, keepdim=True) + mod.variance_epsilon) | |
| return out + self._scale(layer, out.dtype) * (p.to(out.dtype) * h.to(out.dtype)) | |
| return hook | |
| def _emb_hook(self, Pe): | |
| def hook(mod, inp, out): | |
| return out + self._scale(EMB, out.dtype) * F.embedding(inp[0], Pe) | |
| return hook | |
| def _head_hook(self, Pe): | |
| def hook(mod, inp, out): | |
| return out + self._scale(EMB, out.dtype) * F.linear(inp[0], Pe) | |
| return hook | |
| def set_beta(self, beta): | |
| self.beta = beta | |