Skip to main content

14 posts tagged with "Hugging Face"

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

View All Tags

Hugging Face Transformers Tutorial for NLP in Python — Part 1: Install Transformers and Run Your First Pipeline

· 30 min read
Jagdish Kumawat
Founder @ Dewiride

Hugging Face Transformers gives you thousands of pretrained language models and a few lines of Python to use them. In this first part you install Transformers and PyTorch, run your first pipeline on your computer's GPU, and build the first version of a project the whole series grows: a router that reads a customer's support message and decides what it's about.

Fixed: AttributeError: 'code' object has no attribute 'co_lnotab'

· 8 min read
Jagdish Kumawat
Founder @ Dewiride

On Python 3.15, Dataset.map(..., num_proc=2) from Hugging Face's datasets library failed with AttributeError: 'code' object has no attribute 'co_lnotab'. The error comes from dill, which datasets uses to send your function to its worker processes: Python 3.15 removed co_lnotab, and the dill version datasets allows still reads it. Moving the project to Python 3.14 fixed it.

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.