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
720
Rust for Python Native Extensions
maciejkula
0
490
Hybrid Recommender Systems at PyData Amsterdam 2016
maciejkula
5
2.9k
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
なぜあなたのコードには「コシ」がないのか?〜AI時代に問う、最後まで美味しい設計と戦略〜 #phpconkagawa / phpconkagawa2026
shogogg
0
210
〜バイブコーディングを超えて〜 チームで実験し続けたAI駆動開発
tigertora7571
0
210
RailsTokyo 2026#4: AI様があれば、 Hotwireの弱点は消えるか?
naofumi
1
250
要はバランスからの卒業 #yumemi_grow
kajitack
0
170
PHPでローカル環境用のSSL/TLS証明書を発行することはできるのか? #phpconkagawa
akase244
0
370
空間オーディオの活用
objectiveaudio
0
150
When benchmarks go bad - what I learned from measuring performance wrong
hollycummins
0
390
「OSSがあるなら自作するな」は AI時代も正しいか ── Build vs Adopt の新しい判断基準
kumorn5s
7
2.7k
いつか誰かが、と思っていた フロントエンド刷新5年間の実践知
kiichisugihara
1
280
ローカルLLMでどこまでコードが書けるか / How much code can be written on a local LLM
kishida
2
360
2026年のソフトウェア開発を考える(2026/05版) / Software Engineering Scrum Fest Niigata 2026 Edition
twada
PRO
23
13k
属人化しないコード品質の作り方_2026.04.07.pdf
muraaano
0
350
Featured
See All Featured
The Illustrated Children's Guide to Kubernetes
chrisshort
51
52k
The untapped power of vector embeddings
frankvandijk
2
1.7k
Ethics towards AI in product and experience design
skipperchong
2
270
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
530
Build your cross-platform service in a week with App Engine
jlugia
234
18k
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
120
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
280
sira's awesome portfolio website redesign presentation
elsirapls
0
240
Producing Creativity
orderedlist
PRO
348
40k
Side Projects
sachag
455
43k
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
150
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
5.9k
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