# train-sentence-transformers

> Claude/Codex skill by [@huggingface](https://omgskills.com/library/huggingface/index.md) · 19k stars · Updated 2026-09-11

Train or fine-tune sentence-transformers models across \`SentenceTransformer\` (bi-encoder, dense or static embedding model for retrieval, similarity, clustering, classification, paraphrase mining, dedup, multimodal), \`CrossEncoder\` (reranker, pair scoring for two-stage retrieval / pair classification), \`SparseEncoder\` (SPLADE, sparse embedding model for learned-sparse retrieval), and \`MultiVectorEncoder\` (ColBERT / late-interaction, per-token embeddings scored with MaxSim). Covers loss selection, hard-negative mining, evaluators, distillation, LoRA, Matryoshka, and Hugging Face Hub publishing. Use for any sentence-transformers training task.

## Install

```sh
git clone https://github.com/huggingface/sentence-transformers /tmp/sentence-transformers && ln -s /tmp/sentence-transformers/skills/train-sentence-transformers ~/.claude/skills/train-sentence-transformers
```

## From README

Train a sentence-transformers Model This SKILL.md is a router, not a manual. It tells you which references and example scripts to load for your task. The actual content (recommended losses, evaluators, training-script structure, model selection, training-arg knobs, troubleshooting) lives in references/ and scripts/. Do not synthesize a training script from this file alone. Open the per-type production template (scripts/train example.py) and copy it as your starting point. The templates contain load-bearing scaffolding (autocast helper, model-card class, logger silencing list, force=True, seed, TF32, version-compatible imports, named-evaluator metric handling) that prior agent runs have repeatedly missed when rolling their own from a synthesized snippet.

## Links

- HTML page: https://omgskills.com/skills/huggingface/sentence-transformers/train-sentence-transformers/
- GitHub: https://github.com/huggingface/sentence-transformers
- Author: [@huggingface](https://omgskills.com/library/huggingface/index.md)

## More skills by this author

- [add-or-fix-type-checking](https://omgskills.com/skills/huggingface/transformers/add-or-fix-type-checking/index.md) — Fixes broken typing checks detected by ty, make typing, or make check-repo.
   - [@huggingface](https://omgskills.com/library/huggingface/index.md) · 165k stars
- [trl-training](https://omgskills.com/skills/huggingface/trl/trl-training/index.md) — Post-train LLMs with TRL (Transformers Reinforcement Learning) — SFT, DPO, GRPO, KTO, and reward-model training.
   - [@huggingface](https://omgskills.com/library/huggingface/index.md) · 19k stars
- [sync-models](https://omgskills.com/skills/huggingface/chat-ui/add-model-descriptions/index.md) — Sync chat-ui's model config with the HuggingFace router — add descriptions for new models, flag reasoning-capable ones,...
   - [@huggingface](https://omgskills.com/library/huggingface/index.md) · 11k stars
