This post was originally published on Medium.
Member-only story
Hugging Face Pipelines
Nov 21, 2023
Are you searching for a quick way to use machine learning models, all in just a few lines of code? Are you interested in utilizing machine learning models without requiring an extensive understanding of the intricacies of machine learning?
I have always been interested in artificial intelligence and have always wanted to learn how it works and develop my own AI applications. But considering the fact that AI is a very technical field it can be very difficult sometimes to know where to start.
I have been on Hugging Face for some time now but a few weeks back I came across their learning hub, started learning from there, and discovered their pipeline function and since then it has proved to be by far the easiest way to use ML models, IMHO.
Hugging Face pipelines provide a convenient and straightforward method for utilizing models in inference. So these pipelines allow you to use models that are hosted on Hugging Face without you knowing the intricacies of how the model works. These pipelines provide APIs for tasks such as Sentiment Analysis, Text Generation, and Named Entity Recognition. Too much of me talking, let’s get our hands dirty.
from transformers import pipeline
classifier = pipeline("sentiment-analysis")
classifier("I feel not so good today")
[{'label': 'NEGATIVE', 'score': 0.999760091304779}]


