Skip to main content

How to Find a Model for a Task on the Hugging Face Hub

· 10 min read
Jagdish Kumawat
Founder @ Dewiride

The Hugging Face Hub holds a huge number of free, pretrained models, so the hard part is often choosing one. The Models page can narrow them down by task, by name and by license, and each model's page tells you how big it is, how well it did and what it learned from. This guide finds a model that tells which emotion a sentence expresses.

The Example​

The task: label short English texts with an emotion, such as joy, anger or fear. Choosing one label out of a fixed list is called text classification. The model should also allow commercial use, so the search keeps only models under the Apache 2.0 license. You don't need an account for any of this.

Step 1: Choose the Task​

Open huggingface.co/models. On the left are filters in tabs: Main, Tasks, Libraries, Languages, Licenses and Other. Click Tasks, and under Natural Language Processing, click Text Classification:

The Natural Language Processing group of the Tasks filter on the Hugging Face Models page, with Text Classification selected and highlighted, next to Token Classification, Table Question Answering, Question Answering, Zero-Shot Classification, Translation, Summarization, Feature Extraction, Text Generation, Fill-Mask, Sentence Similarity and Text Ranking.

Models on the Hub are tagged with the task they were trained for, and this filter keeps only the ones tagged for text classification. The other names in the list are tasks too, such as Token Classification, which finds names and places in a sentence.

Step 2: Filter by Name​

Above the list is a box called Filter by name. Type emotion:

The top of the Models list after typing emotion in the Filter by name box: Models 5,510, sorted by Trending, with the first four results MORES-horizon/MORES_emotions9, Mapzoll/indoroberta-emotion-6class-id, sahil281203/priyu-emotion-e5-small and benji-666/emotions_service_public, each with only a handful of downloads.

The box matches the word in the model's name, which is how most authors describe what a model does. 5,510 text-classification models matched. The list is sorted by Trending, which puts models that are getting attention right now on top: here, new models with a few dozen downloads.

Step 3: Sort by Downloads​

Click Sort: Trending to see the other orders:

The Sort menu of the Models page, open, with seven choices: Trending, Most likes, Most downloads, Recently created, Recently updated, Most parameters and Least parameters.

Choose Most downloads. A model that many people download has been tried by many people, so problems with it are more likely to have been noticed:

The emotion models sorted by Most downloads: j-hartmann/emotion-english-distilroberta-base with 353k downloads and 507 likes, jitesh/emotion-english with 207k, thoriqfy/indobert-emotion-classification with 168k and SamLowe/roberta-base-go_emotions with 166k downloads and 704 likes.

Each card shows the task, the size where the Hub knows it (82.1M is 82.1 million parameters, the numbers a model learns), when it was last updated, its downloads and its likes. The top result has 353 thousand downloads. Before you take it, check its license.

Step 4: Keep Only the Licenses You Can Use​

Click the Licenses tab in the filters and choose apache-2.0:

The Licenses tab of the Models page filters, with a Filter Licenses by name box, a Reset Licenses button, and the license chips apache-2.0, selected, then mit, other and openrail.

The list now holds 3,208 models:

The emotion models with the apache-2.0 license, sorted by Most downloads: Models 3,208, with AdamCodd/tinybert-emotion-balanced at 72.1k downloads, bhadresh-savani/distilbert-base-uncased-emotion at 67M parameters, 47.5k downloads and 164 likes, bhadresh-savani/albert-base-v2-emotion at 27.5k and nateraw/bert-base-uncased-emotion at 14.9k.

The most downloaded model from Step 3 is gone. Its card has no license in its metadata, so the license filter can't include it, and without a license you can't tell what you're allowed to do with it. The license guide shows how to read and check a license.

All the filters are in the page's address, so you can save or share the search:

The search as a link
https://huggingface.co/models?pipeline_tag=text-classification&license=license:apache-2.0&sort=downloads&search=emotion

Step 5: Check the Model's Page​

Click a model that fits. Here it's bhadresh-savani/distilbert-base-uncased-emotion, the most liked of these four. Its page starts with the model's name and its tags:

The top of the bhadresh-savani/distilbert-base-uncased-emotion model page: 164 likes, then tags for Text Classification, Transformers, PyTorch, TensorFlow, JAX, Safetensors, the emotion dataset, English, a DOI, distilbert, emotion, Eval Results (legacy), arxiv:1910.01108 and License: apache-2.0.

The tags answer the first questions: the task (Text Classification), the libraries it works with (Transformers and PyTorch among them), its language (English) and its license (apache-2.0). Safetensors means its weights are stored in the safe file format that loads without running any code.

On the right of the page are its downloads and its size:

The side panel of the model page: Downloads last month 47,465 with a chart of recent downloads, and Safetensors details: Model size 67M params and Tensor type F32.

67 million parameters stored as 32-bit numbers (F32) is about 268 MB to download, small enough for any laptop.

Below the tags is the model card, the author's description. Look for results, a table or numbers that say how well the model did on test data. This one has a table:

A table from the model card titled Model Performance Comparision on Emotion Dataset from Twitter: Distilbert-base-uncased-emotion with accuracy 93.8, F1 score 93.79 and 398.69 test samples per second, then Bert-base-uncased-emotion at 94.05, Roberta-base-emotion at 93.95 and Albert-base-v2-emotion at 93.6.

It got 93.8% of the test messages right, close to the other three models in the table, and it handled about twice as many messages per second as each of them. Treat the author's numbers as a starting point: what counts is how it does on your own texts.

Last, the right side also names the data the model learned from:

The Dataset used to train box on the model page: the dataset dair-ai/emotion, with a Viewer link, updated Aug 8, 2024, 437k rows, 34.3k downloads and 530 likes.

Open the dataset too. It tells you what kind of text the model knows, here English tweets, and the dataset has its own terms: the dair-ai/emotion card says "The dataset should be used for educational and research purposes only." If you're building a product, weigh that along with the model's own license.

Step 6: Use the Model​

The model's name, bhadresh-savani/distilbert-base-uncased-emotion, is all a pipeline needs. Pin it to a commit so it can't change under you, as the revision guide shows, and run it on your own texts: the every-label guide runs this model and prints its score for each of the six emotions.

What to Check Before You Choose​

CheckWhereWhy
TaskThe first tagA model only does the task it was trained for
LicenseThe License: tagIt says whether you may use the model in a product
LanguageThe language tagA model trained on English text does poorly on other languages
SizeModel size on the rightBigger models are slower and need more memory
ResultsThe model cardThey show how well it did on test data
Training dataDataset used to trainIt shows what texts the model knows, and the data has its own terms
Downloads and likesThe list and the pageWidely used models are more likely to work as described

Common Mistakes​

MistakeWhat happensDo this instead
Taking the first resultThe default Trending order favours new models, often with few downloadsSort by Most downloads or Most likes
Choosing by name aloneA name such as emotion-english doesn't say which emotions, what data or what licenseOpen the model's page and check the tags and the card
Skipping the licenseSome models have no license or forbid commercial useFilter by license, then read the license itself
Trusting the card's numbers for your dataThey were measured on the author's test dataTry the model on examples of your own texts

FAQ​

Do I need an account to search the Hub?​

No. Searching and reading model pages is open to everyone. You need an account for gated and private models, and to upload your own.

Why are there thousands of emotion models?​

Anyone can upload a model, and many people fine-tune a base model on an emotion dataset for practice or for their own project. The filters exist to cut that list down.

Can I search from Python or the terminal instead?​

Yes. hf models ls takes a search text (--search), a task (--pipeline-tag) and an order (--sort downloads), and the huggingface_hub library can search from Python, which is handy in scripts. The page is easier for comparing models by eye.

Conclusion​

The Text Classification task, the name emotion, the Most downloads order and the apache-2.0 license turned 5,510 matches into a short list of well-used models you may build on. The model page of bhadresh-savani/distilbert-base-uncased-emotion then showed its size (67M parameters), its results (93.8% accuracy) and its training data, including that data's own terms.

Additional Resources​