Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Framework for state-of-the-art sentence, text, and image embeddings. Provides 5000+ pre-trained models for semantic similarity, clustering, and retrieval. Supports multilingual, domain-specific, and multimodal models. Use for generating embeddings for RAG, semantic search, or similarity tasks. Best for production embedding generation.
.claude/skills/openlair-sentence-transformers/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-06 | ✗→✓ | ▲ Improved | 61% | 0% |
| case-08 | ✗→✓ | ▲ Improved | 50% | 0% |
| case-12 | ✗→✓ | ▲ Improved | 28% | 0% |
| case-17 | ✓→✓ | = Same ✓ | 188% | 0% |
| case-01 | ✓→✓ | = Same ✓ | 3% | 0% |
Python framework for sentence and text embeddings using transformers.
Use when:
Metrics:
Use alternatives instead:
bashpip install sentence-transformers
pythonfrom sentence_transformers import SentenceTransformer # Load model model = SentenceTransformer('all-MiniLM-L6-v2') # Generate embeddings sentences = [ "This is an example sentence", "Each sentence is converted to a vector" ] embeddings = model.encode(sentences) print(embeddings.shape) # (2, 384) # Cosine similarity from sentence_transformers.util import cos_sim similarity = cos_sim(embeddings[0], embeddings[1]) print(f"Similarity: {similarity.item():.4f}")
python# Fast, good quality (384 dim) model = SentenceTransformer('all-MiniLM-L6-v2') # Better quality (768 dim) model = SentenceTransformer('all-mpnet-base-v2') # Best quality (1024 dim, slower) model = SentenceTransformer('all-roberta-large-v1')
python# 50+ languages model = SentenceTransformer('paraphrase-multilingual-MiniLM-L12-v2') # 100+ languages model = SentenceTransformer('paraphrase-multilingual-mpnet-base-v2')
python# Legal domain model = SentenceTransformer('nlpaueb/legal-bert-base-uncased') # Scientific papers model = SentenceTransformer('allenai/specter') # Code model = SentenceTransformer('microsoft/codebert-base')
pythonfrom sentence_transformers import SentenceTransformer, util model = SentenceTransformer('all-MiniLM-L6-v2') # Corpus corpus = [ "Python is a programming language", "Machine learning uses algorithms", "Neural networks are powerful" ] # Encode corpus corpus_embeddings = model.encode(corpus, convert_to_tensor=True) # Query query = "What is Python?" query_embedding = model.encode(query, convert_to_tensor=True) # Find most similar hits = util.semantic_search(query_embedding, corpus_embeddings, top_k=3) print(hits)
python# Cosine similarity similarity = util.cos_sim(embedding1, embedding2) # Dot product similarity = util.dot_score(embedding1, embedding2) # Pairwise cosine similarity similarities = util.cos_sim(embeddings, embeddings)
python# Efficient batch processing sentences = ["sentence 1", "sentence 2", ...] * 1000 embeddings = model.encode( sentences, batch_size=32, show_progress_bar=True, convert_to_tensor=False # or True for PyTorch tensors )
pythonfrom sentence_transformers import InputExample, losses from torch.utils.data import DataLoader # Training data train_examples = [ InputExample(texts=['sentence 1', 'sentence 2'], label=0.8), InputExample(texts=['sentence 3', 'sentence 4'], label=0.3), ] train_dataloader = DataLoader(train_examples, batch_size=16) # Loss function train_loss = losses.CosineSimilarityLoss(model) # Train model.fit( train_objectives=[(train_dataloader, train_loss)], epochs=10, warmup_steps=100 ) # Save model.save('my-finetuned-model')
pythonfrom langchain_community.embeddings import HuggingFaceEmbeddings embeddings = HuggingFaceEmbeddings( model_name="sentence-transformers/all-mpnet-base-v2" ) # Use with vector stores from langchain_chroma import Chroma vectorstore = Chroma.from_documents( documents=docs, embedding=embeddings )
pythonfrom llama_index.embeddings.huggingface import HuggingFaceEmbedding embed_model = HuggingFaceEmbedding( model_name="sentence-transformers/all-mpnet-base-v2" ) from llama_index.core import Settings Settings.embed_model = embed_model # Use in index index = VectorStoreIndex.from_documents(documents)
| Model | Dimensions | Speed | Quality | Use Case | |-------|------------|-------|---------|----------| | all-MiniLM-L6-v2 | 384 | Fast | Good | General, prototyping | | all-mpnet-base-v2 | 768 | Medium | Better | Production RAG | | all-roberta-large-v1 | 1024 | Slow | Best | High accuracy needed | | paraphrase-multilingual | 768 | Medium | Good | Multilingual |
| Model | Speed (sentences/sec) | Memory | Dimension | |-------|----------------------|---------|-----------| | MiniLM | ~2000 | 120MB | 384 | | MPNet | ~600 | 420MB | 768 | | RoBERTa | ~300 | 1.3GB | 1024 |
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-17 | pass→pass | 3,687 | 2,080 | -44% | 1 | 1 | 0% | 703 | 2,024 | +188% | 0 | 0 | — |
case-01 | pass→pass | 12,590 | 3,757 | -70% | 1 | 1 | 0% | 2,221 | 2,292 | +3% | 0 | 0 | — |
case-02 | pass→pass | 14,118 | 9,508 | -33% | 1 | 1 | 0% | 2,540 | 3,491 | +37% | 0 | 0 | — |
case-03 | pass→pass | 12,366 | 6,529 | -47% | 1 | 1 | 0% | 2,178 | 2,889 | +33% | 0 | 0 | — |
case-04 | pass→pass | 6,634 | 1,127 | -83% | 1 | 1 | 0% | 1,264 | 1,808 | +43% | 0 | 0 | — |
case-05 | pass→pass | 4,269 | 2,645 | -38% | 1 | 1 | 0% | 842 | 2,164 | +157% | 0 | 0 | — |
case-06 | fail→pass | 7,639 | 3,784 | -50% | 1 | 1 | 0% | 1,536 | 2,475 | +61% | 0 | 0 | — |
case-07 | fail→fail | 18,577 | 7,080 | -62% | 1 | 1 | 0% | 3,690 | 3,158 | -14% | 0 | 0 | — |
case-08 | fail→pass | 7,859 | 3,139 | -60% | 1 | 1 | 0% | 1,482 | 2,219 | +50% | 0 | 0 | — |
case-09 | pass→pass | 7,541 | 3,140 | -58% | 1 | 1 | 0% | 1,568 | 2,213 | +41% | 0 | 0 | — |
case-10 | pass→pass | 16,541 | 4,040 | -76% | 1 | 1 | 0% | 2,916 | 2,310 | -21% | 0 | 0 | — |
case-11 | pass→pass | 10,283 | 2,974 | -71% | 1 | 1 | 0% | 1,783 | 2,171 | +22% | 0 | 0 | — |
case-12 | fail→pass | 10,994 | 5,160 | -53% | 1 | 1 | 0% | 2,031 | 2,593 | +28% | 0 | 0 | — |
case-13 | pass→pass | 5,092 | 3,077 | -40% | 1 | 1 | 0% | 908 | 2,169 | +139% | 0 | 0 | — |
case-14 | pass→pass | 5,087 | 2,051 | -60% | 1 | 1 | 0% | 937 | 2,046 | +118% | 0 | 0 | — |
case-15 | pass→pass | 3,014 | 1,944 | -36% | 1 | 1 | 0% | 541 | 2,026 | +274% | 0 | 0 | — |
case-16 | pass→pass | 3,912 | 4,313 | +10% | 1 | 1 | 0% | 753 | 1,934 | +157% | 0 | 0 | — |
case-18 | pass→pass | 2,729 | 2,117 | -22% | 1 | 1 | 0% | 465 | 2,041 | +339% | 0 | 0 | — |
case-19 | pass→pass | 7,261 | 4,414 | -39% | 1 | 1 | 0% | 1,317 | 2,493 | +89% | 0 | 0 | — |
case-20 | pass→pass | 2,975 | 1,872 | -37% | 1 | 1 | 0% | 531 | 1,965 | +270% | 0 | 0 | — |
case-21 | pass→pass | 10,082 | 1,575 | -84% | 1 | 1 | 0% | 1,769 | 1,889 | +7% | 0 | 0 | — |
case-22 | pass→pass | 5,837 | 5,608 | -4% | 1 | 1 | 0% | 1,133 | 2,793 | +147% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of +14 percentage points is the difference between those two pass rates over the 22 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.