Skip to main content

23 posts tagged with "Transformers"

Hugging Face Transformers, the Python Library for Pretrained Models, Pipelines, Tokenizers and Fine-Tuning

View All Tags

Fixed: "KeyError: The task question-answering has been removed from transformers"

· 7 min read
Jagdish Kumawat
Founder @ Dewiride

pipeline("question-answering") stopped with KeyError: 'The task question-answering has been removed from transformers. Use the text-generation pipeline with a chat model instead.' Transformers 5 removed that pipeline on purpose. A small chat model in a text-generation pipeline answers the same question from the same text.

How to Measure How Similar Two Sentences Are with Hugging Face Embeddings

· 6 min read
Jagdish Kumawat
Founder @ Dewiride

"A man is playing a guitar" and "Someone is making music" share only the word "is", yet they mean nearly the same thing. Comparing their embeddings, the lists of numbers a model gives each sentence, captures that: the closer the meanings, the closer the numbers. This guide scores one sentence against three others with a Hugging Face feature-extraction pipeline and cosine similarity, with Transformers 5.26.0 on Python 3.14.

How to Turn a Sentence into an Embedding with a Hugging Face Feature-Extraction Pipeline

· 6 min read
Jagdish Kumawat
Founder @ Dewiride

An embedding is a list of numbers that stands for the meaning of a piece of text: texts that mean similar things get similar numbers. That makes embeddings the base of semantic search, clustering and finding duplicates. A Hugging Face feature-extraction pipeline gives you one vector per token, and one line of PyTorch averages them into one vector for the whole sentence. This guide does it with Transformers 5.26.0 on Python 3.14.

How to Predict a Missing Word with a Hugging Face Fill-Mask Pipeline

· 5 min read
Jagdish Kumawat
Founder @ Dewiride

Models such as BERT learn language by guessing words hidden in sentences. A Hugging Face fill-mask pipeline lets you play that game with them: you hide a word behind a special mask token, and the model suggests what goes there, each with a score. This guide asks DistilBERT what someone drinks every morning, with Transformers 5.26.0 on Python 3.14.

How to Get the Score of Every Label from a Hugging Face Text Classification Pipeline

· 6 min read
Jagdish Kumawat
Founder @ Dewiride

A Hugging Face text-classification pipeline normally answers with one label: the one the model is most sure of. Often you want more, such as how close the second choice was, or a score for every label to compare or store. The top_k argument does that. This guide prints every emotion score an emotion model gives a sentence, with Transformers 5.26.0 on Python 3.14.

How to Find Names, Places and Organizations in Text with a Hugging Face NER Pipeline

· 9 min read
Jagdish Kumawat
Founder @ Dewiride

Named entity recognition, or NER, finds the names in a piece of text: people, places, organizations and other named things. A Hugging Face token-classification pipeline does it with a pretrained model, either one token at a time or grouped into whole names. This guide finds two people, a society and a city in one sentence with Transformers 5.26.0 on Python 3.14.

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

· 31 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.

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.