SCANN (Scalable Nearest Neighbors) is an open-source vector search library from Google Research designed for efficient Maximum Inner Product Search (MIPS) and cosine similarity at massive scale. Its core innovation is anisotropic vector quantization (AVQ), a compression technique that accounts for the varying importance of different vector dimensions, combined with a tree-AH (asymmetric hashing) index structure. This architecture enables SCANN to achieve state-of-the-art recall and throughput by performing a fast, coarse search followed by a precise, fine-grained re-ranking of candidates.
Glossary
SCANN (Scalable Nearest Neighbors)

What is SCANN (Scalable Nearest Neighbors)?
A technical overview of Google's high-performance vector search library.
The library is engineered for high-dimensional embeddings common in machine learning, offering configurable trade-offs between accuracy, speed, and memory footprint. Unlike simpler graph-based indexes like HNSW, SCANN's multi-stage process—partitioning data with a coarse quantizer, compressing residuals, and using asymmetric distance computation (ADC)—makes it particularly effective for inner product metrics critical to recommendation systems and dense retrieval. It serves as a benchmark for approximate nearest neighbor (ANN) search performance in production vector databases.
Key Technical Features of SCANN
SCANN (Scalable Nearest Neighbors) is a vector search library from Google Research optimized for high-throughput, high-recall Maximum Inner Product Search (MIPS) and cosine similarity. Its architecture is built around a unique combination of quantization and tree-based partitioning.
Anisotropic Vector Quantization (AVQ)
Anisotropic Vector Quantization (AVQ) is SCANN's core compression technique. Unlike standard Product Quantization (PQ), which assumes uniform variance across dimensions, AVQ learns a rotation of the vector space that aligns the principal components with the quantization axes. This allows it to allocate more bits to dimensions with higher variance, significantly reducing quantization error for the same compression rate. This leads to more accurate distance approximations, which is critical for maintaining high recall in compressed searches.
Tree-AH (Tree Asymmetric Hashing) Index
The Tree-AH index is SCANN's hierarchical search structure. It combines a tree-based index for coarse partitioning with an asymmetric distance computation (ADC) stage for fine-grained scoring.
- Tree Partitioning: The dataset is recursively partitioned using a balanced tree, enabling logarithmic-time traversal to narrow the search to a leaf node.
- Asymmetric Hashing: Within each leaf partition, database vectors are compressed using AVQ, while the query remains in full precision. Distances are computed asymmetrically between the full-precision query and the quantized database vectors, maximizing accuracy. This two-stage design provides an excellent balance between search speed and recall.
Maximum Inner Product Search (MIPS) Optimization
SCANN is specifically engineered for the Maximum Inner Product Search (MIPS) problem, which is fundamental to recommendation systems and retrieval where similarity is defined by dot product. It handles this by:
- Transforming MIPS into a cosine similarity search on unit vectors, which is equivalent under certain constraints.
- Utilizing its AVQ and Tree-AH design to efficiently approximate and rank inner products.
- Providing configurable reordering stages that use exact distances on a shortlist of candidates to guarantee final result accuracy. This makes it superior to algorithms primarily optimized for Euclidean distance (L2) when inner product is the target metric.
Reordering and Score-Aware Search
To bridge the gap between approximate and exact results, SCANN employs a sophisticated reordering strategy. After the Tree-AH index retrieves an initial candidate set, a brute-force re-ranking step is performed:
- A subset of the top candidates (e.g., top 1000) is extracted.
- Exact distances (inner product or cosine) are computed between the full-precision query and the full-precision versions of these candidate vectors.
- The final results are sorted based on these exact scores. This score-aware process ensures the final output's Recall@k is extremely high, often matching near-exact search quality, while the bulk of the work is done efficiently via the approximate index.
Batched Query Throughput
A defining feature of SCANN is its exceptional performance on batched queries. Its algorithms are designed for modern hardware, leveraging:
- SIMD (Single Instruction, Multiple Data) instructions for parallel distance computations.
- Efficient memory access patterns during tree traversal and AVQ table lookups.
- Multithreading to process multiple queries or index partitions concurrently. This architecture allows it to achieve orders-of-magnitude higher queries per second (QPS) compared to algorithms optimized for single-query latency, making it ideal for serving environments where high throughput is critical.
Configurable Recall-Latency Trade-offs
SCANN provides multiple levers to tune the trade-off between search latency and recall accuracy, allowing engineers to match performance to application requirements. Key hyperparameters include:
- Leaves to Search: The number of leaf partitions (from the tree) to probe during query time. Increasing this number improves recall but increases latency.
- Reordering Budget: The number of candidates to re-score with exact distances. A larger budget improves final accuracy.
- AVQ Configuration: The number of bits and subspaces used for quantization, affecting both memory footprint and approximation quality. By adjusting these, SCANN can be configured for ultra-low-latency serving or for high-accuracy offline batch retrieval.
How SCANN Works: The Core Mechanism
SCANN (Scalable Nearest Neighbors) is a vector search library from Google Research designed for high-throughput maximum inner product search (MIPS) and cosine similarity. Its core mechanism is a two-stage indexing strategy that combines anisotropic vector quantization with a specialized graph structure.
The first stage is anisotropic vector quantization (AVQ), a learned compression technique. Unlike standard product quantization, AVQ optimizes codebooks specifically for the MIPS objective, minimizing the error in inner product approximation. This creates a highly accurate coarse quantizer that partitions the dataset. The system then builds a tree-AH (asymmetric hashing) index, a graph where nodes are the compressed vectors. This graph is constructed to have the small-world property, enabling fast, logarithmic-time traversal.
During a query, SCANN performs a multi-sequence search. It uses the AVQ coarse quantizer to identify promising partitions. Within those partitions, it traverses the tree-AH graph using a greedy beam search with a configurable search beam width. Finally, it employs asymmetric distance computation (ADC) to re-rank candidates, comparing the full-precision query against the quantized database vectors for high recall@k. This hybrid approach balances memory efficiency from quantization with the speed of graph-based search.
Primary Use Cases for SCANN
SCANN (Scalable Nearest Neighbors) is a vector search library from Google Research optimized for high-throughput, high-recall similarity search. Its unique architecture makes it particularly effective for specific, demanding production scenarios.
Large-Scale Recommendation Systems
SCANN is engineered for Maximum Inner Product Search (MIPS), the core mathematical operation behind user-item matching in recommendation engines. Its anisotropic vector quantization is optimized for the angular geometry of inner product spaces, unlike algorithms designed purely for Euclidean distance.
- High Throughput: Achieves millions of queries per second on a single machine, critical for serving recommendations to massive user bases.
- High Recall: Maintains >99% recall for top-k retrieval, ensuring users see the most relevant items.
- Example: Retrieving candidate products from a catalog of 100M+ embeddings for real-time personalization.
Semantic Search & Retrieval-Augmented Generation (RAG)
For RAG pipelines and semantic search engines, SCANN provides fast, accurate retrieval of text chunks based on cosine similarity of their embeddings. Its tree-AH (Asymmetric Hashing) index allows for efficient filtering of billions of passages.
- Low Latency: Delivers sub-10ms p95 latency for retrieving context from a billion-scale vector index, keeping overall LLM response time low.
- Accuracy: High recall ensures the retrieved context is relevant, directly reducing the chance of LLM hallucinations.
- Use Case: Grounding enterprise chatbots by searching internal knowledge bases of documentation, tickets, and transcripts.
Dense Retrieval for Search Engines
Modern search has moved beyond keywords to dense retrieval, where queries and documents are encoded into vectors. SCANN's scalability handles web-scale corpora where traditional inverted indexes struggle with semantic matching.
- Hybrid Readiness: Works efficiently alongside traditional keyword (sparse) indexes for hybrid scoring.
- Memory Efficiency: Product Quantization compression reduces the memory footprint by 4x-8x, enabling larger datasets to reside in RAM.
- Example: Powering the "similar documents" or "semantically related news" features for large content platforms.
Multi-Modal Retrieval Systems
Systems that need to search across modalities—like finding images with a text query, or audio matching a video clip—rely on cross-modal embeddings in a shared vector space. SCANN's high-dimensional efficiency is key.
- Unified Index: Can index embeddings from different encoders (CLIP for image-text, AudioCLIP for audio) into a single, searchable space.
- High-Dimensional Performance: Maintains performance in spaces of 512 to 2048 dimensions, common for modern multi-modal models.
- Application: Building media libraries where users can search using natural language descriptions of visual or auditory content.
Deduplication & Near-Duplicate Detection
Identifying near-identical items in massive datasets, such as duplicate product listings, plagiarized content, or redundant user profiles, requires finding vectors with near-perfect similarity. SCANN's precision at the top of the result list is ideal.
- High Precision @1: Optimized to find the single closest match with extreme accuracy.
- Batch Processing: Efficiently processes large batch queries for offline deduplication pipelines.
- Real-World Scale: Used to deduplicate web-scale image datasets or user-generated content platforms with billions of items.
Scientific & Biometric Data Search
In domains like molecular similarity search for drug discovery or facial recognition, datasets are enormous and vectors are high-dimensional. SCANN's algorithmic optimizations provide a practical balance of speed and accuracy where exact search is computationally impossible.
- Structured Data: Excels with vectors that have inherent geometric structure, such as chemical compound fingerprints or biometric templates.
- Reproducible Research: As a library from Google Research, it is built for rigorous, reproducible benchmarking common in scientific computing.
- Example: Searching a database of 1B+ molecular embeddings to find potential drug candidates similar to a known effective compound.
SCANN vs. Other Vector Search Libraries
A technical comparison of SCANN's design and performance characteristics against other prominent open-source vector search libraries, focusing on core algorithms, quantization strategies, and operational trade-offs.
| Feature / Metric | SCANN | FAISS | HNSWlib |
|---|---|---|---|
Primary Indexing Method | Tree-AH (Asymmetric Hashing) with anisotropic vector quantization | IVF (Inverted File) with Flat, PQ, or HNSW composable indexes | Pure HNSW (Hierarchical Navigable Small World) graph |
Optimized Distance Metric | Maximum Inner Product Search (MIPS) & Cosine Similarity | L2 (Euclidean) Distance & Inner Product | L2 Distance & Inner Product |
Core Quantization Technique | Anisotropic Vector Quantization (AVQ) | Product Quantization (PQ) & Scalar Quantization | |
Native Support for Filtered Search | |||
Dynamic Indexing (Real-time Updates) | |||
GPU Acceleration Support | |||
Typical Recall@10 (on benchmark datasets like DEEP1B) |
| 90-98% (varies by IVF/PQ parameters) |
|
Index Build Time (Relative) | High | Medium | Very High |
Query Latency at High Throughput | < 1 ms per query (batch) | 1-5 ms per query | 0.5-2 ms per query |
Memory Footprint (Compression) | Very Low (highly compressed via AVQ) | Low to Medium (via PQ) | High (stores full-precision vectors in graph) |
Primary Use Case | Ultra-high-throughput MIPS for recommendation systems | Flexible R&D and production deployment with multiple index types | High-recall, low-latency search for static datasets |
Frequently Asked Questions
SCANN (Scalable Nearest Neighbors) is a vector search library from Google Research optimized for high-throughput, high-recall maximum inner product search (MIPS) and cosine similarity. This FAQ addresses its core mechanisms, performance characteristics, and practical applications.
SCANN (Scalable Nearest Neighbors) is an open-source vector search library developed by Google Research, designed to efficiently solve the Maximum Inner Product Search (MIPS) and cosine similarity problems at massive scale. It operates through a multi-stage, anisotropic quantization and partitioning pipeline. Its core workflow involves:
- Tree-AH Indexing: The dataset is partitioned using a tree-based asymmetric hashing (Tree-AH) structure. This creates a hierarchical set of partitions, allowing the search to quickly narrow down to the most promising subset of vectors.
- Anisotropic Vector Quantization (AVQ): Unlike standard quantization that minimizes mean squared error, AVQ is optimized specifically for the inner product. It learns a codebook that maximizes the preserved inner product between the original and quantized vectors, which is crucial for high-recall MIPS.
- Residual Quantization: After coarse partitioning, residual vectors (the difference between a vector and its partition centroid) are further compressed using product quantization for efficient storage and fast asymmetric distance computation (ADC).
- Re-ranking: A small set of candidates from the quantized search is re-scored using exact, full-precision distances to produce the final, accurate ranking.
This architecture allows SCANN to achieve a superior trade-off between recall, throughput (queries per second), and memory footprint compared to other approximate nearest neighbor (ANN) libraries.
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
SCANN operates within a broader ecosystem of algorithms and techniques designed for efficient high-dimensional similarity search. Understanding these related concepts is crucial for selecting and tuning the right indexing strategy.

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us