Instructions to use priyaganesh2050/all-MiniLM-L6-v2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use priyaganesh2050/all-MiniLM-L6-v2 with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("priyaganesh2050/all-MiniLM-L6-v2") sentences = [ "That is a happy person", "That is a happy dog", "That is a very happy person", "Today is a sunny day" ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [4, 4] - Notebooks
- Google Colab
- Kaggle
all-MiniLM-L6-v2 (mirror)
A 6-layer MiniLM sentence encoder that maps text to a 384-dimensional normalized vector. It is the default workhorse for semantic search, clustering, deduplication and RAG retrieval โ roughly 90 MB and fast enough to embed thousands of sentences per second on CPU.
This is a mirror. The weights and tokenizer files here are an unmodified copy of
sentence-transformers/all-MiniLM-L6-v2, re-hosted on this profile for reproducibility and convenience. All credit for the original work belongs to its authors. The upstream license (apache-2.0) is preserved and applies to this copy. If you need the canonical version, please use the upstream repository.
This mirror carries only the PyTorch/safetensors weights and tokenizer (~92 MB). The upstream ONNX, OpenVINO, TensorFlow and Rust variants were intentionally left out to keep the repo small; fetch those from upstream if you need them.
Specs
| Layers | 6 |
| Embedding dim | 384 |
| Max sequence length | 256 word pieces (longer input is truncated) |
| Pooling | mean, then L2-normalized |
| Parameters | ~22.7M |
Usage
With sentence-transformers (recommended โ pooling and normalization are handled for you):
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("priyaganesh2050/all-MiniLM-L6-v2")
emb = model.encode(["How do I reset my password?", "password recovery steps"])
print(emb.shape) # (2, 384)
print(model.similarity(emb[0], emb[1]))
With plain transformers:
import torch, torch.nn.functional as F
from transformers import AutoTokenizer, AutoModel
tok = AutoTokenizer.from_pretrained("priyaganesh2050/all-MiniLM-L6-v2")
model = AutoModel.from_pretrained("priyaganesh2050/all-MiniLM-L6-v2")
def embed(texts):
batch = tok(texts, padding=True, truncation=True, return_tensors="pt")
out = model(**batch).last_hidden_state
mask = batch["attention_mask"].unsqueeze(-1).float()
pooled = (out * mask).sum(1) / mask.sum(1).clamp(min=1e-9)
return F.normalize(pooled, p=2, dim=1)
print(embed(["semantic search", "vector retrieval"]) @ embed(["finding similar text"]).T)
Notes
- Embeddings are already unit length, so cosine similarity is just a dot product.
- Input beyond 256 word pieces is silently truncated โ chunk long documents before embedding.
- English-only. For multilingual work use a multilingual encoder instead.
- Downloads last month
- -
Model tree for priyaganesh2050/all-MiniLM-L6-v2
Base model
nreimers/MiniLM-L6-H384-uncased