I’ve always been a huge NLP fan and as a result of that a big HuggingFace fan. While HuggingFace is known for their strong NLP background, they’ve recently released a new feature known as Spaces, that helps you quickly host ML demo applications on your profile. Spaces supports two frameworks that can quickly build Python apps: Streamlit and Gradio. I’m also a big Streamlit fan so we’ll be using that framework to build out a sample Spaces application for today’s article. If you want even more flexibility and control of your front-end you can work with a custom framework or bring your own HTML code.
NOTE: For this article we won’t really be focusing on any model building packages, it will be centered around displaying the functionality of the Spaces feature.
Table of Contents (ToC)
- Setup
- Build Application & Test
- Conclusion & Additional Resources
1. Setup
To get started with Spaces you can need to make a HuggingFace Profile account at the following link.

Here you can add extra features such as a Github or Twitter username if you want to collaborate with other members. After this, click "Create new Space" and you can setup your project.

For this example we’ll be working with Streamlit and creating a public workspace. For a custom SDK, get in touch with HuggingFace through the "Add yours" link.
After we’ve created our Space, we can navigate to "Files and Versions" where we manage our directory. First create a requirements.txt file with any additional dependencies, this is how Spaces will pick up on the frameworks that you are using. Spaces comes with the following pre-installed libraries: huggingface_hub, requests, and datasets. In our requirements.txt we will add the transformers and textblob library for Sentiment Analysis.
Next create an "app.py" file, this is where our application code will be created. The file structure should look like the following screenshot.

2. Build Application & Test
Now we can edit our app.py file to build our application. We’ll make a simple application that gives the option to use two different frameworks for Sentiment Analysis on some sample text. As you’re creating the file, you can preview how it looks on the App tab in the top left corner of your Space.

Now we can add some basic logic to use either available framework.
We can now test our application with the two different frameworks.


Within 10 minutes, we’ve managed to deploy a simple yet powerful demo application that is publicly shareable. To adjust any knobs of the application you can also go to the Settings tab to make the Space private or to delete it.
3. Conclusion & Additional Resources
Spaces is a new and extremely useful feature to quickly test and demo ML applications if you don’t have your own infrastructure setup. I’m curious to see the future flexibility HuggingFace provides in regards to potentially bringing your own front-end stacks/frameworks for your application. If you would like to see a video demonstration check out the following tutorial HuggingFace released. For different HuggingFace pipelines and tasks check out the following documentation.
If you enjoyed this article feel free to connect with me on LinkedIn and subscribe to my Medium Newsletter. If you’re new to Medium, sign up using my Membership Referral.