Views
No views yet
[!NOTE] This is a mirror. The weights and tokenizer files here are an unmodified copy ofsentence-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.
| Layers | 6 |
| Embedding dim | 384 |
| Max sequence length | 256 word pieces (longer input is truncated) |
| Pooling | mean, then L2-normalized |
| Parameters | ~22.7M |
sentence-transformers (recommended — pooling and normalization are handled for you):1from sentence_transformers import SentenceTransformer
2
3model = SentenceTransformer("priyaganesh2050/all-MiniLM-L6-v2")
4emb = model.encode(["How do I reset my password?", "password recovery steps"])
5print(emb.shape) # (2, 384)
6print(model.similarity(emb[0], emb[1]))transformers:1import torch, torch.nn.functional as F
2from transformers import AutoTokenizer, AutoModel
3
4tok = AutoTokenizer.from_pretrained("priyaganesh2050/all-MiniLM-L6-v2")
5model = AutoModel.from_pretrained("priyaganesh2050/all-MiniLM-L6-v2")
6
7def embed(texts):
8 batch = tok(texts, padding=True, truncation=True, return_tensors="pt")
9 out = model(**batch).last_hidden_state
10 mask = batch["attention_mask"].unsqueeze(-1).float()
11 pooled = (out * mask).sum(1) / mask.sum(1).clamp(min=1e-9)
12 return F.normalize(pooled, p=2, dim=1)
13
14print(embed(["semantic search", "vector retrieval"]) @ embed(["finding similar text"]).T)