Feature Extraction
sentence-transformers
Safetensors
Transformers
qwen3
text-generation
sentence-similarity
text-embeddings-inference
Instructions to use Qwen/Qwen3-Embedding-8B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use Qwen/Qwen3-Embedding-8B with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("Qwen/Qwen3-Embedding-8B") sentences = [ "The weather is lovely today.", "It's so sunny outside!", "He drove to the stadium." ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [3, 3] - Transformers
How to use Qwen/Qwen3-Embedding-8B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("feature-extraction", model="Qwen/Qwen3-Embedding-8B")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen3-Embedding-8B") model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen3-Embedding-8B", device_map="auto") - Inference
- Notebooks
- Google Colab
- Kaggle
Add missing `torch_dtype` in commented snippet in `README.md`
#9
by alvarobartt HF Staff - opened
Without setting the torch_dtype the snippet will fail with RuntimeError: FlashAttention only support fp16 and bf16 data type, as it defaults to torch.float32.
@Qwen Please merge this is needed to make it work
Still not merged and I've also encountered this issue recently...π
You can also set it to "torch_dtype":"auto"
this will reference config.json and load it as bfloat16