In this lesson
The Hub is a shop window of models.
The Hugging Face Hub is like a GitHub for AI models. Each model is a repository with files, a model card and a license. People who read the card choose with judgment. People who do not read it download the first search result.
- Read a model card before you download
- Run a Portuguese-language model with one line of code
- Protect your token and avoid dangerous files
Read the card before you download
The model card is the repository's README. At the top of it, there are four pieces of information to check.
| Field | What it says |
|---|---|
| license | What you are allowed to do. Licenses with NC are for non-commercial use |
| pipeline_tag | What the model was made for. A translator is no good for classifying emails |
| base_model | Which model it was derived from. The original's license may apply too |
| language | Whether the model has really seen Portuguese |
An empty card, or one with no license, is information too. Be suspicious.
Pipeline: one line, three steps
The Transformers library has the pipeline function. You name the task and it downloads the model and runs it. Inside, it turns the text into numbers, lets the model do the math and translates the result.
Careful with the default. The sentiment model that comes out of the box was trained on English. It classifies sentences in Portuguese with high confidence and no judgment at all. Always pass the name of a Portuguese-language model.
from transformers import pipeline
mascara = pipeline("fill-mask", model="neuralmind/bert-base-portuguese-cased")
for item in mascara("A capital do Brasil é [MASK].")[:3]:
print(item["token_str"], item["score"])
On the first run, the model is downloaded. On the second, it is read from disk, and it is much faster.
What the pros know
A model's download count is not a count of people. The Hub documentation explains that every HTTP request to the files used for counting, such as config.json, counts as one download, including GET and HEAD requests. So a server that reloads the model on every run, or an automated test system, adds to the total too. When choosing a model, treat downloads only as a hint, and put more trust in the license, the model card and a test with your own examples.
Cache: where the models live
Everything you download goes into a cache folder, usually ~/.cache/huggingface/hub. A large model takes up several gigabytes, and nothing is deleted on its own. Take a look now and then.
hf cache ls # what is stored
hf cache rm model/openai/whisper-small # deletes a model (asks for confirmation)
On a server, pin the version with the revision parameter. A model that "changed on its own" in production almost always received an update on the main branch.
Tokens and dangerous files
To download restricted models, the script uses a token, like an app password. Create a read-only one, with access to the specific repository, and keep it in an environment variable.
The old weights format, the .bin file, is a pickle: a list of instructions that Python executes when it opens the file. A malicious file can run whatever it wants on your computer. Safetensors stores only numbers, so there is nothing to execute. Always prefer it.
Careful
A token inside the code ends up in a commit and in a log. If it leaks, revoke it right away. And never use trust_remote_code=True without reading the code the repository brings, because that runs someone else's program on your computer.
Practice · 5 min
- Pick a task from your work and search the Hub with the Portuguese language filter. Set aside three models.
- For each one, write down the license, the file format and whether it requires a token or external code.
- Run all three with five examples of your own and give each answer a score from 0 to 2.
Summary
- Read the model card: license, task, base model and language.
- Always pass a Portuguese-language model to the pipeline.
- Prefer safetensors. A pickle can execute code.
- Read-only token, in an environment variable.
Sources
Read on October 30, 2026.
- Hugging Face. Models Download Stats: how downloads are counted.
- Hugging Face. Model Cards: model card fields.
- Hugging Face. Pickle scanning: risks of the pickle format.
- Hugging Face. Safetensors: the safe format.
Lesson quiz
Three situations to apply what you learned.
Isaque Victor free courses