Skip to content

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

Apple Machine Learning Research 12 min read Research hardMaster

Faster Retrieval for Better, More Efficient RAG

Maximum inner product search can be amortized by training small neural networks offline on a known query distribution, exploiting the fact that the max-inner-product function is the convex support function of the key set, whose gradient is the best-matching key. SupportNet, a loosely constrained input convex neural network, learns per-cluster support functions to replace centroid routing in IVF indexes. On Natural Questions (~2.6M passages, 128 clusters) it reaches 95% routing recall about 1.9× faster than centroids. KeyNet maps a query to its predicted best key as a query rewriter in front of a FAISS IVF index, reaching 99% recall up to ~8× faster and scanning ~11× fewer keys. Use KeyNet when speed is the bottleneck, and SupportNet when calibrated scores are needed or models must be small.

Assumes: vector embeddingsinverted file (IVF) indexesneural network regressionconvex functions

Related posts

  • pgvector v0.5.0: Faster semantic search with HNSW indexes

    Supabase mediumAdept

    pgvector v0.5.0 adds HNSW indexes, which combine skip-list-style layering with navigable small world proximity graphs to do approximate nearest-neighbor search over embeddings. In Supabase benchmarks on 1536-dimension OpenAI vectors, HNSW delivered about 3x the QPS of IVFFlat on 224K vectors and over 6x on 1M vectors at equal accuracy. Tuning ef_search, m and ef_construction trades speed against recall; raising ef_construction to 80 reached 0.99 accuracy@10 with ef_search 100 and 35% more QPS. HNSW can be built on an empty table and stays optimal as data arrives, but it builds more slowly and uses more memory than IVFFlat, whose build times dropped over 50% thanks to parallel list assignment and float-based FMA distance math.

  • Understanding vector search and HNSW index with pgvector

    Neon mediumAdept

    pgvector 0.5.0 adds an HNSW (Hierarchical Navigable Small Worlds) index for approximate nearest neighbor search in Postgres, replacing O(N) sequential exact scans with a multi-layer graph traversal that trades a little accuracy for much faster queries. A walkthrough covers vector embeddings, L2 and cosine distance with worked examples, and pgvector SQL for storing and querying vectors with the <=> operator. Index tuning hinges on m (graph degree), ef_construction (build-time candidate list) and ef_search (query-time beam size): higher values improve recall at the cost of build time, memory or query latency. HNSW is faster and higher-recall than IVF but resource-intensive to build, often requiring more RAM and a larger maintenance_work_mem.

  • Neon Docs search is now built on Neon

    Neon mediumAdept

    Neon's docs search now runs entirely on its own stack: Lakebase Postgres with the lakebase_vector (pgvector-compatible ANN) and lakebase_text (BM25) extensions, a Hono API on Neon Functions, and Neon AI Gateway for embeddings and reranking. Pages are ingested as markdown via a GitHub Action, chunked by heading, embedded and stored with tsvectors in one table. To fit search-as-you-type latency budgets, full hybrid results (ANN plus BM25 merged with reciprocal rank fusion, then an LLM rerank) are precomputed for common queries and cached, while unseen queries fall back to BM25 only. Cache hits take 1.9 ms and BM25 misses 8.6 ms at p50 on the server, and top-5 hit rate rose from 80% to 94% on 171 real queries.

  • Training 100x Cheaper Retrieval models Neon and Castform

    Neon easyNovice

    Castform uses data stored in Neon Postgres, exposed through Lakebase Search's BM25 and vector functions, to RL post-train a 4B open-source model for agentic retrieval. The post claims the model matches GPT-5.6 Sol's accuracy at about 100x lower cost; a frontier multi-turn search request takes over 10s and costs around $0.03. The pipeline generates synthetic question/answer tasks from the existing corpus. Training uses a hybrid search tool with RRF merging and a reward function that scores retrieval, citation and answer correctness. Neon's autoscaling absorbs the bursty search load from parallel rollouts, and branching is positioned as a way to give stateful agents isolated environments.

  • Multi-Vector (Late Interaction) Embedding Models with Sentence Transformers

    Hugging Face mediumAdept

    Sentence Transformers v6.0 adds MultiVectorEncoder, a fourth model type for ColBERT-style late-interaction retrieval that loads PyLate, Stanford-NLP ColBERT and (with added config) colpali-engine checkpoints. Multi-vector models keep one projected, normalized vector per token and score with MaxSim, summing each query token's best match against document tokens. This preserves exact-match and multi-requirement signals that single-vector models average away, and helps on long documents (mLateOn 77.92 vs mDenseOn 51.59 on MLDR). The cost is index size: 4,874 NQ passages produced 608,414 vectors (311.5 MB float32 vs 7.5 MB for MiniLM), cut to 92 MB with a fast-plaid index and reducible further via token pooling or retrieve-and-rerank. The guide covers loading, separate query and document encoding, scoring, indexing, and visual document retrieval.

The quest for software engineering knowledge.

Look:
Layout: