# sentence-transformers

> Embeddings, Retrieval, and Reranking

- **URL**: https://www.freshcrate.ai/projects/sentence-transformers
- **Author**: pypi
- **Category**: Databases
- **Latest version**: `v5.5.1` (2026-05-20)
- **License**: Apache 2.0
- **Source**: https://github.com/huggingface/sentence-transformers/
- **Homepage**: https://pypi.org/project/sentence-transformers/
- **Language**: Python
- **GitHub**: 18,570 stars, 2,774 forks
- **Registry**: pypi (`sentence-transformers`)
- **Tags**: `bert`, `embedding`, `networks`, `nlp`, `pypi`, `pytorch`, `sentence`, `transformer`, `xlnet`

## Description

<!--- BADGES: START --->

[![HF Models](https://img.shields.io/badge/%F0%9F%A4%97-models-yellow)](https://huggingface.co/models?library=sentence-transformers)
[![GitHub - License](https://img.shields.io/github/license/huggingface/sentence-transformers?logo=github&style=flat&color=green)][#github-license]
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/sentence-transformers?logo=pypi&style=flat&color=blue)][#pypi-package]
[![PyPI - Package Version](https://img.shields.io/pypi/v/sentence-transformers?logo=pypi&style=flat&color=orange)][#pypi-package]
[![Docs - GitHub.io](https://img.shields.io/static/v1?logo=github&style=flat&color=pink&label=docs&message=sentence-transformers)][#docs-package]

<!-- [![PyPI - Downloads](https://img.shields.io/pypi/dm/sentence-transformers?logo=pypi&style=flat&color=green)][#pypi-package] -->

<!--- BADGES: END --->

# Sentence Transformers: Embeddings, Retrieval, and Reranking

This framework provides an easy method to compute embeddings for accessing, using, and training state-of-the-art embedding and reranker models. It can be used to compute embeddings using Sentence Transformer models ([quickstart](https://sbert.net/docs/quickstart.html#sentence-transformer)), to calculate similarity scores using Cross-Encoder (a.k.a. reranker) models ([quickstart](https://sbert.net/docs/quickstart.html#cross-encoder)) or to generate sparse embeddings using Sparse Encoder models ([quickstart](https://sbert.net/docs/quickstart.html#sparse-encoder)). This unlocks a wide range of applications, including [semantic search](https://sbert.net/examples/applications/semantic-search/README.html), [semantic textual similarity](https://sbert.net/docs/sentence_transformer/usage/semantic_textual_similarity.html), and [paraphrase mining](https://sbert.net/examples/applications/paraphrase-mining/README.html).

A wide selection of over [15,000 pre-trained Sentence Transformers models](https://huggingface.co/models?library=sentence-transformers) are available for immediate use on 🤗 Hugging Face, including many of the state-of-the-art models from the [Massive Text Embeddings Benchmark (MTEB) leaderboard](https://huggingface.co/spaces/mteb/leaderboard). Additionally, it is easy to train or finetune your own [embedding models](https://sbert.net/docs/sentence_transformer/training_overview.html), [reranker models](https://sbert.net/docs/cross_encoder/training_overview.html) or [sparse encoder models](https://sbert.net/docs/sparse_encoder/training_overview.html) using Sentence Transformers, enabling you to create custom models for your specific use cases.

For the **full documentation**, see **[www.SBERT.net](https://www.sbert.net)**.

## Installation

We recommend **Python 3.10+**, **[PyTorch 1.11.0+](https://pytorch.org/get-started/locally/)**, and **[transformers v4.34.0+](https://github.com/huggingface/transformers)**.

**Install with pip**

```
pip install -U sentence-transformers
```

**Install with conda**

```
conda install -c conda-forge sentence-transformers
```

**Install from sources**

Alternatively, you can also clone the latest version from the [repository](https://github.com/huggingface/sentence-transformers) and install it directly from the source code:

```
pip install -e .
```

**PyTorch with CUDA**

If you want to use a GPU / CUDA, you must install PyTorch with the matching CUDA Version. Follow
[PyTorch - Get Started](https://pytorch.org/get-started/locally/) for further details how to install PyTorch.

## Getting Started

See [Quickstart](https://www.sbert.net/docs/quickstart.html) in our documentation.

### Embedding Models

First download a pretrained embedding a.k.a. Sentence Transformer model.

```python
from sentence_transformers import SentenceTransformer

model = SentenceTransformer("sentence-transformers/all-MiniLM-L6-v2")
```

Then provide some texts to the model.

```python
sentences = [
    "The weather is lovely today.",
    "It's so sunny outside!",
    "He drove to the stadium.",
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# => (3, 384)
```

And that's already it. We now have numpy arrays with the embeddings, one for each text. We can use these to compute similarities.

```python
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.6660, 0.1046],
#         [0.6660, 1.0000, 0.1411],
#         [0.1046, 0.1411, 1.0000]])
```

### Reranker Models

First download a pretrained reranker a.k.a. Cross Encoder model.

```python
from sentence_transformers import CrossEncoder

# 1. Load a pretrained CrossEncoder model
model = CrossEncoder("cross-encoder/ms-marco-MiniLM-L6-v2")
```

Then provide some texts to the model.

```python
# The texts for which to predict similarity scores
query = "How many people live in Berlin?"
passages = [
    "Berlin had a population of 3,520,031 registered inhabitants in an area

## Recent releases

| Version | Date | Urgency | Changes |
| --- | --- | --- | --- |
| `v5.5.1` | 2026-05-20 | High | This patch release fixes a small quirk with multimodal inference when using single-key multimodal inputs like `model.encode({"image": ...})`.  Install this version with ```bash # Training + Inference pip install sentence-transformers[train]==5.5.1  # Inference only, use one of: pip install sentence-transformers==5.5.1 pip install sentence-transformers[onnx-gpu]==5.5.1 pip install sentence-transformers[onnx]==5.5.1 pip install sentence-transformers[openvino]==5.5.1  # Multimodal depe |
| `v5.5.0` | 2026-05-12 | High | This release ships the `train-sentence-transformers` Agent Skill, adds two new training losses, and brings a long list of robustness and correctness fixes.  The new `train-sentence-transformers` Agent Skill lets AI coding agents (Claude Code, Codex, Cursor, Gemini CLI, ...) drive end-to-end training and fine-tuning across all three model types. `EmbedDistillLoss` is a new embedding-level knowledge distillation loss for `SentenceTransformer`: it aligns a student model's embeddings with pre-comp |
| `5.4.1` | 2026-04-21 | Low | Imported from PyPI (5.4.1) |
| `v5.4.1` | 2026-04-14 | Medium | This patch release allows `encode()` and `predict()` to accept 1D numpy string arrays as inputs.  Install this version with ```bash # Training + Inference pip install sentence-transformers[train]==5.4.1  # Inference only, use one of: pip install sentence-transformers==5.4.1 pip install sentence-transformers[onnx-gpu]==5.4.1 pip install sentence-transformers[onnx]==5.4.1 pip install sentence-transformers[openvino]==5.4.1  # Multimodal dependencies (optional): pip install sentence-tr |
| `v5.4.1` | 2026-04-14 | Medium | This patch release allows `encode()` and `predict()` to accept 1D numpy string arrays as inputs.  Install this version with ```bash # Training + Inference pip install sentence-transformers[train]==5.4.1  # Inference only, use one of: pip install sentence-transformers==5.4.1 pip install sentence-transformers[onnx-gpu]==5.4.1 pip install sentence-transformers[onnx]==5.4.1 pip install sentence-transformers[openvino]==5.4.1  # Multimodal dependencies (optional): pip install sentence-tr |
| `v5.4.1` | 2026-04-14 | Medium | This patch release allows `encode()` and `predict()` to accept 1D numpy string arrays as inputs.  Install this version with ```bash # Training + Inference pip install sentence-transformers[train]==5.4.1  # Inference only, use one of: pip install sentence-transformers==5.4.1 pip install sentence-transformers[onnx-gpu]==5.4.1 pip install sentence-transformers[onnx]==5.4.1 pip install sentence-transformers[openvino]==5.4.1  # Multimodal dependencies (optional): pip install sentence-tr |
| `v5.4.1` | 2026-04-14 | Medium | This patch release allows `encode()` and `predict()` to accept 1D numpy string arrays as inputs.  Install this version with ```bash # Training + Inference pip install sentence-transformers[train]==5.4.1  # Inference only, use one of: pip install sentence-transformers==5.4.1 pip install sentence-transformers[onnx-gpu]==5.4.1 pip install sentence-transformers[onnx]==5.4.1 pip install sentence-transformers[openvino]==5.4.1  # Multimodal dependencies (optional): pip install sentence-tr |
| `v5.4.1` | 2026-04-14 | Medium | This patch release allows `encode()` and `predict()` to accept 1D numpy string arrays as inputs.  Install this version with ```bash # Training + Inference pip install sentence-transformers[train]==5.4.1  # Inference only, use one of: pip install sentence-transformers==5.4.1 pip install sentence-transformers[onnx-gpu]==5.4.1 pip install sentence-transformers[onnx]==5.4.1 pip install sentence-transformers[openvino]==5.4.1  # Multimodal dependencies (optional): pip install sentence-tr |
| `v5.4.1` | 2026-04-14 | Medium | This patch release allows `encode()` and `predict()` to accept 1D numpy string arrays as inputs.  Install this version with ```bash # Training + Inference pip install sentence-transformers[train]==5.4.1  # Inference only, use one of: pip install sentence-transformers==5.4.1 pip install sentence-transformers[onnx-gpu]==5.4.1 pip install sentence-transformers[onnx]==5.4.1 pip install sentence-transformers[openvino]==5.4.1  # Multimodal dependencies (optional): pip install sentence-tr |
| `v5.4.1` | 2026-04-14 | Medium | This patch release allows `encode()` and `predict()` to accept 1D numpy string arrays as inputs.  Install this version with ```bash # Training + Inference pip install sentence-transformers[train]==5.4.1  # Inference only, use one of: pip install sentence-transformers==5.4.1 pip install sentence-transformers[onnx-gpu]==5.4.1 pip install sentence-transformers[onnx]==5.4.1 pip install sentence-transformers[openvino]==5.4.1  # Multimodal dependencies (optional): pip install sentence-tr |

## Citation

- HTML: https://www.freshcrate.ai/projects/sentence-transformers
- Markdown: https://www.freshcrate.ai/projects/sentence-transformers.md
- Dependencies JSON: https://www.freshcrate.ai/api/projects/sentence-transformers/deps

_Generated by freshcrate.ai. Indexes pypi releases for AI-agent ecosystem packages._
