Scaling ML embedding models to serve a billion queries

A presentation at AI DevWorld 2022 in October 2022 in San Jose, CA, USA by Senthilkumar Gopal

Slide 1

Slide 1

Scaling embedding models to serve a billion queries Senthilkumar Gopal @sengopal

Slide 2

Slide 2

Journey of a Query @ eBay 2 © 2022 eBay. All rights reserved.

Slide 3

Slide 3

Search @ eBay How can we discover items without describing them? This is a problem across many domains where search is a core functionality. Question to ponder can we provide users with the ability to “discover” through visual cues instead? 3 © 2022 eBay. All rights reserved. https://unsplash.com/photos/2oUiUu5QAys

Slide 4

Slide 4

Current Search Experience Nice Kilim Pillow for my couch! 4 © 2022 eBay. All rights reserved. Is this a kilim pillow? Or a orange kilim pillows? Perhaps a orange throw kilim pillow??

Slide 5

Slide 5

k nearest neighbours search - A thought experiment Let’s represent an item TITLE as a 2-dimensional vector 5 © 2022 eBay. All rights reserved.

Slide 6

Slide 6

So what is an embedding then? Represents Semantic Similarity Similarity (sofa, couch) A real word example [R768] 6 © 2022 eBay. All rights reserved. https://pytorch.org/tutorials/beginner/nlp/word_embeddings_tutorial.html

Slide 7

Slide 7

So what is an embedding then? You shall know a word by the company it keeps - (Firth, J. R. 1957:11) Large Language Models - GPT 3 [175 B] ○ 45 TB text data - Wikipedia and books Neural network learns word associations from a large corpus. 7 ○ Detects synonymous words. ○ Suggests words for a partial sentence. © 2022 eBay. All rights reserved. https://en.wikipedia.org/wiki/Word2vec https://ruder.io/word-embeddings-1/

Slide 8

Slide 8

So what is an embedding then? books numbers companies 8 © 2022 eBay. All rights reserved. http://web.stanford.edu/class/cs224n/slides/cs224n-2022-lecture02-wordvecs2.pdf 8

Slide 9

Slide 9

So what is an embedding then? 9 © 2022 eBay. All rights reserved. http://web.stanford.edu/class/cs224n/slides/cs224n-2022-lecture02-wordvecs2.pdf

Slide 10

Slide 10

What about an image? 10 © 2022 eBay. All rights reserved. https://en.wikipedia.org/wiki/Convolutional_neural_network

Slide 11

Slide 11

Model Architecture Multiple Modalities - Inspired by CLIP * 11 © 2022 eBay. All rights reserved. https://openai.com/blog/clip/

Slide 12

Slide 12

How do we “learn” an embedding? Text Encoder 12 © 2022 eBay. All rights reserved. R768 That’s how an embedding looks like!!! Image Encoder Devlin, Jacob, et al. “Bert: Pre-training of deep bidirectional transformers for language understanding.” arXiv preprint arXiv:1810.04805 (2018). https://en.wikipedia.org/wiki/Convolutional_neural_network

Slide 13

Slide 13

Why do we need ANN? All problems start with SCALE Exhaustive search curse of dimensionality ANN Approximate Nearest Neighbours 13 © 2022 eBay. All rights reserved. https://en.wikipedia.org/wiki/Proximity_analysis#/media/File:Euclidean_Voronoi_diagram.svg http://ann-benchmarks.com/index.html#algorithms

Slide 14

Slide 14

14 © 2022 eBay. All rights reserved. combining the elements together

Slide 15

Slide 15

How does this function? Display all inventory matching my visual appeal Quickly pivot to entire inventory using a visual first cue 15 © 2022 eBay. All rights reserved. Is this a orange throw kilim pillow?

Slide 16

Slide 16

Data Engineering

Slide 17

Slide 17

Design Trained model 17 © 2022 eBay. All rights reserved.

Slide 18

Slide 18

Data Ingestion 18 © 2022 eBay. All rights reserved.

Slide 19

Slide 19

Data Ingestion Challenges 19

Speed vs. resource trade off

Storage

Download errors

Downstream dependencies © 2022 eBay. All rights reserved. https://unsplash.com/photos/wrrgZwI7qOY

Slide 20

Slide 20

ML Platform and Inference 20 © 2022 eBay. All rights reserved.

Slide 21

Slide 21

Cassini Indexing 21 © 2022 eBay. All rights reserved. The Architecture of eBay Search Trotman, Andrew, Jon Degenhardt, and Surya Kallumadi - eCOM@ SIGIR. 2017.

Slide 22

Slide 22

Orchestration 22 © 2022 eBay. All rights reserved. https://unsplash.com/photos/yUJVHiYZCGQ

Slide 23

Slide 23

Workflow Orchestration using Apache Airflow Processing modes - BULK - DELTA 23 © 2022 eBay. All rights reserved. Apache Airflow Logo

Slide 24

Slide 24

Challenges with Apache Airflow Challenge Solution Multiple Spark versions Define task level parameters Multiple Docker image versions Python virtual environment packages Different platforms, zones, and network Retries, system monitoring flakiness 24 © 2022 eBay. All rights reserved. Apache Airflow Logo

Slide 25

Slide 25

A/B Testing How do we test different models in production? Trained model 25 © 2022 eBay. All rights reserved.

Slide 26

Slide 26

Data Publishing for A/B Tests using Airflow 26 © 2022 eBay. All rights reserved.

Slide 27

Slide 27

Evolution Model Drift • Seasonality • Aging of the models Actions • Metrics monitoring • Downstream evaluation • Retraining 27 © 2022 eBay. All rights reserved. Data Drift • Data Integrity • Data pipelines Actions • Fault tolerance • Monitoring of time, cpu, memory, disk

Slide 28

Slide 28

Key takeaways Similarity 28 © 2022 eBay. All rights reserved. Scalability Monitoring

Slide 29

Slide 29

Questions? slides areeBay. available at https://bit.ly/ebay-ml 29 © 2022 All rights reserved. https://unsplash.com/photos/4V1dC_eoCwg

Slide 30

Slide 30