Using a powerful Business-Contextual Image Retrieval
Paul-Louis Nech | Senior ML Engineer @Algolia | M. ScEng @EPITA
Who we are
Powering discovery
Agenda
User expectations
The challenge
Start with Vectors
Giving finer control
1
2
3
4
01
—
User expectations in 2023
Powering discovery
Powering discovery
Users expect �instant interactions�
Powering discovery
Powering discovery
Returning results quickly
doesn’t matter
If it’s the wrong ones
Powering discovery
Users expect relevant results
Powering discovery
Powering discovery
On mobile and via chat,�the first result(s)
is all that matters
Powering discovery
Users expect �Understanding�
�See “Like Having a Really bad Personal Assistant: �The Gulf between User Expectation �and Experience of Conversational Agents”,�Luger & Sellen, 2016
Powering discovery
Powering discovery
“We find user expectations dramatically out of step �with the operation of the systems, �particularly in terms of �known machine intelligence, �system capability and goals.”
Ewa Luger
Microsoft Research, 2016
Powering discovery
Users expect MultiModality
Pinterest’s PinSage recommender system
based on “visual and annotation embeddings as input features”
Powering discovery
The Challenge:
�Building an API which meets these expectations
Powering discovery
Marketplaces�with short-lived items
Powering discovery
Powering discovery
“Find me this”�shopping experience
Powering discovery
Powering discovery
Step by step�user journeys
Powering discovery
V1 = v(product['image']) + 0.2 * v(category['title'])
V2 = v(product['image']) + 0.1 * v(previous_product['image'])
V3 = v(product['image']) - 0.3 * v(not_this_product['image'])
Powering discovery
02
—
Baseline: �Image Vectors Retrieval
Powering discovery
Powering discovery
From Images to Vectors
Resnet18 | Deep Residual Learning for Image Recognition�https://arxiv.org/abs/1512.03385
Fixed length vectors�(512)
Arbitrary-sized images
img2vec = Img2Vec(cuda=False, model="resnet18", layer_output_size=512)
Powering discovery
From Vectors to Binary Hashes: LSH
// returns a dense binary vector using signals >0 as activation threshold.
func (h *NH) Hash(v []float32, b []byte) []byte {…}
Similarity Search in High Dimensions via Hashing
A. Gionis, P. Indyk, R. Motwani
Powering discovery
From Vectors to Binary Hashes: Semantic Hashing
// returns a dense binary vector using signals >0 as activation threshold.
func (h *NH) Hash(v []float32, b []byte) []byte {…}
Semantic Hashing
R. Salakhutdinov, G. Hinton
http://www.cs.columbia.edu/~smaskey/CS6998-0412/supportmaterial/semantic_final.pdf
Powering discovery
From Hashes to Results: Retrieval with HNSW
Efficient and robust ANN search using� Hierarchical Navigable Small World graphs
Yu. A. Malkov, D. A. Yashunin�https://arxiv.org/abs/1603.09320
Powering discovery
Putting it all together
Vectorization + Hashing
Nearest Neighbors (ANN) retrieval via HNSW
Powering discovery
Putting it all together
Indexing at 47 qps, �with p95 latency under 500ms
Powering discovery
Preliminary results
Powering discovery
Powering discovery
Preliminary results
Powering discovery
Preliminary results
Powering discovery
The Limitation:
�What you See is
(mostly)
What you Get
Powering discovery
The “What you see is what you get” problem
Powering discovery
The “What you see is what you get” problem
Nearest (different) neighbor
Input
Best match
Powering discovery
The “What you see is what you get” problem
Nearest (different) neighbor
Input
Best match
Powering discovery
Powering discovery
What we would like instead
Vectorization
With img2vec
🔢
Retrieval
With HNSW
🎣
Hashing
With a Learned LSH
🪓
Filtering
Using object-level metadata
🪣
Rules
boost/bury on demand
📐
Powering discovery
03
—
Designing an image rec. API �for broader use-cases
Powering discovery
Powering discovery
Leveraging object-level properties
Powering discovery
Filtering results based on object-level properties
Powering discovery
API-based Filtering to enable unexpected use-cases
{
threshold: 0.3,
maxRecommendations: 5,
queryParameters: { parameters },
fallbackParameters: { parameters }
}
Powering discovery
QueryParameters: filtering the happy path
Powering discovery
QueryParameters: concrete example
queryParameters={{
facetFilters: [
`roastLevel:${selectedProduct.roastLevel}`,
`inStock: ${true}`,
],
}}
Powering discovery
QueryParameters: concrete example
queryParameters={{
facetFilters: [
`store:San Francisco`,
],
}}
Powering discovery
FallbackParameters: recover from not-happy path
fallbackParameters={{
facetFilters: [
`category:${selectedProduct.category}`,
`colourFilter: ${selectedProduct.colourFilter}`,
`inStock: ${true}`,
],
}}
Powering discovery
Rules: enable campaigns and merchandising
Powering discovery
Rules: enable campaigns and merchandising
Powering discovery
Rules: enable campaigns and merchandising
Powering discovery
From an API to a Service
Powering discovery
From an API to a Service
Powering discovery
Integration
Operation
Powering discovery
To summarize
Powering discovery
To summarize
Hashing vectors is key to scaling
Vectorization is a powerful core tech
An expressive API unlocks many use-cases
Paul-Louis Nech | ECIR23 Industry Day | Slides: alg.li/ecir23-talk 🔗
Powering discovery