Skip to main content

Sentence-Transformers Cheatsheet

Sentence-Transformers is a Python library for encoding text into dense vectors using pretrained Transformer models. Widely used for semantic search, clustering, text similarity, and RAG embeddings. Supports both Bi-Encoder and Cross-Encoder architectures.

Updated: 2026-07-20·7 commands

Quick Start

``bash pip install sentence-transformers

python -c " from sentence_transformers import SentenceTransformer model = SentenceTransformer('all-MiniLM-L6-v2') emb = model.encode('Hello world') print(emb.shape) # (384,) " ``

Startup & Modes(1)

CommandLevel
pip install sentence-transformers
Install Sentence-Transformers
Basic

ai-embedding(6)

CommandLevel
st encode
Encode text into embedding vectors
Basic
st encode batch
Batch encode multiple texts
Basic
st similarity
Compute semantic similarity between two texts
Basic
st paraphrase mining
Find semantically similar sentence pairs
Expert
st semantic search
Search most relevant texts in a corpus
Intermediate
st cross-encoder
Use Cross-Encoder for re-ranking
Expert

FAQ

This cheatsheet is compiled from official tool documentation. Last updated: 2026-07-20.