Instructions to use batiai/Qwen3-Embedding-4B-GGUF 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 batiai/Qwen3-Embedding-4B-GGUF 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 batiai/Qwen3-Embedding-4B-GGUF:Q6_K # Run inference directly in the terminal: llama cli -hf batiai/Qwen3-Embedding-4B-GGUF:Q6_K
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf batiai/Qwen3-Embedding-4B-GGUF:Q6_K # Run inference directly in the terminal: llama cli -hf batiai/Qwen3-Embedding-4B-GGUF:Q6_K
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 batiai/Qwen3-Embedding-4B-GGUF:Q6_K # Run inference directly in the terminal: ./llama-cli -hf batiai/Qwen3-Embedding-4B-GGUF:Q6_K
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 batiai/Qwen3-Embedding-4B-GGUF:Q6_K # Run inference directly in the terminal: ./build/bin/llama-cli -hf batiai/Qwen3-Embedding-4B-GGUF:Q6_K
Use Docker
docker model run hf.co/batiai/Qwen3-Embedding-4B-GGUF:Q6_K
- LM Studio
- Jan
- Ollama
How to use batiai/Qwen3-Embedding-4B-GGUF with Ollama:
ollama run hf.co/batiai/Qwen3-Embedding-4B-GGUF:Q6_K
- Unsloth Desktop
- Pi
How to use batiai/Qwen3-Embedding-4B-GGUF with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf batiai/Qwen3-Embedding-4B-GGUF:Q6_K
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": "batiai/Qwen3-Embedding-4B-GGUF:Q6_K" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Docker Model Runner
How to use batiai/Qwen3-Embedding-4B-GGUF with Docker Model Runner:
docker model run hf.co/batiai/Qwen3-Embedding-4B-GGUF:Q6_K
- Lemonade
How to use batiai/Qwen3-Embedding-4B-GGUF with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull batiai/Qwen3-Embedding-4B-GGUF:Q6_K
Run and chat with the model
lemonade run user.Qwen3-Embedding-4B-GGUF-Q6_K
List all available models
lemonade list
- Hermes Agent
How to use batiai/Qwen3-Embedding-4B-GGUF with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf batiai/Qwen3-Embedding-4B-GGUF:Q6_K
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 batiai/Qwen3-Embedding-4B-GGUF:Q6_K
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use batiai/Qwen3-Embedding-4B-GGUF with OpenClaw:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf batiai/Qwen3-Embedding-4B-GGUF:Q6_K
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 "batiai/Qwen3-Embedding-4B-GGUF:Q6_K" \ --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"
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 batiai/Qwen3-Embedding-4B-GGUF:Q6_KRun Hermes
hermesQwen3-Embedding-4B GGUF — Quantized by BatiAI
GGUF quantizations of Qwen/Qwen3-Embedding-4B — the mid-tier sweet spot for 16 GB+ Macs. Higher retrieval quality than 0.6B; leaner RAM than 8B. Part of BatiAI's on-device RAG stack for BatiFlow.
Quick Start
Ollama
ollama pull batiai/qwen3-embedding:4b # Q6_K (3.3 GB, recommended default)
ollama pull batiai/qwen3-embedding:4b-q8 # Q8_0 (4.3 GB, max quality)
curl http://localhost:11434/api/embeddings -d '{
"model": "batiai/qwen3-embedding:4b",
"prompt": "semantic search query"
}'
llama.cpp
./llama-server \
-m Qwen3-Embedding-4B-Q8_0.gguf \
--embeddings --pooling last -c 32768 \
--host 127.0.0.1 --port 8080
Available Quantizations
| File | Quant | Size | When to use |
|---|---|---|---|
Qwen3-Embedding-4B-Q6_K.gguf |
Q6_K | ~3.3 GB | recommended default — Q8↔Q6 drift cos 0.998, indistinguishable on retrieval |
Qwen3-Embedding-4B-Q8_0.gguf |
Q8_0 | ~4.3 GB | maximum quality, ~25 % bigger disk |
Why Q6 over Q8 as default? Measured drift 0.998 = cosine distance well below any retrieval noise floor. Saving ~1 GB matters on 16 GB Macs where every GB of free RAM helps. If you want maximum conservatism, pull :4b-q8.
Why no IQ3 / IQ4 for embedding? Unlike chat LLMs, embedding quality cascades into cosine-similarity drift at low bit-widths. Q6_K / Q8_0 are the safe range.
Quality Verification (measured)
Four-stage harness run on both quants. Full testset + script reproducible via scripts/bench-embedding-quality.sh.
| Stage | Test | Q8_0 | Q6_K |
|---|---|---|---|
| A. Same-lang semantics | 30 (EN+KO) triples, directional correctness | 30/30 (100 %) | 30/30 (100 %) |
| average margin | 0.289 | 0.289 | |
| B. Cross-lingual alignment | 30 EN↔KO parallel pairs | 30/30 (100 %) | 30/30 (100 %) |
| parallel cos avg | 0.762 | 0.761 | |
| unrelated cos avg | 0.220 | 0.221 | |
| separation Δ | 0.542 | 0.540 | |
| C. Real-doc top-1 retrieval | 20 EN chunks × 20 EN queries | 19/20 (95 %) | 19/20 (95 %) |
| 20 KO chunks × 20 KO queries | 20/20 (100 %) | 20/20 (100 %) | |
| combined recall | 97.5 % | 97.5 % | |
| D. Quant drift | Q8_0 ↔ Q6_K on 20 sample queries | avg cos 0.9984 (min 0.9979, max 0.9990) — PASS |
All stages PASS with comfortable margin. Q8_0 and Q6_K produce essentially identical retrieval quality on this testset, with Q6_K saving ~25 % on disk.
Quality tier comparison (across BatiAI text-embedding lineup)
| Model | A margin | B separation Δ | C recall (EN / KO) | D drift avg |
|---|---|---|---|---|
| Qwen3-Embedding-0.6B (Q6) | 0.281 | 0.521 | 95 % / 100 % | 0.9967 |
| Qwen3-Embedding-4B (Q6) | 0.289 | 0.540 | 95 % / 100 % | 0.9984 |
| Qwen3-Embedding-8B (Q6) | 0.308 | 0.569 | 100 % / 100 % | 0.9988 |
4B sits in the middle — meaningfully better separation than 0.6B, within striking distance of 8B, at roughly half the disk footprint of 8B. Recommended default for 16 GB+ Macs.
Matryoshka — runtime-configurable dimension
Qwen3-Embedding-4B outputs up to 2560 dimensions. BatiFlow RAG stack defaults to 1024 (quality / latency sweet spot per our tests). Truncate at read time — no re-embed needed:
emb = get_embedding(text) # [2560]
emb_1024 = emb[:1024] # truncate for storage savings
import numpy as np
emb_1024 = emb_1024 / np.linalg.norm(emb_1024) # re-normalize
Why text-only?
Qwen3-Embedding-4B is designed specifically for text. For multimodal (image + text), see Qwen3-VL-Embedding-8B on BatiAI.
| Task | Use |
|---|---|
| Document search / Q&A retrieval | this repo (text-only) |
| Image / screenshot search | batiai/Qwen3-VL-Embedding-2B-GGUF |
RAG Stack Integration
user query
↓ [Qwen3-Embedding 4B] ← YOU ARE HERE (mid tier)
1024-dim vector
↓ vector DB (sqlite-vec / LanceDB)
top-K candidates
↓ [Qwen3-Reranker 4B or 8B]
top-3
↓ [Qwen3.6-35B-A3B chat LLM]
answer
Recommended Usage — query vs document
# Query side
query = "Instruct: Given a document query, retrieve the most relevant chunk.\n" \
"Query: " + user_input
# Document side — no instruction prefix
document = chunk_text
BatiFlow handles this automatically. For custom integrations, see Qwen3-Embedding usage.
Why BatiAI?
- Quantized directly from Qwen's BF16 safetensors
general.author: BatiAIfor provenance- 4-stage quality harness (same-lang, cross-lingual, real-doc top-1, quant drift) — numbers published
- Paired with Qwen3-Reranker-4B and Qwen3.6-35B-A3B on the same org
Technical Details
- Original Model: Qwen/Qwen3-Embedding-4B
- Architecture: Qwen3 Causal LM → last-token pooling
- Parameters: 4.02 B
- Embedding dim: up to 2560 (Matryoshka)
- Context: 32 K
- License: Apache 2.0
- Quantized with: llama.cpp build
bafae2765 - Quantized by: BatiAI
BatiAI RAG Stack
| Role | Model | Repo |
|---|---|---|
| Text embedder (entry) | Qwen3-Embedding-0.6B | batiai/Qwen3-Embedding-0.6B-GGUF |
| Text embedder (mid) | Qwen3-Embedding-4B | this repo |
| Text embedder (top) | Qwen3-Embedding-8B | batiai/Qwen3-Embedding-8B-GGUF |
| VL embedder | Qwen3-VL-Embedding-2B / 8B | batiai/Qwen3-VL-Embedding-2B-GGUF |
| Reranker | Qwen3-Reranker-4B / 8B | batiai/Qwen3-Reranker-4B-GGUF |
| Chat LLM | Qwen3.6-35B-A3B | batiai/Qwen3.6-35B-A3B-GGUF |
License
Mirrors upstream Qwen Apache 2.0 — commercial use permitted.
- Downloads last month
- 238
6-bit
8-bit
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp# Start a local OpenAI-compatible server: llama serve -hf batiai/Qwen3-Embedding-4B-GGUF:Q6_K