train-sentence-transformers
Skill11k starsChanged 43 days agoApache-2.0View on GitHub
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.
- Installs packages
6 other projects use a version of this, 4 of them edited.
Adopted by
Steady: 0 new projects took it in the last 4 weeks, none the 4 weeks before.thin data
Most recently taken up by
- PracticalSwan/agent-skillsedited, first seen Oct 19, 2026
- waybarrios/opencode-power-packedited, first seen Oct 13, 2026
- huggingface/sentence-transformersword for word, first seen Aug 11, 2026
- Adhamxon/claude-code-skillsedited, first seen Jul 30, 2026
- noahsilve123/claude-skillsetedited, first seen Jul 3, 2026
- tim-osterhus/millrace-skillstheir own version, first seen Apr 28, 2026
Who's talking about huggingface/skills
- Alejandro AO“Fine-Tune an Open Source LLM with Claude Code/Codex (Hugging Face Model Trainer Skill)”YouTube · Feb 17, 2026 · 30k views
- A Hacker News story“Hugging Face Skills”Hacker News · Feb 24, 2026 · 201 points
- Dhaval Bhatt | AI Product Accelerator“AI Agents are Broken - Here's how I fixed them”YouTube · Apr 4, 2026 · 60 views
- Gourcer“huggingface/skills - Gource visualisation”YouTube · Feb 21, 2026 · 29 views
- mastra-ai/mastra“[FEATURE] Introduce skills support”GitHub · Jan 23, 2026 · 4 reactions
The biggest 5 of 56 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 56
Talked about on GitHub, YouTube, Bluesky, the web and Hacker News (56 times).
On GitHub · 45
- Jan 23, 2026[FEATURE] Introduce skills support — mastra-ai/mastra4 reactions · 9 comments
- May 13, 2026chore(deps): bump the uv-all group with 3 updates — Ven0m0/gemini-web-wrapper3 reactions · 7 comments
- May 17, 2026build(deps): bump sentence-transformers from 3.0.1 to 5.5.0 — EvezArt/evez-atlas2 reactions · 2 comments
- May 16, 2026deps(lora): bump the lora-deps group across 1 directory with 6 updates — Bryan-Roe/Aria1 reaction · 2 comments
- May 16, 2026deps(lora): bump the lora-deps group in /ai-projects/lora-training/microsoft_phi-silica-3.6_v1 with 8 updates — Bryan-Roe/Aria1 reaction · 4 comments
40 more on GitHub
- Feb 28, 2026Add Hugging Face skills tutorial link to Claude Agent Skills playbook — TomasHer/prompting-blueprints1 reaction · 1 comment
- Feb 17, 2026add `SKILLS.md` to Gradio repo, part 1 + cleanup — gradio-app/gradio1 reaction · 3 comments
- Nov 2, 2026chore(skills): bump the skill-packs group across 1 directory with 16 updates — solanabr/ai-kit0 reactions · 2 comments
- Oct 29, 2026claude-code-plugins.github.huggingface.skills: 0-unstable-2026-10-23 → 0-unstable-2026-10-29 — sudosubin/agents.nix0 reactions
- Oct 29, 2026claude-code-marketplaces.github.huggingface.skills: 0-unstable-2026-10-23 → 0-unstable-2026-10-29 — sudosubin/agents.nix0 reactions
- Oct 29, 2026agent-skills.github.huggingface.skills: 0-unstable-2026-10-23 → 0-unstable-2026-10-29 — sudosubin/agents.nix0 reactions
- Oct 23, 2026claude-code-marketplaces.github.huggingface.skills: 0-unstable-2026-10-08 → 0-unstable-2026-10-23 — sudosubin/agents.nix0 reactions
- Oct 23, 2026claude-code-plugins.github.huggingface.skills: 0-unstable-2026-10-08 → 0-unstable-2026-10-23 — sudosubin/agents.nix0 reactions
- Oct 23, 2026agent-skills.github.huggingface.skills: 0-unstable-2026-10-08 → 0-unstable-2026-10-23 — sudosubin/agents.nix0 reactions
- Oct 21, 2026chore(skills): bump the skill-packs group across 1 directory with 19 updates — solanabr/ai-kit0 reactions · 2 comments
- Oct 14, 2026claude-code-plugins.github.huggingface.skills: 0-unstable-2026-10-01 → 0-unstable-2026-10-08 — sudosubin/agents.nix0 reactions
- Oct 13, 2026agent-skills.github.huggingface.skills: 0-unstable-2026-10-01 → 0-unstable-2026-10-08 — sudosubin/agents.nix0 reactions
- Oct 13, 2026claude-code-marketplaces.github.huggingface.skills: 0-unstable-2026-10-01 → 0-unstable-2026-10-08 — sudosubin/agents.nix0 reactions
- Oct 4, 2026[Candidate] huggingface/skills/skills/hf-cloud-sagemaker-deployment-planner - hf-cloud-sagemaker-deployment-planner — ProSkillsMD/proskills0 reactions · 1 comment
- Oct 4, 2026[Candidate] huggingface/skills/skills/hf-cloud-python-env-setup - hf-cloud-python-env-setup — ProSkillsMD/proskills0 reactions · 1 comment
- Oct 4, 2026[Candidate] huggingface/skills/skills/hf-cloud-aws-context-discovery - hf-cloud-aws-context-discovery — ProSkillsMD/proskills0 reactions · 1 comment
- Oct 4, 2026claude-code-plugins.github.huggingface.skills: init at 0-unstable-2026-10-01 — sudosubin/agents.nix0 reactions
- Oct 4, 2026claude-code-marketplaces.github.huggingface.skills: init at 0-unstable-2026-10-01 — sudosubin/agents.nix0 reactions
- Oct 3, 2026agent-skills.github.huggingface.skills: 0-unstable-2026-09-17 → 0-unstable-2026-10-01 — sudosubin/agents.nix0 reactions
- Sep 28, 2026agent-skills.github.huggingface.skills: init at 0-unstable-2026-09-17 — sudosubin/agents.nix0 reactions
- Sep 14, 2026source is defined as the indexing registry and used as the artifact origin — ards-project/ard-spec0 reactions · 2 comments
- Aug 15, 2026Daily skills library maintenance: add official Cloudflare, Stripe, Hugging Face, and security skills — ilaysandrusi/skills-library0 reactions
- Jul 31, 2026Mode's skills — xavier-arosemena/roo-plus0 reactions
- Jul 29, 2026Federation request: index the iParq Parquet Inspector catalog — huggingface/hf-discover0 reactions
- Jul 9, 2026[Collection]: huggingface/skills — shimoncohen/the-great-skill-dictionary0 reactions · 1 comment
- Jul 3, 2026Audit candidate: huggingface/skills — xiaolai/nlpm0 reactions · 3 comments
- May 18, 2026chore(deps): update sentence-transformers requirement from >=2.7.0 to >=5.5.0 — m01126057061-lang/post-processing-ai-quality-api0 reactions · 1 comment
- May 18, 2026deps(deps): update sentence-transformers requirement from >=5.4.1 to >=5.5.0 — hotak92/vibecoded-orchestrator0 reactions · 1 comment
- May 15, 2026build(deps-dev): update sentence-transformers requirement from <5.0.0,>=2.5.0 to >=2.5.0,<6.0.0 — OktoLabsAI/okto-pulse-core0 reactions · 1 comment
- May 13, 2026build(deps): update sentence-transformers requirement from >=3.0 to >=5.5.0 — allenai/artifact-linker0 reactions
- Mar 20, 2026hugging-face-paper-pages, NielsRogge, 2026.03 — AkihikoWatanabe/paper_notes0 reactions · 1 comment
- Feb 28, 2026[News] 投稿 — Yuyz0112/koala-oss-app0 reactions · 3 comments
- Feb 20, 2026hugging-face-trackio — AAswordman/OperitSkillMarket0 reactions
- Feb 20, 2026hugging-face-tool-builder — AAswordman/OperitSkillMarket0 reactions
- Feb 20, 2026hugging-face-paper-publisher — AAswordman/OperitSkillMarket0 reactions
- Feb 20, 2026hugging-face-model-trainer — AAswordman/OperitSkillMarket0 reactions
- Feb 20, 2026hugging-face-jobs — AAswordman/OperitSkillMarket0 reactions
- Feb 20, 2026hugging-face-evaluation — AAswordman/OperitSkillMarket0 reactions
- Feb 20, 2026hugging-face-datasets — AAswordman/OperitSkillMarket0 reactions
- Feb 20, 2026hugging-face-cli — AAswordman/OperitSkillMarket0 reactions
On YouTube · 4
- Feb 17, 2026Fine-Tune an Open Source LLM with Claude Code/Codex (Hugging Face Model Trainer Skill) — Alejandro AO30k views · 42 comments
- Apr 4, 2026AI Agents are Broken - Here's how I fixed them — Dhaval Bhatt | AI Product Accelerator60 views · 1 comment
- Feb 21, 2026huggingface/skills - Gource visualisation — Gourcer29 views
- Feb 24, 2026🔥 skills is Taking Over GitHub — JQ Software2 views
On Bluesky · 4
- Mar 21, 2026The official Hugging Face skills repository that gives AI coding agents like Claude Code, Codex, and Cursor instant access to the entire ML… — @arifsolmaz.bsky.social3 likes and reposts · 1 reply
- Mar 11, 2026Install it with one command: npx skills add github.com/huggingface/... --skill transformers-js github.com/huggingface/skills — @nico.dev1 likes and repost
- Feb 24, 2026HuggingFace Agent Skills Discussion — @hn100.bsky.social1 likes and repost
- Feb 24, 2026💎 Hidden Gem! 💎 (1000+ new stars) 📦 huggingface / skills ⭐ 4,569 (+1,451) 🗒 Python — @github-trending.bsky.social1 likes and repost · 1 reply
On the web · 2
- Oct 23, 2026huggingface/skills agent skills - QAI — qai.io
- Feb 22, 2026Hugging Face Skills: The 'Plug-and-Play' Mental Model for ... — hoangyell.com
On Hacker News · 1
- Feb 24, 2026Hugging Face Skills201 points · 58 comments
Other versions6 projects use a version of this.
Word for word · 1
- huggingface/sentence-transformers★ 19k100% same
Edited · 4
- waybarrios/opencode-power-pack★ 54796% same
- PracticalSwan/agent-skills★ 2279% same
- Adhamxon/claude-code-skills★ 298% same
- noahsilve123/claude-skillset★ 198% same
Wrote their own version · 1
- tim-osterhus/millrace-skills★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository26 other files it gives its agents.
- agentsmd/AGENTS.mdAGENTS.md
- hf-mcpSkill
- hf-cliSkill
- hf-cloud-aws-context-discoverySkill
- hf-cloud-python-env-setupSkill
- hf-cloud-sagemaker-deployment-plannerSkill
- hf-cloud-sagemaker-iam-preflightSkill
- hf-cloud-sagemaker-production-defaultsSkill
- hf-cloud-serving-image-selectionSkill
- hf-memSkill
- huggingface-bestSkill
- huggingface-community-evalsSkill
- huggingface-datasetsSkill
- huggingface-gradioSkill
- huggingface-llm-trainerSkill
- huggingface-local-modelsSkill
- huggingface-lora-space-builderSkill
- huggingface-paper-publisherSkill
- huggingface-papersSkill
- huggingface-spacesSkill
- huggingface-tool-builderSkill
- huggingface-trackioSkill
- huggingface-vision-trainerSkill
- huggingface-zerogpuSkill
- transformers-jsSkill
- trl-trainingSkill
The file
We split this skill into the rules it gives an agent
2 rules. 0 are common, 0 are distinctive, and 2 are very specific to this project.
0
Common
Most of the 5 edited versions we read keep these.
0
Distinctive
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 73
Single run: After it completes, propose experimentation if the user would benefit (weak/marginal verdict, "see how high you can push it" …
- Very specific: line 98
After the run, append to logs/experiments.md and propose iteration if the verdict is weak/marginal.
“Common” is measured: kept by at least 6 in 10 of the 5 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
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_<type>_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.
1. Identify the model type
| Tag | Class | What it does | When to pick |
| [SentenceTransformer] | SentenceTransformer (bi-encoder) | Maps each input to a fixed-dim dense vector | Retrieval, similarity, clustering, classification, paraphrase mining, dedup |
| [CrossEncoder] | CrossEncoder (reranker) | Scores (query, passage) pairs jointly | Two-stage retrieval (rerank top-100 from bi-encoder), pair classification |
| [SparseEncoder] | SparseEncoder (SPLADE) | Sparse vectors over the vocabulary | Learned-sparse retrieval, inverted-index backends (Elasticsearch / OpenSearch / Lucene) |
| [MultiVectorEncoder] | MultiVectorEncoder (ColBERT) | One embedding per token, scored with MaxSim | Late-interaction retrieval, recall gains over bi-encoders at higher storage cost, multimodal (ColPali / ColQwen2) |
Tiebreakers when the request is ambiguous: "embedding model" / "vector search" / "similarity" → [SentenceTransformer]. "rerank" / "ranker" / "two-stage" → [CrossEncoder]. "SPLADE" / "sparse" / "inverted index" → [SparseEncoder]. "ColBERT" / "late interaction" / "multi-vector" / "MaxSim" / "ColPali" / "ColQwen" → [MultiVectorEncoder]. If still unclear, ask.
2. Required reading
Read these in full before writing any code. Do not triage by perceived relevance.
Per-type: always required
[SentenceTransformer]
references/losses_sentence_transformer.md: loss-to-data-shape mapping,BatchSamplers.NO_DUPLICATESrequirement for MNRL-family,Cached*↔gradient_checkpointingincompatibility.references/evaluators_sentence_transformer.md: evaluator-to-task mapping,metric_for_best_modelkey construction (named vs unnamed), per-evaluatorprimary_metricvalues.references/model_architectures.md: encoder vs decoder vs static vs Router pipelines, pooling rules (mean / cls / lasttoken), auto-mean-pooling behavior for fresh-start MLM bases.scripts/train_sentence_transformer_example.py: production template. Copy this as your starting point.
[CrossEncoder]
references/losses_cross_encoder.md: pointwise / pairwise / listwise / distillation,pos_weightderivation,activation_fn=Identity()mandatory for non-BCE losses (silent eval-rank collapse otherwise).references/evaluators_cross_encoder.md:CrossEncoderRerankingEvaluatorrecipe, named-evaluator key formateval_{name}_{primary_metric}.scripts/train_cross_encoder_example.py: production template. Copy this as your starting point.
[SparseEncoder]
references/losses_sparse_encoder.md:SpladeLosswrapper requirement, FLOPS regularizer weights, smoke-test active-dim ramp behavior.references/evaluators_sparse_encoder.md:SparseNanoBEIREvaluator(English-only) and the in-domain alternative,eval_{name}_{primary_metric}key format.scripts/train_sparse_encoder_example.py: production template. Copy this as your starting point.
[MultiVectorEncoder]
references/losses_multi_vector_encoder.md: MaxSim scoring, scale choice per scoring mode (scale=1.0for MaxSim, roughly the average query length for MeanMaxSim), MNRL / CachedMNRL / MarginMSE / DistillKLDiv, XTR-vs-ColBERT scoring, CachedMNRL ↔gradient_checkpointingincompatibility.references/evaluators_multi_vector_encoder.md:MultiVectorNanoBEIREvaluator(English-only) and the in-domain alternative,eval_NanoBEIR_mean_maxsim_ndcg@10key format, distillation-eval spearman variant.scripts/train_multi_vector_encoder_example.py: production template. Copy this as your starting point.
Cross-cutting: always required (regardless of task)
references/training_args.md:TrainingArgumentsknobs, precision rules (load fp32 + autocast bf16/fp16, nevertorch_dtype=bfloat16),warmup_steps(float) vs deprecatedwarmup_ratio,save_stepsmust be a multiple ofeval_stepsforload_best_model_at_end, schedulers, HPO, tracker, resume, hub-push variants.references/dataset_formats.md: column-matching rules (label name auto-detection, column-order-not-name), reshaping recipes, hard-negative mining options.references/base_model_selection.md: discovery commands, per-type model namespaces, ModernBERT-familymax_seq_length=8192trap,datasets >= 4script-loader rejection, non-English starting-point shortcuts.references/troubleshooting.md: symptom-indexed failure recipes. Skim the section headings on every run, even a healthy one. The "Metrics don't improve" and "Hub push fails" entries cover bugs that bite frequently and are cheaper to recognize before they fire than to debug after.
Cross-cutting: load when applicable
references/hardware_guide.md: VRAM sizing, multi-GPU, FSDP / DeepSpeed, HF Jobs flavors. Required for >24GB models, multi-GPU, or HF Jobs runs.references/hf_jobs_execution.md: required when running on HF Jobs.references/prompts_and_instructions.md: required when using prompt-tuned bases (E5, BGE, GTE, Qwen3-Embedding, Instructor, Nomic, etc.) or addingquery:/passage:style prefixes.
Variant scripts (open when the task matches)
- [SentenceTransformer]
scripts/train_sentence_transformer_<matryoshka|multi_dataset|with_lora|distillation|make_multilingual|static_embedding>_example.py. - [CrossEncoder]
scripts/train_cross_encoder_<distillation|listwise>_example.py. - [SparseEncoder]
scripts/train_sparse_encoder_distillation_example.py. - Hard-negative mining CLI:
scripts/mine_hard_negatives.py.
3. Defaults
Override only if the user specifies otherwise:
- Local execution. Pitch HF Jobs only if local hardware can't fit the job.
- Single run. After it completes, propose experimentation if the user would benefit (weak/marginal verdict, "see how high you can push it" framing, etc.). Iteration rules in
references/training_args.md(Experimentation section). - Public Hub push at end-of-run, wrapped in try-except. On HF Jobs (ephemeral env) ALSO enable in-trainer push (
push_to_hub=True+hub_strategy="every_save"). Details inreferences/hf_jobs_execution.md.
4. Constraints the produced script must satisfy
These are non-negotiable contracts. Implementation lives in the production templates and references. Do not reinvent.
- Capture the pre-training evaluator score as
baseline_evalbeforetrainer.train(). - Emit a single end-of-run line:
VERDICT: WIN|MARGINAL|REGRESSION | score=... | baseline=... | delta=.... A monitor scrapes for this. - Silence
httpx,httpcore,huggingface_hub,urllib3,filelock,fsspecto WARNING (otherwise HF download URLs flood the agent's context). - Tee logs to
logs/{RUN_NAME}.log. - End with
model.push_to_hub(...)wrapped intry/except. - Smoke-test before any long run (
max_steps=1+ tiny dataset slice). The production templates show one common pattern (SMOKE_TESTenv var). - [CrossEncoder] Include
EarlyStoppingCallback(patience>=3). CE rerankers often peak mid-training and regress. - [SparseEncoder] Log
query_active_dims/corpus_active_dimson the verdict line. High nDCG with collapsed sparsity is not a win. The keys come back name-prefixed (e.g...._query_active_dims). Use suffix matching to pluck them. See the SPARSE production template for the exact pattern. - [MultiVectorEncoder] Match
scaleto the scoring mode on any MNRL-family loss: near1.0for unnormalized MaxSim (do not copyscale=20.0from bi-encoder MNRL), roughly the average query length with length-normalized MeanMaxSim, since each score is divided by its query's token count.XTRScoresis a train-onlysimilarity_fct: the evaluators reject it, so evaluation always scores with MaxSim, including for XTR-trained models.
5. Workflow
- Identify the model type (§1). Ask if ambiguous.
- Load the §2 required-reading files for that type.
- Open
scripts/train_<type>_example.pyand copy it as your starting point. - Replace
MODEL_NAME,DATASET_NAME,RUN_NAME, the loss, and the evaluator with the user's task. Cross-check loss/data-shape match againstreferences/losses_<type>.md. Cross-check themetric_for_best_modelkey againstreferences/evaluators_<type>.md(named evaluators format the key aseval_{name}_{primary_metric}). - Smoke-test (
max_steps=1). - Run.
- After the run, append to
logs/experiments.mdand propose iteration if the verdict is weak/marginal.
Prerequisites
pip install "sentence-transformers[train]>=5.0" # add [train,image] / [audio] / [video] for [SentenceTransformer] multimodal
# [MultiVectorEncoder] requires >=6.0
pip install trackio # optional tracker (or wandb / tensorboard / mlflow)
hf auth login # or set HF_TOKEN with write scope (for Hub push)GPU strongly recommended. CPU works only for demos and [SentenceTransformer] StaticEmbedding.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

