Skip to main content

31 posts tagged with "Hugging Face"

Hugging Face, Its Hub of Models and Datasets, and the hf Command-Line Tool and Cache

View All Tags

How to Choose the Device a Hugging Face Pipeline Runs On

· 5 min read
Jagdish Kumawat
Founder @ Dewiride

A Hugging Face pipeline can run its model on the main processor (CPU) or on a graphics processor (GPU), which is usually much faster. Transformers 5 picks the GPU for you when there is one, and the device argument overrides it. This guide shows what the pipeline picks on an Apple M1 Pro, how to force the CPU, and which setting fails on a Mac.

Fixed: "No model was supplied, defaulted to distilbert/distilbert-base-uncased-finetuned-sst-2-english"

· 6 min read
Jagdish Kumawat
Founder @ Dewiride

A Hugging Face sentiment-analysis pipeline worked, but first printed No model was supplied, defaulted to distilbert/distilbert-base-uncased-finetuned-sst-2-english and revision 714eb0f. and Using a pipeline without specifying a model name and revision in production is not recommended. Naming the model and its revision in the code makes the warning go away, and makes the code safe to run in production.

How to Classify Text into Your Own Labels with Zero-Shot Classification

· 8 min read
Jagdish Kumawat
Founder @ Dewiride

Zero-shot classification sorts text into labels you choose when you call it, such as "sports", "politics" and "technology", without training a model on them first. It works by asking a model trained for natural language inference whether each label fits the text. This guide classifies headlines with Hugging Face Transformers 5.24.1 and facebook/bart-large-mnli, and shows how the two main options change the scores.

How to Use Hugging Face Models Offline with HF_HUB_OFFLINE

· 5 min read
Jagdish Kumawat
Founder @ Dewiride

Even when a model is already downloaded, Hugging Face libraries normally contact the Hub to check for a newer version. On a plane, behind a strict firewall or on a server with no internet, that check fails or waits. Setting HF_HUB_OFFLINE=1 tells them to use only what's in the cache. This guide shows both sides with huggingface_hub 2.5.0: a cached file loads, a missing one fails.

How to Check a Model's License on the Hugging Face Hub

· 5 min read
Jagdish Kumawat
Founder @ Dewiride

Every model on the Hugging Face Hub comes with a license that says what you may do with it. Some allow almost anything, including selling a product built on them; others forbid commercial use or add conditions. Check it before you build on a model. This guide finds the license of google-bert/bert-base-uncased on its page and from the terminal.

How to Change Where Hugging Face Stores Downloaded Models with HF_HOME

· 6 min read
Jagdish Kumawat
Founder @ Dewiride

By default, Hugging Face keeps downloaded models in ~/.cache/huggingface, on your main drive. Models can take many gigabytes, so you may want them on a bigger drive or inside a project. The HF_HOME environment variable moves that whole folder. This guide sets it in bash and PowerShell with huggingface_hub 2.5.0 and checks the result.