# SentenceTransformers
**SentenceTransformers (SBERT) is the Python library most people reach for to turn text into [[Embeddings]] locally, without calling an API.** It wraps transformer models behind a two-line interface and runs on CPU or GPU.
```python
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("all-MiniLM-L6-v2")
vectors = model.encode(["some text", "more text"])
```
Why it's everywhere:
- **Local and free.** No API key, no per-token cost, no data leaving the machine. That's why tools like [[CocoIndexCode]] bundle it as the default, with cloud providers (via [[LiteLLM]]) as the opt-in alternative.
- **Big model zoo.** Hundreds of pretrained embedding and re-ranking models on Hugging Face, from tiny MiniLM to multilingual and domain-specific ones.
- **Built for retrieval.** Bi-encoders for fast similarity search, cross-encoders for precise re-ranking, plus support for asymmetric search where the query and document get encoded differently.
It's the embedding layer underneath a lot of [[Retrieval-Augmented Generation (RAG)]] and [[Semantic Search]] stacks.
License: Apache 2.0.
## References
- https://www.sbert.net/
- https://github.com/UKPLab/sentence-transformers
## Related
- [[Embeddings]]
- [[Semantic Search]]
- [[Retrieval-Augmented Generation (RAG)]]
- [[CocoIndexCode]]
- [[qmd]]
- [[LiteLLM]]