Feature Extraction
Transformers
Safetensors
qwen3
text-generation
embeddings
nvfp4
blackwell
compressed-tensors
text-embeddings-inference
8-bit precision
Instructions to use andrebadini/Qwen3-Embedding-4B-NVFP4 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use andrebadini/Qwen3-Embedding-4B-NVFP4 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("feature-extraction", model="andrebadini/Qwen3-Embedding-4B-NVFP4")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("andrebadini/Qwen3-Embedding-4B-NVFP4") model = AutoModelForCausalLM.from_pretrained("andrebadini/Qwen3-Embedding-4B-NVFP4") - Notebooks
- Google Colab
- Kaggle
Qwen3-Embedding-4B (NVFP4 quantized)
Quantization of Qwen/Qwen3-Embedding-4B
to NVFP4 (NVIDIA FP4 with FP8 micro-block scales) for Blackwell GPUs (RTX 50-series, B200).
Format
- Quantization scheme: NVFP4 — weights in FP4 E2M1, scales in FP8 E4M3 per group of 16 elements
- Storage:
compressed-tensors(nvfp4-pack-quantized) - Layers quantized: all
Linearlayers exceptlm_head - Original size (BF16): ~8 GB
- Quantized size: 2.7 GB (~3.4x compression)
Usage
This model is in compressed-tensors format. To load on a Blackwell GPU:
import torch
from transformers import AutoModel, AutoTokenizer
model = AutoModel.from_pretrained(
"andrebadini/Qwen3-Embedding-4B-NVFP4",
torch_dtype=torch.bfloat16,
trust_remote_code=True,
device_map="auto",
)
tok = AutoTokenizer.from_pretrained("andrebadini/Qwen3-Embedding-4B-NVFP4", trust_remote_code=True)
inputs = tok("Your text here", return_tensors="pt").to(model.device)
with torch.no_grad():
outputs = model(**inputs)
# last-token pooling (matches Qwen3-Embedding-4B default)
emb = outputs.last_hidden_state[:, -1, :]
print(emb.shape) # torch.Size([1, 2560])
Inference server (vLLM)
Recommended (works out of the box on Blackwell):
vllm serve andrebadini/Qwen3-Embedding-4B-NVFP4 \
--runner pooling \
--convert embed \
--trust-remote-code
The --convert embed flag tells vLLM to run in embedding mode; the OpenAI-compatible
endpoint becomes POST /v1/embeddings.
Quantization recipe
default_stage:
default_modifiers:
QuantizationModifier:
targets: [Linear]
ignore: [lm_head]
scheme: NVFP4
Calibrated oneshot on 20 samples from neuralmagic/calibration (LLM split).
Hardware notes
- NVFP4 tensor cores require Blackwell (SM 120). On Hopper (H100) or older, kernels will JIT-compile through CUTLASS via FlashInfer (slower first run, cached after).
- The flashinfer cache (
~/.cache/flashinfer/0.6.12/120f/cached_ops/fp4_gemm_cutlass_sm120/) holds the JIT kernels; keep it across runs to avoid recompilation.
Limitations
- LM Studio does not currently load
compressed-tensorsformat. Usetransformersdirectly or run via vLLM / TGI. - Other inference engines (llama.cpp, exllamav2, etc.) do not yet support NVFP4.
License
Inherits Apache 2.0 from the original Qwen3-Embedding-4B.
- Downloads last month
- 32