It is important that your dataset format matches your loss function (or that you choose a loss function that matches your dataset format). See Training Overview > Dataset…
Dataset Overview
It is important that your dataset format matches your loss function (or that you choose a loss function that matches your dataset format). See Training Overview > Dataset Format to learn how to verify whether a dataset format works with a loss function.
In practice, most dataset configurations will take one of four forms:
- Positive Pair: A pair of related sentences. This can be used both for symmetric tasks (semantic textual similarity) or asymmetric tasks (semantic search), with examples including pairs of paraphrases, pairs of full texts and their summaries, pairs of duplicate questions, pairs of (
query,response), or pairs of (source_language,target_language). Natural Language Inference datasets can also be formatted this way by pairing entailing sentences.- Examples: sentence-transformers/sentence-compression, sentence-transformers/coco-captions, sentence-transformers/codesearchnet, sentence-transformers/natural-questions, sentence-transformers/gooaq, sentence-transformers/squad, sentence-transformers/wikihow, sentence-transformers/eli5
- Triplets: (anchor, positive, negative) text triplets. These datasets don't need labels.
- Examples: sentence-transformers/quora-duplicates, nirantk/triplets, sentence-transformers/all-nli
- Pair with Similarity Score: A pair of sentences with a score indicating their similarity. Common examples are "Semantic Textual Similarity" datasets.
- Examples: sentence-transformers/stsb, PhilipMay/stsb_multi_mt.
- Texts with Classes: A text with its corresponding class. This data format is easily converted by loss functions into three sentences (triplets) where the first is an "anchor", the second a "positive" of the same class as the anchor, and the third a "negative" of a different class.
- Examples: trec, yahoo_answers_topics.
Note that it is often simple to transform a dataset from one format to another, such that it works with your loss function of choice.
Multimodal Datasets
Dataset columns are not limited to text. When using a multimodal model (e.g. a vision-language model like Qwen/Qwen3-VL-Embedding-2B), columns can contain images, audio, video, or combinations of these modalities. The same dataset format categories described above (Positive Pair, Triplets, etc.) apply. The only difference is that one or more columns hold non-text data instead of strings.
Accepted column types
See Input Formats for accepted representations, array shapes, and metadata. Each dataset column contains individual inputs in these formats. The model must support the modalities used by your dataset.
Cross-modal dataset example
A common use case is matching text queries to document screenshots (images). This is simply a Positive Pair dataset where the first column contains text and the second column contains images:
from datasets import load_dataset
dataset = load_dataset("tomaarsen/llamaindex-vdr-en-train-preprocessed", "train", split="train")
"""
Dataset({
features: ['query', 'image', 'negative_0', 'negative_1', 'negative_2', 'negative_3'],
num_rows: 10000
})
"""
print(dataset[0]["query"])
# "What are the new anthropological perspectives on development as discussed by Quarles Van Ufford and Giri in 2003?"
print(dataset[0]["image"])
# <PIL.Image.Image image mode=RGB size=...>
Here, query is a text column and image is an image column. The first column is the anchor and the second is the positive, just like a standard Positive Pair dataset. The negative columns (negative_0 through negative_3) contain additional hard-negative images.
Automatic preprocessing
You do not need to manually tokenize text or transform images before training. The data collator calls the model's preprocess method on each column, which automatically detects the modality (text, image, audio, or video) and applies the appropriate preprocessing (tokenization, pixel processing, audio feature extraction, etc.). This means you can pass raw PIL.Image objects, file paths, or URLs directly in your dataset and they will be handled correctly.
Datasets on the Hugging Face Hub
For more information on how to manipulate your dataset see the Datasets Documentation.
Pre-existing Datasets
The Hugging Face Hub hosts 150k+ datasets, many of which can be converted for training embedding models.
We are aiming to tag all Hugging Face datasets that work out of the box with Sentence Transformers with sentence-transformers, allowing you to easily find them by browsing to We strongly recommend that you browse these datasets to find training datasets that might be useful for your tasks.
These are some of the popular pre-existing datasets tagged as sentence-transformers that can be used to train and fine-tune SentenceTransformer models:
表格(50 行)
| Dataset | Description |
|---|---|
| GooAQ | (Question, Answer) pairs from Google auto suggest |
| Yahoo Answers | (Title+Question, Answer), (Title, Answer), (Title, Question), (Question, Answer) pairs from Yahoo Answers |
| MS MARCO Triplets (msmarco-distilbert-base-tas-b) | (Question, Answer, Negative) triplets from MS MARCO Passages dataset with mined negatives |
| MS MARCO Triplets (msmarco-distilbert-base-v3) | (Question, Answer, Negative) triplets from MS MARCO Passages dataset with mined negatives |
| MS MARCO Triplets (msmarco-MiniLM-L6-v3) | (Question, Answer, Negative) triplets from MS MARCO Passages dataset with mined negatives |
| MS MARCO Triplets (distilbert-margin-mse-cls-dot-v2) | (Question, Answer, Negative) triplets from MS MARCO Passages dataset with mined negatives |
| MS MARCO Triplets (distilbert-margin-mse-cls-dot-v1) | (Question, Answer, Negative) triplets from MS MARCO Passages dataset with mined negatives |
| MS MARCO Triplets (distilbert-margin-mse-mean-dot-v1) | (Question, Answer, Negative) triplets from MS MARCO Passages dataset with mined negatives |
| MS MARCO Triplets (mpnet-margin-mse-mean-v1) | (Question, Answer, Negative) triplets from MS MARCO Passages dataset with mined negatives |
| MS MARCO Triplets (co-condenser-margin-mse-cls-v1) | (Question, Answer, Negative) triplets from MS MARCO Passages dataset with mined negatives |
| MS MARCO Triplets (distilbert-margin-mse-mnrl-mean-v1) | (Question, Answer, Negative) triplets from MS MARCO Passages dataset with mined negatives |
| MS MARCO Triplets (distilbert-margin-mse-sym-mnrl-mean-v1) | (Question, Answer, Negative) triplets from MS MARCO Passages dataset with mined negatives |
| MS MARCO Triplets (distilbert-margin-mse-sym-mnrl-mean-v2) | (Question, Answer, Negative) triplets from MS MARCO Passages dataset with mined negatives |
| MS MARCO Triplets (co-condenser-margin-mse-sym-mnrl-mean-v1) | (Question, Answer, Negative) triplets from MS MARCO Passages dataset with mined negatives |
| MS MARCO Triplets (BM25) | (Question, Answer, Negative) triplets from MS MARCO Passages dataset with mined negatives |
| Stack Exchange Duplicates | (Title, Title), (Title+Body, Title+Body), (Body, Body) pairs of duplicate questions from StackExchange |
| ELI5 | (Question, Answer) pairs from ELI5 dataset |
| SQuAD | (Question, Answer) pairs from SQuAD dataset |
| WikiHow | (Summary, Text) pairs from WikiHow |
| Amazon Reviews 2018 | (Title, review) pairs from Amazon Reviews |
| Natural Questions | (Query, Answer) pairs from the Natural Questions dataset |
| Amazon QA | (Question, Answer) pairs from Amazon |
| S2ORC | (Title, Abstract), (Abstract, Citation), (Title, Citation) pairs of scientific papers |
| Quora Duplicates | Duplicate question pairs from Quora |
| WikiAnswers | Duplicate question pairs from WikiAnswers |
| AGNews | (Title, Description) pairs of news articles from the AG News dataset |
| AllNLI | (Anchor, Entailment, Contradiction) triplets from SNLI + MultiNLI |
| NPR | (Title, Body) pairs from the npr.org website |
| SPECTER | (Title, Positive Title, Negative Title) triplets of Scientific Publications from Specter |
| Simple Wiki | (English, Simple English) pairs from Wikipedia |
| PAQ | (Query, Answer) from the Probably-Asked Questions dataset |
| altlex | (English, Simple English) pairs from Wikipedia |
| CC News | (Title, article) pairs from the CC News dataset |
| CodeSearchNet | (Comment, Code) pairs from open source libraries on GitHub |
| Sentence Compression | (Long text, Short text) pairs from the Sentence Compression dataset |
| Trivia QA | (Query, Answer) pairs from the TriviaQA dataset |
| Flickr30k Captions | Duplicate captions from the Flickr30k dataset |
| xsum | (News Article, Summary) pairs from XSUM dataset |
| Coco Captions | Duplicate captions from the Coco Captions dataset |
| Parallel Sentences: Europarl | (English, Non-English) pairs across numerous languages |
| Parallel Sentences: Global Voices | (English, Non-English) pairs across numerous languages |
| Parallel Sentences: MUSE | (English, Non-English) pairs across numerous languages |
| Parallel Sentences: JW300 | (English, Non-English) pairs across numerous languages |
| Parallel Sentences: News Commentary | (English, Non-English) pairs across numerous languages |
| Parallel Sentences: OpenSubtitles | (English, Non-English) pairs across numerous languages |
| Parallel Sentences: Talks | (English, Non-English) pairs across numerous languages |
| Parallel Sentences: Tatoeba | (English, Non-English) pairs across numerous languages |
| Parallel Sentences: WikiMatrix | (English, Non-English) pairs across numerous languages |
| Parallel Sentences: WikiTitles | (English, Non-English) pairs across numerous languages |
Source and license
Source: Sentence Transformers documentation, adapted for this site. Licensing and attribution follow the terms of the upstream project.