मुख्य सामग्री पर जाएँ
Skillpedia
मशीन लर्निंग11k · #11781

train-sentence-transformers

यह क्या करती है

यह स्किल ऐसे मॉडल ट्रेन करती है जो टेक्स्ट को खोजे जा सकने वाले vectors में बदलते हैं, या यह आंकते हैं कि दो टेक्स्ट कितने मेल खाते हैं। यह उन डेवलपर्स के लिए है जो खोज, मिलान या क्लस्टरिंग फ़ीचर बना रहे हैं।

कब इस्तेमाल करें

  • ✓जब आप खोज या समानता के लिए embedding मॉडल को fine-tune करना चाहते हैं।
  • ✓जब आप ऐसा reranker ट्रेन करना चाहते हैं जो query और passage के जोड़ों को आंके।
  • ✓जब आपको sparse या multi-vector retrieval मॉडल ट्रेन करना हो।

Skill का लिंक

https://github.com/huggingface/skills/blob/main/skills/train-sentence-transformers/SKILL.md

इसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।

कैसे इस्तेमाल करें

सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।

पेस्ट करने के लिए तैयार मैसेज

इस skill से मेरी मदद करो: https://github.com/huggingface/skills/blob/main/skills/train-sentence-transformers/SKILL.md इस लिंक की SKILL.md फ़ाइल पढ़ो और मेरे काम में उसके निर्देशों का पालन करो।
क्या आप चाहते हैं कि आपका AI ऐसी skills खुद ढूँढे?मुफ़्त Skillpedia MCP इंस्टॉल करें: बस एक लाइन, और हर काम से पहले यह 15,000+ skills में खोजता है।1 मिनट में इंस्टॉल करें →

AI से क्या माँगें: उदाहरण

“मेरे सहायता प्रश्नों और उत्तरों के जोड़ों पर एक sentence-transformers मॉडल fine-tune कीजिए, ताकि खोज बेहतर हो।”

हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।

यह कैसे काम करती है

AI सही मॉडल प्रकार चुनता है, जैसे bi-encoder, cross-encoder या sparse encoder। फिर वह शून्य से स्क्रिप्ट लिखने की बजाय परखे हुए ट्रेनिंग टेम्पलेट से शुरू करता है और उसे आपके डेटा के अनुसार ढालता है।

तकनीकी सामग्री (मूल SKILL.md)

लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे 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)
[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_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.

[MultiVectorEncoder]

  • references/losses_multi_vector_encoder.md: MaxSim scoring, scale choice per scoring mode (scale=1.0 for MaxSim, roughly the average query length for MeanMaxSim), MNRL / CachedMNRL / MarginMSE / DistillKLDiv, XTR-vs-ColBERT scoring, CachedMNRL ↔ gradient_checkpointing incompatibility.
  • references/evaluators_multi_vector_encoder.md: MultiVectorNanoBEIREvaluator (English-only) and the in-domain alternative, eval_NanoBEIR_mean_maxsim_ndcg@10 key 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: TrainingArguments knobs, pre
अक्सर पूछे जाने वाले सवाल

कौन से मॉडल प्रकार कवर होते हैं?

यह embeddings के लिए bi-encoders, reranking के लिए cross-encoders, SPLADE जैसे sparse encoders और multi-vector मॉडल कवर करती है।

टेम्पलेट से क्यों शुरू करें?

टेम्पलेट में सेटअप के वे विवरण होते हैं जो आसानी से छूट जाते हैं, इसलिए उनसे शुरू करने पर आम गलतियाँ बचती हैं।

क्या यह मॉडल प्रकार चुनने में मदद करती है?

हाँ। स्किल में एक तालिका है जो काम के हिसाब से मॉडल प्रकार चुनने में मदद करती है।

जानकारी

लेखक का मूल विवरण

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.

repo: huggingface/skills

लोकप्रियता

GitHub स्टार
11k
रैंकिंग में स्थान
#11781
लाइसेंस
Apache-2.0
अपडेट की गई
30/10/2026

क्या यह skill काम की है?

0

लॉग इन करें वोट करने के लिए।

कमेंट

  • …

इस repository की और skills

hf-cli

11k

यह आपके एजेंट को hf कमांड लाइन टूल से Hugging Face पर मॉडल, डेटासेट, Spaces, रिपो और लोकल कैश डाउनलोड करने, अपलोड करने और संभालने में मदद करती है।

डेटामशीन लर्निंग

hf-cloud-aws-context-discovery

11k

यह आपके एजेंट को किसी भी क्लाउड काम से पहले AWS प्रोफ़ाइल, क्षेत्र और खाते का विवरण खोजने में मदद करती है, ताकि वह अंदाज़ा लगाकर खाता न चुने।

कोडिंगडिप्लॉय और क्लाउड (DevOps)

hf-cloud-python-env-setup

11k

यह आपके एजेंट को SageMaker या AWS ऑटोमेशन चलाने से पहले सही Python संस्करण और ताज़ा लाइब्रेरी वाला साफ़ Python वातावरण सेट करने में मदद करती है।

कोडिंगडिप्लॉय और क्लाउड (DevOps)

hf-cloud-sagemaker-deployment-planner

11k

यह आपके एजेंट को मॉडल को Amazon SageMaker पर डिप्लॉय करने की योजना बनाने में मदद करती है, real-time, serverless, async या batch होस्टिंग में से सही विकल्प चुनकर।

कोडिंगडिप्लॉय और क्लाउड (DevOps)

मिलती-जुलती skills