train-sentence-transformers
What it does
This feature allows training or fine-tuning AI models to understand text similarity. It creates numerical representations (embeddings) of words or sentences, useful for tasks like information retrieval, text clustering, or classification.
When to use it
- βWhen you want the AI to find texts similar to an example text.
- βWhen you need to automatically group texts with similar themes.
- βWhen you want the AI to classify texts into different categories.
Skill link
https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/train-sentence-transformers/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agentβs skills folder.
Example of what to ask your AI
βTrain a model to find similar news articles about technology.β
5 new skills a week. 1 minute to read.
How it works
The system uses example data to teach the model to associate texts with similar meanings to close numbers. It adjusts the model based on specific examples to improve its performance in similarity or classification tasks.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
Train a sentence-transformers Model
When to Use
Use this skill when you need 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...
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_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.
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.
β¦
FAQ
What's the difference between SentenceTransformer, CrossEncoder, and SparseEncoder?
SentenceTransformer creates a number for each text (good for general search). CrossEncoder compares two texts together to give a score (good for refining results). SparseEncoder uses a different method to create sparse numbers, good for specific searches with indexes.
Do I need to write code to use this?
Yes, this feature is for those already familiar with programming. It provides models and instructions, but you'll need to adapt the code examples to your specific needs.
What are 'embeddings'?
Embeddings are numerical representations (vectors) of texts. Texts with similar meanings will have numerically close embeddings, allowing the AI to understand the relationship between them.
Details
Original description by the author
Train or fine-tune SentenceTransformer, CrossEncoder, and SparseEncoder models for retrieval, similarity, clustering, classification, reranking, and related embedding tasks.
Popularity
- GitHub stars
- 48k
- Ranking position
- #6014
- License
- MIT
- Updated
- 10/15/2026
Comments
- β¦
More skills from this repository
00-andruia-consultant
48kHelps your agent start or improve AI projects. It analyzes code, suggests tools, and creates action plans in Spanish.
007
48kLets your agent perform security audits and threat modeling. It's useful for protecting projects against attacks and vulnerabilities.
10-andruia-skill-smith
48kHelps your agent create or improve AI tools. It defines how tools work, writes documentation, and validates the structure.
20-andruia-niche-intelligence
48kLets your agent create a summary about a specific industry. It's useful for understanding the context, rules, usage patterns, and risks of a project, using reliable sources.
Similar skills
add-model-provider
394kLets your agent connect a new AI model provider to OpenClaw using safe setup commands, keep API keys out of plain text, and run a live test.
acp-router
394kHelps your agent send a task to a coding assistant such as Claude Code or Cursor through OpenClaw, so the work runs in that tool.
browser-automation
394kTeaches your agent to control web pages step by step, including logins, tabs, and recovery when a page stops responding.