30th issue! If you missed them, you can read the previous issues of the Machine Learning Monthly newsletter here.
Daniel here, I'm 50% of the instructors behind Zero To Mastery's Machine Learning and Data Science Bootcamp course and our new TensorFlow for Deep Learning course.
I also write regularly about machine learning on my own blog and make videos on the topic on my YouTube channel.
Enough about me!
Welcome to this month's edition of Machine Learning Monthly. A 500ish (+/-1000ish, usually +) word post detailing some of the most interesting things on machine learning I've found in the last month.
Benchmarking PyTorch running on Apple Silicon GPU(s) (collaboration with Alex Ziskind)
Last month I showcased how to setup PyTorch to run on your Apple Silicon Mac GPUs (update: PyTorch 1.12 is out so you no longer need the nightly versions).
This month Alex Ziskind and I teamed up to speed test a bunch of our Apple Silicon machines to see how fast the new versions of PyTorch are.
The results: PyTorch on the Apple Silicon GPU is a fantastic speed up and great for experimenting but not without bugs.
My brand new course is launching this week!
Sign up to the newsletter above and maybe we'll send you a special discount code when it launches π.
This monthβs theme is creating embeddings for everything.
Whatβs an embedding?
An embedding is a learnable representation of data.
The key word being learnable. Rather than representing a piece of data as a static collection of numbers (a tensor), an embedding can be updated over time and continually improved to better represent the data.
An embedding is usually a vector and youβd usually have one vector per piece of data.
For example, an image of pizza might be represented by the numbers [0.24, 0.45, 0.33...]
(Iβve made these up, only to give an example, an embedding can be as long or short as you like, longer usually means a better representation but also more compute).
Once youβve turned all of your data into embeddings, or learnable vectors, you can start to perform similarity methods on them such as the dot product, cosine similarity or nearest neighbour search to find similar examples.
This creates a forever-improving way to search your data.
Why?
Because if your data is in the form of learnable embeddings, these representations can be continually updated and improved over time.
How does this help?
Imagine searching for an article with the text βThe best machine learning resourcesβ.
A simple approach would be to return articles with the exact title βThe best machine learning resourcesβ.
Another approach would be to turn the articles as well as the search query into embeddings (numerical representations) and then see which article embeddings match the search query embeddings the best.
This is only the tip of the iceberg when it comes to the idea of creating embeddings for everything but itβs been something Iβve been coming across more and more.
Just like turning data into tensors, once you get the idea of embeddings in your head, it never leaves.
The first two resources discuss this further.
In this article, Romain Beaumont, one of the founders of Laion AI, shares the idea of applying semantic search to almost anything.
Semantic search is using natural language to search for what you mean, rather than the exact text of your search.
For example, searching images themselves for βblue dressβ rather than images explicitly labeled with βblue dressβ.
Semantic search demonstration for different applications: text search in images, image search for matching images, recommendation based on similar movies, recommendation based on time-specific parameters (Source).
The best thing about turning data into vectors is: you can search it, fast.
Continuing on from the example of turning everything into embeddings above, Google Cloud offers a managed solution called Vertex AI Matching Engine.
You upload your embeddings (or create them on Google Cloud) and the Vertex AI Matching Engine makes them searchable/matchable.
This is the same backend powering Google Image Search, YouTube, Google Play and more.
Example demo of using Google Cloudβs Vertex AI Matching Engine to match similar embeddings for various images. Notice how fast it can easily match similar images across a database of 2 million images. Try it out for yourself at MatchIt Fast.
Instacart is a grocery delivery and pickup service with 600,000 people shopping for others on the app.
Dealing with this many people couldnβt be done without machine learning.
The article above shares how the Instacart team developed their machine learning platform to deal with almost every feature of the app.
My favourite section is towards the end where they discuss:
As you start to get more familiar with machine learning codes, you might notice how different frameworks implement similar features with different styles.
For example, Scikit-Learn has the classic model.fit()
built-in.
Whereas if youβre using pure PyTorch, you might create a function called train()
or implement the fit()
method to your model
class on your own.
Or even slightly outside of machine learning but still related to the resources above.
The proxy design pattern is used to cache the most active queries.
For example, if lots of people are searching for βblue dressβ, it makes sense not to recompute the search every single time. Instead, you could cache the search for βblue dressβ and the next time someone searches βblue dressβ, they get delivered the cached results instead of brand new results.
This saves resources on the backend (less computing search queries) and speeds up the experience on the frontend (quicker results).
What kind of design pattern should you use for your application?
Well, it depends.
Usually, itβs best to figure it out by trial and error. But being aware of the different design patterns that exist can be very helpful.
The following two posts discuss many popular and useful machine learning design patterns:
Stop the press!!!!
After years of Andrew Ngβs original course being the gold standard for anyone new to machine learning, the OG ML educator is back with a new and improved version.
And this time everythingβs coded in Python instead of MATLAB or Octave (I never got into these languages).
Andrew Ngβs courses are what got me started in machine learning and Iβm stoked to see the newest iteration opening up to the public.
Optical character recognition (OCR) is the process of identifying text characters with computer vision.
For example, scanning a driverβs license or reading a passport or taking a picture of a credit card and retrieving the numbers.
Iβm a big fan of models running the browser.
Because what it often means is a (potentially) faster experience and the data is kept private.
The faster comes from the data not having to be sent across the internet to an inference computer.
And the private is because the data never leaves the browser.
Everything happens on the personβs device.
Until recently, deploying complex machine learning models such as OCR models (models with several stages) to the browser has been quite a challenge.
But the team at Mindee has shared how they deployed a version of their OCR model called DocTR in the browser using TensorFlow.js (a version of TensorFlow in JavaScript, the programming language of the web).
I tried it out on a screenshot of last monthβs Machine Learning Monthly and the results turned out pretty good.
OCR in the browser demo with TensorFlow.js by Mindee.
SpaCy is one of the best natural language processing (NLP) engines on the market.
The use cases for NLP are almost endless.
What about seeing whether a health supplement is worth it or is a waste of time by analysing its reviews?
In Healthsea: an end-to-end spaCy pipeline for exploring health supplement effects, machine learning engineer Edward Schmuhl showcases a technical approach for using Spacyβs NLP capabilities to analyze user reviews of health supplements.
Iβve been loving reading along with Alexβs series on creating a custom object detection model from scratch including data collection, labeling, synthetic data creation, data versioning and now deployment.
In his latest blog post he shares ideas of how heβs going to deploy his custom redaction detection (finding locations in a document that have been blanked out) into production so others can use it.
This is one of my favourite machine learning blog post series on the internet right now.
A fantastic example of learning MLOps by doing.
Youβve just started learning machine learning, now youβd like to start building your ideas.
How do you do it?
The best option is to just start.
Figure things out on the way.
But while youβre figuring it out, reading Chip Huyenβs Designing Machine Learning Systems book along the way will help tremendously.
Chip is one of my favourite people in the world of ML.
And this book is based on years of experience as well as talking to some of the best machine learning practitioners in the business.
Iβve got a copy for myself on the way.
Once it arrives Iβll be sure to share what Iβve learned.
You can buy the book online or see an outline on GitHub.
Letβs finish off with a couple of fun things from Twitter.
#1: Jeremy Jordan shares his high level overview of MLOps
I love the simplicity of this.
You could see each section being a collection of Pythons scripts each with a single goal.
#2: ClearBuds: Wireless Binaural Earbuds for Learning-Based Speech Enhancement
One of the best ML demos Iβve ever seen. If you thought noise-cancelling headphones were getting good, check these out.
What a massive month for the ML world in June!
As always, let me know if there's anything you think should be included in a future post.
In the meantime, keep learning, keep creating, keep dancing.
See you next month, Daniel
By the way, I'm a full-time instructor with Zero To Mastery Academy teaching people Machine Learning in the most efficient way possible. You can see a couple of our courses below or check out all Zero To Mastery courses.