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
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Maciej Kula
July 24, 2015
Programming
1.4k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
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
3.1k
Binary Embeddings For Efficient Ranking
maciejkula
0
730
Rust for Python Native Extensions
maciejkula
0
500
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
ドリフトを絶対に許さない(?)CDK運用 / CDK Ops with Zero Tolerance for Drifts (?)
akihisaikeda
1
180
改善しないと、タスクが回らない。 “てんこ盛りポジション” を引き継いだ情シスの、入社3ヶ月の業務改善録
krm963
0
260
ここ半年くらいでAIに作らせたR用ツール
eitsupi
0
370
自動化したのに回らないテスト運用の壁ーAI時代の品質責任と生産性
mfunaki
0
130
Laravel Boostに学ぶ、AIにPHPを書かせる技術 〜OSSの実装から蒸留するエージェント制御の王道〜
kentaroutakeda
3
670
ソフトウェア設計に溶けるインフラ ― AWS CDK のインフラ認識論
konokenj
3
770
PHP に部分適用が来るぞ!……ところで何それ?おいしいの? #phpcon / phpcon-2026
shogogg
0
600
【QA Test Talk Vol.8】AI-DLC による Whole Team Approach の加速
pkshadeck
PRO
0
120
生成AIで帳票OCRが「簡単に」作れる時代になった?
kon_shou
0
640
JAWS-UG横浜 #102 AWSサ終供養LT会 成仏できない AWS サービスたち 〜本日、三体供養します〜
maroon1st
0
340
Foundation Models frameworkで画像分析
ryodeveloper
1
600
FDEが実現するAI駆動経営の現在地
gonta
2
270
Featured
See All Featured
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
34
2.8k
KATA
mclloyd
PRO
35
15k
The #1 spot is gone: here's how to win anyway
tamaranovitovic
3
1.1k
Ten Tips & Tricks for a 🌱 transition
stuffmc
0
160
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.6k
So, you think you're a good person
axbom
PRO
2
2.1k
The Curse of the Amulet
leimatthew05
2
14k
AI: The stuff that nobody shows you
jnunemaker
PRO
9
890
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
400
Raft: Consensus for Rubyists
vanstee
141
7.6k
Six Lessons from altMBA
skipperchong
29
4.4k
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.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