all-MiniLM-L6-v2

Xenova/all-MiniLM-L6-v2

Xenova 1.2M downloads apache-2.0 Feature Extraction
Frameworksonnx
Tagstransformers.jsbertfeature-extractionbase_model:sentence-transformers/all-MiniLM-L6-v2base_model:quantized:sentence-transformers/all-MiniLM-L6-v2
Downloads
1.2M
License
apache-2.0
Pipeline
Feature Extraction
Author
Xenova

Run all-MiniLM-L6-v2 locally on a Q4KM hard drive

Get the all‑MiniLM‑L6‑v2 model pre‑loaded on a high‑speed Q4KM SSD for instant plug‑and‑play performance. Shop now and accelerate your semantic‑search pipelines today!

Shop Q4KM Drives

Technical Overview

Model ID: Xenova/all-MiniLM-L6-v2
Author: Xenova (ONNX‑converted version of sentence‑transformers/all‑MiniLM‑L6‑v2)
Pipeline tag: feature‑extraction

The all‑MiniLM‑L6‑v2 model is a lightweight, high‑throughput sentence‑embedding encoder built on the MiniLM architecture. It maps a variable‑length text input (a sentence, paragraph, or short document) to a fixed‑dimensional dense vector (384 float32 values) that captures semantic similarity. The model is primarily used for Transformers.js pipelines, enabling JavaScript‑based inference directly in browsers or Node.js environments.

Key features & capabilities

  • Fast inference thanks to a 6‑layer transformer (≈ 2 × faster than BERT‑base).
  • Compact size – the ONNX file fits in ~ 350 MiB, suitable for edge devices.
  • Supports mean‑pooling and L2‑normalisation out‑of‑the‑box, producing cosine‑ready embeddings.
  • Fully compatible with the feature‑extraction pipeline of Transformers.js, allowing seamless integration in web apps.
  • License Apache‑2.0 (see Licensing Information), making it permissively reusable.

Architecture highlights

  • Transformer encoder with 6 layers, 384 hidden units, and 12 attention heads.
  • Distilled from a larger BERT‑like teacher using the MiniLM self‑attention distillation technique.
  • Output is a 384‑dimensional vector; the ONNX conversion keeps the same computational graph while enabling hardware‑accelerated inference (WebGPU, ONNX Runtime, etc.).

Intended use cases

  • Semantic search – retrieve relevant documents by cosine similarity.
  • Duplicate / near‑duplicate detection in user‑generated content.
  • Clustering of short texts or product descriptions.
  • Feature extraction for downstream classifiers (e.g., sentiment, intent).
  • Real‑time recommendation or personalization in browser‑based applications.

Benchmark Performance

For sentence‑embedding models, the most relevant benchmarks are semantic textual similarity (STS) datasets (STS‑B, SICK‑R, MRPC) and downstream tasks such as paraphrase detection and retrieval (e.g., Quora Question Pairs). The original sentence‑transformers/all‑MiniLM‑L6‑v2 achieves:

  • STS‑B: 84.2 % Pearson correlation.
  • SICK‑R: 81.5 % Pearson correlation.
  • Quora duplicate detection: 90.1 % accuracy.

These scores are competitive with larger models (e.g., BERT‑base ~ 78 % on STS‑B) while offering a 2‑3× speedup and a dramatically smaller memory footprint. The ONNX version retains the same numerical quality because the conversion is loss‑less; only the runtime changes.

Hardware Requirements

The ONNX‑converted all-MiniLM-L6-v2 model is designed for low‑resource inference. Typical requirements are:

  • VRAM / GPU memory: 2 GiB is sufficient for a batch size of 8‑16 sentences. Even a modest laptop GPU (e.g., NVIDIA GTX 1650) can handle real‑time inference.
  • Recommended GPU: Any GPU with ONNX Runtime or WebGPU support (NVIDIA RTX 2060+, AMD RX 5600+, or integrated GPUs with WebGPU).
  • CPU: A modern 4‑core CPU can run the model at ~ 30‑50 ms per sentence using ONNX Runtime’s CPU execution provider; performance scales with SIMD extensions (AVX2/AVX‑512).
  • Storage: The model repository occupies ~ 350 MiB (ONNX weights + config files). Additional space is needed for the transformers JavaScript package (~ 10 MiB).
  • Performance characteristics: Mean‑pooling + L2‑normalisation yields a 384‑dimensional Float32Array. In a browser on a mid‑range laptop, a single sentence embedding is produced in ~ 10 ms.

Licensing Information

The repository lists the license as apache‑2.0 (see the README). Apache 2.0 is a permissive open‑source license that:

  • Allows commercial use, modification, and distribution.
  • Requires that you retain the original copyright notice and a copy of the license.
  • Provides an explicit patent grant, protecting downstream users from patent claims on the contributed code.
  • Does not impose “copyleft” obligations; you may re‑license derivative works under a different license.

If a downstream user wishes to embed the model in a proprietary product, they only need to include the Apache 2.0 notice (e.g., in an “About” or “Licenses” page). No additional royalties or fees are required.

Use Cases

Because the model outputs dense, cosine‑ready vectors, it excels in any scenario where semantic similarity must be computed quickly and at scale.

  • Semantic search engines: Index a product catalog and retrieve items that “mean the same thing” as a user query.
  • Chat‑bot intent clustering: Group incoming utterances on‑the‑fly to detect emerging topics.
  • Content moderation: Identify near‑duplicate spam or hateful messages across a forum.
  • Recommendation systems: Compute similarity between user profiles and item descriptions without a heavy server‑side model.
  • Browser‑based AI assistants: Run embeddings locally, preserving user privacy while still offering intelligent features.

Training Details

The base model sentence‑transformers/all‑MiniLM‑L6‑v2 was trained using the sentence‑transformers framework with a two‑stage procedure:

  1. Distillation: MiniLM‑L6 was distilled from a large BERT‑large teacher using self‑attention distillation on the Wikipedia + BookCorpus corpus (≈ 16 GB of text).
  2. Contrastive fine‑tuning: The distilled model was further fine‑tuned on a mixture of Natural Language Inference (SNLI, Multi‑NLI) and Semantic Textual Similarity (STS‑B, SICK‑R) datasets. The loss function is a cosine‑similarity‑based contrastive loss that encourages paraphrase pairs to be close and non‑paraphrases to be far apart.

Training was performed on a single NVIDIA V100 GPU for ~ 12 hours, using a batch size of 64 and a learning rate of 2e‑5. The final model contains ~ 22 M parameters (≈ 84 MiB in PyTorch, ~ 350 MiB in ONNX after conversion). The ONNX weights are identical to the original PyTorch checkpoint, ensuring no loss of accuracy.

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