How google/ginger works
GINGER is a C++ approximate-nearest-neighbor library for vector retrieval and graph construction. The main workflow accepts a dataset and configuration, builds a graph index (PiPNN or Vamana), optionally projects, reorders, quantizes, and compresses it, then searches the graph and returns nearest neighbors with configurable scoring and reranking. Separate capabilities include standalone approximate kNN graph construction, index persistence, and custom distance metrics. The graph follows documented usage and indexed source references; unsampled details and uncertain call paths are omitted.
Main entry points: searcher_builder.cc Searcher builder · searcher.cc Searcher API · pipnn.cc PiPNN builder · flat_graph.h Graph representations
Components 25
API and datasets
- Vector dataset
ginger/dataset.h - Recommended config
ginger/config_recommender.cc
Index construction
- Searcher builder
ginger/searcher_builder.cc - PiPNN builder
ginger/pipnn/pipnn.cc - Vamana builder
ginger/vamana/index_builder.cc - PCA projection
ginger/projection/pca.h - Graph reordering
ginger/reordering/recursive_graph_partitioning.cc - Graph representations
ginger/graph/flat_graph.h - PiPNN kNN graph
ginger/pipnn/pipnn_knn.cc
Compression and scoring
- Compressed graph
ginger/graph/compressed_graph.h - TurboQuant codec
ginger/turboquant/codec/codec.h - Encoded datapoints
ginger/turboquant/datapoint/encode_datapoint.h - Quantized dataset
ginger/turboquant/layout/dataset_soa.h - Norm storage
ginger/turboquant/layout/norm_storage.h
Search and retrieval
- Query encoding
ginger/turboquant/query/encode_query.cc - TurboQuant query
ginger/turboquant/query/query.h - Searcher API
ginger/searcher.cc - Beam search
ginger/search/beam_search.h - Distance scoring
ginger/search/search_functors.h - JL candidate filter
ginger/candidate_filtering/jl.cc - Neighbor results
ginger/types.h
Persistence and evaluation
- Index persistence
ginger/io/index_io.cc - Recall evaluation
ginger/eval/recall.cc
Other components
- Client
- kNN graph client
Connections 28
- Client → Vector dataset: supplies vectors
README.md - Client → Recommended config: requests defaults
README.md - Client → Searcher builder: configures build
README.md - Searcher builder → PiPNN builder: builds graph
ginger/searcher_builder.cc - Searcher builder → Vamana builder: builds graph
ginger/searcher_builder.cc - Searcher builder → PCA projection: fits projection
ginger/searcher_builder.cc - Searcher builder → Graph reordering: reorders graph
ginger/searcher_builder.cc - Searcher builder → Graph representations: uses graph
ginger/searcher_builder.cc - Searcher builder → TurboQuant codec: configures quantization
- PiPNN builder → Graph representations: produces graph
ginger/pipnn/pipnn.cc - Vamana builder → Graph representations: produces graph
ginger/vamana/index_builder.cc - Searcher builder → Compressed graph: compresses graph
ginger/searcher_builder.cc - TurboQuant codec → Encoded datapoints: encodes vectors
ginger/turboquant/codec/codec.h - Encoded datapoints → Quantized dataset: populates dataset
ginger/turboquant/layout/dataset_soa.h - Quantized dataset → Norm storage: stores norms
ginger/turboquant/layout/dataset_soa.h - Client → Searcher API: submits query
README.md - Searcher API → Beam search: searches graph
ginger/searcher.cc - Searcher API → Query encoding: encodes query
ginger/searcher.cc - Query encoding → TurboQuant query: creates query
- Searcher API → Distance scoring: scores candidates
ginger/searcher.cc - Searcher API → JL candidate filter: filters candidates
ginger/searcher.cc - Searcher API → Compressed graph: traverses graph
- Searcher API → Neighbor results: returns neighbors
README.md - Client → Index persistence: saves or loads
README.md - Searcher API → Index persistence: serializes index
ginger/io/index_io.cc - Client → Recall evaluation: evaluates results
- kNN graph client → PiPNN kNN graph: requests graph
README.md - PiPNN kNN graph → PiPNN builder: uses PiPNN