Skip to content

Train Sentence-Transformers Models

Guides an agent through fine-tuning embedding, reranker, sparse and ColBERT-style retrieval models

Stars
11,253
Licence
Apache-2.0
Files
15 files

What it does

When installed, this skill teaches an AI agent how to train or fine-tune sentence-transformers models for search, similarity and retrieval. It works as a router: it tells the agent which type of model fits the task (bi-encoder, cross-encoder reranker, sparse SPLADE, or ColBERT multi-vector), which reference documents to read on losses, evaluators, datasets and hardware, and which example training script to copy. The agent is told not to write training code from memory, so the resulting scripts follow the maintainers' tested patterns.

Great for

  • Machine learning engineers fine-tuning an embedding model on their own domain data
  • Teams building a two-stage search pipeline with a bi-encoder plus a reranker
  • Developers who want to publish a trained model to the Hugging Face Hub

Skip it if

  • Simply using an existing embedding model for search without training, since that needs no training skill (the references are long and mostly irrelevant)
  • Users without GPU access or a Hugging Face account when running large jobs, since hardware and HF Jobs usage costs money and needs credentials
  • Non-technical users who only want a finished model, since the output is Python code that must be run and checked

Try asking

  • “Fine-tune a sentence-transformers embedding model on my product FAQ pairs for semantic search”
  • “Train a CrossEncoder reranker on my query-passage relevance labels with hard negatives”
  • “Create a SPLADE sparse retrieval model for my Elasticsearch index”
  • “Train a ColBERT-style multi-vector model and evaluate it on NanoBEIR”
Step-by-step guide: how to use Train Sentence-Transformers ModelsInstall, first run, examples, tips and FAQs

Install in 3 steps

  1. 1

    Download the skill

    The ZIP contains the 15 original files, the Apache-2.0 licence and an attribution note.

    train-sentence-transformers.zip
  2. 2

    Add it to your agent

    Claude Code (all projects)

    mkdir -p ~/.claude/skills && unzip train-sentence-transformers.zip -d ~/.claude/skills/

    Claude Code / Agent SDK (this project only)

    mkdir -p .claude/skills && unzip train-sentence-transformers.zip -d .claude/skills/

    Claude apps (web/desktop): Settings → Capabilities → Skills → Upload skill, and choose the ZIP.

  3. 3

    Ask for the task

    No special command needed — the agent reads the skill's description and loads it when your request matches. Try one of the prompts above.

Get better results

  • Give the agent your dataset shape (pairs, triplets, labelled classes) up front so it picks the correct loss and column format
  • Start with a small smoke-test run and check the output before launching a full training job
  • Review any generated script and the Hub push target before running, since training code executes locally and uploads go to a public or private repo

What's inside

  • references/base_model_selection.md
  • references/dataset_formats.md
  • references/evaluators_cross_encoder.md
  • references/evaluators_multi_vector_encoder.md
  • references/evaluators_sentence_transformer.md
  • references/evaluators_sparse_encoder.md
  • references/hardware_guide.md
  • references/hf_jobs_execution.md
  • references/losses_cross_encoder.md
  • references/losses_multi_vector_encoder.md
  • references/losses_sentence_transformer.md
  • references/losses_sparse_encoder.md
  • references/model_architectures.md
  • references/prompts_and_instructions.md
  • SKILL.md

Redistributed unmodified from huggingface/skills under the Apache-2.0 licence. The assessment was drafted with AI from the skill's files on 2026-10-29. Skills can instruct your agent to run code — read SKILL.md and any scripts before installing.