Careers In AI

Mar

Tuesday

28

Developing and Deploying Machine Learning Models with Hugging Face

Hugging Face is much more than an AI platform with the tools to develop, train and deploy machine learning models, it is an AI community where people come together to share machine learning models while contributing to several open-source projects. 

Hugging Face was founded in 2016 by Clément Delangue, Julien Chaumond, and Thomas Wolf. They have since scaled up to raise more than 160 million in venture funding. Hugging face started as a chatbot app before transforming into a machine learning platform. Hugging Face provides different machine-learning models for different tasks. As expressed in the mission statement of the company “…We are on a mission to democratize good machine learning, one commit at a time”. Hugging face wants to become to Machine Learning and AI what GitHub is to Software Engineering


With pre-trained models, tools and libraries, Hugging Face stands out in Natural Language Processing (NLP) tasks such as Text classification, Text generation,  Text summarization, and translation. Hugging face can also be used for Computer Vision Tasks, Audio tasks and many other ML tasks. 

This piece will provide a brief introduction to hugging face which covers:


  • A brief history of Hugging Face
  • The Transformers Library by Hugging Face
  • Models Hub
  • Datasets on Hugging Face
  • Inference API
  • AutoTrain
  • Hugging Face Spaces

Training, and evaluating machine learning models on Hugging Face 

Hugging Face Transformers Library


Hugging Face was initially developed for NLP tasks but it has evolved for other ML tasks in audio and visual domains. The Hugging Face transformers library is a python library created to provide ease of access and simplicity to complex ML models which can be loaded and trained.

Transformer is a collection of state-of-the-art models for computer vision, audio and voice processing, and natural language processing (NLP). This collection of models also includes “non-Transformer” models as well, such as contemporary convolutional networks for computer vision tasks.

Hugging’s Face Transformers is the best available solution today for building ML models, hugging face’s transformers has huge access to models to cover both individual and enterprise implementations.

Apart from NLP and Computer Vision Tasks, Hugging Face Transformers is also useful for

  • Pre-processing Data
  • Fine Tuning Data 
  • Sharing Models 

Models Hub

As a repository of numerous models, hugging face offer models for many NLP tasks not limited to token classification, text-to-text generation and text classification. There are also several models for multimodal tasks, computer vision tasks, audio tasks, tabular data tasks and reinforcement learning.

The model hub can be used to fine-tune already existing models and through the transformer’s library, built models can be uploaded to the Hugging Face Model hub. Hugging Face users who have an account on the platform can also upload their models manually by signing in, clicking on “My Profile”, then selecting “New Model” and start uploading their files.

The Models Hub can help to create models for an ML task at hand, by providing code snippets that can be utilised by a developer.  The Model Hub page has InferenceAPI embedded in it and this allows the user to select the right model for a specific use case by testing the model on Hugging Face. This saves a lot of time as a user can know if a model is right for the task at hand or not.

Data Sets

In a manner similar to providing several models, Hugging Face also provides datasets for Multimodal, Computer Vision, Natural Language Processing, Audio, and Tabular tasks. Presently, there are over 25,000 datasets available on hugging face and this number increases by the day. A user can upload the dataset for their tasks to hugging face. 


AutoTrain

AutoTrain is one of the latest offerings from Hugging Face. AutoTrain is no code solution for training, evaluating and deploying state-of-the-art NLP models. The models built with AutoTrain can be deployed directly to the Hugging face Model hub.

AutoTrain is an autoML tool created by hugging face, this autoML tool allows developers to create powerful models without having to write code. The AutoTrain have great features that allow users to deploy models directly to the Models Hub. 

AutoTrain is used by top companies like eBay, WRITER and Orlo because it I quite easy to use, it also offers no code and low code developers a solution as it handles everything from training to evaluation and deploying with a bunch of mouse clicks.

Inference API

For developers who do not care about all the NLP or ML stuff going on the backend, and who want to build machine learning applications (app or web applications) without training a model, the Hugging Face inference API is a hit-and-get-response API.

By clicking on a specific model for a task at hand, Hugging Face opens up a page with a Hosted inference API on the right side which allows a developer to try the model of the particular model and see how it works.

The inference API allows a developer to integrate models into python code, JavaScript code and cURL code via the deploy button on the right section of the model page. 

Deploying Applications

Hugging Face is a complete AI package, that allows state-of-the-art models to be built, evaluated and deployed collaboratively and efficiently.  Models can be deployed in some ways on Hugging face, with inference API and AutoTrain. Hugging Face Spaces is not just a space for deploying machine learning models, it is also a space for showcasing ML applications built by the community. 

Hugging Face Spaces 

Spaces on Hugging Face is the quickest and easiest way to deploy machine learning apps, with spaces, developers can use any existing code build an app around it and share it instantly, all for free on Spaces.

Creating a new Space on Hugging face requires the developer to be logged in to a hugging face account.

  • Click on the User Icon in the Top Right Corner
  • Then click ‘New Space
  • Name the project
  • Select any of the Open Source Libraries preferred (Streamlit or Gradio)
  • Select ‘Public’ or ‘Private’
  • Then click ‘Create Space’ to create a new project

In just a few lines of code, the machine-learning app can be created and shared with a link. Machine Learning Engineers and Data Scientists can showcase their portfolio in Spaces

Concluding Remarks

With over 86,000 stars on GitHub and over 5,000 organizations using Hugging Face, it is obvious that Hugging face is not just a platform for building, training, and deploying machine learning models, it is a data science community with rich ML resources, features and tools that aid collaboration and effectiveness.

The Hugging Face company has hired the best ML practitioners all around the world intending to democratize good Machine Learning. Hugging face is one of the best AI platforms today. You can check out more of our resources to get started. https://huggingface.co/