Downloads · 30 days
19
10% of all-time downloads
dinhhungitsoft/Qwen3-Embedding-4B-bnb4
Qwen3-Embedding-4B-bnb4 is a sentence similarity model from dinhhungitsoft. Use it when you need a score for how close two texts are. It is set up for transformers. The card lists the license as apache-2.0.
This is a 4-bit quantized version of Qwen/Qwen3-Embedding-4B using BitsAndBytes NF4 quantization.
Downloads · 30 days
19
10% of all-time downloads
All-time downloads
189
Public
Parameters
4.1B
2.7 GB on disk
Likes
1
Public
Click a slice to open those files.
.safetensors2.7 GB · 100%
How the weights are stored.
U83.7B · 91%
From the Hugging Face model README
This is a 4-bit quantized version of Qwen/Qwen3-Embedding-4B using BitsAndBytes NF4 quantization.
bnb_4bit_quant_type: "nf4"bnb_4bit_use_double_quant: Truebnb_4bit_compute_dtype: float16Tested on Vietnamese corpus (100 documents) with 20 queries:
from transformers import AutoTokenizer, AutoModel
import torch
model_name = "dinhhungitsoft/Qwen3-Embedding-4B-bnb4"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModel.from_pretrained(
model_name,
trust_remote_code=True,
device_map="auto"
)
def embed(texts):
inputs = tokenizer(texts, padding=True, truncation=True, return_tensors="pt", max_length=512)
inputs = {k: v.to(model.device) for k, v in inputs.items()}
with torch.no_grad():
outputs = model(**inputs)
embeddings = outputs.last_hidden_state[:, 0, :] # CLS token
# Normalize embeddings
embeddings = torch.nn.functional.normalize(embeddings, p=2, dim=1)
return embeddings.cpu().numpy()
texts = ["Hà Nội là thủ đô của Việt Nam", "Paris is the capital of France"]
embeddings = embed(texts)
print(embeddings.shape) # (2, embedding_dim)
docker run -d \
--gpus all \
-v ~/.cache/huggingface:/root/.cache/huggingface \
-p 8000:8000 \
--ipc=host \
vllm/vllm-openai:latest \
--model dinhhungitsoft/Qwen3-Embedding-4B-bnb4 \
--trust-remote-code \
--gpu-memory-utilization 0.6 \
--max-model-len 4096
Then query via OpenAI-compatible API:
import requests
response = requests.post(
"http://localhost:8000/v1/embeddings",
json={
"model": "dinhhungitsoft/Qwen3-Embedding-4B-bnb4",
"input": ["Your text here"]
}
)
embeddings = response.json()["data"][0]["embedding"]
Optimized for:
If you use this model, please cite the original Qwen3 model:
@article{qwen3,
title={Qwen3 Technical Report},
author={Qwen Team},
year={2024}
}
Apache 2.0 (inherited from base model)