Unlocking Efficient Ad Retrieval: Offline Approximate Nearest Neighbors in Pinterest Ads
Pinterest uses online approximate nearest neighbors (ANN) for ad retrieval, but offline ANN is also valuable for large-scale data processing, and cost-effective operations. Offline ANN precomputes candidates offline, ideal for scenarios with high throughput and low-latency query responses and relatively static query context. Pinterest has successfully applied online ANN, but faces challenges with expanding ads inventory. Migrating from Hierarchical Navigable Small World (HNSW) to Inverted File (IVF) algorithm enables a larger tier index, but increases costs. Offline ANN benefits from ample computational resources and latency tolerance, effective for candidate generators with static query contexts. The primary difference between online and offline approaches is the timing of the ANN search. Offline ANN has pros, including cost efficiency and extensibility, but cons, including real-time limitations and fixed neighbors. Pinterest has evaluated offline ANN-based retrieval in several use-cases, including similar item ads and visual embedding. Offline ANN has shown better engagement and conversion performance, and Pinterest is actively developing its own offline ANN framework and platform for future advancements.