Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Hugging Face 16 min read Deep dive mediumAdept

Binary and Scalar Embedding Quantization for Significantly Faster & Cheaper Retrieval

Quantizing embeddings themselves, rather than model weights, sharply cuts retrieval memory, disk and cost. Binary quantization thresholds normalized float32 values at 0 to give 32x smaller vectors searched by Hamming distance, while scalar int8 quantization uses per-dimension min/max ranges from a calibration set to give 4x savings. On MTEB retrieval, mxbai-embed-large-v1 keeps about 96% of NDCG@10 with binary embeddings plus float32-query rescoring, and 97% with int8. A combined pipeline does a binary in-memory search, then rescores the top candidates with int8 embeddings loaded from disk, serving 41M Wikipedia texts with 5.2GB of memory instead of about 200GB. Sentence Transformers code and vector database support tables are included.

Related posts

  • Matryoshka embeddings: faster OpenAI vector search using Adaptive Retrieval

    Supabase mediumAdept

    OpenAI's text-embedding-3 models are trained with Matryoshka Representation Learning, so an embedding can be shortened by truncating trailing dimensions and renormalizing, which reproduces the API's `dimensions` output. Adaptive Retrieval exploits this with a two-pass search: a fast HNSW-indexed ANN pass on a low-dimensional prefix fetches an oversized shortlist, then exact KNN on the full 3072d vectors re-ranks it. Benchmarks on 1M dbpedia embeddings found a 512d first pass (ef_construction=400, m=32, ef_search=200, limit = top_k × 8) reached 99% accuracy against 3072d KNN at about 580 QPS. By comparison, a single pass on 1536d vectors topped out near 89%. The post finishes with a Postgres/pgvector implementation using a sub_vector SQL function.

  • We built a vector search engine that lets you choose precision at query time

    ClickHouse hardMaster

    QBit is a new ClickHouse column type that stores BFloat16, Float32 or Float64 vectors as transposed bit planes, each held in a FixedString subcolumn. Vector search can then read only the top N bit planes and choose precision at query time, trading recall for I/O and compute without duplicating data or committing to irreversible quantisation. Distance functions like L2DistanceTransposed reconstruct truncated floats with AVX-512 SIMD untransposition, and downcast only the reference vector when the bit layout matches, as with Float32 to BFloat16. Search remains O(n), so HNSW is still faster when its index fits in RAM.

  • SQLite Retrieval Augmented Generation and Vector Search

    Turso mediumAdept

    Retrieval-augmented generation fixes stale or hallucinated LLM answers by retrieving relevant data, typically via embeddings and vector similarity search, and injecting it into the prompt. libSQL adds native vector search to SQLite: embeddings are stored in an F32_BLOB column (SQLite treats column types as hints), inserted with a vector() function, and queried with vector_distance_cos() plus ORDER BY/LIMIT for exact top-k results. That exact search is a full table scan and only scales to small datasets, so larger collections need approximate nearest-neighbour indexing, which a follow-up post will cover.

  • What's new in pgvector v0.7.0

    Supabase mediumAdept

    pgvector 0.7.0 adds float16 (halfvec), sparse and bit vector types to exploit redundancy in embeddings and cut memory and storage. Halfvec halves both table and HNSW index size (3.5GB vs 7GB for 900K 1536-dim OpenAI vectors) and builds parallel HNSW indexes about 30% faster, with Jonathan Katz's benchmarks showing up to 3x faster builds at essentially unchanged recall and QPS. Binary quantization with Hamming-distance HNSW indexes enables a fast pre-select followed by exact re-ranking on a small subset, with limit sizes tuned per dataset. The release also adds L1, Hamming and Jaccard distance operators and index opclasses.

  • How Hugging Face Inference Endpoints, Jobs, and Buckets Power Search on Papers with Code

    Hugging Face mediumAdept

    Papers with Code search combines PostgreSQL full-text search with pgvector semantic search over Qwen3-Embedding-0.6B vectors, fused by weighted reciprocal rank fusion (k=60), with exact-title, arXiv-ID and navigational matches pinned on top. Hugging Face Jobs build the full corpus on an L4 GPU from checksummed snapshots stored in immutable run prefixes in Storage Buckets. A scale-to-zero TEI Inference Endpoint embeds live queries and hourly incremental updates. A strict versioned embedding contract (pinned revision, 256-dim Matryoshka vectors, query/document prompts, content hashes) keeps generations reproducible, and pilot tests showed 0.9955 Recall@20 at ~1.3 ms p50 with 27% of the 1024-dim storage. A one-second timeout and circuit breaker fall back to lexical search when the endpoint is cold or unhealthy.

The quest for software engineering knowledge.

Look:
Layout: