Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Locality Sensitive Hashing at Lyst
Search
Maciej Kula
July 24, 2015
Programming
1.4k
0
Share
Locality Sensitive Hashing at Lyst
Description of the intuition behind locality sensitive hashing and its application at Lyst.
Maciej Kula
July 24, 2015
More Decks by Maciej Kula
See All by Maciej Kula
Implicit and Explicit Recommender Systems
maciejkula
0
3k
Binary Embeddings For Efficient Ranking
maciejkula
0
710
Rust for Python Native Extensions
maciejkula
0
490
Hybrid Recommender Systems at PyData Amsterdam 2016
maciejkula
5
2.8k
Recommendations under sparsity
maciejkula
1
390
Metadata Embeddings for User and Item Cold-start Recommendations
maciejkula
2
1k
Other Decks in Programming
See All in Programming
事業会社でのセキュリティ長期インターンについて
masachikaura
0
250
VueエンジニアがReactを触って感じた_設計の違い
koukimiura
0
170
tRPCの概要と少しだけパフォーマンス
misoton665
2
180
How Swift's Type System Guides AI Agents
koher
0
250
iOS機能開発のAI環境と起きた変化
ryunakayama
0
180
GNU Makeの使い方 / How to use GNU Make
kaityo256
PRO
16
5.6k
レガシーPHP転生 〜父がドメインエキスパートだったのでDDD+Claude Codeでチート開発します〜
panda_program
0
900
10 Tips of AWS ~Gen AI on AWS~
licux
5
380
3分でわかるatama plusのQA/about atama plus QA
atamaplus
0
170
YJITとZJITにはイカなる違いがあるのか?
nakiym
0
220
Cache-moi si tu peux : patterns et pièges du cache en production - Devoxx France 2026 - Conférence
slecache
0
210
Vibe NLP for Applied NLP
inesmontani
PRO
0
420
Featured
See All Featured
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
770
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
1.9k
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
320
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
520
What does AI have to do with Human Rights?
axbom
PRO
1
2.1k
Un-Boring Meetings
codingconduct
0
270
YesSQL, Process and Tooling at Scale
rocio
174
15k
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
Chasing Engaging Ingredients in Design
codingconduct
0
170
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
5.6k
brightonSEO & MeasureFest 2025 - Christian Goodrich - Winning strategies for Black Friday CRO & PPC
cargoodrich
3
680
Transcript
Speeding up search with locality sensitive hashing. by Maciej Kula
Hi, I’m Maciej Kula. @maciej_kula
We collect the world of fashion into a customisable shopping
experience.
Given a point, find other points close to it. Nearest
neighbour search… 4
None
At Lyst we use it for… 1.) Image Search 2.)
Recommendations 6
Convert image to points in space (vectors) & use nearest
neighbour search to get similar images. 1. Image Search (-0.3, 2.1, 0.5)
Super useful for deduplication & search.
Convert products and users to points in space & use
nearest neighbour search to get related products for the user. 2. Recommendations user = (-0.3, 2.1, 0.5) product = (5.2, 0.3, -0.5)
Great, but…
11 80 million We have images
12 9 million We have products
Exhaustive nearest neighbour search is too slow.
Locality sensitive hashing to the rescue! Use a hash table.
Pick a hash function that puts similar points in the same bucket. Only search within the bucket.
We use Random Projection Forests
Partition by splitting on random vectors
Partition by splitting on random vectors
Partition by splitting on random vectors
Partition by splitting on random vectors
Partition by splitting on random vectors
Points to note Keep splitting until the nodes are small
enough. Median splits give nicely balanced trees. Build a forest of trees.
Why do we need a forest? Some partitions split the
true neighbourhood of a point. Because partitions are random, other trees will not repeat the error. Build more trees to trade off query speed for precision.
LSH in Python annoy, Python wrapper for C++ code. LSHForest,
part of scikit-learn FLANN, an auto-tuning ANN index
But… LSHForest is slow. FLANN is a pain to deploy.
annoy is great, but can’t add points to an existing index.
So we wrote our own.
github.com/lyst/rpforest pip install rpforest
rpforest Quite fast. Allows adding new items to the index.
Does not require us to store points in memory.
We use it in conjunction with PostgreSQL Send the query
point to the ANN index. Get ANN row ids back Plug them into postgres for filtering Final scoring done in postgres using C extensions.
Side note: postgres is awesome. Arrays & custom functions in
C
Gives us a fast and reliable ANN service 100x speed-up
with 0.6 10-NN precision Allows us to serve real-time results All on top of a real database.
thank you @maciej_kula