---
title: 'Hugging Face Crash Course | Learn Hugging Face in 1 hour | Amit Thinks | 2025'
source: 'https://youtube.com/watch?v=b665B04CWkI'
video_id: 'b665B04CWkI'
date: 2026-07-28
duration_sec: 4175
---

# Hugging Face Crash Course | Learn Hugging Face in 1 hour | Amit Thinks | 2025

> Source: [Hugging Face Crash Course | Learn Hugging Face in 1 hour | Amit Thinks | 2025](https://youtube.com/watch?v=b665B04CWkI)

## Summary

This course provides a comprehensive overview of Hugging Face, a company and open-source community focused on NLP and AI. It covers key libraries like Transformers, Datasets, and Tokenizers, along with practical implementations of various NLP tasks including sentiment analysis, text classification, summarization, translation, question answering, and text-to-image/video generation.

### Key Points

- **Introduction to Hugging Face** [0:00] — Hugging Face is a company and open-source community focusing on NLP and AI, best known for its Transformers library providing pre-trained models for tasks like text classification, sentiment analysis, and machine translation.
- **Key Libraries and Features** [1:36] — Main libraries include Transformers (pre-trained models like BERT), Datasets (for accessing datasets), and Tokenizers (for tokenization). Features include Model Hub, Spaces for demos, and a strong community.
- **Popular Models** [2:39] — Popular models include BERT (bidirectional context understanding), GPT (generative pre-trained transformer), and RoBERTa (robustly optimized BERT approach with dynamic masking).
- **Use Cases of Hugging Face** [4:10] — Use cases include conversational AI (chatbots), sentiment analysis, text generation, text summarization, named entity recognition, machine translation, question answering, speech recognition, recommendation systems, fraud detection, and multimodal applications.
- **Transformers Library Installation** [11:15] — Install using pip: `pip install transformers`. On Google Colab, use `!pip install transformers`. Also installable from GitHub.
- **Datasets Library** [15:33] — Provides easy access to over 350K datasets for NLP and ML. Install via `pip install datasets`. Features lazy loading, unified API, and integration with Transformers.
- **Tokenizers Library** [20:39] — Fast and efficient tokenization library. Install via `pip install tokenizers`. Supports custom tokenizers and multiple algorithms.
- **Hugging Face Access Token** [25:23] — Access token (API key) is needed for private/gated models, inference API, and uploading to Hub. Not needed for public models. Create via huggingface.co/settings/tokens.
- **Downloading a Dataset** [30:51] — Use `load_dataset` from Datasets library. Example: `load_dataset('imdb')` downloads the IMDB dataset for sentiment analysis.
- **Downloading a Model** [34:02] — Use `from_pretrained` from Transformers. Example: `AutoModel.from_pretrained('bert-base-uncased')` downloads BERT model.
- **Sentiment Analysis Implementation** [36:38] — Use pipeline('sentiment-analysis') to analyze text. Example: `sentiment_pipeline(['I love cricket', 'I hate missing a century'])` returns labels and confidence scores.
- **Text Classification (Spam Detection)** [43:09] — Use pipeline('text-classification', model='model_name') for spam detection. Example classifies texts as spam or not spam with confidence scores.
- **Text Summarization** [48:52] — Use AutoModelForSeq2SeqLM and AutoTokenizer with a summarization model like 'facebook/bart-large-cnn'. Generate summary with parameters like max_length, min_length, length_penalty, num_beams.
- **Translation (Text-to-Text Generation)** [52:43] — Use T5 model with task prefix 'translate English to Spanish'. Example: `model.generate(input_ids)` translates text.
- **Question Answering** [56:27] — Use pipeline('question-answering') or AutoModelForQuestionAnswering with a context and question. Example extracts answer from given context.
- **Text-to-Image Generation** [59:00] — Use Stable Diffusion pipeline from Diffusers library. Example: `pipe('Flying cars over futuristic cityscape')` generates and saves an image.
- **Text-to-Video Generation** [63:08] — Use Stable Diffusion to generate frames from text prompts, then stitch frames into video using OpenCV. Example generates 10 frames of a futuristic cityscape.

### Conclusion

Hugging Face provides a comprehensive ecosystem for NLP and AI, with easy-to-use libraries and pre-trained models for a wide range of tasks. This course covers installation, key concepts, and practical implementations of sentiment analysis, text classification, summarization, translation, question answering, and generative tasks.

## Transcript

In this video course learn Hugging Face and 
its concepts Hugging Face is a company and  
open-source community that focuses on Natural 
Language Processing and Artificial Intelligence  
It is best known for its transformers library 
which provides tools and pre-trained models for a  
wide range of NLP task such as text classification 
sentiment analysis machine translation and more In  
this course we have covered the following lessons 
with live running examples Let us start with the  
first lesson In this lesson we will learn what is 
hugging face With that we will also understand the  
features Let us start Hugging face is a widely 
known company and open-source community that  
focuses on NLP that is natural language processing 
It also focuses on artificial intelligence  
Hugging face is best known for its transformers 
library that provides tools and pre-trained models  
so that wide range of NLP tasks such as sentiment 
analysis machine translation text summarization  
can be performed The most widely used hugging face 
libraries are transformers datasets and tokenizers  
Let us see the features It includes lots 
of libraries One of the key library is  
transformers that includes pre-trained 
models such as BERT Hugging face also  
includes model hub that is a platform 
where users can share and download  
pre-trained models With that users can 
also download data sets and other resources  
Hugging face also includes a library for a variety 
of data sets The library is called datasets  
library and is used for NLP task Hugging face is 
also having a platform for hosting and sharing  
machine learning demos and applications which is 
called spaces With that using hugging face you  
can easily deploy and use models in production 
environments Hugging face is having a strong  
community and collaboration that is a community 
of developers AI lovers that contribute to the
ecosystem Let us see some of the popular models 
on hugging face The widely used BERT It is used  
for understanding the context of words in a 
sentence Its full form is birectional encoder  
representations from transformers It is a powerful 
open-source machine learning framework developed  
by Google for NLP It excels at understanding 
the context of words and sentences by analyzing  
relationships between them in a birectional manner 
that allows computers to better understand the  
meaning of ambiguous language It also includes GPT 
that is generative pre-trained transformer also  
textto text transformer with that robata that 
is a robustly optimized BERT approach RoBERTa  
is a transformerbased language model that employs 
self attention to analyze input sequences RoBERTa  
applies dynamic masking where the masking pattern 
is changed It offers enhanced performance on  
various NLP task So you can also relate BERT with 
RoBERTa Consider that the main goal of the roba  
model is to improve the performance of the B model 
by addressing its limitations So these were the  
popular models of hugging face In this lesson we 
saw what is hugging face its introduction features  
and some popular models Thank you for watching 
the video In this lesson we will understand the  
use cases of hugging face Hugging face supports 
a wide range of use cases across NLP computer  
vision and even multimodel applications Let us see 
the use cases Hugging face is widely used We have  
discussed some key use cases here Beginning with 
conversational AI which you already know that is  
chat bots Okay They build intelligent chat bots 
using models like GPT Blenderbot and others These  
chat bots can be used for customer support like 
virtual assistants With that you can also create  
interactive dialogue systems These can be used 
as educational assistants as well as therapy  
bots Next comes sentiment analysis As the name 
suggest you can easily analyze customer feedback  
analyze their social media post or the responses 
to service so that you can determine the sentiment  
that is it is positive negative or neutral With 
that easily generate text generate articles blogs  
even poems using models like GPT codes can also 
be easily generated generate code snippets in any  
programming language With that content can 
be generated including product descriptions  
review marketing plans and others Next comes text 
summarization If you want to summarize your text  
let's say you want to summarize news you can 
easily do it with that let's say you have some  
PDF documents and you only want to summarize it 
Those lengthy documents can be easily summarized  
into important points With that you can also 
jot down meeting notes Then comes your named  
entity recognition Easily extract name skills 
and experience from rums It is also useful  
in healthcare to identify diagnosis the name of 
patients some medical terms and others With that  
you can also extract name of companies how they 
are working from their financial reports as well  
Therefore it is also used in the finance domain 
Machine translation as the name suggests you can  
translate your website app and even documents from 
one language to another Let's say from English to  
Spanish It can also be used in languages which 
have low resources that is for translation  
Question Answering use case is mostly useful 
for customer support with that easily answer the  
questions asked by students based on a specific 
textbook or notes FAQs can be easily answered and  
when I said customer support that itself means 
like we have seen support tickets on websites so  
that users can easily ask questions with that you 
can easily retrieve answers from large documents  
or databases Also use it for speech recognition 
and synthesis You can also convert speech to  
text Build voice controlled applications 
using speech to text and texttospech models  
You can also provide real-time captioning generate 
descriptions for images Let's say you have scanned  
document or images and you want text from it 
You can easily achieve this Also if you want  
to read or scan images that can also be achieved 
That means visual question answering Then comes  
your recommendation systems You must have seen it 
on Netflix or Amazon Prime can easily recommend  
movies or web series using what people are 
actually liking in their account With that enhance  
the search results by understanding the intent 
of users and their context also detect frauds  
easily with that regarding emails Easily detect 
and filter spam emails Mental health can also  
be monitored using a model Easily analyze text 
or speech so that the emotions can be detected  
such as stress anxiety or even depression With 
that understand the emotions of customers during  
support calls or even chat Text to speech and 
speech to text can also be achieved and realtime  
translations can be easily worked upon Multimodel 
applications analyze video content easily With  
multimodel applications you can easily analyze 
not even text but also video and audio Augmented  
reality applications can also be built Easily 
generate synthetic text data for training machine  
learning models You can also paraphrase text Also 
identify relationship between entities in text  
Grade the essays or assignments of students easily 
Build tools for grammar correction vocabulary  
rephrasing content and others Use in healthcare 
and life sciences from the medical records of a  
patient You can easily extract the insights from 
legal documents Easily extract the key clauses  
obligation or any possible risk With that you can 
also create AIdriven narratives for games Analyze  
social media easily so that you can identify the 
trending topics or even hashtags Also analyze the  
impact of post done by influencers Multilingual 
applications can also be created so that you can  
enable search across multiple languages Hate 
speech and harmful content is something that  
needs to work on With this you can easily detect 
and moderate them Easily predict the stock market  
trends by analyzing news articles social media 
sentiments Twitter post and others Predict events  
like a product launch Personalize email content 
for marketing campaigns Customize website or app  
content based on user preferences and behavior 
Fine-tune pre-trained models for your specific  
task Also you can compare the performance of 
different models on custom data sets So guys we  
saw some of the great use cases of hugging face 
In the upcoming lessons we will implement some  
of them In this lesson we will understand 
the transformers library of hugging face  
We will also learn how to install it Let's see 
The transformers library is the core library for  
pre-trained models and pipelines It is an open 
source Python library As I said before hugging  
face developed the transformers library and it 
is modular and extensible It includes thousands  
of pre-trained models for a wide range of NLP 
tasks such as translation text summarization text  
classification and others So in this lesson we 
will understand what is the transformers library  
why use the transformers library its use cases as 
well as how to install Let us start So we already  
saw what is the transformers library here Now 
we will see why use the transformers library  
Transformers library is widely used because it 
is quite simple to use with complex NLP models  
It provides you access to cutting edge models With 
that it is backed by a large and active community  
It supports customization and fine-tuning With 
that you can integrate the transformers library  
with other tools Here are some use cases of 
the transformers library classify text into  
categories like text classification in the case 
of spam detection in emails Also identify entities  
like names dates and locations in text which is 
called named entity recognition Translate text  
between different languages like from English to 
German with that generate text using models like  
GPT also implement question answering that is 
to answer on the basis of a given context Let  
us see how to install the transformers library 
So here are different ways Use pip to install  
the transformers library PIP is a package manager 
to download install and manage Python packages and  
libraries With that you can also use Google Colab 
Here you can find some difference in the syntax  
There is a exclamation sign if you are installing 
it on Google Colab With that you can also install  
the transformers library directly from the 
hugging face GitHub repository So let us see  
how to install it We will use Google Colab for it 
We will add the following command Let's see Here  
is a browser I'll type Google Colab and press 
enter Here is the link provided by Google only
collab.resarch.google.com Here you can see 
I already logged into my Gmail account So  
it will directly open I clicked on it So it is 
asking me to create a new notebook here These  
are my already created notebooks I'll click 
new notebook So it is a free web application  
So now we will use the same command here to 
install it I'll show you again Here is the  
command Okay let us type the same command Okay 
pip space install space transformers After that  
what we need to do we need to just click 
this It's written run here Can you see run
cell okay Okay So in this way we can install 
the transformers library using Google colab  
You can add the name of your Python notebook 
here So this created a Python notebook If you  
know Anaconda you can easily guess what is a 
Python notebook Save it from here and rename it
later So here I've just implemented this 
syntax to install the transformers library  
In this lesson we saw what is the transformers 
library We also saw that why it is so popular With  
that we also saw some use cases and how to install 
it In this lesson we will understand the datasets  
library on hugging face With that we will also 
see how to install it Let us start The datasets  
library provides easy access to a wide variety 
of data sets for NLP and other machine learning  
task It is developed by hugging face and is a 
Python library It makes it easier for developers  
and researchers to work with data for training 
and evaluating models So in this lesson we will  
see what is the datasets library Why to use it 
some use cases of the datasets library With that  
how to install it Let us start We already covered 
what is the datasets library So let us start with  
why use the datasets library One of the reasons is 
efficiency Lazy loading and streaming make it easy  
to work with large data sets The data sets can be 
huge and we always need a library or a technology  
to ease the work of accessing and working on 
those data sets So this library really helps  
It has a unified API for processing data sets You 
can also work with the transformers library and  
other ML frameworks with the datasets library So 
that integration and interoperability is possible  
Thousands of data sets are provided by 
hugging face It supports custom data sets and  
pre-processing pipelines So before installing 
the datasets library let me show you its
website So here is the link huggingface.co the 
official website of huggingface/datas So you can  
see how many data sets are provided over 350K and 
here it is If you'll click on any one of them you  
can get all the details In this tutorial we will 
also show you how to download and access a data  
set easily using hugging face Now let us see the 
use cases of the datasets library with the easily  
load and pre-process data sets for task like spam 
detection that comes under text classification  
With that you can also work with sentiment 
analysis and question answering Using this you  
can easily build question answering systems Some 
data sets are also provided for translation with  
that named entity recognition purpose can also be 
fulfilled with some data sets already provided by  
hugging face load and pre-process your custom data 
sets using the datasets library Now let us see how  
to install the datasets library So you can use 
pip PIP is a package manager to download install  
and manage Python packages and libraries Just use 
the command pip space install space datasets With  
that you can also use Google Colab easily But 
there is a difference between both the syntaxes  
You have an exclamation mark for Google Colab 
We will see it later With that you can directly  
download it from the hugging face GitHub 
repository using the provided syntax The  
g plus github.com huggingface/datas tell pip to 
install the package from the hugging face data  
sets repository on github Now let us see how 
to install the datasets library We already saw  
Google colab So I'll just use the second syntax 
to install the datasets library on Google Colab  
So this was our Google Colab We already saw 
how to install the transformers library We  
can install the data set library here itself But 
let me create a new notebook Go to file Click new
notebook Now a new Python notebook 
opened Let us type the command to  
install data sets pip install pip 
space install space data sets and  
just run the cell from here I have 
shown this before as well Let's
wait Tick mark is visible That means we 
successfully installed it You can also  
save it from here I told you before also save and 
let us add the name to our Python notebook So in  
this way guys we can easily install the datasets 
library In the upcoming lessons we will also see  
how to work with them and its use cases Guys 
we saw what is the datasets library We easily  
understood the concept its use cases also and 
we also saw how to install the datasets library  
In this lesson we will understand the tokenizers 
library of hugging face With that we will also see  
how to install it The tokenizers library is a fast 
and efficient library for tokenizing text which is  
often used alongside the transformers library We 
already saw the transformers library before in the  
previous lessons So the tokenizers library is a 
fast efficient and flexible library designed for  
tokenizing text data which is a crucial step in 
natural language processing Tokenization involves  
splitting text into smaller units such as words 
subwords or characters Then these are converted  
into numerical representations that ML models can 
process In this lesson we will understand what is  
the tokenizers library why use it its use cases 
as well as how to install it So let us start We  
already saw what is the tokenizers library So now 
we will see why use the tokenizers library It is  
quite quick for tokenization that means optimized 
for fast tokenization even on large data sets  
It also supports custom tokenizers as well 
as flexible enough to support multiple  
tokenization algorithms Integration is possible 
that means you can work it with other hugging face  
libraries like transformers It has an easy API for 
tokenizing decoding and managing vocabularies With  
that you can easily access pre-trained 
tokenizers Now let us see the use cases  
easily tokenize the textual data for classifying 
text like for spam detection in emails With  
that you can also analyze the spam easily 
perform sentiment analysis Align the tokens  
with entity labels It is also used for machine 
translation Some of its other use cases includes  
text generation and even question answering 
with that train and use tokenizers for domain  
specific data sets Now let us see how to install 
the tokenizers library We can use pip PIP is a  
package manager to download install and manage 
Python packages use the syntax pip space install  
space tokenizers to install it With that we can 
also use the tokenizers library on Google colab  
We already saw how to install a library on Google 
colab So similarly we can use the exclamation mark  
pip space install space tokenizers to install it 
Also the third way you can tell pip to install the  
package from the hugging face data sets repository 
You can also use the third way that is directly  
install from the GitHub repository Type pip space 
install space get plus the GitHub path to install  
it Now let us see how to install tokenizers 
library on Google Colab We will open Google Colab
again So here is our Google Colab We already 
installed the transformers and datasets library  
We can install the tokenizer library here itself  
But let me create a new Python 
notebook Go to file Click new
notebook Now let us type the command 
exclamation mark pip space install  
space tokenizers and click on 
the cell Click here run cell
Now the tokenizers library will get
installed You can also save
this As I told before it will create a Python 
notebook So here I'll type AIT you can add any  
name And this is our Python notebook Okay We will 
utilize all these libraries later on when we will  
work on the use cases of hugging face So guys 
we saw what is the tokenizers library We also  
saw its purpose as well as the use cases With 
that we also installed the tokenizers library  
on Google Colab In this lesson we will learn 
what is a hugging face access token With that  
we will also learn how to create it Let us start 
Consider an access token as a secure string of  
characters This is mainly used to access hugging 
face services and resources The hugging face API  
key and hugging face access token are the same 
thing So in this lesson we will see what is an  
access token that is an API key With that we will 
learn when do we need a hugging face access token  
Also we will understand that when the hugging 
face access token isn't required In the end  
we will learn how to create an API key Let us 
start So we covered what is an API key that is  
an access token in hugging face Now let us see 
when do we need a hugging face access token Here  
it is When you're using a private or gated model 
or an inference API okay you need a hugging face  
access token You must have heard about metas lama 
It is a private model To access it you need to  
authenticate That means you need to create an API 
key You need a token with that If you're using the  
hugging face inference API then you need an access 
token to make API calls Also if you're uploading  
models or data sets or even spaces to the hugging 
face hub you need an access token Now let us see  
when do you not need a hugging face access token 
Obviously if you're accessing public models which  
are publicly available to download and use you 
don't need an access token just like GPD2 Also  
if you're using the models via the transformers 
library of hugging face you don't need an access  
token These are publicly available and can be 
easily downloadable without any authentication  
without any API key Also a lot of open source 
models are available To access these models  
you don't need an API key You don't need an access 
token because they are freely available So in the  
upcoming lessons we'll be working on these public 
and open source models only so that there's no  
need to create a hugging face access token Now 
let us see how to create a hugging face access  
token So we will go to the hugging face website 
and we will create an access token So let us
start Open the official website huggingface.co
/join and press
enter So here it is you need to join that means 
you need to create an account on hugging face Here  
you can use your email address So let me create my 
account So here I have added my account my email  
id Now enter the password Here it is Now 
click next Complete your profile here Add a
username Add your name You can also 
add your Twitter username These are  
optional LinkedIn profile also You 
can also upload your aftar I'll
click Also you can add your GitHub 
username as well as your website
As you can see these are optional Click 
I have read and after that click create
account We have created an account 
You need to check your email address  
for a confirmation link Now your account is
verified Your email address has been verified
Click on your profile Go below It's written 
excess tokens Here it is Click on it Now you  
need to create a new token by clicking here 
Remember do not share your excess tokens with  
anyone Create new token Add the token name 
Let's say I'll type demo key Okay Now go
below click create token The key created 
successfully You can copy it and save it  
Here it's written save it somewhere safe You will 
not be able to see it again after you close this  
model Click done Now all your keys are visible 
Here it is We created a single key just now  
And when you'll click here you can edit it 
You can edit the permissions and also delete  
it Okay we saw what are access tokens or API 
key in hugging face With that we also learned  
how to create it In this lesson we will learn 
how to download a data set from hugging face  
For that we will use the datasets library Let 
us see A data set refers to a collection of  
structured data which can be used for training 
evaluating or testing machine learning models  
So hugging face is having a lot of data sets on 
his platform which can be used for various use  
cases like NLP We will use the datasets library 
to download a data set from hugging face Let us  
see First let us see the data sets Go to the 
hugging face website/data sets So these are  
the data sets provided by hugging face You 
can see a lot of them Let us see how we can  
download it So we will go to the same platform 
Google colab which we have used before in this
tutorial Here it is Okay So 
this is the notebook we already
created In this first we installed the 
datasets library I already told you how  
to install it on Google Colab using the 
pip command After that we loaded a data
set using the load data set function This 
function can download data sets from the  
hugging face hub or load them from local 
files We are downloading a data set from  
the hugging face hub right now Here it is Okay 
Here we are loading the IMDB dataset After that  
I'm printing the data set using the print method 
Here we are importing the load data set function  
This provides access to various public data sets 
like IMDB In this case here we are loading the  
IMDB dataset The IMDB dataset contains movie 
reviews labeled as positive or negative for  
sentiment classification When you'll run it will 
automatically download and process the data set  
Here we are printing the data set This will split 
the data set into train and test Okay that is  
it will display an overview of the data 
set including the number of samples in  
each split Let us see after running Here 
it is It is showing us the structure of  
the IMDb data set as data set dictionary which 
organizes the data set into different splits  
The train contains 25k rows with features text 
for movie reviews and label for sentiment like  
positive or negative Here for test that is 25k 
rows for testing purposes with the same features  
It contains 50k rows but this plate typically 
doesn't have labels for sentiment analysis  
It's often used for tasks like pre-training or 
semi-supervised learning In this way guys we can  
download a data set In this lesson we will learn 
how we can download a model from hugging face Let  
us see So to download we will use the transformers 
library where that we can also download directly  
from the hugging face hub So let us see a 
step-by-step guide to download and use models from  
hugging face We will use the transformers library 
which we already discussed Let us see Here is our  
VS code We already created a notebook file open 
notebook So here we created amit_d download model
already In this what we did first we installed 
the transformers library We already discussed  
that hugging face developed this library So we 
used pip to install it on Google Colab After  
that what we did here we downloaded a model using 
the transformers library We have used the from  
pre-trained method for this This method downloads 
the model weights configuration and tokenizer  
from the hugging face hub We are downloading a 
pre-trained BERT model Here it is After running  
what we will get we ran this and we got the shape 
This shape is commonly seen in models like BERT  
where each token in a sequence is represented 
by a 768 dimensional vector When we use the  
BERT hyphen base uncased model and pass the input 
hello hugging face the last hidden state output  
shape represents the tensor dimensions For this 
example the shape you would typically see is the
following Here one is visible Okay it 
is the batch size since there is one  
input sentence Seven is the sequence length 
This corresponds to the tokenized version of  
hello hugging face including special tokens 
Okay that means the following hello hugging
face 768 is the hidden size Each token 
is represented as a 768 dimensional  
vector standard for BERTs base architecture In 
this way guys we can easily download a model  
using the transformers library with Google 
Colab In this lesson we will learn how to  
implement sentiment analysis with hugging 
face We will understand what is sentiment  
analysis with its type After that we will run 
a coding example on Google Colab Let us see  
So we already discussed the transformers library 
provided by hugging face It is a powerful tool  
for task like sentiment analysis Now what is 
sentiment analysis as the name suggest it includes  
determining the sentiment expressed in a piece of 
text like positive negative or neutral So let's  
say I love cricket So this is a positive sentence 
Okay I don't like something I'll hate something So  
that is a negative sentiment Similarly when I'll 
explain the types of sentiment analysis things  
will be more clear First one is polarity detection 
that is positive negative or neutral I love this  
product is positive Obviously the service is 
terrible is not good is negative and and when  
the things are not clear it will be neutral like 
the package arrived on time Next comes emotion  
detection Let's say you said this is not good 
This is pathetic this is so frustrating That is  
anger And joy is expressed by a sentence like I'm 
thrilled about the results So emotion detection  
includes happiness frustration and other emotions 
Then comes aspect based sentiment analysis like  
sentiment towards a specific product or service 
like the food was great but the service was  
slow In this case the food is having a positive 
sentiment obviously but since the service was not  
good it is a negative sentiment Then the intent 
analysis like the intent to purchase something to  
complain Let's say you said where can I buy this 
product so that is a purchase intent So these were  
the types of sentiment analysis Now let us see the 
coding example In this we will use a public model  
So we won't be creating an access token 
because for public models as I already  
told we don't need it We will run the code 
on Google Colab for efficiency we can also  
change the runtime on Google Colab So I'll 
also show you that with the example Let us
start Here is our Google Colab 
Okay Let me open the code file  
Open notebook I already created 
the project Here it is Sentiment
analysis Here it is So for efficiency we can 
change the runtime type Click the runtime menu  
Here click change runtime type Okay We can see 
we already selected the T4 GPU Not a problem  
If your project is quite complex or you are 
having a large scale project you can select  
the V2-8 TPU also I'll keep the same Okay So 
initially here what we did first we installed  
the required libraries that is transformers 
and torch Okay we used the paper We already  
discussed how to install it in the previous 
lessons After that we ran it using this run
cell In this we imported the necessary modules in 
this line Here we loaded the sentiment analysis  
pipeline The pipeline function provides 
a simple way to perform various NLP task  
including sentiment analysis You can load a 
pre-trained sentiment analysis model as follows  
So here what we did we loaded the following 
model Okay After that we performed sentiment  
analysis Since we have loaded the sentiment 
analysis pipeline use it to analyze the  
sentiment of a piece of text So here I love 
playing and watching cricket These are my  
text and I hate when Virat Kohli misses a 
century So obviously you can guess this is  
a positive sentence and this is a negative 
sentence You can easily guess it So this is  
the sentiment analysis Here the output you 
can see is a list of dictionaries Here it
is Here each dictionary contains the sentiment 
label and the confidence score Here it is label  
and the confidence score So here we have analyzed 
multiple text at once by passing a list of strings  
to the sentiment analyzer Now let us understand 
the output completely The score in the output  
of the hugging face sentiment analysis pipeline 
represents the confidence level or probability  
that the model assigns to the predicted sentiment 
label It indicates how confident the model is that  
the given text corresponds to the predicted 
sentiment The score is a value between 0 and  
one As you can see the score closer to one means 
the model is very confident in its prediction If  
the score was closer to zero that would have mean 
the model is less confident in its prediction The  
label positive indicates that the model predicts 
the sentiment of the text is positive That is  
the following The negative means the opposite 
that is negative Here it is So here you would  
be wondering why the score is so high close to 
one This is because the model we are using has  
been fine-tuned on a large data set and is 
highly accurate for sentiment analysis task  
The input text likely contains strong unambiguous 
language that makes it easy for a model to predict  
the sentiment with high confidence like hate 
means negative and love means positive So in  
this way guys we can work on sentiment analysis 
with hugging face In this lesson we will learn  
how we can use the hugging face for text 
classification First we will understand  
what is text classification With that we will also 
see the difference between sentiment analysis and  
text classification After that we will create and 
run an example on Google Colab Let us start Text  
classification as the name suggests can be used 
for spam detection So on your email id you must  
have seen that some emails go to spam some emails 
are not considered as spam In a similar way you  
can also classify news articles or documents like 
sports article under the sports category a tech  
related article under the technology category 
and with that it also includes a use case for  
intent detection like to cancel an order to book 
a flight and others So let us see till now we have  
covered the sentiment analysis So here is the 
difference between sentiment analysis and text  
classification As the name suggest sentiment 
analysis are narrow that is specific to the  
sentiment Let's say positive sentiment for a 
text like I love cricket In a similar way the  
labels for text classification depends on the 
task like I just discussed about spam or not  
spam or different topics with that For sentiment 
analysis we discussed before it is mainly positive  
negative or neutral Some use cases include 
classifying email as spam or not spam Under text  
classification under sentiment analysis one of the 
use case can be a positive product review Now let  
us see a coding example where we will detect spam 
or not spam based on a text We will use a publicly  
available model that is the following So we won't 
be needing any access token from hugging face for  
this So let us see the example and classify 
text as spam or not spam Here is our Google  
Colab We created these notebooks till now Let 
us open our text classification notebook Open
notebook So here it is We already created it 
Let us see the steps First we will install  
the required libraries that is to begin with 
the hugging face transformers library as well  
as the torch library So we have used the pip 
install command for this Let's go below After  
that we will import the necessary modules 
Here we have imported the pipeline module  
Then we have loaded a pre-trained spam detection 
model that is the following here It is freely
available So we did not applied any key for it 
from hugging face Now the next step includes  
performing the spam detection So first we have 
set multiple text so that we can detect whether  
these text are spam or not spam We have classified 
multiple text at once by passing a list of strings  
Here it is We have mapped labels to spam and not 
spam Here here it is Label mapping Negative means  
spam Neutral means not spam Positive means not 
spam Okay To display the results we have used the  
for in loop Here it is What will happen a score 
will be visible in the output Okay The output  
will also include the label whether the text is a 
spam or not spam With that the score will also be  
visible These are the confidence scores Here it is 
So according to our model the first text is a spam  
obviously because it is showing congratulations 
you have won a 500 INR Amazon gift card Click  
here to claim Now the second one is not a spam 
obviously Hi myth Let's have a meeting tomorrow  
at 12 p.m So obviously this is not a spam The 
last one is also considered as a spam We get  
a lot of such spam emails that your Gmail account 
has been compromised Here the confidence interval  
is displaying the score Low confidence scores 
indicate that the model is uncertain about its  
predictions The following model is fine-tuned for 
sentiment analysis Okay but not specifically for  
spam detection We are still adapting it for spam 
detection Okay that's why here it is showing not  
spam but the confidence score is even less than 
0.7 And I told you that low confidence scores  
indicate that the model is uncertain about 
its predictions You can set a different model  
here from the hugging face Here we are showing an 
example So in this way we can use the transformers  
library on hugging face to detect spam that is 
to perform text classification In this lesson we  
will understand how to perform text summarizations 
using hugging face First we will understand that  
why we need to summarize and then we will see a 
coding example on Google Colab to summarize text  
Let us start The hugging face transformers 
library as you already know is used for NLP  
task that includes summarizing text as well So 
why summarization summarization is actually used  
in a lot of real world applications You must 
have seen summarizing long articles into short  
snippets With that summarizing documents or 
research papers chatbots also provide quick  
concise responses With that you can extract key 
points and summarizations from a document and from  
large data sets also Now let us see an example 
here We will use the following model which is  
publicly available on hugging face So we don't 
need to add the access token Okay Okay we will  
run the code on Google Colab like we saw before So 
let us see the code So here is our Google Colab We  
will open our code file Open notebook So here we 
are discussing about summarization Here is our
code First what we did we installed the required 
libraries So we have installed the transformers  
as well as the PyTorch library here using the pip 
space install command We already discussed this  
command before After that we will use automodel 
for sequence to sequence LM and auto tokenizer  
for more control over the process so that we 
can load the model and tokenizer directly So  
this is what we have done here Here we have 
loaded the following pre-trained model for
summarization So here we have set the input 
text to summarize So this is a text We will  
summarize this First we have tokenized the 
input text using the following Okay So here  
you can see some parameters These parameters 
will control the summaries length and quality  
Max_length is the maximum number of tokens 
in the summary We have set 512 So here the  
summary will be no longer than 512 tokens 
We have tokenized the input text Here to  
generate the summary we have used the generate 
method Here we have some parameters First the  
input the following tokenized Then the 
max length which is the maximum number  
of tokens in the summary This is the 
minimum number of tokens in the summary
Length penalty What is this this encourages 
longer or shorter summaries Here it is two  
That means longer summaries Num beams controls 
the beam search width Higher values improve  
quality but slow down inference Here we have 
set it to four That means four beams for
decoding Okay So here was our input and this is 
the summary Here we have printed the summary Here  
we have summarized it Okay So in this way guys 
we can use hugging face So in this way guys we  
can summarize text easily In this lesson we will 
understand how we can perform translation using  
hugging face that is textto text generation Let us 
see for translation task We will use the hugging  
face transformers library Some models are already 
provided for this So translation as we all know  
includes let's say translating English text to 
Spanish This is a part of texttoext models that  
requires a task prefix to specify the type of task 
For example translation summarization and others  
Textto text generation includes not only 
translation but also summarization paraphrasing  
question answering and even sentiment 
classification So let us see the difference  
between text to text and text generation So 
text generation is used for auto reggressive  
text generation where the model generates text 
sequentially one token at a time like dialogue  
systems text completions and others The text 
to text generation class is used for sequence  
tosequence task where the model will take an 
input sequence and generate an output sequence  
like your text summarization paraphrasing and even 
translation Now let us see an example to perform  
translation using the hugging face transformers 
library In this we will use a model t5-small which  
is publicly available on hugging face This model 
is a smaller version of the T5 model and can be  
used for task like summarization translation and 
even question answering Let us see the example  
on Google Colab Here is a Google Colab We just 
saw the text summarization example Now let us
open Now let us open the 
translation example Here it is
First we will install the required libraries that 
is the following Here we have used the pip space  
install command We already saw this command 
before After that we will load a pre-trained  
translation model that is here we have loaded 
the T5 model It is a versatile textto-ext
model that can handle translation 
by prefixing the input with a task  
specific prompt So we are loading a T5 model
here Here we have prepared the input text So this 
is the text we will translate Translate English  
to Spanish That is the following text will get 
translated Tokenize the input text into input  
ids that the model can process Use the model to 
generate the translated text You can customize  
the generation process with parameters like 
max length num beams We saw in the previous  
lesson also Here the output tokens will be 
decoded to text and after that we will print  
the translated text So here is the output 
translated text My name is Amit Diwan and  
I love cricket So here it is translated to 
Spanish So in this way guys we can perform  
translation In this lesson we will understand how 
to use the hugging face for question answering  
We will also see an example Let us start So we 
will use the transformers library of hugging  
face for performing question answering task 
We will run the code on Google Colab So here  
we will use the following model which 
is publicly available on hugging face  
So we don't need to create an access token for 
this So let us see the example on Google colab
So here we will open our
code First we will install the required 
libraries we have shown We have used the  
same pip install command which we saw 
before to install the required libraries  
After that we will load a pre-trained QA 
model and tokenizer Here is our model and the
tokenizer prepare the input for QA task 
that is for the question answering task  
we need a context as well as a question What 
is a context now it is a paragraph or text  
where the answer might be found that is the 
following I'm providing a context also and  
here is the question So this is about me and 
here is the question the question you want  
to answer Okay So we have said both After 
that we will tokenize the input Tokenize  
the context and question using the tokenizer 
We have done both Get the model's prediction  
Pass the tokenized input to the model 
to get the answer That is the following
It will extract the start and end scores
also Okay it will get the most likely start and 
end positions Okay here And it will use the same  
to convert token ids back to words so that the 
answer is displayed here Answer tokens will be  
set here and it will be decoded back to words 
This will have your output So here the question  
was where Amit Diwan is based The context was 
the following and the answer is Delhi So in  
this way guys we can perform question answering 
easily In this lesson we will understand how we  
can perform text to image using hugging 
face Let us understand with an example  
So here we will use the hugging face diffusers 
library This example will use the stable diffusion  
model also which is one of the most popular text 
to image models available in the diffusers library  
Now what is the diffusers library and stable 
diffusion the diffusers library is an open-source  
Python library to focus on diffusion models for 
generating images audio and other types of data  
These are a class of generative models only 
developed by hugging face What is stable  
diffusion it is a latent diffusion model 
designed for high quality image generation  
So you can generate images from text prompts 
using this It is also one of the most popular  
generative model Let us see the example here Here 
we will use a publicly available model on hugging  
face Let us see the example and convert text to 
image The output will be generated as an image  
on Google colab itself So let us see here is our 
Google colab Let us open our notebook for text to
image
Here it
is First we will install the required libraries 
using the same pip install command we already  
discussed So now we will load the stable 
diffusion pipeline The diffusers library  
provides a stable diffusion pipeline that makes 
it easy to generate images from text prompts  
We will load the stable diffusion model here 
Now generate an image from a text prompt Easily  
generate an image by passing a text prompt to the 
pipeline Here is a prompt Flying cars soar over  
a futuristic cityscape at sunset The following 
will generate the image Okay here is our image  
This image will get saved on Google Colab 
only using the same method and it will  
also print image saved as generated 
image.png So a PNG file will get  
generated Okay where it will be visible 
on Google Colab Click here You can see
files Now I'll run it
I'll run
it I'll run this now
Now I'm running to generate an image and save
it Okay So here is our image It's 
written image saved as generated image
dotpng Okay So it generated it I'll just go here  
From here you can download it You 
can also copy the path I'll click
download It downloaded Okay Here it is So 
we generated an image that is text to image  
In this lesson we will understand how to perform 
text to video using hardinface This is called  
text to video synthesis We will understand what 
it is and we will also run a sample example So  
let us start Text to video includes generating 
video from textual descriptions like typing a  
text and generating a video Like we saw in 
the previous lesson text to image we typed  
a text and generated an image In this case 
we will generate a video So we have a lot of  
pre-trained models and tools for generating 
videos Hugging face provides the same models  
The text to video synthesis term I just told it 
includes generating a sequence of frames based on  
a textual description Since it's a complex task 
it requires combining different NLP models with  
generative models or even diffusion models Okay 
division models we saw in the previous lesson  
It is used for generating images or videos Let 
us see some video generation frameworks Before  
moving towards the example one of the most 
popular ones are Runway ML It offers tools  
for video generation and editing Mostly for AI 
generated videos you can use pickabs with that  
deep minds perceiver IO can also be used to 
handle multimodel inputs Multimodel input can  
include text even images and even videos You need 
to use the libraries like pytor or tensorflow so  
that you can build pipelines for generating 
video frames Let us see an example So here we  
will use the diffuser library also We already 
discussed the diffuser library It is an open  
source library developed by hugging face and used 
for generating images and even videos We will use  
the publicly available stable division model 
In our example we will run the code on Google  
Colab like we saw before Let us start Here is 
a Google Colab Let us open our code file Open  
notebook We will open our notebook for text to 
video I'll type video only to search Here it
is First we will install So here we have used the 
pip install command to install the transformers as  
well as the diffusers library also with PyTorch 
After that we will load a text to image model So  
here we are loading it This is the model I already 
told you We have used the diffusers library to  
load a pre-trained text image model like stable 
diffusion Generate frames from text First we have  
set the prompt Here we will generate individual 
frames based on the text description So this is  
the text description A futuristic cityscape at 
night with flying cars This will generate 10  
frames using the for in loop Here it is 10 and 
it will append Later on we have used the open  
CV library to stitch the frames into a video Here 
we are using the Open CV inside the for in loop  
so that we can stitch it We have also used the 
numpy library We are using the numpy array in it  
So this will save frames as images and this will 
stitch the frames into videos and the following  
will display the output which is gathering the 
frames using the for in loop and the output will  
be displayed like this in a form of frames So 
here when I'll run it will display me 10 frames  
because we are generating 10 frames here and 
after that in the end it will display the video  
So here is the output The output video will have 
the following name output video.mpp4 but it will  
also generate frames How many frames 10 frames 
The format of the frame will be the following  
Frame i the value of i So the frames would be 
like frame_0.png frame_1.png and it will go  
until 9 that means 10 frames and the output 
will be here I told you Now let us run it
Now we will click here and here you can see I told 
you it will generate 10 frames frame_0.png till 9  
and output video will be here So this was the 
output I'll just click here and click download
It downloaded right-click and
open Here is our video Okay You can see 10
frames So in this way guys we can generate 
video from text with hugging face Thank you  
for watching the video guys If you like the video 
you can directly go to our channel and support us  
by subscribing and joining Click on the Join 
button here and you can support us Okay by  
clicking join here and you can also go to any 
of our video okay here in click on the three  
dots and click thanks You can also directly 
support us here Okay thank you for watching
