If you've been wondering where to find a model or dataset that's perfect for your tasks, Hugging Face is the perfect solution! Hugging Face is one of the most popular platforms among AI practitioners.
In this topic, you will get familiar with Hugging Face and learn about its ecosystem.
The Hugging Face Hub overview
The Hugging Face Hub is a platform that provides access to pre-trained ML models, datasets, metrics, demo apps, and other artifacts. You can download models or dump your own pre-trained or fine-tuned models, and also, you can (serverless-ly) interact with the models via an API. Models and datasets on HF can be private or public. Private models/datasets are suitable if you work on some project and want to save intermediate results, or if you wish to share your model with only a few people. HF offers documentation and several open courses on various subjects, such as NLP, Deep RL and ML for 3D.
The Hugging Face Hub has several advantages for practitioners working with ML models:
The Hugging Face Hub supports version control, allowing users to manage different versions of resources (such as models and datasets). This helps with collaboration among researchers and reproducibility of experiments.
The Hugging Face Hub integrates with the Transformers library, making it straightforward to download and use models within code. The library provides a unified API to load and utilize models from the Hub, simplifying the development and deployment process.
Hugging Face has a large community of ML enthusiasts, researchers, and developers who actively contribute to the Hub. The community provides support, shares resources, and collaborates on improving existing models and developing new ones.
The Hugging Face Hub is an ecosystem for model development, sharing, and collaboration, making it easier for practitioners to access state-of-the-art models, datasets, and evaluation metrics while fostering a community-driven approach to advancements in AI.
Let's look at what you can find on Hugging Face!
Hugging Face's content
The Hugging Face Hub contains many tools for ML practitioners. You can find and filter models by many parameters. There are models for text, audio, images, videos, and structured data processing, so you can choose the most suitable model for your tasks. Here is a brief overview:
Datasets. The HF Hub contains many datasets suitable for model training, which you can also filter by parameters.
Apps. This site allows you to use models as attachments, which can be handy for presenting them. You can find ready-made apps in the Spaces section.
Libraries for using transformers. You can use the Transformers library for fine-tuning models as well as for using ready-to-go NLP models. The Accelerate library allows PyTorch code to run on different hardware setups and configurations and supports several training optimizations to make the code run faster.
Metrics. You can evaluate the quality of the model you trained using the Evaluate library (
pip install evaluate). This library contains the most popular metrics for evaluating the quality of various models. For evaluating LLMs, Hugging Face maintains LightEval.Inference Providers. Many models on HF can be called through Inference Providers, which route your request to a hosting provider, so you can use them for prototyping without having to download the models locally.
So, you already know a lot about the functionality of Hugging Face. Now it's time to join this community!
Log in and connect with an IDE
Let's create an account on Hugging Face and connect it with an IDE (this is needed to tinker with models locally). For this example, we will link the account to Jupyter Notebook. First, you need to create an account on HF.
After registering and signing in, click on the top right icon (your account icon) and choose "Access tokens". You will see a page with the list of your tokens. A token is like a password, and it is confidential. Generally, each token is created for an individual task, but you can use one for all. Click on "New token" and pick a name for it and the token's role:
read — if you are going to load a model only,
write — if you want to upload your model as well,
fine-grained — where you can combine various rights.
To log in to HF via Jupyter Notebook, use the following code:
from huggingface_hub import notebook_login
notebook_login()Run the cell, open the link it shows, enter the code and approve the request. When it's done, you will see a message like:
Login successful. Logged in as <your-username> (token: <token-name>).If you'd rather use the access token you created, pass it to login(token=...) (also from huggingface_hub), or set the HF_TOKEN environment variable (in Colab, add it as a secret).
Using Inference Providers
Alternatively, you can access Inference Providers with a token to interact with the hosted models without downloading them (the docs recommend a fine-grained token with the "Make calls to Inference Providers" permission). As an example, let's call the gpt-oss-20b model for chat completion (you can access this via the 'Use this model' drop down menu on the model card, under Inference Providers):
Note that here we paste the HF token in the code itself for demo purposes, but this should be avoided in shared code. Use .env files for secure key management instead.
from huggingface_hub import InferenceClient
client = InferenceClient(api_key="<Your HF token here>")
messages = [
{
"role": "user",
"content": "Could you explain gradient descent?"
}
]
completion = client.chat.completions.create(
model="openai/gpt-oss-20b",
messages=messages,
max_tokens=500
)
print(completion.choices[0].message.content)Which will output something similar to:
Gradient descent is an optimization algorithm ...Inference Providers are pay-per-use, and PRO accounts include monthly credits; free accounts need to buy credits first (see the pricing page).
Conclusion
In this topic, you have learned:
About The Hugging Face Hub and its advantages;
The Hugging Face Hub stores models and datasets and has a rich ecosystem for ML-related tasks;
How to connect your Jupyter Notebooks with The Hugging Face Hub and how to access models through Inference Providers.