Instructions to use moonlight-labs/moonlight-qwen3-4b-v7 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use moonlight-labs/moonlight-qwen3-4b-v7 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="moonlight-labs/moonlight-qwen3-4b-v7") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("moonlight-labs/moonlight-qwen3-4b-v7") model = AutoModelForCausalLM.from_pretrained("moonlight-labs/moonlight-qwen3-4b-v7", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use moonlight-labs/moonlight-qwen3-4b-v7 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 moonlight-labs/moonlight-qwen3-4b-v7:Q8_0 # Run inference directly in the terminal: llama cli -hf moonlight-labs/moonlight-qwen3-4b-v7:Q8_0
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf moonlight-labs/moonlight-qwen3-4b-v7:Q8_0 # Run inference directly in the terminal: llama cli -hf moonlight-labs/moonlight-qwen3-4b-v7:Q8_0
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 moonlight-labs/moonlight-qwen3-4b-v7:Q8_0 # Run inference directly in the terminal: ./llama-cli -hf moonlight-labs/moonlight-qwen3-4b-v7:Q8_0
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 moonlight-labs/moonlight-qwen3-4b-v7:Q8_0 # Run inference directly in the terminal: ./build/bin/llama-cli -hf moonlight-labs/moonlight-qwen3-4b-v7:Q8_0
Use Docker
docker model run hf.co/moonlight-labs/moonlight-qwen3-4b-v7:Q8_0
- Llama new
- LM Studio
- Jan
- vLLM
How to use moonlight-labs/moonlight-qwen3-4b-v7 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "moonlight-labs/moonlight-qwen3-4b-v7" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "moonlight-labs/moonlight-qwen3-4b-v7", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/moonlight-labs/moonlight-qwen3-4b-v7:Q8_0
- SGLang
How to use moonlight-labs/moonlight-qwen3-4b-v7 with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "moonlight-labs/moonlight-qwen3-4b-v7" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "moonlight-labs/moonlight-qwen3-4b-v7", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "moonlight-labs/moonlight-qwen3-4b-v7" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "moonlight-labs/moonlight-qwen3-4b-v7", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Ollama
How to use moonlight-labs/moonlight-qwen3-4b-v7 with Ollama:
ollama run hf.co/moonlight-labs/moonlight-qwen3-4b-v7:Q8_0
- Unsloth Desktop
- Pi
How to use moonlight-labs/moonlight-qwen3-4b-v7 with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf moonlight-labs/moonlight-qwen3-4b-v7:Q8_0
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": "moonlight-labs/moonlight-qwen3-4b-v7:Q8_0" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Docker Model Runner
How to use moonlight-labs/moonlight-qwen3-4b-v7 with Docker Model Runner:
docker model run hf.co/moonlight-labs/moonlight-qwen3-4b-v7:Q8_0
- Lemonade
How to use moonlight-labs/moonlight-qwen3-4b-v7 with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull moonlight-labs/moonlight-qwen3-4b-v7:Q8_0
Run and chat with the model
lemonade run user.moonlight-qwen3-4b-v7-Q8_0
List all available models
lemonade list
- Hermes Agent
How to use moonlight-labs/moonlight-qwen3-4b-v7 with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf moonlight-labs/moonlight-qwen3-4b-v7:Q8_0
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 moonlight-labs/moonlight-qwen3-4b-v7:Q8_0
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use moonlight-labs/moonlight-qwen3-4b-v7 with OpenClaw:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf moonlight-labs/moonlight-qwen3-4b-v7:Q8_0
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 "moonlight-labs/moonlight-qwen3-4b-v7:Q8_0" \ --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"
🌙 Moonlight Qwen3-4B v7
Moonlight is a privacy-first, sovereign AI assistant fine-tuned on top of Qwen3-4B. It is designed specifically for local and edge execution on consumer laptops (RTX 2050 4GB VRAM) and Android smartphones (via GGUF).
🌟 Key Features
- Strict Anti-Fabrication & Honesty: Refuses to invent facts, benchmark numbers, false status reports, or imaginary tool capabilities.
- Privacy-First Sovereignty: Engineered for 100% offline, local execution. Zero telemetry, zero cloud data transfer.
- Fluent Roman Hinglish: Native support for conversational Roman Hindi mixed with English without verbose repetitive boilerplate.
- Tool Honesty & Edge Grounding: Clear operational boundaries distinguishing internal knowledge from verified external runtime inputs.
- 4GB GPU & Mobile Friendly: Runs locally in 4-bit NF4 with CPU offload on 4GB GPUs, or in Q4_K_M / Q8_0 GGUF on Android devices.
📊 Benchmark & Evaluation Results
Tested against the frozen Moonlight Generalization Holdout Benchmark (36 test items):
| Evaluation Dimension | Pass Rate | Details |
|---|---|---|
| Python Code Generation | 100% (4 / 4) | Passed all executable unit tests and edge cases |
| Tool & Boundary Honesty | 100% (4 / 4) | Strict refusal of ungranted filesystem/network access |
| Adversarial Pressure | Pass | Refuses user pressure to mark unconfirmed operations as successful |
| Provenance & Identity | 100% (4 / 4) | Accurate attribution of engine vs publisher |
| Zero Regressions | Verified | No baseline capabilities broken from previous champion versions |
🚀 Quickstart Usage
Using Hugging Face Transformers
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
model_id = "your-username/moonlight-qwen3-4b-v7"
# 4-bit Quantization (fits in 3.5 GB VRAM)
quant_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_quant_type="nf4",
bnb_4bit_compute_dtype=torch.float16,
bnb_4bit_use_double_quant=True,
)
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
model_id,
quantization_config=quant_config,
device_map="auto",
torch_dtype=torch.float16,
)
system_prompt = """You are Moonlight, a privacy-first AI assistant powered by Qwen3-4B.
Be accurate, helpful, practical, and concise.
Never invent facts, sources, developer information, ownership information, benchmark results, measurements, or tool access."""
messages = [
{"role": "system", "content": system_prompt},
{"role": "user", "content": "What are the core design principles of Moonlight AI?"},
]
inputs = tokenizer.apply_chat_template(messages, tokenize=True, add_generation_prompt=True, return_tensors="pt").to(model.device)
outputs = model.generate(inputs, max_new_tokens=256, do_sample=False)
response = tokenizer.decode(outputs[0][inputs.shape[1]:], skip_special_tokens=True)
print(response)
📱 Mobile & Edge Deployment (GGUF)
Moonlight can be quantized and executed offline on Android using llama.cpp, Ollama, or PocketPal AI:
# Run with Ollama
ollama create moonlight -f Modelfile
ollama run moonlight
📜 Model Details
- Model Name: Moonlight Qwen3-4B v7
- Base Architecture: Qwen3-4B (Dense Causal LM)
- Parameters: 4.02 Billion
- Context Length: Up to 40,960 tokens
- Training Method: 4-bit QLoRA SFT with layer streaming
- License: Apache 2.0
- Downloads last month
- 53