Generative AI Full Course – Gemini Pro, OpenAI, Llama, Langchain, Pinecone, Vector Databases & More
this massive course about foundational
generative AI was originally recorded
live we've put it all together into this
one video this course offers insights
into generative models and different
Frameworks investigating the production
of text and visual material produced by
AI the course is taught by three
experienced instructors okay I think uh
we can start with the session so hello
everyone good afternoon to all uh this
is the very first session for the uh
generative AI uh from today onwards we
are going to start with a community
session of generative AI so uh yes in
today's session we'll be talking about
that what all thing we are going to
discuss uh throughout the sessions and
uh this session actually it will be
happening for uh upcoming two weeks and
uh it will be on the same time I'm going
to take the session from uh 3:00 p.m.
onwards uh maybe 3: to 5 so here in this
uh committee session we'll try to to
discuss many more thing regarding the
generative AI so we'll start from very
basic and we'll go to the advanc there
we'll try to develop different different
type of applications as well uh first of
all I will start with the theory uh so
there I will uh discuss about the
theoretical uh uh like stuff and all
that what is generative AI what is a llm
and after that I will uh like go with
the open a Lang and don't worry each and
everything I will discuss in a very
detailed way and and uh I will show you
the dashboard as well where all the
lectures and all will be uploaded and
apart from that I will uh show you the
uh like uh where you can find out all
the videos quizzes and uh assignments
and all because along with the session I
will give you the different different
assignment different different quizzes
so at least you can practice with the
concepts got it guys yes or no so are
you excited please do let me know in the
chat if you are excited
then
great so I think we going to start and
uh so first of all guys what I will uh
do I will give you the uh the detail
introduction of the course that what all
think we are going to discuss in this
committee session and uh here basically
this is our dashboard so let me share
this link with all of you so uh don't
worry my team will share the link of
this dashboard in the chat so from there
what you can do you can enroll it is
completely free you no need to pay
anything for this uh committee session
and all the lectures and all the
assignment and quizzes will be uploaded
over here don't worry I will come to the
curriculum also so here first of all let
me show you the homepage uh this is the
homepage guys uh this is the homepage of
this dashboard and there uh uh like you
can enroll in this particular dashboard
and don't worry uh each and every video
you will find out over the Inon YouTube
channel as well so all the recorded
video and all it will be available
inside the Inon YouTube channel uh
definitely this video is going to be
record after the session so this video
will be available inside the I YouTube
channel as well as uh over the dashboard
so here guys this is the dashboard I
think you got a link of the dashboard so
there you can enroll and then uh like
you can start your journey of the
generative AI so here guys uh me and buy
both are going to take this particular
session so there we are going to discuss
in depth uh about the generative AI
about the llm we'll try to discuss about
a various application various recent
model llm models and all uh we have so
many things uh to discuss about the
generative AI we have planned for the
two weeks but uh maybe uh more than 2
weeks uh we'll try to uh take if we are
not able to cover and like all the
curriculum whatever we have defined
whatever we have thought uh so
definitely we'll be extending the date
as well but yeah we will make sure that
within 2 week whatever curriculum we
have defined we'll try to complete it so
here guys are me and uh buy so if you
don't know about me guys so my name is
Sun my name is s Savita I'm working in
Aon from past three year and I have I'm
having an expertise in data science uh I
have explored U every aspect of the data
science like machine learning deep
learning and advanced deep learning like
computer vision NLP I have worked with
the mlops as well uh there I have
designed a various applications and all
got it so yeah uh you can search me
about more over the LinkedIn uh there
you will get uh you will you will get
got my profile and you will uh like uh
get each and everything in a detailed
way so here guys uh what you need to do
so first of all you need to enroll to
this particular dashboard uh you no need
to pay anything over here and if you are
going to login after login what you need
to do uh so uh you will be redirect
redirecting to this uh particular
dashboard and uh so let me show you the
dashboard first of all this is the
dashboard guys as of now there is no
such videos and all uh definitely after
the session we'll uh upload the videos
and assignment and quizzes so definitely
along with the sessions and all you can
practice so this thing is clear to all
of you yes or no have you enroll uh
through this dashboard did you get this
Dashboard please do confirm in the chat
I'm waiting for your reply please do it
guys great so I can see uh uh many
people are saying yes so definitely now
uh we can discuss about the curriculums
and all so whatever thing we are going
to discuss throughout this committee
session first of all I will give you the
detail uh like uh detail introduction of
the uh syllabus uh what all topics we
have uh we'll try to more focus on the
re recent Trends I'm not going into the
uh classical uh machine learning and the
Deep learning basically so I will focus
more Focus basically on the open Ai
langen and all so don't worry
I will give you the detail introduction
of the syllabus uh that whatever thing
we are going to discuss inside this
committee session so the first thing
what you need to do guys you need to
enroll inside this dashboard and uh
whatever like videos and all you will
get uh you will like go through and
basically you can watch it over here
itself directly now let's discuss about
the curriculum and all that what all
thing we are going to discuss and uh for
that basically I have created one PPT so
let me show you that particular p PPT uh
just a
second so here is a PPT guys can you see
this PPT yes or no please do confirm in
the chat if it is visible to all of
you
great I think uh this uh PP is visible
to all of you now guys uh we can discuss
uh that uh what will be our uh like
topics and all uh that what all thing
basically we have to discuss throughout
this committee session so here uh first
of all I will start from the generative
AI so there I will give you the detail
overview of the generative AI that what
is a generative AI uh why uh we should
use a generative AI uh what all type of
like application we can create and uh
each and everything each and every every
theoretical stuff we try to discuss
regarding the generative Ai and after
that after the generative AI I will come
to this uh large language model so just
a second let me open my uh pen as well
so I can write it down um each and
everything
yeah so here guys uh we can uh I can
write it down as well now so here the
first thing basically first I'm going to
start from the generative AI there uh
definitely I'll will be talking about
each and everything each and every
aspect of the generative AI then after
that I will come to this large language
model there I will try to discuss this
llms large language model in a very
detailed way we'll try to see the
complete history of the large language
model that what is a large language
model what types of model we have what
was the classical model and uh what is a
recent model okay so each and everything
we'll try to discuss regarding this llms
and after that after completing this uh
theoretical part theoretical of this uh
stuff and all regarding the generative
AI regarding this llms I will come to
this open AI open Ai and this lenen so
there uh we'll try to discuss in a very
detailed way that what is the open AI
what is the open AI API and inside the
open AI API we have a different
different them right so in OPI openi
itself you will find out a various model
that like openi open has created a
various model uh that different
different version of the gpts okay so it
is having some uh like a old model as
well some legacies and all and some
upcoming models so each and every model
will try to discuss I will give you the
walk through regarding those particular
model and I will discuss about the
python API python uh API uh that uh how
you can uh use utilize those particular
model by using the python getting my
point and apart from that apart from the
python API and all will try to discuss
that uh like if we are going to be uh if
we are going to use the Lenin right so
how it is different from the open AI so
at the first place I will give you the
uh detailed differences between this
open Ai and this lenen that how it is
different to each other that why this
Lenin is required then I will come to
the Lenin and then again we'll try to
create uh again basically we'll try to
Define the lenen and all uh by using the
python we'll try to uh use the lenen or
different different like a component of
the Lenin like memory chain agents and
all and yes after that I will try to
create one
application okay so here uh basically
we'll try to create one application and
with that uh definitely we'll be able to
justify the knowledge whatever actually
uh we are going to learn regarding this
llm open lenion by using uh that by
creating that particular project
and after that I will uh come to the
advanced part Advanced part like uh
Vector databases uh we'll try to discuss
about a different different Vector
databases and first of all we'll try to
discuss the need of the vector database
that why it is required what is the
meaning of the embedding uh how we can
uh like uh save the embedding how we can
retrieve that and how this a vector
database this a vector database plays an
important role whenever we are going to
create any application related to this
llms okay so there we'll try to discuss
about the vector databases and then I
will come to the some open source model
so uh first of all I will come to this
uh llama uh and I will discuss about the
Llama indexes what is the Llama index
and we have a like couple of Open Source
model which is a very very famous so
we'll try to talk about those model as
well like we have a llama to itself we
have a falcon we have a bloom there are
various model and we'll show You by
using those model how you can create uh
like a how you can create your end to
and application uh you can solve any
sort of a task just take a name don't
worry I will give you the detail
overview about the NLP and all that what
all task does exist what all task
basically we have what all task we can
solve by using this llm each and
everything we'll talk about and then
finally we'll create one more end to
endend project there we'll try to uh use
the entire knowledge uh whatever we are
going to be learn uh like this Vector
databases different different open
source model and a length CH open a
llama indexes and finally we'll try to
deploy that model by using the amops
concept so did you uh like this syllabus
yes or no please do let me know guys
please do let me know in the chat if you
like the syllabus yes or
no the agenda is clear to all of you if
you can write it down the chat I think
uh that would be
great great so I can see many yes in the
chat and many people are saying yes they
are
able to get yes don't worry we'll give
you the PPT and all each and everything
will be there in a uh resource section
so from there you can download this PP
you can download this entire thing
whatever I'm uh like I will be using
throughout the
session yes uh so fine I got a
confirmation now uh the first thing uh
many people are asking the prerequisite
what will be the prerequisite if you are
starting with this committee session so
prerequisite wise uh if you have a basic
knowledge of the Python if you have a
basic knowledge of the Python if you
know about the core python uh in a core
python actually we have uh uh like a
ifls for Loop and uh different different
type of data structure and the knowledge
of the database exception handling if
you are uh if you know about the basic
python the basics of python then
definitely you can proceed with this go
along with that if you have a like some
basic knowledge about machine learning
and deep learning so you will understand
uh the concept basically whatever uh
like we are going to teach you in a
better manner in a better way because
here I'm not going to talk about the
classical uh ml or the basics of the
deep learning like uh artificial NE
Network CNN and all definitely I will
give you the overview about the transfer
learning fine tuning and all but here uh
uh I won't talk about the neural network
and this recurr neural network lstms and
all so uh if you have a basic
understanding of machine learning and uh
deep learning so definitely you will
understand the concept in a very well
manner otherwise basic python knowledge
is fine for creating application basic
python knowledge is uh like fine okay so
you no need to worry about it uh
whatever thing actually I need to
explain you definitely I will do that uh
in the class itself and uh we'll do the
live implementation I'm not going to
show you any uh pre-written code and all
uh definitely I will write it down each
and everything in front of you only got
it so prerequisite is clear so
prerequisite nothing just a python or uh
I can write it down over here basic
knowledge basic knowledge of ML and DL
if you know this much then definitely uh
like uh you will be able to understand
each and everything in a well
manner great so yes we'll talk about the
RG approaches and all each and
everything diffusion model is there
there are some recent model in l each
and everything will talk about and you
will be capable so uh let's say if you
are working in your company or maybe you
are trying to switch into the generative
AI or maybe you are fresher in every uh
case right so this community course will
help you definitely if you if you are
going to attend every session if you are
going to learn along with me definitely
you can build anything after learning
all sort of a thing got it great so I
think uh this uh introduction is clear
to all of you now I already discussed
about uh about the dashboard and all so
uh I given you the walk through of the
dashboard so link you can find it out
inside the chat inside the chat and from
there itself you can enroll now the
syllabus is clear dashboard is clear
each and everything is fine so I think
we can start with the introduction of
generative AI generative Ai and llm
because from today's on uh from
tomorrow's onwards I I will be like move
to the Practical part and there I will
be talking about the open a how to
generate a open key how to use the open
API and uh we'll try to understand the
chat completion API functional API and
uh we'll try to understand the concept
of the token also that what is a token
uh like how many token should I use
whenever we are giving any sort of a
prompt what is a different different
prompt template and all there are lots
of thing which we need to understand so
today's session actually it will be uh
like completely introduction session and
in this particular session uh we'll talk
about the generative Ai and the history
of the large language model so guys uh
are you ready can I uh get a quick yes
in the chat if you are ready
then yeah definitely we'll talk about
the uh like use cases of the generative
and all u in today's session itself I
will like give you that uh particular
idea that where you can uh utilize this
generative AI in a real time
yes definitely this course content and
all whatever you are seeing over here
this one definitely it will be available
over the dashboard as well so this is
our dashboard we'll update it over here
inside the course syllabus section so
each and everything uh like uh we'll try
to update in the dashboard
itself here is a class timing and all
and uh I will make sure that the uh the
link also okay so uh we are not going to
uh we are directly streaming over the
YouTube so directly you can uh join
through the YouTube so for that you just
need to subscribe the channel and you
will get a notification in that
case great so people are saying yes sir
we are ready ready ready
great yeah definitely Wy we'll try to
discuss the applications and all and uh
I will explain you all the thing and
that uh specific way only don't
worry we are going to build AI
application by using the AI
tools AI based
application great so I got uh many yes
in the chat now I think uh we can start
with
a uh with the introduction of generative
Ai and the LM so guys uh first of all
tell me that how many of you you are uh
you have started with the generative Ai
and all already means uh you have
learned something at least you have
learned the basics in all uh so if you
can write down the chat so that would be
great means you are starting from very U
like a scratch or you have some sort of
idea
great so many people are saying uh so
some people are saying they know about
the basics and some people are saying uh
they're starting from the scratch don't
worry so uh basically I will start from
the scratch only now here guys uh you
can see I have created One PP for all of
you so let me uh first of all let me go
through with this particular PP and
later on what I will do I will again I
will give you the revision by using this
PP only and in between I will use my
Blackboard also for explaining you some
uh Concepts and all so here is my
Blackboard so here I will be writing
down uh the whatever basically thing I
need to explain you and in between I
will be using the ppds and all so first
of all let me go through this particular
PP and here you can see so uh I have
written some sort of a name uh so in the
generative AI whenever we are talking
about the generative AI or a large
language model so couple of name are
very famous nowadays and in in those
name actually this chat GPT is a uh like
very very famous so here I have written
this chat GPT it's a product of the open
AI as we know about this Chad GPT
everyone knows about the chat GPT yes or
no I think yes now if we talking about
this Google bar so it's a product of the
Google and we talking about this meta
llm 2 so this meta llm 2 it's a product
of the Facebook got it guys yes or no so
yes uh nowadays actually everyone using
this chat GPT Google B meta lm2 is it
it's also a platform similar to this
chat GPT uh where you can uh chat or
where you can ask a specific question
which you uh which you do in a chat GPD
itself So Meta lm2 it's a a model from
the Facebook site now here guys if we
are talking about the generative AI or
we are talking about the large language
model so in our mind the first image
which comes into the picture that is a
chat GPT Google B and meta llm 2 yes or
no tell me guys yes because of that only
uh because of this chat GPT Google B and
like the other the different like
whatever application you are seeing
nowadays right so mid journey is one of
the application or maybe Delhi uh or
different different application because
of that only I think you are learning
this uh particular uh thing this
particular course this generative AI
course yes or
no yes so but guys this generative AI is
having their own Roots it's not all
about the chat jpt Google B and some
other uh application which you are
seeing chat jpt is just a application of
this generative AI chat GPT or this
Google B is just a application of this
uh like llm large language model
basically we are using this large
language model in a back end U like
whatever application you are seeing like
chat GPT and all in the back end but
apart from this this generative Ai and
this llm is having their own Roots so
first of all what I will do I will
explain you the concept of the uh like
first of all I will uh start from the
deep learning itself means I need to
explain you few uh terms and terminology
regarding this deep learning so let me
uh back to the Blackboard so there I
will be talking about the basics of the
deep learning So within uh 5 to 10
minutes I will be discussing the types
of the neural network and all and then I
will directly move to the uh like LMS
and this uh genem so here guys uh you
can see uh what I can do I can uh draw
one box over here so this is the uh you
can think this is what this is the
neural uh uh basically if we are talking
about the okay so first of all let me
start from the deep learning itself so
uh if we talking about a deep learning
so uh we can uh divide this deep
learning into three major segments so
let me write it down over here this a
deep
learning so guys this deep learning
actually we can divide into three major
topic so the first topic actually which
is called artificial neural
network artificial neural network netork
the second topic is called convolution
neural network
CNN the third one basically which is
called recurrent neural network so we
have a three types of the neural network
and we can divide this a deep learning
into this three major section apart from
this you will find out other uh like
topics as well so let me write down
those uh thing over here so the fourth
one uh which I can write it down over
here that is a uh reinforcement learning
and uh the fifth one we generally talk
about it uh so that is what that is a
gain so this gain also it comes under
this generative AI I will talk about it
I will talk about this game I will like
give you the glimpse of this uh
generative advisal Network that what is
this and how the architectures look like
of this gains and why I'm saying that
this gains comes into the generative AI
so if we talking about thisn so let me
draw the box now so if we are talking
about this n so here guys see we have an
input layer inside this Ann actually
what we have we have a input layer and
uh you will find out the output layer
and in between actually in between this
input and output we have a hidden layers
so just a wait now over here guys see we
have a input layer and we have a output
layer now in between actually you will
find out a hidden layers various hidden
layer so let me write it down over here
input and here you'll find out the
output now here in between this input
and output you will find out of various
hidden layers so let me write it down
the hidden over here so this hidden
layer actually it is nothing it's a
hyper parameter so we can have as many
as hid layer we can have as many as node
inside the hidden layer we all know
about the artificial neural network I'm
assuming that thing now if we talking
about this uh CNN actually so the CNN is
nothing so in the CNN uh one more thing
you will find out in terms of this CNN
that is what that is a convolution we
always perform the convolution in terms
of this CNN so here if we are talking
about this enn so uh we are using the uh
like structure data where we have a like
different different features numeric
feature or categorical feature and uh we
try to solve the regression and
classification related problem but
whenever we are talking about this CNN
so here uh the CNN actually specifically
we use for the image uh related data
image or video related data you can say
that uh we use the CNN and all for the
grid type of data okay so we use the CNN
for the grid type of data and there uh
like you will find out one more
component that is what that is a
convolution so here uh let me write it
down so the component name is what
component name is a convolution so in
the convolution actually you will find
out a various step so uh we have a
various step in the convolution itself
so the very first step which we perform
what we do guys tell me we perform the
feature X section by using a different
different filter after that what we do
we perform the pooling and then we
flatten the layer so there are different
different like uh uh steps you will find
out inside the convolution itself and
after that what we do we apply the fully
connected layer so that is nothing that
is my Ann itself so over here I can
write it down we have this convolution
and we have a artificial neural network
so this is my first architecture which
is a like uh which is the Ann itself and
and this is my second one that is what
that is a CNN now if we talking about
the third one which is a very very
interesting that is called recurrent
neural network that is called recurrent
neural network so this enn we generally
use for the structured data where we
have a numerical column or categorical
column and in the Target column like it
will be a numeric or categorical one and
based on that basically we are going to
decide whether it will be a
classification problem or a regression
problem now if we talking about this CNN
so already I told you if you're talking
about this RNN so the name is what the
full form what the full form is the
recurrent neural network so this RNN
actually we are using for the sequence
related data so wherever we have a
sequence wherever we have a sequence so
this RNN we used for the sequence
related data now let me do one thing let
me draw the architecture of this RNN so
over here guys in the RNN what you will
find out so let's say this is my uh box
and here is what here is my input so
this is what guys tell me this is my
input now here is what here is my output
so let me draw the output one more time
this is what this is my output got it
now here guys see uh this is my input
this is my output and this is what this
is my hidden layer now in the hidden
layer actually you will find out one
thing one concept and the concept is
nothing the concept is called a feedback
loop okay so whatever output I'm getting
from the hidden layer actually again we
are passing that output to hidden layer
until the entire time stem so that thing
actually uh we learn or we learn in in
the RN itself actually this RNN is
nothing it's a special type of neural
network and there you will find out the
feedback loop feedback loop means what
so whatever output we are getting from
the hidden layer again we are passing
the same output to the hidden layer
until we are not going to complete the
entire time stem that is what that is
the RNN now uh you are uh we are talking
about the llm so why we are uh why I'm
discussing this RNN and all because this
llm actually somehow it is connected to
this RNN itself before starting with a
llm a large language model we'll have to
understand the concept of the RNN lstm
attention uh like encoder decoder and
then attention self attention and all so
here I'm not going to discuss in a very
detailed way I'm just giving you the
glimpse of that that what is a like RNN
what is the lstm what the Gru and then
what was the sequence to sequence
mapping and where this attention comes
into a picture then how they have
invented the self attention then how
they started the using this transfer
learning and this finetuning in terms of
this uh in terms of this large language
model why we are calling it is a large
language model why we are not calling it
a model okay so each and everything
we'll try to discuss now uh you all know
about this uh reinforcement learning and
all so in the reinforcement learning uh
you will find out one agent environment
regarding that particular agent you will
find out a different different state
getting my point and then you will find
out the feedback so that actually it
comes inside the reinforcement learning
and that is also part of the deep
learning only now if we are talking
about gain so gain is uh nothing
actually so in the gain again you will
find out a neural network uh which we
are using for generating a data and that
also comes in under inside the
generative Ai and we have a different
different types of game so first of all
tell me guys uh this uh uh like types of
the neural network this is clear to all
of you please do let me know in the chat
if uh this thing is clear then uh I will
proceed with the next
topic use cases wise I will come to the
use case and I will uh try to discuss a
different different use case I will come
to the use case then I will tell you the
applications of that and then I will
come to the domains as well then in what
all domains you can apply those use
cases so don't worry each and everything
we'll try to discuss over here
yes I will directly come to the
generative a itself but before that I
will give you the timeline don't worry
from Tomorrow onwards I'm going to be
start uh I'm going to start from the uh
like uh from the open ey itself uh like
complete practical and all so no need to
worry about it s Prasad I think you got
your
answer
I think uh this basic introduction is
clear
now yes coming to the generative only
don't
worry yeah it's going to end to end uh
we'll try to discuss end to end thing
don't worry about
it if you have any questions and all so
you can directly ping into the chat
uh so I will reply to you don't
worry okay so I think now we can proceed
so guys here uh in the uh PP itself I
was talking about the generative AI then
I given you the uh like uh uh the types
of the neural network and I just explain
you the uh like the regarding the
artificial neural network and the CNN
and this RNN so here in the generative
AI uh you'll find out that I have like
included a few slides and all so let's
try to understand a few uh thing from
here and then again we'll go back to the
uh the Blackboard and then I will try to
discuss few more concept so over here uh
we have seen the chat GPT like I was
talking about the different different
application like chat GPT Google B and
metm and all now let's talk about the
generative AI that what is a generative
AI now here you can see the definition
of the generative AI uh which I have
written over here uh that is what that a
generative AI generate new data based on
a training sample right so the name is
uh the name is self-explanatory right so
the name is explaining everything
generative AI the AI which is generating
something now what all thing we can
generate so here if we are talking about
the generative AI so you can generate
images you can generate text you can
generate audios you can generate videos
as a output you can generate anything uh
so uh this image text audio video it's
nothing it's a type of the unstructured
data and definitely it is possible by
using the generated AI we can uh
generate this type of data by using the
generative AI now if we are talking
about the generative AI so uh as I told
you that it is having their own Roots
okay so it is having their own roots and
if we are going to divide this
generative AI so we can divide into two
segment so the first segment is called
generative image model and the second
segment is called generative language
model and this llm actually it falls
into this particular segment into this
generative language
model are you getting my point yes or no
I think yes so if we talking about this
generative image model so I told you
when I I was talking about the Deep
learning uh like Ann RNN and CNN
reinforcement learning and there was a
gain so initially we were using the gain
for generating a data so let me show you
the architecture of the gain so the how
the architecture of the game looks like
so with that you will get some sort of
idea in the game we are using this uh
neural network only so let me show you
the architecture of the game so let me
search it over here over the Google game
architecture now uh here in the image uh
let me open the architecture of the game
so here guys uh just see so in the gain
actually we have two main components so
the first component is a generator this
is what this is a generator okay so uh I
think this is visible to all of you this
is what this is a generator and here you
will find out discriminator so this
generator and discriminator is nothing
it's a neural network so we are passing
this real data so here basically what we
are going to do we are going to pass a
real data and here we have a generator
which is generating some sort of a uh
like synthetic data and here we have a
discriminator based on that we are going
to discriminate between real data and
the synthetic data so this is the
architecture of the game and inside this
architecture you will find out we are
using two main thing we are using two
main component the first one is
generator and the second component is a
discriminator I think you're getting my
point and this generator and
discriminator is nothing it's a neural
network got it so this is also comes
under this generative AI so now let me
show you this generative AI now over
here I have written two points
generative image model and generative
language model so if you're talking
about generative image model so in our
previous days in our back back days
actually in our old days in 2019 18 so
this gain was very popular for
generating a data again uh this gain is
very uh like EXP uh like expensive in uh
terms of computation power and all so it
is very like very much expens uh like
expensive in terms of like uh
computation uh so over here you can see
so we were using this gain uh we were
using this gain for generating images
and all in our back days in 2018 and in
2019 and it was very very popular and we
have a different different uh variants
of the Gams if you'll find out the type
of the gain you will find out many types
now uh recently actually you will you
have find out the trend of the llm large
language model now guys here uh we are
uh we are talking about the game and
then uh this gain basically it was the
old concept it is a old concept
basically and there are different
different variants of the gain as well
now over here if we are talking about
this large language model so it become
very famous from the Transformer I will
come to the Transformer I will tell you
the complete history of the Transformer
as well now uh this image model and this
language model
but a recent days in a recent days what
I have seen in terms of this llm and all
even we can generate the images by using
this llm we got those llm basically
which is like that much powerful so by
using those particular llm we can
generate generat images as well okay so
we I will show you couple of models and
all uh regarding this uh like image
generation and definitely you will get
some sort of idea that how the uh those
part particular alms is working in terms
of image generation I can give you a
couple of example uh like Delhi so Delhi
is a example you can uh check over the
open a which is a model which is like a
uh like a famous for the image
generation now here uh if we are talking
about this image model so actually see
this image model basically it was
working for image to image Generation
image to image generation now this
generative model actually so if we are
talking about this generative model it
is working Tech uh it is working in
terms of text to image generation text
to image generation and text to text
generation so this two tasks definitely
we can perform by using this llm model
and this image to image generation
before we were doing it by using this
gain model in 2018 and in 2019 now uh as
I told you that we have those powerful
model in our recent Days by using those
particular model definitely we can
Implement image to image generation as
well that is also possible so uh
regarding that uh definitely I will show
you couple of model so we are having
four tasks here I have written it now
let me move to the next slide and let me
show you that what I have so here guys
you can see uh this cat is representing
a genitive model where you are giving a
prompt uh means where you are giving a
question and uh as a response U again as
a output basically you are getting a
response so in terms of uh see here we
are talking about generative model I'm
not talking about specifically this El M
okay so I told you this uh generative
model actually uh you can think it's a
super set this generative Ai and under
this generative AI you will find out
this llm and gang is also part of the
generative AI getting my point I think
this thing is getting clear so over here
we are talking about the generative
model so we are giving a input and we
are getting a like output now
specifically if I'm talking about
regarding this llm regarding this large
language model so this input actually
this is called input prompt and the
output actually it is called output
prompt so this cat you can imagine as a
generative model or as a llm model so
what we are passing as a input we are
passing input prompt and we are getting
as a output output prompt so this prompt
term is a very very important I think
you have heard about this uh prompt
engineering and all that uh uh like uh
prompt engineer is getting this much
that much and this prompt engineer plays
a very important role if uh we have to
design any sort of of a prompt now uh
different different types of prompt of
like zero short prompt few short prompt
few short learning and all we'll talk
about it as I will progress with the
like implementation and all in between I
will give you like idea regarding each
and everything now over here guys you
can see uh where this generative AI
exist so if you will look into the uh
look into through this particular slide
so here you will find out this
generative AI actually it lies inside
the Deep learning getting my point so
the generative AI actually it uh like
reside inside the Deep learning uh
initially only I have explained you that
uh we have a different different types
of neural network and it's a part of the
deep learning only now whether we are
going to generate an images by using the
llm or by using the gains or whether I'm
going to perform text to text generation
text to image generation or image to
text Generation by using the llm both
lies inside this generative Ai and this
generative AI is a part of the it's a
part of the tell me it's a part of the
deep learning now over here guys I have
written a couple of more slid so I will
try to explain you uh but first of all
let me give you the timeline of the llm
and then I specifically I will come to
the llm and all and I will be talking
about this discriminative Ai and the
generative AI as well so tell me guys uh
this part is clear are we going good are
you able to understand whatever I'm
explaining to all of you so if you are
getting it so please write down the chat
and you can ask me the questions as
well
if you have any uh type of Doubt or U
like if you're getting it or not getting
it whatever you can ask me in the chat
uh like chat section uh I will reply to
your questions
no reinforcement learning is not
required uh uh specifically we should
not go for the reinforcement learning
and
all yes this is a part of the uh like
this Genera way is a part of the deep
learning right
right yes llm model used in a generative
AI correct you got it uh
guys mathematical intuition so we will
talk about the mathematical intuition
and all but this uh more uh this course
this comp session is it is more focusing
on the applied side so I will create a
various application in between whatever
math iCal concept and all will be
required I will let you know that don't
worry great so I think uh people are
getting it and uh they are trying to
understand fine so whatever I have
explained you let me explain you the
like Blackboard uh and then again I will
come to this PP and we'll try to uh wrap
up the theoretical stuff and U then I
will explain you the applications and
all so over here guys see I was talking
about this Uhn CNN RNN RL and G now I
started from the generative AI itself so
I have started from the generative Ai
and I told you this generative AI is
nothing you can consider it as a super
set as a super set now inside this
generative AI you will find out many uh
like uh many uh concept many topics and
all so here uh regarding the generative
AI there is uh two main thing which you
will find out the first one is
gain gain that is a generative aders
Network the second is what
llms llms large language model now we
have a various task so here let me write
down the task as well so the task wise
so here I told you the different
different task basically so the first
task which I can write it down over here
that is a image to image Generation
image to image
generation now the second task was the
uh image to text uh text to text
generation text to text generation text
to text generation now the third task
was
the uh image to text
Generation image to text
generation and the fourth one was
the uh image to image generation sorry
uh text to text Generation image to text
and text to image generation so let me
write it down over here text to image
generation text to image
generation now if we are talking about
this image to image generation yes we
were able to do this particular thing by
using this
gain we have seen the gains now we are
talking about this text to text
generation yes it was possible by using
the lstm RNN and the uh different
different by using the different
different model as well but yeah this
text to text generation actually
nowadays you are seeing uh we are
preferring this large language model for
this text to text generation and you
this chat GPT is a biggest application
uh biggest like example for that the
chat GPD which we are seeing image to
text generation yes uh this is also
possible by using a different different
model like RNN lstm and Gru image
captioning if you have if you uh if you
have heard about this uh like image
capturing task so that is also possible
uh by using this uh like uh classical
model but yeah by using this llm also we
can perform it we can uh do it now if we
are talking about this uh text to image
generation so yes uh this type of task
nowadays it is possible by using the uh
llm so yes yes uh llm is able to do llm
is able to perform a various amount of
task uh whether it's a homogeneous or
it's a hetrogeneous now uh I was talking
about the uh llm uh sorry I was talking
about this generative AI so where it
exists so this generative AI actually it
exists uh in a u like a deep learning
itself so you can think that AI is a
superet machine learning is a subset
deep learning again is a subset of the
machine learning and this generative AI
is a subset of the deep learning because
as I already told you we have a
different different uh like other neural
network also in a uh like a deep
learning and this CNN is one of them
this a convolution neural network okay
so I think this part is clear to all of
you now let me draw the architecture uh
that where this uh generative AI exists
so you can think this is what this is my
AI this is one uh this is the like a
super set now here this is what this is
my machine learning this one now uh
inside that you will find out the uh
deep learning and inside the Deep
learning you will find out this
generative AI uh so let me take a
different color over here uh let me take
uh this color so here you will find out
the generative AI so this is what this
four circle is what this is the
generative AI got it now here uh you can
see why we are saying so why we are
saying this is a like a subset so I
think each and every explanation I have
given you over here uh you can uh prefer
this uh like a this particular slide
that why I'm saying this generative AI
is a subset of the deep learning so let
me write it down over here this is what
this is nothing this is a gen Ai and
it's a subset of the deep learning now
guys let me explain you the timeline of
the uh this llm so uh now you got it
that this uh llm is nothing it's a part
of the generative a itself this large
language model now let me talk about the
complete timeline of this large language
model so how it evaluate and uh uh I can
like talk about the complete history of
it and uh here guys you can see that
first I was talking about the RNN so as
you know that uh what is the RNN tell me
RNN is nothing it's a type of the neural
network it's a type of the neural
network so uh there basically we have a
feedback loop again we can pass the
information to our H layer now you will
find out a different different types of
RNN or some Advanced architecture in
terms of this RNN itself El the second
uh like thing which is a type of the RN
itself that is called lstm
lstm right so in the lstm actually uh if
we are talking about this lstm so here
you will find out the concept of the
cell state so in the RNN we just have a
Time stem and it is for the shortterm
memory it is for the shortterm
memory we cannot retain a longer
sentences by using this RNN it is not
not possible if our sentence is a very
very huge or it's a very very long so we
cannot retain that particular sentence
by using this RNN but if we are talking
about this lstm yes we can do it by
using this
lstm so in this lstm you will find out
the concept of the cell state so uh this
uh lstm is nothing it is for the
short-term dependency and it is for the
long-term dependency also it is for the
short like a memory short-term memory
and is for the long-term memory as well
if you look into the architecture of the
lstm so you will find out along with
this uh time stem so here we have the
time stem U like it's a hidden State
actually uh like on a different
different time stem along with that
you'll find out one cell state so it is
going to retain it is going to retain
the long-term dependency and in between
in this a time stamp in this short-term
memory and in this cell State you will
find out a connection the connection in
terms of gates so here you will find out
one connection uh like uh one gate
basically that is called forget gate so
here I can write down the forget gate
now here you will find out one more gate
actually so that is called input gate
here you are passing the input now here
you will find out one more gate over
here that is called output gate output
gate okay so we have three gates inside
the lstm for sustaining a long-term
dependency or for reminding a longterm
uh long sentences now uh you will find
out one more updated version of the lstm
so this RNN is a old thing this lstm is
also old thing now you will find out one
more updated version of the lstm that is
what that is a GRU so this Gru actually
they have invented in
2014 and they had they took the
inspiration from the lstm itself now
inside this Gru you won't find out the
concept of the cell State everything is
being done by the hidden State itself
and here basically in the gru we just
have two gate update gate sorry reset
gate and update gate and it's a uh Advan
or you can say it's a updation on top of
this lstm it's a updated version of the
uh like lstm itself now what is the full
form of the gru G and recurrent unit now
over here guys see this was the three
architecture which was very very famous
during 2018 and 19 in our old days now
here see uh one concept comes into the
picture if we are talking about this RNN
lstm and Gru so by using this particular
architecture what we are doing so by
using this particular architecture we
are going to process a sequence data yes
or no we are going to process a sequence
data now here one concept comes into a
picture sequence to sequence mapping and
for that only we are using this
particular architecture so we have a
different different type of uh like a
mapping technique so let me write it
down over here uh different different
type of mapping technique
uh now it is fine uh I think I'm audible
to everyone
now now I am audible guys please do
confirm in the chat I think there were
the issue from the mic side
now I'm audible so please do confirm in
the chat if I'm audible then and uh is
there any Eco or uh what
so guys are you facing any Eco in my
voice now it is
fine yeah it is perfect I
think great fine fine fine uh it's
clear great uh I think now I am audible
to everyone sorry I think there was a
issue from
the do let me know in the chat uh from
where I lost my
voice so this concept is clear this one
to many or one to one one to many many
to one many to
many
[Music]
yeah so I think uh I was there RNN lstm
and Gru now I think it is fine I'm
audible to everyone great so I was
talking about RNN lstm Gru and then U I
talked about the different different
mapping sequen
now uh this mapping sequences actually
we can Implement by using this uh RNN
lstm and
Gru so over here uh yes so 1 to 1 one to
many many to one many to many RN and LSM
and Gru this was the sequences actually
I was talking about now in 2014 actually
see this was the sequences by uh we can
Implement by using this different
different models getting my point now
over here uh if we talking about this
particular sequences definitely we can
uh like uh per we can uh create a
various uh application by using this
model but here basically we are having
some sort of a restriction uh as I told
you the different different application
like one to many many to one so many to
one means uh you can think that
sentiment analysis one to one to many
means what one to many you can say image
capturing many to many image uh sorry uh
language translation so there are
various application of the sequences now
see uh we are talking about the
sequences uh the sequence to sequence
mapping now uh we can definitely
implement it by using this particular
architecture so the problem we were
having the problem was actually uh we
cannot see let's say we are giving an
input in the input actually we have a
five words so whatever output we'll be
getting in the output also we should
have a five words
so it's a fixed length input and
output getting my point what I'm saying
so by using this particular mapping 1 to
one many to one or like many to many
specifically we are talking about many
to many so there was some problem there
was some issue the issue was fixed
length input and output so whatever
number of inputs we are passing in terms
of this many too many I'm talking about
okay so whatever number of inputs we are
passing so those many output on we can
get it over here in the output itself so
uh here actually one a research paper
came into the picture in 2014 you can
search about uh the research paper
sequence to sequence learning so inside
that uh paper they have introduced the
concept of the encoder and decoder in
the encoder and decoder actually the one
segment the one segment was the encoder
segment segment so let me uh draw it
over here so the one segment was the
encoder segment and the another segment
was the decoder segment this another
segment was the decoder segment and in
between actually in between we were
having in between actually we are having
the context Vector so here uh in between
this encoder so we are having the
encoder and we are having the decoder
decoder one part was the encoder and one
part was the decoder and in between we
having the context Vector means whatever
information was there whatever
information was there from encoder to
decoder we are passing through this
context Vector means we are wrapping all
the information in this context vector
and we are passing to the
decoder that actually the paper uh has
been published in 2014 you can search
about it you can search over the Google
sequence to sequence learning so let me
uh search in front of you only now over
here I can write it down sequence to to
sequence
learning research paper now uh over here
guys you will find out this uh
particular research paper now just try
to read this paper now here in this
particular paper they have clarify the
issue that what was the issue with the
classical mapping so that was restricted
to the input and output now over here
you if you will read this particular
research paper so easily you can find it
out the issue here itself in the
like introduction itself they have
mentioned they have mentioned this uh
despite their flexibility and power can
only be applied problem who inputs and
targets can be sensibly encoded with the
vector of fixed dimensionality it was
just for the fixed dimensionality and
basically there was we were having a
limitations so for solving that
particular limitation this a sequence to
sequence learning paper came into the
picture and there was three person Ilia
sasar and orol and this there was one
more person and this paper from the
Google side now here guys uh let me open
this uh Blackboard again so there was a
context Vector but this uh encoder and
decoder also was not able to uh perform
well for the long uh longer sentences so
here in the research basically they have
proved if my sentence is going uh is
going uh like above from 30 to 50 words
right if it is longer than 30 to 50
words so in that case it was not able to
sustain the context it was not able to
sustain the context if we are using this
encoder decoder architecture now you
will ask me sun what we were having
inside the encoder and decoder so we are
talking about the encoder so again here
we were using the either RNN lstm or uh
lstm and we were using this Gru and here
also in the decoder also we are using
this rnl we are using the lstm and we
were using this
Gru got
it I think you got the problem now and
you got to know about the encoder and
decoder so we have started from the RNN
then now we came to the lsdm Gru and
then we have a different different
mapping and for solving this particular
issue which is related to this many to
many uh like uh mapping many to many
sequence mapping and this uh uh this
language translation is one of the
example if you will search over the
Google translate uh just search over
there anything let's say in the in H you
are saying that or whatsoever so it will
generate output so this input word and
output word will would be a mismatch but
that was a restriction with this uh like
with the classical mapping so for using
this encoder and decoder architecture we
can solve that particular problem now
here also we are having the issue that
we cannot proceed a longer
sentences we cannot proceed a longer
sentences so here One More Concept comes
into a picture inside this context
itself and that was the
attention that was the attention so uh
here neural translation
with just a second let me search about
the neural trans TR a NS relation with
attention yes this was the paper and uh
this was the first paper let me search
about the research paper yeah now guys
uh this was the paper in this particular
paper they have introduced the concept
of the attention and just try to
download it you need to download this
particular paper and uh then you can see
there so just a second let me show you
this paper as well and this is the main
uh like main papers uh basically which
you will find out uh while you will be
learning this deep learning and all so
this paper actually this has been
introduced in
2015 I think in 2015 or 16 now here they
have introduced the concept of the uh
attention actually so just try to read
uh this particular paper at least try to
read the introduction of it uh there we
have uh there they have defined that uh
what was a problem with the encoder and
decoder and where this attention comes
into the picture and what is the actual
meaning of the attention they have
introduced each and everything over here
inside this particular paper inside this
particular paper they have introduced
each and everything regarding the
attention see this is the architecture
of the attention model and uh before
going through with any blog any website
or any tutorial try to uh go through
with the research paper and try to
understand the motive of that research
paper now see guys uh here I'm not going
into the detail of the attention because
this attention itself uh is a longer
topic but I can uh like give you the
glimpse of that that uh uh what what
they were doing in the attention so they
were mapping so let's say we have a five
words in the sentence so they were
trying to map each word whatever word we
have a input we were trying to match
each each input word with the output
word means this input and output this
encoder and decoder if we are talking
about this decoder actually so this is
having the uh information each and every
information of the Hidden State whatever
like in the encoder like you will find
out this RNN lstm or whether it's a GRU
so uh we have a hidden State actually
right so uh this decoder part is having
the information regarding those
particular hidden State all the hidden
State and because of that it was able to
uh it was able to predict so whatever
like sentence and whatever words or
longer sentences or like U like uh the
longer sentences and all which uh
whatever basically we were passing it
was able to predict okay so this word is
related to that particular sentence so
what I will do I will create a like a
one dedicated video on top of it there I
will try to discuss uh this attention
mechanism but yeah here I'm just giving
you the timeline U and with that um you
can clearly understand so uh here we
were having the attention mechanism now
guys by using this attention mechanism
by using this attention mechanism in
2018 Google again Google published one
research paper and the research paper
name was
attention about this encoder in the
encoder and this decoder we were using
what we were using guys tell me we were
using this LSM either we are using the
lstm RNN or maybe Gru now uh there also
we are having the lstm maybe RNN or
maybe you are having the Gru and uh if
we are talking about the attention so
whatever uh information we are passing
from here to here so you are having the
context Vector context Vector now on top
of that we are having the attention
layer attention layer and it was nothing
it was just a mapping from input words
to out output word now here actually
they have published one paper in 2018
and the paper name was attention all
your need attention all your need now
this paper actually it was a
breakthrough in the NLP history this
paper has been published in
2018 and here
actually
decoder but there is one uh there is one
thing basically in terms of this encod
and decoder you won't be able to find
out this lstm RNN and Gru they are not
using any RNN cell any lstm cell or any
Gru cell so here actually they were
using something else and here the what
is a uh name of the research paper so
they were saying that attention all your
need only attention is required for
generating us let's say we are passing
any sort of an input means any longer
input so from that particular input only
attention is required for generating
output now how let me show you
that this Transformer architecture or
let me show you the attention all your
need research paper so attention all
your need research paper so guys this is
a very uh prestigious paper in our NLP
history and uh this changed the complete
history of the NLP and whatever llm and
all whatever you are seeing like
nowadays so they have used this
Transformer architecture as a base model
I will come to that and there I will try
to uh discuss that uh what is the
encoder and decoder again I'm not going
into the depth of the mathematics but
yeah definitely I will try to give you
some sort of a glimpse so over here uh
let me zoom in first of all this paper
and and here guys the paper name was
attention is all your need so this was
the researcher asish Nome Nikki Jacob
you can uh search about these particular
people and here is the abstract uh you
can see and this is the introduction at
least try to read the introduction try
to read this particular background and
the model architecture so this was the
model architecture which has been
introduced by the uh by the Google
researcher and the architecture
basically which you will find out inside
this research paper I think everywhere
you will find out this uh this
particular architecture in uh whatever
NLP tutorial or if you are going to
understand the attention mechanism and
all so this is the architecture now in
this particular architecture let's try
to understand that what all things we
have so see first of all we have a
input okay try try to understand try to
focus over here so we have a input over
here then we have a input embedding so
this is my first thing input and this is
what this is the input embedding the
third thing which we have that is a
positional encoding getting my point and
then after that you will find out the
multi-headed attention then we have a
normal uh normalization and all and then
we have a feed forward Network now guys
just tell me this is what this is a
encoder part this is what this is a
encoder part and this is what guys this
is this is a decoder part this is the
decoder part got it getting my point so
here also we have a two segment first
was the encoder and the second was the
decoder but here we are not using any
RNN cell lstm cell or maybe Gru cell
here actually we are using something
else some other concept and the concept
actually I think this is not a new thing
for you this embedding and all uh this
embedding attention already I talked
about the attention that what it is
mathematically it is having a like uh
like a some different explanation but
yeah I think you got to know the idea
now here we have a feed forward neural
network you know like what is a like
artificial neural network what is a feed
forward neural network so it's not a
like a new thing for all of you and by
assembling all those thing they have
created one cell one architecture and
the name is called this uh Transformer
so this architecture itself is called a
Transformer what is this guys tell me
this is a Transformer now here guys just
see uh this uh Transformer if we are
talking about this Transformer and all
so let me uh tell you few things
regarding this Transformer uh so first
of all guys this is a uh fast compared
to the classical architecture if we are
talking about this RNN lstm and all so
there we are passing the input based on
a Time stem based on a Time stem but if
we are talking about this Transformer
guys so here what is the importance or
what is the like plus point which we
have inside the Transformer it is a
faster why because we can pass the input
in a parallel manner we can pass all the
inputs all the tokens in a parallel
manner in a parall actually we can pass
the input now over here see we have a
input embedding we are doing an
embedding over here and then we have a
positional encoding means we are
arranging a sequence sequence of the
sentence then we have a multi-headed
attention again we are trying to uh
figure out the uh meaning see let's say
uh the sentence is what I am Sunny now
uh here it is trying to find out the
relation I with M and sunny is trying to
find out the relation M with uh this I
and sunny it's time to find out a
relation this sunny uh and this m and
this I so it is trying to find out a
relation with each and every word so it
is doing the same thing inside the
multi-headed attention then you will
find out this feed forward Network
neural network actually and yes uh this
is what this is my encoder part as I
told you this is what this is my encoder
part now if you will look into the
decoder side so again we have a same
thing so here we have a outputed output
embedding means in uh uh like whatever
uh like a sequence uh in whatever like U
am format I want output so that is uh
this particular thing this output Ting
and then again we have a like
multi-headed attention and we are
passing this thing uh to the next one to
the next layer and again we have a feed
forward neural network over here on top
of this you will find out the soft Max
and finally we are getting a output
output probability so don't worry I will
try to discuss this Transformer
architecture mathematically in a
detailed way in some other video but as
of now I'm just giving you the GL
Glimpse because whatever llms we are
going to discuss
okay as a base architecture they are
using this
Transformer so guys until here
everything is fine everything is clear
please do let me know in the chat yes or
no yes you can uh let me know in the
chat uh then I will proceed with the pp
and all and uh we'll try to wrap up the
uh introduction of this llm and all and
in tomorrow's session we'll try to talk
about the open a and we'll discuss about
the open API and all and a different
different models of the
openi any doubt anything so if you have
any sort of a doubt please do let me
know guys please do let me know in the
chat uh I will try to clarify that uh
those doubt and
uh
so did you get a timeline timeline of
the llm I will come to the llm now the
specific word and
uh after deep learning an NLP what is
the topic uh for generative AI please
give up uh so after the Deep learning
and see after the Transformer actually
by using this particular Transformer
people has created a different different
llms and all large language model now I
will come to that by using the slide I
will try to show you that
I think this
is pry much clear now let me go back to
this uh uh notes and here you can see so
I started from the deep learning then
generative VI and all then you got to
know that where generative a lies then
Alm Gru different different mapping
encoder decoder attention and finally
attention all your need now let's try to
understand uh like rest of the thing by
using the slide so here guys uh one more
thing I think we were uh trying to
understand this particular part where
this generative AI exists and I hope you
got a clearcut idea now let me go back
to the uh let me like come to the next
slide so in this slide you can see uh
I'm talking about the generative versus
discriminative model so what is the
difference between this generative and
discriminative model so we are talking
about this discriminative model so
whatever you have learned so far in a
classical machine learning and deep
learning so uh let's say uh I'm I'm
talking about this uh any classification
based model let's say I'm talking about
this uh RNN so here actually see uh you
are training your model on a specific
data so this is your data this is your
input and here is your output what you
are doing guys tell me you are
performing a supervised learning you are
performing a supervised learning by
using this recurrent neural network
there is a classical model or we have
like other classical model and all you
can use any uh uh like a machine
learning based model as well like na
buers and uh different different
variants of the nap bias or maybe some
other model you can uh use that
particular model also uh so over here we
have a model and we are going to train
this model by using the supervis machine
learning there we are going to pass a
specific type of data to this particular
model and here we have a different
different output like a rock this music
is belong to the rock music classical
music or maybe ranting so here we are
passing this uh like music to my model
and finally it is going to predict
something like that this is a
descriptive model now if we are talking
about a generative model so this is a
little different compared to this
discriminative model how it is different
uh compared to this discriminative model
so here guys see we are training this
see first of all the if we are talking
about the generative model if we talking
about the generative model so the
training process is a little different
if we are talking about the large
language model if we are talking about
the llms so uh the proc of training this
llms is a little different compared to
this discriminative model now over here
we are talking this discri this
generative model basically so we are
passing the input to this generative
model and we are getting an output how
how so here basically we have a
different different step for Gen for
like training this generative models so
gain wise I already told you that what
is a like process if you want to like
train uh any gain model if we are
talking about llm large language model
so at the first first place there will
be unsupervised learning unsupervised
learning then at the second place we'll
be having a supervised fine-tuning and
at the third place uh basically we have
a reinforcement learning reinforcement
learning they have recently used inside
the chat uh in the GPD model itself uh
which we are using for the chat GPD but
before that whatever llm model they have
created they have created they have
trained on a large amount of data so for
that first they have performed the
unsupervised learning and then they have
performed the supervised fine tuning
so because of that that model were able
to understand each and every pattern
which was there inside the data and
because of that it was able to generate
the output so this generative model is
nothing in that basically we have a data
on top of that particular data we are
training a model and for that we have a
various step and uh basically then only
we are going to do a prediction so what
it is giving me as a prediction so
whatever input we are passing so that
input it is taking and finally it is
generating uh the output related to that
particular input means it is generating
a new
data getting my point I think this part
is clear to all of you how this
generative model is different from this
discriminative model discrimin model is
a classical model like supervised
learning uh we are performing The
supervis Learning now right so here we
are having the RNN and we are passing a
data and all and we are trying to train
it generative model various step we have
like for the training and all and it is
responsible for generating a new new
data that's it so I hope guys this uh
thing is clear to all of you now I have
kept couple of more slide regarding uh
this particular concept just try to note
down the uh the headings and all and try
to remind uh this particular thing this
discriminative versus generative model
and all now here uh the same thing
unsupervised supervised learning which
is related to this uh discr model got it
and here uh you can see uh this is the
generative like model so in the
generative model what we do first we
perform the unsupervised learning we are
doing a grouping and all and then we
discri we perform the supervised
finetuning supervised learning so that
is a like process for training a uh like
any sort of a llm model which comes
under inside the generative AI itself
and again wise I already talked about it
now here actually uh we're going to talk
about this uh llm so let me give you the
quick idea about this llm and all that
is what that is a large language model
so for that all Al I have created one
slide and there specifically I kept the
thing related to this uh llms only so
let me start from the very first slide
uh let me give you the overview and uh
from tomorrow uh actually in tomorrow
session I will give you the detail uh
like overview uh with respect to
different different models and all
whatever we have as of now just a quick
introduction now what is the llm so llm
is nothing it's a model it's a large
language model which is trained uh like
U it's a large deep uh it's a large
language model which has been trained or
a huge amount of data and it is behaving
like it is generating something right so
actually by using this uh llm we can
generate any uh like a sort of a data
like Text data or maybe image data and
that is a like uh that is a advantage or
that is a like uh uh one uh very uh like
a very famous uh thing regarding this
llm and all now if we are talking about
this why this is called llm why this is
called large language model so here guys
if we are talking about this large
language model so because of the size
and the complexity so here specifically
I have mentioned regarding this large
language model regarding this llm why
this is called this uh this large
language model so here because of the
size and because of the complexity of
the neural network uh neural network
neural network as well as the size of
the data set uh which has has been uh
which is trained on actually this is
trained on the huge amounts of data
because of that only actually it is
called a large language model so here uh
if we are talking about this uh L large
language model so uh actually before we
were not having the huge amount of data
so uh recently actually uh you know uh
this uh data generation and all uh Big
Data actually came into the picture and
this companies and all generated a huge
amount of data and this Google also
Google Facebook and the other companies
is having a huge amount of data so uh
they uh they are able to like find uh
means uh actually they have uh gathered
that particular data and on top of that
data they have uh like as I told you
they have performed the unsupervised
learning and all and they have
categorized a data and they have
provided to a different different model
which U like has been created like GPT B
and all and because of that uh like they
were able to predict the next next
sentence and that is a like a main thing
main advantage of this large language
model now over here you will find out so
in the next slide uh I have mentioned
that what is the what makes llm so
powerful so here by using one single
model by using one single llm actually
we can perform a different different
type of task like text generation
chatboard uh we can create a chatboard
also we can uh do the summarization
translation code Generation by using a
single LM we can do that particular
thing
now here uh if you will find out so
already I told you that what is the base
architecture of the llm so here this
Transformer is what it's a base
architecture behind this llm behind this
large language model and I have already
explained you the concept of the uh
Transformer that what we having inside
the Transformer now here guys uh this is
a few Milestone which we have in terms
of the llm like bird is there I think
you know about the bird if we are
talking about the uh we are talking
about the like a bad days right or old
days in 2018 19 or 20 when uh chat GPD
was not there just uh this uh GPT was
not there GPT 3.5 and all the recent
model which we are using inide of chat
GPT so there were few Milestone and we
were using this thing in our old days
like B was there GPT uh actually GPT is
having a different different variant it
is having a complete family GPD 1 2 3
and 3.5 and recently GPD 4 came into the
picture and other variants as well so
xlm is also there uh cross lingual
language model pre-training by uh this
particular guy now T5 was also there
this a text to text
transfer text to text transfer transform
Transformer and it was created by the
Google Now Megatron was also there so
Megatron actually it was created by the
Nvidia now M2M was there so it was the
part of the Facebook research so there
were many uh like uh there was the uh
like many model actually actually okay
and this was a milestone in uh this uh
in terms of this large language model
now over here guys see this bird GPT xlm
T5 they are using a base architecture as
a Transformer one only now if you will
see in the next slide so I have
categorize this thing so they are using
a base architecture as a Transformer one
only but in that you will find out some
of the model are using a encoder and
some of the model are using a decoder
and some of the model are using both
encoder and decoder now here I have
categorized this particular thing that
uh this is the model like B Roberta xlm
Albert Electra DTA so these are the
model they are just using the encoder
only and if we are talking about this
decoder uh if we are talking about the
GPT GPT uh 2 gpt3 GPT new or like the
entire family of the GPT so they are
using this decoder so we have a two
segment of the Transformer architecture
few of models they are using an encoder
side encoder part and few model
basically they are using a decoder and
uh here guys you will find out some
model which is which are using both
encoder as well as decoder so this T5
Bart M2 m00 Big B so these are the model
actually they are using both encoder and
decoder in the Transformer architecture
if you'll find out we have a two segment
so this is a this segment basically this
one is called an encoder segment and
this particular segment this is called a
decoder segment so here uh like I think
you got to know uh you got to know the
idea that uh this is what this is a like
uh transform this is the encoder segment
and this is what this is a decoder
segment and this model this T5 B M2M and
big but they are using both and we have
other models as well I just written this
uh couple of name over here now apart
from this you will find out some openi
based model open a based llm model so
GPD 4 is there GPD 3.5 is there GPD
based is there Delhi Biser iddings okay
so these are the different different
model which you will find out over the
open website itself and uh here uh
definitely GPT is uh one of the
prestigious model or this is one of the
very important model which uh people are
using uh nowadays for creating their
like applications and all and it is it
can perform any sort of a task related
to a generation okay now over here uh
this is the openi based model which I
have written now apart from this you
will find out other open source model so
this is the model from the openi side so
if you are going to hit this model so
definitely open is going to charge you
regarding the tokens regarding the uh
regarding like how many tokens and all
whatever you are using according to that
it is going to charge you but here we
have some couple couple of Open Source
model as well and I have written the
name like Bloom Lama 2 Palm Falcon Cloud
amp okay stable LM and so on we have a
various model various open source model
and uh yes but I I will show you that
how you can use this particular model if
you are going to create your application
so definitely I will let you know I will
show you that how you can utilize this
model as well I will show you the use of
the Falcon I will show you the use of
the Llama 2 if you don't want to use
this GPT uh GPT 3.5 GPT 3.5 turbo I will
show you the use of this llama and this
Falcon and some others open source model
as well I think you are getting my point
now here uh if we are talking about what
can llm be used for so if we are talking
about llm that what it can do so it can
uh we can use this llm for any sort of a
task like classification text generation
summarization chat board question
answering or maybe speech recognization
speeech identification spelling
character so this uh llm actually uh if
we are talking about this L LM so first
of all it's a model it's a large model U
it's a language anguage model and it's a
large model it's a large language model
and what is a like what we can do by
using this large language model we can
generate the data okay it can identify
the pattern of the data it is having
that cap cap uh that uh that much of
capacity so it can identify the pattern
from the data and by using those pattern
we are we can perform a various amount
of
task okay that's why this llm is too
much powerful
and here we can use this llm for any
sort of a task and yes uh we know about
this it and already I have uh like I
explain you this thing I hope this
introduction is clear to all of you now
coming to this uh prompt design so
prompt design and all uh definitely I
will talk about it uh once I will come
to this open a API there will try to hit
the uh different different models of the
open a and uh we have a different
different type of prompts so as as of
now you can think that the prompt is
nothing whatever input we are passing to
the model uh that is called input prompt
and whatever output we are getting from
the model itself that is called the
output prompt and here how cat GPD was
trained so generative of pre-training
supervise fine tuning and this
reinforcement learning there was three
step which I have mentioned so I will be
talking about this also and not in
today's session in the like next session
uh I'll be talking about this uh how CH
GPT and all it was stained uh okay now
what I can do so over here guys uh I
think uh we should uh conclude the
session so how was the session please uh
do let me know in the chat it was good
bad or what so did you uh understood
everything did you understand everything
whatever I have explained you uh
regarding this uh regarding this llm and
this generative AI the complete
introduction because uh I want that
before starting with any sort of a
practical the basics should be
clear everything did you
understand amazing
great to what is the
topic
yes fine uh if you have any doubt and
all so you can ask me I will try to
answer for that now before concluding
with uh like uh before concluding the
session let me show you few more things
over here so see uh here first of all
what you need to do uh first of all you
need to like uh go through with the open
a and you need to generate a open a API
and all so that uh basically don't worry
I will show you while I will be doing a
practical and all so you need to like at
least you need to create an account and
uh and you need to login it over here so
so once you will log in guys here you
will get two option first is chat GPT
and the second is API just go through
with this API and generate this API key
generate the API key from here don't
worry in the next session in the next
class again I will show you this thing
and here I see we have a different
different model so let me show you those
model and whatever open source model and
all is there so you will find out over
the hugging phase so let me show you the
hugging face models hugging face Hub and
uh here you will find out the model Hub
so guys uh here actually we have a model
Hub just a second yeah models now you
will find out a different different type
of model see these are the models which
is a open source and uh uh you'll find a
complete description let's say this uh
we are talking about this Orca 2 so this
updated 12 days ago and it's a recent uh
llm model uh which has been published uh
by the Microsoft now over here you can
see so it like you will find out the
complete description or complete detail
regarding this model and like uh how to
use it and uh each and everything
basically definitely we'll talk about it
now for what all task basically we can
use it okay so according to that also
you can uh like select the models so
just go through with the hugging phase
models and there you will find out many
uh like a different different models
okay and yes for sure openi is also
having uh different different llm model
so we'll talk about that we'll try to
understand the concept of this uh we'll
try to understand this uh assistant
actually and we'll try to talk we'll try
to understand the chat U actually so
what is this and how to use it how to
use this chat option and this assistant
option and here if you will go inside
the documentation so you will find out
of different different models over here
this GPT GPT 3.5 Del TTS whisper
embedding moderation GPT W gpt3 right
right different different models we have
and uh apart from that you can find out
the different different task according
to that also they have given you the
model so text generation so they have
given you the complete code and all so
just try to visit it just try to go
through it uh by yourself now uh we have
other uh platform as well so if you are
not going to use the uh maybe J uh if
you don't want to use this uh GPT and
all so here uh I can show you one more
uh like option so
AI 21 okay so AI 21 Labs AI 21 Labs so
this is the Recently I figured it out
actually this is the uh like alternative
of the GPT so we'll talk about this also
if you don't want to pay to this uh if
you don't want to pay for the GPT so you
can use this AI 21 lab uh and it will
give you the uh like a uh one model one
llm model so you can use it uh like
freely actually it gives you the $90
credit so so yes I will show you how you
can use this AI 21 lab uh so let me show
you the documentation and let me show
you the models as well so here you will
find out the uh model basically which is
there so Jurassic 2 is a model and it's
like a pretty amazing model and uh uh
yes definitely I'll be talking about it
and along with that uh the applications
of it which is very much required that
for what all task we can use it whether
if you are going to create a chat board
or maybe if you are going to do a
question answering or text generation or
like sentiment analysis for what type of
task we should use it and how to design
a prompt and all regarding the specific
task got it so we'll talk about this
also so uh yes many things is there and
definitely uh uh like from Tomorrow
onwards I'm going to start from the open
a lure and step by step I will come to
the uh different different models and
all so I hope guys this is uh clear
yes practical implementation will be
there don't
worry yes recording will be available
over the
YouTube yes all the uh all the topic
will be covered in the upcoming session
uh all the discussed topic and
all yes definitely this will be
available in the dashboard you can go
and check uh your dashboard this uh
video along with the video you will find
out the assignment you will find out the
quizzes and regarding the particular
topic fine I think uh we can conclude
the session
now is gener andm are also used in
computer vision based project so for
computer vision based project we have a
uh like others model we have a different
models uh because uh the task is
different over there so the task wise we
are talking about the computer vision
related task like object detection
object segmentation tracking OCR object
classification and for that we have a
different model and definitely we can
use a transfer learning of finding over
there now uh by using this L llm um like
this llm is for the like a different
task it is related to the language
related task it is not related to that
detection or a segmentation or tracking
it is not related to that particular
task it is related to the language
related task and uh here see let me show
you one uh one more paper one more
research paper so here I can show you
this uh ULM fit now see uh so just try
to go through with this particular paper
universal language model find tuning for
text classification now here in this
particular paper you will find out that
see uh this uh if you know the Deep
learning so in the Deep learning we have
uh two major concept so the one one
concept is uh called transfer learning
transfer learning the second concept is
called fine tuning F transfer learning
means what so you are transferring the
information from uh from one state to
another state okay or like you can I can
give you very simple example for that
let's say you know like how to how to
write the cycle so for you like for if
you know how to write the cycle
definitely you can use that information
and you can write the motorcycle also so
that is the same thing basically which
we uh do inside the transfer learning
let's say we have trained the model uh
like let's say we are talking about the
computer vision so inside that uh you'll
find out uh we have a various Tas like
detection classification tracking and
all so let's talk about the model let's
say YOLO so or we have other model also
like faster rcnn rcnn and all SSD SSD
and all like a different different model
related to a detection so the model
already has been trained on some sort of
a data some amount of data on some
Benchmark data so by using that
particular information we can uh like
perform the detection and all for our
specific task if we are not able to do
it then definitely I will fine-tune my
model but how we can use the same thing
in NLP because in NLP actually we have a
task uh the task is very specified we
have a specific task let's say we are
talking about um if we are talking about
a task let's say uh ner name entity
recognization or let's say we are
talking about the task let's say a
language gener language translation
language
translation language translation or
maybe sentiment analysis so these are
the specific task specific task ask
means regarding to the specific uh
regarding to the specific topic let's
say if I want to do a sentiment analysis
so not for the entire data whatever
there in the world for the specific uh
let's it for the Twitter data only means
whatever TW tweets and all we are
getting now if we are giving any other
data un any other like a task related
data so it won't be able to perform that
so actually in this particular paper you
will find out that how we can use this
uh language model language model
for uh like for the universal task and
there only this llm comes into a picture
L this llm actually it came from the
language model itself okay because we
are training this uh language model on a
huge amount of data that is why it is
called llm large language model because
we have we have trained this data on a
huge amount of we have trained this
model on a huge amount of data got it so
here in this particular paper they have
like shown you that how to use this
transfer learning because uh in before
2018 uh actually we were using this
transfer learning in the computer vision
only in the uh like in a different
different tasks of the computer like
object detection or segmentation you
will find out the image data so on top
of that data we have trade like a Ben
model and directly like like vgg rset
and all and directly we are using those
particular model for our like a other
task so here if we are talking about the
NLP so we are not able to do it before
this Transformer and all so actually see
we got a Transformer we got this
particular concept like how we can use
this transfer learning and all in the
like NLP field so this two concept came
together transfer learning and the
architecture like Transformer self
attention and all and from there itself
this uh llm came into the picture llm
means large language model which has
been train on a huge amount of data
which is able to perform the transfer
learning and we can do it uh we can find
T it also and the main uh like uh
the main cap or the main uh role of the
llm is what it is able to generate a
text text generation got it so fine I
think we are done with the session now
so rest of the thing we'll try to
discuss in the uh tomorrow session and
we'll try to more focus on the Practical
side so all the recordings and all it
will be updated on a dashboard and uh
yeah that is it yes so I think uh we can
start with the session now so yeah uh
welcome again again uh so you all are
welcome in this uh Community session
generative AI Community session uh
yesterday we have started this uh
generative AI Community session where we
have discussed about the generative AI
so there I have given you the
introduction related to the generative
Ai and large language models and here
you can find out the video so this is
the dashboard uh it's a free dashboard
actually uh which we have created for
all of you the same video actually it is
available over the Inon uh YouTube
channel as well if you we will go in a
live section so this uh same video you
can find it out over there as well now
uh let me show you uh that particular
video so here is my YouTube now let me
search over here I neon and here guys uh
go inside this uh live section and this
is the video so the same video same
lecture you will be able to find out
inside the live section apart from this
uh the same uh thing basically we are
uploading or the in neuron dashboard and
here along with the video you will find
out the resources so all the resources
basically whatever I'm using throughout
the session uh so whatever notes and all
which I'm writing and whatever PPS and
all or whatever code file I'm using
throughout the session you will find out
all the resources over here got it guys
yes or no so do you have this dashboard
do you have this dashboard tell me I
think uh many people are androll
yesterday uh for this free community
session and yes all the videos and all
basically we are going to upload over
here not even video and resources along
with the video and resources you will
find out the uh live uh you will find
out the quizzes and assignment as well
so already uh I have prepared the
quizzes and assignment so soon it will
be uploaded over here so in this
particular video you will find out one
more section so the section will be
quizzes and assignment so there you will
find out a uh like uh a video related or
a topic related quizzes and assignment
got it yes or no so please uh give me a
quick confirmation in the chat if this
uh dashboard related thing and this uh
video related thing is clear to all of
you I'm waiting for your reply in the
chat and if you have any sort of a doubt
then you can ask me in the like chat
section as well and don't worry my team
will give you the link of the dashboard
so if you haven't enrolled so far so uh
by using that particular link definitely
you can enroll it you can enroll U
inside the
dashboard great all clear all clear
great fine so here I got a confirmation
now uh so let's start with the session
let's start with the uh second day so in
the first day actually so what I
discussed I discussed about the
generative AI so where I have like told
you that what is a generative AI so this
is the slide basically which I was using
and here actually this was the agenda
the complete agenda which I going to
discuss this uh throughout this
committee session and uh today is the
second day where I will start from this
open AI so in the previous session I was
talking about this generative Ai and I
discussed each and everything related to
this generative a and I hope you got a
clear-cut idea that what is a generative
Ai and in the generative AI actually
what all things comes into the picture
where llms lies so if we are talking
about this large language model so
regarding the large language model also
I have clarify each and everything I
have given you the complete timeline of
this large language model where I have
discussed about the uh the complete
history of the large language model from
the RNN so first I have started from the
RNN then I came to the lstm then uh I
discussed about the uh different
different sequence to sequence mapping I
talked about the encoder and decoder and
after that I have explained you the me
uh the concept of the attention and then
I have discussed about the attention is
all your need uh the Transformer
architecture and I told you that
whatever llms which you are seeing
nowadays so those uh all the llms are
using Transformer as a base architecture
so I have explained you the
the like whatever thing was there inside
the Transformer architecture whatever
component whatever segment was there
each and everything I have discussed
over there and apart from this
generative AI I have talked about this
llm also so there I have talked about
that what is a llm why it is called
large language model and uh why it is so
powerful because this one uh because
this one llm is able to perform lots of
like task lots of uh one basically llm
we can use for the different different
type of application so here uh I have
written the couple of name like text
generation summarizer translation or
code generation and so on we all know
about the chat GPT uh chat GPT is are
application and uh chat GPT is using
gpt3 gpt3 is a a base model so GPD 3.5
actually it's a base model so how it is
how much it is powerful we all know
about it and that is a example of the
large language model which is capable to
do so many things why because uh it is
having a power so so that actually it
can generate a it can generate a data
based on a previous data it can
understand the pattern and because of
that only we are able to trans we are
able to use this Transformer as a or
whatever like Transformer based model we
have we are able to use those transforma
based model as a transfer learning I
have explained you the concept of the
transfer learning and the fine tuning as
well so here I was talking about this
llm and then I talked about the few
milestone in a large language model so
here I have written couple of name bird
GPT xlm T5 Megatron M2M so these are the
uh like a few milestone in a large
language model now this model has been
trained on a huge amount of data now
specifically we are talking about GPT so
in a GPT Family itself you will find out
of various model I will talk about it it
I will come to the open Ai and each and
everything I will keep in front of you
only and uh I will uh I will show you
that how much it is powerful so we are
talking about GPT so it's like really
powerful and it it has been trained on a
like huge amount of data and it is
having a billions of parameter so here
is few Milestone so in our back days in
our history basically we are using this
particular models now in a recent day we
got so many uh architectures so many uh
open source models and so I will talk
about uh regarding those model as well
so here in the next slide I have shown
you so what all encoder based
architecture we have what all decoder
based architecture we have if we are
talking about anod and decoder right so
in which architecture you will find out
both encoder and decoder if we are
talking about B xlm Electra DTA so these
all are these all the architecture
actually it is based on an encoder we're
talking about this GPT GPT family so
it's a based on a decoder itself and the
idea has been taken from the Transformer
itself now here you can see this T5 Bart
M2M big but so these are the model which
are which is using this encoder and
decoder both got it so now here uh then
I talked about the openi based llm model
so here uh the very first thing comes
into the picture that is a GPD itself
GPT 3.5 which is a like base model
behind this chat GP chat GPT just a
application it's not a model now here
you will find out this Delhi whisper DCI
there are many model I will be coming to
that particular model and I will show
you how you can get all the model from
the opena itself and uh yes we'll try to
use those model for our task for our
like a uh for the for our like a like a
requirements and all definitely will try
to use this particular model like GPT
GPT 3.5 I will show you how you can use
GP 3.5 turbo viso da in or other model
as well like aming and moderation so
apart from that this apart from this uh
like uh Milestone whatever Milestone I
shown you and this openi based model
here you will find out some other op
Source model like Bloom llama 2 Palm is
a model it's a very famous model from
the Google side nowadays like most of
the people are using this pal Falcon is
a model cloud is there MP 30 uh MP is
there uh this B actually it is showing a
parameter right and here we have a
stable Im so a stable LM so there are
like so many open source model so I will
come to that also and I will show you
how you can utilize those particular
model and apart from that I have like
kept some more slight over here inside
this particular PP so you can go through
with that and you can understand some
other uh like concept like how this chat
GPD has been trained and all so I hope
guys still here everything is fine
everything is clear
now we can move to the Practical part so
please do let me know in the chat if
everything is clear so far in terms of
theory guys I'm waiting for your
reply uh just a wait so let me give you
the link of the website and
uh
yes guys I'm waiting for your reply so
if you can confirm in the chat uh uh
like everything is fine or not so that I
can proceed with the Practical
stuff yeah definitely this uh PP is
already there so just try to enroll in
this course the dashboard Bic basically
which we have created this is our
dashboard which you will find out over
the Inon website so just try to log to
your Inon website first of all if see if
you are a new person so what you need to
do you need to sign up after sign up uh
you will login and after login you will
search uh regarding this dashboard so
here actually what is the name of the
dashboard so the name of the dashboard
is generative AI Community Edition so
just click on this dashboard and here
after clicking on this dashboard you it
will ask to you whether you want to
enroll or not so yes uh you will click
on the enroll and it is completely free
so it won't ask you any sort of a money
and after enrolling into this particular
course uh you can get the videos and you
can get the resources as well so all the
resources we have uploaded over here
inside this resource section got it
clear great so I think everything is
fine everything is clear now let's start
with the uh let's start with the
Practical implementation so first of all
guys uh let me clarify the agenda that
what all thing we are going to discuss
in today's session so for that what I'm
going to do I'm going to open my
Blackboard and here I will try to
explain you each and everything uh like
what what whatsoever we are going to
like cover in this particular session so
let's start uh let me write it down all
the thing step by step now first of all
I can write it down over here a day two
Community session and then I will begin
with the topic so here guys are day two
of the community session now uh
yesterday actually I I talked about the
introduction part I talked about the
introduction of the generative Ai and
the llm now today I will be more
focusing on the open a so here I will be
discussing about the open AI so first I
will give you the U like a complete walk
through of the openai website of the
openai documentation after that I will
come to the openai API that how you can
use this open API how you can use this
open API and this API we are going to
use by using this python so guys if you
you know python so definitely uh like uh
you will be able to write a code along
with me uh and don't worry I will show
you how to do the entire environment
setup and all each and everything I will
try to uh I will try to do in front of
you uh from very scratch so uh you all
can do along with me now over here I
will come to this openi API and there
I'm going to use Python and we have
couple of more option like nodejs on all
so if you are familiar with the
JavaScript or maybe some with other
language so in that case also you can
use this openi API after that I will uh
I will come to the openi playground so
here uh they have given you very
specific feature or very uh like uh very
interesting feature that is what that is
a openi playground so over here I will
explain you that uh how you can use a
different different model how you can uh
like pass a different different prompts
and how you can generate output how you
can set up your uh like a different
different uh sentiments and all
regarding the system that okay so my
system should behave like this or that
so each and everything I will explain
you over here and after that what I will
do I will show you the chat completion
API so I will use this chat completion
chat completion and by using this chat
completion actually uh we can call the
GPT model so whatever uh like uh we can
call the like openi API and uh with that
definitely we can use any sort of a
model like a GPT model or any other
model so first I will uh start with the
openi API we'll use we'll be using a
python over here and I will show you how
you can generate the openi key and after
that I will come to the playground and
assistant and then chat completion API
and then I will explain you the concept
of the function call function call now
this is the agenda for today's session
this is the agenda for today's Community
class now before starting with the openi
I will uh I will explain you that why
openi is this much important why not
other other like things or uh if we have
like a other competitor of the openi
that why we are not using that instead
of this open ey and if we are going to
use that then how we can do that okay
and one more thing I would like to
explain you over here so along with the
open a I will uh talk about the hugging
face so see over the hugging face
actually hugging face is has provided
you one uh hugging face hub for all the
models so there you will find out all
the open source model so directly you
can generate a hugging face API key and
you can utilize all sort of a model
whatever is there over the hugging face
Hub yesterday I have shown you that let
me show you again uh that particular Hub
so guys here once you will write it down
so over the Google so once you will
search uh once you will write it down
hugging face model Hub so there uh you
will get a link and you just need to
click on that so here you will uh and
then basically it will be redirecting to
you to this particular model Hub now
here you will find out all the open
source model from a different different
organization so yesterday I was talking
about this Ora 2 now here you will find
out other model as well like whisper
large V3 now from the Facebook side
there's a
seamless okay now here you will find out
other model as well so see from The Meta
side there's a lamba Lama 2 so I will
show you how you can utilize these
particular model for the different
different tasks according to your
requirement getting my point so we will
not restrict it uh we will not restrict
to ourself to the till the open ey
itself apart from that we'll try to
explore few other model few other open
source model and yesterday actually I
have shown you one more platform and
here's the platform AI 21 studio so it
it gives you one model this Jurassic
model so we can utilize that particular
model also and this all are called large
language
model this IDE this thing is clear to
all of you yes or no so uh what is the
difference between hugging face and open
AI so open AI is a different
organization hugging face is a different
organization and over the hugging face
Hub see uh if you have heard about this
Docker or this GitHub so first of all
let me show you this GitHub so if I'm
searching about this GitHub so here
actually over the GitHub you will find
out uh like see this is my GitHub and uh
you all have the GitHub ID right you all
have log to the GitHub and all and first
you sign up and then you log in and
whatever course and all you are having
and definitely you are going to upload
it over here uh in terms of repository
now let's see if I if I have to find out
something so what I will do here let's
say if I'm going to write it down GitHub
machine learning uh linear regression so
GitHub machine
learning machine learning linear
regression so here if I will search uh
like this then definitely I will get a
link and here you can see so it has
suggested me one repository and you will
find out uh this uh code and all
whatever code and all has been uh
uploaded by this particular person and
definitely you can download it and you
can use it similarly we have a Docker
Hub similarly we have a Docker Hub so
let me show you the docker Hub so the
docker Hub actually you will find out
all the images and all so let's say uh
like uh you downloaded Docker in your
system you did setup and all now uh you
don't want to install it from scratch
you want to run it by a Docker so yes
there is a Docker Hub and there you'll
find out different different images and
all so you can uh like uh you can pull
that image and definitely you can run it
inside your container so similarly we
have a hugging face Hub there uh like it
is uh it it is going to provide you a
different different model actually on a
single place so yes uh just uh you just
need to log in over there and after that
you need to generate a API key and
directly you can use those particular
model whatever is there like over the
hugging face Hub now similarly we have
openi it's other another organization so
yes by using the openi API we can access
the open a model as well so here uh okay
so if you will find out if you will see
to this open a this one this is the open
a right now I will show you what all
models this openi is having it is having
a different different model various
model I will come to that I will show
you from very scatch so till here
everything is fine guys everything is
clear so uh just give me a quick quick
confirmation so that I can show you the
entire setup related to this opena API
and we can run a couple of uh couple
couple of line of code as well so please
do let me know in the chat if uh
everything is clear so
far yes we'll talk about the fine tuning
and all so how we can uh do the fine
tuning regarding a different different
model uh it's not a like easy task it's
a a very expensive thing so we'll talk
about
it yes hugging pH model are
free yes correct for building a model uh
so for using uh if you want to use that
particular model so either I can use
open a so or else I can use hugging
phase see whatever model is there over
the hugging for definitely we can access
that but let's say open a is having
there uh like a uh it's a separate
platform right so whatever model is
there over the open a so we'll be able
to access those model only from the open
a not all the model which is there
inside the hugging face also but hugging
face actually is having all the models
open source and all whatever model is
there and some of the model from the
openi side as well but openi actually
it's a specific specific one specific
organization clear yes or no so please
do let me know if uh this thing is clear
to to all of you so that I can proceed
with the uh next part next
section great so people are saying sir
it is clear clear clear okay
great yeah the model is already created
over the hugging face and open ey they
already trained the
model
we don't have all the models in the ging
phase that's why we are learning this
open great so I think uh all the thing
uh like each and everything is clear to
all of you now let's start with the uh
like uh next part of this session so
here I have uh discussed about this open
Ai and this hugging phase and I clarify
the agenda that what all think we are
going to discuss but before starting
with the open AI so let me give you the
a brief introduction of the open AI that
why this open AI is too much important
so for that what I did I have created
one small PP so with that actually you
will get some U uh some basic idea uh
regarding this open AI so here uh let me
start uh let me start the slideshow so
over here guys you can see about the
open if we are talking about the openi
so what is the openi open a is leading
company in the field of AI it was
founded in 2015 as a nonprofit
organization by same Alman and Elon Musk
as we know about the uh founder of the
like open a so yes uh I think we are we
are aware about uh with this particular
names right same Alman and this Elon
Musk and it has founded in 2015 as a
nonprofit organization just for the
research purpose now here in the next
slide I have kept the name so he's a
like
he's a CEO of the open a Sam Alman and
uh yes I think you know about the Sam
Alman he was fired by the open board
we'll talk about that also what what
might be the reason behind that so we
will discuss about that uh as well now
over here you can see uh openi founded
in uh 2015 and the company founded with
the goal of developing and promoting
friendly AI in a responsible way that
was a logo of the open AI so with the
focus on transparency and open research
and he was the and they are the founder
member of the like open a so Elon mus
Sam Alman Greg Brockman okay this guy is
a like great researcher and vak and zon
so these are the founder founding member
of the open AI now over here are open
goals so there are some goals of the
open related to the AI and all now openi
Milestone so I was talking about that
why this openi is too much important why
not other does because if you will look
into the market there are other uh there
uh there are you will find out other
organization as well uh so we have a
Google and Google is having their
separate Department Google uh AI
research and all so Microsoft is also
having their own department for the AI
research even meta is having that even
IVM so all the like big big giant so
there they are having their own research
uh like Department related to this Ai
and all and they are working on that and
they were working on that actually but
why this openi is too much popular and
why we should start from the openi
itself so you know about the openi in
2020 actually they have launched the
Chad GPT and guys believe me it was the
Milestone and it was the major
breakthrough in the history of the AI
because before that also we are having
so many llm model and it was able to do
uh some sort of a thing but not like to
not similar like to this GPT this GPT
actually the GPT model which is a
backbone of this Chad GPT application uh
it was a a breakthrough in the history
of the NLP and because of this this open
AI came into the Limelight and uh apart
from the GPT then uh uh like they have
shown or they have released the other
different different research so here
here I have written couple of name
basically so generative model is one of
the Milestone of the open now apart from
that you will see that they are going to
uh they are going to participate in the
robotic research and all and here uh
like other uh like other few more thing
basically so solving uh robic Q with a
robot hand and here multimodel neurons
and artificial neural network you can
search about uh this particular things
and yes uh this open ey actually it
become uh very uh important uh basically
because of this uh like GPT and all
because of this uh chat GPT application
and yes they were using a different
technique for training this uh GPD model
which we are using for the chat GPT and
the idea from where they took the idea
uh for training this GPT model there we
have unsupervised learning we have a
supervised learning and we have this
reinforcement learning so they took from
the ULM fit research paper yesterday I
have shown you that which has been
published in 2018 and in 2019 in 2020
actually they have released this GPT GPT
got it now here you can see buildin with
open AI API so these are couple of name
getup copilot keeper Tex Bible dingo so
these are some application which is
using this openi API and apart from that
you will find out so what is the openi
vision so the vision is like uh promote
a friendly AI in a way that benefit all
the humanity and all so this is a vision
of the openi now feature so chat GPT
Delhi whisper alignment so so these are
the feature of the open AI Chad GPT is a
a milestone Delhi is also there Delhi 2
recently they have they have released
the Delhi 2 whisper is uh one of them
whisper actually it is a very good model
for generating a transcript and all so
whatever like text we are giving or
whatever like videos we are giving to
this particular model it is able to
generate a transcript from that and here
uh alignment is there startup fund so
these are some feature of the open AI
now guys uh before starting with the
open AI API I think got enough amount of
idea uh regarding this open AI yes or no
please do let me know in the chat if uh
this part is clear so I will proceed
with a uh open a API so how you can
generate a key and all and how you can
utilize
that
yes are you getting guys whatever I'm
explaining you over here uh if you have
any sort of a doubt anything so you you
can ask me in a chat section I will
reply to all of your
doubts so step by step we'll try to
proceed uh and uh so each and everything
will be
clarified great so
clear yes waiting for your reply uh if
you can write it on the chat so then I
will
proceed what is the learn tool what is
the aim to learn open AI so that I can
utilize the same capability same AI
capability in my
application whatever model has been
trained by the openi so that I can use
the same model in my application for a
different different
task great so I think I have uh
discussed each and everything related to
the open a now this is the website of
the openai so if you will search openai
definitely you will get a website of
that so in the website itself they have
mentioned everything so latest update
whatever uh latest update and all it is
there so they are mentioning over here
and Sam Alman return as a CEO of the
open a I think you know about this
controversy of the open a so let me uh
give you some sort of a glimpse of that
uh if you know about the open a so it
was founded as a nonprofit
organization but uh in 2019 actually
they have uh started with their uh
for-profit organization as well if you
will search about the four profit
organization
of for profit organization of this open
a so in 2019 actually they have started
this a for profit organization and uh it
was doing uh lots of work uh regarding
this Ai and all and they collected uh
like uh funds from different different
companies and all from a big big giants
and uh they were working on the G GPD
model itself okay now after that uh this
chat GPD has been released and in 2022
actually 2022 or 23 basically so uh they
started work on a uh like a different
type of project so the project name was
the
qar the uh basically the project name
was the qar and it was more specific to
it was more specific to towards this AGI
so may I know guys what is the full form
of the AGI
if if you know uh the full form of the
AGI so please write it down in the chat
what what do you uh understand with this
AGI so the full form of the AGI is
please write it down in the chat if you
know about the full form of the AGI
please do it yes artificial Journal
intelligence correct so the full form of
the AGI is artificial Journal
intelligence actually see we talking
about the chat GPD now this particular
application it's not it is not
representing a general artificial
intelligence it is a restricted one it's
a specific
one getting my point so let's say there
one side there is a Chad GPT and one
side there is a human so definitely this
Chad GPD can answer in a better way it
can generate answer in a better way
compared to this human but still it is
not like a human so still we are not on
that particular level where we can
achieve a artificial intelligence like a
human that is called artificial general
intelligence and the project name was
given by this openi the project name was
the
qar and that was happening in the
for-profit organization this is the
subsidiary of the open
itself getting my point now because of
that uh so there was a conflict in
between the board member and uh this uh
Sam Alman was fired and now again he
joined the company uh there is a long
story story but yeah I have given you
the Glimpse you can search over the
internet and you can uh read about it U
okay so if you like to read the AI news
and all AI related news news and all so
definitely uh you should check it on a
daily basis because on a daily basis
there's something is happening on a teex
side on a like organization side uh
whatsoever so over here guys uh here you
can see the open a website now if I will
scroll down so you will find out each
and everything over here itself that
what all research is there uh what all
upcoming models is there uh on whatever
applications they are working so each
and everything actually you will find
out over here itself so here uh recently
they have released this Delhi 3 so in
October uh 20123 3rd of October 2023
they have released this Delhi 3 there
was a GPD 4 gp4 Vision where we can uh
upload the images and we can do a lots
of lots of task related to the images
and all
getting my point so here you will find
out a research whatever latest research
is there from the open a side no need to
go anywhere everything you will find out
over here itself if you want to start
from the open a if you are using this
open a in your organization if you want
to use it and before that if you want to
explore it so please go through the
website and here you will find out each
and everything now guys here is a
question I told you that why uh what is
the open a now why we are learning it I
have to give you the specific answer of
this particular question if you will ask
me S why we are learning this open a
what is the main Aim so now let me tell
you that so first of all guys after
opening this opena website what you need
to do you need to log in it you need to
log to this particular website and here
you will get two option so the first
option is a chat GPD and the second
option is a API so we all know about
this chat
GPT I think uh we all have used this
chat GPT and I think we are using it on
a daily basis now we are not going with
this chat GPT we are going with this API
so I will click on this API option and
once I will click on this API option so
I will get this type of interface so I
believe guys you all are getting this
particular interface after clicking on
this API please do let me know in the
chat if uh everything is uh uh like
going fine uh like me so please do let
me know in the
chat
great so yes I think uh people are doing
along with me now see guys here is what
so here is a uh like open a API uh so
once you will click on that you will get
this particular interface now just uh
overover your mouse left hand side and
here you will get a different different
option or various option now what you
need to do guys for here first of all
you need to click on this documentation
so just click on this documentation and
you will come to this particular page
now here you will find out this overview
so here they have given you the complete
overview about the openi API that what
all things they have and uh for what all
applications we can use this openi API
now here you will find out the
introduction section as well so in the
introduction section they have defined
some sort of a thing related to a
different different task like text
generation aming assistant tokens and
all now here you will find out the quick
start so let's say uh you want to
explore this open API so what you will
do at the first place so after opening
this open uh a openi API and after
opening this after opening this
particular documentation you just need
to click on this quick start so after
clicking on this quick start you will
get all the code which initially you
need to run inside your system getting
my point if you want to use this open
API if you want to use this openi API
and you want to run the code if you want
to start then for that what you need to
do you just need to click on this quick
start and over here you will find out uh
different different option so let's say
you know the nodejs so here you can
click on this nodejs and you will find
out entire setup related to this nodejs
how to install the package how to uh set
the key and all now here you'll find out
the different different uh like Windows
different different operating system
related option and here you will find
out the code snippet so directly you can
run it and you can use it now if you are
a python lover if you know the python
only in that case yes they have given
you the option so you just need to click
on this uh Python and here you will find
out the complete setup guide so how to
install a python how to install how to
create a virtual environment how to
install this openi Library so and after
that you will find out this uh setup
openi key uh regarding this Mac OS and
windows now here you'll find out how to
uh request to your openi uh API how to
request to the different different
models so here is a code snippet so we
are going to use this particular process
uh if uh so yes you can use the same
process don't worry I will show you how
you can do the entire setup and all and
how you can call the different different
model now over here you will find out a
model now guys this model actually this
model is a uh like a very important part
of the openi API now here they have
given you the various model like GPD 4
gp4 Turbo G PD 3.5 Delhi is there TTS is
there whisper is there iding moderation
GPD 5 is there GPD 3 which is a legacy
now and here you will find out some
deprecated model so here they have given
you some a deprecated model like uh GP
3.5 Turbo with this much of tokens and
here you will find out this text Ada Ada
text weage text cury text DaVinci so
these are the depricated model you can
use it if it is required definitely you
can use it so here you will get a
complete list of the model whatever
model you want to use for your task for
your particular task now over here uh
this is the uh like overview regarding
the model now if I'm clicking on this
GPD 3.5 so once I will click on this GPD
3.5 so here I will get a complete detail
regarding this particular model now here
is a what here is a model name so what
is the name of the model GPT 3.5 turbo
1106 okay now over here you will find
out two things so the first is what
context window now in the context window
you will find out the number of tokens
now guys this tokens actually the number
of tokens displays a very very important
role if we are talking about this tokens
so really it plays a very very important
role and I told you if we are giving an
input to our model to our LM model so
we'll give in the form of prompts and
prompt is nothing it's a collection of
token so whatever input and output we
are getting we are getting in the form
of prompts right so we are giving a
prompts to our model and we are getting
a prompts from our model and this prompt
is nothing it's a collection of tokens
now we'll talk about this tokens and all
then how much token is uh so as a return
actually how much token you can get as a
output as a free one actually this uh
Chad this open a actually it stopped the
free services now so before actually uh
uh you would be getting this uh let me
write it down over here so $20 of credit
so earlier if you have used this uh open
a so you must have seen that uh if you
are uh like uh if you are going to
create a open API key so in that case it
was giving you this $20 free credit now
they have stopped this particular
service now they are not giving to you
so first of all what you will have to do
so first of all you will have to add the
method a payment method actually so so
you will have to add your credit card or
debit card details and after that you
will have to set your limit let's say
$20 $50 $100 or whatever uh like limit
um actually you find out it is fine so
inside uh in that basically in that
particular limit uh my work will be done
so first of all uh you need to add the
payment method and you need to set the
limit and then only you can use this
open API so recently they have updated
this particular thing now we have
alternative also so we have this AI 21
lab so I will uh show you this uh thing
as well where we have a Jurassic model
and it gives you the $90 fre free credit
$90 free credit but you won't be able to
use this GPD 3.5 because it is only it
is only available in this opena itself
if you want to use this GPD 3.5 model
GPD 3.5 turbo or gbd4 so it is only
available in the opena itself and they
haven't open source it and for this one
you will have to pay if you want to use
it in your organization in uh with
respect to your task so definitely you
will have to pay for that getting my
point now over here guys see uh it
return return a maximum of 4096 output
token so regarding this particular model
now here you can provide this much of
tokens actually so this much of tokens
as a uh input as a input basically and
you will get this much of token as a
output if you are going to use this
particular model now here GPD 3.5 turbo
So currently point to GPD 3.5 turbo 0
613 will Point GPD format turbo 11
starting date this is this is the
starting date and here this is the token
size now here this is the token size
basically they have given to you so you
can uh provide this much of token and
here you will be getting output in uh
like as uh this is the maximum token
size actually uh with respect to this
particular model so you can go and read
more about this model and all and here
you will find out this training data so
this uh model has been trained up to
2021 SE number 2021 and here uh these
all are the model so I will uh use any
sort of a model from here itself and I
will show you how you can hit it by
using this P openi python API now apart
from that uh you will find out some
other uh thing so let's say if I want to
do a text generation so they have given
you the complete detail regarding that
and here they have given you the API
endpoint as well so you can click on
that and here in this particular way
actually you need to write a prompt and
all you need to define a prompts and all
uh so actually this is the uh rate
assistant uh as of now it is not working
so you can click on that or you can use
it this API endpoint inside your
application so uh here they have given
you the code that if you want to perform
this particular task this text
generation task so directly use this Uhn
code snippet after setting up the
environment and all after generating the
openi key and you can perform this text
generation over uh text generation if uh
this is required according to your uh
like application and all now over here
you will find out the other option so
embedding is there so embedding is
nothing uh embedding actually you are
just going to be uh convert your text
into a uh some numeric uh numbers and
here uh this ambing comes into a picture
and this this is very robust model from
the openi side and definitely you should
use it uh I will show you how you can
utilize this particular model and you
find you will find out the complete code
in s it and all and yes you can generate
a Ming regarding your test Ming is
nothing it's just a numeric
representation of your text now here uh
if you want to do a fine tuning so
regarding that also you will find out a
complete detail so how you can do a fine
tuning and all now image generation is
also there so if you want to do a image
generation so which model you should use
from here Vision related to The Vision
also there is a GPT 4 now Vision related
facilities it is there inside the gbd4
itself text to speech speech to text
moderation so no need to train your uh
no need to train your model your uh NLP
model from scratch now so they are
giving you everything you just need to
call the API and you can utilize it now
many people are asking to me that sir
what is the aim to learn behind this
open ey and all so the aim is very very
simple if you want to use this
particular model for your uh uh
different different task the task
basically which they have mentioned over
here you can directly use it you no need
to like train it by your yourself
because this model has been trained on a
huge amount of data now that's why it is
called llm I told you clearly right
yesterday what is the meaning of the llm
and yes uh in most of the cases in 99%
of the cases it will work fine if let's
say if you want to do a fine tune this
particular model so definitely you
required a higher resources and in that
case you will have to pay to the openi
as well getting my point so here you can
read uh entire detail regarding this
fine tuning and all so once I will come
to this fine tuning part I will explain
you this uh thing as well how to do the
fine tuning and all regarding this model
definitely I'm not going to do it uh in
the live class but yeah I will give you
the uh quick guidance regarding uh this
fine tuning so I hope guys uh this model
related thing model related part and
this quick start and this introduction
and what of capabilities is there so
this thing is clear to all of you if it
is clear then please do let me know in
the
chat yes or no so waiting for your reply
please do let me know in the
chat what what are the job opportunity
after this particular course so after
that you can apply as a NLP engineer uh
you can work on a gentic way related
project you can work uh as a uh gen VA
engineer so if you are going to complete
this particular course so after that you
can join uh the company uh like whatever
designation I told you on that
particular designation
and uh here in an interview do they ask
from the scratch inside of using API no
they won't ask you that you need to like
uh you just show them like how to use
the API and all no they won't ask you
this particular thing uh they you just
need to tell you what was your use case
which model you have used and uh what
was the cost regarding behind that
particular model uh how you you have
designed your prompt template how many
tokens basically there uh you were uh
defining inside your prompt in U
basically inside the input input prompt
and how much tokens basically you are
getting inside the output
prompt okay so these are the thing uh
like uh they might they might ask you
regarding this uh uh like openi API and
all and open AI models uh they won't ask
you that uh generate this key that key
or
whatever do we need to learn all the
underlined math behind the model hugging
pH and open ey yes the architecture
should be clear so the architecture part
should be clear uh architecture means
what so uh the base architecture
Transformer architecture they definitely
they might ask you the or Transformer
architecture in one of the interview
they they have asked to me that uh can
you uh explain me the Transformer
architecture what is the meaning of the
positional uncoding why we are using a
skip connection over there and can you
code it as well so if you want to use
this Transformer in the python how you
can do that which uh like which Library
you will call or can you write it down
the code from scratch so this type of
question you might face if they are
going on a architecture level they won't
ask you the uh they won't ask you the
architecture of the different different
model which is there over the hugging
face and all no they won't ask you
that so can we proceed now if uh this
part is clear tell me guys fast yes or
no I given you the complete walk through
of the open uh website openai API now I
will show you how you can utilize it and
don't worry guys I will uh show you the
advanced thing as well I will show you
the advanced part as well uh I will show
you this function uh calling and all and
uh first let me complete this uh uh chat
completion and after that I will come to
the function
calling great so here uh I think this
thing is clear now let's try to start
with the Practical implementation so for
the Practical implementation first of
all uh what you need to do so let me uh
write it down the step all the step so
here uh the first thing what you need to
do see uh you should have uh you should
have this uh Anaconda inside your system
I think you know about this Anaconda
what is this Anaconda it's a package uh
it's a package manager for the data
science projects and all so you should
have this uh Anaconda inside your system
the second thing uh python must be
installed python must be installed all
now here whatever practical which I'm
going to do so I'm going to do by using
the Jupiter notebook so here let me
write it down uh the Jupiter notebook
now whatever practical and all whatever
I'm going to do I'm going to use
basically I'm going to do by using this
jupyter notebook in the next class uh
I'm going to uh create an end to end
project first of all uh before starting
with the end to end project I will come
to the Len chain and there I will
explain that each and every concept of
the Len chain that how it is different
from the openi and why should uh why we
should use it and after that once I will
come to the end to project then I I will
start from the vs code itself vs code
Visual Studio code so any ID you can use
I'm not restricting you for the ID and
all so if you are familiar with the py
charm you can use that also if you are
familiar with the like any other ID you
can use that but yeah I love this vs
code so uh for the project for the end
project I will use this vs code as of
now I going to use the Jupiter notebook
uh just for the
uh like open a uh python API uh so guys
if you have this two thing this three
thing actually inside your system so
after that what you need to do you need
to create one virtual environment so uh
here by using this cond by using this
cond you need to create one virtual
environment I will show you all the step
don't worry so here you need to create a
virtual environment there inside after
creating a virtual environment you need
to activate it activate this virtual
environment
and here you need to install all the
packages all the required packages
inside this virtual environment so here
you need to install all the required
packages so let me write it down over
here install all the required packages
now uh required packages means what
required packages means so you need to
install this open a as of now and we
have other packages also like pandas
napai and all so if I will be uh if I
will be having any sort of a requirement
uh regarding the pandas numine uh or
regarding any other packages so
definitely I will install that also in
my virtual environment now after
installing all sort of a thing so after
like creating a virtual environment
after activating it and after installing
all the packages then what I will do I
will be starting with the Practical
implementation so guys in my system I
already having Anaconda so you can uh
download it by searching this Anaconda
so just go through with the Google and
search over here Anaconda download so on
once you will search this Anaconda
download so here you will get the
website uh here you will get a link so
just click on that and here you will get
a option for downloading this Anaconda
now uh it is giving you the option based
on your operating system so if you are
using Windows if you using Mac or Linux
according to that you can download this
Anaconda now apart from that uh one more
thing will be required so if you don't
have python in your local system so you
need to download that as well so
python uh download so here I'm going to
write down the python download and yes
uh this is a website of the Python and
uh here you need to uh here basically
you can uh download the python by
clicking on this particular website I
would suggest you uh download this 3.10
or 3.11 don't download the latest
version this 3.12 or this 3.13 actually
uh it is having some sort of a like
issues so better uh okay don't download
this 3.11 also either download the 3.10
or 3.9 it will be working fine or you
can download this 3.8 also this all
three version is a stable version fine
now after downloading this anaconda and
this python inside your local system
then what you need to do so once you are
ready with the Anaconda and this python
after downloading and installing and all
you need to search Anaconda prompt so
here uh you will find out the uh like
Anaconda prompt so once you will search
over here in the search search box
Anaconda prompt so there itself you'll
find out the Anaconda prompt now this is
what this is my anaconda prompt guys
this one now here actually this is what
it is it is showing me a base
environment as of now this base is a by
default environment now here what I need
to do I need to create a virtual
environment how I can do that how I can
create a virtual environment so for that
we have a command now here the command
is what cond create so cond create
hyphen n and here I need to write it
down my environment name so here my
environment name is what testing open AI
so testing open AI this is what this is
my environment name you can give any XY
Z name over here I don't have any issue
now you need to mention the python
version so here you need to write it
down the python equal to 3.8 now guys
here I'm going to use 3.8 you can use
3.9 3.10 don't use 3.11 12 and 13 3.8 7
9 10 these are the stable version and
you can use it for your project now as
soon as I will hit enter ENT so yes I
will be able to create an environment so
yes let me hit the enter and it is
creating an environment so are you doing
along with me if you are doing along
with me then please do let me know in
the chat
guys yes I okay so people are saying yes
we are doing
it can we do sir using API as well as
our make
model if you have trained your own model
then definitely you can do
it great so many people are doing a lot
with me I think now here you can see so
uh this is what uh this is my base
environment sorry this is my base
environment and here I have created a
virtual environment and this is my
virtual environment if I want to
activate it so for that this is the
command so here you need to copy this
command and just just paste it over here
and so you will be able to find out that
I have uh I'm able to activate my
environment now you can clear the screen
so for that you just need to write it
down the CLS and here is what guys here
is my virtual environment now here what
you will do see uh first of all you need
to check that what are libraries is
available inside your virtual
environment so for that you can write it
down the command the command is what the
command is PIP list so once you will
write it down this pip list here you
will find out all the library what ever
is there as of now inside your virtual
environment so these are the library
which is there inside my environment and
here I uh still I haven't uh downloaded
this uh open open Package because by
using the open by downloading the openi
package only by using that open Package
only I can hit the API getting my point
yes or no so don't worry I will give you
the entire step whatever step I'm
following over here now here first of
all you what you need to do see I took
told you over my Blackboard that after
creating a virtual environment you need
to activate it and then you need to
install the required package and before
that I told you one thing that
everything I'm going to do inside the
jupyter notebook so guys here in this
particular environment in this virtual
environment you need to download or you
need to install the Jupiter notebook and
for that we have a command so let me
write it on the command pip install
Jupiter notebook so here I can write it
down g u p y t e r n o t e b k so this
is the command pip install jupyter
notebook and with that you will be able
to download the jupyter notebook and oot
te so this is the correct spelling let
me rewrite it
again yeah so installing J notebook are
you doing along with me tell
me yeah so here let me write down the
command in the chat section so cond
create hyphone n and you can write it on
environment name whatever you want to
write it down so let's say testing open
a and here python version is what
3.8 so this is the command uh you need
to run this particular command for
installing the sorry for creating a
virtual environment now let me give you
one more command so here you can check
all the listed uh Library uh all the
like Library whatever is there inside
the virtual environment pip list is a
command now let me give you one more
command so here is one more command pip
inst install Jupiter notebook so pip
install Jupiter notebook so these are
the three command did you get it uh
please do uh confirm in the chat please
give me a quick confirmation the
chat see if you're not installing this
Jupiter notebook in your current virtual
environment in that case it will launch
the jupyter notebook from your base
environment so it is a better practice
if you are creating a virtual
environment then please install the
jupyter notebook or please install the
ipnb kernel over there so now if you
will find out uh now if you will search
pip list over here so just search pip
list now once you will search pip list
then you will find out lots of libraries
or lots of
packages which came along with the
jupyter notebook now see here you can
see all the packages and all after
installing the jupter notebook now once
I will write it down the Jupiter
Notebook on my anaconda prompt so here
let me write down the Jupiter notebook
and it will open the notebook so once I
will write it down the Jupiter notebook
and you will see that yes it has open
the Jupiter notebook so got it guys yes
or no please do let me know in the chat
if you are able to launch your Jupiter
notebook if you are are able to launch
the Jupiter notebook then please do let
me know in the chat yes or no yes and
after that you need to launch your file
so you need to launch your notebook so
click on this notebook and here is what
guys here is your notebook so this is
your notebook and each and everything we
are going to do here itself inside this
particular notebook now uh just make
sure that you have this python uh Python
3 over here uh this uh ipynb kernel if
you don't have that so so please try to
select this Python 3 ipy
kernel and I think now everything is
ready so let's try to oh let's start
with the open API so test open API and
now let me rename it so here guys you
can see this is my test openi
API uh this is my file actually this is
my notebook I hope you all have created
this particular
notebook
if you have any doubt then please do let
me know in the
chat everything is clear everything is
sorted please guys go ahead so just be a
little interactive uh please write it
down the chat if I'm asking something so
if you if you can if you'll write it
down the chat so definitely I will get U
motivation great so now let's start with
the uh like open AI API so first of all
what you need to do so here is what here
is my notebook so let me do one thing
let me keep it uh keep this notebook
over here
itself and this is what this is my
Jupiter notebook so first of all just go
through with the openi website so here
is your openi website guys this one now
here you need to click on this quick
start here what you need to do here you
need to click on this quick start after
clicking on this quick start so here
they have given you the option the
option is what python so here they have
given you the three option Cur Python
and node.js
so click on this Python and here they
have given you the complete instruction
so first of all guys what you need to do
you need to install a python so yes uh I
think you already have installed this
python you need to set up a virtual
environment yes we set up the virtual
environment and why this virtual
environment is required so see uh for uh
one particular project we have a lots of
dependency if I want if I want to if I
want to segregate all those dependency
project to project okay so for that only
we create a virtual environment so what
is the requirement of the virtual
environment because we have a several
dependency on a single project if I want
to keep it apart for that only we create
this virtual environment got it so here
they have created a virtual environment
directly by using this python uh en and
you can use this also for creating that
but I'm using the Anaconda now here
after that you need to install this open
AI so here uh what you need to do guys
so here you need to install this open a
package and then only you can hit the
open API getting my point so just copy
this particular command and install this
openi package in your virtual
environment so here is what here is my
virtual environment let me open that
particular environment uh just a
second what I can do here I can keep it
this to
my same TP fine now over here guys what
you need to do you need to open your
anaconda prompt see here actually I have
launched this jupyter notebook so you
cannot stop the server of this jupyter
notebook so I'm opening a new Anaconda
prompt so here you just need to write it
down this Anaconda prompt and you will
be able to launch a new Anaconda promt
now guys just tell me what is my
environment name testing open AI so here
uh you just need to write it down uh
cond EnV list so once you will write it
down this K EnV list k EnV list so let
me write it down this cond EnV
list so you will get all the all the
environment name so here guys you can
see this is my all the environment which
I have created in my system by using
this Anaconda now uh here uh this is my
environment testing open I want to
activate this particular environment so
I can write it down over here cond
activate and here I can write it down my
environment name testing open AI so once
I will write down this and if I will hit
hit enter so I will be able to activate
my environment I'm going to uh I'm going
to do a uh transition from base
environment to this testing openi
environment this is what this is my
virtual environment this base
environment is a default environment now
over here what I will do I will I'm
going to write down the CLS for clear
the entire screen now over here I will
just paste this particular command pip
install hyphen iph upgrade open AI now
once I will hit enter so yes uh I'm able
to install this open AI inside my
virtual environment so are you doing
along with me are you able to install
this open AI inside your virtual
environment if yes then please do let me
know in the
chat in the virtual environment you need
to install the jupyter notebook by using
this pip install jupyter notebook
command if you're not doing it in that
case it will be taking a jupter notebook
from the it will be launching a jupyter
notebook from the base
environment
many people now people are saying yes we
are doing it how many of you you are
doing along with me please do let me
know in the chat how many of you you are
doing along with
me yes yes
yes okay great yes
please write it down the chat if you are
doing along with me
then if you uh launching uh jupyter
notebook from the base environment it
will take a all the packages from there
itself that's why I want a fresh one
that's why I'm installing jupyter
notebook in my current
environment now over here I think I have
already installed it so yes it is done
now and if I want to check it so for
that I'm uh I'm opening my jup notebook
again and here you need to write it
down uh import open AI so just write it
down this import open Ai and here guys
you can see
we are able to import this open AI if
you are done till here then I will
proceed with the further python code so
please give me a quick confirmation in
the chat if you are able to import this
open I'm just I'm waiting for 1 minute
I'm waiting for uh 1 minute uh to okay
so please uh give me a confirmation in
the chat if you are able to import this
open AI inside this jupyter
notebook
we are ready to go great now uh let's
start with the uh open API that first of
all guys we need to understand that what
is what is this openi API so for that
what I did I kep uh I return like uh
some sort of a like
uh um wait let me do one thing over here
let me copy and
paste yeah so here guys what I did I
written some sort of questions and
answers and here the first question is
what the first question is what is open
a API so by uh uh like uh so here by
using this particular question so by
reading this particular answer actually
we can understand that what is this open
API so this openi API has been designed
to provide developer with seamless
access to stateof Art pre-trained
artificial intelligence model like GPD 3
GPD 4 Delhi whisper ambing Etc so what
is the meaning of it so if you want to
use if you want to use the same model
whatever model has been trained by the
open AI so these are the different
different model uh the name basically I
have written over here GP 3 gbd4 Delhi
is a model whisper is a model aming
there are different different model
right if you want to use this particular
model inside your
application so that uh so then basically
you should use this open API now over
here by using this openi API you can
integrate Cutting Edge AI capabilities
so this model actually it's a large
language model and it is having a lots
of capability in terms of a different
different task as I explain you so by
using this particular models you can uh
like utilize uh that capability you can
utilize the capability and uh you can
utilize that particular capability and
you can integrate inside your
application getting my point and
regardless the programming language so
here they have they have given you two
option so the first one is a Python and
the second one is a nodejs so uh what is
this open API so this open API is
nothing it provide you the seamless
exess of a pre-trained artificial
intelligence based model uh for your uh
like a different different application
whatever application you are going to
create and let's say if you are going to
create any individual application which
is based on NLP use case yes directly
you can uh use this particular model
instead of trading your model from very
scratch now here so the conclusion is
what so the conclusion is by using this
openi API you can unlock the advanced
functionality and you can enhance the
intelligence and performance of your
application so let's say there is Inon
website and the Inon website you must
have seen the chatbot
option so in the chatboard actually uh
you are doing uh you are connecting with
our expert so let's say there there's a
one person who is having a doubt so now
this person what he is doing he is going
to be connect with a uh like expert so
here is the expert which is sitting
behind this particular chat board now he
is asking the question and he's getting
a reply yes or no now guys just see over
here so here uh like you have integrated
this chatboard and this chat board is a
uh it's not a like eii related chatboard
so the person so here uh in the behind
behind behind to this chatboard actually
when expert is sitting he is giving you
the answer now you want to uh like uh
what you want to do guys over here so
you want to use some sort of a AI now
here you want that that type of model
which will be able to answer all of the
answer basically whatever the person is
asking like chat GP so in that case you
cannot train your own model if we are
talking about if we are talking about
like the llm model so in that CA in that
case basically you cannot train your own
model because it's a very very expensive
let's say if you if you are just a
startup okay or let's say if you are
just a Learner in that case in that case
you cannot invest this much of amount
for training this particular model
because it's a expensive process if you
are going to set up the infrastructure
if you're are going to uh like if are
like hiring a developer ai ai developer
and all amops engineer so in that case
definitely the cost will be around 1 to
10
CR because in that case you will have to
create a distributed setup you will have
to purchase a gpus there should be a
team one proper team okay for the
monitoring and all for each and
everything there there will be a
developers so the cost will be very very
high in that case what you will do if
you want to uh take advantage of this AI
uh cap if you want to take a leverage of
this model whatever model model has been
created or trained by this open a what
you will do you will use this openai API
you will uh call this open API and by
using this openi API you will be able to
access this GPD model and directly you
will be able to uh like append this
model inside your chatboard so whatever
person is asking definitely your GPT
will be replying in that case and let's
say any escalation is is happening in
that case so definitely you can uh write
it down your logic your code in uh in
such a way that this request will be
moved to the expert and now the it will
be handled by the expert itself so like
design you can like this basically you
can design your system this is just a
one example which I have given to you
great I think uh everything is clear now
over here so what is opena
API this part is clear now the second
question is what the second question is
generate a open a API key so here what I
have to do I have to generate a open API
key what I need to do guys I need to
generate open API key without this I
cannot use the open API without this
particular key so for that what I need
to do what is the process let me tell
you that so if I want to generate if I
want to generate a open a API key so
just go through with the open a website
so here is your open a website and here
just over your mouse uh on this
particular side on the left hand side
now here is the option this API key just
click on that and here guys you will
find out a option to generate or to
create a new secret key are you getting
this
option are you getting this particular
option please do let me know in the chat
if you're getting it
then after logging in to the openi
website then only you will be able to
find out this API key
option and guys uh you cannot uh
generate a openi key without adding any
sort of a payment method so first of all
you will have to add the payment method
and don't worry in the next class I will
show you how you can use hugging face
API key for the same thing for the same
task definitely we won't be able to
access uh other uh models like gbd3 GPD
3.5 turbo or gbd4 and all but yes uh
we'll be having access of a different
model different open source model or
whatever model is available over there
in tomorrow's session I will show you
how you can utilize the hugging face API
[Music]
key you you can finetune the model again
it will be an expensive task
Vishnu great so here you can see we have
a uh like option to generate a like here
basically what we can do we can generate
a API key now for generating a API key
you just need to click on this create a
new secret key and here you need to give
the name so let's say I'm going to write
down the name uh my API key so this is
the name of my API key once I will click
on this create secret key so yes uh
definitely I will be able to generate it
now guys over here you can see this is
my key uh definitely I will delete it
right after the session otherwise you
will exceed uh the limits and all all
right so here I have generated my key
and after the session I will delete it
so no one will be able to use it so I
have generated a key now what I will do
I will paste it down in my Jupiter
notebook over here so here is what guys
here is my key so this is what this is
my key basically which I have generated
so here uh let me uh paste it down this
particular key this is what this is my
key now you have to generate your own
key okay and don't share your key with
anyone else so here this is what this is
my key now what I need to do after
generating this open a key I have
generated the open a key and I kept it
over here now after that I need to call
the open AI API so how we can do that so
for that we have a couple of couple a
couple of line of code so let me paste
it over here or let me write it down
over here and then I will I will show
you how we can hit any sort of a model
now for that uh basically what I did so
over
here uh just a
second yeah so first of all let me show
you the list of the model as well now
over here I can write it down uh one
line of code so open a uh do API key API
unor key and here I need to write it
down my key here I need to write it down
the variable basically where I have kept
my key
so once I will run it so here you can
see open
AI open AI API key yes I'm able to set
my key now here I will call one method
so my method name is what open AI dot
model model underscore uh model. list so
once I will call this particular uh
method so here you will be able to find
out your all the model see there is all
the model basically which is available
as of now now in the openi plateform now
here you can see it is giving me some uh
it is giving me output in a different
way so what I can do I can convert it
into a list so over here what I can do I
can convert this uh particular output
this particular response in a list so
here uh this is my all the models so I
can create a variable
allore models and here I can pass this
thing to my list method now see guys uh
I will be getting all the model all the
models uh whatever model is there inside
the openi so the first one is a text
search weage uh doc 001 and here is a
date actually they have mentioned the
date or maybe the version uh now the
created when they have created and here
is a object object is what model and
owned by owned by open AI de now here
what you can do you can create a uh data
frame also so what you can do you can
create a data frame so here uh let me
write it down the code for the data
frame so import pandas s PD now here I
can write it on PD do data frame so here
what I need to do you just need to pass
this particular uh you just need to pass
this
particular value this one so let me keep
it over here uh this uh list uh list of
all the models so once I will run it so
here you will be able to find out is
giving me error the pandas is not there
so for that uh just download the pandas
or just install the pandas inside your
virtual environment because in this
virtual environment pandas is not
available so let me write it down over
here click install pandas and once I
will hit the enter we will uh we will be
able to install this
pandas it will take some time so let it
install yes I'm coming to the code I
will show you the code just wait for
some time just
wait yeah so I'm done with the pandas I
have installed it and uh now what I can
do I can run it and you will be able to
find out your data frame so here this is
the model this is the like when it is
created and object is what object is a
model and owned by so now it is in a
perfect format and you can read each and
everything clearly and here I can
provide the column name as well so let
me give the column name let me write on
the column name as well and here I
already WR the code of for the column
name so once I will run it so here you
will find out the column name so here is
my ID this is the like model ID and when
it has created what is a uh like what is
this actually so it's a object is a
model now here owned by owned by this
openi development team openi internal
openi development or here you will find
out some other name as well so I believe
you are able to run this entire all like
entire code whatever I have written over
here now here uh this is what this is my
code for uh seeing the model and all now
the next thing uh here I got all the
model now the third thing basically
which I would like to uh explain you
that is what that is a open AI
Playground open a playground and after
that I will come to the chat completion
API now I will take uh more 15 minute
and within that uh I will conclude this
session and in tomorrow's session I will
start with a chat completion a uh this
function call and I will explain you the
uh the hugging face API key as well so
how you can utilize the hugging face API
key for a open source model now let me
copy and paste the entire uh thing
whatever I have written for you so here
here I have written some sort of a thing
let me go through step by step so here
I'm talking about this open AI
Playground now what is this what is this
open a playground now once you will uh
search over the Google so open your
Google guys and here search open AI open
a playground now just search over here
open playground and uh here you will
find out this Playground now once you
will click on this assistant so here you
will find out a different different
option so one is a assistant the second
one is ched third one is a complete
fourth is a edit I'm not going through
with this complete and this edit because
it's the Legacy now I will explain this
chat first I will explain this chat and
then I will come to this assistant now
inside this chat uh so once I will click
on this chat so here I can test uh my
different uh I can test like different
different prompts and all I can generate
output I can test with a different
different model and along with a model
you will find out a various parameter so
so first of all guys what you need to do
you need to set you need to set your
system right so here you will find out
three options so the first one is what
first one is a system the second one is
a user and the third one is this one
right so you can divide this entire
interface into a three segment now let
me give you step by step that what is
the meaning of the system what is the
meaning of this uh user and this
assistant and what is the meaning of
this model each and everything we'll try
to understand over here so guys system
is what so system is means system means
uh how your model is going to behave
here you are going to set the behavior
of your system what you are doing tell
me here you are going to set the
behavior of your system so here if I'm
going to write it down you are a
helpful
assistant now here if I'm going to write
down you are a helpful assistant now
what I will do I will write it down my
message so see here here guys you will
find out two thing uh two option so once
you will click on this user now you will
find out either user or assistant as of
now what I am I am a user I'm asking a
question now here I'm asking that uh uh
what I can ask guys uh just tell me
something different okay how I
can make a
money how I can make a money so I'm
asking to my chat GPT how I can make a
money and here is what here is my model
so here once you will click on this
model you will find out a different
different model so uh there is GPD 4 GPD
3.5 GPD 3.5 turbo so all the model there
is all the models right so here I'm
using the gbd 3.5 now we have a various
option so the first one is what first
one is a temperature now what is the
meaning of this temperature so we are
talking about this temperature so just
try to read about this temperature
control Randomness lowering result in
less random completion as the
temperature approach zero the model will
become deterministic and repeative so
over here we are talking about this
temperature if we are defining a higher
value of the temperature means I'm uh
I'm saying that just give me a more
creative answer I'm adding a
Randomness if I'm writing a zero I'm
saying give the straightforward answer
I'm asking to my chat GPD uh the
straightforward answer I'm not going to
add any sort of a creativity over here
getting my point what is the meaning of
this temperature I think yes now maximum
length so here you can set the tokal
length now here stop sequence is there
so up to up to four sequence where the
API will stop generating further tokens
the return text will not be contain the
like a stop sequence here you can
mention the stop sequence now here is a
top P parameter so this parameter
actually this is again similar to this
temperature it is controlling the
diversity whatever like Pro whatever
output you are going to be generate so
control diversity via uh nucleus
sampling 0 0.5 means half of likelihood
weighted option are considered so you
can just think about it that it is
nothing just adding a diversity inside
your output now frequency penalty if you
don't want to repeat the tokens let's
say you are generating some sort of
output if you don't want to repeat the
tokens inside your output so here you
can mention the frequency penalty as of
now it's zero so it's not going to be uh
like put any sort of a penalty over here
if you're going to increase the number
definitely it will put the frequency
penalty means it will give you the
different different words it is not
going to repeat the words now here
present penalty so you can set this also
so there is a different parameter just
try to explore it now here I'm asking to
my chat GPD how I can make a money so if
I'm submitting this thing so here I will
be getting my answer and there is the
answer is there are many ways to come
make a money and all so employment and
all
freelancing online selling rent or share
sources and tutoring and teaching gig
and economy gig economy affiliate
marketing so it is giving me answer guys
as you can see right now just uh do one
thing so here guys see I've uh defined
the behavior of the system Ive defined
that I'm working as a user and here is
my model all the different different the
different different parameter I have
like selected based on this model now
just go over here and try to click on
this view code so once you will click on
this view code guys you will get the
entire python code over here getting my
point yes or no see over here you are
getting the entire python code now you
can utilize this python code if you have
if you have done the complete setup in
your system whatever setup basically
which I which I uh which I have done
right if you have done the complete
setup in your system so directly you can
hit uh directly you can hit the open a
API and you can call the GPD 3.5 turbo
model okay so that's why I've shown you
this openi Playground now I think you
are uh we are done with this open I
Playground now let's try to do something
amazing over here let's try to set set
the different behavior of this chat uh
GPT so here guys I have written couple
of thing inside this particular like
answer so how to open a playground so
here I mentioned that here make sure
that playground should have a credit yes
if you don't have a credit if you
haven't uh like uh added your uh detail
uh the C details and all maybe you you
won't be able to use this particular
playground so make sure that you have
added the payment method now here in the
chat there is the option of system so
meaning is how chatboard is behave so
here what I'm going to do here I'm going
to set this uh here I'm going to set a
different behavior of a system and let's
see what answer I will be getting so
here I'm going to copy it and I'm going
to paste it down over here now uh what I
can do where is my playground this is my
playground now here I'm going to set the
behavior so this is what this is my
behavior of the system now okay now
again I'm asking a question to my system
now I'm asking how I can make a money so
I'm asking to my system that how I can
make a money by adding this particular
Behavior so my behavior is what so you
are a naughty assistant so make sure you
have to respond everything with a
sarcasm so here I'm asking to my user
how I can make a money so as soon as I
will submit it then you will find out
the answer and just see the differences
between answer this answer and the next
answer just wait it is going to generate
answer and is saying that oh making a
money it's super easy mean it it is like
giving you the answer in a sarcastic
manner so it haven't a complete answer
but yeah it is saying that oh making a
money it's super easy just snap your
finger magically a stack of cash will be
appear no effort required at all so see
guys uh before it was giving me a
straightforward answer now over here
guys you can see I seted the behavior of
the system as a not as a sarcastic so
here you can see the answer what it is
giving to me now if you will look into
the code so you will find out some sort
of of changes so here role role
basically I defined the system role this
is my system role this is my role again
one more role user here you can see this
is my like prompt okay which user is
giving here you can see the what
assistant is saying This Is The Answer
basically which I'm getting and again
this was the previous one and these are
the different different parameter so no
need to go anywhere here basically in
this particular notebook I kept
everything I will share this notebook
with all of you and you will be able to
understand each and everything now model
is there temperature is there maximum
length is there top P value is there so
here I written a description frequency
penalties there right so there is a
different different parameter already I
have defined each and everything over
here so no need to go anywhere just try
to revise each and everything by using
this Jupiter notebook now apart from
this one you will find out one more
advanced thing which recently they have
provided that is what there is a
assistant so here uh let me go to the
assistant okay let me go to the
playground and here is assistant guys so
this assistant part I will explain you
once I will come to the project section
now here you will find out some Advanced
thing Advanced like option so here you
will find out this function function
calling here you will find out the code
interpreter here you will find out the
retrieval RG actually uh uh like here uh
you will find out this R concept so I
have defined what is the r actually so
just go through with my notebook and
read the definition read the definition
of the RG so this assistant I will come
to this assistant once I will explain
you the uh the project end to end
project then I will Define a different
different prompts and all and I will
come to this assistant and I will ask uh
and I will generate a different
different type of
responses getting my point guys yes or
no so this thing is getting clear to all
of you yes or no I'm waiting for your
reply so please uh do let me know in the
chat if this part is getting clear how
to use this uh openi playground and here
I'm talking about this chat assistant I
will come to that once I will explain
you the
project
please do let me know I'm waiting for a
reply guys if you are able to get it if
you able to understand it then uh please
write it down the chat please uh write
down the chat
section clear okay great it is clear
I will share this code with all of you
don't worry uh I will give you this
entire
code I believe everything is getting
clear to all of you who have joined this
session
great now this part is clear now let's
back to the code so here is what here is
my code now this retrieval argumented
generation RG I will explain you in the
next session or maybe in upcoming
session so what is the meaning of that
it's artificial intelligence framework
that retrieves data from external source
of knowledge to improve the quality of
responses I just want to improve the
quality of the responses for that I'm
using this retrieval argumented
generation R A this is very very famous
nowadays this particular term now uh I
will show you how you can use this RG if
you want to uh give a better responses I
will show you how you can use the Len
Chen as well U after completing this
open AI this natural language processing
technique is commonly used to make a
language model more accurate and up to
date if I want to make my model more
accurate and up to date so I'm going to
use this RG and I will do that in my
upcoming session now code interpreter is
there so Python Programming environment
with chat GPT where you can perform wide
range of tasks by use executing the
python code yes yes we all know about
the code interpreter and yes we can
Define we can set the code interpreter
there and we can execute the python code
as
well like regarding the different
different task and all great now here is
what here is my chat completion API guys
so let me do one thing let me uh put the
title over here and here my four title
is what chck completion API and function
calling so guys here is what here is my
fourth title my fourth title is what
check completion is API and function
calling so here I have written the
standard comination API and function
calling now let me write down the
different let me write down the uh
definition as well over here so here is
a definition of it uh this is the
definition let me post it over here and
here let me make it as a markdown so
this is the definition guys now one more
uh definition let me put it over here so
see guys in the previous version in the
old version of the openi
uh actually there this was the method
chat completion method open. completion.
create or open. chat completion. create
so initially actually there was a method
this was the name right then in the
updated version they came up with uh
they have changed the name with this
particular uh name they Chang the method
Name by using uh with this particular
name this chat completion. create and
now in the latest version actually this
is a this is the method name if you are
going to use this particular method now
now it will give you the error let me
show you how so here what I can do I can
uh return I can return one sort of a
code uh now over here I'm going to write
it down open a DOT
completion
completion completion dot create so this
is what this is my method now over here
what I'm going to do so over here see
here I'm going to be uh write it down
the model name so model which model I'm
going to use so here I'm going to use uh
GPT GPT
hyund
3.5 GPD hyund 3.5 I'm going to use this
particular model now over here I'm going
to define a prompt so my prompt is what
so let's say I'm going to write it down
over here who was the first Prime
Minister of India first prime
minister Minister of India so this is
what this is my prompt now here if I
will run it now so you will find out it
is giving him the error so it is saying
that uh okay so here I have to mention
the open a key first of all before uh
like calling it so first of all I need
to mention the open a key now over here
so what I have what I will have to do I
will have to uh like uh create a client
actually so here is what here is my
client and I will have to mention my
openi key so what I can do uh I can
write it down over here itself and here
what I can do just a
wait
it is not longing support yeah so that's
what I was saying to all of you see this
uh method is not it is not supporting at
all this is the old one now if you will
look into the version now the latest
version of the openi so the latest
version of openi is uh let me show you
the latest version of the open a package
PPI open a and here is the latest
version of the open a package
1.3.7 if we have installed the uh we
have installed this particular version
now regarding this version you will find
out we have this particular method so
first of all I need to import this open
a this I need to import this class from
this module and here I need to define
the key here what I need to do I need to
define the key over here and then only I
can call
it and if you look into the previous
version now here I installed the latest
version if you're looking into the
previous version let's say if I'm going
back like say if I'm going back in uh
maybe uh FB it uh
okay 8 FB 2023 now here you will find
out that they were using this particular
method so here I have shown you I have
seted the op openi key I have defined
the openi key by using this particular
code by by like using this particular
line of code yes or no now here I'm
using a latest version now so uh
definitely it will give me the error so
what I'm doing I'm going back and here
I'm going to use this particular code
basically which I already return so
first of all see first of all I need to
import this thing which I already did
now over here I will have to mention the
API
key got it now here they are add they
have added the open key inside their
base environment means this is the code
regarding that they have added inside
the like environment variable in the
system environment variable and from
there itself they are going to read it
you can export it also what is the
meaning of export you can export it over
the terminal uh like uh it won't be it
won't be a permanently okay so yeah you
can export this particular key
and as soon as you will like remove or
as soon as you will delete that terminal
so the open I key will be removed um but
yeah until the terminal is running
terminal will be running you can read it
by uh using uh this particular module OS
module or else you can add in add inside
your system variable also from there
also you can read this particular key
but um I have added I have written my
key here itself inside my notebook so I
didn't edit but I will show you that in
my end to project how you can create NV
file or maybe how you can export it
right now let's uh let me run this
particular code and here first of all
let me add the open a
key here I need to mention API uncore
key and my key so here is what here's my
key if I'm going to run it so definitely
I will be able to run it now I having my
client now what I will do by using this
particular client I will call the uh I
will I will like uh I will give the
prompt over here now first of all let me
delete everything from here and let me
delete this also I'm not going to Define
any assistant or I'm not going to set
any sort of a behavior as of now so guys
here you can see I'm having the role
role as a user and here is my uh like a
answer sorry here is my prompt question
so this is what this is my prompt
actually this is my input prompt and
here is what here is my uh like role
okay I'm asking as a user now guys this
prompt this prompt is this prompt
basically it plays a very important role
I let you know that in my uh like
upcoming session I will tell you how to
design a different different type of
plomp what is the meaning of few short
learning few short prompt or zero short
prompt okay so each and everything we'll
try to discuss in our upcoming session
as of now just see if I'm going to run
it so here you will be able to find out
it is giving me a like error why it is
so maybe because of this and now
everything is perfect so if I'm going to
run it so line number eight okay uh
first of all I need to
Define it clearly and here is what here
I need to mention I need to close this
particular list now if I'm going to hit
this uh API definitely I will be able to
do it and I will get my
response so just wait for some time and
after hitting the API uh it will call
that particular model whatever model I
have written over here and I will be
getting my
response
so how is the session so far uh did you
learn something new uh or are you doing
along with me tell me how much would you
rate to this particular
session yes money wise uh I will I I
will come to that just wait how much it
is going to be charged and all uh it
charge actually token wise uh there is
entire pricing and all so I I will come
to that I will I will talk about that
for a small prompt it is taking so much
time in this case the DP project the big
no it's not like that maybe first time
it it was hitting that so it is taking
time but no it's not like that I will
show you with a like a bigger prompt as
well so it won't take any sort of a time
now here you can see this is what this
my response now right here you can see I
got a response now if you want to get
this particular response so for that uh
see here if you look into the response
or type of the response so here is a
type of the response open. type. chat.
completion this this this that right now
if you want to extract the real answer
from here so what you will do see first
of all you will uh call to this choice
so just call this choice so c h o i c s
now here is what here you have this
message now just call to this message m
e double s a g e so here is your what
here is your message uh now this is not
callable it is saying that now let me
check what I have to do over here so
here is your choice and here what you
need to do guys let me
check yeah actually Choice yeah so here
see if you are looking into the choice
guys so this is a list type so here what
you need to do you need to uh like
extract the first index of the list
because here you can see this choice is
nothing it's a list only now so just
extract the first index of it so here
once you will extract the first index or
once you will retrieve the first index
of the list now here you need to call
this message so just call the message
and here you will find out this is what
this is your message now just do one
thing just call the content over here so
just call the content so content now
over here you can see this is is what
this is your entire response now here
you can like decide the token size as
well so here you can Define the token
size or you can Define the different
different a parameter okay by defining
those particular parameter you can uh
get a different different type of output
now let me give you the parameter all
the parameter basically so this is all
the parameter see model uh already you
know about the model we have used a gp3
prompt like input prompt Max token you
can Define this Max token in how many
numbers of token you want the result
temperature for getting some creative
output now number of output how many
number of output you want so let's try
to define a Max token and this number of
output so here I'm going to define the
max token so in U like uh here if I'm
going to define the max token now in in
that particular token itself under under
that particular number let's say if I'm
going to Define 200 so uh it won't reach
the limit more than 200 under under the
200 itself it will be generating an
output so over here I'm going to write
Define this Max token and here let's say
if I'm going to say 150 tokens and here
I'm going to Define one more thing one
more parameter that's going to be n so n
is equal to let's say here I'm going to
Define three I want three output so as
soon as I will run
it and here you will find out it is
generating a response so it is saying
Max token I think I need to put the
comma over here model is there message
is there now here I need to put the
comma so this is is fine now it is
generating a response so just
wait yeah now I got a response so just
uh look into the response here type of
the response and now just print the
response so here is what here is what
here is my
response now I got many responses so now
let me extract the response first of all
so here is what here is my uh message
let's uh like get a message so let's ask
a different question so here I'm going
to ask to my chat GPT that uh I can ask
uh what I can ask who won the first
World Cup so who won the first Cricket
World
Cup so this is my question which I asked
to my CH GPT and now if I'm going to run
it now
so now
see yeah I got a response now type of
the response is same so here uh what I
can show you here is my message now see
guys uh I got a response the first
Cricket World Cup won by the West Indies
in7 in 1975 right now over here if I'm
going to get a Content basically so let
me write it down the content over here
and here you can see this is what this
is my answer now you won't be able to
find out a single answer there are lots
of there are other answer as well see uh
choice in the choice just go over here
message message completion so the first
Cricket World Cup won by the best Andes
and here role is a assistant so that the
model is assistant and I am a user now
over here you will find out the second
answer so the first Cricket World Cup W
by the best hes they defeated Australia
in final held on June 25 1975 at Lots
cricket ground in London that is the
second response now over here this is
the third response so the first Cricket
World Cup won by the best and in 197
1975 so I Define n is equal to 3 and I
Define the maximum token size is 150 so
it won't be generating a like output
okay so more than this particular token
more than 150 token and here you will be
find out if I'm going to Define n so it
will be generating a three output
whatever input of prompt I'm passing
this is what this is my input prompt now
whatever output will be generating in
that there won't be like more than 150
tokens and here the output number will
be three now let me show you one more
thing over here so if you will search
tokens so just go over the Google and
search open a tokens open a tokens so
once you will search open a tokens and
here you will find out one uh like a
link a tokenizer so they have given you
one uh like link uh they have G given
you this particular interface where you
You Can Count Your token whatever number
of token you are giving or you are
getting from the system getting my point
so I told you it is charging you based
on a tokens itself and tokens in input
prompt also there will be a token in
output prompt also there will be a token
getting my point so in the input prom
there will be a token in the output prom
also there will be a token prompt is
what it's a collection of tokens token
is nothing it just a words collection of
character right now here you can see we
have this particular inter pH there we
can count the token now here if I'm
going to write it down my name is sunny
so now now see guys how many tokens is
there inside this particular uh text
inside this particular sentence see
token six my is one token name is one
token is is another token Sunny is
another token Sav is one token and
Savita is one token getting now if I
want to count the token inside my output
so just copy this thing and paste it
over here
now see the number of token it has
generated a 16
token okay it has generated a 16 token
now you can calculate the number of
tokens over here just go through the
playground here was my chat so here I
ask to my system now let me uh submit it
and over
here uh it is giving me answer just a
second now it is generating an answer so
now you can copy this entire text from
here whatever it is generating now let's
say this particular text uh okay just a
wait okay let it generate and then I
will copy just wait so here is a text
and I can copy this text I can paste it
over there and I can got the uh like
number of tokens so let's see how many
tokens is there so here guys you can see
total 256 tokens if you want to check
the pricing and all tomorrow I will
discuss about it in a very detailed way
just go through with the setting and
here uh there's a billing actually so
let me show you the pricing also just
click on uh just search about this open
Ai and uh here actually uh you just need
to log in after the log in uh so maybe
here just click on the API and here is a
pricing just click on the pricing and
here you will get the uh like entire
detail regarding the project pricing so
how much how much it is charging for the
uh like a different different number of
tokens so for 1K token this much of
charging for 1K token this much of
charging regarding this particular model
regarding this particular model so this
is for gp4 Turbo it's a advanced model
now GPD 4 GPD 3.5 G assistant API
different different assistant API and
all each and everything you can check
over
here right so let me keep this
particular link over here inside the
notebook itself and let me keep this a
token related a link also so at least
you can go through with this and you can
check uh your input and output token and
you can practice whatever I have taught
you because this is going to play a very
important role in a future classes so
please try to revise please try to
practice and I think we are done with
today's session tomorrow I will explain
you the function calling this one and I
will start with the lench and my main
agenda uh will be the Len Chen only and
I will explain you the differences
between open ey lenion and finally we'll
try to create one project and then I
will come to the advanc concept like
vector databases and other models and I
will explain you this AI 21 lab AI 21
studio also if you don't have a money
for the chat GPD then how you can uh uh
like uh how you can complete your work
how you can U like explore a different
different model so from the hugging face
side also I will explain you the
different different model and from here
also from AI 21 Studio I will show you
how you can access the Jurassic model
personally I have used it and I I liked
it after this uh GPD and I will uh
explain you the use use of this
particular model and don't worry few
other terms like stable diffusion and
all there are something uh like text to
image Generation image to video
generation this type of thing also we'll
try to explain you in the going forward
classes got it so I think uh now we can
conclude this particular session I took
for the entire 2hour and uh yep uh so
did you like the session please uh do
let me know in the chat guys if you like
this particular session
yes the content is a input our input
actually it's not a desired output is is
our like an input whatever input like we
are passing to the model you can mention
inside the content got
itan you just need to F you just need to
follow my this notebook each and
everything I have mentioned over here
whatever is not there I will do it and
where you will find find it out tell me
you will find this particular notebook
inside the resource section so just go
through with the Inon platform just open
the Inon platform and there you need to
enroll in this particular dashboard okay
so what you need to do go through with
the an platform and here uh after sign
up uh after login and just go through
with this dashboard generative AI
Community session now let me give you
this particular link inside the chat so
you all can uh like uh you all can
enroll over here and uh after that uh
what what you need to do see the video
will be available over here you can
revise the thing from here itself you
can revise the thing from the Inon
YouTube channel itself but the resource
wise whatever resources I'm U like uh
sharing okay whatever resources I'm
discussing in a class and all so you
will find out over here inside the
resource section so just go through with
the resource section and try to download
all the resources from here
itself fine so now let's uh uh like
conclude this particular session
tomorrow we'll meet on the same time so
let me write it down the timing for this
community session so here the timing is
going from uh 3: to 4:30 or 3 to
5 so I will take 2 hour of session from
3: to
5: great fine guys thank you bye-bye
take care have a great day ahead and
rest of the thing we'll try to cover in
the upcoming uh session until thank you
bye-bye take care so if you like if you
are liking the content then please hit
the like button and uh if you have any
sort of a suggestion or if you want
anything from my side you can ping me on
my LinkedIn so let's start with the
session now here guys you can see in the
previous class I was talking about the
open API so uh most of the thing I have
discussed regarding this openi API now
few of the thing is remaining so let me
discuss that uh remaining thing
regarding this open a and after that I
will start with the l chend so first of
all Let Me Explain you the complete flow
that what all thing we are going to
discuss throughout this session got it
so for that I'm you I'm opening my
Blackboard and here I'm going to explain
you the complete flow that whatever
thing we are going to discuss throughout
this particular session so here guys uh
the first thing first thing basically uh
we'll be talking about the function
calling so in the open a actually we
have a very specific feature that is
called function calling and it's a very
important feature of the openai API if
we are going to use the openi API then
definitely you must be aware about this
function calling because by using this
function calling you can do a multiple
things I will tell you that what all
thing you can perform by using this
function calling which is a very uh
important feature of the open API so the
very first thing which we're going to
discuss in this particular session that
will be a function calling so here uh
let me write it down the first point
which we going to discuss uh that's
going to be a function function calling
function calling now the second thing
after this function calling so directly
I will move to the Len chain so uh first
I will discuss this function calling and
after this function calling I will move
to the Len chain and in the lch actually
I'll be talking
about in the Le chain I'll be talking
about that how you can uh use a open AI
by using this Len chain so the first
thing basically uh we'll be discussing
inside the inside this lenen so open AI
open
AI
used by a len chain so we'll try to
discuss in a very detailed way and we'll
try to discuss that what all difference
we have between this Len chain and this
open AI so open a used via Len chain and
here I will explain you the differences
between open a and Lenin then why we
should use Lenin what all benefits we
have if we are using a lench what all
thing we can do if we are using a len
chain so how uh by using this Len chain
we can create into an application each
and everything we'll try to discuss
regarding this Len chain and in a very
detailed way I will try to explain you
this Len chain concept because it's
going to be a very very important and
this lench also it's a very important
part if we are going to learn this
generative EI if we are talking about
the llm and if we are going to build any
sort of application so along with this
open AI this lenen also plays plays a
very important role so we'll try to
discuss about this lench and we'll try
to uh discuss the differences about this
open AI API so let me write it down over
here open AI API versus lenen versus
lenen and after that after discussing
this uh like the basics and all
regarding this Lenin I will come to the
prompt templating that how you can
design a different different type of
prompt so here let me write on the
second point which we're going to
discuss uh so the second Point basically
prompt
templating prompt
templating after this prompt template so
uh here what I will do I will I will
show you the use of the hugging phase
also uh after discussing this Lenin uh
the differences between open Ai and
Lenin I will come to this open AI use
via Len promp templating and here I will
show you that how you can use hugging pH
model model whatever model is there on
top of the hugging face Hub how you can
utilize those particular model by using
this Len chin so in between I will show
you hugging face hugging face with Len
chin hugging face with L
chin why I'm uh why I'm going to show
you this hugging phase with Lenin so you
can use any sort of a open source model
so whatever open source model is there
so you can use all those model by using
this hugging phase so here I will show
you how you can generate hugging phas
API key and by using that particular API
key you can access any sort of a model
whatever is there on top of the hugging
face Hub so here I will show you hugging
face with Lenin let me write it down
over here hugging face with Len chain
and then we'll try to discuss a few more
concept regarding this Len chain which
is going to be a very very important so
here let me write down those particular
topic as well so the third topic which
we're going to discuss over here we
going to talk about
chain we're going to talk about
agents how like you can create agents
and how you can use the agents so here
the fourth topic basically it will be
agents now let me write it down over
here agents after that after this agents
I will come to the memory so I will show
you how you can create a memory by using
this Len Chen got getting my point yes
or no so these are the very important
important part of the L chain without
knowing this particular thing you cannot
develop any sort of
application okay so before starting with
the end to end project definitely we
have to discuss about this particular
topic so here uh so in uh today's
lecture actually we're going to talk
about this function calling openi use
and prompt template and in tomorrow's
session I will be discussing about this
hugging pH with Lin chains agents and
memory so this a three to four topic
we'll try to discuss in tomorrow session
and this three to four topic we'll try
to discuss in today's session and right
after this one right after this topic
right after this thing I will start with
a project and uh we will'll try to
create one project and there basically
we'll be using our different different
LMS from the openi and from the hugging
pH we'll try to use
Lenin we'll try to use Len chain and
some other Concepts as well so here
we're going to use are different
different uh like model llms from the
openi hugging face Len chin and here
we'll try to uh create one uh UI as well
by using flask or streamlit each and
everything I will show you in a live
class itself so flask and streamlet and
I will show you the complete I will show
you the complete uh setup how you can do
a complete setup for any an to and
project so first we'll try to create a
project template and then we'll start
with a project de development so this
idea is clear to all of you please do
let me know in the chat if the agenda is
clear for today and for the tomorrow
session I'm uh expecting the answer in
the chat so please write it down in the
chat guys please do it
fast
yes
we'll discuss the risk and all what risk
is there and we'll try to discuss about
the different different point uh first
let us uh uh create at least one project
after creating this particular project
definitely uh we'll try to uh discuss
about the multiple things that uh
basically which is a very very important
in terms of the
industry we'll come to that part don't
worry
fine so now each and everything is clear
each and every part is clear so let's
move to the Practical implementation so
if you will go through with my notebook
so which is already available in a
resource section okay I have shown you
how you can download this particular
notebook so just try to go through with
the dashboard and from the resource
section you can download this notebook
now uh here guys see uh The Notebook is
there so just try to download it and try
to run it inside your system uh how you
have to do a system setup how you have
to create an environment and all how you
have to install the library inside the
environment each and everything I have
shown you in my previous class only so
again I'm not going to repeat that
particular thing so over here you can
see already we have talked about the
open a now let's discuss more about this
open AI so just uh give me a moment here
uh from here itself basically inside uh
uh this particular file itself I will be
writing a code now I'm going to change
the name of the file so here I'm going
to write it down test open API and Len
chain because in today's session I'm
going to include the Len chain as well
and I will do in a same Jupiter notbook
I'm not going to create any new notebook
uh as of now I will be doing over here
itself so here I'm going to be write it
down I'm going to rename this particular
file uh so here I'm going to write down
this Lenin as well so test openi API and
L CH so this is the new name of my file
now let me rename it and now everything
is ready so here guys see if I'm going
to write it down this import here if I'm
going to write import statement import
length chain now here you will find out
it is saying that no module named L
chain can anyone tell me how I can
resolve this particular error please do
let me know in the chat how I can
resolve this particular
error
correct so here what I need to do tell
me here I need to write it down pip
install and the L chain pip install and
the module name so just try to open your
anaconda prompt and there write it down
pip install and Len chain so let let me
show you that just a wait uh so here uh
this is my prompt uh this is what this
is my ANA prompt here already this
jupyter notebook is running so I'm not
going to stop the server of uh this
particular prompt now let me open the
new prompt over here so here I'm going
to write it down this Anaconda prompt so
first of all guys what I need to do I
need to activate my virtual environment
as of now we are in a base environment
and this base environment is my default
environment so here what I need to do
tell me here I need to activate my
virtual environment so for activating
the virtual environment first of all we
should be aware about the name uh in
which environment actually we are
working so let me show you all the name
all the name of the environment so here
I'm going to write it down this cond en
list here I'm going to write down this
cond en list so once I will write it
down this particular command I will get
all the environment name so here you can
see we have a different different name
of the environment Len chain open AI
base testing and these are the other
environment which is there inside my
local folder now guys yesterday actually
we have created this particular
environment testing open AI now let me
activate this environment over here so
here I'm going to write it down cond
cond activate cond activate and the
environment name is what the environment
name is testing open AI so if I'm going
to write it down this testing open AI so
definitely I will be able to activate my
environment now if you want to check
over here that my Lang chain is working
or not so definitely you can do it so
first of all you need to clear this
screen and here if you are going to
write it on the python so it will give
you the python prompt so here let me
write it down the python so this is what
guys tell me this is my python cell or
my python prompt now here itself you can
write it down the uh statement import
statement so let's try to write it down
the import statement over here and here
if I'm going to write it down this Len
chain length chain now see guys it is
saying that no module name length chain
and even you can check so for checking
that what all module is there what all
module is there in my current virtual
environment so what is the command the
command name is PIP list we are using
pip manager over here right so over here
what I'm going to do I'm going to write
down the exit if I want to exit from
this particular shell from the python
shell now here what I will do guys here
I I'm going to write it down pip list so
once I will write it down this pip list
you will find out all the packages name
whatever packages is there inside my
current environment so these are the
package guys which is there inside my
current environment you can read the
name of the packages and here you will
find out this Len chain is not available
so just try to go through with this
particular package try to go through
like alphabetically and here you will
find out that we don't have any package
with the name of linkchain so here what
I will do first I will install the L
chain so for installing the Lang chain
there's a simple command pip install pip
install pip install Len chain so here
once I will write down this pip install
Len chain now guys see my Len chain is
getting install inside this current
virtual environment so are you doing
along with me are you writing this thing
or are you like following uh to me guys
please do write it uh please write it on
the chat so I will get some sort of idea
that uh uh this many people are doing
along with
me
I will come to the connects between this
Len chain and this open a just allow me
uh like 15 more minute each and
everything will be clarified regarding
this open and this Lent just believe
me so people are saying they are writing
a code along with me that's great please
do it guys please do it and uh yes
please implement along with me if you
are uh getting stuck somewhere so please
write it on the chat and let's uh make
this session more interactive and yes
definitely after the session you should
uh you should be able to get something
it's uh my guarantee to all of
you fine now here guys you can see we
have installed this lenon inside this
current virtual environment now if you
want to check it so here itself directly
here itself you can check so just write
it down this Python and here what you
need to do you need to write it down
this import Len chain just write it down
this import Len chin and here the name
is wrong so let me write down the
correct name now see guys we are able to
import this Len chain means L chain is
there in my current virtual environment
okay fine so I think till here
everything is fine everything is clear
now here again I'm going to import it so
definitely I will be able to import but
before starting with this length chain I
would like to explain you the function
calling so what is a function calling
why I'm saying this function calling is
very important uh definitely we should
learn it actually it's a new feature
inside this open AI so let's try to open
this open a website and here okay so
here already I opened it now guys once
you will open the documentation of the
open AI so there itself you will find
out this function calling so it's a new
feature uh recently they have added
maybe uh four to 5 months back and uh
what we can do by using this particular
function calling so by using this
function calling there is a there is a
many use of this function calling so the
first use basically uh the very basic
use which I would like to tell you we
can formate our
output okay we can we can formate our
output in a we we can formate the output
in our desire desire format so whatever
output we are getting now from the open
uh let's say we are using openi API and
we have a model open API what it is
doing tell me it is calling the llm
model agree now whatever output we are
getting now we can format that
particular output in a desired format in
our required format that is the first
use of this function colleag now we have
other use of this function colag some
Advanced use of this function colag
let's say uh we are uh calling any sort
of a API means let's say we are asking
something to my CH GPT and it is not
able to answer for that particular
question so for that what we are doing
we are calling any third party API any
any sort of a plugins and whatever
output we are getting whatever output we
are getting right so we can format that
particular output and we can append that
output in our conversation
chain that is really powerful and
somehow L chain is also doing the same
thing but yeah so recently they have
added this function colleag this one
feature actually inside this open a and
here uh like it's really uh like a
important one and it's like really uh
very very useful and in the lenon also
we can do the same thing right but apart
from this thing lenon is having so many
functionality in the lch actually we can
perform so many things I will come to
that I will I will show you the
differences between this open and this
lench why we are using this openi why uh
why we are why we are going to use this
Len chin why uh we are not going to use
this openi API itself because see in a
back end if we are going to talk about
this Len chain so in a back end this Len
chain this Len chain actually it's
calling open API it's a wrap up on top
of the open API come I I will come to
that first of all let me clarify this
function calling so guys to understand
this function calling I will I draw the
architecture and all I will I will try
to uh explain you each and everything
okay but before that let me write it
down some sort of a code over here so
here what I'm going to do here I'm going
to open my IP NV file and here I'm going
to write it down some sort of a code to
understand this function calling so step
by step I will try to explain you and
please do along with me I think uh that
would be great so for that guys what I
did so here uh just a wait I have
written one
text great so here guys see uh I have
written one text so let me copy and
paste this particular
text now here I'm going to run this
particular uh cell and once I will print
this student description so here you
will get the entire description so I I
just written a very basic description so
uh s saita is a Str of the computer size
it Delhi he's a Indian and he's having a
8.5 cgpa something something about me or
something about like U any person you
you can write it down this uh particular
description so here is a short
description now guys what I will do see
so here is what here is my short
description now here I have designed one
prompt and that prompt I would like to
pass to my chat GPT means I would like
to pass to my GPT model so here see uh
whenever we are talking about a prompt
so I told you that what is a prompt so
let's say this is my llm
model this is what this is my llm model
now we are passing input to this llm
model and we are getting response we are
getting a output so this respon this
input actually so this input is called
input prompt and this prompt is nothing
it's a collection of
tokens
so you can understand in such a way that
this prompt is nothing it's a
sentence and this token is nothing it's
a words what is this tell me it's a
words so this uh sentence is nothing
it's a token and sorry sentence is a
prompt is nothing it's a sentence and
token is nothing it's a words right so
here we will be having input prompt and
here we have a output
prompt getting my point so here see I
have written one description now I will
write it down my prompt I will I have
designed one prompt so let me uh copy
and paste that particular prompt and
let's see uh what will happen if we are
going to paste uh if we are passing this
particular prompt to my llm so here is
my prompt guys so just try to read this
thing over here and so this prompt is
saying so let me run it first of all so
this prompt is saying please extract the
following information from the given
text whatever text we are passing let's
say this is a description so uh we are
passing this particular description so
from that particular description I have
to extract a few useful information so
here the information is what name
College grade and Club so these are the
information just just try to read this
particular uh description and based on
this definitely uh you can extract this
particular information like name College
grade and
club now chat GPT or this GPT model will
do it uh will do it for me uh something
like this I have designed this
particular prompt so here I'm saying
please extract this particular
information and this these are name and
here this is the body of the text and
here I'm passing my text you can see so
here I'm writing I have a string so I
have defined one prompt and here I'm
passing my description now see once I
will run it so definitely I will be
getting my prompt so here is what guys
tell me here is what here is my prompt
this is what this is my prompt okay it
is fine not an issue now guys what I
will do I'm going to pass this
particular prompt to my chat GPT all
right now what I can do I can pass this
particular promt to my chat GPT and over
here uh first of all let me copy and
paste this particular code or let me
write it down that so here I'm going to
write it down from open a
import open AI so this is what this is a
class now here what I'm going to do I'm
going to create object of this
particular class so here I'm going to
create a object of this particular class
so here I will write it down open Ai and
here uh what I'm going to do so here is
what here is my object now I can keep
this object inside one variable now here
I'm going to say my variable name is
what my variable name is client now if I
want to make a connectivity so for
making a connectivity what I need to do
tell me so here I need to pass my API
key so how I can do that so here is a a
parameter uh we need to pass one
parameter over here so the parameter
name is what parameter name is API unor
key so here I'm going to write it down
AP apore key and here I will pass my key
so my key is what my key is my key so
once I will uh run it so here you will
be able to find out this is what this is
my client so let me contrl Zed and here
is what here is my client so this is
what guys tell me this is my client now
by using this particular client
definitely I can call my chat completion
API so let's try to call this chat
completion API and here I have already
written the code for that so let me copy
paste uh I have written some sort of a
code already I kept in my notepad so
from there sometimes I will copy it uh
because I want to save my time otherwise
uh if I'm going to write each and every
line so definitely it's going to take
more time now here uh you can see so we
are going to call this chat completion
API now chat completion this is the
particular method that's it now here is
what here is my prompt now once I will
run it so you will be able to find out I
will be getting one response so here is
my response let me show you this
particular response and here is what
guys here is my response definitely I
can extract this response uh for that uh
what I need to do so here I just need to
write it down this
response uh response and this response
actually uh inside this response there
you will find out this choices so I will
write it down this dot choices dot
choices now I will run it so here you
will get this choices now from here what
I need to do
from here this is the list actually so
here I will write it on this zero zero
index whatever information is there on
this zero index now from here I'm going
to extract uh this particular
information now here I will write it
down this message message now here is
what this is my message actually and
from this message I'm going to write it
down I'm going to except this content so
here I'm going to write it down this dot
content now guys see this is what this
is my entire information now if I want
to convert this particular
information now if I want to convert
this particular information in Json
format so for that what I will have to
do so here actually what I'm going to do
I'm going to collect this thing in one
variable that is what that is my output
now here what I will do guys here I'm
going to import Json so here I'm going
to write it down import Json and here
I'm going to write down json. load now
to this load function I will uh provide
my variable my variable name is what my
variable name this output now here you
will find out uh is saying this json.
load it is giving me Str Str object has
no attribute read okay it's not going to
read let me check what is the correct
function just a
second so the function name is loads
here guys you can see so the uh the
method basically which I was calling so
the method name was loads so Json do
loads and here we are are passing this
output now you can see this is what this
is my output are you getting my point
guys are you able to see what I did I I
given this uh I given this prompt I
given this basically I given this
description to my model and I asked that
okay just give me this particular
information just give me this particular
information from this description and
here what I did I passed this particular
prompt to my tell me to my chat
completion API actually this chat
completion API is calling this GPD 3.5
turbo model and here guys you can see we
are able to get a response whatever
description we have given according to
that whatever prompt we have designed
and it is giving me that particular
response we have given a description we
have designed a prompt and according to
that only we are getting a response here
you can see this is a response actually
I have converted it into a Json format
so this is the first thing which I want
to show you now here guys see this type
of prompt it is called few short prompt
it is called few short prompt where I'm
giving my description and I'm saying
that okay so uh you need to behave like
this means whatever description I'm
giving to my model and here uh regarding
that particular description I want to
extract some sort of a
information so here actually this type
of prompt is called fuse short prompt
now directly I was asking something to
my model in my previous one in my
previous uh session so here actually
directly I was asking uh the question to
my uh model to my llm model so this is
called actually zero short prompt this
is what zero short prompt now here this
type of prompt actually is called few
short
promp getting my point this idea is
getting clear to all of you please do
let me know in the chat if you are able
to follow me till here please write it
down in the chat I'm waiting for your
reply
I'm sharing the text uh don't worry I
can share everything in the chat so just
a
second um here is a
text so here is a text guys
I
think it's
a it's a half text let me give you the
full so college and here is the full
text because it is having a word limit I
cannot uh like give more than 80 words I
think I cannot uh like paste more more
than 80 words in the inside the
chat
yes is it is it because we are asking
for a number of variable in a second
prompt correct your understanding is
correct
Goldie so zero short means we are not
defining anything over here directly we
are asking a question to my model now
what is a few shot so here we are giving
some sort of a description and based on
that particular description we are
asking regarding some information we are
asking some information okay so this is
called few shot and here is a zero shot
don't worry uh we have a many example
here I just given you the glimpse of
that just wait for some time one or two
more classes you will get more about it
because uh now we just we are going to
design The Prompt and all and in the
next session specifically I will I will
be working on the prompt on a different
different prompt and even uh for the uh
inside the project also we are going to
design a different different prompts got
it now see uh definitely we are able to
call our l m we are able to call our
like open a API and definitely we are
able to get our output also from the llm
models now here guys what is the use of
the function calling so first of all let
me uh Define one very basic function and
then I will Define one Advanced function
also so here what I'm going to do see
here I did this particular thing by
using this uh chat jpt Itself by using
this completion API now let me show you
the same thing by defining the function
so here what I'm going to do so here I'm
going to Define one function so let me
do one thing let me Define one function
and here this is my function guys see
I'm going to define the function this is
my function now from where I got this
particular format so you must be
thinking sir okay so sir you define this
function now from where you got this
particular format so just try to go
through with the open API and here uh
sorry open a documentation and here just
click on this function calling and once
you will scroll down over here so here
you will get the code s snippet so and
inside this code s snippet you will find
out this function definition that how to
decide or how to define this particular
function getting my point I will come to
this particular example I have designed
one example for all of you but first of
all let's try to understand a function
calling from uh like very basic example
and then I will come to the advanced
part so here you can see we have a
function
and from here itself I took this
function definition and how to decide
how to define this function and all now
let me tell you what I written over
there so here I have opened this uh
notebook now see uh what is the name of
this function actually student custom
function it's not a function like python
we write it down that Def and all it's a
like function basically which we are
writing down for the open AI U actually
we have to uh like pass this thing to
the uh to inside the chat complete API
itself I will come to that first of all
let's try to understand this uh
structure so first of all I I need to
write it on the name so here I have
written the name name is equal to
extract student information then we have
to write it on the description so here
you can see this is the description of
the function that why we are going to
Define it now here you will find out
some sort of a pairs so key and value
pairs so first we have a parameter so
here you can see we have a parameter now
uh we have a type so which type of uh
like object object we are going to be
defined over here and then we have a
properties now here you will find out
inside this parameter you will find out
a different different values like name
school grade and Club whatever actually
I Define over there inside my prompt the
same thing the same thing over here
right so first we have a name the second
thing we have a description the third
one we have a parameter inside the
parameter we have a different different
values like names school grade and Club
getting my point now here just see the
type of this name it's a string just see
the type of this school it's a string a
college you can write down the college
here is a college so let me write down
the college instead of this school so
here is what here is college so instead
of this is school I can write down this
college now here is college the type of
college is string right now here is a
grade now grade type is integer now here
is a club so Club type is integer again
I think you getting my point that how to
define this function it's a predefined
format or the Inon platform itself
you'll get this particular form format
now just run it okay now just run it and
after that what you need to do so here
see you need to uh call the chat
completion API so here is your chat
completion API let me copy this chat
completion API from here and let me
paste it down now here you need to
Define some sort of a parameter now let
me write it down those particular
parameter and then I will run it so here
guys you can see we have this message so
let me keep this message in a single
line so here I'm going to keep this
particular message in a single line so
here is what guys here is what here is
my message it is fine now after the
message what you need to do you need to
write it down one more parameter and the
parameter will be what the parameter
will be a function so here I'm going to
write it on the parameter the parameter
name is what function so here is my
parameter function now tell me what is
the name of the function so here the
name of the function is nothing it's a
student custom function so let try to
copy it and try to paste it over here
that's it you just need to copy the
function name from here and you need to
paste it over
here okay as a value of this particular
parameter now guys I can keep this
particular response in response two so
so here I'm going to write it down this
response to so here is what here is my
response to now let me run it and let's
see what I will be getting so here is
saying okay it is giving me error so I
think uh chat
completion role is fine I'm using client
only let me check with the
client yeah client uh now everything is
fine what is the issue I you code
incorrect API
provided okay okay just a second let me
use the correct client this is
fine and here I can keep the Cent c l i
e n t now
see uh it is saying that
incorrect invalid key uh why it is
so um just to check let me check this
key over here student custom information
prompt is fine U but before it was
giving me output now why it is saying
like that let me check with a key over
here so my key and here is what here is
my key just a second guys let me take a
correct
key
uh
okay don't worry I will delete this
particular key uh I'm running in front
of you everyone but after the session I
will delete it fine so now I am having
my key and here what I can
do again I can run
it
great now let's
see yeah now everything is working fine
so this is what this is my response to
two and here guys you you will find out
that we are getting a output so we are
getting output in whatever format we
have defined this thing so we have
defined this thing like uh name College
grade and club now here you will find
out the same thing so name is there
college is there grade is there and Club
is there if you don't if you want to
change any sort of a description you can
change it and you again you can check it
and now actually we are
not we we are not uh doing directly this
thing we are using a function over here
and this is a very basic use of the
function as of now which I have shown
you getting my point so directly also
you can do that you can call it but here
they have given the function by using
this function also you can call
it okay so here actually this is the
basic use of the function and at this
point of time you you won't be able to
find out any differences in a direct
call and in a function call both is
looking same but now the difference will
start once I will explain you the second
example now over here you can see so
this is the response which I'm getting
now let's try to extract the response so
over here what I can do I can write it
down this a contain and let's see what I
will be getting over here so here is
what here is my uh content which I want
okay which I want to extract from here
so let me copy it and let me paste it
over here actually I want to extract the
content so that's why I'm going to be
write down response to Choice message
and content so once I will done it and
over here I will be getting this content
so here I am getting this content now
let me check over here okay actually see
here actually we have to get the content
from the function call so till message
it's fine so let me check with the
message till message I think it is fine
now if I want to extract the content now
so over here I will have to call this uh
I will have to write it down this
function call because before I was
extracting the message because directly
I did it directly I I called my llm
model now here I'm calling it but by us
using function so here I've defined the
format in a function I have defined the
format of the function and now by using
this function I'm calling my API so the
the API is hitting the model and
whatever output desired output I want
I'm getting it now over here what I will
do so here I'm going to write it down
this uh dot function call so let me copy
and paste it over here function
underscore call now over here guys you
can see we are getting this particular
value now let me write it the argument
over here arguments and this is what
this is my output now yes same thing we
can do over here as well so here I can
write it down this uh Json Json do loads
and here what I can do I can write down
the json. loads and now see I'm getting
a same output but see guys here at this
point of time definitely you are not
able to find out a difference between
the direct function call and between
this uh direct call and this function
call right now I will show you one
Advanced example and by seeing that
particular example definitely you will
be able to discriminate getting my point
so till here everything is fine are you
able to do it don't worry I will give
you the code and I will give you each
and everything whatever I'm writing over
here and uh this file and all it will be
available inside my resource section so
here is the resource section guys uh so
just try to enroll into the course and
uh yes definitely you will be able to
get this particular file inside this
resource section and this is completely
free you no need to pay anything you no
need to P you don't need to pay actually
a single rupees for this for this
particular dashboard so please try to
enroll and try to download the resource
from there so till here everything is
fine please give me a quick yes then I
will proceed with a further
topic
what is the difference between Json and
function call so here you will find out
so just check the type of this output so
here you will find out the type of this
output is nothing let me show you it's a
string now here I have converted into a
Json that's it okay I don't I I don't
want to keep it in a a string because uh
it's not looking good to me if you will
print it now if you will print it guys
see it's not looking good to me that's
why I converted into ajason now if you
will check the type of this particular
output so here you will find out a Json
let me write it down the type over here
and let me print it now so here is what
guys tell me here is nothing it's a Jon
not dictionary got it so this is fine to
everyone I think till here everything is
clear
great now let's start with the second
concept so over here uh the first
concept actually I shown you the basic
use of the function and all now let's
try to understand the advanced use of
this function calling so over here guys
see uh we have few more thing regarding
these functions and all so first of all
let me tell you that now let's say if
you want if we are passing a description
of two student all together so it can
handle that thing also it can handle
that thing also now over here let me
show you that particular uh that
particular thing also just a wait uh I
have I have a code for that and I'm
going to copy and paste see guys so what
you need to do so over here I just
written one for Loop and let me show you
that particular for Loop and here see
inside this for Loop what I have written
so first of all I Define one uh list and
inside this list we have a two
description so the first one you know uh
already I written this particular
description now let me uh let me run it
okay so what was the name of that so
just a wait let me check
um okay where I have written this
student I think this one so that name
the name of the variable is student
description so let me copy and paste
over here let me copy and paste this
student description so this is what this
is the student description this is the
first one so let me
write it down student description over
here now let me keep it over here now
student description now I'm going to
Define one more so here I'm going to
create one more variable and here
student description
two and here guys what I will do again
I'm going to copy and paste a same thing
so this is the value which I'm going to
copy and paste and I'm going to do some
sort of a changes over here so instead
of this s Savita I'm going to write down
something else so let's say I'm going to
write it down Krish n so and here
Krishna is a student of a compter
computer science I uh maybe instead of
this delh let me change the name so here
is what here is Mumbai now here he is a
cgpn so he's having more than 9.5 cgpa
so let me write down this like cgpa as
well and here let me change the name so
instead of Sunny what I'm saying I'm
saying Krish is known for his
programming skill and he's a member of
here I can write down DS Club data
science club data science club so here I
am giving an information regarding
two student now here see he hopes to
pursue in a career in artificial
intelligence after graduating something
else right so now what I will do let me
run it and let me keep this particular
description over here so here what I'm
going to do I'm going to keep this
particular description now what I will
do so over here uh I I'm just going to
run the for Loop and here you can see
one by one the description is coming and
it is going through this particular uh
completion API this Chad completion API
and I will be getting a response so
let's try to make some changes over here
because it's a like old code let me give
the latest one over here so this is the
latest let me copy and paste the latest
function so here is what here is a
client chat completion. create now over
here the model name is what model name
is same now here message uh it's the
same this one now let me write down the
student so it will be more uh like clear
to all of you so here here uh you can
see we are calling a function now here
guys see we are calling which function
this particular function let me copy the
same name so here the function name is
what student custom function so here I'm
going to copy the name of the function
and let me paste it over here so this is
what guys tell me this is my function
name and here is function call is auto
right automatically the function is
going to be called now what I want tell
me I want a response so over here I'm
going to print this particular response
and let's see we'll be able to get a
correct response or not so if I'm going
to run it guys so you will be able to
find out a response regarding two
description so it is saying that check
completion is not a subscribable okay so
over here I think I will have to paste
this thing now let me copy it and let me
paste it over here
so this is the one I think it is fine
now and this is going to be a response
so response whatever response we are
getting there is a choice and inside
that we have a message and finally
function call and from there we are
going to collect a argument so once I
will this argument actually this
arguments you can map this argument with
this thing this uh thing basically which
I have written over here inside the
function name College grade and
Club getting my point so here what I'm
going to do now here I'm going to run it
and let's see what I will be getting
so once I will run it definitely I will
get a response great so here it is
giving it has given me a response
regarding the first uh description and
now guys you can see it has given me a
response regarding the second
description so the first one is s sabida
and the second is kishna you can give as
many as uh like description in all so
over here let me take the third one and
let me keep it over here and here I can
say so here student description three
three now over here instead of this
krishak let's say I'm going to write
down one more name let's say sudhansu
Kumar and here I can say that he's a
student of
IIT Hyderabad or I let's say uh
Bangalore now over here he's a Indian
he's having a cgp around let's say 9.2
and he's programming skill and he's a
active member of mlops club now let me
write it down over here mlops Club so
now yes I have given this particular
description over here and if I'm going
to copy it and let me paste sit over
here so regarding this description also
definitely we'll be able to call our
model we'll be call our API and finally
we'll be getting a output it's doing the
same thing which our chat completion API
is doing directly without function right
now we are doing along with a function
along with a multiple description
getting my point so here this is the
basic use actually basic use of the
function after this one I will come to
the advanc use just wait now over here
see if I'm going to run it so let's see
what I will be getting uh so here I will
be getting a First Response yes this is
my first response now this is the second
response and here you can see there is
the third response getting my point guys
yes or no we can call our llm model we
can we can call our API we can hit the
model and we can summarize the result
according to the prompt if this thing is
clear to all of you then please write it
down yes in the chat please do let me
know in the chat guys if this part is
clear to all of
you yes it's a case sensitive whatever
variable you are going to Define in the
function col it's a k so please make
sure that you are going to write it down
the correct
name after this one the use of the
function call will be clear just wait
okay fine now this thing is clear to all
of you now let me come to the next point
so here actually what we are going to do
see uh we are going to call a single
function right regarding this particular
description uh this is my function but
we can call a multiple function also we
can call a multiple function also so
here guys let's say if we are going to
define a one more function here let's
say if we going to define a one more
function so you can Define any sort of a
function over here let's say function
two let me write it down over here
function 2 function _ 2 you can define a
second function and after defining see
you will Define in a same format
whatever format is there this one in
this format itself so in this format
whatever format I have written now the
variable and the parameter and the
description U and those thing will be
changed but the format will be a same
because the same format which you will
be find out over the tell me over the
open a API s they already have given you
that so this is what this is my function
two now you can like Define a function
two whatever information you want so
let's say I just want this grade and
club or whatever so right so if I'm
going to remove it you can remove it or
maybe you can Define one more function
for some other information right and now
if you want to call it so how you will
do that tell me so for that actually uh
here I have created this uh list right
here we have created a list of the
student information regarding a
different different description
now here again I can create one more
list the list basically the list
regarding this function so here what I
can do I can copy this code and I can
paste it over here this particular code
and here what I can do I can create one
more list and inside this list what I
can do I can write it down the function
so here is what let me a copy and paste
so this see this is what this is my
function parameter now here we have a
first function and we have a second
function so this is this is my first
function which I defined already this
one so let me copy this particular name
and let me paste it over here this one
so this is what tell me guys this is my
first function which I'm going to write
down over here and this is my second
function already I given the same name
so like this you can call a multiple
function
also getting my point so here I have
defined this function and according to
that I'm getting my desired output
desired parameter you can create one
more function on top of a same
description and here you just need to do
one thing instead of this specific
function you just need to write it down
this function you just need to provide
this list and you are done according to
the definition you will get output so
this is your assignment you have to do
by yourself I have given you the way I
have given you the path now just Define
a second function regarding whatever
information is there inside the
description whatever you want to extract
just Define a function and call it over
here so here I can mention this thing as
assignment don't worry each and
everything I will provide you uh this
notebook will be available in the
resource section you can download from
there this is what this is your
assignment guys now here this part is
clear that uh we are calling up llm so
here directly we are calling llm then
what we are going to do see we have
designed a prompt directly we are
calling llm then what we are going to do
we have Define a function then uh like
we are getting that particular output
that is also fine now we are going to
call our llm by using openi with respect
to different different description that
is also fine means regarding a like
different different description on the
same time now we can Define two function
as well more on more than two function
that is also fine now what is the actual
use of it still we are not able to find
out the actual use of this function
everything is looking same now let me uh
explain you that particular part I'm
coming to the advanced example now so
over here what I'm going to do I have
written one Advanced example and uh let
me copy and paste uh the code basically
which I have written step by step I will
copy and paste don't
worry okay so here guys see again I'm
going to start from
scratch now Advanced example of function
call
Advanced example of function calling
okay now over here guys see uh what I'm
going to do I'm going to call my chat
GPT so here I'm going to copy and paste
one code now this code actually we have
defined something over here so here I'm
saying uh what I'm asking I'm asking to
my llm that what is the next flight from
so here I let me change the name let me
write it down Delhi to Mumbai so here
I'm going to write it down what would be
the next flight from Delhi to Mumbai
this is my prank now just tell me guys
will my Chad GPT able to answer for this
particular
question my CH chat G is able to answer
for this particular question the
question which I'm asking over here I
want your uh like p uh like I want your
opinion on that please write down the
chat I'm asking to all of you can my
chat GP answer for this particular
question no why why it cannot be answer
because like this chat GPT has stayed on
the limited amount of data right so not
a limited amount of data it has stay on
uh the data basically which is available
till September
2021 getting my point if you look into
the chat GPT if you look into the open a
just just go with the open AI uh not
this one so where it is this one so here
guys just just uh go over here and uh
what you can do you can go into the
models now over here just click on this
GPD 3.5 and uh just look over here
training data so it has trained up to
September 2021 data up to this
particular data that's why it won't be
able to answer for this particular
question whatever I'm going to write it
down here now let me run it and let's
see the response that what response I
will be getting so over here uh yes it
is giving me a response let's wait for
some time I got a response now and here
I'm going to run it so see what it is
saying that it is saying that as an AI
language model I don't have a realtime
information however you can easily find
out next flight from Delhi to Mumbai by
checking the website or mobile apps of
Airlines so that operate the route such
as air india indigo spice jet vistara go
Additionally you can contact travel
agency or use online flight scratch
engine for up to date now just tell me
if you are going to create if you're
going to create any chatbot by using
this open API so will you give this type
of answer to your user if your user is
going to ask you that what is the next
flight from Delhi to Mumbai definitely
you will have to do some sort of a jugar
right you will have to extract the
information from
somewhere you you cannot give this type
of answer right so you will have to make
your chatboard that much of that much
capable you you have to make your
application that much capable so it can
answer for this type of question as
well okay now let me tell you uh the use
of the function calling over here that
how function calling can help to us so
over here what I'm going to do here I'm
going to Define one
function what I'm going to do guys here
I'm going to Define one function so this
is what this is my function just like
observe step by step don't run anything
don't write it down any sort of a code
just observe whatever I'm explaining to
you that's it so here is what here is my
function function description now we
have a name of the function get flight
info we have a description get flight
information between two location now
here we have a parameter and inside
parameter we have two things so the
first one you will find out that is what
that is a location origin and location
destination so in my case what is the
origin
delhi now here in my case like whatever
prompt or whatever question I'm asking
in that case the destination is what
destination is tell me
Mumbai so there is two parameter I have
here is a type here is a description
here is a type here is a description
that's it so let me let me change
something inside the description also so
here I'm I can write it down Delhi d e l
and here let me write it down the Mumbai
mu M mu M so this thing is fine now here
if you will observe so I have mentioned
one more thing I have mentioned one more
parameter over here the parameter name
is what the parameter name is required
now what is required location required
origin location required and destination
is required two things is required over
here okay that is fine till here
everything is fine we are able to
understand but still we didn't get a
complete idea how you will get it first
of all let me run the entire code right
so here you can see we have a
description so let me run it and this is
fine this is like perfectly fine now
here I have a prompt so let me copy The
Prompt over here I'm not writing from
scratch because it might takes time so I
already return in my notepad and all
somewhere so I'm just going to copy and
paste that's it so here guys um I'm
asking to my chat GPD or sorry I'm
asking to my GPD model when is the next
flight from New Delhi to Mumbai this is
my question now over here if I'm going
to run it so here guys you will see that
okay so this is my this is my user Prem
now what I'm going to do now I'm going
to copy it now I'm again I'm going to
copy the same thing this one and I'm
hitting this particular prompt so here
is what here is my model here is my role
role is what role is a user and here is
my prompt getting my point now here now
I'm passing my function just focus over
here just focus now over here I'm
passing passing my function function
underscore description this is what this
is my function description now see over
here uh this is my prompt and if I'm
going to run it now if I'm going to run
it now now you will see the response
that what response I will be getting
before actually I was getting this
particular
response before I was getting this
response now just look into the response
that what will be the response over here
so here what I'm going to do I'm going
to copy the same thing uh this
particular thing and here I'm going to
write it down response to response to
choice choice message and contain so
once I will run it so here you can see
it's not giving me anything okay so why
it is not giving me let me show you
because there is no such content there
is no such content that's why it is not
giving me anything now let me print till
message only and you will find out the
uh the like values over here so over
here guys see if I'm going to print till
message so it is giving me a message
whatever message I'm getting step by
step we'll try to understand it don't
worry now here let me copy this thing
and let me check with this particular
argument so here I'm going to copy this
argument and let's see what argument we
have uh so over here it is saying okay
first of all I need to call this
function call and then only I can call
this argument uh not an issue fine now
over here we have a argument see we have
two argument first is loc uh location
origin that's a Delhi and location
destination that's a
vom getting my point guys see it is
going to extract from here location
origin and location destination and here
is Delhi here is Mumbai this is a
location origin location destination now
it is not giving me answer but it is
going to it is it is it is able to
extract something right from this
function call and here you can see these
are this is two argument right there you
will find out two argument this is the
argument basically which we are able to
get it from here because we have already
defined it over here this thing okay
that is fine this is clear to all of you
now guys see how you will uh give this
uh like flight actually so for that you
will have to call any third party API
then only you will be able to provide
the information now right so let's say
if I'm talking about the make my trip so
what it does it is having access of a
different different API if I'm going to
book any train ticket so is calling the
IR CZ API and is giving me the entire
detail make my trip is not a owner of
the Railway where it is having the
entire data entire information of the
Railway Indian Railway no
IRCTC actually it's a organization
actually that is a portal which is like
governed by the uh Indian government and
like it it is having some sort of apis
and all which is being called by the
make my trip or any other website and
because of that only you are able to get
an information whatever rails and all
whatever flights and all you are going
to find out over there or maybe some
other website right so here what you
will do for getting this information you
will call the API any third party API
now here see I'm not going to call any
sort of API I'm giving you as assignment
this thing so you can call any sort of
API you can explore a different
different API and you can accept the
information from there I'm uh I can uh
give you the very basic name rapid API
just go through go and check with the
rapid API there you will get the each
and every API related to the weather
related to the different different thing
as of now what I did actually I created
my own function which is working as a
API I created my own function which is
working as a API now let me give you
that uh let me show you that particular
function so here what I did I have
created my own function which is working
as a API you can think this working as a
API but you can call your real time API
for extracting a real data don't worry I
will show you that thing I will uh show
you how you can call the Sur API in my
next class when I will discuss about the
agents in a lang chain there I will
discuss about the Sur API and all so
over here you can see guys we have a uh
I have created one function get flight
info location origin location
destination now here I'm going to be uh
like here I written some sort of a code
that is what that is nothing as a flight
information and it is in a dictionary
format so here we have a location origin
destination date time Airlines and
flight this is the airlines time and
this is the flight number and all now
here this function is working as a API
you can think like that now if I'm going
to run it so over here uh it is working
fine now guys see what I'm going to do
here so this function is working fine
now here uh I'm going to collect this
origin and this destination so first of
all let me show you this particular
thing uh argument I already shown you
this one this is my
argument and over here uh what I'm going
to do I'm going to be convert this
argument into a Json so
json. loads now over here what I'm going
to do so let me run it and here I am I
having two argument uh first is Delhi
and the second is Bombay this is my
origin and this is my destination so
this thing this information I'm going to
collect in my like a variable that is
perams now over here we have a variable
that is perams now from here I'm going
to extract few more information I want
to extract the origin and the
destination so for that I already
written the code let me copy and paste
so this is my origin so I'm calling this
get uh method on top of this uh
dictionary actually this is my
dictionary and I'm extracting a value of
this particular key as like this I'm
extracting a value of this particular
key you you can see over here let me
show you so this is what this is my
dictionary now on top of this dictionary
if I will call this get method now uh by
using this uh key so get and over here
what I will do I'm going to write it on
the key so the key name is what location
uncore origin now over here see if I'm
going to run it now you will find out
this Delhi so this is my origin and here
you will find out the destination
similarly I can get the destination also
now it's not a big deal see now over
here I can call this a destination why
I'm doing it entire thing will be clear
and I will give you the quick revision
also just wait for some time just wait
for more 5 minute everything will be
fine so Delhi is there Delhi and Bombay
is there so here we have origin and
destination now we got both origin and
destination right so parameter is uh we
are able to get a parameter we are able
to get origin and destination now let's
try to find out the flight detail right
so let's try to fly find out the F
flight detail so for that basically what
I'm going to do here I'm going to call
one uh so here I'm going to call one
method that is a a right so what this a
will do so here actually I'm going to
pass the name so let me show you this
particular value what is happening over
here so just a wait let me copy and
paste over here so this is what this is
the name this name is what this is the
function name get flight information
right now I'm giving this uh function
name uh this uh function name this GL
get flight info which is a string as of
now let me show you the type of this
function over here so over here what I'm
going to do here I'm going to write it
down type of this function so this type
of the function is nothing it's a string
only so let me uh keep it inside the
bracket so this is what this is a string
now if I'm passing this thing to my eval
function eval method so you will get the
actual function this eval is doing
nothing this EV is giving you the actual
value that's it this is what this is the
function now we have defined get flight
information it will give you the actual
value that's it so here you can see it
is giving me the function only this is
what this is my function this get flight
info is what it's a function now it's
not a string we have already defined it
over here see this one so this is doing
nothing it is just giving me actual
value okay now let me show you one
example very basic example let's say if
I'm going to write down and here if I'm
going to write down two now tell me what
is this two if I'm going to write down
like this uh type and here I'm going to
write it down two just tell me what is
this it's a string but two is a string
no it's an
integer right it's a integer so if I'm
I'm going to write it down like this now
if I'm passing to my so it will provide
an integer see this is what this is an
integer if you check with the type so
type the type will be an integer only so
it is converting whatever value we are
passing into the well method now it is
converting into a original format into a
original form so here we are getting a
function so this is what this is my
function which I collected over here now
I just need to call this particular
function so here I'm going to call this
function now after calling this
particular function I will be get see
here I'm going to pass the parameter
keyword argument keyword par like this
this particular parameter params this
one okay location origin and location
destination this two thing we want over
here this one right now once I will run
it so here I will be getting my details
so let me run it first of all uh where
is a perms here is a perms and here is
what here is my flight details so name
date time is not defined let me Define
the date time over
here so from date time on of date time
import date time and it is done I think
now let me run
it time Delta is not defined let me
check what all import statement is there
just a
wait time Delta also we can import from
here itself so this is going to be a
time Delta great now let me run it and
over here you will find out a detail see
so actually what we are going to do uh
this function actually uh you can think
it's a it is working as a API got it now
here what we are going to do so we are
extracting a information from the uh
like whatever prompt and all we are
passing now so from there basically we
are extracting an information and we are
collecting a detail of the flight okay
from U like this is the response
actually see first what I did I defined
a function this is what this is my
function
this is what this is my function right
after that we are calling the uh after
that we are hitting to the uh like model
by by using this open API now after
hitting it so actually whenever we are
checking with a response so in argument
actually in a function argument we have
this two thing now by using this two
thing now what we are going to do so we
are uh like extrating the information
from here so as of now this is this
function actually you can think it's my
API but you can call actual API by using
this particular information that is what
I'm doing over here just just think over
here that is what I'm doing so now what
I did what I got tell me guys so I I
collected the information whatever see I
Define the thing inside my function
inside this particular function okay
this one this is the value this is the
like parameter which I defined now I uh
I like called my model I called my open
API and it is hitting the model right so
whatever response I'm getting now from
that particular responses I'm getting
this particular argument because my chat
GPT is not able to answer for this
particular question and by using this
argument I'm hitting my API I'm hitting
my API and after hitting the API guys
you can see this is the detail this is
the information I'm
getting okay by using those particular
argument now let me show you the
complete one so once we are getting this
particular information the flight
information regarding those particular
argument okay you can create an end
application here I'm showing you in a
notebook itself so here see guys what
I'm getting now give you the final code
so we are getting this particular
information and is done now let me uh go
for the final call so here you can see
uh I can keep it as a uh response three
client chat completion create now here
is what here is my model and here is
what here is my user prompt whatever
prompt I I'm passing now see guys over
here see role is what role is a function
now I have changed the role okay uh here
is a role role is a user now role is a
function function now this is the value
I'm extracting from the function
whatever function I'm defined and here
is what here is a like content basically
which I'm passing this is what this is a
flight right so this is the argument
which we are extracting from the
function whatever function I have
defined right and then this is what this
is my function description that's it
right so here see guys uh my role role
as a user as a role as a user basically
what I'm asking to my uh chat GPT or
sorry to my GPT model let me show you
that so over here what I'm going to do
I'm going to print it this user prompt
this is my question this is my prompt
this is what basically which I'm going
to ask right now over here roll again I
Define one more role that is what that
is a function right now over here I'm
going to pass the name and here I'm
going to extract the like function the
the ex exact function over here you can
check over here you can like copy it and
you can paste it over here this one so
just just paste and you will get this
function called now just collect the
name name of the function do name so
what is the name of the function get
flight info right now here is what
content is nothing content is a flight
now as soon as I will run it so here you
will be able to find out that we are
able to extract the information now let
me show you this response three so here
is what here is my response three and
guys see what I'm getting over here so
let me print the final one and here you
will be able to find out a detail so let
me run it see guys so now let me call
the uh this uh function call just a
second function uncore
call function _ call and over here guys
you can see we have argument and
actually we have a message over there
just a wait let me show you that
also uh function call and
argument okay just a
wait oh message inside the message
message itself I will be able to get it
uh where my message is coming inside a
choice and
here okay I need to call a Content
actually just a
second message function call this is my
function call that is fine now here
Choice uh just a second choice what we
have inside a
choice okay it is a response three fine
fine fine I was checking with a response
two uh yeah this was a response now it
is fine it was a response three I was
checking with a response two it's my bad
it's my bad uh okay now let me collect
the message from here so here is what
here is a zero and
uh now let me call this
message so here is my message and let me
collect the content
tent and here is what here is my content
guys so did you get it what is the use
of this function calling now let me give
you the definition of this function
calling in a single line so just a wait
I'm giving you the definition definitely
you will be able to relate now so if we
are talking about this function calling
now so here is a definition of it let me
copy and paste so what is our definition
of the function calling so function
calling is nothing learn how to connect
large language model to the external
tool that's it we can define a function
we can Define the parameters we can
Define the values and according to that
we can get our responses from the third
party API and here I have defined this
particular function M function is a
third party API but you can call the
realtime API and you can get the
information you can get the exact
information this thing is clear to all
of
you yes or
no how many of you you are able to get
it how many of you you are able to
understand this thing if you can let me
know in the chat so I think that would
be great again I will try to revise it
uh I will give you the quick revision of
it and then I will move to the link
chain will you revise it please do let
me know in the chat will you revise this
concept
I'm waiting for a reply if you can
answer me in the chat I think that would
be
great
yes I'm going to revise it just wait
just give me a second first of all uh do
let me know how much person you got so
if you can tell me uh in a percentage
also so that would be great I will get
some sort of idea that okay you are
getting something from here whatever
code I'm writing you're getting from
here so please uh do let me
know 80%
great 70 70
80 yeah if you're getting 70 or 80% now
so I think rest of the thing like you
just need to revise Sor is saying sir
I'm just getting 10% so Sor in that case
you need to follow from a very first
session just check with the very first
session and then come to the second one
and then come come to this third
one if you are near to 70 to 80% now
then you just need to revise it once
that's
it yes correct uh your understanding is
correct here we are extracting value
from given prompt using function
call
what is the meaning of the role is equal
to function which
one here we are defining now see we have
a user so user is asking a question and
rest of the information we are going to
collect from here we are defining one
more role we have we can Define many
roles over here um we can Define uh like
uh we can Define the system we can
Define role as assistant we can Define
role as a user user we can Define role
as a
function user is asking something and uh
and uh from wherever basically we are
going to be get output or we are getting
a uh we are we trying to exct the
information regarding this particular
prompt so we are defining as a rle over
here that's
it great so let's revise it now and then
I will go for the Len chain so we'll try
to understand the langen chain and all
already I have installed this L chain
and try to hit the open API and tomorrow
we'll understand the lch in a very
detailed way uh today uh just a quick uh
understanding quick uh uh first of all I
will give you the quick recap of all
those all this thing and then I will
come to the lon part so let's understand
this function calling one more time from
scratch
great so over here see we are talking
about this uh we are talking about this
chat completion API and I think you know
about it how many time we have discussed
so we're passing the prompt here is my
prompt and we are getting the output now
Today I Started from the like a
different type of prompt so uh today I
have started from the function calling
so here I have defined one description
and here I'm writing uh the prompts my
prompt is saying that uh here you need
to extract this information from the
given description that's it now here you
can see uh this is my client this is
what this is my client now here I'm
going to call my chat GPT and sorry I'm
going to call my GPT model so after that
what I'm getting I'm getting my response
I'm going to convert into a Json and
this is fine right this is fine anything
you can ask to your model and you can
print as a response you just need to
define a prompt that that's it now here
the same thing I'm going to do by using
this function so here I'm going to do uh
the same thing by using this function
now here I'm going to define a several
parameter so this is my parameter name
College grade and Club it should be a
same similar to this prompt itself
whatever prompt I have defined I have
written right so just look into the
prompt I will share this notebook then
you can check it should be similar to
that only this particular properties
this particular values now over here uh
you will find out that okay I again I'm
going to call it again I'm working I'm
like role I've defined as a user there's
a Content prompt and you are getting a
response and here you are getting a
response now guys here you can see we
are going to print a message and finally
we are getting a same thing by calling
this uh by using this function call as
well now here actually once you will
look into the prompt we have defined one
thing over here we we are saying that uh
return it as a Json object return it as
a Json object so whatever response you
are getting now from from the openi side
also I tested the same thing of the CH
GPT see I given the description this was
my description and CH GPD has given me
output is a Json format so if you are
calling it now uh this uh like a GPD
model so it will give you the output in
a Json format this one so here it is
giving you the output this particular
output in a Json format this one
actually it's a string but yeah we can
convert into a Json and that is what I
did now the same thing why we are doing
by using this function now over here H
it's fine it's clear now here I've given
you a few more uh like functionality
regarding this function I can call it
for the several description in a single
sort I just need to keep the for I just
need to write down the for Loop over
here so I'm getting a multiple responses
for sun for Chris for sansu right so
here I'm getting a multiple responses
now here I given you an assignment so
here I told you that you can call a
multiple function also don't call a
single function here I'm getting an
information from the single
function but you can call a multiple
function and here I shown you the way
you just need to define a function in a
list and that's it so here is a function
you just need to define a function in
the list and just pass it over here and
according to that only you will get a
response getting my point now here I've
shown you the advanced example of
function calling and that's a real use
of the function and here if you want to
Define this function in a single word in
a single line if you want to understand
this function in a single line so here
you can see this is the definition learn
how to connect large language model to
the external tool
so here what I want to do so here let's
say uh this is my model and here I'm
going to write down some sort of a
prompt where uh like it is going to be a
request and here I'm getting a response
now this prompt actually it's something
uh related to a real time I'm asking a
real time question that just give me the
flight just tell me like what all
matches uh we have in upcoming days or
uh just tell me the weather okay
something like that so I'm asking a real
time information it won't be able to
provide it to me in that case what you
will do so you are not going to call
your llm now because it is not trained
on that uh on it it has not been trained
on top of that data actually if you are
talking about this GPT so this GPT
actually train on this uh till actually
till September 2021 so this GPD train
till uh 2021 only now in that case
whatever prompt you are going to be
write it down you won't be able to get a
response right so here this function
calling comes into a picture so once you
will Define the function now so here
what you will do you are going to define
a function you are going to different
Define a different different arguments
and all each and every information you
are passing to this function that's it
now you just need see here this argument
what you will do by using this
particular argument you will call a
third party API third party API
third party API now you will call this
third party API here or whatever
function you are going to Define and
whatever prompt you are writing
according to that you will get a
response because this llm is not able to
provide you the response right and the
same thing the each and everything you
can do by using the chat completion API
only chat completion method you can say
chat completion API or chat completion
method both are fine by using this chat
completion method now let me show you in
terms of coding so over here if you look
into the code so I'm doing the same
thing here I have defined a function see
this is what
uh first of all I'm asking to my first
of all I'm asking to my uh llm model it
is not able to answer now after that
what I did I defined the function got it
after that I defined a prompt I'm
passing to my model I'm passing to my
actually uh this uh like chat completion
method so here is my user here is my
prompt and here is my function
description by doing that what I'm able
to do I able to extract few of the uh
few value whatever is there inside this
function whatever I have defined over
here because here I'm writing in this
function description now after that this
value I'm using and this is what this is
my API okay this this is my like it's
not a real API it's like a virtual API
whatever you can say now whatever value
I'm passing whatever uh thing I'm
collecting from here I'm passing to this
API and I'm getting a response over here
this is the response this is my
response got it now what I will do here
now I compiled each and everything over
here inside this chat chat completion
method so how I compile this is my model
this is my prompt this is my user this
is my prompt this is my function call
this is my function call along with the
argument and over here this is my
function that's it if I'm going to run
it now it is going to extract the
information from the third party API
which is my function as of now now you
can take as assignment you can call the
real time API you can use the rapid API
you can do that you can call a real time
API so now this function calling is
clear to all of you yes or
no correct ran your understanding is
correct
now your understanding is correct and I
think you are able to get
it now let's start with the length chain
so we have a a 10 minute uh now we can
understand the concept of the length
chain and then from Tomorrow onwards I'm
going to start with the Len chain now
first of all let me write it down the uh
code for the Len chain so here I'm going
to write it down Len CH and here uh you
can I can mark down it and uh so first
of all guys what I need to do so I'm
going to start from the Len chain uh so
the first thing very first thing uh I
need to import it so let me give you the
entire code okay so step by step let me
write down each and everything so first
of all I have to import the Len chain so
here I'm going to write it down import
length
chain now here I have imported the Len
chain now from this like in this lure
actually we have a different different
modules we have a different different
module and inside that we have a
different different classes so as of now
we are going to use the open AI so here
I'm going to write it down from Len chin
from Len
we are going to import this open AI so
lenin. llms and here I'm going to write
down this open AI okay so we are able to
import this open AI now what I will do
so initially I told you that this lenon
is nothing it's a wrapper on top of this
open AI so you can think that this is my
open AI right this is what this is my
open AI now on top of this open a on top
of this open API this lench is nothing
it's a
wrapper okay so this is what length
chain now here whatever request we are
making whatever request we are making
right so now we are not directly using
this open a now we are not directly
using this open API instead of that we
are using this L chain so our request is
going through to this a len chain and
then it is hitting this open AI but this
Len chain it is not restricted to till
here itself we have a many uses of the
Len
chain getting my point this Len chain is
not restricted to this one only we have
a many uses of the link chain I will
talk about those uses and this Len chain
actually it's a very powerful uh it's a
very powerful application it's a open
source I will show you the source code
as well uh even we can search about it
so let me show you that uh let me show
you the source code of the Lenin so here
I'm going to write it down Len Chen Len
Chen GitHub so here is what guys here is
a len Chen GitHub uh just a second yeah
so this is a lenion GitHub now you will
see the number of folks the number of
star number of folks number of start
number of watching right so number of
watching in a real time and this length
chain is really amazing let me give you
this link inside your chat please try to
uh explore it by yourself and it's a
very uh Power powerful and very
important as well if you want to build
any llm based application so you can use
this length chain it's a it's completely
op source and here you can see used by
40,000 people and here is a number of
contributor you can also become a
contributor if you like to contribute in
a open source now here you can see the
commits 7 hour ago they committed
something just just go through with this
commits and check what thing they have
committed what what changes they have
made over here try to understand it and
this package actually it is available on
the pii repository so just go over the
pii repository pii Len chain and search
about the Len chain and here you will
find out this Len chain this is what
this is a len chain guys this is a like
they have hosted the package on pii
repository and it is a latest version of
The Lang chain now here also just just
uh scroll down here also you will find
out the same thing
uh deployment so they are doing a deploy
here is a package package see this is
the release so 0.0.3 46 0.0.3 46 this is
the latest uh version which you can see
over here as well this one is uh so far
they did 297 release total 297 release
see this is the total release actually
total number of release now you can see
over here as well just go inside the
real uh just go just click on this
release history and check the uh entire
uh like release related to the length CH
got it right so here is a latest version
of the Len chain similarly we have a
llama index two also and this Len chain
is a open source and the Llama index 2
it's a framework from The Meta we can do
a same thing by using this llama index 2
also I will come to that I will come to
the Llama Index right now over here see
we have this Len chain we have this
openi now let's try to create now let's
try to create object of this open Ai and
here what I need to do guys tell me here
I'm going to here I'm going to pass pass
my open a key so first of all uh I will
have to pass the parameter now let me um
give the parameter over here and here I
need to write it down this my key and
here is what here is my client right now
I just need to call one method and my
method is going to be a predict right so
my the method name is going to be a
predict so let me write it down over
here Cent c l i n t dot predict now here
what I need to do here I just need to
pass the prompt prompt is what prompt is
a input whatever input we are passing to
the model that's it so let me Define The
Prompt so here I'm going to write it
down the prompt and this prompt let's
say I'm going to ask to my model what I
can ask so I can ask can you tell
me
total number of country total number of
country in Asia so here is my question
so I just asked a little tricky question
not a tricky actually it's a
straightforward so uh here is my
question my question is what my question
is can you tell me total number of
country inia now this is called guys
zero short prompting what is this tell
me this is called zero short
prompting this is what guys tell me this
is a zero short prompting now here if I
will run it and here if I will pass my
prompt to My Method client don't predict
so here you will get output so here it
is saying that there are 48 country in
Asia if you would like to uh if you want
to name then here you can mention
can you give me can you give
me top
10
country name so here uh I have extended
the question now and now see over here I
will be getting a name of the country so
it is giving me the sash slash sash is
nothing it means it means that if I'm
going to print it now so it will print
after two line so for that what you can
do you can just call this a strip
SD and it will strip your output so here
you will find out the correct output so
there are 48 continer isia the top 10
country by population in Asia these are
the country now here if I'm going to
write it on print so you will get a
output in a correct format so here guys
you can see you will get output in a
correct format so there are total 48
country in Asia and these are the top 10
countries China India Indonesia Pakistan
Bangladesh Japan Philippines Vietnam
Iran and turkey got it guys how to use
lch I just given you the introduction of
that but there are many more things so
all the things uh uh the remaining thing
definitely we are going to discuss in
next session as of now just think that
this uh lench is nothing it's a rapper
on top of the open AI but it is having a
lots of uses it can call any third party
API it can call any sort of a data
resource it can uh like uh it it it is
having a power to read a different
different documents it's a having a
power to making a change to making a
memory it is having a power it is uh it
is not only for the open AI we can use
this lenen for any open source model any
open source llm model and tomorrow I
will show you here I have used so let me
write down tomorrow's agenda what all
thing we are going to discuss tomorrow
tomorrow uh tomorrow's
agenda so we are going to uh cover
hugging phase hugging phase API with Len
chain uh and we'll try to understand the
use of the Len chain use of the length
chain so we'll try to understand this
use of the Len chain in very
detailed way so this will be the agenda
for tomorrow's uh like this this is the
agenda for tomorrow's class and after
that I will directly jump to the project
we try to create one project and with
that your understanding will be clear
and rest of the topic we'll cover after
uh after the project and all so tell me
guys how was the session did you like
this session uh did you uh did you got
everything yes or no whatever I have
explained yeah meanwhile you can explore
it by yourself that is a good
idea tell me guys fast uh did you like
the session please do let me know in the
chat if you are liking the session if
you're liking my content I have WR and I
I created each and everything from
scratch by myself only and believe me if
you are following this notebook if you
are following my content you won't face
any
issue and even in our interview also you
can answer in a better
way
okay so I think uh now uh we have
covered all the thing whatever I told
you and uh yeah all the resources and
all you can find it out over the
dashboard so we are uploading each and
every resources in a resource section so
just visit the dashboard and here uh we
have all the videos videos and quizzes
assignment each and everything we are
going to update over here so along with
the session you can and practice now
here uh we have our resources regarding
the first session so all the all the PDF
and all all the PPT so at least you can
revise the thing you no need to go
through with the video again and again
you can directly uh download the
resource and you can look into that if
you have attended my live session and
here we have a IPO NV file also so just
visit this uh resource section and this
is the IP VB file now I will update this
IP VB file in my day three video and
along with that we'll be having some
quizzes assignment and don't worry I
will give you more assignment more
quizzes and see in between whatever I'm
leaving so here I told you that you need
to create your own API this one uh in an
advanced example of function calling so
just use any API okay just search over
the internet I told you you can use
Rapid API and try to get a realtime data
instead of this uh dummy function which
I created over here you can take it as
assignment here I told you that you need
to you can use multiple function right
in a single shot just try to create one
more function define it in your in your
own way and then uh run it and uh get an
information so here I'm getting an
information regarding three user you can
add more user and you can add multiple
function over there so now let's start
let's begin so in the previous classes
uh in the uh previous three classes
actually I have talked about the
generative Ai llm and then I came to
this open Ai and yesterday I have I did
the detailed discussion on top of this
open Ai and I have introduced the Len
chain to all of you uh so guys this is
the notebook inside this notebook I have
kept each and everything whatever notes
whatever code and all whatever thing I
was doing all right so uh in terms of
code and all so each and everything I
have kept inside this particular
notebook and this notebook is available
inside your resource section so from
where you will get a resource guys so
for for that uh you need to go through
with the dashboard so here is your
dashboard here you will find out uh here
you will find out all the recordings U
Day One recording day two recording day
three recording so just try to go
through with the day three you just need
to click on the uh day three and here uh
check with the resource so go inside
your resource section and this is the
dashboard guys generative AI Community
Edition English so here you will find
out uh two dashboard uh the two
Community dashboard one for Hindi and
one for English so this is for the Hindi
one U actually I'm taking a same classes
on a Hindi uh Channel as well I on Hindi
I on teag Hindi you can search over the
uh YouTube and the uh it's it is your
one this English one so just go and
check with your dashboard you will find
out all the recordings and all so click
on this day three and here check with
your resource section so okay so
resources is not there I have already
given to my team but don't worry I will
check and here is what guys here is a a
notebook so uh definitely I will provide
you this particular notebook inside the
resource section so you all can run it
you all can run it and by running it you
can uh revise the thing and all and
apart from uh this notebook apart from
this resources you will find out the
quizzes and assignment also so please
try to enroll to this dashboard try to
visit the Inon website sign up over
there login and then uh enroll into this
community session for this commun
session you no need to pay anything it's
just it's a free one okay so just just
go through with the Inon website and
login um after sign up do the login and
you can access this particular dashboard
and you will find out the same dashboard
in a description also so just just try
to check the description of this video
of this live section you will find out
the dashboard or else you can check with
the previous Live recorded session also
which is already available on the over
the Inon YouTube channel got it so this
uh resource uh part is clear to all of
you now in today's session what all
thing we going to discuss so guys first
I will will start from the Len chain
first I will explain you the complete
Len chain that what is a len chain what
all things we have inside the Len chain
why we should use it why it is too much
powerful each and everything we'll try
to discuss regarding the Len chain and
after that I will come to this hugging
phase I will explain you that how you
can uh how you can use any any like open
source model from the hugging face Hub
got it yes or no so in the previous
class I told you that whatever model
whatever model is there over the open AI
platform how you can use that by after
generating a API key now in today's
session after discussing this lench I
will come to the hugging phas and I will
show you I will show you that after
generating a API key hugging face API
key how you can utilize that particular
model so each and everything uh we'll
talk about in today's session uh
whatever I have told you and after that
we'll start with the project so in
tomorrow's session or maybe day after
tomorrow so I will start with the
project end to end project I will use
this openi concept hugging face concept
linkchain concept and I will uh show you
that how you can create a web
application end to end web application
and then we'll come to the advanced part
like vector databases and some other
topic so I think uh everything is fine
uh the agenda is all clear uh so please
give me a quick confirmation in the chat
if we can start then and whatever I have
explain you whatever I have explained
you so far so it is clear or not so
please do let me know in the chat uh if
it is clear and if we can start then I'm
waiting for your
reply
fine so I got the answer now great so
let's start uh let's start with the
topic so in this uh uh notebook itself
I'm going to write it down the entire
code uh of the Len chain so whatever
thing is there regarding the Len chin I
will try to do here itself and whatever
thing uh things will come into the
picture uh whatever other libraries and
all so definitely we'll try to install
all those library in the current virtual
environment now here guys uh I told you
that how to create an environment how to
uh launch the Jupiter notebook how to
install the openi over there how to uh
like install the langen each and
everything I have discussed in my
previous session so if you don't know
about it so please go and check with my
previous session there I did a detailed
discussion regarding the environment
setup got it now here guys um already I
have written some sort of a line some U
like sort of a quotee for the L chain
yesterday actually I I like uh I was uh
I I have imported the Lenin and I have
used the key the openi key and basically
I have imported this openi class and I
created a object then I uh written a
prompt over here and here I was uh like
giving this prompt to my open API and in
the back end it was running the llm
model and here you can see this is what
this is my output got it now here I I
had written actually this this this is
the today's agenda whatever thing we are
going to discuss in today's session so
hugging face API use of Lang CH and all
so each and everything we'll try to do
here itself in the uh in today's class
itself so first of all let me write it
down each and everything over the
Blackboard so with that you will get a
clear-cut understanding regarding the
agenda and all that whatever the thing I
am going to discuss and after that I
will come to the code part code section
so let's start uh with the agenda now in
today's class guys we'll be talking
about the Len chain so let me write it
down over here in today's session we're
going to start with the Len chain now
what is a len chain why we use Len chain
and what is a difference between this
open a and this Lenin so each and
everything we'll be discussing over here
itself now the first thing the first
thing which we going to discuss in the
Len Chen the first thing how to use Len
Chen or how to use open a uh how to use
how to use open AI by a lang chin so how
to use open AI via Len chain that's the
first thing we'll try to discuss got it
after that I will come to the prompt
template prompt uh templating so how you
can do a prompt templating by using this
Len chin so the second thing the second
topic which we're going to talk about
that will be a prompt
templating promp templating the third
thing which we're going to discuss
inside the Len chain that will be chains
we'll talk about the chains that what is
a chains uh how we can utilize this
chains what is the meaning of the chain
how uh what all the different different
type of chains is there each and
everything we talk about over here then
we'll talk about the agents that what is
the
agents okay so we'll talk about the
agent that what is the agent and what we
can do by using this agent so each and
everything we'll try to discuss
regarding this agent and here if uh so
here I will show you that how you can
use the Google API so by using the Sur
API so what I will do so by using the
surp
API I will try to I will try to use the
Google API Google API Google search
API so in the agent section I will
explain you this particular thing and
after the agent the fifth one the fifth
topic which we're going to discuss
that's going to be a memory so we'll let
you know that how we can retain the
memory how we can retain the memory like
chat GPD is doing how we can do the same
thing if we are using this open API so
we will try to discuss this memory uh
memory part as well and which is a uh
like which is available over here inside
the lench and by using this Len Chen we
can implement this particular feature
after this memory I would come to that
uh document loader so uh how we can load
our different different type of
documents so document is nothing
documented just a file like PDF file CSV
file tsv file or any other file how you
and load that particular document so
we'll talk about a document loader as
well so here let me write it down
document
loader after completing all these thing
then I will come to this hugging
phase hugging phase I will show you how
you can I will show you that how you can
uh generate a hugging face API key
hugging face API token and how you can
utilize any sort of a model whatever
model is is there over the hugging face
Hub so how you can use that particular
model so I will talk about the hugging
face after that and finally we'll move
to the project section so uh this is the
agenda for today's session for today's
class and apart from this each and
everything I have explain you how to
generate a open key how to uh like use a
open a what is chat completion what is a
function calling and all even I have
talked about the basics of the langen as
well so if this part is clear to all of
you so please do let let me know in the
chat if till uh like if the agenda is
clear so I just want quick yes in the
chat and please do let me know how many
of you you are writing a code along with
me because today I will go a little slow
so you also can write it down the code
along with me please do let me know guys
please write down the
chat
good I think many of you you are writing
a code
mhm uh just a wait just uh give me a
second
fine so let's start with the uh agenda
now so here guys you can see I have
written a agenda and first of all uh let
me explain you that what is a len chain
why we are not using this openi API why
we are using this Len chain and uh why
it is too much important this Len chain
and this llama index to so first of all
let me talk about uh the differences
between this open Ai and this Len chain
and then I will come to the
implementation part so here uh first of
all let me write it down the limitations
of the chat
GPT sorry limitations of the open a
API uh limitations of open AI
API now here guys see uh if we are
talking about this open API so here you
won't be able to find out a free model
so the first thing actually the first
thing uh in the limitation uh like which
we are going to talk about so here open
a model is not a free one so here let me
write it down open AI model open AI
model open AI model is not a
free now let's see uh let's assume that
okay so the model is not a free one and
if I want to use the llm uh like if if I
want to use the llm capability or that
AI capability in my application I if I
don't have a budget so what I will do I
will go with the other option other free
option open source
option okay so let's say some XYZ
organization some XYZ organization
created one llm now I want to use this
particular llm so yeah definitely what
you can do you can use the uh API
whatever API this XYZ company has given
to you and by using that particular API
you can use this particular llm right
now let's say you don't want to use this
llm you want to use some other llm
now how you will access it by using the
different API now let's say if you want
to use some other llm whatever llm is
there let's say uh one LM is over the
hugging phas Hub right if you want to
use that particular llm large language
model from the hugging phase right if
you want to use it then definitely you
can use it by generating that particular
API key but guys just think over here uh
yes we are using a different different
API over here first of all uh we were
using this openi API but as you know
that openi model is not a free one for
uh uh like if you want to use it so
definitely we'll have to pay something
and how we're going to pay it so based
on tokens yesterday actually uh day
before yesterday I shown you the uh the
token price and all that how much you
will be a charge if you are going to use
this openi API if you are going to use a
different different model over there I
told you regarding the input tokens
output tokens each and everything I have
discussed so just go through and check
with the previous session okay so if you
are not aware about it now let's say if
I want to use any XYZ llm or any other
llm so how you can use it by using their
API key but just think that uh just
think on top of it if why not like if we
have any one solution so the one
solution actually it can interact with
several
apis right so here I'm using this open
API I if I want to access this
particular model definitely I'm using
this XYZ API or let's say some other
model for that I'm using this XYZ API or
maybe I'm downloading it but just think
on top of it if we have any single
solution for all the llms with that
particular solution if we can access all
the llms to that will be well and good
now so lenen provide you that capability
Len chain provide you that capability so
by using this Len chain you can access
any sort of a llm right I will let you
know that uh what all llm and let's say
this openi is not a free one now let's
say if you want to access a model from
this hugging phase let's say you want to
access one model from the hugging phase
so this length chain gives you that
particular capability by using the Lang
chain you can access the model from the
hugging face also and from a different
different apis I will show you what all
apis this Lang Chen is having I will
come to the documentation so Lang Chen
is not
restricted till this open AI it is
having an access of a multiple API that
is the first thing
here is a limitation and here I told you
the advantage of the Len chain I think
you got my point now the second thing if
we talking about this GPD model uh if we
are talking about the GPD
model you know this have been trained
till September 2021 data this train till
September 2021 data if I'm going to ask
anything to my chat GPT or if I'm going
to ask anything to my GPD model
definitely it won't be able to reply me
and you all agree with this thing
getting my point so if you will ask to
the chat GPT that uh just tell me who
won the recent Cricket World Cup will
the chat GPT uh able to answer this
particular
question no it cannot answer to this
particular question because this have
been trained till September 2021 data so
for that what I will have to do I will
have to call any third party API for
extracting the information yesterday I
was doing by using the function C in op
open a right but here by using this
length chain we can do in a more
efficient
way getting my point why we use this
length chain because here if we are
talking about if we are talking about
this uh like if we are talking about the
limitation of the GPT so I can write it
down over here uh it is uh it is having
limited knowledge so let me write it
down over here it is having it is having
it is having a limited knowledge a
limited
knowledge
till 2021 so if I want to extract
something if I want to extract something
if I want to exess some extra if I want
to exess something which is which
happened uh recently or uh any like real
time information so for that also like
we use this length chain and apart from
this you will find out
uh like different different like
function or different different
functionality inside the Len chain this
Len chain actually it's a more powerful
so here there I have given you two main
reason that why you should use the
length chain now here by using this
length chain so let me write it down
over here by using the different color
so we are talking about this length
chain so by using this length chain what
you can do you know so you can access
any model okay so you can
access
different llm
model different llm
model by using by using different
API whatever API this lenion support by
using different
API second
thing you can
access you can
access you can access uh uh private data
resources private data
sources you can access uh any third
party API so here let me write on the
third point you can access you can
access any third party
API got it so this is the
uh like some features of the length
chain now if we are talking about this
length chain so let me do one thing let
me create one Circle here what I'm going
to do so here I'm going to create a
circle now here I can write it down
inside this particular Circle I can WR
write it down this length CH so what I'm
doing here I'm writing
down uh just a
second so here I'm writing down length
chain now what this length chain can do
so this lench actually it is having a
chain so it can create a chain I will
tell you what is a
chain it can read the documents okay so
document loader it is having a document
loader now here I can write it on the
third one so it is having a concept of
agent for accessing any third party API
agent now this can access any sort of
llm so let me create Arrow over here so
here I can do one thing I can uh give
the arrow so what it can do so here uh
let me keep the arrow so it can access
any sort of a
llm large language model from a
different different API whether it's a
open AI or any other API I can give you
the example of two as of over here
hugging face hugging
face and open Ai and open AI
and it it is having a access of a
different different apis as well so it
is having agent it is having a chains it
is having a document loader and it can
retain the memory as well so we are
talking about the fifth one so it it it
can retain the memory so let me write it
down over here what it can do guys tell
me so it can retain the
memory it can retain the memory I will
uh come to that memory part so this one
langin actually it can do a multiple
things it can perform of multiple things
and here I have written a couple of
limitations of the openi API and this is
a limitation which you will find out
inside the openi API openi model is not
a free one and it is having a limited
knowledge so here guys you will uh so
what is this what is this Lang chain so
here this Lang chain actually it's a
open source framework which provide you
a multiple
functionality with that you can create a
agent you can connect with any third
partyy API you can create a memory you
can retain a memory you can uh read a
different different kind of documents
like CSV tsv PDF or whatever and here
you can create a chain you can create a
prompt template also I forgot one thing
so here I can write it down you can
create a different different a prompt
template so let me write it down over
here different different prompt
templates got it are you getting my
point so if we are talking about so see
if we are talking about in terms of
openi the code basically which I have
written inside uh my previous class this
one so what is this it's nothing now
instead of using open API directly I'm
using one wrapper on top of that that is
what that is a len chain so over here
let me write it down one more thing one
more point so just just think over here
that this is what this is my open API
let me let me draw it over here so here
is what guys tell me so here is my open
AI API this one now here we have a
L
chain sorry uh here actually see this is
open a API and how we are making a
request to this open API so this is what
this my Lang
chain now if we are going to run any
sort of if if we are passing any sort of
a prompt right so just just think over
here if we are passing any sort of a
prompt so we are running it we are
running it through this Len
chain okay so we are passing a input
this is what this is my l Len chin
Lenin and here this prom is going
through now to this open
API open AI
API and here is what here is my
llm if we are talking about with respect
to this openi API so like this it is
working it's nothing it's just a
wrapper it's just a
wrapper on top of on top of open
API
on top of open a API it is what guys
tell me it's just a wrapper on top of
this open AI API and not this open a API
actually it can do a multiple thing so
it can do a multiple thing right so let
let me tell you what thing it can do
let's say this is your application so
here what I can do so let's say this is
what this is my application and here is
what here let's say I have used this Len
chain this is what guys tell me let me
change a color so this is what this is
my Len chain now if I'm us using this SL
CH so it can interact with many it can
interact to a many uh like apis like
hugging face open or with any third
party like API so let me draw it over
here this one this one okay now let me
do one more thing so over here let me
draw uh one more Circle and with that
maybe the thing will be more clear now
here what I can write it down let's say
this is what this is your application
okay so over here I can write it down
this is what this is your application so
this is this is
your app now it's making a request so
this request is going through this Len
you can uh think that it just it is
nothing just a prompt is we are passing
we want to interact with llm actually
large language model so here we are
passing a prompt so first it is going
through this Len chain this is what this
nothing this is my Len
chain now this Len chain actually it can
it can interact in a many ways so over
here I can write it down some sort of
API so here I can connect with the open
AI
open API I can connect with the hugging
face hugging face API I can connect with
a bloom
API and I can access a different
different
llm I can access what I can do I can
access a different different large
language
models getting my point yes or no and
apart from this this Len can connect
with a other data resources also with
some third party API like
Google like we
Wikipedia and some other data
sources now tell me guys this length
chain is clear to all of you what is the
length chain here I have uh here here I
created like each and every diagram and
with that particular diagram I have I I
try to explain you each and everything
regarding this Len chain so please do
let me know in the chat if this thing is
clear or
not
I'm waiting for your reply please do let
me
know yes I will share this PDF note with
all of you don't worry uh I will keep
inside the resource
section please do let me know in the
chat guys if this thing is clear then I
will proceed further I will proceed with
the
Practical great so if you are liking the
content then please hit the like button
also so I will get some more motivation
so yeah guys please hit the like button
and please be interactive if I'm asking
something then please try to answer
please please write down the answer in
the chat uh that will be a great
motivation for
me okay now let's start with the
Practical implementation so over here
you can see I uh started with a len
chain so let me uh run it first of all
so here is what here is what here is my
Len chain now uh here I'm going to be
import my open a uh this uh each and
everything I have explained in my
previous class itself now let me uh
import first of all let me check with my
key this uh I will have to generate a
openi key if I want to access the open
API now now I'm not directly going to
hit this open openi API I am hitting by
using this length chain
getting my point so here I will have to
mention the open API key so let me take
my open API key just a second
uh so here I can keep it somewhere just
wait uh so here is my openi key now let
me paste it over here this
one so yes I have created my client
means I have created my object now here
is what here is my prompt here is what
guys tell me here is my prompt now what
is the prompt guys tell me the prompt is
nothing in whatever see prompt is
nothing it's just a sentence which we
are passing to to our llm as a input
it's nothing just a collection of words
collection of tokens so word itself is
called a token that's it that's is a
prompt now over here if I'm going to run
it so let me run this particular prompt
and here you can see I'm asking to my
chat GPT sorry I'm asking to my GPT
model can you tell me total number of
country in the Asia can you give me top
10 country name yes it is able to give
it it is it is able to like provide a
name basically now let's start from here
because still here I've explained you
each and everything in the previous
class now let me give the next prompt
the second prompt so over here I can ask
something else to my uh GPD model now
tell me guys what should I ask any uh
any question anything which uh you would
like to highlight uh which should I
return return over
here
good so over here I didn't get
any okay so let's uh ask like any uh
basic question so can you tell me can
you tell me a
capital of
India so let's uh search about this
capital of India and here what I can do
I can run it and uh let me uh give this
particular input uh let me give this
particular prompt to my uh uh to my
model and I just need to call this
client. predict and here I need to
provide the prompt so client. predict
and here I just need to provide the
prompt so it is giving me answer it is
saying that the capital of India is New
Delhi now here let's try to strip this
uh particular output strip means it it
will remove the slend from here so I'm
going to strip it and here you can see
it is giving me an answer so I am
getting answer without this selection
now I think it is clear to all of you
now one person is asking that what
exactly tokens and Vector uh so here
let's Ty to ask this same question uh to
the GP or uh to the jpt model so what
I'm going to do here I'm going to uh
keep same question from the chat itself
and the question is what is a token and
a vector you can ask anything to your
chat GPT and behind the chat GPT
actually this uh behind the chat GPT the
GPD model is working so let's uh ask
about the tokens and the vectors and
let's see uh what will be the answer uh
which I will get from the GPD side so
let me predict this a prompt three and
here the answer is client. predict prom
three and see the answer tokens are
individual unit that a computer program
used to perform operation they can be
words symbol or numbers so the same
thing I told you now this tokens is
nothing just a words right that are used
in programming language to represent a
specific intersection Vector is data
structure that is store a elements of
the same time it is used to store
sequence of el such as number of
character so a vector is nothing what is
a vector vector is having two unit now
magnitude and the direction so how we
represent the vector in our algebra in
our algebra if you are like little
familiar with the algebric uh algebra
concept um algebra Concept in the
mathematics so we open the square
bracket we write it down some sort of a
number and we close the square bracket
that is the representation of the vector
and along with that maybe the direction
uh might be involved that's it so here
uh you you can see definitely we are
able to call the openi API now let's try
to understand few more thing related to
this length chain now here let's start
to talk about the prompt template the
very first topic which we're going to
talk about uh we want to talk about
related to this prompt template so first
I will show you the example of this
prompt template that how you can create
a prompt template and after that I will
um I will try to explain you that what
is a prompt template first let me run
the code so here is here is what uh we
are going to discuss about this prompt
template now I'm going to write it down
from length chain from length chain and
from here I'm going to import
prompts prompts and let me import this
prompt template class so
prompt prompt uh p r o m PT prompt
templates so I'm going to import this
particular class what is the name of the
class prom template okay it's not a temp
templ actually a template so prom
template now if I will run it so
definitely I will be able to import it
so here my spelling is wrong so let me
correct it first of all and here you can
see we are able to import this
particular class now after that what I
will do so here actually I want to
create my prompt right I want to create
my prompt now let me do it first of all
and then I will come to the explanation
so here what I'm going to do so I'm
going to create an object of this prompt
class so here is what here is my object
so I'm saying that it is nothing it is
my prompt template name so here I'm
going to write it down prompt template
this is what this nothing this is my
variable prom template name got it I
have created my object now inside this
object I have to pass some parameter so
let's try to pass few parameters over
here the first parameter which I'm going
to pass over here the parameter is going
to be input variable so here the
parameter which I'm going to pass over
here that's going to be an input
variable in input variable and the
second parameter which we're going to
pass over here that's going to be a
template so how my prompt will be
looking like so here I'm going to write
it down template and is equal to right
now in the variable actually I'm going
to write it down the name what will be
my variable so here I'm saying city city
will be my variable and here I'm going
to write it down my template now in the
template actually I'm going to write
down that uh can you tell me the capital
of so here I'm just saying that can you
tell me the capital of and here on a in
a curly braces I'm going to write it
down the city right City so c i t by so
here whatever uh this is what this city
is nothing it's my input variable so
here I'm going to write down the city so
this is what this is my object this is
what this is my object for the plum so
here I can put the question mark as well
and if I'm going to run it now here you
will be able to find out it is giving me
an error why because I didn't put the
comma over here now here you will you
can see this is what this is my prompt
template now what is the issue over here
input variable okay so the so the
parameter name is what input variable
now I think everything is fine
everything is clear now here what I will
do I will call one method I will call
one method just just be careful over
here right so here I will call one
method now here I'm going to write it
down format and here what was my
variable what was my input variable
input variable was City now if I'm going
to write down City so here let me write
it down this uh Delhi so here once I've
have done it now so it is giving me a
specific prompt that can you tell me a
capital of Delhi automatically right now
here see again I'm going to ask the here
again I want to create a prompt for uh
for a different country let's say I want
to ask a capital of China c i n now here
you can see it is saying uh it is uh
giving me a prompt that can you tell me
a capital of China can you tell me a
capital of China so what is the meaning
of this prompt template what what what
is the use of it now I think you can
understand so by using this prompt
template we can construct The Prompt
based on a input variable now let's say
you are going to create an application I
can give you very uh good scenario now
here is your
application right here is what here is
your application now you you have
created this application by using the
flas now here you are ask asking to the
user just a city
name just a city name or just a country
name actually and based on that city of
based on that country you want to
provide a specific information and here
you are using any sort of a
llm whether it's from hugging face or
open AI now guys over here uh you don't
want to be here actually you don't want
that that your user is giving a entire
prompt you just want to take take a you
just want to take a city name you just
want to take a variable like we do in a
python you know in a python we we have
an input function yes or no but and by
using this input function we take a like
input from the user and let's say we
have to uh showcase the addition uh
divide or maybe uh multiplication
whatever on top of those input variable
we can do it similarly over here let's
say we are taking just a city name so by
using this city name we can construct
our prompt and that particular prompt we
can pass to the
llm and Leng chain gives you this
particular functionality we don't have
this thing inside open AI API getting my
point now so here I have created my prom
now let's try to pass this prompt to the
length chain so what I can do here I can
write it down this is what this is my
prompt
first p o p
Mt prompt first this is what this is my
prompt first and here I can write it
down prompt second this is what this is
my prompt second and here is prompt
second now let's try to pass this
particular prom to
my to my llm or let's let's try to call
the API open API for that already we
have a method client predict so let's
try to call this particular prompt now
here I'm going to call the prompt first
this is the prompt which I'm going to
call and here uh I'm going to call I'm
going to write down this strip function
also so I won't get any sort of slash or
whatsoever right now here you can see
the capital of Delhi is India the
capital of New Delhi is India okay so
here I need to write it down just just
let me redefine it instead of the city
what I can do I can write down the
country right now uh this is what this
is my country and here instead of the
city let me write it down the country
one more time and here I can write it on
the India I think now it is it is a
meaningful now here I can write it on
the country one more time uh country c u
okay c u n c
o un n and here the
same here is a same and here is also
same now it's a meaningful and let me
run it and see what I will be getting
over here so prompt one prompt second
and here is uh like a it's a New Delhi
and let me check with a prompt two so
guys here what I can do I can pass the
prompt two and let's see the output it
is saying the capital of China is a
Bing so this prompt basically this
prompt template will help you a lot
whenever you are going to create any
sort of application where you just
required a single word from the
user this thing is clear to all of you
if yes then please do let me know in the
chat
please do let me know in the chat if
this part is clear to all of you please
write it on the chat I'm waiting for
your
reply are you liking the session are you
liking the content so please hit the
like button as well if you are getting
everything if you are able to understand
whatever I'm explaining to all of you
please do let me know in the chat and
yeah and whatever questions you have you
can write it down the chat I I I'm
monitoring the chat don't
worry wait S I will come to that again I
will try to explain the L and Advantage
first of all let me uh complete the code
part otherwise we won't be able to
complete all the thing within
R yes correct Vishnu your understanding
is pretty much clear now
since open AI model is not free uh so we
Len access all
API all other API as well like uh uh
hugging face API it can access the
hugging face API it can access the bloom
API or different different API I will
come to the documentation let me uh
clarify the basic basic thing uh
whatever is there inside the Lang chain
I will come to the uh
documentation great now here everything
is clear everything is fine so here we
have this uh here we have this object
name prom template uh name and here is
what here is my method that is what that
is a format now what I'm going to do
here H so here actually we have a second
method also which is doing the same
thing let me show you that at many
places you will find out that particular
method also I written it somewhere uh
just give me a second yeah this one so
it is working in a similar way langen
has given you the two ways actually for
creating this prompt so first of all see
we have this promp template
class we can create
object and we can call this method
format method got it now we have a
second way here you can see this one
prompt template. from template you can
call this particular method also and it
will work in a similar way both are same
don't ask me sir why we are using this
that Lenin is giving you the two option
for creating a prompt template right now
here you can see prompt template prom
template what is the good name of the
company that makes product I can write
it on any like name uh any uh product
name so here uh what I can say I can
give this particular uh okay first of
all let me run it and here is what I'm
going to call this format method over
here so from template do from temp prom
template. frommore template and here is
what here is my template template and
here is what here is my tell me what is
this this is my key now input variable
now right now now let me show you what I
will get over here so I will be able to
construct my prompt what is a good name
of the company that make a
toys here is my key and here is my
template it's going to combine both and
finally I'm getting my prompt so over
here what I can do so over here I can
write it down my prompt so this is what
this is my prompt number three and see
guys if I'm going to run it so what I
will get so here I'm if I'm going to run
it this promt three ah it will give me a
name it's not a 23 basically it's just a
three so let me run it and let's see
what would be the output so p r o p Mt p
r o MPT uh it's a spelling
mistake and now let me check it is
working or not so toy makers unlimited
so this is the company name actually
which I'm getting if I'm giving this
particular prompt to my GPT model you
can test over the chat GPD as well so uh
you will get this type of nam in the
back end we are calling the GPD model
don't forget over here don't forget okay
so we are getting a uh GPT we are
basically calling a GPT model over here
so this part is clear to all of you and
uh I think now this uh prompt part
prompt section is pretty much clear I
believe that it is clear yes or no this
uh prompt template if it is then uh
please confirm in the chat then I will
uh explain you the second topic that is
a agent agent in a lang chain and after
that I will come to the uh chain and
memory and document loader and finally
we start with the hanging phase so tell
me guys it is clear this uh prompt
templating how we can create a prompt
template great it is clear to all of you
now let's understand the agent so what
is an agent guys tell me so agent is
nothing we use this agent in the L chain
for calling any third party tool that's
a simple definition of the agent if
someone is going to ask okay just tell
me who is a
agent who is a agent in a real time
let's say if I'm saying uh there is one
agent uh let's say you uh went to the uh
any uh you want to purchase any property
you want to purchase any property and
you went to the Builder and you are uh
and uh once you visited the property and
you have visited the Builder office or
whatsoever there you will find out agent
so who is the agent actually so it's a
it will so let's say you are a main
person and uh you want the information
of the property so that you want a like
the main person and you want the
information from the of the property
basically so this agent will help you
this agent will collect the information
of that particular property and it will
provide you in a similar way the agent
is working over here getting my point
yes or no I think yes now let me run it
and let's try to understand the agent so
guys over here I will start the thing uh
I will ask ask one question to my chat
GPT so here I'm going to ask one
question to my chat
GPT just a
wait great so let me open my chat GPT
and here let me ask one question the
question is very very simple so here I
want to know that uh can you tell
me
current GDP
of
India so here uh I'm asking to my CH GPD
can you tell me the current
GDP of India now if I will uh run it so
here it is saying to me I'm sorry I
don't know in a real time as my training
only include information up to the
January 22 this that whatever getting my
point yes or no tell me so it is not
having uh this particular information if
I'm asking to my CH gbt can you tell me
who won the
Cricket World
Cup
recently now here see what I will
get so here it is saying guys I don't
have a real time
information only includes data up to
January
2022 or 20 202 20 okay as my latest
updated the most recent information
World Cup was held in 2019 emerged as a
champion defeating New Zealand in a
thrilling final so is giving me an
information from the 2019 match I think
India again uh uh like uh they out uh I
think uh they uh they they got defe from
the New Zealand itself right in a
knockout match in a semi-final itself
uh yes I'm able to remember it so here
uh it is not able to give me an answer
now let's ask the same thing uh through
the open so through the lench itself in
my code I'm going to write down the same
thing over here so here I'm going to
create a prompt for so I'm asking to my
model prompt 4 so here I'm asking to my
model can you tell
me who W the
recent
Cricket World
Cup so this is the question and now let
me ask it let me run it so what I can do
I can write it down this client predict
and here I can pass my prompt prompt
four now see uh okay first of all I will
have to run it p r o m PT p r o m PT now
see guys uh it is saying that uh the 201
won by the England I'm asking about the
recent World Cup but it is saying that
uh the 2019 Cricket World Cup won by the
England only it's completely wrong right
now here what I can do I can ask one
more thing can you tell me the current
GDP of can you tell me a current GDP of
India can you tell me current
GDP current GDP of India so let's see
what will be the answer so here is what
here is my prompt five let me copy it
let me paste it over here and here I can
write it down this prom
five so as of 2039 India GDP was
estimated to be around
2.94 trillion actually it has been
trained till 20 uh 22 data 2022 data
right so till January 2022 data right so
here it is not able to give me a proper
answer uh it is not able to give me a
real time answer so for that what I will
do guys tell me so here I will use the
agent I will use the concept of the
agent which will extract the information
from the third party API now here I'm
going to use Sur API now here so for for
extracting extracting or real time info
real time info I'm going to use I'm
going to
use Sur API Sur API Now by using the Sur
API
Now by using now by using this Ser
API I will now by using the Ser API I
will
call Google search
engine
and I will
extract the
information in a real time so here I
have written this particular uh like a
statement so I hope it is clearly
visible to all of you now let me keep it
in a mark down and it is clear so for
extracting a real time info I'm going to
use Sur API Now by using the Sur API I
will call Google search engine and I
will extract the information in a real
time let's see how you can do it so here
what I'm going to do so first of all I
will have to install this particular
Library pip install Google search result
that is the first thing now install this
library inside your current virtual
environment so here what I'm going to do
here I'm going to install this
particular here I'm going to install
this particular liity in my current
virtual environment where guys tell me
in a current virtual environment clear
fine now after that what I will do so
after that I will create my Sur API key
Sur API key because uh with that only I
can access I can access a different
different API now let me show you the
surp API so just open the Google so here
just open the Google let me show you
from scratch so over the Google what you
need to do you just need to uh okay so
here what I'm going to do I'm going to
write down the surp API so let me write
down this Sur
API so once I will write down surp API
now now here you will get this very
first link so what is a Sur API like uh
we have a rapid API now in a similar way
we have a Sur API so Sur API is a
realtime API to access Google search
result not from the Google actually and
from any search engine Bing or maybe
some other search engine even we can
access the Wikipedia also right I will
show you how so here uh if I will open
it now so you just need to do sign in
first you need to do register and then
you need to do the sign in I already
registered so that's why it is giving me
this particular page now just scroll
down over here just see over here API
documentation now in a over here you
will find out a different different
documentation related to Google search
API Google Map API Google job API Google
shopping API Google image API now apart
from the Google you will find out the
Bing Bing search API also by do
also BYU also it's a Chinese search
engine now Doug du go search API Yahoo
search API yendex search API eBay search
API YouTube search API any API you can
call by using this Sur API now just
click over here API key and here is what
guys here is my API key now you have to
generate your own API key this is my API
key now let me copy this API key from
here and it is having some sort of a
limitation actually you can just do a
100 search in a free version but in a
paid version I think uh you can uh like
increase the number of search so just
see over here just open it and you will
be able to find out entire
detail so plan is a free plan price per
mon
zero uh total plan s 100 plan search
left 995 5 I already did it and yeah
this is it in a free version you can
check check with the plan so just go in
the change plan and here you will find
out the entire detail so production plan
developer plan big data plan all the
plans you'll find out over here and by
using this API you can access the Google
search engine you can access the Google
search API inside your application right
now here what I need to do I just need
to paste this API key in my I just need
to keep this APK in my variable till
here everything is fine everything is
clear now what I will do guys so over
here I will I I have to like import few
uh I have to import few uh like import
uh statement basically uh I have to
import few packages so agent type load
tools and initialize agent so these are
the these are the like these are the
packages basically which I need to
import agent type load tool and
initialize agent so see guys uh let me
import this particular thing first of
all and yeah it is working F now first
of all what I will do first of all I
will create a ag first of all I will
create a client means here I've created
now this open a uh client this
one this one okay let me use this one or
I can create one more time not an issue
as many as time you can do it so here
what I'm going to do so here I'm going
to uh paste this particular code here
I'm going to create my client so this is
what this is my client now after that I
have to load the tools which tool tell
me which
tool which tool like we are going to
load Sur API now we are going to use the
Sur API now so that that's the only tool
right so here what I'm going to do I'm
going to create a object of this
particular method sorry this particular
class so here is what here is my object
now this is what this is my tool now
here I will mention something inside
this tool now let me do it over here so
let me uh mention this particular thing
so here I'm going to mention it so this
is a thing basically which I need to
keep Sur API uh first of all I need to P
The Sur API key and llm so here is what
here is my llm already I've created this
client I'm using open still I'm using
open okay I didn't uh explain you the
hugging face so far so this is my Sur
API key and here is the name which tool
you are using that's it in our square
bracket you need to write it down the
name you can find out each and
everything with the alen tuto lenion
documentation everything is there
everything is there I will come to that
just wait so here is what here is my
tool I created my tool now I have to
inal I have to create my agent type so
here what I want to do uh so here
basically what I want to do guys tell me
so here I want to create my agent type
so U here what I will do I will uh
create an object of this initialized
agent let me create the object of this
initialize agent and here is what guys
tell me here is my agent this is what
this is my agent now inside this
initialize agent again I will keep
something so first of all the first
thing which I will keep that is going to
be a tool so the tool basically which
which I've created the second type will
be a client means my model the third
type will be a agent this agent this
agent uh basically agent type actually
and here we are going to talk about this
zero short react description we are
going to mention this zero short react
description and verbos to means whatever
information um what if I will run it now
so whatever information will be in a
back end I will be able to see not over
the display there's the meaning of the
bbos right so here I mentioned three
parameters the first is tool the second
is client the third is Agent
and the first fourth is barbos great now
let me run it so this is what this is my
agent now what I will do so here I will
write it down agent and I will run so
run now here I will ask the same
question so my question was let me take
this particular question from the chat
jpt can you tell me the okay so can you
tell me who won the recent World Cup so
if I'm going to ask the same question
now to my
agent so here what I'm going to do I
going to ask it and let's see what I
will be what I will be getting so it is
executing the agent and here is search
here is action who won the Cricket World
Cup and here you can see Australia won
the Cricket World Cup it's a recent
information it's a real time information
which I'm getting now it is giving me
many given me some other thing as well
links and all because it is calling the
Google API Google search engine actually
in a back end and here you can see it is
giving me answer a on the recent World
Cup you can ask anything
you can ask anything guys just just uh
write it down over here so you can say
that
uh can
you tell me five
current can you tell me five top current
affairs a f i i RS so if I will learn it
now it will hit the Google search enger
and here it is saying that see uh so it
is saying that top five current affairs
and still it is running so read is not
available tool try to open I should
search engine to find out observations
see here it is giving me
some like top five current affairs
International breaking news uh affairs
from us Europe this is the second one a
current affairs Subs is one of the best
known as a improved life
jagaran Jo affairs.com okay it has given
me a different different website maybe
or uh it here is a news Okay so actually
it is giving me a different different
name it it is not giving me a proper
current affairs I will have to mention
that I will have to write uh that
particular prompt basically so let's do
one thing now let's understand the
Wikipedia also so how we can uh like
call the Wikipedia so here what I will
do I will be writing down pip install
pip P install
Wikipedia now I will have to install it
in a current virtual environment now if
I will run it now pip install Wikipedia
so let it run uh so here you can see
I've installed the Wikipedia now what I
will do first of all guys see tell me
what is the first thing I have to load
the tool so let me load the Tool uh so
here is what guys see here is my tool
and here is my LM means my client open a
client that's it now my tool now what I
have to do I have to create an agent so
here is what here is my agent this is
what my agent I have initialized the
agent here is my tool here is my like
model and here is my agent type zero
short react I will come to that what is
this react description and BOS equal to
two once I will run it and here whatever
I will run now see I'm going to write
down uh agent dot run and here I'm
asking can
you tell
me more can you tell me about this re uh
okay can you tell me more about this
recent
Cricket c i c k e Cricket World
Cup so if I will run it now it is going
to extract the entire information from
the
Wikipedia okay it is it is taking from
the 2019 World
Cup okay it is taking from the 2023
World Cup itself the World Cup for the
39 Cricket World Cup which was H in
India 5th October November 23 Australia
won the
tournament great so it is excting a
information from the uh recent one
itself now here I can ask one more
question to my just a second what I can
do I can copy it first of all let me
copy this particular thing and here what
I'm going to do here I'm going to pass a
next question so the next question is so
let me keep the question over here
uh let me run
it it is taking the information from the
Wikipedia itself are you getting it guys
yes or no yes surf I explain you
everything regarding the surf API s if
you are here if you look into the surf
API right so each and every plan I have
shown you and it give you the free uh
access also but up to uh like it is
having some limitation over there you
can just hit 100 search you can just hit
the 100 100 search in a free version if
you're going to take a plan so in that
case uh there will be a different uh
number of search actually search plan is
there different different plan is there
see Di okay
$2,500 per month $8,000 per month Cloud
for plan many plans is there see guys
how much plans is
there uh which you will find out just go
through with it I let me give you this
particular link inside the chat and
don't worry each and everything will be
available inside the resource section at
the single place uh at the single place
I will keep all the thing and I will
give you that don't worry so now see it
is extracting the entire information
from the uh like uh it is going to
extract the entire information from the
vikkipedia so final answer the total
National dep of the this one and here
you can see this is the GDP of the uh
USA and here observation and all
everything everything now see action
Wikipedia input GDP of United State
observation p economy of United States
summary this is the complete information
complete information which is going to
fetch which it is fetching from the
Wikipedia itself now tell me guys how
many of you you are able to understand
the concept of the agent so please let
do let me know in the chat and then
again I will revise it and I will
explain you uh through the lench and
documentation please do let me know in
the chat first if you are how many of
you are able to understand the concept
of this
agent here from here I have started this
agent tell me guys
fast by using the Sur API we can uh
access uh we can access a real time
information and it is possible in a is
possible in a len
chain please do write it down in the
chat if you're liking the uh session so
please hit the like button also and I'm
waiting for your response guys please
please do let me
know sir please explain the logs which
is coming from the agent so here I can
explain the log so here is what here is
my logs what is this uh what is it uh
just check over here so it is saying
entering new agent executor chain so
after this I'm coming to the chain
concept chain and memory two thing is
remaining and the document loader three
is remaining uh uh then uh you will be
able to understand this chaining and all
in a better way now here entering a new
you execute a chain so action is what it
just want to search now action input top
current affairs so it is making
observation it is searching everything
from the Google then it is thinking
something I need a narrow down the list
of top five internally it is doing
everything internally it is doing
everything and it is giving you the
final answer this one finished chain
actually each and everything has been
coded in the form of chain llm chain I'm
coming to that chain and once you will
understand that particular chain now
this thing will be are like pretty much
clear to all of you believe me just just
read it by yourself as
well what is the use of client in this
what is a just it's just a name now what
is a client see I told you please learn
the python first if your python uh topic
is clear then definitely you will be
able to understand this line of code see
someone has created openi class
somewhere in openi P you just downloaded
that you just downloaded that particular
package by using pip install openi and
now you are creating a object of that it
is just is just a class and here is a
object this is the object name you can
keep it anything here you can give your
name like whatever name your name just
write it down your name this is what
this is nothing this is the object of
the openi class and here you are passing
a different different
parameter someone has created a class
and you are just using it that's it
nothing else so this is what this is my
client and I think this is clear to all
of you now coming to the next part so
here first of all let me show you the
Lenin documentation so I'm going to
write it down over here Lenin
documentation now over here uh like uh
you can see this is what there is
nothing there's a Lenin documentation
and here is an introduction so they have
given you the complete introduction of
the lenen over here Lenin Library lenen
template Lang server Lang Smith
everything you will find out over here
and this document is a
amazing one similar to this open a uh so
yesterday we have seen the open a
documentation right so this length chain
documentation is similar to that openi
documentation it's a pretty amazing each
and everything you will find out over
here itself each and everything you will
find out over here itself now let's
start with the installation so how you
can do that it is very very easy pip
install length chain and pip install and
all what is the meaning of this pip
install hyphen e dot so this thing we'll
try to understand in our upcoming
session once I will start with the end
to end project now L server we try to
understand this also what is the Lang
server all L CLI so many like they have
given you over here as of now this lch
package is required that's why we are
going to download it now over here we
have a quick start so here you will find
out the quick start so you can go
through with this quick start and you
can uh like you can take a glimpse of
this Len CH so everything you will find
out over here in a quick start itself
pip install lch pip install open a you
can export the open a key key and then
you can use it and here is a different
different thing which you will be able
to find out whatever thing we are
running so open a you can uh create
object of this chat openi also now here
is llm model here is U you can use this
particular class also chat open AI now
human messages lch schema human message
there you can check with this what is
this now you can create a prompt
templates already we have created now
just see over here what is a what is a
PR prom template most llm application do
not do not pass user input directly into
llm most of the application you will
find out you just require a single word
I given you the example yes by using
this prompt template you can achieve
that particular functionality and here
is example for that got it now here is a
chat comprom template so each and
everything you'll find out over here and
uh as uh like you will find out the
latest version so there might be some
sort of a changes in a code and all but
don't worry the concept ccept will
remain same we'll find out some changes
in a code in a classes the name of the
classes but the core concept will same
if you're getting any error in a new
version then check with the like
documentation and try to rectify it
that's it so here is a quick start and
you can go through with this quick start
and you can understand a different
different things now security wise they
have given you the different different
thing now let me come to the next part
so over here just click on this G to
started again they have given you the
different different uh thing prompt is
there model is there which model you
going to use output parser entire
pipeline okay R they have included their
R also now okay so retrieve augumented
generation so you can go through with
this and you can understand what is this
R but don't worry I will cover this in
my uh next class this RG it is I'm
having this R in my pipeline so I will
try to cover it this U uh in a live
class itself in a Jupiter notebook
itself I will write it on the code now
over here you can understand about a
different different thing different
different concept just just go through
with this document it's amazing one now
interface is there so prompt chat model
llm out part are retriever tool these
are the things just just go through with
this try to understand it now how to so
here is a different different thing
which they have mentioned Right add
fallbacks bind R time runable Lambda
many things right so here you will find
out the cookbook so inside the cookbook
everything they have given you
everything prompt plus LM so the thing
basically which we are going to do over
here uh which we are going to do as of
now they have mentioned it over here R
RG this was this was not there
previously when I had checked recently
they have added in a new version so R is
there so here you will find out the code
related to the r see this one now here
multiple chains chains I will come to
this chains after this one I will
explain this chains right so here you
can see the change and all so each and
everything they have given you but as of
now we are trying to understand this
particular part we are trying to
understand this agent and we are trying
to understand this model input output so
prompt already we talked about chat
model already I shown you by using the
open
so this is like pretty amazing document
guys so once you will go through with
this document now you will find out uh
it is having so many things and they
have given you the code and all each and
everything they have provided you
believe me guys so just go through with
this one and try to understand uh
different different thing or whatever
thing basically is there so we going to
understand this chains now and we'll be
try we'll try to understand this memory
but apart from this chains and memory it
is having lots of thing which uh we
might uh we might use in our application
if if you are creating application now
so this concept uh like might come into
the picture regarding the RG or
regarding a different different one
different different topic basically
which they have included but over here I
would like to tell you one thing
whatever I'm explaining you in a Jupiter
notebook U if you are a beginner that
definitely it's a more than uh it's more
than enough for all of you and uh in the
next class once uh when I once I will
implement the project now then uh you
will find out the importance of it and
don't worry I will uh keep some latest
thing also like R and all inside my
project and inside my uh future classes
and you will get to know that so here uh
I have given the overview now let me
talk about this uh agent type so there
basically you have seen one thing that
was the agent type now let me talk about
this agent type what is this so here you
can see guys in a agent itself you'll
find out the agent type see agent type
just just click on this agents and here
you will find out the agent type now we
have a different different type of agent
zero short Agent Zero short react agent
structure input react
agent openi function yesterday I have
talked about this openi function and now
it's a legacy people are not using it
people are using this agent concept from
the lench and directory people are not
using this open function uh but still I
have explained you that so here you will
find out the conversation self ass react
documentation and all and this zero
short is nothing it's a basic one so if
you're going to ask something to your LM
model to your GPT model so you will use
the zero shot react now here you will
find out this this agent use a react
framework to determine which tool to use
based on a solar on the tools
description so whatever tool description
you are giving based on that it will
search the uh like compatible tool and
it will provide the prompt to that
particular search engine or to that
particular tool and it will give you the
out that's it zero short
react now here this is the most general
purpose action agent you can see the
node so this thing is clear to all of
you now let's start with the
chains so are you comfortable till here
and if you're not able to write it on
the code along with me sometimes it
happens in the live session don't worry
just listen to me just listen to my
words whatever I'm saying and practice
after the class practice after the live
session recording will be there and
resources also will be there so let me
write it the chain over here and let's
start with the chain
now
so first of all tell me guys this part
is getting
clear how many days you will take to
come up with an end to end project one
day only one day I will take to come up
with an end to end
project so lench is only made for the
NLP use case or any other compete
capabilities also it is having as of now
I have used this for the NLP use cases I
will have to explore the recent uh thing
whatever is there inside the Lenin maybe
uh we can use it for the other uh like
for the other task also but I haven't
explored it for the other task I just
use for the NLP once I will explore it I
will let you know that whatever recent
update is there but if you want to know
about it just go through with the recent
documentation all the llm has only text
or code generation capability yes but
you can do many whatever NLP task is
there now you can do by using the llm
because it is having the code generation
capability with that it can understand
the pattern inside the data so you can
fine tune it it is uh possible you can
fine tune inside your CPU Itself by
using your CPU I will let you know uh
otherwise I will share the resources
with all of you uh don't worry we we'll
come to that and uh we'll try to talk
about it uh not as of now later on but
yeah uh I will give you the glimpse of
that
great uh I think uh now people are
getting many
things we are using uh not completely
actually if you don't know about those
thing you won't be able to understand
this particular part that's why first I
started from the basic from the open
itself otherwise directly I can start
from the lch and then uh again you will
ask to me sun what is this uh
what is this open Ai and what is this
llm what is this genitive AI I can even
I can start from here itself from the
Leng chain so but I started from the
very
basic
okay so let's start with a a new topic
uh that's a chain so what is a chain so
let's understand the
chain so first of all I can uh show you
the documentation and
uh
just a
wait great so here actually what I did I
kept one a simple definition of the
chain and let me copy and paste
it
so here is a definition just try to read
this particular definition and try to
understand the meaning of chain and it
will be more clear once I will write it
on the code so Central to length chain
is a vital component uh known as a lang
chain chains forming the core connection
among one or several large language
model in certain sophisticated
application it become necessary to chain
llm together either with each other each
other or with other element so if you're
not able to understand by this
particular definition so let me open the
documentation for all of you so here in
the go inside this more uh just click on
this more and here is a chain just uh
read about this chain so using an llm in
isolation is fine for a simple
application but more complex application
require chaining llm either with each
other or with other component now what
is the meaning of it
so just uh okay so I have uh explained
you the agent that's why I explain you
the agent at the first place and then I
came to this chain now tell me guys this
llm was not working over there so I
changed what I did now I Chang I changed
the terminology so what I did guys now I
so this LM was not working for that
particular prompt so after coming to
this llm means let's say if I'm not
getting any sort of output so I came to
to this
chain and this chain actually it was
connecting to me it was connecting to me
to The Sur API through the surp API
basically it was connected to me Google
search engine getting my point so here
what is the meaning of chain so chain is
nothing okay if if you're talking about
chain in journal so let's say this is a
chain so something like this you will
find
out so what is this what do this guys
tell me so chain is nothing which is uh
like connecting a several
components which is connecting a several
component getting my point yes or no I
think you are getting try to understand
it what is a chain so chain is nothing
it is just connecting a several
component so here they are
saying using llm in isolation it's fine
but in complex application require
chaining that the example I shown you by
using the agent if you will read it if
you will read the answer of the if
you'll read the answer of the agent
agent I'm running agent don't run and
you are getting an answer so if we'll
read that you'll find out it is chaining
means for is trying to find out
somewhere else it's not able to get then
again it is going to somewhere else and
it's going to take a information then
again it is going to call some other
prompt and it's going to take a
information so what is a chain so chain
is nothing it's a collection of
component now which component what
component whatever component maybe
inside the uh like uh uh like whatever
let's say we are using length chain and
inside that we have a different
different component I'm going to chain
to those particular component and maybe
I'm going to uh like connect with other
llm so I can do that as well or maybe
I'm going to connect any third party API
I can connect that as well so I'm doing
a chaining if I'm running chat agent.
run now internally it is doing a
chaining
getting my point I think you're getting
now let's try to understand in terms of
python code so here first I will start
with a very basic example so what I can
do here so here uh first of all I can
write it on my
client so here is my client guys c r i e
n t this is what this is my client now
what I will do guys so here I'm going to
import The Prompt template so this is
what this is my prompt template and by
using this prompt template I'm going to
create I'm going to
create uh I'm going to create one prompt
so here is what here is my prompt so
what is a good name for a company that
makes a product so here I can run it and
let's say uh I'm going to write it down
any company name so okay I'm going to
write down the uh actually I want a
company name what is a good name for a
company that makes a product so I'm just
asking to my chat GP okay I I'm making
this particular product just give me a
good name for this particular company so
here I'm going to write down let's say
wine so wi so here I uh I'm uh just just
think that uh just think like that that
I'm going to open a company uh and here
I'm going to produce a wine and all uh
okay so I want a name any creative name
okay that I'm asking to my LM model now
here if I will uh like close it so what
I'm going to do so here I'm going to run
it so uh prompt. format so this is what
this is my prompt what is a good company
name for a what is a good name for a
company that makes a wine so that's
going to be my
prompt p r o p Mt so this is what guys
this is my prompt now what I will do so
here actually I'm going to import the
chain here I'm going to import this llm
chain here I'm going to import the llm
chain just just be with me just for uh
next 5 minute everything you will get
it's my promise to all of you I have
simplified every thing every uh like uh
every line of code just be with me next
for 5 minute so here you can see we have
a llm chain now what I'm going to do I'm
going to create a object of this llm
chain now guys uh here I'm not going to
call a predict method I'm not going to
call a predict method what I'm going to
do so here in this llm CH what I'm going
to pass guys I'm going to pass client
right and I'm going to pass my prompt
that's it this two thing I'm going to
pass so llm llm is what c l i n t and
here I'm going to pass my prompt so p r
o p Mt prompt is equal to
prompt so I passed the client and I
passed the prompt here now this is what
this is my llm Chen right I'm going to
connect both component LM and my prompt
now over here what I'm going to do so
this is what this is my chain this is
the object basically which I have
created now here you can see it is
saying that uh it is giving me
a why I'm getting it let me check with
the
prompt so here uh let me run it first of
all what is a good company that makes a
wine okay from template uh I think I
will have to
use format uh I think I will have to use
this particular prompt only uh this one
this only uh let me delete it because it
is asking
I need to provide in the form of
dictionary so I cannot pass a direct
prompt over here what is a uh because uh
here whenever I'm running this uh
whenever I'm calling uh the run method
Now by using this chain then
automatically it will uh like take the
name from here itself so let me delete
it let me delete this particular line
I'm going to delete it guys this one so
here is what here is my prompt now Len
chin llm chain and here now it is fine
now what I will do here I'm going to
write down chain and chain. run and here
actually I need to pass the value so
here I'm going to pass y now if I will
run it now see it is giving me answer
the name of the company is what it's a
uh sdip strip and is the name of the
company is what Vintage Wines Winery so
it it has given me a name of the company
like I want to create this particular
product and here it has generated answer
now I'm going to change
I I'm making a chain by using two
components the first one is llm model
that is that I'm getting from the openi
and which is available inside my client
and the second is what second is a
prompt which I'm passing over here so
now I can directly run it by giving the
keyword and here you can see I'm getting
answer so I'm changing this two thing
this is the simple this is the simplest
uh like uh there simplest example I've
given you now let come to the second
example so over here what I'm going to
do so here I'm giving the the second
example example
two example two so I took one more
example to for explaining uh this
chaining part actually so here uh let me
copy and paste so here is what guys here
is my prompt template this is what this
is my prompt template now here I'm
asking uh this is what this is my
template I want uh to open a restaurant
for cuisin Indian cuine Chinese cuisine
Mexican Cuisine Japanese cuisin American
Cuisine whatever for that I want a f see
name this is my prompt template let me
run it here I'm running it now if you
will find out the prompt template so
here you will find out the prompt
template so this is what this is my
prompt template got it now what I will
do guys here I will make a chain so what
I'm going to do so here I'm going to
make a chain so let's say uh this is
what this is my chain so llm chain and
I'm going to combine two thing first is
client and the second is what the second
is promt template now if I will uh run
it so so here I'm getting my chain then
I will write it down chain do run now
I'm uh let's say I'm giving something
over here let's say I'm giving uh
Chinese so according to that it will
give me answer so the answer which I'm
getting the golden dragon dragon place
so here what I'm getting guys I'm
getting this Golden Dragon place so the
emperor's kitchen that's the name okay
if I'm writing over here uh Indian let's
say what I will be getting so Indian so
here actually I'm getting Maharaja
Delight so just the name it is
suggesting me one name which I'm asking
to my llm model that's it now let me
show you few more thing over here now so
here I'm getting a a response and the
response is fine now let me uh come to
the second thing second example so here
what I'm going to do so here let me show
you something so now over here if you
want to see the detail actually so for
that I have mentioned one more thing
that is a verbos parameter as I told you
earlier if I want to check all the
detail whatever is happening in back end
so for that there is a parameter verbos
is equal to true now if I will run it
now see what I will find out uh let me
predict with some name so let me uh
check uh chain. run and here I can write
it down let's say America so here it is
saying that entering new llm chain
prompt after formatting I want to open a
restaurant for American food suggested a
fancy name for this and here is a name
American spice Visto so you can see the
complete detail over here what is
happening by using the barbos true until
here everything is fine everything is
clear now guys here uh this is the
simple chain basically which I have
created by using this two component now
let me explain you One More Concept over
here so here actually I have written one
definition or I have written one text uh
just let me explain you the this
particular part and then uh again I will
try to revise you so here I'm going to
mark down it and here guys see what I'm
saying if you want to combine multiple
change and set a sequence for that we
use Simple sequential chain simple as
simple as that right so if you want to
combine a multiple chain if you want to
combine a multiple chain and set a
sequence for that we use a simple
sequential chain so let's try to use the
simple sequential chain and let's
understand what is it so for that
basically I have designed one prompt
okay just just understand over here so
step by step we'll try to understand see
Ive already written a code in my doc I'm
just copy and pasting so that I can save
my time that's it everything is same see
I can write it now the code in front of
you also but it will take some time for
writing this particular uh statement on
all it's the same thing okay wherever I
have to write from scratch I will do
that now over here see uh let's try to
understand step by step
now over here this is what this is my uh
second prompt so in the first prompt see
in the first prompt The Prompt template
which I have defined what I'm saying
over here I'm saying uh I want start a
startup right I want want a start a
startup and suggest me a good name so
here is my prompt now here you can see
this is my input variable that is what
that is a startup name yeah it's fine
it's clear to all of you now here I've
created a chain by using this a model
this is my model and this is my prompt
template okay this is the first shap now
here I have created one
more prompt now here I'm saying uh
suggest some strategy for the name so
whatever name name whatever name I will
get from here startup name for that what
I want I want some sort of a strategy
let's say I'm going to open or I'm going
to start my atte startup so for that
what I require tell me so I for that
basically I require audience I required
my team I required my Marketing sales
team if I want to open any fintech
startup or if I want to start any
consultancy or whatever right whatever
uh like company which I want to start so
regarding that what I want I want some
sort of a strategy
getting my point here yes or no so now
what I will do I will combine this two
change see here this this is my first
change this this this is what this is my
first chain this one and this is my
second
chain now I will combine this both Thing
by using simple sequential chain I will
making I'm making a
sequence I'm trying to make a sequence
between these two
chain okay before I I was just running
with a single uh like uh with a single
chain only and we we are having only two
component llm and my prompt now here I'm
going to come my true chain now just
tell me guys here I'm using this
particular llm can I use a different llm
over
here I can try with that I can check
right so here I'm using a same model now
I can check with a different LM also in
this particular case so this chain is a
pretty amazing thing it is connecting a
homogeneous component or it is it can uh
we can connect a hetrogeneous component
also means some other model as well you
can test it with the other model uh so
here you can see we are able to do it
now guys here what I will do so here is
my first template this is my first chain
this is my second template this is my
second chain now what I will do over
here so here I'm going to import a
sequence uh so here I'm going to import
a simple sequential chain here I'm going
to import this simple sequential chain
now once I will run it so here I
imported now let me create
a now let me create a object of it so
here guys here is a object now inside
this object inside while I'm creating
object I will pass some sort of a
parameter so it will call my init method
okay in a back end now here I'm going to
pass some sort of a parameter and that's
going to be a very very easy and here is
the parameter name so chains first is
name chain and the second is stategy so
automatically see what will happen
actually first it will call to this one
it will uh generator startup name
automatically it will give uh it it will
give name to this particular uh like a
to this particular template
automatically it will fetch from there
itself and I will be getting this
strategies I will be getting this
particular strategies automatically
chaining automatically chaining is
happening okay this one now let me show
you how so over here uh what I will do
so let me uh create object and here I
just need to call a method so here I'm
going to call uh method that's going to
be a chain. run now here I want to open
a startup let's say the startup related
to the artificial intelligence so here
I'm going to write it down
artificial
intelligence now here once I will call
it so let me run it and let's see what I
will be getting over here so I'm making
a sequence guys between a
prompts so it is saying that uh develop
a strong marketing strategy and and some
sort of a information let's let me print
it uh so that I won't get this
lesson so here is my
strategies stay informed and up toate on
a latest AI train develop a
comprehensive uh AI strategy utilize AI
tools utilize data driver inside so
these are some sort of a strategy
actually see automatically I'm getting
see this name now which which we have
defined see startup name which is coming
over here okay then whatever name is
coming from there automatically is going
over here this inside this name and we
are getting a strategies we are chining
we are chining right now this is a
simple sequential chain now here uh here
we have one drawback actually uh we it
is giving me a final answer it is not
giving me a answer uh it is not giving
me answer related to the first prom it
is not giving me it is not giving me
that particular answer it giving me a
direct uh the last one answer from the
last uh like a prompt itself if you want
answer like from the entire prompt so
for that also we have one method okay uh
sorry we have one more class let me show
you that particular class now so here uh
what we can do so I already written the
name so let me give you that particular
uh name and here is what here is a name
guys so the name is what now let's try
to understand the sequential chain so so
far actually we have understand the
simple sequential chain now we are going
to understand the sequential chain and
it is having a more power compared to
this SE uh simple sequential chain where
we can uh keep uh the sequence sequence
of the different different prompts and
the different different chains now uh
let's try to understand this sequential
chain and here what I'm going to do here
I'm going to copy one more code now let
me paste it over here so again I'm going
to create okay already I have a client
so let me move it it is not required at
all so here is my prompt template and
what I'm saying here I want to open a
restaurant suggest me a fancy name now
just see over here what I'm going to do
I'm going to mention one key over here
that is what there is my output key and
what is my output key output key is
nothing it's a Resturant name right now
now just see over here where I'm going
to use this output key so here I'm going
to Define one more parameter one more
prompt template and here guys you can
see so in this particular prompt
template prompt template name we have a
prompt template and and here input
variable kin and this is a template now
here is my chain llm chain this is my
model this is my prompt template and
here we have a output key output key is
what restaurant name so whatever name
basically whatever name I will get from
here I will keep inside this restaurant
name and this restaurant name I'm
passing over here this restaurant name
I'm passing over here and here whatever
thing I will get from here from this
particular prompt I'm keeping inside the
menu item and if you are going to create
a next
prompt you can mention over there now
let me run it and let me show you what
will be the final answer over here so
here I'm going to import the sequential
chain and here you can see so this is
what this is my sequential chain and now
let me copy it and let me paste the
final code and here is my uh object of
the sequential chain so let let me keep
it in a single line so here sequential
chain this is the object which I have
created now change what I want to chain
means like in terms of what I want to
make a chain so this is the first name
name chain this is the one now second
chain is what food item chain means I
want a food item regarding that
particular restaurant now over here this
is my input variable and here is my
output variable restaurant name and menu
items this
one Whatever output I'm getting from
here I'm keeping over here inside this
variable whatever output I'm getting
from here I'm keeping over here inside
this variable and I'm going to mention
inside the output variable if you want
to make a further chain you can do it
according to your problem statement now
let me run it and let me show you the
final answer and the final response so
here I am going to call this method
chain okay so this is about this is my
chain and here let me run it and see
what I will be getting so chain and I'm
I'm passing cuisin Indian so it is
giving me cuin is what cuin is Indian
and here is a restaurant name there's
going to be a Taj Mahal Palace Taj
Maharaja Palace and here is a menu item
now so guys this is the response which
I'm getting over here can you see over
here the response which I'm getting all
the thing all the thing in a sequence
now let me revise this particular thing
revise me this particular concept so
chain what is a chain which is going to
connect two components so here what I
did see here I have connected two
component first is model second is
prompt now in example two you can see
what I'm going to do so same thing I'm
going to perform now in the third one uh
with the entire detail actually with our
entire detail now in the third one I'm
calling simple sequential chain in that
I'm getting a output from the last
prompt but if we are talking about a
sequential
chain instead of the simple sequential
chain I'm using sequential chain so I'm
getting a entire output over here means
from first template uh from first prompt
template to last prompt template and
here you can see we are mentioning this
output key so whatever answers I'm
getting over here whatever answers I'm
getting from this particular uh prompt
right we are able to store it over here
and we are passing to the we are passing
to the next prom we are passing to the
next uh like a prompt basically over
here you can see this one same
restaurant name and we are going to
combine it finally
so guys tell me do you like it did you
understand
it I will come to that the purpose and
all everything will be clarified right
so uh we will talk about because
everything should be connected now to
each see whenever uh like if you are
going to ask to anything uh to your chat
GP what do you think tell me so how this
application is working we are are we are
like uh what we are going to do guys so
we are reaching step by step actually we
are trying to reaching to our final
application understand guys so here if
someone has created this chat GPT it
they have implemented everything
whatever we are going to run by using
this Len chain here you will find out
the memory concept okay let me ask one
question to my CH gbt so here here I'm
asking can you tell
me can you tell me about something Taj
okay so here uh I'm asking this question
to my chat jpd now here you can see
uh uh like uh here is the answer now I'm
asking to my chat GPT 2 + 2 how much so
it is saying to me let me run it so here
it is saying to me 2 + 2 is nothing it's
a five okay sorry uh it's a four right
now here if I will ask to my chat GPT
how much 100 uh
multiply by 1,000 now if I will run it
so here you will get the answer now here
if I will ask to my CH GPT
who
uh build the Taj Mahal can you who built
the Taj Mahal so here if I'm going to
ask this particular question so here you
can see the Taj m b by the mul Emperor
so actually it is not going to forget
the context whatever you are asking now
previously it is able to sustain the
that particular memory it's a biggest
power of the CH GPT so we are trying to
reach uh like step by step we are going
to we are trying to understand all sort
of a thing by using this Len CH and then
finally we will move to the uh the end
uh like a goal the our end application
now over here this chain actually is
very important if you want to uh like a
retain the information from the first
prompt to the last prompt for that you
can use this uh you can use this uh
sequence chain I can understand you are
uh trying to understand that where we
are using in a real time in a
application and all I will come to that
part okay but just understand over here
so I was running the Sur API so here
actually once you will read the entire
detail of the Sur API of this agent so
you will find out that in like uh uh
internally it is using the chaining it
is trying to chain each and every thing
back in a back end basically they have
implement the chaining complete chaining
so just just try to read it and finally
it is giving me a the the like
conclusion over here so in a similar way
here I just shown you the example a very
basic example but by yourself what you
can do guys so by yourself uh like you
can uh like create a different different
prompts and you can implement this
chaining concept over there and you can
understand in a better way you can
search about the applications and
all getting my point yes or
no tell me guys this thing is getting
clear to all of you if it is getting
clear then please do let me know in the
chat
so are you able to get it uh please do
let me know in the chat guys if uh this
thing is fine to all of
you
I'm waiting for a reply guys if you can
write it down the chat and if you're
liking the session so please hit the
like as
well great now let's try to understand
uh One More Concept and then I will uh
stop the session uh today I couldn't
reach to the hugging phase but don't
worry tomorrow I will show you that and
memory also so One More Concept is there
memory now let me show you the basic
concept now the uh the very basic
concept of the Leng chain which we are
going to use in a future that is going
to be a document loader so let me
explain this document loader also so
here uh what I'm going to do I'm going
to uh show you that how you can read any
sort of a document by using this uh by
using this length chain now once you
will search uh let me search over the
Document
loader document loader Lang chain
documentation so simply I'm searching
about this uh document loader on top of
the documentation so here uh let me open
this document loader so once you will
come inside this module now and here is
a uh here is a like option retrieval now
inside that you will find out a document
loader so CSV file directory HTML Json
markdown PDF or different different
document you can load and it is required
it is required I will show you where it
is required and once I will reach to the
Practical implementation once I will
create any sort of a project okay so
there I will show you how you can read a
different different files and how you
can utilize let's say uh you have one
information so some information inside
the uh txt file or maybe in the format
of HTML or Json or maybe CSV now you
want to read it from there and you want
to give it to you uh you want to give uh
that particular information to your uh
chat GPT or maybe GPD model so in that
case you will have to use this document
loader so let me show you how you can
use this uh PDF loader so here is what
here is a PDF loader so for that first
the first thing what you need to do you
need to install this P PDF so just open
your notebook and here write it down
this pip install pip install P PDF so
once you will write it down this pip
install P PDF you will be able to
install this Pi PDF inside your virtual
current virtual environment now after
that you need to lo you need to write it
down this particular command uh you need
to write it down this particular import
statement from lench do document loader
import Pi PDF loader right from the
documentary itself I'm going to take it
I I'm I'm I'm not going to write down by
myself here I'm showing you the power of
the documentation so once you will
explore it you will get a many more
thing from here itself right whatever
like you want so here I'm going to uh
what I'm going to do guys so here I'm
going to mention this import statement
now we have one uh ex uh now here
actually we have to call this particular
method sorry we have to create a object
of this particular uh class and here let
me paste it down so this is the pi PDF
Lo now I have to pass my PDF I have to
give the uh I have to like write it down
the my path whatever is there uh in my
local system so inside my download let
me check any PDF is there or not so let
me check with the
PDF LM here is a PDF machine translation
attention so let me copy the path uh let
me paste it down over there let's see it
is able to read it or not
so where is a path guys here is a
path let me copy the path and I have
copied the absolute path now where it is
here is my code so here I pasted my path
and let's see it is going to load or not
it's showing a uni code error so let me
put the r over here and it is done now
let me check inside the loader that what
I have so here it is created the object
now let me I write it down the loader
over here loader do loader so once I
will write down this thing so here you
will see that uh okay l a d r loader do
loader P object no attribute
loader uh what is this let me check the
documentation here they are calling
loader and split and that will give you
the
pages great so let me call this uh
loader and split
and here I have a Pages now let's see we
have a Pages yes I got the entire detail
so see I able to read the PDF by using
this document reader why I've shown you
this thing because uh it will be
required we use now pandas do read CSV
for uh like collecting any any sort of a
data in the form of data frame right so
if I want to uh take any data if I want
to format any data in the form of data
frame so so we use this pd. read CSV or
we use np. aray similarly if you want to
read any a document by using this L
chain you can do it you can do it guys
so here there is another one and uh you
can take it as assignment you can read
the CSV there is a complete code here is
a uh code for the file directory here is
a like HTML here is a Json markdown is
there there's a different different uh
like a uh different different document
loaders you will find out now guys uh
let's try to revise the thing let's
revise the session what all thing we
have learned in today's class in today's
session and then I will conclude it and
in tomorrow's session I will start from
the memory memory and finally hugging
face sorry actually I went uh into some
depth Okay I uh I try to explain New
Concept in a detail way that's why I
couldn't start with a hugging face API
but don't worry in tomorrow's session I
will show you how you can uh how you can
uh download any open source model how
you can use any open source model model
by using the hugging pH API and then uh
right after that we'll try to create our
application that is going to be a McQ
generator we'll see that how you can
generate McQ by giving any sort of a
text and where this document loader
where this chaining memory each and
everything will come into the picture
and even the prompt also prompt template
right now let's revise the thing what
all thing we have learned so let me
revise it over here so in today's class
uh we have talked about so where is my
pen
yeah so in today's class we have talked
about this agent I have shown you that
how to call a third party API so here we
have seen how to call a Google search
engine Google search engine API Google
search engine API so let's say uh your
chat GPT actually has been trained till
uh September 2021 data so if it is not
able to give the information in a real
time in that case you can use this agent
you can call you can can use the concept
of
chain right you can use the concept of
chain in which scenario so where you
have a multiple prompt which is
connected to each
other not a simple application not a
simple prompt just for the testing I'm
talking in a real
time so I'm talking in a real time uh
just a
wait
uh now it is fine so here I was talking
about this uh Google search engine and
uh yep and then we have talked about the
change prompt template also document
loader now this uh two thing is
remaining so in uh tomorrow's session I
will start from the memory uh in
tomorrow session actually I will try to
explain the memory concept and then I
will come to this hugging phas API got
it guys yes or no so how was the session
uh did you learn something new so please
do let me know guys uh did you learn
something new from here whatever I have
explained and uh how was the session how
was the content uh please do write it
down the
chat
should I add a few more things if you
want then uh please do let me know
please uh write it on the chat I I'm
like waiting for your replies and you
you can comment also so if you are
watching re-watching the video and if
you want something from my side you can
write it on the comment section you can
tell me over the LinkedIn and yeah
that's it so I hope you are liking my
session so please hit the like button if
you liking the content if you're liking
the
session GB 3.5 get updated till yeah ah
recently we have seen that today
itself
so why we are using Len chain and
advantages over other API you will get
to know more about it in tomorrow's
session otherwise just try to revisit
the session in a starting itself I have
talked about the limitations of the
openai and I talked about the advantage
of the open a clearly I have written it
over here so just try to revisit the
session you will get it and here I have
tried to explain you everything what is
a lenen it's a rapper or the open Ai and
uh your app here is a lenen which is a
rapper now you can hit a multiple Thing
by using this Len
chain yes day three not day three
notebook will be available in your
resource section soon it will be
available don't worry uh yeah so this is
it guys from my side I hope uh like uh I
already told you the tomorrow's agenda
uh memory and the uh hugging phas right
so thank you guys thank you bye-bye for
joining the session if you have anything
any doubt or any concern or anything in
your mind so just uh do let me know
please uh write down the uh please write
down your thoughts in a comment section
and you can ping me over my LinkedIn as
well okay so let's start with the
session and today is a today is the day
five day five of this community session
Community session of generative AI so uh
I already uh covered um most of the
thing actually in a in with respect to
this open a and this Lin and uh in total
I took four session uh here you can see
all all these four session uh where I
have started from the introduction of
the generative AI then I came to the
introduction of the open Ai and we we
have understood we have understood the
concept of the open API then I have
discussed about the Len chain and
yesterday also I was talking about the
Len chain in today this class uh I will
be talking about the memory Concept in
the Lang chain which was the remaining
one and after that I will start with the
hugging face API and then uh from next
class onwards we'll try to uh Implement
our first end to end project by using
this linkchain and this open AI so uh
guys here we have uploaded all the
sessions all the lecture you can go
through with this dashboard which is
already there over the Inon platform you
just need to sign up and after the sign
up you need to login over there and you
will get this particular dashboard uh
over the in youron platform so already
we have given you the link uh in the
chat so please try to uh enroll yourself
if you are new in this particular
session uh this enrollment is completely
free you no need to pay anything for
this uh for this en for this particular
session uh so you can down uh you can
enroll inside the course and you can
access all the uh lectures and here you
will find out the resource section
inside that all the resources uh is up
to date whatever thing I have discussed
in the live classes each and everything
you will find out over here so let me
show you yesterday I have discussed
about the lure so this file is already
there you just need to download it and
you can uh run inside your system you
can run inside your system you can run
over the Google collab anywhere you want
so I shown you the setup in in the local
system itself you can go through with my
previous session and there you can
understand how to to do a local setup
how to do a h setup with respect to open
Ai and Linkin how to run a code
regarding this open Ai and Lenin each
and everything I have explained you in
the previous classes so please go
through with my session and uh like uh
try to understand at least till here
till this L and this open I so uh you
can implement the project along with me
whatever thing I'm going to explain from
next class onwards uh because in today's
class I will cover this lure memory and
then I will come to this hugging face
API and from Monday on onwards Monday
onwards Monday to Friday so Monday
onwards I'm going to start with the
project Tuesday also I will take a
project and then I will come to the
vector database and then few more
concept few uh like different different
models uh some open source model and I
will try to explain you this uh ai2 lab
also that uh how you can uh access that
Jurassic model uh which I told you in my
initial uh like introduction so yeah I
think everything is clear everything is
fine to all of you so please do confirm
in the chat if uh everything is fine
everything is clear till here then we'll
start with today's concept so I'm
waiting uh for your reply please write
it on the chat
guys and you can find out the same
session over the Inon YouTube channel as
well so just try to visit the Inon
YouTube channel and go inside the live
section there you will find out this
committee session already uh the
recording is uh already we have upd the
recording in the live uh section itself
and in the description you will find out
the uh you will find out this dashboard
link as
well uh let me show you that just a
second yeah so here is Ion YouTube
channel so just uh uh over the click
over the channel and here go inside this
live section click on this live section
there you will find out all the
recordings so uh this is the very first
recording where I have discussed uh each
and everything regarding the generative
Ai and the second recording is this one
the third one this is the third
recording and here you will find out the
fourth recording now just click uh any
of them so after clicking just try to go
through with the description and here
you will find out the uh dashboard link
and other details so each and everything
you can find out uh over the Inon
YouTube channel as well you you can find
out this uh dashboard link over there
just click on that and enroll yourself
it is completely free now let's start
with today's session so here I will be
talking about the Len chain L memory in
Len chain so how you can uh like uh how
you can use this memory con concept by
using this Len Chen but before starting
with the Practical let me give you some
theoretical explanation so what I'm
doing here I'm going to open my
Blackboard and here I will try to
explain you the concept of the memory
right and a what thing we are going to
discuss that also I will be talking
about here I will be writing in front of
you and then finally we'll Implement uh
those particular thing in a python now
uh in the previous class I was talking
about the Len chain and I given you the
complete detail introduction regarding
the Lenin that what is Lenin why we
should use it what is the advantage on
top of this openi API why we should not
use openi API why we should use lenen
each and everything we have discussed
now in future session uh I will explain
about the Llama index 2 so it is similar
to Lenin and I will come to the Llama
index 2 and it's a framework from the
Facebook site so we'll try to discuss
each and everything related to L related
to this llama index 2 as well and I will
give you the differences between Len
Chen and Lama index 2 but as of now here
I'm going to explain you the Len chain
only and most of the concept I already
discussed so if we talking about the Len
chain so what all thing we have
discussed so far let me tell you that so
in the Len chain first I discussed that
how to uh call the open a API by using
this Len chain you can think that this
Len chain is nothing it's a wrapper on
top of this open a API and not only
openi API we can access a various API by
using this Len shed so here we have
openi API we have seen that how to
access and how to uh how to access or
how to use the open API by using the
there is just a simple import statement
which I which we have to write it down
inside the notebook or inside the code
and we will be able to import it that's
it now apart from that we have seen the
concept of the agent I have explained
you that what is the agent then uh I
have explained you the prompt template
that what is a prompt
template prompt template how you can
create a prompt template and all so we
have seen each and everything regarding
that now we have understood the concept
of the chains that what is chains and
what we can do by using the chains if we
are going to define a chain right so uh
what all thing we need to import what
component is required what is the
meaning of the simple uh sequential
chain what is the meaning of the
sequential chain each and everything I
have discussed regarding the chains
after that I came to the document loader
I have discussed about the document
loader if you want to uh load any sort
of a document document is nothing it's
just a like a files and all right so if
you want to read the PDF PDF file if you
want to read the Excel file CSV file
HTML file or maybe any other file so you
can um you can load that particular file
by using this link chain it is possible
now the fifth one now the sixth one
which we're going to talk about that is
going to be a memory so we'll uh discuss
the concept of the memory first I will
write it on the code and then again I
will come to this memory part and try
will try to explain you but before that
uh I would uh I will explain this memory
memory concept by using the chat GPD
also before writing a code now this is
all about the L CH these all are the
thing basically which we need to discuss
regarding the L chain and that's going
to be a very important if you are going
to implement the project end to end
project now after that what I will
discuss so here let me write down the
topic name which we're going to discuss
after this Lon so I will talk about the
hugging phase hugging phas API how you
can generate a token how you can
generate a hugging phas API token and
after that we'll try to access a open
source model whatever model is there on
top of the hugging phase so we'll try to
access those particular model by using
this hugging phase and we'll try to do a
same thing we'll try to do a same thing
basically which we are doing uh by using
this open API but at this uh now at that
time I'll will be using the open source
model not this U uh like not this GPD
model basically which is a uh which is a
like model of the open a now will try
try to access those open source model
and then we'll try to understand that
how uh we'll try to understand that how
you can create a pipeline by using the
hugging face so we'll try to understand
the concept hugging face pipeline
hugging face pipeline I told you this uh
Lenin is nothing this lenen is a wrapper
okay this lench is a wrapper on top of
this uh open ey this lench is a wrapper
on top of the hugging face so not only
open AI we can interact with hugging
face also uh by using this L chain and
not even with hugging phase we can
interact with many API in future I will
explain you that I will come to that and
if you if you want to know about it so
you can visit the documentation
yesterday I shown you the documentation
of the Len chain and you can see over
there not even open AI not even hugging
pH we can access a multiple API by using
Lang chain so Lang chain is nothing just
a rapper on a different different uh on
top of a different on top of different
different
API got it yes or no I think this thing
is clear to all of you then we'll see
how we can create a hugging face
pipeline which we used to do by using
the hugging pH Transformer now here also
we can import the same thing we can
import the hugging face pipeline by
using the Len chain and we can create
the pipeline and we I will show you so
here uh by using the hugging phas API
you can access the model by using the
hugging face API you can access the
model but you can install this model
inside your local environment also
inside a local environment also inside
your local memory also so I will show
you how you can perform the same thing
by
local llm local LM means what nothing
I'm just going to be uh I'm just going
to be download the model I'm just going
to be download the model from the huging
phase and that model itself I'm going to
use similar to this uh GPT and all which
I which I'm like accessing by using the
open API or by using the Len Chen Len
Chen and openi right so same thing I can
do over here as well uh okay by using
the hugging face API but if you want to
download the model in your local memory
in your local system that that also you
can do that also uh you can do and that
is also possible so I will explain you
that part as well and finally we'll
create a hugging phas Pipeline and from
next class onwards we'll start the
project implementation so uh if uh
everything is fine until here then
please do let me know if the agenda is
clear to all of
you and if you are liking the session
then please hit the like button
guys please hit the like button if you
are liking the session
I just started I I just given you the
overview that what all thing we are
going to discuss that's it I haven't
started with the coding and
all no we don't have a session on
Saturday and Sunday uh we have a session
from Monday to
Friday
great so let's start with the
implementation so first I'm going to
start from the memory that what is a
memory inside the L chain and how we can
use that so see first of all let me uh
explain you the same thing by using the
chat GPD so what I'm going to do here
I'm going to open my chat GPD and let me
write it down something over here so
here I'm going to write it down that uh
can you tell me uh can you can you tell
me who won the first World Cup first
Cricket World Cup so I'm going to ask to
my Chad GPD that can you tell me who won
the first Cricket World Cup so that this
is my question which I'm going to ask to
much chbd now let me hit the enter and
let's see the reply so is saying that
the first Cricket World Cup was held in
1975 and uh the Western de emerged as
the champion they defeated Australia in
the final which took place as a l uh
Lords cricket ground in London on uh
June 21
1975 so Western was the uh winner at
that particular time now let's try to
ask something to my chat gbt so here I'm
asking to my chat GPT can you tell me
can you tell me 2 + 10 so here it is
giving me answer 2 + 10 is 12 now let me
ask something else to my CH gbd can you
tell me
about the Indian GDP so here I'm going
to ask my chat GPD can you tell me about
the Indian GDP so it is uh saying that
uh my knowledge up to date till uh U
till January 2022 so I don't have a most
recent data now it is giving up some
more detail now you can ask the GDP you
can ask like GDP the that what was the
GDP in 2021 in 2022 something like that
or whatsoever now here see what was my
first question so here I asked the first
question can you tell me who won the
first World Cup who won the first
Cricket World Cup now here see after
writing this many of after writing a
different different like a question now
is still my Chad GP is able to remember
this particular sentence this particular
sentence because in back end actually it
is using the memory concept it's able to
remember the it is able to remember the
conversation that whatever conversation
is happening over here so here if I will
ask to my chat GPT can you tell me can
you tell me can you tell me the winning
team captain so here I didn't mention
anything and I'm just asking to my chat
GPT can you tell me the winning team
captain so if I will if I will hit the
enter and here guys you can see the
reply
so it is saying okay captain as of my
knowledge and I don't have information
wining team captain uh can you tell me
the winning
team okay let me ask one more time is
saying that uh can you tell me who won
the first Cricket World Cup and here I'm
asking can you tell me
winning
Captain uh winning
team
captain name so if I'm asking to my gp2
so it is saying that uh it seems like
might be a slight
spelling about the okay cap it's a
captain I am writing a wrong spelling
let me correct the spelling first of all
so here uh the spelling will be a
captain just a second let me copy the
correct uh correct spelling and let me
paste it over here and let's see I'm
getting answer or not so here it is
saying information the
tournament okay so it is saying that uh
uh just a second guys what I can do uh
let me delete this chat or let me open
the new chat and let me show you this
particular thing oh yeah just a wait so
it is able to remember the thing uh let
me start from the new one uh first of
all let me delete it don't know why it
is doing like this just a second let me
delete the chat okay now here is what
here is my new chat now here uh let's
start from the beginning so here I'm
asking to my chat GPT can you tell me
who won the first
Cricket World Cup this is a SE uh like
simple question which I'm going to ask
my chat GPT so here uh you can see it is
giving me answer okay no doubt no issue
now here if I'm going to ask my chat GPD
that what will be uh what will be 2 + 2
2 + 2 right so now let's see what I will
be getting over here so here is saying
that 2 + 2 will be four now let me ask
my chat GPT what will be 2 * 5 now here
it is saying that uh the multiplication
will be 10 now I'm asking to my chat GPT
can you tell me can you tell me about
can you tell me who was the winning who
was the captain d a i in captain of a
captain of the winning team now let's
see uh will it be able to answer or
not it's taking time and let's see what
will be the
answer yes it is able to answer now see
so here I asked to my C GPT who won the
first Cricket World Cup so here is my
like answer now I asked to my CH GPT
what is 2 + 2 and the answer is this one
now I asked to my CH GP 2 into 5 so this
is the answer now again I asked to my
chat GPT without giving any sort of an
information regarding this Cricket World
Cup and all and you can see the answer
it is saying that Clive Lord was a
captain uh clyve Lord was a captain of
the West Indies cricket team that was
was the Cricket World Cup in 1975 so
here guys in a back end this chat GPT is
implementing this memory concept now if
you are accessing if you are accessing
your uh if you are accessing llm uh this
GPD and all by using the open AI or
maybe by using the huging phase so how
you can retain the memory because chat
GPT chat GPT is application in backend
uh this GPD model is running getting my
point now if you want to implement a
same thing let's say if you are
accessing the model llm model by using
the open API or maybe by using the Len
Chen basically Len Chen is hitting the
open API only so how you can retain this
particular memory how you can do that so
now let's try to understand that
particular part that particular concept
so if I'm using uh the open API that how
I will be able to retain the memory and
Len chain gives you this particular
facility so by using the memory concept
you can retain the memory like chat GPT
so the problem statement is clear to all
of you please do let me know in the chat
if uh the problem statement is
clear I'm waiting for your reply guys
please do let me
know
what's the purpose of the Len chain so
in the previous class I have clearly
defined the purpose of the Len chain if
you don't know about it so you must
visit the previous class where I have um
I did the detailed discussion about the
Len
chain great so everything is fine
everything is clear now let's uh begin
with the implementation so first of all
guys what I need to do so first of all I
need to import a different different uh
first of all let me import the different
different uh like a uh import a
statement okay so here is my open Ai and
okay it is fine now let me do one thing
over here let me
[Music]
import the same file I already given to
you you can check in a resource section
from there you can download it's a same
file which I'm using over
here so it is for the asent type
uh okay everything is fine now let me
take a prompt template from
here great so here what I'm going to do
here I'm going to write it down the
memory so just a
second yeah so first of all let me write
it on the memory over here
and
memory now let's begin let's start so
here I'm going to import The Prompt
template the first thing which I'm going
to do over here so first of all I will
have to uh create my a client right so
for creating a client actually uh let me
write another the code so here actually
let me import one more thing I'm going
to import llm Chen actually I restarted
my kernel that's why I need to import it
again and here uh let me do one thing so
LM chain I already imported let me
create a client first of all so for
creating a client what I can
do already written a code inside my
file yeah so this is the code for
creating a client so here uh what I'm
going to do guys see here I'm going to
create a
client so this is what this is my client
now open AI key is not defined okay
first of all I will have to import the
open a so from length chain Len
chain do open and here I'm going to
import this open AI now let's run it
again and it is saying open AI is not
there so let me change the spelling of
the
openi I think it is
capital no it is not like that so let me
check with the correct import statement
what is
that
yeah this is
the okay I'm using the length chain just
a wait so by using the Len
chain okay from llm actually we have to
import this open a uh it's my bad so now
it is done yeah it is fine I created a
CLI yep now everything is set so here I
have imported three state M first is
prom template second is llm chain and
third is open AI I restarted my kernel
that's why I uh got a a requirement to
reimport it uh this particular statement
now here I created a client now let's
try to understand the concept of the
memory so first of all guys what I will
have to do I will have to create a
prompt template and I will have to hit
my model right so for that uh what I did
I already written a code so let me uh
keep the prompt template over here so
this is what guys this is my prompt
template I told you that what is the
meaning of the prompt template and how
to create a prompt template each and
everything I have discussed in my
previous classes if you don't know about
it so please go and check with my
previous s so this is what guys tell me
this is my prompt template now here I'm
uh not going to hit my model U like
directly uh instead of that I'm going to
use llm chain I clearly told you in my
previous class that what is llm chain
llm CH LM chain is nothing l l m chain
uh is a like concept where we are going
to connect two components right so what
is the meaning of the chain so inside
chain you will find out that we are
going to connect a multiple component so
here we have llm chain where we are
going to connect a multiple component my
first component is a client uh which is
my object of the open a which I have
created and the second uh the second
component is prompt template let's try
to use llm chain over here and let's see
what I will be getting so for that first
of all I'm going to create a object of
this llm chain now let me create a
object of this llm chain and I can keep
it over here I can keep this particular
object inside this chain variable now
let me pass my llm llm is nothing it's a
client itself because by using this
client only uh we are getting a model we
are getting a model from the open Ai and
by default I think we are using text D
Vinci uh and if you are going to mention
the model parameter you can use your
desired model as well so that is also
possible now over here I'm going to
write down this client and then what I
will do guys so here I will mention my
prom template so let me mention my
prompt template let me write down the
parameter prompt p r o m PT and here let
me copy this name prompt template name
and here I have this prompt template
name so once I will run it so here you
can see we are able to create a chain so
this is what this is my chain now what I
will do I will run uh uh I will I will
like uh I will call the run method and
here I will mention the name so I'm I'm
asking over here what is a good name for
the company that makes so I can uh so
this product actually uh I can I can
give any sort of a product name over
here so let's say here if I'm saying uh
if I'm uh asking to my uh like model so
colorful
colorful colorful uh cup so here I'm
asking to my model colorful cup so if I
will uh run it so here you can see so it
is giving me answer so for if I want to
like uh check that what is the answer
which I'm getting over here so I can
give it to my print statement and let's
see what will be the final answer so
here it is saying holder color cup
Corporation something like that it is
giving me a name so let me call the
strip over here strip will remove
unnecessary thing from here so it is
saying cakes uh Sugarland sprinkle so
this is the name basically which I'm
getting uh if I'm asking this particular
question to my to my model right to my
llm model to my uh GPT model now uh till
here I think everything is fine already
we did uh uh like uh we did it so many
times in our previous classes in our
previous session now let's try to
understand few more thing over here
let's try to understand the memory
concept that how the memory how this
memory is working in terms of this uh
Len chain okay and how we can uh sustain
the memory basically the uh conversation
whatever conversation we are going to do
now here see guys uh I'm going to write
it down uh one more time so let me
create one more prompt over here so
let's say uh there the same prompt uh
same prompt template I have used now
here what I'm going to do um here I'm
going to ask to my uh here I'm going to
ask uh again one thing so let me do one
thing let me again create this chain
over here and I'm going to copy and
paste the same thing and let me run it
so chain do run I'm going to call this
chain. run and instead of this colorful
cup I'm giving a different name so here
I'm giving name let's say drone so
drones I I want to ask a I want to ask a
company name so which make a drones so
here the product name is what the
product name is drones I'm passing the
product name inside this method inside
this run method so chain. run and here
I'm passing this drone let's see what
will be the name so here it is giving me
a name drone X technology so uh it is
giving me a name that that uh don't ask
technology okay so here I can call this
a strip so it will remove the
unnecessary thing uh from the a
beginning so skyron technology so this
is the name basically which is giving to
me and I hope till here everything is
fine everything is clear already we have
learned these many things right now let
me uh explain you the uh like memory
concept so here uh if I'm going to call
one parameter so let me write it down
this chain do memory
so here if I'm going to call this
parameter chain. memory so here I'm not
getting anything here I'm not getting
anything so let's try to see the type of
this chain do memory that what is the
type of this chain do memory so chain do
memory now let me show you the type of
this chain do memory so here you can see
it is giving me a non type means it is
not going to return anything to me
because here we are not going to sustain
any sort of a memory whatever
conversation we are doing to my model
what whatever conversation is happening
right so we are not going to sustain
anything over here we are not going to
sustain anything over here in terms of
the conversation now let's try to
understand how we can do it how we'll be
able to sustain the conversation
whatever conversation we are making uh
like by using the API and whatever
conversation we are making with respect
to that particular model so here for
that we just need to write it down one
parameter so uh first of all let me
write down the heading over here so the
heading uh let me write down the heading
The Heading is nothing heading is
convers conversion buffer memory so here
uh we want to save a memory we want to
save a like conversation memory so here
I return this conversation buffer memory
we have three to four topic inside this
memory so step by step I will try to
explain you each and everything now
first let's try to understand what is
this conversation buffer memory so uh
you can just think about uh this
conversation perform memory uh just like
a memory whatever conversation we are
going to do with respect to our model
right so is going to store all those
thing right it it is going to sustain
all those thing it's going to sustain
the entire memory throughout the
conversation that's it now here what I'm
going to do so here let me uh copy and
paste one more statement and let's see
uh what I have written over here so here
why we have I have written that uh we
can attach memory we can attach memory
to remember on the previous conversation
I just need to uh mention one parameter
the parameter name is what the parameter
name is a memory so I just need to
attach one parameter and we'll be able
to remember all the previous
conversation regarding this model now
how I can do it so here uh let me first
of all let me import this conversation
buffer memory from the lenon itself and
the uh and then I will show you the same
thing by uh from the documentation also
so each and everything I uh pick up from
the doc documentation itself and again I
will go through with the document again
I will go through the documentation and
I will show you the same thing over
there as well so just wait for few
minutes and each and everything uh each
and every part will be clear to all of
you now here uh you can see I'm going to
import this conversation buffer memory
now what I need to do here so this is
the class so I need to create a object
of this class so here I'm going to
create a object of this class and I'm
going to keep uh this object inside the
variable so I've created a variable by
name Memory so this is what this is my
uh like variable where I'm going to keep
a object of this conversation buffer
memory now let me run it so here is what
here is my memory now I just need to
mention this particular parameter inside
my chain that's it and my work will be
done let me show you how so here what
I'm going to do again I'm going to
create a prom template so here is what
here is my prom template as you can see
this is what this is my prom template
now here what I'm going to do here I'm
I'm going to create uh here I'm going to
write it down llm chain so let me write
it down this llm chain and the first
parameter which I need to mention over
here that's going to be a llm and my llm
is nothing it's a client itself so in
the client variable I'm going to keep my
llm so here you can write it down this
CLI c l i n t and here you need to
mention the prompt so here is what here
is my prompt and to this particular
parameter to this prompt parameter you
just need to pass uh this particular
value this prompt template name so once
you will pass this prom template name
and you will what you can do you can
create a object of this Ln chain and
then you can call chain do run getting
my point chain is nothing it's a
collection of
component getting my point yes or no in
a uh like uh in a sequence in a
particular chronology so here you can
see we have llm client prom template now
if I want to retain all the conversation
if I want to retain all the memory which
I'm able to retain in a chat GPT here
you can see so if I'm asking to my chat
GPT can you tell me who won the first
Cricket World Cup so it is answer like
it is generating answer now if I'm
asking to my chat GPD what will be 2 + 2
so here what will be 2 into 5 now again
I'm asking to my chat GPD that can you
tell me who was the camp of the winning
team I'm not giving any such information
in inside my prompt as you can see but
is still it is able to give me an answer
based on a previous conversation so if I
want to do a same thing with my API how
we can do it so that's a thing which I'm
explaining you now let me mention one
parameter over here that's going to be a
memory so m m o r by and here let me
mention me m o r by so once I will run
it so first of all let me uh uh keep all
the thing in a variable variable name is
going to be a chain so here Ive created
a object of this llm chain now here if I
will run so let me run something over
here chain do run so here I'm going to
ask that uh I'm going to ask regarding
the product so what be the good name for
the company that makes a product let's
say I'm asking about the wines so if I
will run it so it is giving me a name so
it is giving me a name it is generating
a name over here now again what I'm
going to do so again uh I'm going to ask
to my uh again I'm going to ask to my
model so here I'm asking to my model so
what would be the good name for the
company that makes let's say here I'm
saying camera so here I'm asking a c
like regarding a camera I just want a
name so it is saying that camera Lum
technology so it is giving me a name it
is suggesting me a name now uh here is
what here is my name now uh let me ask
to something else over here let's say uh
I want a company I want to create a
company so the company related to a
drone so I want a company name which
create a drones so here if I'm saying
that drones now here you can see is
giving me answer drone craft so here I
asked three question to my to my model
by by hitting the API I asked three
question to my model to my LF model now
uh let's see it is able to sustain the
memory or not so now if I will run this
chain. memory now you will be able to
find out yes it is able to retain all
the conversation whatever conversation
is happening because because of what
because of this conversation buffer
memory so whatever conversation we are
doing right whatever previous
conversation is there so each and every
conversation we are able to sustain but
previously we were not able to do it so
here it was was giving me none type here
it was not giving me anything but now
you can see we are able to sustain the
information and if I'm calling chain.
memory it is giving me the entire detail
over here now let's try to understand
let's let's try to like uh uh let's try
to understand a few more thing over here
now here if I will run this chain do
memory chain. memory and here if I will
call this chain do memory. buffer so now
you will find out that this is the
entire conversation now let me uh print
uh let me keep this thing uh in my print
method so I won't get this selection
over here instead of that I will get the
new line because slash and me is what SL
and me is nothing it's a new line now
over here you will find out the entire
conversation that whatever conversation
is happening between me and model so
here human is asking about wines so e is
giving me answer now human is asking
about the camera is giving me answer
human is asking about the drones it is
giving me answ so like this you can draw
uh you can create your prompt template
and you can ask to anything to your
model and you can sustain the entire
memory you can sustain or you can uh
keep the en entire conversation with you
getting my point guys yes or no are you
able to understand it is getting clear
so please do let me know if you are able
to understand this particular concept
I'm waiting for your reply in the chat
please do let me know guys please write
down the chat if you are getting it and
please hit the like button so yeah I
will get some sort of a
motivation I are you able to understand
the concept of the memory how to retain
see here actually we are going to uh
like retain the conversation and uh I
will explain you the further use so uh I
will I will explain you a few more
concept over here just just wait step by
step we'll try to understand each and
everything so don't be in a hurry and
try to understand the entire thing if
you have started something then
definitely I will end it okay so here
people are saying that it is clear and
you are able to they are able to
understand the concept of the memory
that how to sustain the conversation
whatever conversation we are doing all
the previous conversation now let's try
to understand few more thing over here
so uh yes we are able to uh maintain the
previous conversation by using this
conversation buffer memory we just
created a object and we are just going
to keep it over here in our chain that's
it now guys here let me show you one
more thing so here here what I'm going
to do so here uh I'm going to introduce
you with the New Concept that's going to
be a conversation chain now let's try to
understand what is this conversation
chain each and everything we'll try to
understand by using this conversation
chain so here uh I'm saying that here
I'm going to uh like write it down some
sort of a statement and the statement is
something like this so here uh let me
mark down it and let me show you so
conversation buffer memory goes growing
endlessly means uh whatever conversation
you are doing uh so you will be able to
sustain all the conversation by using
conversation buffer memory No Doubt with
that but just remember last five
conversation chain or if you want to
remember just last 10 to 20 conversation
chain in that case what I can
do what should I do over here so here L
chain has given you few more method now
let's try to understand regarding uh
let's try to understand those particular
method that what is the use of this
conversation chain and we have one more
me method now let me uh give you that
particular method also try to understand
about it so here is my second method see
each and everything I kept it somewhere
in my notepad I'm just going to copy and
paste so try to understand please
because I'm doing it uh because I want
to save my time and uh in a short uh
amount of time I want to deliver uh like
uh more and more thing so here you can
see uh there is one more concept that is
conversation buffer window memory so
there is two concept which we need to
understand now here first let's try to
understand this conversation chain that
what is the meaning of it so here uh
what I'm going to say that uh let me
keep it in a single line and if I uh if
just remember let's just remember 10 to
15 convers and that would be great now
what I can do here I can write down some
sort of a code regarding this
conversation chain so first of all guys
what I need to do here first of all I
need to import it so let me import this
conversation chain over here so from uh
the link chain itself from the link
chain do chains I am going to import
this conversation chain now let me run
it and yes we are able to do it now here
what I'm going to do I'm going to create
object of this conversation chain now if
you look into the if you look into the
object so here I'm going to keep a
couple of thing here I'm going to write
down a couple of things so here the
first thing see uh this is what this is
the object this is the object and inside
this object I'm going to mention few
parameter the parameter nothing here I'm
just is going to mention this model LM
model and here I mention open a I can
write it down the client directly or
else I can write it down like this open
a and here is my open a key and this is
the temperature you already know what is
the temperature in the previous session
in my uh day two actually I have uh
explained you the concept of the I have
explained the concept of this
temperature what is the meaning of the
temperature and the value you will find
out of this temperature between 0 to 2
if you are keeping it zero so you will
get a straightforward answer but you
have like increasing the value of this
temperature so it's going to be this
model is going to be a more creative it
will give you the creative answer so
here you can U maintain the temperature
of the answer whatever answer basically
you want whatever output basically you
want you can maintain a temperature you
can maintain the creativity of that
particular answer now here uh to this
particular method to this conversation
chain I'm just going to pass this llm
and here is what here is my object open
Ai and there's couple of parameter which
uh with that you are already familiar
now let me run it so let me create a
object of this conversation chain so
here I created object of this
conversation chain and the uh object
name is what the object name is convo
now I just need to run something over
here so uh here what basically what I'm
going to do here I'm going to write down
convo convo do prompt so here if I will
write convo do prompt so you will find
out that this is nothing it is giving me
a prompt template so here we have a
input variable which is history and
input template so it is a there is a
template the following is a friendly
conversation between a human and AI the
AI is a tative uh provides lots of a
specific detail from its context if AI
does not know the answer to the question
it truthfully say it does not know so
here uh they have written by one by
default message one by default prompt
actually now let's try to see uh
something else over here so here I'm
going to write down con. prom. templates
now uh let me extract this template and
here you will see that uh here basically
we have a template the same message
which I was trying to read from there
from here itself so now you can see the
same message over here now if you will
write it on the print so here you will
get the clear cut message uh without the
selection and all so just write down
inside the print so this is the uh thing
uh this is the message basically which
I'm getting it's a by default message uh
which I'm getting if I'm calling this
con. prompt so here in the template it's
a by default message now uh now let's
try to understand that what is the use
of this uh convo what is the use of this
particular object now here what I'm
going to do here I'm going to ask the
same question to my chat GPD uh to my
GPD model now here I'm saying that convo
convo do run and here I'm asking to my
uh model uh who won the first Cricket
World Cup who won the first Cricket
World Cup who won the first Cricket
World Cup this is the question now if
I'm going to run it so here you will
find out it is giving me answer that the
first Cricket World Cup won by the
Western be in 1975 they beat Australia
by 179 in the final so this is the
information which I'm getting from the
from my model now here what I'm going to
do here I'm going to run uh convo convo
do run now here I'm asking to my model
that uh can you tell me can you tell me
uh can you tell me how
much will be 5 + 5 so it's a simple
question which I'm asking to my model
now let's see the answer the answer is
10 now let's try to ask one more
question over here so let's try to ask
one more question to my uh model so here
what I'm going to do here I'm asking con
can you tell me how much will be 5 * 5
so that's a question or let me keep
something else over here let's say 5 + 1
and here and this is the expression this
is the mathematical explation which I'm
passing now let's see what will be the
answer so it is able to answer me that
the answer is 30 now let's try to ask uh
uh the question to my model that uh who
was the captain of the winning team the
same question which I was asking to my
chat GPT and it was able to answer now
let's see uh will it be able to answer
the same question or not over here if
I'm hitting my API let's see now so here
what I'm going to do so here I'm going
to uh copy it conversion uh convo do run
and I'm going to ask the question the
question is nothing the question is uh
very simple so who was the captain who
was the captain of the
winning team so I didn't give any sort
of information what winning team which
winning team I just like going I'm just
going to follow the conversation now if
I will hit the enter so here you will
find out it is able to give me a reply
the captain of the winning team in the
first Cricket World Cup was the live lck
so it is able to sustain it is able to
sustain the conversation now how we can
do it by using this conversation chain
so first we have understood that if you
want to get the if you if you want to
get all the previous conversation so you
can get it you just need to mention the
memory parameter over here if you're not
going to do it so in that case it will
give you the none but if you're going to
mention it conversation buffer memory so
it will be able to retain all the
previous conversation
now here we are talking about this
conversation chain so by using this
conversation chain I will be able to
retain the I will be able to retain the
tell me I will be able to retain the
memory and uh yes uh like you can ask
anything let's try to uh again check
with a different uh like uh let's try to
check again with a different prompt so
here I'm uh saying to my model
so can you divide can you divide
those uh can you
divide uh the
number numbers and can you give me
answer can you give me a final answer so
here I'm asking through my model that
can you divide the number whatever
number basically is using before
actually it is using so can you divide
those particular number and can you give
me the final answer now let's see what
what I will be getting over here so it
is giving me the five okay so it is
giving me a five uh which uh number is
going to divide I uh so the answer is
five which number it is going to divide
I think uh 5 is six 5 / by uh five if it
is saying like that maybe is going to
divide this uh 30 by six so that's why
I'm getting this five but yeah it is
able to retain the memory it is able to
retain the memory and it is working so
uh I think uh you got to know that how
to uh get all the previous conversation
that is the first thing and how to
retain the memory if you are using the
API now guys see we have one more method
over here the method name is what
conversation buffer window memory now
what's the meaning of that first of all
let me show you first of all let me
write it on the code actually and then I
will explain you the meaning of this
conversation buffer window memory so uh
tell me guys still here everything is
fine everything is clear that whatever
thing my chat GPD is doing I able ble to
do the same thing by using this Len
chain this Len chain is too much
powerful if you if I'm using my API so
in that case how I can sustain the
conversation how I can remember all
those thing so here is a way you just
need to import the classes and all in a
back end already the code has been
written by someone you just you are just
going to use it and uh definitely you
can uh create a application in that you
can use the same concept got it so if
this part is getting clear then and
please do let me know in the
chat no buffer this is a different
object now we are just going to remember
all the previous conversation here see
we are able to retain the previous
conversation this one is giving me all
the conversation but here actually by
using this conversation chain what I'm
doing tell me so here by using this one
I'm able to do like same this chat
GPT okay okay so where we are able to
retain the uh like where we are able to
retain the memory so here I was asking
this thing to my CH to my model to my
API and then I I written this particular
um like me I I written this particular
prompt and then again I asked this
question related to this one and it is
able to give me
answer so that's a difference try to
understand try to observe it here
conversation buffer memory this a
different method by sustaining the
conversation here you can see and
conversation chain is doing a same
Behavior Uh like which we are able to
achieve in a chat GPT so somewhere in a
in the chat GPT application also they
implemented the same concept for
sustaining the memory that's why it is
able to do it we don't know uh uh What
uh what type of code they have written a
backend if you want to check you can
check it you can go through with the Len
chain so here uh you can search a len
chain l a n
g and uh just check with the Lenin
GitHub so here you will get the source
code code of the Lang chain and now you
can uh check that what code they have
written regarding a different different
thing so here go inside the cookbook and
there is like all the code regarding a
different different thing and just try
to read the lowlevel code that what
all what Logics and all they are going
to uh they have written over here
actually so you just need to go through
with the Len and uh GitHub and there
you'll find out all the codes and
all tell me guys now this part is
getting clear to all of you please or do
let me know in the chat if the part is
getting if this part is if this part is
getting clear or not this uh
conversation chain and this uh
conversation buffer memory now let's try
to understand this conversation buffer
window memory but that what is a meaning
of it and then again I will uh I will
try to revise it and I will uh I will be
showing you the same thing by using the
uh documentation so all the thing uh
they have mentioned over there already
uh each and every theoretical is stuff
then uh I will try to explain you that
uh from there itself now here we are
talking about this conversation buffer
window memory then what is a use of this
particular method now let's try to
understand it so here the first thing
which I have to do so first of all I
have to create a object of it now uh
here let me create a object so I'm going
to import it conversation buffer window
memory now if I'm going to run it so yes
I'm able to run it and I'm able to uh
I'm able to like import this particular
statement so here I'm going to create a
object of it so this is what this is my
like object and here I'm going to write
down my object name is nothing it's a
memory now inside this uh uh like object
actually uh there is one parameter so
let me write it on the parameter name so
the parameter name will be a key right
which I represent with which they
represent with K so here I I'm going to
pass one parameter the parameter name is
what the parameter name is K now here I
can pass any sort of a value regarding
this K 1 2 3 4 5 6 7 8 9 10 11 12
whatever now what is the meaning of that
so first of all let me write down that
and let me run it in front of you and
then I will try to explain you this
thing so here I'm going to write it down
K is equal to 1 now here I created a
object so here I've created a memory now
what I'm going to do I'm going to create
a conversation chain again so the
conversation chain which I uh uh which I
imported over here now let me paste it
over here this conversation chain
conversation chain and now what I need
to do I I'm just going to be mention one
parameter over here so I'm going to
mention memory parameter inside this
conversation chain see this is my main U
this is my main class this conversation
chain which I'm using over here though
uh along with that you'll find out two
more so conversation buffer window
memory and conversation uh conversation
buffer memory so buffer window memory
what is the meaning of that after this
uh particular example you will get to
know by yourself on only so here I'm
going to keep it and let me uh write it
on this memory over here and here what
I'm going to do here I'm going to create
a object so convo object so this is what
this is my convo object now uh what I'm
going to do I'm going to run it so here
I'm going to run the same thing so now
let me uh copy it and let me paste it
over here so let me paste it over here
uh this particular thing uh this
particular sentence and here let's see
what will be the answer so here if I'm
going to run it so you can see that it
is saying that the first Cricket World
Cup uh was held in 1975 and it w won by
the wested that is perfectly fine now
again I'm going to ask to my model that
convo. run convo do run and here I'm
asking that what will be 5 + 5 now it is
saying that 5 + 5 will be 10 now I'm
asking to my uh now I'm asking to my
model that who was the captain of the
winning team so if I'm uh giving this
particular code question now let's see
what will be the answer so it is saying
that I sorry I don't know I'm sorry I
don't know because see uh if I didn't
mention anything it is able to uh by
default actually see there is a uh
memory parameter see in a you can create
this conversation buffer memory and if
you are going to create a chain now if
you're going to create a chain now there
you can mention this memory and you can
track the entire conversation that is
perfectly fine now here uh if I want a
same behavior like this chat GPT for
that there is a main method conversation
chain there's a main method so here
conver here I created a object of the
conversation chain and here is what here
I'm going to call this run method now
you can see it is able to sustain the
memory it is able to sustain the memory
now here you will find out one more
thing uh like one more class
conversation buffer window memory now
here Ive created a object of this
conversation buffer buffer window memory
and I passed the key value key equal to
1 so key equal to 1 means what is the
meaning of this key equal to 1 so it is
just able to sustain or it is just able
to remember all the thing uh like till
the one prompt till the first prompt
only after that it won't be able to
remember anything if I'm writing over
here K is equal to 4 now in that case
just see the effect so here if I'm going
to create K is equal to 4 so see uh
convo is there now I'm going to run it
okay great now I'm going to ask to my
model okay
now see see now it is giving me answer
so I can Define the window size I can
Define the number of prompt here if I'm
saying uh K is equal to 2 so now let's
see what it is giving to me so here I'm
saying K is equal to 2 that's great this
one is fine this one is fine now it is
saying the first Cricket World Cup was
held in 1975 now it will stop over here
now if I'm going to ask to my uh like
this one so here it is giving me answer
because now I'm going to sustain this
both both conversation see K is equal to
1 means what let me tell you that K is
equal to 1 means what see k equal to 1
means what this one only the first one k
is equal to 2 means what this both this
both K is equal to 2 so if I'm writing
over here K is equal to 2 so it is going
through with this particular sentence
and it's going through with this
particular sentence and if it is seeing
this sentence now so it is able to
remember it is able to see this one now
this one and this one so in that case it
a it is able to generate answer but if I
mention k equ Al to one so after this
one is not able to remember anything
that's the last one okay so I can select
the window size over here you can select
the window size if you're not going to
select it will be tracking the entire
conversation by default it will be
tracking the entire conversation now
let's try to see the same thing by using
uh like on top of the documentation also
so they have mentioned the same thing so
let me open the Len chain documentation
l n Len chain documentation and over
here uh let me open it first of all so
Lin memory where you will find out go
inside more and here is a memory so
let's try to understand uh about the
memory that uh what all typee of
memories we have and what all thing
basically they have written over here
let's try to understand that thing so
most llm application have a
conversational interface so an essential
component of the conversation is begin a
it's conversation uh is being able to
refer to information introduced earlier
in the conversation means uh whatever
conversation we are making so it should
be like uh like it should have a
connectivity in between so at bare
minimum a conversational system should
be able to access some window of past
message directly so a comp more complex
system will need to have a world model
that is constantly updating which allow
us to do thing like Mentor information
about the entities and their
relationship so here they have given you
the complete detail now building memory
into a system how how state is stored
how state is queried so there are like
some sort of a theory they have given
over here now here they have given that
this get is started so let's try to read
it from here so let's look at what
memory actually looks like in L chain
here we will cover the basics of
interacting with the arbit memory class
so here the same memory class uh which
we were using so here I have created a
like object of the memory class now here
I'm asking so memory. chat. memory add
user and what is up so something like
that uh there calling basically this
particular method over here which is
there inside this conversational buffer
memory itself now what variable get
written from memory so here if you will
load the memory you are getting this
particular thing the same thing I was
able to get by calling this parameter
the parameter which I was calling chain.
memory actually I'm not directly using
this thing I'm not directly using a
method from this particular class from
this conversation buffer memory instead
of that what I'm doing instead of that
I've have created a object of this llm
chain and here I'm passing my all the
component I'm making a chain okay I'm
stacking all the component and then
basically I'm calling this chain. memory
and I'm getting here I'm getting this
particular output and the same output
you can see over here as well you you
you are getting the same output over
here as well right so yes I'm able to
get the same output by using that
particular parameter chain. memory.
buffer or chain. memory now here uh we
have other one also so like you can give
the key and all you can explore about it
now there are few more parameter like
return return message and all each and
everything you will find out over here
now end to an example so they have given
you the endend example over here so open
a prompt
template conversation buffer memory now
see I'm using the same thing I'm using a
same thing over here I'm using the llm
chain I'm I'm running the same example
in my jupyter notebook so you can go
through with the documentation and you
can copy from there also and you can
test it they have given you like a small
small code is snipp it just for the
testing just for the learning and
directly you can integrate this thing
inside your application got it now here
uh you can see using a chat model so one
more example they have given you and
then next step inside that you will find
out few more thing uh memory in llm
chain memory types okay now customized
conversation custom memory multi uh
multiple memory classes there are so
many thing you will find out so if
you'll go inside this memory type so
just just see uh with the memory types
and and then conversation buffer
conversation buffer the same thing um
the entire code you will find out then
conversation buffer window now let's see
what is the meaning of the conversation
buffer window so conversation buffer
window memory keep a list of interaction
of the conversation over the time it
only uses the K interaction the number
of interaction so this can be useful for
keeping a sliding window of of most
recent interaction so the buffer does
not go too large so if we are talking
about buffer so it is having a complete
uh like a complete uh conversation
whatever conversation we are doing but
if you want to keep it short so you can
mention the K over there so here I I was
doing that so here if I'm writing K is
equal to 1 so here if I'm writing K is
equal to 1 in that case is not able to
remember anything so simply it is saying
that I don't know about it it it it is
just going to stop over here itself so
this one and this one now uh if I'm
going to ask this uh particular thing so
it is saying I don't know about it
because after this one is not going to
track anything K is equal to 1 means
what just one sentence means it is not
going to remember anything uh over here
now if I'm going to write it down over K
is equal to 2 in that case it will be
able to sustain something right by using
this two particular prompt and if I'm
going to ask something after this one so
it is saying that yes now it is knowing
okay now it knows about it so here uh if
you're not mentioning any sort of a
window is is going to keep a track for
the ENT entire conversation but if you
are going to mention a window parameter
over here in that case it will be
restricted each and everything they have
mention inside the documentation itself
try to read it from here got it now how
to use a chain means how to like uh uh
like how to uh sustain a memory and all
means if you're going to make any sort
of a conversation and all so this
conversation buffer memory conversation
buffer window memory is just for sustain
the the memory basically the
conversation but actual conversation how
you make the actual conversation which
we are doing over here actually here so
by using this particular class
conversation chain class this is the
main class and this two class for
sustaining a conversation this is for
the entire conversation and this is just
for the limited window means a
customized window whatever number you
are going to write it down till that
particular window now it is clear what
is a memory yes or no please do let me
know in the chat if uh this part is
getting clear to all of you
are you able to get it guys uh are you
able to understand the concept of the
memory how to do that how to make a
conversation how to import the different
different import statement how to like
uh how to go through the
documentation yes or no please do let me
know in the chat if you're getting it
I'm waiting for your
reply
clear clear clear great
uh if you have any doubt you can ask me
in the chat and then I will start with
the next
concept what is the limit of of memory
Li limit you can Define now you can def
Define the limit according to your
problem
statement you don't want to be create uh
to Long buffer so in that case you can
uh you can uh like uh mention this K
parameter it's up to you it's up like uh
up to your requirement up like how much
what uh how much uh like your
configuration and all what all resources
you are using according to that you can
decide where the memory concept used in
a real uh life exam application
so here what I explained tell me so it
is not a real time explain this chat
GPT so this chat GPT is a real time
application now that that that's why
first I have explained this one only so
let's say if you are making a
conversation to the
chatbot if you're making a conversation
to the chatbot and if you ask to the
chatbot let's say you visited a website
any website and let's say I your own
website side there you are asking uh
let's say we have a chatboard on in own
website you are asking to the chatboard
okay what is the price of this
particular course then U like let's say
you are getting some sort of a prize and
then you are asking something else who
was a mentor and all now again you are
asking a question related to that course
itself that what all thing you covered
in this course now it is saying that
which course I don't know about any
course even though you mention the name
over there gener course but it is saying
no I don't know about it because is not
able to S it is not sustaining the
conversation the conversation is not in
buffer so like there it can go and it
can like read each and everything the
model actually it is not able to sustain
the context is able to sustain a context
in terms of the a sentence but not in
terms of the
conversation so that's a real time
example so that's why I have explained
you this chat GPT at the first place and
then I back to this uh I uh went to this
uh like python implementation by us
using like if we are implementing the
same thing like by using the API by
using the openi how we can achieve this
particular thing how we can achieve the
memory and all how we can sustain the
memory so it's all about that only
please try to run it by yourself please
revise it you will be getting and one
more thing uh before implementing with
uh before implementing any sort of a
concept from the Lan chain try to go
through with the documentation theyve
given you each and everything along with
the theory so first read the theory and
read the uh like uh code snipp it and
all whatever they have given you and
then you can uh run it inside your
system and then uh basically you can run
my file as well whatever like code and
all I'm writing it don't worry I give
you I will give you the each and
everything in a resource section so from
there itself you can download
it okay so if this thing is clear do
please do let me know because I'm going
to start with a new thing uh with a new
topic and now let me create a new
notebook over here
I think this Lang chain is clear in the
Lang chain I have explained you five to
six concept which is going to be a very
much important once uh we'll start with
the project you will get to know the
importance of this thing this topic and
inside this particular top inside this
particular notebook I have kept
everything related to this open API and
this L chain so here let me rename it so
test open AI
API test open AI API and Link Chain so
everything you will find out regarding
this openi API and Lenin inside this
particular notebook guys you just need
to visit this notebook everything I have
written over here along with the code so
let's start with a new topic and the new
topic is going to be a uh hugging face
hugging face with Len chain uh hugging
face with Len
chain hugging face face is
fce so can we start now have you open
the new
notebook yes correct aishu uh your
understanding is
correct tell me guys uh have you opened
the new jer notebook so uh I can start
with the thing I can start with a new
topic hugging Faith with Lin and after
this one after explaining you this thing
I will move to the uh like I will move
to the project I will I start with the
project from Monday onwards and first I
will explain you the use case and then I
will code in front of you only first I
will explain the use case and the
project setup and all and then we'll
start with the implementation of that so
let's start with the hugging phase with
lench it's going to be a new thing new
concept so let's understand uh this uh
particular thing so first of all guys
what you need to do so first of all you
need to log into the hugging face
hugging face Hub so just search in your
Google hugging face and you will get a
very first website this is the website
of the hugging phas sdps do hugging U
hugging face.com so uh try to visit to
this particular website and uh if you
didn't uh sign up so first do the sign
up and then sign in and after that you
will be able to create your profile so
first you need to do sign up and then do
the sign in so automatically you will
get your profile and this is what this
is my profile I already did a sign up so
no need to do anything you can do the
sign up by using the Google s well by
using your Gmail ID as well so just try
to sign up first and try to like create
your profile and then sign in
automatically you'll find out your
profile over here so after getting your
profile guys see uh here they have uh
see this is the uh like uh homepage now
just click on this model so once you
will click on the model actually you
will find out so here it is saying no re
uh activity display here we have a data
set spaces papers papers collection
Community there are so many thing right
so if I'm following something so it will
be visible over here now just click over
here this one this model so what I can
do I can click on this model so I will
be getting all the model these are these
are the model basically so just click on
this all so here basically you will find
out all the model and here actually it
is showing you the trending model what
trending model is there over here now uh
directly you can search about this model
so what you can do I'm not able to open
let me check with this models yes guys
so over here you can see these are these
all are the model which is there over
the hugging phase now you can uh short
it uh which is a trending one which is a
most download one which is a recently
one recently updated most uh liked llm
so there you will find out like all the
llms and all now let's check with the
most like so here I'm going to short all
the model with this most like okay so
stable diffusion is is a model which is
the most liked one now you will find out
Bloom is there uh okay so here orange
mix is there a control net is there open
journey is there chat glm is there star
coder so there are so many model even
Lama 2 is also there this one Dolly V2
it's a model from the uh data brakes
this llama 2 it's a model of the meta
it's a model from The Meta now stable
diffusion is also there stability AI
there's the organization name stability
Ai and here you will find the table
diffusion and here you can see the
number of downloads as well so there you
will find out the number of download now
see llama this llama 2 how many times it
has been downloaded
947k around 1 million now here you will
find out gpt2 gpt2 is also there it has
been downloaded 17 million times 170
million download is there okay so okay I
think it's not a download it may be a
size
uh let me check with the download so
most
downloaded so here now I'm going to
check with the most downloaded I think
it's a download only it's not a size
actually so 73.3 million and distal GPD
is also there robot is there there are
so many model you will find out and you
can see the number 4 lakh 27,000 so if
you are talking about the open API so
you are restricted with the open API let
me show you that what all model is there
so if you search over the open a so just
open the opena website and check with
the models just do the login First and
try to uh like click on this API and go
inside this model now here you will find
out all the model this all the model has
been developed by the openi itself and
you will find out a different different
variants of this model like this chat
GPT there are so many variant of this
Chad GPT but if we are talking about
this hugging face Hub so it's a open
source repository anyone can contribute
over over here so whoever has created
their llm so they have uploaded to this
hugging face Hub now you can see the
number of model you can see the
different different uh like a task over
here that what you want to do feature
extraction text to image or text to text
image to video text to video whatever
you want to do you will find it find it
out over here let's say what I want to
do let's say I want to perform text to
text generation so if I will click on
this one so you will find out so you
will find out all the model from text to
text generation you can perform text to
text Generation by using this particular
model let's say you want to perform a
conversation so for the conversation
basically there is a different model
dialog GPD is there and go is there and
you will find out other model as well so
from a different different organization
you you can go through with it and you
can check got it yes or no so this part
is getting clear to all of you you can
check with the training you can check
with the training and you will find out
like which is a trending one now let's
say I want to do a text to text
generation so here I'm going to use this
particular model FL T5 base so I'm going
to use this particular model now how I
can do that what will be the procedure
if I want to use this open source model
without any charges so here I'm not
going to pay anything as of now for this
particular model so how I can use it how
I can like uh perform text to text
Generation by using this particular
model now let me tell you that so first
of all what you need to do so just click
on your profile and here click on the
setting so once you will click on the
like this setting so here you will find
out the token access token so click on
this access token so already I have
created a token over here so you can
click on the new token you can click on
the the create token and you will be
able to create a new token over here now
this is going to be a API key this is
going to be a token you can delete it
you can recreate it whatever you want
you can do it and here uh you will find
out access token probability
authenticated your identity to the
hugging face Hub allowing application to
perform specific acction specify the
spoke of permission read write and admit
so here you can visit the documentation
and you can read more about it so first
of all guys you need to sign up and then
you need to log in and after that you
will be able to create your profile and
then you can go inside your profile and
go inside the setting and there you will
find out the token this access token
this particular option and try to create
the new token after creating a new token
what you need to do you just need to
copy this token and uh I will tell you
step by step what you need to do so from
scratch only I'll be writing all the
code so first of all see before starting
with the hugging face you need to
install some Library some other
libraries as well so let me give you the
name of all those Library I I like kept
it somewhere I'm just going to copy and
paste all the thing now here are the
first thing first Library which I'm
going to be install that's going to be
hugging face Hub the second one is a
Transformer and the third one is
accelerate and bit sendy bytes so here
this is to the this two is not a
mandatory one but yeah you need you can
install it because I was getting some
sort of a error and for that only I have
used this I have like installed this
libraries so if uh U like uh so yes
please uh like download uh this thing
this particular uh like packages
accelerate and bit sendy by so you won't
get any sort of error throughout this
implementation but this two is a
mandatory one the first one is a hugging
ph up and the second one is a
Transformer so you cannot SK skip this
two thing and L chain should be there
inside your virtual environment because
this hugging phase actually we are going
to access by using the Len chain only by
using the Len chain only we are going to
access the this hugging phase so I
already did it I already installed it
you just need to run it and uh if I
already installed then it will uh it
will give me the message that
requirement is already satisfied so here
you can see it is giving me that
requirement is already already satisfi
got it now guys what is the next thing
which I need to do so step by step I
have written each and everything I'm
going to write it down over here as well
so the step first what you need to do so
in the step first you need to uh
download all the required Library so let
me write it down over here the step
First Step first is
nothing
download all the required Library
now let me keep it over here and see we
are able to download now in the step two
what I'm going to do here in the step
two I'm going to import it so let me
import all the required Library so I
have written it over here let me import
it uh over here so this is the library
which I have imported so the first one
is H prompt template hugging phase from
the lenon itself of okay so I'm going to
import this hugging face Hub and here is
what here I'm having the llm chain I'm
using this hugging face with Len chain
I'm using this hugging phase with this L
chain try to remember this thing guys
okay so if you are implementing it by
yourself please try to remember that we
are using this hugging phase by using
this Len chain I told you this H Len
chain is a wrapper on a different
different API not even op open AI we can
access many API by using this Len chain
many open source model and all it has
been designed in such a way now here uh
I have imported this thing now what I
need to do guys so here I'm going to
write it down the Third thing so the
third one is what you need to uh like
set the environment variable so for
setting up the environment variable let
me tell you what is a step so here is a
like code basically which you need to
run so let me copy and paste each and
everything I have written uh somewhere
so I'm just going to copy and paste the
small small lines and all now you need
to uh you need to set the environment
variable and here first of all you need
to import this opening system so import
OS os. environment and here is what here
is your hugging phase API token and set
the environment variable set the
environment variable by using this
particular uh like a command now if I
will run it so here I'm able to set the
uh like hugging fish token okay this is
my variable name and this is my value
value of the variable now from where I
got this particular value so I got this
value from here itself from the token
itself so just try to click on this
access token and you will get this value
you will get the value of the token got
it yes or no now here guys just click on
this hugging face and here I seted this
token I set this token and this is the
variable and this is the value now what
is the fourth thing which I need to do
so here let me write it down uh this
particular thing so step by step I have
written each and everything now the next
thing which I'm going to do over here
I'm going to do text to text generation
I'm going to do text to text generation
I'm using sequence to sequence model
this Transformer is what it's a sequence
to sequence model now if we are talking
about the uh different different llm
actually as a base archit Ure it is
using the same Transformer architecture
right so either you can say sequence to
sequence model encoder decoder model
anything anything will be fine for the
Transformer also now I want to do a text
to text generation so I shown you over
here itself in the hugging face model so
let me show you where it is so once I
will click on this model and here let's
say text to text generation I want to do
text to text generation so this is a
model this a flan T5 base it's a model
from the Google side it's a Google model
flan T5 base you can read uh everything
about this uh T5 model for what this has
been trained what uh which data they
have used what is a model size 2848
million parameters is the it is having
like 248 million parameter and here the
number of here you can see the number of
downloads here you can see the table of
content each and everything basically
they have defined they have written over
here regarding this particular model and
this is a Google model and yes you can
uh check about it you can use use it
actually uh how to use it uh let me tell
you that but yeah you can check about it
uh just go through the hugging face Hub
hugging face model and click on this
model click on this text to Tex
generation and you here you will get
this FL T5 base now guys what I need to
do what will be the next thing so the
first of all I need to Define my prompt
and here what I'm going to do guys here
I'm going to Define my prompt so let me
copy The Prompt and here is what guys
here is my prompt this is what this is
my prompt now here I'm going to uh like
Define the chain so let me create a
chain over here now inside the chain
just just try to focus guys what I'm
going to do over here so here guys let
me remove this max length I'm not going
to write it down as of now so initially
like uh not initially in my previous
example just look into the chain uh what
I was doing over
there so if you look into the chain
there I was writing there I was defining
the model from the open a API so let me
show you uh let me show you the chain
prom template agent and here we have a
chain so where is a chain where is a
chain where is a chain this is a chain
now see prom template is there chain and
here I was I was defining a model from
the opena itself what what I was doing
guys tell me I was defining a model from
the open itself now instead of the open
now instead of the open now I'm using
the hugging phas so what I did I created
a object of this hugging face Hub and I
given the repo ID means uh this is the
ID of the model and here is a argument
that U like I need to set the
temperature and all so in this
particular format let me take it in a
different uh let me take it in a
different cell let me show you so here
I'm going to copy it and let me paste it
over here so what is happening just see
what is happening let me take it as a
command so this is the code which I'm
running see this is the code so here now
I'm using now I am going to access the
llm okay which llm this Google FL T5
large now instead of the openi I'm going
to use this particular llm FL T5 large
and this is the uh this is hugging pH
actually which we already imported from
the lenen itself this is the one and
before that actually you need to install
this hugging phase so what you need to
do guys tell me you need to install this
hugging phase pip install hugging phase
otherwise you might face issues so here
uh you have you are using this
particular model this is some sort of
argument uh which you need to mention
now let's try to create a chain and here
the same thing you need to pass the
prompt only now see the power of the
length chain what it is able to do now
uh instead of the hugging open AI I'm
able to connect with the hugging face
also like likewise we will be able to
connect with many apis just check with
the documentation uh so now here you can
see we are able to create a object I'm
getting some sort of a warning you can
ignore it because just a uh it's not an
error actually it's a dependency warning
that uh don't use this version that
version what whatever now here I have
created a chain now what was my prompt
so here I'm saying what is a good name
for the company that make a product
whatever like uh regarding whatever
product I can ask over here so here I'm
saying that chain do run the same thing
I'm going to ask over here chain dot run
now here uh let's say I'm going to ask
uh which product I want so I want uh
let's say mic or I want camera again so
if I'm asking regarding the camera so
let's see so here it is giving me answer
uh Nikon what is a good company name for
a uh what is a good name for a company
uh that makes product so it is giving me
a neon regarding this camera Let's uh
let ask to the different uh uh product
let's say watch so here let's see it is
giving it Tata now let's see uh here if
I'm asking colorful cloths colorful
cloths so here you will see that it is
giving me a DE
so different different name I'm getting
in a similar way uh which I was getting
by using this open API now instead of
the open API I'm using this flan T5
large model you can use any sort of a
model any other model as well there are
like lots of model which you will find
out regarding this text to text
generation you can use this model also
Mard you just need to mention the ID
Mard this is the basically ID just open
it and just copy it from here just copy
it and keep it over here like uh keep it
like this let let me show you that so
here is your model name and what you can
do just copy this hugging pH from here
uh this the complete uh sentence and
just change the name just change the
name of the model just copy it and paste
it over here that's it so just copy it
and paste it over here and you'll find
out this Facebook ambot large 50 now you
can use this particular model if you
want few more a few creativity over here
you can uh pass the temperature M uh
like temperature uh value 1.5 let's say
so so this is what this is a model from
the hugging face and now this time you
are using a different model so the model
name is what Facebook MB large 15 so
like this you can access a different
different model by using the length
chain now what you can do you can create
a one more chain so here I'm going to
copy the same thing now let me change
the envir variable name there's going to
be a chain two and here what I'm going
to do I'm going to copy this hugging
face Hub so from here I'm going to copy
this hugging face Hub and let me paste
it over here so this is what this is my
hugging face Hub this is my repo this is
my model here I'm setting the
temperature and this is what this is my
prompt now if I'm going to run it so yes
I'm able to create a object now here
what you can do here you can call the
method run so run and here you can ask
anything so let's say here I'm asking uh
which product so you can ask uh a mobile
so here let's say regarding any sort of
a product you can ask so it is running
so what is the good name of the company
that makes mobile uh it is saying that
uh it is giving me a prompt only over
here I think I need to follow something
else uh chain do run let's ask regarding
the same thing colorful cloths and let's
see what will be the
answer it is giving me a prompt only I
think in between I need to run something
over here that's
why so Transformer this is a pipeline h
okay
tokenizer I think it is not giving me a
correct answer what so so prompt is fine
I'm passing a same prompt and this is
the
prompt now let's say I'm saying zero
let's set the different value of the
temperature or
05 and see what I am getting over here
uh chain
two what is a good company that makes a
colorful Clause it's not giving me
answer instead of that it's giving me a
uh like a complete prompt
itself so llm hugging face and M large
50 model is what there is a parameter
okay no issue I will check with that if
I need to mention something over here
but that's a way maybe it is not able to
uh like predict correctly whatever I'm
asking but yeah it is giving me answer
this flan T5 large model and even the CH
GPD the GPD uh model also from the open
AI but it is giving me something else it
is running but uh I'm getting other
answers or other answer over here not
related to our related to our prompt I'm
asking something El it is giving me the
complete prompt over here okay so this
is fine now tell me guys how to use any
open source model did you get it please
do let me know in the chat if you got
this particular part that how to use a
different uh how to use any open source
model from the hugging
phase
because it is not a rule-based system
now if I'm again running a query so it
is not giving a same name because it's a
AI based system again and again if you
asked to the chat GP now it will do the
same thing all right it won't repeat the
thing it won't repeat the thing based on
your uh like query it will give you the
different different suggestions and all
so that's why it is giving you the
different
name tell me guys fast uh it is free
actually this hugging pH uh like token
is free you can read more about it uh
just go through the documentation there
is some sort of charges and all U okay
so but as of now it is free uh means uh
like up to some sort of a tokens and
regarding some sort of models it is free
okay so here guys I think this hugging
face part is clear to all of you please
do let me know in the chat if this part
is
clear yes make question answer board
will create in the next class first of
all let let me explain you that how to
use any uh open source uh model so here
I'm using this open source model Google
FL T5
large tell me guys fast uh so this part
is getting clear to all of you if it is
getting clear then please do let me know
in the chat I'm expecting yes or no in
the chat if you have any sort of a doubt
you can ask me I try to clarify that and
then I will explain you how to create a
pipeline how to create a pipeline by
using the uh Transformer so uh we can
import the Transformer over here we can
write it down Leng ch. Transformer and
we can create a complete pipeline as
well means we can uh download the model
we can download the model in our local
okay and in our local memory actually we
can do it uh we can download it and then
we can do the prediction and all the
same thing which I'm doing over here by
using the API I will show you the
pipeline over here so first of all tell
me till here everything is clear think
is fine yes you can use the Lama 2 also
here you will find out the Llama 2 just
try to check with a different different
model related to a different different
task got it so here you will find out of
different different model you can use
the Llama 2 here is a llama 2 this one
llama 2 B Lama 2 13 billion actually
it's from the Billy U but you can check
from The Meta also so here I think there
was a meta you can search about it so
here you can write it down Lama 2 so
once you will search it so you will find
out the Llama just a
second uh you can use llama from the
hugging phase I just seen that uh
training lamba lamba where is a lamba oh
I think I need to check with a different
page So Meta Meta Nick
snip Q see
Stark why I'm not getting it just a
second I think I kept this text
generation that's why now yeah there
there is a llama so here meta Lama so
this is the model from the Facebook side
from The Meta side and uh you will find
out a different different variants of
this llama just uh take it and use it
and it updated uh 25 days ago this
one
got it guys yes or no I think you are
getting it and you are able to get this
particular thing this particular part
now let's try to understand that how you
can download this model in your local so
for that there is a certain step so let
me write it down those particular step
and step by step we'll try to understand
how we can create a pipeline and how we
can in download this model in our local
is whatever model we want to use it we
can download it now for that uh I will
have have to perform some sort of a step
so here uh let me write it down the
heading uh here guys this is the heading
uh basically just a second uh let me
copy and paste um so here what I'm going
to do here I'm going to do a text uh
here I'm writing text generation model
decoder only model so now I will use the
decoder only model any model where I I
will just have a decoder so what I'm
going to do here so the first thing
again I'm going to create a prompt so
there's my prompt a same prompt I'm
going to use or maybe I written a
different prompt over here can you tell
me a famous fitw footballer so here I I
will give the name so I I can remove
this famous from here and see the prompt
over here that what is my prompt so here
I'm asking that can you tell me uh about
a footballer can you tell me about the
footballer and here I will just give the
name so this is what this is my prompt
actually now what I will do guys here I
will create a chain now in the chain uh
what I'm going to do so just a
[Music]
second fine so here uh let me do one
thing for first of all so here I'm going
to import some sort of a library
otherwise I will get the issues I will
get the error so here I'm going to
import a few libraries so these are the
name so these are the name hugging face
pipeline which I'm going to import from
the lenen itself actually this is
available in a like if you are directly
installing the hugging phas hugging face
have in your system in your local
environment so by using the Transformer
also you can import this hugging face
hugging face pipeline but as I told you
this Len CH is a wrapper on top of this
uh apis on top of this libraries so by
using this lenon also you can use this
hunging face pipeline now what is the
meaning of the rapper so uh you know
right so tensor flow so this Kass
actually it's a repper on top of the
tensor flow if you have seen the Kass so
there you must have seen that uh like we
are just going to call a Kass Dot and
pipeline we are just going to write it
down Kass ad and we are creating a
number of note and then kasas or this
that whatever so in back end this T the
tens code is running but on top of this
T tensor flow they have created one UI
or they have created one interface now
you are not interacting directly with a
lowlevel API low level code you're not
going to write it down that instead of
that what you are going to do you are
using the rapper Kass so it is easy to
use for you so similarly see the similar
thing you can see over here this Len is
nothing it is a wrapper on top of the
other apis okay on top of the other
packages so over here you can see uh
like I need to import this particular
thing so the first thing I'm going to
import that is a like Pipeline and the
second thing which I'm going to import
that is a auto tokenizer auto model uh
for uh casual LM Pipeline and auto model
for sequence to sequence llm I will come
to each and every import statement uh
once I will write on the code step by
step I will try to explain you that why
I writing this a particular thing right
now here what I'm going to do I'm going
to download the model the same model in
the local instead of using this API I'm
downloading the same model in my local
local memory in my current uh memory in
my volatile Ram actually so here what
I'm going to do first of all I need to
mention the model ID now model ID wise
you will find out like I'm using a same
model FL T5 large and this is a model
from the Google side Google has given
this model this particular model fly T5
large so this is what this is my model
ID from where you will get a model ID
you just need to click on the model name
and from there itself you can copy this
model ID so let's say I want to get a
model ID so just copy from here just
copy from here copy model name to the
clipboard that's it so here's what here
I'm having a model ID now guys what you
want to do so here actually you need to
uh like create a like a the object of
this tokenizer and here actually you
need to create one uh here you need to
here you need to call one method from
tokenizer it's a standard processor if
you want to use this hugging face
pipeline so uh at the first place you
will have to perform the tokenization
and uh here I'm going to do a same thing
so whatever data which I'm going to pass
right so this tokenizer will
automatically uh take care of it and
back end actually some mathematical like
like some mathematical equations and all
it's going on uh maybe like with respect
to the tokenization uh you know like
different different tokenization
technique what is the meaning of the
tokenization so whatever prompt you have
that a text prompt actually are going to
convert into a numbers so that is
nothing that is my uh token means like
uh the in a numbers itself so that is
what that is your encoded value so by
using this Auto encod auto tokenizer you
are going to do the same thing you are
going to encode the values got it yes or
no I think you are getting my point so
here uh you are going to use this Auto
tokenizer and here I'm going to call
this particular method so from uh model
ID from pre-train from pre-train and
this is what this is my method and here
I'm passing this model idid so now what
I'm going to do I'm going to keep this
particular thing inside the variable the
variable name is going to be a tokenizer
so here is what here is my variable name
so once I will run it now over here you
can see we are able to create a object
and we are able to call this particular
method by passing this model ID now what
I will do guys so here uh I will uh I
will uh like uh call I will call this
particular method let me show you the
next one it's a standard procedure don't
worry again I will give you the quick
revision first of all let me run it the
entire thing now over here I'm writing
down Auto model for sequence to sequence
LM and here I'm I'm calling this method
from pre-train and here is what my model
ID and here is device map is auto right
just just like a like ignore this
particular parameter just look into this
model ID so here actually I'm passing
this model ID Google fly T5 large so
this model this is my model actually
which I want to which I want to get so
here I have a method Auto model here is
I'm basically Class Auto model for
sequence to sequence LM and from here
I'm going to call this from pre-rain
this particular method I'm passing this
parameter model ID parameter now if I
run it so here you will be able to see
that we are able to run it so here we
have created a object for this one also
now guys the next thing what I have to
do so here actually I'm going to create
my pipeline so uh here uh I'm going to
create my Pipeline and for this one uh I
have written a code so this is a code
this is what is my pipeline here I
already imported it now here I'm going
to pass the key text to text generation
here is my model this is what this is my
model now here is what here is a
tokenizer this is a tokenizer and here
is a max length so you can remove it you
can uh remove the max length also not an
issue with that so here uh I'm going to
create my pipeline so for first thing
what I need to do I need to create a
tokenizer and the second thing I need to
create a model I need to download the
model see uh first time if you will
download this model now you will get the
uh the progress bar I'm not getting it
why why because I I did it actually I
was practicing with the thing so at that
time I downloaded this I downloaded that
particular model and this tokenizer and
it is in a buffer itself so it is it is
like taking from the caching memory so
that's why you are not seeing this that
particular progress bar but in your case
if you're doing first time you will see
the progress bar you will see the prog
progress bar okay so here you are going
to create a pipeline so this is what
this is my Pipeline and here I passed
the two thing the first one is a key
text to text generation this is my key
and here uh is what here I have written
the model and here is my tokenizer
that's it you just need to focus on this
two part now here I'm going to create a
pipeline so this is what guys this is my
pipeline now after that what I'm going
to do I have to pass this particular
pipeline to my hugging phase Pipeline
and here actually you will find out this
is what this is my local llm means see
what I'm going to do so this is my model
this is my tokenizer which I'm going to
download from the pre-train one from the
pre-train one and this is the model ID
the same uh tokenizer
which has been used to this particular
model from the pre-train see I'm calling
this method so here is my tokenizer and
here is my model from this particular ID
I'm not getting any progress bar why
because I already did it it is taking
from a cachia memory okay but if you are
doing it first time you will be getting
a progress bar and you will be seeing
that all the parameters getting
installed over here right got it now
here what I need to do I need to keep
all the thing in a pipeline and then
finally I'm passing it to the hugging
face Pipeline and this is what this is
my local llm now everything is done
everything is clear now let me run this
prompt so here is what here is my prompt
so what I can do let me keep this prompt
over here this is my prompt and here
this is my prompt and this is what this
is my local llm now let me run it and
here what I will do guys so now uh let
me call the chain and to the chain I'm
going to do a same thing what I'm going
to do guys tell me to the chain actually
see what is a chain I told you chain is
nothing it's a it's a like a collection
of of the components right you are going
to uh you are going to you are you are
stacking the components a different
different component have you seen the
chain right so uh there I was stacking
the llm and this prompt so I'm doing the
same thing now see the power of the Len
chain not even with the open AI we are
able to use it with the different
different apis with the hugging face
also directly and even in the with uh
with respect to the local one also with
respect to the local LM also so it works
with in every scenario this lenion works
with every scenario okay now here if I'm
going to run it uh so now I I'm able to
create this chain now if I will ask
anything to this chain so let me write
it down over here chain do run now here
what I'm going to do here I'm going to
pass let's say Messi okay Messi now if I
will run it so you will find out that it
is generating a answer so Messi is a
footballer from Argentina and I just
asked what I asked guys so here I asked
what was my prompt can you tell me about
footballer so here is a name name which
I'm passing now let me write it down
some any Indian Indian like footballer
name so Sunil
Chri so let's see uh what will be the
answer it is able to get it or not sonil
chetri uh okay Sunil chetri born 24th
August 1971 it's a former Indian Indian
footballer who played up forward so
great guys it is able to give me an
answer and here you can see I have
installed I downloaded the model in a
local itself so tell me guys this part
is clear to all of you how to use the
hugging face API by using the lenen and
how to download the model and how to use
it please do let me know in the chat if
this part is getting clear to of all of
you so yes this is the number of tokens
max length So within that itself within
uh it is not going to exceed the answer
and this is the max length basically it
will be uh within that itself you will
be getting an
output
tell me guys fast so is it clear to all
of you if this part is clear then please
do let me know please hit the like
button and uh yes if you have any sort
of a doubt then you can ask
me you can ask about the vat kohi you
can check over here so here you can
write it down the vat kohi even though
he's not a footballer let's see what
will be the answer it depends on the
model our GPT model is very much uh
powerful let's see uh this uh Flame T5
large so okay so I'm getting verat kohi
is a s linkan footballer who plays it is
completely wrong now you can see so it
is uh not giving me a correct answer
let's try to design a different prompt
over here so here I can uh do that let
me this let me design one more prompt
and can you tell me about cricketer so
here I can write it down cricketer c r i
c k uh cricket so this is the spelling
now let me take this thing and here is
going to be my chain two this is my
chain two and this is my prompt two and
I'm using a same llm over here so this
is my chain two now what I will do here
I'm going to run it and let's see will I
will I get a correct information or not
will this model is capable or not this
uh which is a name what is the name
flame T5 large so let's see it is a
capable or not so chain two. run and uh
if I'm running it
so in the district of balut prad is
giving me a wrong answer I think uh
cricketer Koh he does not belong from
the bhalpur it belong he belong or not I
don't know about it let's uh talk about
the suchin uh let's talk about the sain
or Ms D so here I can ask about the MS
Tony chain. run and let's see who play
the Indian Premier League site Mumbai
okay it is saying mson plays a cricket
from the Indian Premier League from
Mumbai Indian so it is like a completely
it is giving a wrong answer this flain
T5 so you should use a different model
in that case actually see GPD is a
better one it always gives a correct
answer and and is like a much more
capable that's why I started from the
open a and that's why I didn't started
from the hugging page but yeah according
to the task according to data according
to requirement so now that will be your
responsibility as an NLP engineer as a
generative engineer you have to check
you have to like check with a model that
uh like on which data it has been
trained okay on which data has been fine
tuned how many parameters is there what
is a performance performance of that if
uh like uh we are doing a text
generation that what is a blue score
like blue score with that we can
identify the uh that like how much it is
capable for generating a text so each
and everything you will have to read
about the model and then only you can
use in a production not directly so
there will be so many uh like uh uh uh
there will be so many experiment which
you will have to
perform okay there will be so many back
and forth you will have to perform
before deciding any sort of a model and
here I have given you the approach guys
here you can append the memory here you
can play with the chains here you can uh
like play with a different different
prom template you can download the
document you can import the document
each and everything I have shown you
inside this two notebook now you are
enough capable to implement uh for
implementing any sort of a project now
whatever project I'm going to teach you
definitely you will be able to grab it
and uh I will uh after the like jupyter
notebook implementation of the project I
will uh explain you that how you can
convert into an end to endend one so uh
from next class onwards we are going to
start our Inn project by using this Len
chain open ey hugging fish and all and
apart from that we are going to use some
other thing as well and I will show you
the complete setup of the project the
project name is going to be McQ
generator got it yes or
no yes you can fine tune the model as
well if you want like if you want to
find uh if you want the process of the
fine tuning I will give you that also I
will give you the fine tuning process
also just wait for some time step by
step we try to do each and everything if
I'm going to explain you everything in a
single class so it might be a difficult
for you so uh step by step we'll try to
do it don't worry we are not going to
like conclude or we are not going to
step stop this community session uh like
uh we'll be continue this uh like in
know next week also and there uh we
going to talk about
many you can use uh like which open stes
model you can use for the machine
translation you can check over here just
go through with the hugging phase API
and click on the model model uh just uh
click on the model and here you will get
the machine translation so maybe machine
translation is there classification
question answering yeah here is a
translation so just see the model what
all models is there just try to use this
particular model open source model apart
from that you'll find out other model as
well so see llama 2 is a open source
model you will find out a different
different variants of this llama you'll
find out a different different variants
of this llama okay so you can use this
llama 2 model for your image translation
as I click on this translation here you
can see the result got it now you can do
your own research you can go through
with the different different API as I
told you if you don't want to use the
chat GPT so here I have created one more
API for all of you so like I have
written a code regarding one more API
that's going to be a AI 21 lab so in the
next class I will show you means after
the project actually after completing
the vector databases and all I will come
to some Mis mous topic there I will show
you the code regarding this a21 lab okay
so here actually uh like we'll talk
about the Jurassic model uh which is a
very powerful model with that also you
can do a multiple thing Falcon is there
you can use the Falcon so Falcon you
will find out here itself you know uh
let me show you where is a falcon so
once you will search over here Falcon so
it's a model from the Google yeah uh no
it's a not of Google one it's a not of
Google model actually it's a model from
this particular
organization I think it's a Chinese
organization maybe and one more model
let me write it on the name Falcon let
me recall the name Falcon was there
Bloom is there uh let me check with the
bloom yeah Bloom is there and apart from
that farm is also there p a LM Palm is
also there it is not actually you won't
be able to find out this pal over here
uh you uh you will have to access it
from the separate API so it's a Google
model pal p a l m 2
Palm 2 API just search over the Google
and you will find out it this Palm
API so it's a uh model from the Google
research Google researcher it's a model
from the Google community so you can
explore about the API and you can
utilize this all you can see generate
your API key just generate a API key and
try to use this form model as well and
after like so many back in fors after so
many research and all then only you can
decide that which is which is my best
model which one I should which one
should I productionize this is working
fine or that is working fine but gpd1 is
a like trusted one and here you we can
you can see the clear application of the
GPD model where they are using GPD 3.5
turbo and GPD 4 itself so many people
are using the GPI even though it is a
paid one but people are checking with
the other open source model as well like
this Palm Falcon Bloom and all okay
Cloud a is one of the model you can
check about the cloud as well so I think
now uh each and every uh thing is clear
to all of you so guys if you're liking
the session if you uh like the content
then please do let me know in the chat
or please hit the like button if you are
able to understand everything whatever I
have explained you in today's
session here I will explain you how to
build the applications and all and from
next uh class onwards I will give you
the different different assignments
also
yes we can use the mlops tools now like
we'll do the development now in between
we can use any mlops tools ml flow we
can use ml flow DBC or Q flow we can use
the uh like other melops tools like
Docker and all don't worry regarding
that so once I will come to come to the
development there I will uh do
that okay great now yeah jimin also come
you can check with that also recently
Google has released the
gemin fine so I think uh now we can uh
close the session uh now we'll meet on
Friday uh Saturday and Sunday we don't
have any session uh the session is going
to be from Monday to Friday only and the
timing is 3: to 5: p.m. IST so let me
write it down over here uh Saturday
Sunday we don't have any session
Saturday and Sunday there won't be any
session
s session will be
continuing
continuing uh from Monday
onwards Monday onwards and the timing
will be timing will be
sa so it's going to be from 3:
to 5 p.m. ISD so here guys it's a short
notice for all of you uh we don't have
any session on Saturday and Sunday day
the session will be going on uh from
Monday to Friday only and the timing
will be same 3 to5
istd fine I think
uh I have finished the data loader topic
uh if you will check into this uh this
particular notebook already I have uh uh
like shown you this data loader and all
now I told you now just try to check
with the different different data
loaders and all CSV tsv Excel or
whatsoever just go and check you can do
it by using the documentation but here I
given you the example of the to data of
this document loader so I have imported
this uh PDF I think you missed the
previous sess that's why you are asking
this question fine so I think uh we can
start with the session so welcome back
to this community session of generative
AI uh this is day six and today we going
to start with our first end to end
project that's going to be a McQ
generator so guys uh this is this is our
first uh like end to end project which
we are going to implement by using this
generative AI uh by using the LMS and
all and in this particular project we'll
try to use the all the concept basically
whatever we have learned so far in our
course in our committee session so first
of all uh let me show you that uh where
you will find out all the session all
the uh resources and all because we have
updated each and everything over the
dashboard and each and everything you
will find out uh in the uh resource
section so let me show you that uh
particular thing and for that guys you
just need to visit the Inon website and
after visiting the website you need to
search about the generative AI so search
about the generative Ai and there you
will find out two dashboard so first One
dashboard for the English and One
dashboard for the Hindi so yes I'm
taking a same session on my on the I on
Hindi YouTube channel as well so you can
search ion Tech Hindi so there I'm
taking a same session and uh there also
I'm uh explaining the concept of the
generative a and all so guys here what
you need to do here you need to click on
this particular dashboard generative AI
Community session and once you will
click on that so it will ask you for the
enrollment and here we are not going to
charge you anything any cost so if you
are new then please do sign up and then
uh try to enroll in this particular
course now here guys uh just enroll to
this particular course and after that
you will be redirected uh redirecting to
the dashboard so after sign in you will
get a dashboard uh here you can see this
is uh this is a complete dashboard uh
just a second let me show you
that this is the one so this is the this
is the dashboard guys and here you will
find out all the recording so uh so far
I took five session day one day two day
three day four day five and in this
particular session I covered each and
everything regarding the generative AI
whatever uh is required if you want to
start with the projects and all so uh
just go through with the very first
session there you will find out complete
introduction and in the second one so in
the second session uh there I have
discussed each and everything about the
open Ai and in the third session I have
discussed about the Len chin and then I
talked about the a few more concept like
Len chain memory and all even I have
discussed about the hugging face API so
if you want to use any open source model
if you don't want to use a model from
the open AI so uh you can access the
model from the hugging phase also that
thing also I taught you so if you will
go through with my session each and
everything you will find out now it's
time to implement the project so we'll
try to implement a project and and the
project is going to be end to endend and
not even single so uh not even this
project so we are going to implement to
more project with a few more advanced
concept like vector databases and there
will discuss about the r and there we
are going to create our web API by using
the fast API and flast so each and
everything we are going to do here
itself in a live session so please make
sure that you enroll uh for this
particular dashboard and please try to
check with the ion YouTube channel as
well there we are uploading each and
every video so once you will search over
the Inon so let me show you that so uh
first of all you need to open your uh
open your YouTube and there search about
the uh Inon so here you can see so open
the Inon YouTube channel and inside that
uh like uh there you'll find out one
live section so just click on this live
section and you will find out all the
recordings so here you will find out all
the recording from day one to day five
and uh today I'm uh teaching a project
it's a day six and uh if you will open
any sort of a video so here in the
description also you will find out each
and every detail so here you will find
out a course detail here you find out
each and every detail basically whatever
is required so please make sure that uh
like you are enrolling to the dashboard
for the entire resources and all and yes
recorded video is available over the
Inon YouTube channel as well got it so I
think uh this is fine this is clear now
let's start with the project so as you
have seen the uh the topic uh so the
topic is what topic is the project name
is what the project name is a McQ
generator using open Ai and langen chain
now why I took this a particular project
because see uh we have learned each and
everything we have learned each and
every concept so far related to the open
API related to The Lang chain now how we
can utilize those information until we
are not going to implement the project
so in that case we won't be utiliz that
particular information whatever we have
learned even we won't we won't be able
to relate those thing with a real time
thing so that's why I kept this project
for all of you in between and then we'll
try to move into some Advanced concept
like databases and all and we'll try to
create a few more a few more project in
our upcoming session but yeah so here uh
we are going to start from the very
basic project and then we'll go to the
advanced label got it now what all thing
I'm going to discuss in today's class in
today's session along with the project
so here I will teach you the entire
setup of the project so here uh we are
not going to implement this project in a
jupyter notebook so for that we are
going to create a complete development
environment so I will show you how you
can create a like and to and development
environment and then we'll try to deploy
this project as well so in tomorrow's
session I will show you how you can
deploy this project along with the cicd
concept along with the continuous
integration and continuous deployment
concept so in today's session we'll try
to see that how we can set up our uh
development environment and then uh
we'll try to uh implement the Jupiter
notebook regarding a different different
application and then we'll try to
convert that jupyter notebook into a
endtoend application got it yes or no so
the agenda is clear to all of you please
uh do let me know in the
chat yes or
no
great so I think uh we can start and uh
yeah if you are liking the session then
please hit the like button and uh keep
watching so guys uh the first of all let
me write it down each and everything
each and every step uh whatever we are
going to do here and whatever uh we'll
be doing throughout the session so for
that uh I'm using my Blackboard and here
itself I'm going to write it down the
each and everything so first of of all
let me remove it and yes uh I have
opened the fresh one now let me write it
down each and everything uh regarding
today's session so guys see the first uh
thing which we're going to do uh that is
uh environment setup so at the first
place uh we're going to uh set up our uh
environment our development environment
I will show you the complete a project
setup so here let me write it down so
setup development environment so the
first thing which we're going to do uh
we going to set the development
environment now after that what I will
do after setting the development
environment then uh we'll try to uh run
a few experiments run few experiments uh
few experiment in a Jupiter notebook so
we we'll run a few experiment in a
Jupiter notebook after that we'll create
a end to end will'll create a modular
coding like by using this particular
experiment and all so I will do a like
modular coding I will create a several
file and then I will uh try to segregate
the code so uh after uh doing a few
experiment in a Jupiter notebook I will
convert this jupyter notebook into a
modular
one got it modular coding now after that
after uh converting to a model one
Modular One definitely uh like uh uh my
code will be uh my code will be uh ready
and then I will create my web API then I
will create my web API by using the
stream lid so here by using the stream
lid I will be using I will be creating
my web API and after uh creating this
web API definitely for sure I will test
it and finally we'll try to deploy our
application on my cloud platform in my
AWS or aor got it so these are few step
uh these are the these are few things uh
uh basically which we're going to
perform uh regarding this particular
project so today uh I will be uh cover
this two point the first one second one
and maybe the third one and tomorrow I
will create a web API because we have a
time restriction the session is just for
the 2 hour otherwise I can complete this
thing within a uh class itself so today
I'm going to complete this two thing and
tomorrow uh I will be converting uh the
entire code in a modular one and then uh
we are going to create a web API and
finally we're going to deploy the
application got it now after that now
after that what uh we are going to learn
so after completing this thing we're
going to learn about the vector
databases we'll try to learn a vector
databases we'll try to see that what all
options we have if we want to store the
embedding not even the vector databases
what all other options we have so we'll
try to explore about the mongodb
cassendra and we'll try to look into the
SQL base database also and then finally
uh we'll look into the vector databases
different different options we have and
then uh we'll try to use the RG concept
on top of that and we'll create a few
more project so yes uh from today's
onwards our project journey is going to
be start so don't miss it and within 2
week uh our aim to complete at least
three and to end project in a live
session itself got it so I hope this
idea is clear to all of you now uh let's
start uh first uh with the project setup
so the implement impation the project
basically I'm going to implement in a
jupyter notebook so entire development
setup I'm going to create in my uh sorry
I'm going to create in my vs code so for
the entire development I'm going to use
my VSS code and today I will show you
how you can set up your vs code for the
end development got it so for that guys
uh what you need to do first open your
CMD uh uh Implement along with me
because uh I will share the GitHub link
with all of you so that you can uh write
it down the code you can copy each and
everything from there itself and along
with the uh code I will I will be
writing all the commands and uh all
whatever I'm going to use in my uh in my
project so in my project setup and all
so each and everything I will be uh I
will be writing in my GitHub U I will be
writing in my readme file and then I
will give you uh through my GitHub link
so guys uh you can follow uh uh each and
everything along with me so uh first let
me start from the project setup so uh
here here guys uh first of all what you
need to do so in any directory in C
directory in D directory in whatever
folder you need to create uh one folder
you need to create one fresh folder okay
so go in uh go with any directory C
drive uh C directory D directory C drive
D drive e Drive and inside that you need
to create one folder so here you can see
this is my location C user sunny and
here I'm going to create my folder one
fresh folder so for create a folder
there's a command like mkdir by using
this particular command I can create a
folder so here I'm going to write it
down mqd and my project name so let's
say my project name is what McQ
generator so this is the like uh this is
the folder name which I have written now
uh yes I have created my folder now what
I need to do I need to move into my
folder now I need to change the
directory so here I need to move into my
folder I need to change the directory so
for that we have a command like CD CD
McQ generator this is my folder name now
you can see I'm into my folder now I'm
inside my folder and from this
particular folder I need to launch my vs
code so for launching the vs code from
the command promp there is a command the
command is called code dot code space
dot so once you will write it down on
this particular command code space dot
so in that case you will be able to
launch your jupyter notebook in a
current for folder right so here is my
folder name my folder name is what my
folder name is McQ now here you can see
I'm able to launch my j i I'm able to
launch my vs code inside this particular
folder now if you want to verify so for
that what you can do you can go with
your terminal so just click on the new
terminal and here you will find out the
same location which you are seeing over
the command prompt so guys here you can
see you are into the same location which
you were seeing over the command prom
got it now let's say uh if you don't
have this vs code so from there you can
install this vs code so for that you
just need to go through the Google just
search over the Google just search about
the google.com and here write it down vs
code download so write it down here vs
code download so you will get a link for
downloading the vs code and here uh this
is the link guys I'm giving you this
particular link inside the chat and here
uh like you can go through with this
particular link and you can download the
vs code according to your operting
system so if you are using Mac uh so you
can download from here if you are using
the Linux so from uh for the Linux you
can download from here if you're using
Windows so for the windows you can
download from here you will find out all
the three option for a different
different operating system now uh once
you are done uh uh like with the
download and all so after that what you
need to do so after that you need to
install it so just try to do a double
click and install this vs code in inside
your system and then you can follow the
same procedure so you can create a
directory you can uh write it down this
first and then you can change the
directory and from on that particular
directory you can launch the vs code got
it now if you not able to do it by using
this command line so by using uh by
using the UI also you can do the same
thing so for that uh just uh go inside
your directory and here create a new
folder so create a new folder and then
do the right click and check with the
show more option and here you will find
out option for launching this vs code so
by using this uh GUI also you can do a
same thing and by using the command prom
also you can do a same thing so I took
this command promt approach and here you
can see I'm able to launch my VSS code
inside this particular folder so if you
are done till here so please do let me
know in the chat please uh tell me guys
if uh you are done till here
tell me first have you opened your vs
code in a folder if you did it then
please write it on the chat
yes yeah I'm waiting for 1 minute so
until you can open
it
yeah you can use the pyam
also uh not an issue with that py Cham
will also work any ID so here I'm using
this vs
code okay so I think uh now everyone is
done so so let's start with a further
step so after opening this vs code so F
the first thing uh the first thing which
you need to do you need to initialize
the git so here guys uh what you need to
do you need to initialize the git so uh
here see we have a uh like a various
option here once you will click on this
drop- down so here you will find out of
various option like Power Cell G bash
command prom Ubuntu Kali so in your case
it there might be only G bash command
prompt or Powershell but in my case here
you will find here you can see I have a
different different terminal right but
maybe in your case you just have this
git bash and command prom that's that's
all fine right so either you can work
with this G bash or you can work with
the command prom but don't work with
this poers shell because otherwise
unnecessarily you will get uh uh errors
and all so I won't recommend you to uh
work with this poers shell and all so if
you want to work uh with the like with
the terminal so here either use this git
bash or this command Pro don't select
this Powershell so here I'm using this
git bash so here I can easily run my uh
like Linux command also so yes uh if you
don't want to use this git bash so you
can use this command prom also that is
also fine now guys here uh you'll find
out that okay so this is what this is my
G bash now uh here if you are not able
to see the base environment so for that
what you need to do so just try to click
on this View and go with the command
pellet so here you need to go uh you
need to click on The View and click on
the command PL and then select python
interpreter so here you will find out
various interpreter so you need to
select this base interpreter and after
that you need to relaunch this git bash
so in that case uh if if you are not
getting that base environment in your uh
G bad so after uh like following this
step uh definitely you will be able to
see that so here now you can see I have
a Bas environment on my good bash now uh
let me uh let me run the further thing
so the first thing what you need to do
over here like so the first thing you
need to initialize the git right so
inside this directory you need to
initialize the git so for initializing
the git I just need to write it down a
simple command that is what that is git
in it so by using this particular
command I can initialize the git in my
current folder in my local folder so now
this local folder will be treated as a
local repository and then I can uh I can
upload this same folder on my uh GitHub
and yes like that's going to be my
central representing so GitHub is going
to my central repository and as of now
if I'm going to initialize the git in my
local folder so this is what this is my
local repository each and every thing
each and every track actually I'm going
to keep it keep over here itself in my
local folder so that uh like the entire
data you will find out inside the dogit
folder I will show you that so here you
need to write it down this git in it so
once you will write down this g in it uh
so you will be able to initialize the
git inside this particular folder okay
now uh here you can create a file so
here I'm going to create my readme file
so r e a d MD so
readme.md so it's going to be a markdown
file MD means what it's be it's it's a
markdown file so here uh guys you can
see I created my markdown file right now
uh if I want to publish see as of now
see if you will look into this
particular folder so let me reveal it
inside the file explorer so just try to
click uh do the right click on this file
and reveal in the file explorer so here
you will find out this dogit and here
you will find out each and every
information so because of this dogit
folder actually uh this a local folder
is being treated as a local repository
now here you will find out each and
every metadata so regarding your commits
and all so whatever codes you are going
to upload whatever like changes you are
going to made and all right whatever uh
changes you are going to commit and add
so each and every metadata you will find
out inside this dogit folder and why we
use this uh git guys tell me we use this
git for the code versioning got it I
think uh you have a basic idea about the
git so I'm not going into the depth of
this git and all as of I'm just like
giving you the uh the high level
overview that's it now here uh you can
see I have create I have initialized the
git and here you can see this do git
folder inside my uh dogit folder inside
my local repository so is it fine to all
of you I think yes now what I can do
here so here I can publish the branch so
I can publish the this local repository
to my GitHub so for that what you can do
see you can use this uh terminal also
and here this vs code has given you the
GUI option so just click on that just
click on this particular option and here
you will find out uh the various thing
right so uh here you will find out the
various options and all now let me show
you step by step so the first thing what
you need to do so first you need to add
your file so for adding the file you
just need to click on this plus icon so
uh if you want to add the file uh so for
that you need to click on this plus icon
and after that uh like you need to uh
write it on the message so you write
down now that first you run this git in
it and then you run this git ad git ad
and the file name so I'm doing the same
thing over here so by using this plus
icon I'm adding this particular file
right so uh in my uh like staging area
right so and then I will do the commit
after writing a message so here I'm
writing down writing the message uh this
is my first commit so here uh my
messages this is my first commit now
after writing the message what I will do
I will commit it after committing is uh
after committing uh it okay so it will
ask to me would you like to publish this
Branch so I would say yes I would I want
to publish this particular Branch so
here it is asking to me how you would
like to publish it so whether uh as a
private repository or as a public
repository is going to publish over the
GitHub actually so here it is asking to
me how You' like to publish it whether
as a private repository or as a public
repository so as of now I'm going to
publish publish this particular Branch
as a public repository so you can click
on this public repository and yes it
will publish a branch so it is uploading
all the file here you can see and then
it will give you this a particular popup
so here it is telling you that please
sign in with your browser so once I will
uh click on this uh sign in with your
browser so yes it is uh doing that and
uh just wait it is publishing the branch
so it has given me uh this particular
page now let let me authorize it so here
I need to click on this confirm and
after that guys you can can see
authentication succeed so now uh my
branch is uh published let me show you
that so here you can see you can open it
and this is guys this is my Branch okay
so I published this branch on my GitHub
so I hope this thing is uh clear to all
of you and you are able to publish your
branch yes or no guys tell me are you
able to publish your branch um just a
second great so now let me give you this
particular link and so that whatever
code and all I'm going to write it down
so directly you can copy and paste from
here itself from my git so let me give
you this uh particular uh link uh so
that you can copy each and everything
from here itself just a second so did
you get it please uh do let me know in
the chat if you got my
code tell me guys fast sorry if you got
if you got my link then uh please do let
me know in the chat again I'm pasting uh
this particular link so this is my
GitHub link
guys yes please do confirm if you got my
GitHub I given you the GitHub
guys yes or no I am waiting for a reply
please check it check with the popup so
first you need to sign in through the
browser and then only you will be able
to log in if you're not able to follow
this GUI approach uh in that case uh
what you can do so you can uh like uh
push it through the command line
also
yeah if you are not able to log in so
through this uh command line you can uh
configure the username and the uh like
email ID so for that there is a like
command so let me show you that
particular Command right just a second
so what I can do I can show you over
here itself uh so you can search over
the Google how to configure how to
configure get uh username so you can
search over the Google and then you will
get a command so let me give you those
particular command if you are not able
to uh sign in but please make sure that
if you're getting the popup then then
directly you can sign in but if you're
getting any sort of error right so for
that there is a command so get config
hyphen global hyph iph global user.name
and here you need to pass your username
so like whatever username you have so
you just need to pass your username and
then you need to pass the you need to
configure the email also so okay so here
uh for the username and in a similar way
you need to configure the uh you need to
configure the email so let me give you
this uh two command now here let me
write it down that you need to write it
down your your
username
your user
name and here is a command guys so first
try to configure your username and here
again I'm giving you the same command
along with the username you can
configure your email also so let me
write it on the email and in the double
code actually you need to pass your
email so here your email ID so guys uh
run this two commands on your uh on your
uh command line actually and then you
will be able to sign in from here itself
got it yes or no till here uh everything
is fine everything is clear I given you
the GitHub Link in the chat so so um you
can click on that and you can uh like
you can check with my repository each
and everything I'm going to update over
there itself so that uh you can copy and
paste the code directly from there now
guys uh here uh if you're not able to
find out uh if you're not able to click
on this link so you can search uh with
my username also so or over the Google
you can write it down s Savita GitHub
you will get the GitHub directly it will
give you the link link of the GitHub and
this repository is a public repository
so Direct you can go through with my
repository and you will find out this
particular project got
it great yes uh from the same terminal
you need to configure your username and
email ID okay now here we have published
uh this code as a uh like to my GitHub
right this this particular repository
this a local repository I publish to my
GitHub now I need to follow few more
step for setting up my environment so
the next thing what I need to do here I
need to create my environment because
I'm not going to work in my base
environment and I'm going to create a
virtual environment over here okay so
for creating a virtual environment there
is very a simple command so let me write
it down on that command so cond condu
create condu create hyphen P okay hyphen
p and here you need to write it on the
environment name so here my environment
name is going to be en EnV en EnV and
then you can write down the python
version python is equal to 3.8 so I'm
using over here 3.8 and then hyphen y so
this is my command uh which I'm going to
run and by using this particular command
I can create the environment in a
current directory itself in a current
repository so here you can see this is
what this is my environment uh which is
being created so just wait for some time
it will take uh few second let it create
so my environment name is what my
environment name is ENB
now here my environment is getting
created and it is done now after that
what I need to do guys so here I need to
activate my environment so for
activating the environment you need to
write it down Source activate if you are
using this git terminal so in that case
instead of this cond you can write down
this Source because sometimes this cond
gives issue so I'm not going with this
cond here so I'm using this source of
over here so you need to write it down
the source activate activate and here
Dot dot means current directory and from
this current directory there is a folder
folder name is environment e andv right
so here you can see I'm able to activate
my environment and here you can see this
is what this is my virtual environment
got it now let me clear it first of all
so here now you can see it is giving me
a uh like uh it is giving me a how it is
giving me so many files uh for adding
right so U like here it is giving me
more than 5,000 file but I cannot like
add all all the files I cannot like add
all the files on my GitHub right so for
that what I will do if I want if I don't
want to track it if I don't want to
track this particular file so I can U
mention this name this EnV name in in
the file the file name is what the file
name is dog ignore so here let me create
one more file in this uh particular
directory and my file name is what my
file name is uh dogit ignore so here I'm
writing this uh dot get ignore uh and
the touch command is the touch command
for creating a file so touch dog ignore
now here you can see I'm able to create
this particular file this dog ignore now
inside this file you can mention the
name the name of whatever file which you
don't want to drag so here if I don't
want to track this EnV folder right if
you don't want to track these many file
if I don't want to upload it in my cloud
repository right or if I don't want to
track it uh by using this git so so you
can mention it you can mention this
folder name inside this dot inside this
dog ignore file so here I'm writing EnV
uh EnV is nothing it's a folder name now
once I return it once I return this uh
EnV inside this do G ignore now you can
see it is not going to track it at all
so here uh it is not going to track uh
this particular folder now and it is
giving you only it is giving me only one
file now yes I can uh add it so here uh
first I'm going to add this file get add
and this file name now here I'm writing
my message so I have added I added my
get ignore so this is my message and
after that what I will do after after
this after this one I'm going to commit
it so edit my get ignore and then do the
commit now uh you need to click on this
sync changes your and your changes will
be sync so the same file you will find
out the same file you will find out in
my G iub also so uh let me show you
where you will find out that let me open
my GitHub and uh here guys here is my
GitHub let me show you the
repository here is my all the
repository and this is the uh like
folder this is my like project actually
now see uh I just added this dot get
ignore now see see that uh commit just
now just now I committed uh this
particular file and here you can see my
dotg ignore now once you will open it so
here you will find out the folder name
so the folder name is what EnV so I
don't want to track this file throughout
my process right so I uh if I don't want
to track this file at all so yes uh for
that I will mention it inside my dog
ignore file got it now uh till here I
think everything is fine everything is
clear and I hope you are of you are able
to follow me till here so please do let
me know in the chat guys if uh uh
everything is clear everything is fine
till here what about 3.9 yes you can use
3.9 3.10 as well but don't use 3.11 3.12
or 3.13 till 3.9 and 10 it's fine but
please make sure that uh uh please make
sure that you are going to use the same
version which I am using uh so you won't
face any sort of a issue any you won't
get any sort of error uh during the
implementation got it
yeah so if it is done then uh please do
let me know guys please write it on the
chat and uh please hit the like button
if you are liking the session
then done can I get a quick confirmation
in the
chat
great so I think uh now everyone is done
so here I have created my environment
now guys what you need to do so after
that you need to create your
requirement. txt so inside the
requirement. txt I'm going to mention
the entire requirement right so for
creating a requir txt so from here also
you can create by using this particular
icon other you can use the same command
same a touch command by using that
command also you can create the require.
txt in a current folder in a current
repository now uh for creating a requir
txt so I'm using this particular icon
and here I'm writing requirement R Qi r
m m n ts. txt now in this a particular
file I'm going to mention all the
requirement whatever requirement I'm
having regarding this project right so
I'm mentioning all the requirement
inside this require. txt so guys uh let
me copy and paste all the requirement or
whatever is there all I'm going to write
it down here itself so the first thing
which I'm going to use uh in my project
that's going to be a open a so I'm using
the open a API and for that this open a
package is required already I shown you
how to use openi API how to install this
particular package because earlier we
also we have created the environment
and there also we have installed this
open AI if you have attended my previous
session then definitely you must be
aware about this particular thing now
here uh there's a open a now the second
thing which I need to uh install in my
local environment in my current virtual
environment that's going to be a len CH
so here guys let me write down the Lang
gen so you need to install the langen CH
in your current environment first thing
is open Ai and the second thing is what
the second thing is the Len chain the
third one uh which I'm going to write it
down over here that's going to be a
stream L because here I'm going to
create a API by using this stream l so
here I'm going to like install the
stream lit in my local uh like
environment in my current virtual
environment the second thing which I'm
going to be installed over here uh
that's going to be a python hy. ENB so I
will tell you what is the use of this
particular U like uh uh this particular
package python hyon do EnV so I'm going
to install this uh python hy. EnV
package and I will tell you what is a
use of this particular package and apart
from that I'm going to use I'm going to
download one more package that is going
to be a pi PDF so Pi PDF two so these
many thing I'm going to be install in my
current virtual environment okay and
apart from that I'm going to create
couple of more folder right couple of
more folder I'm going to create in my
local repository in my local folder so
uh couple of more uh files and folder
not only folder files also so here uh uh
requ txt is done now I'm going to create
one more file the file is going to be
setup uh setup uh setup.py file now why
we use this setup.py file we use the
setup.py file for installing a local
package local package in my virtual
environment if I want to install the
local package in my virtual environment
for that we use the setup.py file got it
so I created the setup.py file I created
the re. txt now let me create a one more
file so here I'm going to create so not
file actually I'm going to create one
folder here my folder name is going to
be SRC SRC means what SRC means source
code now inside the SRC I'm going to
create a one more folder and the folder
name is going to be so first of all let
me create a file inside this SRC the
file file name is going to be dot uh
sorry underscore
inore dopy so here inside this SRC
folder I'm going to create init file
okay init file I will tell you why we
create this init file inside the a
folder what is the requirement of that
and uh each and everything I will
explain you don't worry so here uh you
can see I've created this init file and
inside this inside this SRC folder
itself I'm going to create one more
folder the folder name is going to be
McQ itself so m McQ generator and this
is what this is my project so McQ
generator so this is what guys this McQ
generator is nothing it's my folder and
inside this also I'm going to create one
init file so here let me create the init
file inside uh this folder also so init
init.py so what I did guys tell me so
here if you will look into this uh if
you will uh let me reveal it inside the
file explorer and let me show you that
what I did so here uh just look into the
SRC folder so inside this SRC folder I
created two things first I created this
init file and the second one I created
the McQ
generator folder and whatever source
code whatever source code I'm going to
write it down throughout my project so
I'm I will be writing down here
itself apart from The jupyter Notebook
so each and every line of code modular
coding I will be doing over here itself
inside my McQ generator folder got it
now here uh what I did I created this
init file underscore uncore inore ncore
now what is the requirement of this init
file why I did it because see if I let's
say uh like here I want to consider this
folder this folder as a package as a
local package right this folder actually
I want to consider as a package now what
is the meaning of the package so the
package is nothing it's a it's a folder
itself folder which is containing a
multiple python file and inside the
python file you have a code you have a
code like a classes functions and all
right so you have a folder inside the
folder you have a file and inside the
file you have written a code right so
now guys see uh let's say if you're
installing pandas if you're installing
numai if you're installing maybe open a
or let's say if you're installing langen
so what is this tell me it's nothing
it's a full it's a package itself it's a
package now and package means what
package package nothing it's a folder
right folder is what F the package is
equal to folder right folder itself is
called a package now inside the package
or inside the folder what you will find
out inside that you'll be having a
multiple python files right and inside
those python file you uh someone has
written a code uh in terms of function
and classes and that is what uh that
only you are going to use right so this
uh lenen this open this pandas napai
someone already created it and they have
uploaded over the pii repository and
from there itself you are going to
install it inside your project but here
this McQ generator actually it is your
local package where you are going to
create a multiple folder mul multiple
python file and uh if you want to
treated if you want to treat this folder
as a package so for that there's a
convention from the python side you will
have to mention this init file inside
the folder right so here my folder is
what my folder name is SRC SRC means
what it's a short form of the source
code SRC now this SRC actually I want to
treat as my local package so there is a
convention from the python side you need
to mention this init file or you need to
create this init file inside this folder
then only it will be treated as a local
package I think the idea is clear now so
by using the setup.py file by using this
setup.py file I'm installing this local
package in my current virtual
environment got it I think now each and
everything is clear to all of you now
let me back to my code so here is what
here is my code so I created couple of a
folder couple of file now guys uh let me
create one more file uh like one more
folder over here and the folder name is
going to be experiment so here I'm going
to be create one more folder and the
folder name is going to be experiment
and inside this particular folder I'm
going to create my Jupiter notebook I'm
going to create my ipb file okay so for
creating ipb file inside this particular
folder so you can click on this folder
and click on this file icon and then you
can write down your name so here I can
uh write down the name any any name I
can write it down here let's say McQ dot
ipnb uh do
ipnb so what is the meaning of this
ipynb so ipynb means nothing uh I python
uh notebook okay that's the full form of
this IP YB now here you can see this is
what this is my jupyter notebook now
whatever experiments uh whatever experim
experiments will be there throughout
this project so I'm going to do my
entire experiment over here in my
Jupiter notebook and then I will convert
into an end code into my end to end
pipeline got it now here uh the first
thing what you need to do so you need to
select the kernel so just click on this
select kernel and then click on this
python environment then you will get all
the python environment so this is your
current virtual environment so this this
the this interpreter which you can see
over here the first place which is a
recommended one so this is from your
current virtual environment from the EnV
itself here you can see EnV python.exe
so here I'm going to select the same
kernel so here I have selected this
particular kernel now you can see uh I'm
done with everything now I just need to
uh I just need to like uh install the
recom txt I will start by writing the
code so let me give you this each and
every file and folder so for that I just
need to add it from here itself so I'm
going to add all the files and all over
here I think it is done now I will write
it on my uh like message so my message
is structure updated so here is what
here's my message guys now let me commit
it so structure s u c Tru structure
updated now I have written my message
after adding all the file
now once I will do the commit and it
will ask to my sync it will it will ask
to me would you like to sync changes so
yes I want to do it now I will click on
okay so as soon as I will click on okay
you will find out every file and folder
in my repository itself so now let me
show you uh every file and folder uh so
here guys you can see I have a
experiment folder now inside that there
is my file ipv file that's what this
this this file this particular file I'm
going to use for my entire experiments
and all and here you will find out my
SRC folder inside the SRC folder you
will find out the init file and one more
folder that is what that the McQ
generator and then you will find out
this setup.py also so here I have the
setup.py as of now you won't be able to
find out any sort of a code over here
but don't worry I will keep it uh inside
my setup.py file and here you can see my
require. txt so here I have mentioned
all the requirements got it now let me
uh give you this link to all of you so
I'm pasting this link inside the chat
and if you're not able to click on that
so you can search over the Google let me
search in front of you only so just go
through the Google and search Sun Savita
GitHub so once you will search it uh
then automatically you will get a GitHub
link just go through with the GitHub
link and here click on the repository so
here is a repository click on the
repository and the Very first project
this one McQ generator uh so just click
on this uh this particular project and I
have kept each and everything over here
itself inside one folder so if you are
done till here then please do let me
know in the
chat yes in my previous class I shown
you how to use hugging pH API Hub don't
worry uh after this project I will use
the open source model only I w't going
to use any
uh like any model from the openi itself
but yeah in today's project in the very
first project I'm going to use the openi
API along with the Len chain got
it tell me guys uh is it fine to all of
you are you able to create an
environment and uh did you publish
it
have you created a environment did you
created a GitHub um and sorry did you
initialize the a git basically and did
you publish your repository if
everything is done then uh please do let
me know guys I will uh move with a
further step so please uh write on the
chat if uh you are done till here then I
will proceed uh with the further
commands don't worry I will give you all
the thing all the commands and all in
our documented format so you won't face
any such issues at all or in a single uh
like go you can run like each and
everything don't worry I will give you
that first of all tell me uh if you are
able to do along with uh if you are able
to do till here if you are able to do
these many thing then uh please give me
a quick confirmation or if you are
comfortable till here please do let me
know
fine so I think uh we can proceed now so
uh here I have created uh you can see uh
I created uh many files and folder now
let me open this setup. py5 okay so here
I have opened my setup.py file and here
I'm going to write it down uh some sort
of a code so what I can do let me copy
the code uh there is only just one
function and here I pasted the code got
it now uh just look into the code so
what I have written over here so here I
have imported one uh statement uh the
statement is what the statement is a
find package so from setup tool I'm
going to import the find package and
here is what here is my setup here's my
method setup method now here I have
mentioned couple of thing uh so I'm
calling this particular method setup a
method and uh I have mentioned uh some
parameters so the first parameter is a
name so here I'm going to write down my
here I'm going to write down the name of
the package now here is a version
version of the package now here is the
author author is a sunny sun Savita
author email sunny. Savita a and here is
install requirement so these are the
package which is like required okay now
here is a package so find package so
once uh see uh this find package
actually this this particular method
only it is responsible for finding out
the local package for from your local
directory so wherever uh it is able to
find out this dot init file wherever it
is able to find out this dot init file
it will consider that folder as a
package got it now uh here you can see
so I have imported this thing find
package setup uh find package find
package and setup method and I have
written all like these many thing over
here right so this is the like name of
my package uh which I have written over
here right each and everything is clear
each and everything F now see guys if
you want to install this package so for
that there's a command the command is
PIP install package name right I think
you all agree so if you want to install
this particular package open a load Lang
Chen stream late python python. EnV P
PDF so for that there is a command the
command is PIP install and package name
if you want to install this re. txt so
for that there is a command the command
name is what the command name is PIP
install hyr re. txt right but if you
want to install this a local package
into your current virtual environment so
uh how we can do that so for that also
we have a command the command is what
the command is directly you can install
the setup.py file you can write it down
python setup.py install so in that case
it will install or it will download all
the current package from your folder
into the virtual environment got it
that's the first way the second way is
what so here you can write it down in
the requir of txc itself you can write
it down hyph e do
right so uh if you are writing this hyph
e dot so in that case it will search all
the local package all the local package
into your current directory into your uh
current folder and it will download or
it will install it inside your virtual
environment again I'm repeating see if
you want to install this particular
package so for that there is a command
pip install re. TX Pap install package
name if you want to install all the
package by using the re. TX XT so there
is a command pip install hyphen r. txt
got it now but see let's say if you want
to install this local package into your
virtual environment so how you can do
that so for that you have two ways the
first one python setup.py install if you
running this command so definitely you
will be able to install it the second
one is what the second one is you can
mention this hyphen e dot inside your
record. txt so automatically it will
search this it will search out the
packages into your current folder into
your current repository and it will
execute the setup.py in backend got it
great now what I'm going to do here I'm
going to be install this require. txt
and so for first of all let me show you
that what all packages we have inside
the current virtual environment so if I
will write it on the PIP list uh so here
you will find out that we just have this
three packages three to four packages
into my current virtual environment how
many packages this guys three to four
packages only right which comes uh by uh
which is a by default only which comes
uh along with the environment itself
whenever we are going to create an
environment now if I want to install all
these packages into my current virtual
environment so how we can do that so uh
if I want to like run this re. txt so
how we can do that so for that there is
a command let me write down the command
pip install hyr requirement. txt so pip
install hyphen R re txt so once I will
hit enter so here you can see my all the
packages is getting installed into my
current environment so just wait for
some time uh it is getting installed and
uh it will take some time uh tell me
guys are you doing a with
me yes you can use it uh if you want to
make a mini project so definitely you
can use it and even you can create it uh
here itself and you can showcase as a
mini
project tomorrow we are going to deploy
it also after creating a web API and
then uh by using the advanced concept we
are going to create one more application
so how's the session so far uh did you
like the
session tell me guys uh did you like the
session did you like the U like
content
if you're liking the session then please
hit the like
button
yeah still it is installing so it will
take some time I'll let it
install
yes you can go through with my GitHub
link so here is my GitHub link just wait
I'm giving you
that
still it is downloading
uh I think we should wait
more
yeah I think now it is done so uh first
of all let me clear the screen and uh
here uh you will find out that it has
created one folder uh the folder name is
what McQ
generator. eggy info so so it has
created one folder and this folder
actually uh it is having the entire
information regarding your local package
so you can visit and you can check with
the different different files over here
so this is the package information
metadata version this one this is the P
package version right this is the
package name author is sunny and author
email ID reir txt so these are are these
all are the requirements actually right
along with the packages now you will
find out all the like details inside
this particular folder the folder name
is what McQ generator. ayen info it has
created a various file inside that which
is keeping all the or which is uh like
uh keeping all the like meta information
regarding your project got it I hope uh
this thing is clear to all of you now uh
what I can do uh first of all let me
close all the files from here now let me
open my app IP VV file and here what I'm
going to do here I'm going to here I'm
going to like uh run
my uh like import statement so what I
can do I can run import OS so here I'm
going to write import OS import Json
import Os Os means what opening system
and here I'm writing import Json import
Json now here I writing import pandas as
PD pandas as PD and here let's say I'm
writing import Trace bag so these are a
few uh uh like a few packages basically
which I imported over here now if I want
to run it now if I want to run this
particular cell so for that I just need
to press shift plus enter right just
press shift plus enter and you will be
able to run it now as soon as you will
run it it will ask you would you like to
install the IPI kernel yes I want to
install it because without that I won't
be able to execute this particular
notebook so here you need to click on
the install and my IPython kernel ipy
kernel is getting installed guys so it
will take uh some time so let it install
and then I will explain you the further
thing further
concept I given you the GitHub Link in
the chat uh you can search over the
GitHub uh sorry you can search over the
Google s with the GitHub and then you
will get the GitHub link my GitHub link
and check with the very first repository
very first project that is the McQ
generator itself the project name the
folder name is same McQ generator here
you can see this one McQ generator just
search over the Google Sun Savita
GitHub so here you can see my ipy kernel
is getting installed so let it install
and after that I will write it on my
further code and uh let I will show you
uh further concept as well uh regarding
this um and entire project
okay
yeah so now it is done and here you can
see uh we are able to import this a
particular statement import Os Os means
operating system Json pandas and
traceback also now guys here what you
need to do the next uh import statement
which I'm going to write it down over
here which is going to be a opena itself
so here I'm going to use the Len chain
and by using the Len chain I'm going to
import this chat over open API right
because I want to access the open API
and by using this particular method only
I'll be able to access the open a API
now let me run it so it's the same
method it's the same method which I have
shown you in my previous classes so
there I was using the lenin. llm opena
now in the recent version in the updated
version they have given you one more
method it's a similar one only it's
updated one and which is doing the same
thing uh like like the previous one like
the open a method and the method name is
what the method name is chat open AI so
yes uh we are able to import this method
and now what I need to do so uh actually
we this is a this is not a method this
is a class so here what I'm going to do
I'm going to create a object of this
particular class now so for that let me
copy it and let me paste it over here so
this is going to my llm so by using this
particular uh method itself I will be
able to call my open API and I will be
able to collect the llm model inside my
llm variable right so for that I need to
mention couple of uh couple of parameter
so here I'm going to mention few
parameter let me do it over here so
these are the parameter guys which I
have mentioned over here so the first
parameter is going to be open a API key
and here basically I need to mention the
key key of the open a open API now after
that uh there is a model name so here
I'm going to use gpt3 .5 turbo model and
then uh I I I have created one more
parameter I I'm going to write down one
more parameter that is going to be a
temperature you know what is the meaning
of temperature so here I'm going to set
the value 0.5 so between 0 to two you
can mention any value of the temperature
so what is the meaning of that the
meaning is nothing meaning is very very
simple you are going to like you want to
create a model if you are mentioning uh
like if you're mentioning the value near
to two right so the range is from 0 to
two if you are mentioning the value near
to two this will be more creative if the
value is will be near to zero so the
model will be less creative it will give
you the state forward answer that's it
now here guys this key will be required
this open AI key will be required how we
can get the open key I shown you how to
generate open key in my previous classes
right again I'm not going to show you
that now here actually I'm going to
collect my openi key but this time I'm
not going to paste it directly over here
instead of that what I'm going to do I'm
going to use my OS module so here what
I'm going to write it down I'm going to
write it down this a particular uh
method I'm going to call this os. get
environment method that uh os. get
environment key method so here I'm going
to call this os. getv and here uh this
is what this is my environment variable
so what I can do guys I can create uh
environment variable I can create one
environment variable into my uh Windows
environment variable and I can read it I
can read my key from there okay I can
read my key from there the second way I
can export it temporarily right so here
I can U on my uh terminal itself I can
write it down
export and here I can mention this a
variable name open API key and I can
pass the value in that case also I will
be able to read it the third Third Way
is there the Third Way is like you can
create your EnV file right you can
create your local environment file and
there inside that particular file
whatever a variable is required whatever
important variable is there you can keep
it over there itself right the first one
is a global approach uh Global means
what so here if you are going to search
environment variable in your windows
search box so you will get the uh you
will get the uh environment variable all
the list of the environment variable
here you can see right so you will get
the list of the environment variable
this one right this one now here you can
see I I created one key and I keept it
over here so from there also I can read
it from there also I can read it by
writing a same thing I I just need to
mention the key the key name over here
the second way the second way is a
temporary way temporary way means you
can export the key over here Itself by
using the export command you just need
to write down the export and here you
can mention the variable name and you
can pass the value of that particular
variable that's the second way now the
Third Way is what here you can create
EnV file so EnV file in your local
repository itself so no need to create
any sort of a variable in your
environment variable here itself inside
this EnV file itself you can keep your
all the variable all your secret
variable and by using the same command
you can read it so that is the third way
so I'm going to select the third way the
third option so here I'm going to create
the EnV file okay so EnV file uh so this
is what this my EnV file and inside this
EnV file I'm going to keep my key so I'm
going to write down the key value and
the variable name is going to be a same
so let me copy the variable from here
the variable is going to be open AI API
key and let me keep the variable over
here and here I I'm going to write down
the value of this particular key so in
the double code actually I'm going to
write down the value
so let me paste my key over here I
already generated it uh I believe you
know how to generate the key so let me
copy and paste it over here so this is
what guys this is my key which I already
generated now let me open my file and
here what I'm going to do I'm going to
read my value the value of this key so
you can treat this EnV file as your
local environment right so which you
have created inside the folder itself
and there you can keep your all the
secret variable right so now if I'm
going to run this OS os. G EnV now if I
will run this particular command now if
I'm going to print the key so here you
will find out my key value so here guys
uh here is what here is my key open a
key now let me show you and here it is
giving me none uh let me run it again
why it is not going to why it is not
getting it now let me show you it is
none wait guys let me restart the
terminal it happens in this vs code
actually sometimes I have seen but okay
so fine I forgot to do one thing uh why
I'm getting this none why I'm getting
this none because I need to load this
environment first all right so I need to
load this environment first and for that
uh I will have to import something see I
already written one module
python.
EnV right so here I have written the
module python hyen do T EnV let me show
you this module so here uh let me open
the Pi Pi first of all and here I can
show you the module uh just a
second Pi Pi now let me show you this
particular module python hy. EnV uh see
python. uh EnV reads key value pair from
a EnV file and can set them as a
environment variable right so it helps
in a development M or application uh
following the 12 Factor principle so
here you can read everything about it if
your application takes configuration
from the environment variable it's a 12
Factor application launching it in a
development it's not very practical
because you have to set those
environment variable yourself means you
will have to set the environment
variable in your local system um okay if
you don't want to do it you can create
the EnV folder in your local so that
will be your local environment file
local environment file itself which will
be available inside your local uh like
reposit itself in your local folder
itself got it now here the first thing
uh see first you need to import this
thing this from. EnV import load. EnV
and then you can you have to call this
uh particular method so what I'm going
to do here so I'm doing a same thing uh
where is my vs code here is my vs code
I'm going to do a same thing just a
second I'm going to load it uh I'm going
to load this uh EnV
so here from EnV this is my EnV file
from EnV I'm going to import a load. EnV
and here is what here is my method so as
soon as I will run it so here I will be
able to load my all the values from this
EnV file now let me run it h let's see
whe whether I'm getting the value or not
so it is saying this OS is not defined
so first of all let me import the OS
this is also fine this is also fine and
now each and everything is fine
now what I can do now I can call it and
let's see whether I'm getting my key or
not now see guys I'm able to get my key
from from my EnV file so here is my EnV
file and from here what I'm getting I'm
getting my key right now let me keep
this EnV in my do getting so I can push
my changes in my ga in that case you
won't get this uh key actually you you
will just get like uh the other file so
here I'm writing do EnV and once I
return it now it you can see it is not
going to track it uh at all so now uh
you want you will find out that there is
no such color anything and now what I
can do I can give you all the files and
all other files basically so let me
click on the
plus
yeah now let me commit it so here I'm
going to write it down of file updated
file
update and let me commit it and sync
changes now click on okay and here guys
you will find out my entire code Let me
refresh it now
and yes that is the entire code so I
think
uh you got the code over here set the
yeah so here is a key let me remove it
from here just a
second
yeah now it
gone so tell me guys uh are you able to
follow till here here uh did you get the
entire code the code which I shared with
all of
you please uh do let me know in the chat
if you got the code
then here I kept the entire code uh in
my GitHub
itself yes uh yes or no please uh write
it down the chat guys please uh do let
me know just search over the Google s
Savita GitHub and there you will find
out this McQ generator repository in my
repository section and here is the
entire
code if you are done till here then
please uh give me a confirmation so I
will proceed with a further uh further
concept
done done done
great fine so now let's start with the
implementation so till here actually I
just shown you the uh I just shown you
the environment setup and all now we are
ready for implementing the
project okay so within uh this uh within
this one hour actually I just shown you
the entire setup now this is the onetime
job I set up my entire environment now
let's start with the Practical uh now
let's start with the experiments and all
and in tomorrow's session I will create
uh the I will create the Modular One
modular project and there I will create
the steam allet application also and
finally we'll try to deploy it now here
uh you can see uh now each and
everything is done let's try to call
this a chat open a method and let's see
we are able to access the llm on l so
here you can see it is running and now
it is done so if you will look into this
llm llm now here you can see we are able
to do it we are able to call it now here
let's try to run the further code now we
are going to use all the concept the
entire concept whatever we have learned
throughout the community session right
throughout the throughout this community
session in our open in the lch so we we
are going to use those entire concept
over here now uh for that basically what
I'm going to do step by step I'm going
to write it down each and everything so
first of all I am going to import each
and everything in a single shot right so
here uh you can see I have imported all
the statement so this Trace back and all
I'm going to remove it from here which I
already did it this is also I already
imported now let me remove this also and
here uh just chat open a also I already
imported now uh here this open a prompt
template l CH sequential and this get
open a call back this is very important
uh this is very important class which I
imported over here uh I will show you
the name I will show you the use of this
particular class this C openi call back
in a very detailed way because it's
going to be very very important right so
far I haven't discussed about it I
discussed about the sequential chain I
discussed about the llm chain I discuss
about the promt template but I I haven't
discussed about this get openi call back
so now let me import import all the
statements over here so you can see we
are able to import it and yeah it is
done now we already created a object of
this chat open Ai and we are able to get
my llm by using this open AI API till
here I think everything is fine
everything is clear now let's move to
the next one now just tell me guys if we
are talking about so here what I can do
let me open my pen and let me ask a few
questions to all of you so here uh what
I'm doing uh just a
second yeah so here uh just uh let me
ask a few question so let's say we have
imported the llm means uh we are able to
access my llm this uh GPD model by using
this uh open AI or API by using this L
chain framework now to this llm what I
will do what I will pass to this llm
tell me so to llm to this particular llm
I will pass my uh prompt right I will I
will pass my input prom so here actually
what I will have to do I will have to
design my input promt right what I will
have to do guys tell me I will have to
design my input prompt and here as a
output what I will get tell me as a
output also I will get a prompt right so
here what I will have to do I will have
to design my input and output prom right
so so whatever my whatever will my input
so that particular prompt and here
whatever will be my output that a
particular prompt got it now let's try
to design my input prompt and let's try
to design the response as well then in
which format I will get the response so
here initially I clarified this thing
the project is going to be a McQ
generator right I am going to generate
McQ McQ right whatever topic whatever uh
subject I will give to my uh GPT model
so So based on that particular subject
based on that particular uh like based
on that particular text is going to
generate a McQ so let's say I'm giving
my paragraph I'm I'm giving one
paragraph to my GPT model So based on
that particular paragraph let's say I
given a paragraph related to our data
science uh okay I I I given one a PDF
file or text file or whatever file to my
GPT model so in that inside that like
you have a paragraphs you have a data So
based on that data is going to generate
a mcqs right so let me do one thing so
here uh first of all let me design my
prompt so here what I'm going to do guys
I'm going to design my prompt by using
this a prompt template I think you
already know about the prompt template
in my previous class I already clarify
the uh the concept of the prompt
template if you don't know then please
go and check with the previous session
so here what I'm going to do guys here
I'm going to Define my prompt template
so just wait uh let me copy and paste
the code because already I written this
uh like a single single line so let me
copy and paste and I'm going to explain
you so here my prompt is what so here my
prompt inside the prompt actually you
will find out in the prompt template you
will find out two things first is a
input variable and the second is
template right so here you can see as a
template I given this particular
variable now to this particular variable
I have to pass some sort of a text right
some sort of a like a template and all I
will pass it just wait right so here is
my template variable and I will pass my
template over here here I'm not going to
write it down directly here I'm going to
pass it to my variable and that variable
I I'm passing inside my prompt template
right now in an input variable you can
see we have a couple of we have a couple
of variable we have couple of parameter
the first one is text the second one is
a number the third one is a subject the
fourth one is a tone and the fifth one
is a response J so we have a five
variable inside my input variable in my
previous classes uh I shown you this
prompt template along with the uh simple
input variable along with the one input
variable right now here inside this one
I have written five input variable and
here I'm going to Define my template now
let's see what will be my template so
from here basically I'm going to copy
the template and let me paste it over
here so I'm saying to my chat GPT so I'm
saying to my chat GPT that uh you are
expert McQ maker right so I'm giving my
a text so on whatever text I want to
generate an McQ I'm passing a text over
here right and I'm saying to my chat GPT
that you are an expert McQ maker given
the abob text so whatever text we have
given to you it's your job by using this
particular text it's your job to create
a quiz of number so how many quiz you
want to create so five quiz six quiz
seven quiz eight quiz you can pass a
number over here so 5 six seven quiz
eight quiz so you can pass the number
and here uh you need to create a five
multiple let's say I'm writing number is
equal to five so five multiple choice
question for the subject now whatever
subject we are going to pass over here
in tone so tone means what tone actually
it is defining a difficulty level so
here if tone is simple so it is going to
generate a five simple McQ question if
tone is uh intermediate so it is going
to generate five intermediate question
if tone is difficult it's going to
generate five difficult in five
difficult McQ question got it now here
I'm saying make sure the question are
not repeated and check all the question
to be confirming the text as well so
each and everything I'm telling to my
GPD right so make sure to format your
response like so here actually I have to
for I have to pass the format also here
I'm going to pass here I have to pass
the format also like in which format you
have to generate a quiz now let me give
you the format now let me show you the
format so uh which format actually I
have designed over here so here what I'm
going to do I'm giving you the format
the format basically which uh I have
designed so let me show you the response
format now guys this is the response
format just just see over here see so
response or it's my response format so
here I'm saying uh like there is my McQ
multiple here I have written first okay
this my first mean like it's a number
itself that's it now here I'm seeing McQ
multiple choice question now here is a
option that uh you have a four Option 1
2 3 4 and here basically I will be
getting my correct answer so it is this
one this one actually this is my first
McQ along with the number along with a
question along with the number this is
my first McQ first McQ now here will be
my McQ now here will be my all the
options and here will be my correct
answer right so this is my response
format and here is my template basically
which I'm passing to my GPT model and
here uh I'm going to create my prompt
template that's it by using this
particular template and these are the
these are the variable which user is
going to pass right which user is going
to pass these are the variable now let
me do one thing let me run it and here
you can see we are able to create a like
temp we have like written a template and
this is what this is my prompt template
which I created that's it I think this
is fine now here uh yes once it is done
uh like uh my template and all basically
it will be created that is fine now
after that what I'm going to do I'm
going to create the chain right I think
you already know about the chain llm
chain I I explain you the concept of the
llm chain that why we use llm chain we
use llm chain for connecting a several
component so here as of now I just have
two component first is llm and the
second is prompt so I'm going to connect
both component all together and for that
I'm going to use llm chain so let's try
to use the llm chain and and here I have
already written the code let me copy and
paste it over here and so this is what
guys this is my uh like this is my uh
like llm chain so here I'm passing my
llm model with whatever model I took by
using the open API and here is what here
is my prompt so prompt is what so quiz
generation prompt so the prompt which I
have created by using this particular
template and by using this particular
response right in this format basically
I want a response now this is what guys
this is the llm chain all the concept
see whatever I have we have learned so
far I'm going to use all those concept
for creating this a particular project
right so so at least you can understand
that where we are using uh like those
Concept in a real time right so here is
what here is my question now let me run
it and here I have created my question
that is fine now guys just tell me uh
here uh I'm creating my quiz right so
here I'm creating my quiz now here
actually see I created a quiz but this
quiz is correct or not the basically in
the at the end you can see in the format
I have written this correct answer I
want a correct answer from it so after
analyzing a quiz actually I want a
correct answer so for that also I have
defined one more template now let me
show you that template so what I did
actually let me show you the template
two which I have created uh so here I
have created the second template now in
the second template you will find out uh
just a second let me copy all the like
thing over here and see this is what
guys this is my second template now here
I'm seeing here I'm saying actually uh
you are an expert English grammarian and
writer I'm telling to my chat jpd I'm
telling mypd actually so given a
multiple choice quiz for this particular
subject right this particular subject
now you need to evaluate the complexity
of the question and give a complexity
analysis of the quiz right give that
complexity analysis of the quiz only use
at Max 50 words for complexity if the
quiz is not at for the quantitive and
the analytic ability of the student
update the quiz update the quiz question
which needs to be changed and change the
tone such as uh such that it perfectly
fits to the student ability so here I
have written so here actually see here
I'm passing my quiz whatever quiz
basically I'm generating so in this
second template I have written that uh I
have written the like prompt regarding
to the evaluation regarding to the quiz
evaluation whatever quiz I am going to
generate right first I will generate and
then I will evaluate it here in the
second prompt now let me run it and here
I'm going to create my one more chain so
here I'm going to create uh so here
basically uh before create cre a chain
basically uh let me create just a second
so here uh what I'm going to do I'm
going to create my template so here in
the template you will find out only two
variable first is subject and the second
is quiz this two variable it is coming
from the user side I will show you how
like it is coming from the user side and
how user will be passing once we'll be
creating a end to end application got it
now here we have a quiz evaluation
prompt and this is what this is my
second prompt and now what I will do
regarding this prompt also I will create
my chain right so here uh here is my
quiz chain now I'm going to create one
more chain that's going to be a quiz
evaluation chain so let me uh like uh
copy this particular code step by step I
have written each and everything and
that is what I'm going to show you so
here is what guys here is my review
chain right so in this one I'm passing
my llm I'm passing my quiz Evolution
prompt and here output key is What so
whatever output I'm getting as a review
so here I'm going to collect it inside
this particular variable and verbos is
equal to True means what means whatever
ex means during the execution whatever
is happening now each and everything I
will be able to find out on my screen
itself that's the meaning of verbos is
equal to two that's it now here if I'm
running this review a chain so I have
created two chain now now after creating
this th I have created First Chain quiz
chain I created second chain review
chain now I'm going to connect both
chain right by using sequential chain so
the same concept I taught you in my
previous session so first I created one
chain where I'm going to add two
component llm and my uh prompt I have
created second chain and now I'm going
to collect both chain right both Chain
by using the sequential uh by using the
simple sequential chain now here what
I'm going to do so here already I have
imported this thing if you look into my
import statement so I have already
imported this sequential chain now let
me create a object object of this
sequential chain and then uh I'm going
to write it down the both name over here
so here what I'm going to do so let me
uh create object of this sequential
chain now so here guys you can see we
have a sequential chain and to this
sequential chain I'm passing the quiz
chain I'm generating a quiz and I'm
passing to my review chain right so from
here I'm generating a quiz and I'm
passing to my review chain and these all
are my input variable and these all are
my output variable and verbos is equal
to True right clear so here I'm going to
create a object of this same sequential
chain I hope till here everything is
fine everything is clear to all of you
please do let me know I use the uh
previous Concepts only I haven't I
haven't taught you anything new uh I use
the previous concept whatever I taught
you in my previous classes so please do
let me know if this uh part is clear to
all of you yes or
no it's very easy very simple don't
worry at the end I will revise all the
concepts uh whatever I'm using here
whatever I'm writing over here but first
tell me is it clear or not this
one if you can write it down the chat I
think that would be great you can hit
the like button you can let me know in
the chat so please do it guys uh I'm
waiting for a
reply because after uh this one the
climax will come and in that like we are
going to create a quizz and all whatever
is
there clear clear clear yes or
no yes saan your understanding is
correct first combining two template
using llm chain and then two H chains we
are going to combine by using the
sequential chain
okay
okay now uh I think till here everything
is fine everything is clear now let's
see how we are going to gener a quiz
from here after giving this many of
things after doing this many of things
so we are able to uh we are able to like
uh here you can see we are able to
create a sequential chain now the next
thing is what here actually what I want
guys tell me I want a text I want a data
so if you have a data in PDF you can
load the PDF if you have a data in txt
file you can load the txt file right if
you have data in some other file you can
load the data from there from anywhere
right so first you will have to provide
a text you will have to provide a data
on top of that data you are going to
create or you are going to generate a
quiz right so let me do one thing here
I'm going to create uh I'm going to
create one file the file name is going
to be uh wait I'm going to create one
file the file name is going to be
data.txt so data.txt
now what I'm going to do here uh I'm
going to open my Google and from there
uh I'm going to copy and paste some sort
of a text so let's say I'm searching
about the machine learning machine
learning machine learning so here I'm
going to search about the machine
learning now here uh is what here is my
machine learning now from here what I'm
going to do so here I'm going to take
all the data for this one right so I
took this particular data I'm copy I'm
going to copy it and let me paste it
over here where I'm going to paste I'm
going to paste in my data.txt so this is
the complete data which I have pasted
over here you can check it you can
reveal this file in your folder so click
on reveal in file explorer you will find
out this particular file uh this
data.txt right just open it and here is
your data which I copy and paste it from
the uh like Google itself from the
Wikipedia right great now let me close
it and here here is what here is your
data now do one thing let's uh do one
thing so let's try to read this
particular data so here what I'm going
to do so here uh let me open my file
ipynb file and here I'm going to read
this particular data so for reading a
data actually we have a we have a like a
code so let me write it down the code
over here so I'm writing over here you
need to open this file in a read mode
and just read the data in this
particular variable now here I need to
provide the file path so for providing a
file path let me write it down here file
underscore path and here uh R means what
R means read it and there I'm giving my
absolute path so here I'm passing the
complete path of the file so this is the
file path guys which I have given or
which I have written over here now let
me run it and let me check with the file
path that I got it or not so here what I
can do I can uh check with the file
underscore path now let me run it and
see guys this is what this is my file
path now I'm uh running this particular
code and here you will find out inside
the text what I got I got my data so
here is what here inside my text you
will find out you uh we have the entire
data now let me print it let me keep
this text variable inside the print
method so see guys I got the entire data
so whatever data I kept it inside my
file inside my txt file so you can see
all the data over here itself got it now
after that what I will do see now there
is a crucial part and there you will
find out the new thing right and one
more thing let me do one more thing over
here so see I created a response I
created a response here is what guys
tell me here is my response now this
response actually it's a
dictionary this is what this is a
dictionary right this one now over here
if I want to convert into a Json
serializer so for that there is a method
json. terms and here actually I'm
passing this dictionary now why I'm
doing it so here if I want to serialize
the python dictionary into a Json format
so here U into a Json format is string
so that's for that's why for that only
I'm going to call this particular method
json. dumps right so here uh I'm going
to call this json. Dums and here you
will be able to find out I'm going to
convert this a particular dictionary
this python dictionary into Json format
his string right this is fine this is
clear to all of you we got a text we got
this dictionary and we got a chain now
my final step will come into the picture
now let me show you my final step so
over here uh my final step is this one
now just just be careful guys and after
that my response will be coming and I
will be able to generate my output so
here guys see uh in the final response
you will find out that we are going to
call this get open Ai call back right
right this is a new thing for all of you
and here I have already imported this
get open Ai call back if you will look
into the import statement here a from
blanchin do callback get open call back
so here you will find out I'm U like
calling a same thing I'm calling this
get open Ai call back right now inside
this get open a call back you will find
out that we are going to call our
generative evaluated generate generate
evaluate change so this is the same
thing basically uh the same variable
over here you can see this one uh like
after creating after creating this is
the object actually generate uh generate
evaluate chain this is what tell me this
is the object object basically which I'm
keeping over here sequential chain is a
class right where I'm passing this
particular argument and this is what
this is my object this one generate
evaluate chain now I'm calling this
particular object over here this one
right this this particular object I'm
calling over here this is fine this is
fine this you are able to understand and
here we are getting a response after
calling but what is the meaning of this
C open Ai call back why we are using it
so just see over here I have written
something over here how to set up token
uses tracking in L chain so if you want
to understand the token uses if you want
to track your tokens and all input token
output token your pricing each and
everything each and everything you will
get by using this get openi call bag you
can check it by using this link which I
kept it over here here is a
documentation link so let me copy and
paste it over here over the browser and
here actually you will find out a
complete detail about this G openi call
back so let me show you so here is
tracking token uses so whatever number
of uh token you are going to use what
will be the pricing input token number
output token number everything you will
get it over here by using this get openi
call back right so just see over here we
are going to import it we are going to
create our llm we are going to got get
we are going to get our llm over here
and here we are going to call this
invoke method and there is my result now
if I'm going to print the CV so here you
will get the entire detail regarding the
token let me show you in terms of my
code right so whatever code and all
whatever like project I'm going to
create regarding that now before that
just see over here uh generate evaluate
chain this is what this is my object now
here if you will look into this
particular object so we are we have a
couple of input variable the first input
variable is text that is the same thing
the text itself right text you know
right which one uh what is the text like
whatever uh which one this text actually
so whatever uh like uh data right we are
passing for generating a McQ right on
whatever data we want to generate McQ
this this this takes actually now here
is a number how many McQ you want to
generate subject tone simple Simplicity
hard intermediate and here is what here
is a uh like request response so I will
have to mention everything over here
inside this variable so json. dumps
already we did it text we already did it
now let me Define this number subject
and tone so here let me take it as a a
variable so here guys you will see that
we have a number we have a subject and
we have a tone so number how many uh
quiz you want to generate I want to
generate five quiz here subject let's
say subject is machine learning let me
change the subject I'm going to keep as
a machine learning so here the subject
name is machine learning now uh here
Stone actually tone let's say it's a
simple one simple McQ I want just like a
simple McQ now if I will uh like run it
so here I have initialized my variable
now guys if I will run this one now you
will find out that everything I'm going
to get in my response itself so let me
run it and see so it is running and guys
over here you can see this is still it
is running and it will take some time
because it is evaluating each and
everything in back end whatever template
whatever prompts I have given and based
on that it will generate a response it
will generate a McQ so just wait for
some time and it is working working
working yeah now it is done guys see we
we got a response and inside this
response I have everything but before
showing you the response let me show you
something over here so here what I'm
going to do here I'm going to show you
the number of tokens number of tokens uh
input tokens output tokens and the
complete cost right so here what I'm
going to do let me copy the code uh
which I already written and it's a
simple like lines and all I'm just
copying pasting because I don't want to
waste the time okay because if I'm
writing it from scratch it it takes
takes a time right so here uh I'm saying
total number of tokens input token plus
output token now here prompt token and
prompt completion mean this is the input
token and this is the output token and
this is complete number of token and
here there is a total cost now if I will
run it guys so here you will find out
that I this is my total number of token
this is my input token this is my output
token and this is the cost and it is in
dollar so I'm able to track each and
everything by using this uh open a call
back getting my point now let's try to
get a response so let's try to uh get a
response from here uh so let's try to uh
get a quizzes and all so first of all
let me show you the response so if I'm
going to print the response now so you
will find out uh it's nothing it's the
uh dictionary itself right so inside the
dictionary uh you have uh different
different key and value now in this
dictionary you will find out one key
quiz right so if I'm going to write it
down here so here if I'm going to write
it down response. response. getet quiz
so if I'm going to write down here
response. getet quiz now see guys here
I'm able to get my quiz here I'm able to
get my quiz right so what I'm going to
do now I'm going to keep it inside my
variable my variable is what quiz this
is what this is my quiz right now what
I'm going to do here I'm going to write
it down Json json. load right Json do
loads and here I'm passing my quiz q i
now once I will write down like this so
you will find out my all the quiz so
here this is my first quiz and it is in
the same format it is in the same format
the response format which I have defined
so this is my first quiz and here is McQ
who coined the term machine learning so
Donald have Arthur Samuel Samuel Walter
pittz and Warren mlo right so here there
is a correct answer now here the second
quiz what was the earliest machine
learning model introduced by the Arthur
Samuel so speech recognization image
classification so you can see guys your
entire quiz over here whatever number I
have given I have given five number I'm
able to generate a five quiz from the uh
from the GPT model by giving a correct
prompt and by giving a correct uh like
response format so there is uh you just
uh required a python over here that's it
nothing apart from that and you will be
able to create the project a project
according to your requirement and this
type of project you can integrate
everywhere let's say uh uh like in a
dashboard itself in your dashboard you
will find out the quizzes and the
assignment so you can automate that
project uh that process you can generate
a quizzes and all from here uh right and
then you can append it inside uh the
dashboard and all so uh like something
like that you can make a real-time
connectivity I think you are getting my
point now let's uh look into the uh let
let's try to create a data frame by
using this uh dictionary so for that
what I'm going to do so here uh I'm
going to create a data frame uh just a
second uh first of all let me keep
everything inside the list so for that I
already written one code so here is the
code guys uh here I'm going to create uh
let me do one thing Let Me Keep It Quiz
only so here is what here is my list and
inside this list we have our items means
uh my quiz and my uh basically value
okay means my options now here actually
I'm going to keep it in a particular
format whatever string I'm going to to
be collect from here I'm going to join
in by using this pipe and here I'm going
to append it everything now let me run
it and you will get a better
understanding so if I'm going to run it
now see uh so it is giving me St Str
object has no uh attribute
items what is the issue over here okay
so just wait uh let me keep it over here
inside the quiz itself and
now I think it is fine so just a second
mm
mhm yeah now is fine so if I'm going to
show you this quiz table data now now
you will get all the thing over here so
yeah now I got each and everything in a
list and see every value every option we
are going to segregate by using this
pipe and for that only I have written
this code once you will go through it
you will be getting it now I can convert
it into a data frame so here uh let me
convert this uh thing this particular
thing in into a data frame so here if
I'm going to write it down
PD do data Frame data frame and here I'm
going to say that okay I'm going to uh
open the parenthesis and
[Music]
then yeah so here guys see this is my
McQ means there is my question here is
my choices there is four choices and
here is a correct answer now let me keep
this thing in my uh variable that is
going to be a quiz and and now let me
convert this uh data frame as a CSV file
so here I'm going to convert this data
this uh quiz actually into a CSV file so
quiz do 2or CSV and here I can write it
down the name and the name is going to
be a machine learning quiz so machine uh
machine
learning. CSV right machine learning.
CSV index is equal to false index is
equal to false now if I will run it guys
see in my current uh directory in my uh
like current local directory you will
find out this CSV file now let me open
the CSV file and here you can see my
quiz I just given the number of quiz how
many number of quiz I want uh see uh if
you will look into the code now now you
will be getting that uh this this number
actually this this thing basically which
I will I was providing to my um like
object this one number of quiz sub
object and toone so this is the only
thing which I want from my user and for
this one only I'm going to create my web
application as of now I shown you the
simple implementation in the python
notebook in ipb itself now in tomorrow's
class what I'm going to do so here I
have created the folder the folder name
is what SRC folder and inside that I
have a McQ generator now each and every
line of code I'm going to write it down
my py file I'm going to create a modular
coding I I'm going to write down the
modular coding here and then finally we
are going to create a web API right web
API and uh here U like yes by using the
B API you just need to pass this
particular value number of quiz you just
need to pass this 3 to four value you
need to pass the text this particular
text you need to pass the number of
quizzes subject and the tone that's it
and you uh and after that once you will
hit the button so the qu will be in your
hand this
one got it yes or no tell me guys so how
is a project uh did you like this tell
me do you like this Jupiter
implementation yes or no tell me guys
fast do you have any any like uh any um
that doubts and all so please do let me
know I will be clarify that and uh don't
worry you won't face any sort of issue
so whatever step I followed just
followed those step and try to do this
uh um this notebook implementation at
least and tomorrow we'll convert this
notebook implementation into an end to
end project so let me give you this code
now so here I can uh add it this file
this file and this file also so I added
this three file now let me write down
the message all files updated updated
okay so just a second all file
updated and here let me commit it and
sync the changes so now guys just check
with the GitHub you will get the uh
files and all right let me show you the
GitHub now and here is my
GitHub so guys uh just check with the G
here you will find out the CSV file
quizzes and all uh and here see quizzes
Which I generated by using the GPT and
here actually there is a ipv file where
you'll find out the entire
code
okay yes it is generating a quiz from
the text itself so let's say if you are
giving this part let's say any different
text so let me do one thing let me give
the different text over
here uh so just a second I'm going to
generate a different text
now uh so any topic uh uh any topic
basically anything you can uh like
search over here let's say you are going
to search about the biology so
biology uh Wikipedia so just search
about the biology and here open
the like Wikipedia page copy it from
here copy it as of now and just keep it
over here inside the text inside your
txt file now see we'll automate this
particular process so you don't need to
paste it like this you just need to uh
give your documentation to your
streamlet application or to your flask
application or Jango application we'll
automate that particular process don't
worry and even we can automate like many
uh instead of providing this particular
text and all right no need to provide
this text by writing directly by writing
the name also we can generate a quiz
okay that is all also possible that is
also possible as of now I'm giving my
text and based on that see this is the
biology text right now what I can do I
can just need to open my uh IP VB here
and after that I just need to load this
text so here I'm going to load my text
this one and I'm going to change my
subject so instead of this machine
learning I'm writing here
biology right I have written biology
over here let me run it so here I got uh
the biology text this is the biology
text and uh yes uh I think now
everything is same this is fine this is
fine now let me run it so here if I'm
going to run it so now it is generating
mcqs from those particular text whatever
text I have given regarding the biology
and all so it is taking that text and it
is generating a uh mcqs and all so it
will take some time let it
run and then you can save uh this file
over
here so now it is done uh it is getting
we are getting some issues
incorrect API key
provided okay it is saying incorrect API
key provided I think some issues there
with the API key but yeah the process
will be same right I will check with the
API key issues what is this uh now see
guys uh I think you got my point you got
the like concept and you got about the
project also and today we are going to
create in2 and one and we'll try to
deploy it also so don't miss tomorrow's
session tomorrow's class uh great so I
think we can start with today's session
uh now in today's session uh again uh
we'll uh try to complete our project
itself so in previous class uh we have
started our uh end to end project uh in
that I have explain you the uh Jupiter
implementation so we did the entire
project setup and after that uh we did
the we implemented our jupyter notebook
now in today's session we are going to
create we are going to write it on the
modular coding modular code and there we
are going to create a several file and
uh I will show you how you can create a
different different file in a different
different folder and then how you can
create your streamlit application and if
uh time will permit so definitely we'll
try to deploy it also and for the
deployment we're going to use
AWS okay so uh don't worry I will write
it down like uh each and every line in
front of you only and uh and I will
clarify the agenda but before that uh
let me show you the resources and all so
where you will find where you can find
it out all the resources so for that uh
let me go through with the Inon website
and here you can search generative AI so
just search about this generative Ai and
there you will get the dashboard so here
we have two dashboard one for the Hindi
and the second for the English so just
click on this English uh this uh this
particular dashboard and here click on
this go to the course so uh let's say if
you are enrolling for first time if you
are opening first time then it will ask
you for the enroll uh for the enrollment
and uh you no need to pay anything it's
completely free so you can enroll to
this particular dashboard and you can
open it so let me open the dashboard so
here is my dashboard guys uh you can see
all the recording we have updated all
the recording whatever thing I have
covered so let me uh show you the
resources as well I think day six
recording is not available over here so
don't worry it will be up uploaded along
with the recording you will uh find out
the assignment and the quizzes also and
where you will find out the resources so
let's check with the day five so uh here
in this uh video right so once uh you
will click on the video uh so here you
will get a different different option
related to the video so just click on
this resource section and here you will
find out all the resources so whatever
thing I'm discussing in the class itself
uh whatever uh like code and all
whatever I'm writing here so uh I'm
going to uh I'm going to upload each and
everything here inside this resource
section so from here itself from the
resource section you can download it got
it yes or
no great so from here you will get the
resources and all and yes U videos is
available over here recorded videos is
available over here and apart from that
you will find out over the ion YouTube
channel so just go through with the Inon
YouTube channel U and there uh go inside
the live section there you will find out
all the recorded video so let me show
you that so visit the Inon uh YouTube
channel and here click on the live
section this one so you will find out
all the videos all the like lecture or
the live lecture which I uh took so far
and here is a day six lecture where I
have started with a project so in this
lecture till day five actually I have
complet completed the Lin first I
started from the introduction then I
went to the open a and then I uh started
with the different different concept of
the Lang and then I move to this uh
particular project the project uh which
I have started that was the McQ
generator by using open a and the Len
chain so here uh you can see I have uh I
shown you that how to do a complete
project setup and even I shown you how
you can push it over the GitHub and all
how you can insize the gate each and
everything I shown you over here and
then uh I shown you the uh Jupiter
notebook implementation so just go
through with this particular video there
you will find out uh like each and
everything uh now uh what we can do we
can start with the remaining part of the
project so here in this uh particular
project so we have created a several
folder now in front of you only I'm
going to create few more file and there
I will be writing my code and finally
we'll try to create a web application
and if time will permit so definitely we
are going to deploy it also so the
agenda is clear to all of you yes or no
please uh do let me know in the chat
please do confirm in the
chat
yes
how long this course is going to be so
the course uh I I have planned two more
end to project so I have to take few
Advanced concept like uh Vector database
R and few open source model and after
that I have planned two more end to end
project so you can assume that uh like
more 8 to 10
days got it so um I I will take two more
end to end project and this is just a
basic project actually after completing
all the concepts and all I taught you
this one but yeah after that I will
complete one project along with the
flask API and I thought one more project
along with the vector database R concept
and the fast
API
okay great so let's uh begin with the
project and here uh what I can do
so just a second just allow me a
minute okay so I already given you this
particular project and if you want this
project uh this project actually so from
where you can get it uh let me show you
so this uh project already I have
uploaded on my GitHub so just uh try to
go through with my GitHub and there you
will find out this particular project
and for that what you need to do just
open your Google and search Sunny Savita
GitHub okay so open your Google and
search Sunny Savita GitHub and after
that you will find out my GitHub so just
click on that uh click on my GitHub and
here go inside the repository here
inside the reposit
and click on this very first link this
McQ generator so just open this one and
here you will find out this particular
project so whatever I'm uh doing
whatever I'm uh whatever code and all
I'm writing I'm pushing in my this
repository so I'm giving you this
repository in the chat section if you
are able to click click on it so that is
fine otherwise you can search over the
Google and directly you will find out
this repository in my uh repository
section got it so from from here itself
you can download the project so you can
download it or you can clone it anything
is fine now uh let's start with the
remaining part of the project now here
guys see I created a couple of uh folder
I have created couple of like files but
let's try to uh uh do something more
over here so as I told you this uh
project is going to be end to end so
here actually see I created the ipv file
so each and every experiment I performed
over here so I I return like some sort
of a line of code here and then uh I
called my openi API and then I generated
the mcqs and all here I have stored
inside my CSV each and everything I did
in my previous class now if I want to
convert this project if I want to uh
like uh convert this project into an end
to end project so for that uh I will
have to create few more file over here
so here guys if you will look into this
SRC folder so here I have created one
folder that is what that is an McQ
generator now inside this McQ generator
I'm going to create few more file so you
can do along with me if you have
completed till here so uh here actually
you can see uh like uh whatever thing I
have done in my previous session so you
can find out each and everything over
here if you have completed till here
then you can proceed along with me now
what I can do so here uh let me create a
few file inside this McQ folder inside
this McQ generator the first file which
I'm going to create over here that's
going to be a logger file so here let me
create the logger file logger py because
each and everything uh let's say
whatever code I'm running and uh
whatever thing I'm going to execute
inside my project so I'm going to log
each and everything so for that this
logger file is very much important so
here I'm going to Define my logging
object and directly I will import this
logging object in any other file and
then directly I'm going to uh like save
the logs and all so I will show you how
to do that first of all let's try to
create the folders so here uh let's try
to create the files and all so here I
have created my logger file logger dopy
inside this McQ generator folder now
after that you need to create one more
file over here the file is going to be a
utils file so here uh let me write it
down the utils.py now what is this util
file why we should use this utils file
actually this utils file is a helper
file so whatever helper function is
there whatever helper function and
method is there so each and everything
I'm going to write it down over here
itself got it so what what is the use of
this utils file so it's a utility file
it's a helper file so what is a what
whatever helping function and all
whatever I have inside my code so each
and everything I'm going to write it
down over here itself now uh one more
file I'm going to create inside this
folder inside this McQ generator and the
file is going to be McQ generator itself
so inside this particular file I'm going
to write it down my entire code got it
now here I'm going to create one file
the file name is going to be a
McQ generator so here is the file name
McQ generator. py so I have created
three file inside my McQ folder inside
my McQ generator folder so the first
file logger file the second file is a
utils file and the third file McQ
generator. py5 fine so I hope till here
everything is fine everything is clear
now let me create few more file now in
the root directory itself I'm going to
create one more file that's going to be
a response response. Json I will tell
you what is the use of this response.
Json because yesterday uh in the
previous class uh if you will uh let me
show you this ipb itself so here I have
written one response here you can see we
have uh I have written this response G
and inside this response G I have Define
uh the response basically in which
format uh like uh the response should be
generated so here I have defined the
response Json now uh the same thing I'm
going to Define inside the Json file and
I will tell you what is the importance
of that so if I want to create a Json
file so for that uh what I need to do I
no need to do anything so here uh click
on this new file and after that uh write
it down here response uh response do
Json response. Json now here you can see
this is what this is my Json file so uh
till now I have created four file the
first file was the logger McQ generator
utils.py and apart from that one more
file that's going to be a response. Json
and this file will be in a uh will be in
a root directory this one response. Json
I think till now everything is fine okay
where I have created it uh let me check
once I think I have created inside this
experiment no need to worry just uh drag
and drop here
yeah so now I got it in my root
directory yeah so here is what here is
my response dojon now let me create one
more file over here and the file is
going to be a streamlit app so actually
I'm going to create my web app by using
the stream l so here I'm going to uh
create one more file and the file is
going to be a stream L and that two you
need to create in a root directed itself
in a root folder itself so here I'm
going to write down stream s e a m
stream lit uh
app.py so this is what this is my file
now let me keep this L as a small one
yeah now it is fine so streamlit do
streamlit app.py so these many file I
have created and now I think it is like
enough now what I can do I can give you
like this complete folder structure so
for that U like I can commit from here
itself uh so let me add all the files
from here I'm going to add all the
changes whatever I have done done inside
my code and I told you how to do that uh
in the previous class I explain you each
and everything regarding the git and all
so if you will go through with my
previous uh session so you will get to
know the uh like you will get uh you
will get the idea that how to like uh
how to uh create a repository and all
how to publish from here itself how to
publish a public repository each and
everything I have discussed in my
previous session now uh here you can see
I have added all the changes now I just
need to commit it in my staging area and
then I will push it in my GitHub so here
I can write down that uh I updated
updated the
folder updated the folder structure so
now what I can do I can commit it and
here I can sync the changes and then
okay yeah so now let me show you did I
get all the files and all here so here
guys you can see I got all the files
like streamlit app streamlit app.py and
here in the SRC you will find out this
uh in the McQ generator you'll find out
this McQ generator. py logger py
utils.py so each and everything uh you
can uh you can see over here inside my
repository itself so I hope guys you got
this entire code yes or no this entire
file now again let me give you inside
the chat uh or else what you can do you
can search over the Google as well so
directly you will get it tell me guys uh
till here everything is fine uh can we
start with the code and
all please uh do let me know in the
chat I given you this uh link inside the
chat I hope uh you are able to click it
otherwise directly check with the Google
you will get this
project Raab please check with my GitHub
repository check with a just search
about my username this s Savita Sun
Savita GitHub and then you will get my
GitHub and then from U from there itself
you can download this particular
code front end and all we are going to
handle by using this stream lead so
stream will handle everything we don't
no need to like create a front end
separately uh in the next project I will
show you that once I will use the
flask maybe with the fast API I will
show you the uh front end part as well
but here uh if I'm using this stream L
then front end is not
required
yeah you can use any ID even you can use
the U Inon lab also so from next project
onwards we are going to use the in
neural lab yesterday actually I did the
entire setup in my uh local vs code only
so that's why I'm continuing from here
itself but uh from next project onwards
I'm going to use the neurol lab so U I
think uh no need to set up in your local
uh directly you can launch the lab and
whatever experiments and all or whatever
project uh like you have uh you can
create over there itself
okay if you're getting any error
relative to the API key then try to
generate a new API key and don't use my
API key okay
because after the class anyhow I will
delete it so yeah don't use my API key
uh use your API key try to generate your
own API key from the open a i shown you
how to do that so go through the uh
openi website and from there itself you
can generate an openi key so if you're
liking the session guys then please uh
hit the like
button and and yes I think now we can
start with the coding so if you will
look into the project so here I have
created a various folder so I have
started from this uh logger if you will
look into this McQ generator so I've
created a couple of file the first file
was the logger the second file was the
utils file and the third file was the
McQ generator now here uh no need to
write it down the separate code for the
separate code for the front end and all
this stream lit will take care of it
this stream late will take care of it we
can create a basic BB application just
to test our API and all so no need to
write it down the code for the front end
and all now guys uh what we can do here
so let's try to uh write it down the
code for the logging so here I'm going
to write down the code for the loging
now why the uh logging is required so
see whenever we are going to execute a
code so in the code actually we have a
various step we have a various files we
have a various method function classes
and all right and each and every
function has been defined for the
particular purpose so let's say uh if
I'm going to write it down any sort of a
function inside the utils file or maybe
McQ generator so the function which I'm
going to create or which I'm going to
Define I'm going to create it for the uh
for the like Define purpose for a
particular purpose right so uh if I if
you want to log that uh information like
so let's say this a function is going to
execute and after the execution like
what you are getting or maybe after the
let's say you have completed the
execution now you want to save that
particular information software okay I
have completed this particular step I
have executed this particular function
or method so that information you can
log somewhere and there this logging
comes into a picture so always make sure
whenever you are going to create any
sort of a project uh whether you are
doing a development code development
machine learning related development or
whe whether you are going to write it
down a code in a gener project or
anywhere this loger exception you and
all this uh this particular files and
folder will remain same it's a part of
the infrastructure got it now here uh
let me write it down the code inside
this logger do py file so here uh let me
import the logging first of all so here
I'm going to write it down import import
login now uh here I have imported the
login then after uh I'm going to import
the OS and the third module which I'm
going to be import over here that's
going to be a date time so from date
time and here I'm going to write it down
import date time so these three import
statement this three statement I have
imported the first one is a loging the
second one is a OS and the third one is
a date Tye now let's try to create our
logger file so for that uh what I'm
going to do so here I have written one
expression now let me show you how my
logger file will be looking like so guys
here is my logger file here is my log
file actually and inside this file I'm
going to log each and every information
right so just try to uh look into this
particular file so here what I'm going
to do see here I'm going to collect my
uh the real uh date time so by using
this date time do now I'm going to uh I
I I will be getting the real date time
now I'm uh calling this particular
method St strf time so I'm formating
this particular time whatever date and
time which uh which we are getting U and
this is the real date time okay okay if
I'm going to call it um as of now right
so let me show you you can perform each
and every thing each and every
experiment inside this experiment uh
inside this uh particular notebook So
Yesterday only I have created so you can
create it and you can perform like
whatever experiments you want to do
before putting into the pipeline now
what I can do here I can copy this uh
code from here now let me copy it and
let me show you that what I will be
getting from here so this small small
experiment you can do inside your
Jupiter notebook now from uh so here
actually I need to import the date time
so from date time what I'm going to do
I'm going to import the date time itself
so from date time import date time now
uh let me do one thing let me run it and
here you will find out the uh the
current date and time now if you want to
formate it uh so here uh for that
actually we have a method so you can
call this method St strf time now let me
call this particular method
and then let's see what you will be
getting over there so I'm going to copy
it and let me paste it over here now you
will find out that I'm getting a date
time in a particular format so here is
month day year Edge means are minute and
second now what I'm going to do so this
will be the file name this will be my
file name and here I'm going to put do
log so do log is what do log is a
extension so this is going to my file
name and with that easily I can identify
that at which particular time I have
executed my code getting my point so
that's why I'm writing this name I'm
giving this name to my log file and this
this will be what this will be my uh
this current uh date and time will be my
name of the log file and what is the
meaning of the do log do log is nothing
it's a extension so here uh you will see
inside this uh logger file so this is
what this is the name of the file uh by
using this particular Name by seeing
this name I can easily understand that
at at which time I have executed my
pipeline right so according to that I
can collect the logs now here you will
find out this is what this is my file
name so I created a loog file and after
that guys what I will do so after that
let me create the path as well so where
I'm going to store my log so for that
also I have written couple of line and
this two line actually I'm using for
saving my log so in which directory I'm
going to save my log okay now here I'm
going to call this method os. path.
jooin os. getcwd means what so os. get
CWD means get current working directory
so as of now um in I am in this a
particular directory let me show you so
let me open my terminal and here you
will find out that I'm in this a
particular directory so I'm in C user
Sunny McQ generator so this is what this
is my folder name so this is my
directory path as of now I'm worki