Skip to content
Skillpedia
Agents48k Β· #6014

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.md

Copy 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

Use this skill to help me: https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/train-sentence-transformers/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
Want your AI to find skills like this on its own?Install the free Skillpedia MCP: one line, and it searches 15,000+ skills before each task.Install in 1 minute β†’

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_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.

[CrossEncoder]

  • references/losses_cross_encoder.md β€” pointwise / pairwise / listwise / distillation; pos_weight derivation; activation_fn=Identity() mandatory for non-BCE losses (silent eval-rank collapse otherwise).
  • references/evaluators_cross_encoder.md β€” CrossEncoderRerankingEvaluator recipe; named-evaluator key format eval_{name}_{primary_metric}.
  • scripts/train_cross_encoder_example.py β€” production template; copy this as your starting point.

[SparseEncoder]

  • references/losses_sparse_encoder.md β€” SpladeLoss wrapper 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 β€” TrainingArguments knobs, precision rules (load fp32 + autocast bf16/fp16; never torch_dtype=bfloat16), warmup_steps (float) vs deprecated warmup_ratio, save_steps must be a multiple of eval_steps for load_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.

repo: sickn33/agentic-awesome-skills

Popularity

GitHub stars
48k
Ranking position
#6014
License
MIT
Updated
10/15/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills