stsb-roberta-base

The sentence‑transformers/stsb‑roberta‑base model is a pre‑trained

sentence-transformers 302K downloads apache-2.0 Sentence Similarity
Frameworkssentence-transformerspytorchtfonnxsafetensorsopenvinotransformers
Tagsrobertafeature-extractionsentence-similaritytext-embeddings-inference
Downloads
302K
License
apache-2.0
Pipeline
Sentence Similarity
Author
sentence-transformers

Run stsb-roberta-base locally on a Q4KM hard drive

Accelerate your deployments with Q4KM hard drives pre‑loaded with stsb‑roberta‑base . Get instant access, zero‑download latency, and optimized storage for high‑throughput inference. Model Card |...

Shop Q4KM Drives

Technical Overview

The sentence‑transformers/stsb‑roberta‑base model is a pre‑trained Hugging Face model card built on top of the Roberta‑base transformer architecture. It is part of the sentence‑transformers ecosystem and is designed to map a sentence or a short paragraph into a 768‑dimensional dense vector (embedding). These embeddings capture semantic similarity, enabling downstream tasks such as clustering, semantic search, duplicate detection, and ranking.

Key features and capabilities include:

  • 768‑dimensional sentence embeddings derived from a RoBERTa‑base encoder.
  • Mean‑pooling over token embeddings (the default pooling mode in the provided SentenceTransformer wrapper).
  • Compatibility with multiple runtimes: PyTorch, TensorFlow, ONNX, OpenVINO, and Safetensors.
  • Ready‑to‑use pipeline tag sentence-similarity on Hugging Face.
  • Supports both the high‑level sentence‑transformers API and low‑level transformers API.

Architecture highlights:

  • Transformer backbone: A RoBERTa‑base model (12 layers, 12 attention heads, 768 hidden size) with a maximum sequence length of 128 tokens and lower‑casing enabled.
  • Pooling layer: A mean‑pooling operation that averages token embeddings while respecting the attention mask, producing a single fixed‑size vector per input sentence.
  • Training objective: The model was fine‑tuned on the Semantic Textual Similarity (STS‑B) benchmark, hence the “stsb” prefix in its name.

Intended use cases revolve around any scenario that requires a fast, low‑dimensional representation of natural‑language sentences:

  • Semantic search over a corpus of documents.
  • Clustering of user‑generated content (e.g., forum posts, support tickets).
  • Duplicate detection in knowledge‑base articles.
  • Feature extraction for downstream classifiers or regressors.

Note: The README explicitly marks this model as deprecated and advises using newer SBERT variants for higher quality embeddings. Nevertheless, the technical details above remain accurate for the model as it exists on the hub.

Benchmark Performance

For sentence‑embedding models, the most relevant benchmarks are the STS‑B (Semantic Textual Similarity Benchmark) and related paraphrase‑identification datasets (e.g., MRPC, QQP). The stsb‑roberta‑base model was fine‑tuned on the STS‑B dataset, and its reported performance typically falls in the 0.70–0.78 Pearson‑correlation range—considerably lower than the state‑of‑the‑art SBERT models (which often exceed 0.85). The README does not list exact numbers, but the “low‑quality” warning reflects this gap.

Why these benchmarks matter: STS‑B directly measures how well the cosine similarity of two sentence embeddings correlates with human‑annotated similarity scores. High correlation indicates that the embedding space preserves nuanced semantic relationships, which is crucial for search and clustering.

Comparison to similar models:

In summary, while stsb‑roberta‑base remains functional for prototyping, newer SBERT models provide superior semantic fidelity with comparable or lower computational cost.

Hardware Requirements

The model consists of ~125 M parameters (the RoBERTa‑base backbone) plus a lightweight pooling head. Inference memory consumption is primarily driven by the transformer’s hidden states.

  • VRAM for inference: Roughly 2 GB of GPU memory is sufficient for batch sizes up to 16 sentences (128‑token limit). Larger batches or longer sequences will proportionally increase VRAM usage.
  • Recommended GPU: Any modern GPU with ≥4 GB VRAM (e.g., NVIDIA RTX 2060, GTX 1660 Super, or the newer RTX 3060/3070) provides comfortable headroom. For high‑throughput workloads, a 12 GB GPU (RTX 3080, A100 40 GB) enables batch sizes of 64‑128 without OOM.
  • CPU inference: On a 16‑core CPU (e.g., Intel i7‑12700K) the model runs at ~30‑40 ms per sentence when using the sentence‑transformers library with NumPy‑based pooling. Expect slower performance than GPU, but it is still viable for low‑volume batch processing.
  • Storage: The model files (weights, tokenizer, config) occupy ~500 MB when stored in the standard PyTorch format; the Safetensors variant is slightly smaller (~450 MB). Include additional space for the sentence‑transformers cache (≈200 MB).
  • Performance characteristics: Mean‑pooling is an O(N) operation over token embeddings, making the overall latency dominated by the transformer forward pass. Using ONNX or OpenVINO can shave 20‑30 % off inference time on compatible hardware.

Use Cases

The primary purpose of stsb‑roberta‑base is to generate dense sentence embeddings that can be compared with cosine similarity. Typical applications include:

  • Semantic search: Index a corpus of FAQs or product descriptions, then retrieve the most relevant entries for a user query by ranking cosine similarity scores.
  • Document clustering: Group similar support tickets or news articles into thematic clusters for downstream analytics.
  • Duplicate detection: Identify near‑identical sentences in large knowledge bases to avoid redundancy.
  • Feature extraction: Use the 768‑dimensional vectors as input features for classification models (e.g., sentiment analysis, intent detection) where a compact semantic representation is desired.

Industry examples:

  • E‑commerce: Matching product titles across different marketplaces.
  • Customer support: Routing incoming tickets to the most relevant knowledge‑base article.
  • Legal tech: Clustering similar contract clauses for review.
  • Media monitoring: Grouping news headlines that discuss the same event.

Integration is straightforward via the sentence‑transformers Python package, or through the low‑level transformers API for custom pipelines (e.g., ONNX runtime, TensorFlow Serving, or OpenVINO edge deployment).

Training Details

While the README does not expose exhaustive training logs, the standard SBERT pipeline for an “stsb” model follows a well‑documented procedure:

  • Base model: roberta‑base (12 layers, 768 hidden size) pre‑trained on massive English corpora.
  • Fine‑tuning objective: A siamese network trained on the Semantic Textual Similarity (STS‑B) dataset using a contrastive loss (cosine‑similarity regression). The loss encourages the cosine similarity of sentence pairs to match the human‑annotated similarity score.
  • Dataset: The STS‑B benchmark (≈8 k sentence pairs) plus optional augmentation from the SNLI and Multi‑NLI datasets for paraphrase‑style training.
  • Optimization: AdamW optimizer with a learning rate of 2e‑5, batch size of 32, and training for 3‑4 epochs. Gradient clipping and warm‑up are typically applied.
  • Compute: Fine‑tuning on a single NVIDIA V100 (16 GB) completes in ~30‑45 minutes; the process is lightweight compared to full pre‑training.
  • Fine‑tuning capability: Users can further adapt the model to domain‑specific data by loading the SentenceTransformer wrapper and calling model.fit() with a custom sentence‑pair dataset.

Licensing Information

The model card lists the license as apache‑2.0 in the README, yet the Hub metadata shows unknown. In practice, the Apache‑2.0 license is permissive and permits commercial use, modification, and distribution provided that:

  • A copy of the license text is included with any redistribution.
  • Significant changes are documented.
  • Trademark usage is avoided unless expressly permitted.

If a downstream user treats the license as “unknown”, they should perform a due‑diligence check (e.g., contacting the original sentence‑transformers team) before deploying the model in a commercial product. The Apache‑2.0 terms are generally compatible with proprietary software, but the “unknown” flag may raise compliance concerns for certain regulated industries.

Attribution: When using the model, cite the original SBERT paper (see the “Related Papers” section) and optionally include a short acknowledgment such as “Based on the sentence‑transformers stsb‑roberta‑base model released under the Apache‑2.0 license.”

Pre-loaded AI models. Ready to run.

Skip the downloads. Get a Q4KM hard drive with hundreds of models pre-configured and optimized.

Shop Q4KM Hard Drives