contriever

facebook/contriever is a dense‑retrieval encoder that produces high‑quality sentence embeddings without any supervised signal. Trained with the contrastive learning framework described in the paper

facebook 6.9M downloads unknown Other Top 50
Frameworkstransformerspytorch
Tagsbert
Downloads
6.9M
License
unknown
Pipeline
Other
Author
facebook

Run contriever locally on a Q4KM hard drive

Boost your retrieval pipelines with a pre‑loaded Q4KM hard drive that ships facebook/contriever model ready for instant deployment. Get this model on a Q4KM hard drive today and enjoy ultra‑fast...

Shop Q4KM Drives

Technical Overview

facebook/contriever is a dense‑retrieval encoder that produces high‑quality sentence embeddings without any supervised signal. Trained with the contrastive learning framework described in the paper “Towards Unsupervised Dense Information Retrieval with Contrastive Learning”, Contriever learns to map a piece of text to a fixed‑dimensional vector such that semantically related texts are close in the embedding space while unrelated texts are far apart. The model is released on the Hugging Face hub and can be used directly with the transformers library; the only extra step required is a mean‑pooling operation over the token embeddings to obtain a single sentence vector.

Key features and capabilities

Architecture highlights

  • Backbone: a BERT‑style transformer encoder (12 layers, hidden size 768, 12 attention heads).
  • Training objective: contrastive loss that pushes a query embedding toward its positive passage and away from a large set of negatives sampled from the same corpus.
  • No additional projection head is required for inference; the raw last_hidden_state is mean‑pooled.

Intended use cases

  • Open‑domain question answering – retrieve relevant passages before a reader model.
  • Semantic document clustering and deduplication.
  • Recommendation systems that rely on textual similarity.
  • Any downstream task that benefits from dense, unsupervised sentence embeddings.

Benchmark Performance

Contriever was evaluated on several standard dense‑retrieval benchmarks, most notably the MS‑MARCO passage ranking and Natural Questions (NQ) datasets. In the original paper, the unsupervised version achieved:

  • ~34 % MRR@10 on MS‑MARCO (comparable to supervised baselines such as DPR).
  • ~70 % Recall@100 on NQ, showing strong coverage of relevant passages.

These metrics matter because they directly reflect a model’s ability to surface the correct document or passage given a query—a core requirement for search‑engine pipelines. Compared to other unsupervised encoders (e.g., SimCSE or Sentence‑BERT), Contriever consistently outperforms them on retrieval‑focused tasks while remaining competitive with supervised dense models, making it a solid choice when labeled data is scarce.

Hardware Requirements

VRAM for inference

  • Model size ≈ 110 M parameters → ~420 MB of GPU memory for the raw model.
  • When processing a batch of 32 sentences, total VRAM usage is typically 2–3 GB on a modern GPU.

Recommended GPU specifications

  • Any GPU with ≥4 GB VRAM (e.g., NVIDIA GTX 1650, RTX 2060) can run single‑sentence inference.
  • For batch processing or real‑time retrieval at scale, a GPU with 8 GB+ (RTX 3060, A100, V100) is advisable.

CPU & storage

  • CPU inference is possible but will be slower; a modern 8‑core CPU (e.g., Intel i7‑12700) is a practical minimum.
  • Model files total ~420 MB; additional space is needed for tokenizers (~30 MB) and any indexed embedding database.

Performance characteristics

  • Throughput: ~200–300 sentences per second on a single RTX 3060 (batch size = 32).
  • Latency: ~5 ms per sentence when using torch‑scripted or ONNX‑exported models.

Use Cases

Primary intended applications

  • Open‑domain question answering pipelines – retrieve passages before a generative reader.
  • Semantic search over large text corpora (e.g., knowledge bases, FAQs, product catalogs).
  • Document clustering and topic modeling where dense similarity is required.

Real‑world examples

  • Customer‑support chatbots that need to fetch relevant help articles from a knowledge base.
  • Legal‑tech platforms that locate precedent cases based on query similarity.
  • Academic literature search engines that rank papers by semantic relevance rather than keyword match.

Industries & domains

  • e‑Commerce – product recommendation and similarity search.
  • Healthcare – retrieving medical guidelines or research abstracts.
  • Finance – clustering news articles or regulatory documents.

Integration possibilities

  • Plug‑and‑play with Hugging Face transformers and sentence‑transformers pipelines.
  • Index embeddings with FAISS, Milvus, or Pinecone for scalable retrieval.
  • Fine‑tune on a small labeled set if a downstream task demands higher precision.

Training Details

Methodology

  • Contrastive learning with in‑batch negatives and hard negatives mined from a large text corpus.
  • Each training step samples a query and its positive passage; all other passages in the batch serve as negatives.
  • The loss function is a temperature‑scaled InfoNCE objective that encourages the query embedding to be close to its positive and far from negatives.

Datasets

  • Training data consists of billions of sentences extracted from the Common Crawl and Wikipedia dumps, filtered for length and language.
  • No human‑annotated relevance judgments are required; the model leverages the natural co‑occurrence of sentences as weak supervision.

Compute requirements

  • Training was performed on a cluster of NVIDIA V100 GPUs (32 GB VRAM) for several days, totaling ≈ 2 k GPU‑hours.
  • Mixed‑precision (FP16) training was used to reduce memory footprint and accelerate convergence.

Fine‑tuning capabilities

  • Because the model follows the standard BERT architecture, it can be fine‑tuned with the Trainer API on any downstream retrieval or classification task.
  • Typical fine‑tuning involves adding a small linear projection head and training on a modestly sized labeled dataset (e.g., 10 k query‑passage pairs).

Licensing Information

The model card lists the license as “unknown”. In practice, this means the repository does not explicitly state a permissive (e.g., MIT, Apache 2.0) or restrictive (e.g., GPL) license. Users should treat the model as “all‑rights‑reserved” until a clear license is published.

Commercial use

  • Without an explicit license, you cannot assume commercial rights. It is safest to contact Facebook Research or the repository maintainer for clarification before deploying the model in a revenue‑generating product.
  • Open‑source projects may still use the model for research or internal prototyping, but redistribution (e.g., bundling the model with a commercial product) is risky.

Restrictions & attribution

  • Even in the absence of a formal license, academic citation of the original paper (arXiv:2112.09118) is strongly encouraged.
  • When sharing the model publicly, include a link to the Hugging Face model card and the GitHub repository (github.com/facebookresearch/contriever).

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