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
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Maciej Kula
July 24, 2015
Programming
0
1.4k
Locality Sensitive Hashing at Lyst
Description of the intuition behind locality sensitive hashing and its application at Lyst.
Maciej Kula
July 24, 2015
Tweet
Share
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
480
Hybrid Recommender Systems at PyData Amsterdam 2016
maciejkula
5
2.8k
Recommendations under sparsity
maciejkula
1
380
Metadata Embeddings for User and Item Cold-start Recommendations
maciejkula
2
1k
Other Decks in Programming
See All in Programming
Ruby and LLM Ecosystem 2nd
koic
1
1.3k
飯MCP
yusukebe
0
350
Fundamentals of Software Engineering In the Age of AI
therealdanvega
2
290
new(1.26) ← これすき / kamakura.go #8
utgwkk
0
2.7k
GC言語のWasm化とComponent Modelサポートの実践と課題 - Scalaの場合
tanishiking
0
130
モダンOBSプラグイン開発
umireon
0
180
KagglerがMixSeekを触ってみた
morim
0
300
Claude Code Skill入門
mayahoney
0
430
ふつうのRubyist、ちいさなデバイス、大きな一年 / Ordinary Rubyists, Tiny Devices, Big Year
chobishiba
1
500
LM Linkで(非力な!)ノートPCでローカルLLM
seosoft
0
210
モックわからないマン卒業記 ~振る舞いを起点に見直した、フロントエンドテストにおけるモックの使いどころ~
tasukuwatanabe
3
420
SourceGeneratorのマーカー属性問題について
htkym
0
220
Featured
See All Featured
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.4k
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
160
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
5
770
Build your cross-platform service in a week with App Engine
jlugia
234
18k
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
1
490
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
220
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
150
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.6k
Technical Leadership for Architectural Decision Making
baasie
3
300
Building a Scalable Design System with Sketch
lauravandoore
463
34k
First, design no harm
axbom
PRO
2
1.1k
Building Applications with DynamoDB
mza
96
7k
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