Sponsored byOutsenseAI that finds your next clients
SponsorGROUOutbound, LinkedIn content and leads for B2B teamsSponsorOutsenseAI that finds your next clientsAd+Your tool hereSeen by people installing AI tools@Weekly picksThe best new tools, one email a week

train-sentence-transformers

Skill by huggingface

Guides an AI assistant through training or fine-tuning sentence-transformers models. It is for developers building retrieval, similarity, reranking or sparse and late-interaction search models.

  • Score 94
  • 19k stars
  • Apache-2.0
  • Updated
Works withClaude CodeClaude apps Antigravity CLI

Install train-sentence-transformers

Built from the published package, never by AI.

git clone --depth 1 https://github.com/huggingface/sentence-transformers /tmp/sentence-transformers && mkdir -p ~/.claude/skills && cp -r /tmp/sentence-transformers/skills/train-sentence-transformers ~/.claude/skills/train-sentence-transformers

Run in your terminal. Claude Code loads skills from ~/.claude/skills automatically.

Step-by-step: install train-sentence-transformers in Claude Code

Skills can run scripts on your machine. Some need an API key: check the README.

About

This skill guides an AI assistant through training or fine-tuning sentence-transformers models. It covers four model types: SentenceTransformer bi-encoders, CrossEncoder rerankers, SparseEncoder SPLADE models, and MultiVectorEncoder ColBERT-style models. The skill works as a router. It points the assistant to reference files and production training scripts for each type, and it tells the assistant not to write a training script from this file alone.

The source covers loss selection, hard-negative mining, evaluators, distillation, LoRA, Matryoshka, and publishing to the Hugging Face Hub. Each run is expected to end with a verdict line that compares the trained model with a pre-training baseline. It is aimed at people training sentence-transformers models for retrieval, similarity, reranking or related tasks.

Written from the project's SKILL.md and checked against it.

What it can do

  • Model type selectionChooses between SentenceTransformer, CrossEncoder, SparseEncoder and MultiVectorEncoder for a task.
  • Loss selectionMatches training losses to the shape of the training data, using the loss reference files.
  • Hard-negative miningMines hard negatives with the scripts/mine_hard_negatives.py command line tool.
  • Evaluator setupSelects and configures evaluators and the metric used for best-model selection.
  • Variant training scriptsProvides scripts for Matryoshka, LoRA, distillation, multilingual and static embedding training.
  • Hub publishingPushes the trained model to the Hugging Face Hub, wrapped in try-except.
  • Smoke testingRuns a max_steps=1 check on a tiny dataset slice before a long training run.
  • Run verdictEnds each run with a VERDICT line comparing the trained score with the baseline.

What you need

  • Python with sentence-transformers[train] 5.0 or later
  • sentence-transformers 6.0 or later for MultiVectorEncoder
  • Hugging Face account with a write-scope token for Hub push
  • GPU, strongly recommended

Try asking

  • Train a reranker on my query and passage pairs using a CrossEncoder
  • Fine-tune a SentenceTransformer embedding model on my dataset with LoRA
  • Mine hard negatives from my corpus before training a retrieval model

Good to know

  • GPU strongly recommended. CPU works only for demos and StaticEmbedding.
  • The SparseNanoBEIR and MultiVectorNanoBEIR evaluators are English-only.
  • Requires sentence-transformers 6.0 or later for MultiVectorEncoder.
  • The skill is a router. Its production scripts must be used as the starting point, not a snippet written from this file.

Security check

A

No download-and-run commands, hidden instructions or signs of sending keys out were found.

Checked automatically: skills/train-sentence-transformers/SKILL.md, skills/train-sentence-transformers/scripts/mine_hard_negatives.py, skills/train-sentence-transformers/scripts/train_cross_encoder_distillation_example.py, skills/train-sentence-transformers/scripts/train_cross_encoder_example.py, skills/train-sentence-transformers/scripts/train_cross_encoder_listwise_example.py, skills/train-sentence-transformers/scripts/train_multi_vector_encoder_example.py, skills/train-sentence-transformers/scripts/train_sentence_transformer_distillation_example.py, skills/train-sentence-transformers/scripts/train_sentence_transformer_example.py, skills/train-sentence-transformers/scripts/train_sentence_transformer_make_multilingual_example.py. This looks for known risky patterns and is not a full audit. How grades work

Inside the skill

  • SKILL.md10 KB
  • references/base_model_selection.md7 KB
  • references/dataset_formats.md6 KB
  • references/evaluators_cross_encoder.md5 KB
  • references/evaluators_multi_vector_encoder.md7 KB
Show all 31 files
  • references/evaluators_sentence_transformer.md6 KB
  • references/evaluators_sparse_encoder.md5 KB
  • references/hardware_guide.md6 KB
  • references/hf_jobs_execution.md7 KB
  • references/losses_cross_encoder.md10 KB
  • references/losses_multi_vector_encoder.md12 KB
  • references/losses_sentence_transformer.md11 KB
  • references/losses_sparse_encoder.md5 KB
  • references/model_architectures.md9 KB
  • references/prompts_and_instructions.md6 KB
  • references/training_args.md15 KB
  • references/troubleshooting.md13 KB
  • scripts/mine_hard_negatives.py8 KB
  • scripts/train_cross_encoder_distillation_example.py9 KB
  • scripts/train_cross_encoder_example.py9 KB
  • scripts/train_cross_encoder_listwise_example.py10 KB
  • scripts/train_multi_vector_encoder_example.py9 KB
  • scripts/train_sentence_transformer_distillation_example.py12 KB
  • scripts/train_sentence_transformer_example.py8 KB
  • scripts/train_sentence_transformer_make_multilingual_example.py12 KB
  • scripts/train_sentence_transformer_matryoshka_example.py7 KB
  • scripts/train_sentence_transformer_multi_dataset_example.py10 KB
  • scripts/train_sentence_transformer_static_embedding_example.py10 KB
  • scripts/train_sentence_transformer_with_lora_example.py10 KB
  • scripts/train_sparse_encoder_distillation_example.py9 KB

And 1 more files on GitHub.

Alternatives to train-sentence-transformers

All alternatives →

Compare with agent-reproduce-align, google_contacts or m06-error-handling

train-sentence-transformers: common questions

Which model type should I train for reranking?

The source says rerank, ranker and two-stage requests map to CrossEncoder. It is used to score query and passage pairs jointly.

Does the skill publish trained models to Hugging Face?

Yes. The default is a public Hub push at the end of the run, wrapped in try-except. On HF Jobs it also enables in-trainer push.

Can I use it on a CPU only machine?

The source says a GPU is strongly recommended. CPU works only for demos and StaticEmbedding training.

How do I install train-sentence-transformers?

Run the command above to copy the skill into ~/.claude/skills/. Claude Code picks it up automatically.

Is train-sentence-transformers free?

The code is published under the Apache-2.0 licence. The service it connects to may have its own pricing.

Is train-sentence-transformers safe to use?

It scores 94 of 100. Grades: maintenance A, licence A, quality A. Security check: grade A, no risky patterns found in the files checked. Review the code before you install. How grades work.

What are alternatives to train-sentence-transformers?

Similar skills: agent-reproduce-align, google_contacts, m06-error-handling, caveman.

train-sentence-transformers Install

Add to stack

Loading.