---
title: 'What is Hugging Face? | Hugging Face Models | Transformers | Pipelines In Hugging Face | Simplilearn'
source: 'https://youtube.com/watch?v=KcfO8SHuPcU'
video_id: 'KcfO8SHuPcU'
date: 2026-06-15
duration_sec: 3050
---

# What is Hugging Face? | Hugging Face Models | Transformers | Pipelines In Hugging Face | Simplilearn

> Source: [What is Hugging Face? | Hugging Face Models | Transformers | Pipelines In Hugging Face | Simplilearn](https://youtube.com/watch?v=KcfO8SHuPcU)

## Summary

This video from Simplilearn introduces Hugging Face, a company that provides pre-trained AI models for language tasks like translation, text analysis, and generation. The presenter demonstrates three practical applications: speech-to-text, sentiment analysis, and text generation using the Transformers library and pipelines.

### Key Points

- **Introduction to Hugging Face** [00:04] — Hugging Face is a company that helps people use AI models for language tasks like translation, text analysis, and generating new text. They created the Transformers library with pre-trained models.
- **Three Cool Things with Hugging Face** [00:43] — The video covers speech-to-text, sentiment analysis, and text generation. Speech-to-text turns spoken words into written text. Sentiment analysis determines if text is positive, negative, or neutral. Text generation creates human-like text.
- **Installing Transformers** [02:49] — The Transformers library is installed via pip install transformers. It allows downloading and running thousands of pre-trained open-source AI models.
- **Using Pipeline** [03:45] — A pipeline describes the flow of data from origin to destination and defines how to transform data. It simplifies using Hugging Face models.
- **Importing Libraries for Speech-to-Text** [05:11] — Libraries imported include librosa (audio analysis), torch (PyTorch), IPython.display (interactive display), and transformers (Wav2Vec2ForCTC, Wav2Vec2Tokenizer).
- **Loading Pre-trained Model for Speech-to-Text** [09:10] — The model used is 'facebook/wav2vec2-base-960h'. The tokenizer and model are loaded using from_pretrained.
- **Loading Audio File** [10:36] — An audio file (v.m4a) is loaded using librosa.load with a sampling rate of 16000. The audio is played using IPython.display.
- **Tokenizing Audio and Getting Logits** [13:52] — Input values are obtained by tokenizing the audio with return_tensors='pt'. Logits (non-normalized predictions) are extracted from the model.
- **Decoding Transcription** [15:23] — Predicted IDs are obtained via torch.argmax on logits, then decoded using tokenizer.decode to get the transcription: 'hello and welcome this is an ai voice message'.
- **Sentiment Analysis Setup** [16:50] — Libraries imported: warnings, numpy, pandas, matplotlib, seaborn, sklearn (train_test_split, metrics), transformers (pipeline), torch.
- **Creating Sentiment Pipeline** [20:38] — A sentiment analysis pipeline is created using pipeline('sentiment-analysis'). It classifies text as positive or negative with confidence scores.
- **Testing Sentiment Analysis** [22:14] — Testing with 'this is a great movie' returns label POSITIVE with high score. 'I did not understand any of it' returns NEGATIVE.
- **Loading Twitter Dataset** [23:57] — A CSV file 'airline_tweets.csv' is loaded using pandas. The dataset contains columns: tweet_id, airline_sentiment (neutral, positive, negative), and text.
- **Filtering Neutral Sentiments** [26:59] — Rows with neutral sentiment are filtered out, leaving 11,541 rows. Sentiment is mapped: positive -> 1, negative -> 0.
- **Predicting Sentiments on Dataset** [29:22] — The classifier predicts sentiments on the text column. Predictions are converted to binary (1 for positive, 0 for negative).
- **Accuracy and Confusion Matrix** [32:10] — Accuracy is 88.99%. A confusion matrix is plotted showing true vs predicted labels for negative and positive classes.
- **ROC AUC Score** [37:46] — ROC AUC score is 0.94 (94%), indicating high accuracy and effectiveness in classifying sentiment.
- **Text Generation Setup** [39:08] — A dataset of poems (robert_frost.csv) is loaded. Content column is extracted, lines are split and cleaned.
- **Creating Text Generation Pipeline** [42:38] — A text generation pipeline is created using pipeline('text-generation'). It generates text based on a prompt.
- **Generating Text from Poem Lines** [43:37] — Using a line from a poem as prompt, text is generated with max_length=20. Example: 'Whose woods these are I think I know' generates 'I wish to go to church because I feel'.
- **Generating Multiple Sequences** [44:42] — With max_length=30 and num_return_sequences=2, two different continuations are generated from the same prompt.
- **Custom Prompt Generation** [47:42] — A custom prompt 'Transformers have a wide variety of applications in NLP' is used to generate text with max_length=100.

### Conclusion

Hugging Face simplifies AI model usage with pre-trained models and pipelines. The video demonstrates speech-to-text, sentiment analysis, and text generation, showing how to implement these tasks with minimal code.

## Transcript

Hello everyone, I am Mang and welcome to
our YouTube channel. Today we are
exploring hugging face, an amazing tool
that makes working with language and AI
super easy. If you're curious about
using advanced technology to understand
or create text, this video is perfect
for you. Hugging is a company that helps
people use AI models for language tasks
like translation, text analysis or even
generating new text. They have created a
library called transformer which comes
with pre-trained models. So you don't
have to build everything from scratch.
It's simple, powerful, and perfect for
developers, researchers, or even
beginner. So in this video, I will show
you three cool things you can do with
hugging face. Speech to text. Turn
spoken words into written text easily.
Great for captions or voice apps. Second
one is sentiment analysis. Find out if a
text is positive, negative, or neutral.
helpful for understanding reviews or
comments. The third one is text
generation. Create humanlike text that
sounds natural, perfect for chat bots or
creative writing. I will also explain
some important basics like how pipelines
make using hugging face model super easy
and how tokenization helps AI understand
text. By end of this video, you will
know how to use hugging phase to start
building your own projects. It's simple,
fun, and really powerful. Before we move
forward, unlock the future of AI with
comprehensive program in collaboration
with ENICT Academy, IIT Goharti. In just
a few months, you will master cutting
edge skills in generative AI, large
language models and machine learning
from learning tools like charge and DLE2
to gaining hands-on experience with
Python and TensorFlow. This course will
equip you to lead AI projects and
qualify for top roles like machine
learning engineer or data scientist.
plus with an IIT certificate on your
resume. You will stand out to the best
employers in tech. So don't forget to
check out the coursing from the
description box below and the pin
comment. So without any further ado,
let's get started. So welcome to this
demo part of this video. So here as you
know we will be doing three things.
First thing speech to text recognition.
The second thing text generation from a
particular sentence or a word. And the
third thing we will do sentiment
analysis. Okay. So we will perform this
one by one. So let's start with
something called speech to text
recognition. Okay. Using hugging face.
So first I will write rename
this. I will write here hugging
face speech to
text. Okay. Yeah. So first I will
install transformers
library. It is already installed on my
system but again just for you as I'm
doing this okay pip install transformer.
So now let's see what is transformers.
So transformers is a powerful Python
library created by hugging face. So that
allows you to download, manipulate and
run thousands of pre-trained open-source
AI model. Fine. So as you can see
requirement already satisfied. It means
like already installed. So these
transformer models cover multiple tasks
across you know modities like NLP,
natural language processing, computer
vision, audio and multimodal learning
like many things. Fine. So now I will do
from
transformers
import
pipeline. Okay. So now let's run it. So
now what is
pipeline? Okay. So a transformer
pipeline describes the flow of data from
origin system to destination system.
Fine. because you already know
transformer means you can run or
manipulate thousands of pre-trained
opensource AI model. So pipeline
describes the flow of data from origin
system to destination system and defines
how to transform you the data along the
way. Okay. So let's check
the
versions
transform
mer
version. Okay that long
tab. Okay. Why it is
coming? Import
transformers. Yeah. So we have currently
4.42.4 version of the transformer. Okay.
So I'm using Google Collab. Okay. So you
can use either Jupyter notebook, Visual
Code Studio or
Collab. Okay. So now let's import
libraries. import
librosa. Okay. So what is librosa? So
librosa is a python package for audio
and music analysis. Right? Because we
are doing speech to text. So we need
this. So it provides various functions
to quickly extract key audio features
and metrics from the audio
files. Okay. And this librosa can also
be used to analyze and manipulate audio
files in a variety of formats such as
wav, mp3, m4a and like that. Okay. So
next we will import
torch. I hope everyone know
torch. So torch is nothing pytorch. It
is a machine learning library based on
the torch library used for applications
such as computer vision and NLP and
originally it was developed by the meta
and now the part of Linux foundation you
know umbrella let's import one more
thing
import so now let's
import
IPython
Okay capital
ipython dot
display as
display. So now you will be wondering
what is this IPython
display. Okay. So it is an interactive
command line uh for the terminal for
Python and it uh you know it can provide
a IPython terminal and the web-based
notebook platform for Python
computing and this uh IPython have you
know more advanced features than the
Python standard interpreter and we
quickly execute a single line of Python
code nothing okay for that I'm using
this and the Next is from
transformers
import
wav
to
vectorzer for
CTC and
WAV
to vectorizer to tokenizer.
Okay. So now what is
this so WA2 vectorizer for CTC is
supported by the notebook on how to
fine-tune a speech recognition
model. Okay. And this tokenizer so
tokenizer is nothing tokenization is a
conversion of a text into meaningful
lexical tokens belonging to categories
defined lexa program. in case of NLP. So
those categories include nouns, verbs,
adjective, punctuation, ATC. Okay. Now,
and the last library, let's import
numpy, s np. I hope everyone know numpy.
What is numpy? Again, numpy is a python
library used for working with arrays. It
al it also has a function you know for
working in domain like linear algebra
fer transform and matrices and many
others. Fine. I hope everyone know about
these library which we have
imported. Okay. So let's move forward by
tokenizer
to
[Music]
tokenizer dot
from
pre-trained. This is why I love this
Google collab. view the site just some
words and it will show the
suggestions you know
Facebook so this is again one pre uh
trained model okay so we are just
importing
it
base
960th this is nothing the name okay then
model equals
to wav2
to for
CTC dot
from
retrained then
Facebook
WV2
vectorizer
2 then
base
960
Fine. Now let's run
it. So now you can see. So we are
loading this. Okay, they they're
downloading. Okay. So you can ignore
these warning. So now let's load the
audio file. So here I will write
audio
sampling
rate equals to
librosa
dot
load. Okay. So you know about libroser
right? Then I have v
dot m4 a. So we I have already one
speech or one audio you can say.
So I will play it. Don't worry. Before
the final output I will you
know show you 15,000.
Okay. So now I will write
Okay. Okay. I've already loaded I
guess.
Okay. Okay. No issues. I will load
again. Okay. The file is
loaded. I will rename it to
V. Yeah. Fine. So now it won't there
won't come.
Again we have v.mpp4
in.
Okay. So
now what we have to
do?
Okay. Let me try
it. We have
v.mpp4 but I don't know why it is not
coming.
Okay, let me copy the path. And now it
will run I
guess it's running.
Yeah. So now I will write here
audio comma
sampling
rate. Okay. Now listen carefully. Then I
will write
display display dot
audio
then
path
comma auto
play to true. Okay.
Hello and welcome. This is an AI voice
message.
I guess you heard but again let me play
play it again. Hello and welcome. This
is an AI voice message.
Okay. So it is saying hello and welcome.
This is an AI voice message. Fine. So
now what I will do? I will input some
values.
Input values equals
tokenizer then
audio comma
return
tensors equals to
pt fine
dot
input values.
Okay. Then here
input
values. Okay. Input
values.
Okay. Yeah. So now logits will come
here. So we have to now store the logits
which means non-normalized predictions.
Okay. So logits equals
to
model
input
values dot
logits.
Okay. Then here I'll write
logits. Okay. It's running. Done. So now
what we will do? We will store predicted
ids. Then we will pass the logits to
values to softmax to get the predictive
value. Okay. So here I will write
predicted
ids equals
torch dot arg
max. Okay. Then
logit dimension equals to minus one.
Okay. Then I will pass the you know
prediction uh to the tokenizer decode to
the
transcription. Okay. So here I will
write
transcriptions equals
to
tokenizer
tokenizer dot
decode predicted
ids
zero running fine. So now let's see our
output
transcriptions. So now you can see hello
and welcome. This is an AI voice voice
message. So now let's play it again.
Hello and welcome. This is an AI voice
message.
Amazing right? So this is how you can
use hugging face for this piece to text
recognition. It's a very small code line
of code as you can see. Okay. So now
let's move forward and do the sentiment
analysis. Okay. Or text
generation. So let me open new
drive. So
yeah. So now I will write
here. I will write sentiment
slash
text
[Music]
generation hugging
face.
Okay. So first of all let's import the
files. So first I'll write
import
warnings then
warnings dot filter
warnings okay I will write here
ignore then we'll
import
numpy you already know what is numpy and
import panda so these are some basic
basic uh Python library and I hope
everyone knows and import Matt plot lib
for the
plots mattplot lib
dot
piplot as
plt then I will import cbond for the
graphs the statics graph okay SNS then
SNS dot
set. So now we'll import skarn model
train
split. So skarn is nothing scikitlearn
is a probably the most useful library
for machine learning python. So, so this
uh library contains a lot of efficient
tools for machine learning and you know
statical modeling including
classification you can do regression you
can do clustering you can do from this
escal okay
from
skarn dot
model
[Music]
selection
import train test
split from
skarn
dot
matrix
import f1
Comma confusion
matrix comma ro
Aore. So again we will import gyms from
transformers
import pipeline. Everyone know what is
this? Then
import
torch. Okay. Now let's run
it. You have too many active session.
Tell me existing to continue. If you're
interesting using one more
session. Okay. Wait. Yeah. Fine.
Now which one is open,
bro? Terminate this.
Terminate this. Terminate
this. Okay. Fine. So now let's do
sentiment
analysis. So uh we will explore
sentiment analysis using a pre-trained
transform model. Okay. The hugging face
library provides you know convenient
pipeline as you already know function
that allows us to easily perform
sentiment on the text. So now let's
first import the necessary dependencies.
and create a sentiments pipeline using
this line. So I will write here
classifier equals
to
pipeline
sentiment
analysis then
type classifier.
Okay. So, it will download the
pre-trained sentiment analysis pipeline.
Pipeline is not
defined.
How?
Okay. Okay. Error is
there. I hope it will run now. Yeah. So
now we can uh pass a single sentence or
a list of sentence to the classifier and
now and get the predictive sentiment
labels and
associate confidence score. Fine. So
now just for the
testing classifier. So, let's write
this is a
great
movie. Okay, now let me run it. So now
you can see here label positive. So
label positive typically refers to the
outcome or a class of interest that the
model is designed to predict. So here we
are just checking the sentiment analysis
model. Okay. So this is why I wrote
this. Okay. So let's check one
more.
This was
a
great
course.
Then
I did
not
understood any of
it. Now let's check
this. Yeah, perfect. And the score you
can see the accuracy score 99%. 99%
which is almost close to 100%. And which
is amazing. So now you have access to a
GPU. So you can also utilize this for
the faster processing by specifying the
device using the parameter. Okay. So
now what I will
do first I
will okay wait. Yeah fine. So now I will
import data
set a line
tweets equals to pd dot read. PD means
pandas library here we are using. Okay.
Now first import will import here
itself. So I have twitter dot tweets dot
csv.
Okay.
Tweets dot
CSV. Let it
upload. Yeah. Done. So now let
me
airline tweets.
Y dot head means you it will show me the
top five
rows. Okay. 0 1 2 3 4 5. Okay. You can
see tweet ID a line sentiment neutral
positive neutral negative. Then this is
this. Okay. So
now let's do something. Okay. So what I
will do df equal df means data frame a
[Music]
line to
it then I will write a
line
sentiment we have airline sentiment this
column
okay text I need these two
columns again df do
had
five. So yeah, air a cime neutral and
this is what this text is all about.
Okay, because these two are the main
things text and the sentiment. So now
let's make
plot count
plot then I will write df
comma x =
to a line
sentiment then
pallet equals
to
is then here I will write plt dotx
label a line
sentiment okay
then plt dot
label
count plt dot show
So it
will draw one
graph.
Okay. Okay. Spelling is
wrong. Yeah. So it will show neutral
positive sentiment and the negative. So
as you can see the negative sentences or
the sentiments are the
more. Okay. So now so we have now three
classes which do not match the two class
available in the hugging face pipeline.
So therefore we will filter out all the
rows which have been labeled as neutral.
Okay. So,
DF equals to
DF and again
DF airline
sentiment.
Fine was not equals
to
neutral. Okay. Then
DF
target equals to
DF
airline
sentiment dot
uh
map then I will write here
positive positive 1 and the negative
0
find negative will
be
zero. Okay. Then
print number of
rows comma df
dot shape.
Okay. So now you can see number of rows
are
11,541. Okay. So now I will write
predictions
five it will
okay predictions is not defined.
Okay. So now what I will
do. So here I will write
text= to
TF text
text and to
list dot to
list then here I will add
predictions equals
to
classifier text.
Okay. So here write
probabilities equals
to
predictions
then
score. If
predictions
label
dot
starts
with starts with P means
positive. Okay.
else 1
minus prediction
score
prediction
score
okay then I will write
for
prediction and
prediction why it is not
running this is taking time too much
time I don't know
why So as you can see finally we have
the output predictions values. So this
depends on you know system to system. My
system took almost 17 minutes 47 seconds
to complete. Okay. So now let's run
it. Okay. Predictions is now defined
row. Now
predictions. Yeah. So now I will write
here predictions equals to
np dot array. np means numpy numpy dot
array then I will write one if
prediction label is
positive
dot
starts
with p. Okay.
else
zero
for prediction and prediction
values.
Yep. Okay. Fine. So now let's check the
accuracy of our model.
Branch
accuracy.
Okay, then I will do round
up the values. So here I will write np
dot
mean then
df then the
target
right.
Yeah. Then I will write equals equals to
predictions. Then I will write into
100
comma two. Then I will write
percentage.
Okay. Fine. Looks good. Yes.
So as you can see our accuracy is
88.99% which is you know very good
again. So now let's do some confusion
matrix
confusion
matrix then
df
target predictions comma
normalize equals
to
true. Okay.
Then I will
plot confusion
matrix. Okay.
DF
then
target predictions command
normalize equals
to
true. Okay. Okay. My bad. My bad. My
bad.
that
confusion
[Music]
matrix
comma
labels. Okay. So here uh I will you
know plot a confusion matrix using
cbond. Okay. So here I will use args
which is confusion matrix np array. So
which is you know labels list. So I will
write plt dot
figure then figure
size equals to 8 comma
6 that's sn
dot
set font
scale equals to
1.4. Okay. Then let's create the heat
map diffusion
matrix comma and not will be
true. Okay. Then I will write
fmp equals to
g then confusion
map equals to
[Music]
blues. Then X ticks
labels equals to
labels. Then
Y labels equals
to
labels.
Okay. Yes. So now I'll write plt
dot title will
be confusion
matrix then plt dox label will
be predicted values then plt doy label
will
be actual values then plt dot
show.
Okay. Why the chart is not
coming? Okay. So I have to write
plot confusion matrix then write
cm
then
negative
comma
positive. Okay. Now the chart will come.
Okay. Yeah. So now you can see here this
is you know actual and this is a
confusion matrix and the negative and
the positive ratio is there. Okay. So
now let's print
the let's check the ROC score. So I will
write here
print
ro A
score then here I will write C A
score then
TF
target
props.
Okay. So 94. Okay. So first let me tell
you what is this ROC AC score. So this
is the area under the ROC curve. So what
it does it sum up how well a model can
produce relative scores to discriminate
between positive and the negative
instance across all the classification
threshold. So with this ROC score of
940.94 which is 94% we can conclude that
the that a pre-trained sentiment
analysis model has achieved the high
level of accuracy and
effectiveness. So in predicting the
sentiment labels so this indicates that
the model is capable of accurately
classifying text into positive or the
negative sentiment categories. Okay. So
now we'll do text generation. Okay. So
text generation involves generating
creative and coherent text based thing.
So I will write here
text.
Okay. So text generation involves
generating creative and coherent text
based on a given prompt or starting
point. So what we will do first? We will
import the necessary dependencies and
load the data data set of the poem.
Okay. So here I am write poems. Let me
write poems equals to pd dot read dot
csv. Don't worry I will give you these
files.
Okay description box below I will
add. So here I will write
robot
frost with dot
csc. Fine. And then I will write
poems dot
head
five or head just have to write it
module pandas
has okay not
doc
csv
yeah okay it will show the top five
stopping by woods on a snowy evening
fire and ice the aim was
song collection content, year of
publish.
Okay. So now what we will do? We will
write
content equals to
poems
content dot
drop na to to
list. Okay. So to generate text we
extract individual lines from the poems
and use the pipeline text generation
function to create a text generation
pipeline. Fine. So here I will write
lines equals to then I will write
for poem and
content. Okay. For
line and poem
dot
split into the next
line.
Okay. Then lines dot
append. Then I will add
line dot write
strip to the right. It will add. Okay.
Fine. So now lines equals
to line for
line in lines.
If
length of
[Music]
line
zero then show me the
lines
five okay so now you have seen here
whose words these are I think I know
then the next line his house is in the
village though the next line he will not
sing okay like this so now Let's
uh you know import that pipeline text
generation module. Okay. Gen equals
to
[Music]
pipeline. So these are the some
pre-trained model you already
know
generation. Okay. So now I will write
here
lines. Let's run
it. Yeah. Done. So in line zero you have
we have whose votes these are. I think I
know. Okay. So now we can now generate
tags by providing a prompt and
specifying the parameters such as max
length and num return sequence. Okay.
Why? Because we have imported this text
generation module. Okay. For example,
see
[Music]
gen. Okay,
sorry.
Lines
zero dot max
length max length equals to 20. So now
it will generate the this to the maximum
20. Okay. till 20 word maximum length.
Okay.
Check. Okay.
Uh okay. Chance expression cannot
contain perhaps double is equals
to where
okay now it will run. So see the line
was this much only whose words these
are. I think I know. Whose words these
are? I think I know. But here the
generated text I wish to go to church
because I feel
like okay this is how you can do you
know text generation. Now let's check
for the more
gen lines
1. Okay. Then
max length equals to
30,
[Music]
num return sequence
says
sequences equals to
two. Okay. So our first line was this.
His house is in the village though.
Okay. 0 1 2 3 4 5. Okay. So here you can
see see his house in the village though.
However you might say that the place was
the same with the place this this this.
So these are the generated text. Okay.
And this is another you know return
sequence second. So there are two one
and the second. Okay. So
now let me you know
import text.
Okay,
then creating function wrap x. I don't
need
this. Then
return text
wrap dot
fill x comma
replace white
space wide space equals to
false comma uh
fix
sentence endings equals to
true. Okay. So now
out equals to generated
lines
zero to maximum
length equals to 30.
Then
print wrap
out to zero.
[Music]
Then
generated
text. Okay. So now we are setting uh the
pad tokens to EOS tokens. Okay. So whose
h these are I think I know. And this is
a maximum 30 till 30.
Okay. So now I will write
here okay preview equals to okay. So now
what you can do you
can you know generate a prompt to
generate text on a specific topic like
this prompt equals
to
transformers have a wide
variety of
applications application in NLB
Okay. So this is my prompt. Okay. This
I'm not importing from the data set.
Okay. So I will write out equals to
gen prompt comma max
length equals to 100.
print
wrap out.
Okay, here I will write anyways here I
will write
generated
text
prompt. Okay, so it is
running. Let's wait.
Yeah.
So, okay. Somewhere is
there. Okay. So, here the issue is with
100 words I go with. We'll go till
50. Yeah. So let me do it again.
100. Yeah. So now you can see we have we
can generate text using by giving a
prompt. So we have covered you know
three topics in this. First thing is
piece to text using hugging face. Second
thing is sentiment analysis using
hugging face. And the third is text
generation using hugging face. Okay. And
in this text generation we have we did
with two methods. One with the data set
and second thing with the you know by
giving prompt like in charge you can
say. So with this we have come to end of
this video. If you have any question or
doubt please feel free to ask in the
comment section below and our team of
experts will help you as soon as
possible. So thank you and keep learning
with simply learn.
[Music]
Hi there. If you like this video,
subscribe to the SimplyLearn YouTube
channel and click here to watch similar
videos. To nerd up and get certified,
click here.
