1 of 47

Using a powerful Business-Contextual Image Retrieval

Paul-Louis Nech | Senior ML Engineer @Algolia | M. ScEng @EPITA

2 of 47

Who we are

Powering discovery

3 of 47

Agenda

User expectations

The challenge

Start with Vectors

Giving finer control

1

2

3

4

4 of 47

01

User expectations in 2023

Powering discovery

Powering discovery

5 of 47

Users expect �instant interactions�

  • 0.5 sec delay causes 20% traffic drop�
  • Users pick a movie in �1.8 seconds�
  • 100ms delay will result in �1% revenue loss

Powering discovery

Powering discovery

6 of 47

Returning results quickly

doesn’t matter

If it’s the wrong ones

Powering discovery

7 of 47

Users expect relevant results

  • #1 search result gets 27.6% of clicks�
  • 10th result gets 10x less clicks than 1st�
  • 37% of users only engage with first page

~ Backlinko, Google CTR Stats

Powering discovery

Powering discovery

8 of 47

On mobile and via chat,�the first result(s)

is all that matters

Powering discovery

9 of 47

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

10 of 47

“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

11 of 47

Users expect MultiModality

Pinterest’s PinSage recommender system

based onvisual and annotation embeddings as input features”

Netflix’ artwork personalization system

optimizing CTR & view share per country and per user

Powering discovery

12 of 47

The Challenge:

�Building an API which meets these expectations

Powering discovery

13 of 47

Marketplaces�with short-lived items

Powering discovery

Powering discovery

14 of 47

“Find me this”�shopping experience

Powering discovery

Powering discovery

15 of 47

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

16 of 47

02

Baseline: �Image Vectors Retrieval

Powering discovery

Powering discovery

17 of 47

From Images to Vectors

Resnet18 | Deep Residual Learning for Image Recognitionhttps://arxiv.org/abs/1512.03385

Fixed length vectors�(512)

Arbitrary-sized images

img2vec = Img2Vec(cuda=False, model="resnet18", layer_output_size=512)

Powering discovery

18 of 47

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

http://www.vldb.org/conf/1999/P49.pdf

Powering discovery

19 of 47

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 {…}

Powering discovery

20 of 47

From Hashes to Results: Retrieval with HNSW

Efficient and robust ANN search using� Hierarchical Navigable Small World graphs

Yu. A. Malkov, D. A. Yashuninhttps://arxiv.org/abs/1603.09320

Powering discovery

21 of 47

Putting it all together

Vectorization + Hashing

Nearest Neighbors (ANN) retrieval via HNSW

Powering discovery

22 of 47

Putting it all together

Indexing at 47 qps, �with p95 latency under 500ms

Powering discovery

23 of 47

Preliminary results

Powering discovery

24 of 47

Powering discovery

25 of 47

Preliminary results

Powering discovery

26 of 47

Preliminary results

Powering discovery

27 of 47

The Limitation:

�What you See is

(mostly)

What you Get

Powering discovery

28 of 47

The “What you see is what you get” problem

Powering discovery

29 of 47

The “What you see is what you get” problem

Nearest (different) neighbor

Input

Best match

Powering discovery

30 of 47

The “What you see is what you get” problem

Nearest (different) neighbor

Input

Best match

Powering discovery

31 of 47

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

32 of 47

03

Designing an image rec. API �for broader use-cases

Powering discovery

Powering discovery

33 of 47

Leveraging object-level properties

Powering discovery

34 of 47

Filtering results based on object-level properties

Powering discovery

35 of 47

API-based Filtering to enable unexpected use-cases

{

threshold: 0.3,

maxRecommendations: 5,

queryParameters: { parameters },

fallbackParameters: { parameters }

}

Powering discovery

36 of 47

QueryParameters: filtering the happy path

Powering discovery

37 of 47

QueryParameters: concrete example

queryParameters={{

facetFilters: [

`roastLevel:${selectedProduct.roastLevel}`,

`inStock: ${true}`,

],

}}

Powering discovery

38 of 47

QueryParameters: concrete example

queryParameters={{

facetFilters: [

`store:San Francisco`,

],

}}

Powering discovery

39 of 47

FallbackParameters: recover from not-happy path

fallbackParameters={{

facetFilters: [

`category:${selectedProduct.category}`,

`colourFilter: ${selectedProduct.colourFilter}`,

`inStock: ${true}`,

],

}}

Powering discovery

40 of 47

Rules: enable campaigns and merchandising

Powering discovery

41 of 47

Rules: enable campaigns and merchandising

Powering discovery

42 of 47

Rules: enable campaigns and merchandising

Powering discovery

43 of 47

From an API to a Service

Powering discovery

44 of 47

From an API to a Service

Powering discovery

Integration

  • GitHub code reviews�
  • CircleCI integration � & deployment�
  • GCP config connector for � review environments
  • ArgoCD for review apps � & continuous deployment

Operation

  • Kubernetes for deployment� and worker autoscaling
  • Google Cloud managed services
  • DataDog for monitoring � & observability
  • Slack notifications for alerting

Powering discovery

45 of 47

To summarize

Powering discovery

46 of 47

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

47 of 47

Building a Business-Contextual Image Retrieval API

Paul-Louis Nech | ECIR23 Industry Day

�Slides: alg.li/ecir23-talk 🔗

Powering discovery