Nomic Contrastors क्या है?
Nomic Contrastors कॉन्ट्रास्टिव टेक्स्ट और मल्टीमॉडल embedding मॉडल को ट्रेन और इवैल्यूएट करें. यह Retrieval & Knowledge (RAG) टूल्स की Embedding Models & Inference श्रेणी में आता है; ओपन सोर्स है और Python में लिखा गया है। शुरू करने के लिए: virtual environment बनाएं और सक्रिय करें.
सारांश
Contrastors, Nomic AI का contrastive learning toolkit है। इसमें nomic-embed परिवार के long-context text और multimodal embedding मॉडल का ट्रेनिंग कोड और रेसिपी शामिल हैं, जो पूरी तरह ओपन सोर्स हैं। इससे researchers और engineers खुद contrastive मॉडल ट्रेन और इवैल्यूएट कर सकते हैं।
यह उन टीमों के लिए है जो सिर्फ hosted API इस्तेमाल करने के बजाय अपने embedding मॉडल खुद बनाना चाहती हैं। यह Flash Attention पर बना है, multi-GPU training को सपोर्ट करता है, और GradCache का इस्तेमाल करता है, ताकि GPU memory सीमित होने पर भी बड़े batch size के साथ training की जा सके।
Embedding मॉडल की category में यह training वाले हिस्से में आता है: इसमें masked language modeling pretraining, contrastive pretraining और finetuning, flexible embedding sizes के लिए Matryoshka representation learning, और vision के लिए CLIP/LiT style training शामिल हैं।
यह क्या करता है
- Flash Attention पर बना, तेज़ और memory-efficient training के लिए
- DeepSpeed और torchrun के साथ multi-GPU training
- सीमित GPU memory में बड़े batch sizes के लिए GradCache सपोर्ट
- Flexible embedding sizes के लिए Matryoshka Representation Learning
- Vision के लिए CLIP और LiT style contrastive learning, साथ में ViT/timm model loading
- आम मॉडल (Pythia/GPTNeoX, BERT) के लिए Hugging Face सपोर्ट और MLM pretraining
शुरू करें
Contrastors, Flash Attention के custom CUDA kernels पर निर्भर करता है, इसलिए इंस्टॉल करने से पहले CUDA 11.8+ वाला Python environment सेट करें। nvcc --version से अपना CUDA version जांचें।
Virtual environment बनाएं और सक्रिय करें
CUDA और Flash Attention की dependencies को अलग रखने के लिए एक साफ़ Python venv इस्तेमाल करें।
python3 -m venv env
source env/bin/activatetorch और build tools इंस्टॉल करें
torch इंस्टॉल करें (अपने सिस्टम के लिए सही command के लिए PyTorch docs देखें), फिर Flash Attention के लिए ज़रूरी build helpers इंस्टॉल करें।
pip3 install torch torchvision torchaudio
pip install wheel packaging ninja setuptoolsFlash Attention kernels और package इंस्टॉल करें
Flash Attention को उसके custom kernels के साथ इंस्टॉल करें, फिर contrastors को editable mode में इंस्टॉल करें।
pip install --no-cache-dir flash-attn --no-build-isolation git+https://github.com/HazyResearch/flash-attention.git#subdirectory=csrc/rotary git+https://github.com/HazyResearch/flash-attention.git#subdirectory=csrc/layer_norm git+https://github.com/HazyResearch/flash-attention.git#subdirectory=csrc/fused_dense_lib git+https://github.com/HazyResearch/flash-attention.git#subdirectory=csrc/xentropy
pip install -e .Contrastive pretraining चलाएं
दिए गए configs में से किसी एक की ओर इशारा करते हुए, अपने GPUs पर torchrun से training run शुरू करें।
cd src/contrastors
torchrun --nproc-per-node=8 train.py --config=configs/train/contrastive_pretrain.yaml --dtype=bf16कमांड और कोड प्रोजेक्ट के अपने दस्तावेज़ों से लिए गए हैं — हमेशा जांचें आधिकारिक repo ताज़ा जानकारी के लिए।
कब इस्तेमाल करें
- MLM pretraining, उसके बाद contrastive pretraining और finetuning के साथ, शुरुआत से अपना BERT-based text embedding मॉडल ट्रेन करें
- अपने corpus पर nomic-embed-text-v1 training recipe को दोबारा बनाएं या उसे अपने हिसाब से ढालें
- GradCache का इस्तेमाल करके memory-limited GPUs पर बड़े effective batch sizes फिट करें
- CLIP/LiT style multimodal embeddings ट्रेन करें और flexible output sizes वाले Matryoshka embeddings बनाएं
How Nomic Contrastors compares
Nomic Contrastors alongside other open-source embedding models & inference tools AI/TLDR tracks, ranked by GitHub stars.
| टूल | स्टार | यह क्या करता है |
|---|---|---|
| Sentence Transformers | ★ 19.3k | Python में टेक्स्ट embeddings की गणना करें, उन्हें प्रशिक्षित करें और rerank करें |
| OpenCLIP | ★ 14.3k | image-text embeddings को ट्रेन और चलाने के लिए CLIP का ओपन इम्प्लीमेंटेशन |
| PyTorch Metric Learning | ★ 6.3k | PyTorch में embedding मॉडल ट्रेनिंग के लिए losses, miners और testers |
| EmbeddingGemma (Gemma) | ★ 5.9k | 308M मल्टीलिंगुअल एम्बेडिंग मॉडल, जो on-device चलने जितना छोटा है |
| Text Embeddings Inference (TEI) | ★ 5.2k | तेज़ HTTP API के ज़रिए ओपन सोर्स embedding और reranking मॉडल सर्व करें |
| text2vec | ★ 5k | चीनी या बहुभाषी टेक्स्ट को sentence embeddings में बदलें, ट्रेनिंग कोड के साथ |
| Infinity (Embeddings) | ★ 3k | एम्बेडिंग, रीरैंकर, CLIP और ColPali मॉडल चलाने के लिए हाई-थ्रूपुट REST API |
| Nomic Contrastors | ★ 807 | कॉन्ट्रास्टिव टेक्स्ट और मल्टीमॉडल embedding मॉडल को ट्रेन और इवैल्यूएट करें |

