train-sentence-transformers

train-sentence-transformers is a skill for Claude Code from waybarrios/opencode-power-pack. It costs 56 tokens per session (2,094 once invoked), scanned A, original, MIT.

A guide for training or fine-tuning sentence-transformer models, which turn text into vectors or score pairs of text for tasks such as search and ranking. It covers bi-encoders, rerankers, sparse models, training losses, evaluation, and related techniques.

In plain words
What is it for?
Use it to train models for retrieval, similarity, clustering, classification, paraphrase finding, duplicate detection, or reranking search results.
Why use it?
It helps choose the right model type and training setup for a text task. It also points to production templates and guidance for handling negatives, distillation, LoRA, and model evaluation.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the opencode-power-pack plugin — 54 skills shipped together

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/waybarrios/opencode-power-pack/train-sentence-transformers
Any agent
npx skills add waybarrios/opencode-power-pack --skill train-sentence-transformers
Clone the repo
git clone --depth 1 https://github.com/waybarrios/opencode-power-pack

Made for: Claude Code.

Or install opencode-power-pack, the plugin that ships this one along with the rest of its 54 skills.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for train-sentence-transformers

README.md
[![agentmods](https://agentmods.dev/badge/skills/waybarrios/opencode-power-pack/train-sentence-transformers.svg)](https://agentmods.dev/skills/waybarrios/opencode-power-pack/train-sentence-transformers)
Your own site
<a href="https://agentmods.dev/skills/waybarrios/opencode-power-pack/train-sentence-transformers"><img src="https://agentmods.dev/badge/skills/waybarrios/opencode-power-pack/train-sentence-transformers.svg" alt="Measured on agentmods" height="20"></a>
Per session 56 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,094 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00056 $0.02094
Opus 5 $0.00028 $0.01047
Sonnet 5 $0.00011 $0.00419
Haiku 4.5 $0.00006 $0.00209

Measured 6d ago against content hash 25a58b414b8b, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

train-sentence-transformers scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 6d ago.

The scan reads SKILL.md. This mod also ships 13 executable files (scripts/mine_hard_negatives.py, scripts/train_cross_encoder_distillation_example.py, scripts/train_cross_encoder_example.py, …), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/train-sentence-transformers/SKILL.md · 103 lines

How it starts

The opening of the file, as written. The whole thing — 103 lines — stays where its author put it; the contents beside it link to each section on GitHub.

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)

Tiebreakers when the request is ambiguous: "embedding model" / "vector search" / "similarity" → [SentenceTransformer]. "rerank" / "ranker" / "two-stage" → [CrossEncoder]. "SPLADE" / "sparse" / "inverted index" → [SparseEncoder]. 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_DUPLICATES requirement for MNRL-family; Cached*gradient_checkpointing incompatibility.
  • references/evaluators_sentence_transformer.md — evaluator-to-task mapping; metric_for_best_model key construction (named vs unnamed); per-evaluator primary_metric values.
  • 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.

Read the full file on GitHub · 103 lines

Files

What ships with it

27 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 6d ago First seen · 103 lines · 56 tokens per session scan A 25a58b414b8b

Subscribe to this mod's changes

train-sentence-transformers is a skill published in the GitHub repository waybarrios/opencode-power-pack (490 stars, last pushed 4d ago), licensed MIT. It adds 56 tokens to every session and 2,094 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.