Winter is a time of magic ๐งโโ๏ธ. Everyone is waiting for something special at this time, and Data Scientists arenโt different. It is not in the power of software developer to be a magician, but I can help you deploy your models with literally a single command right from your Jupyter notebook (and basically from any place like your command line or Python script).
Sounds like magic? It is! ๐ซ
To get some winter season vibes, letโs do some magic ourselves first. Letโs do something that will help us prepare some fun for our friends for the weekends.
To do so, weโll create a model that translates lyrics to emojis. With all due respect to recent advances in NLP and LLM algorithms, itโs still both easier and more fun to convince your friends to do the backward translation:
Ok, Iโm sure humans are up to the challenge!
Alright, just before we get into the actual coding, everything described in this blog post is available on this Google Colab notebook. Now, let's get to it!
First, letโs load an emoji dataset. We need something to base our model on, right?
The secret sauce to creating our emoji language is using a pretrained Distilbert model to tokenize and create embeddings which represent our emoji dictionary:
We can now similarly embed any word and replace it with its โclosestโ emoji embedding to create our textโemoji translator. Using that, โJingle bellsโ should become something like โ๐๐โ:
Good start - it guessed half of the emojis correctly!
Our part of magic is done, now to the single command deployment I promised in the beginning. Before we go rogue and deploy it to the cloud, letโs run a Streamlit app locally to test things out:
What happened here? That innocent looking mlem.api.save method inspected the model object to find all python packages to install did the magic of preparing the model to be used! ๐ชโจ
Now you should have a Streamlit app at localhost:80 that looks just like this:
Once we finished playing around with the model locally, letโs cast our final spell for the day ๐งโโ๏ธ and deploy the model to fly.io:
Some elvish gibberish is printed to the command line, and you get a deployment up and ready.
Now, before you go, remember that these powers extends to serving models as REST API applications, Streamlit apps, building Docker Images and Python packages, and deploying them to Heroku, Flyio, Kubernetes, and AWS Sagemaker.
Or just go here to get a crash course :)








Top comments (2)
Here are some translations. Check you intuition - are you getting what the neural networks are trying to say to you? Just remember, they aren't cherry-picked, just magical ๐ฆ
Song 1
1๏ธโฃ๐๐ซ, 1๏ธโฃ๐๐ซ ๐ท
One way ticket, one way ticket to the blues
(Eruption, "One Way Ticket")
Song 2
โฌ๏ธ๐จ๏ธ1๏ธโฃ๐๐๐ท
Dashing through the snow, In a one-horse open sleigh
("Jingle Bells")
Song 3
๐ โโ๐ฅ, ๐๐
๐ฅ๐ค๐, ๐๐บ๏ธ & ๐๐น
No more champagne,
And the fireworks are through
Here we are, me and you,
Feeling lost and feeling blue
(ABBA, "Happy New Year")
Song 4
๐ค ๐ ๐ฒ ๐ข, ๐น ๐โโ๏ธ
๐ค ๐ ๐ซ ๐ธ, ๐ค & ๐
& ๐ค ๐ญ ๐ค -โ ๐ ๐
I see trees of green
Red roses too
I see them bloom
For me and for you
And I think to myself
What a wonderful world
(Louis Armstrong, "What A Wonderful World")
P.S. Submit wizardry bugs and feature requests to GH:
github.com/iterative/mlem/issues.