So guys, in this particular video we are going to discuss an end to end LM project with the help of
AWS, bedrock and Lang Chain.
This was also one of the most requested video from many people out there.
What we are going to do in this particular project is that we are going to develop a document, Q and
a application where specifically will be harnessing multiple models that are provided by AWS bedrock
like Cloudy Llama two.
And you can also use Amazon Titan, whatever models you specifically want that actually it provides.
We can actually use them and we can implement this entire application.
So to go ahead with, I will just go ahead and show you the quick demo over here.
So what is this specific entire application.
This is a rack right?
We are trying to create a rack system wherein we have multiple PDFs.
All those PDFs is stored in the form of vector embeddings inside vector store.
And whenever we ask any query we will be able to harness the power of AWS bedrock, which provides different
different models like cloudy, Llama two.
And uh.
Based on this particular question, we can retrieve that question from the PDF files.
So let's say I'm asking what are Transformers?
And if I go ahead and click on cloudy Output that basically is going to hit the cloudy API cloudy model.
And I'm going to get the entire response okay.
So currently this is running If you probably want llama two output, I can also go ahead and click on
llama two.
And I can actually get that specific response right.
So whatever questions you you have with respect to this particular PDF documents what the set of PDF
documents also will show you, and you will be able to get the entire response over here.
Right?
So, uh, why it is taking some time?
Because I still need to write that optimized version of the code, but once it runs right for the first
time, I think then after that it works absolutely fine.
Now let me just go ahead and write what is YOLO, right?
So if I go ahead and click on llama two output before see I showed you also llama two, uh, in my local
system itself over there.
It was taking a lot of time, but this is directly coming from the API model itself.
So here is what is the response I am specifically getting.
And I'll be able to get the answers.
Now this is what I'm going to develop completely from scratch already.
If you remember guys in our previous session in our yesterday, I had uploaded a video where I showed
you the power of cloudy dot pi, how to invoke the model and all.
Uh, then we also saw with respect to llama two and all.
Now let me just go ahead and create a new file over here.
So let me just go ahead and write this as app dot Pi.
Now inside this app dot pi I'm going to write my entire code.
Now before I go ahead, I really need to do some installation with respect to some of the requirements.
As said, uh, here we are going to use not only Boto3 and aws CLI, we are also going to use some more
libraries like pi PDF.
So let me just go ahead and write this over here.
So we require pi PDF along with pi PDF we We also need lang chain.
And then we will also be requiring Streamlit write uh.
Along with this we also require fierce fire CPU.
Right.
So this is what we are going to use because from our local environment we are going to do the vector
embeddings.
So for this I'm going to use the fierce DB right.
So through this only we'll be able to create the vector embedding into the vector store.
So these are some of the basic requirements that I actually require.
Now uh aws cli is also there because we really need to configure it.
Now let me quickly go ahead and open the terminal.
Let me clear the screen because yesterday I was creating the images over here.
The first step again you have to create a virtual environment.
Do all this pip install.
And all right I hope I don't have to tell you all those things now because I have repeated many number
of times.
So let me go ahead and write pip install minus our requirement dot txt.
If you are not able to understand it guys, please make sure that I'll be providing you this entire
playlist in the description of this particular video.
You can go ahead and watch it.
Okay, but uh, you have to follow the playlist, right?
Again, I'm not going to repeat everything from scratch, otherwise it is just a waste of time.
Right?
So till this installation is basically taking place, let me just go ahead and talk about what all things
we are going to basically develop.
Right.
So this is the document Q&A search.
So in short my PDF will be stored in a stored in the form of my entire PDFs.
We probably consider this.
My entire PDF will be stored in vector store.
And from this vector store we can specifically query any information that we want.
Along with this, we are going to harness the power of Lang Chen.
Chin Lang Chin along with the LM models from AWS bedrock.
Okay, so this is what we are going to do in this project.
So please make sure that you prepare well, uh, understand the architecture, what we are trying to
do.
So our entire project deals with two important steps one, two.
And before this, we are also going to do a very important step, which is called as data ingestion
Right now in data ingestion, what we are going to do is that we are going to read from the entire folder
how many PDFs are there, all the PDFs.
We are going to read it.
Okay.
So once I probably get this entire PDF, then my next step actually starts over here.
I'm going to take all those documents, the PDFs over there, split this into chunks, create the embeddings.
And here we are going to use this for this database.
So here we are going to use this fast right.
The vector database.
And through that only we will try to create this vector store.
Right.
So step by step I'll show you how to do this.
What embeddings.
Also we are going to specifically use here.
See understand we are going to create the embeddings.
So for embeddings we are going to use today I will show you a new model which is basically called as
Amazon Titan.
Okay.
So that you understand you have multiple options.
You have you may have implemented multiple options with respect to that.
Because tomorrow in companies if you go definitely they are going to use this AWS bedrock because it
provides a lot of features, right.
So for creating this embeddings I will specifically use Amazon Titan.
Other than this, if you don't want to use this, you can also use OpenAI embeddings.
Right?
It is up to you.
I've also shown with Google generative AI embeddings, multiple embeddings techniques in my playlist
with respect to Google, Gemini and all.
So after we create this vector store, now how we are going to use the LM.
So in the second step, whenever we ask any question, first of all the similarity search will happen
from the vector store whatever relevant documents and chunks we get.
We have to take this chunks.
Give it to my LM model along with the prompt.
Like let's say that I say that, okay.
Please summarize this entire information based on the query that I've asked in 250 words.
So this LLM model along with this prompt is going to take this particular data and is going to give
the answer itself.
Right.
So this both I'm going to develop completely from scratch step by step.
We'll try to see it okay.
So uh let's quickly go ahead and let's start our coding without wasting any time.
Okay.
So here is my app dot Pi.
I said that I'm going to do it completely from scratch.
So um, there will be some installation.
There will be some, uh, errors that may be probably coming up.
So we will try to also import all the libraries based on the pipeline that we have created, based on
the steps or architectures that we have already discussed.
So first of all, quickly let's go ahead and import JSON.
So I'm going to import JSON.
I'm going to import OS.
Uh I'm going to import uh sis I think I'll not be using sis but let it be.
These are some of the common libraries that we will specifically use.
Along with this we are going to use Boto3.
And again guys, in my previous video I have shown you how to configure the aws cli.
Please make sure that you watch the playlist, otherwise you will not be able to understand.
Okay, if you directly go into and jump in this particular video, no, you'll not be able to understand.
So in the description I will give you the playlist.
The first video only.
I've shown you how you can actually configure the aws cli.
Okay.
So please make sure this okay.
The next thing is that as I said right.
We will be we will be using.
using Titan embedding small model right for creating vectors or to generate embeddings.
Okay.
So we will create this model.
The reason why I'm showing you because I've never used in any of my videos.
Now this Titan embedding what I will do I will call from the long chain library a long chain framework.
Long chain provides you multiple functionalities, multiple multiple options to properly interact with
bedrock, right AWS bedrock.
So as I said, this framework is compulsory for you all to know.
One is launching and Lama index.
Right.
So what I'm going to do I'm going to right from lang chain dot embeddings I'm going to import bedrock.
Let's see bed.
Bed.
Rock embeddings.
Right.
So I'm going to specifically use this.
This will be small letter okay.
So guys I'm also verifying it from the documentation okay.
So there is a documentation that is given not very much clearly but I've implemented this entire project
also.
Right.
So from lang chain dot embeddings import bedrock embeddings.
The next thing that I'm going to use from lang chain dot LMS.
Like we can also use Lange chain to call this LM models that are present inside bedrock.
So that is also integrated right from LMS dot bedrock import bedrock.
Okay I'm going to specifically use this tool.
One is from Lange dot embeddings bedrock embeddings and from Lange chain dot lms dot bedrock.
Uh I'm going to import the bedrock.
Okay.
So this is specifically for the embedding part okay.
Now they will also be some libraries that I need to import for data ingestion because I really need
to load the data set right.
So over here you'll be able to see I will write import numpy as np.
Okay.
Uh this is numpy I'm going to specifically use.
I think by default numpy will be available.
Import numpy as np perfect, so numpy as np.
Then from long chain dot text splitter, I'm going to use text splitter so that as soon as I load the
document, I need to probably use this recursive character text splitter.
Okay, so this is what we specifically use.
And in my lecture series I've discussed everything about this.
Then again I will go ahead and write from Lange chain dot document on document loaders import.
Um we will specifically use this pi.
So let me just copy this pi pdf directly.
Loaders.
So this is what we are specifically going to use py pdf directly loaders.
And it is actually present inside long chained or document loaders.
Okay.
So this is specifically required for the data ingestion.
With this what I will do I have already created one folder over here which is called as data which has
this two PDFs.
Right.
I need to load all this PDFs from this particular folder and then perform all the vector embeddings
that I require.
So in data ingestion, first of all we will load it.
We will split the entire documents by using recursive character text splitter.
And then after this we will convert this into vector embeddings.
So let me just go ahead and write vector embeddings and vector store here I'm going to specifically
use for this index okay fish db or chroma db.
Also you can use it is up to you.
Again I have shown both the ways in my playlist.
So from Long Chain let me just see this.
Okay, so bedrock embeddings.
Is there something called as from long chain underscore community.
It was right.
Let's see okay.
From from long chain underscore community.
Let's copy this.
Is this correct or not.
We'll try to see Yeah.
Bedrock embeddings was there.
Uh, let's copy this here also.
So py PDF directory loader is also there.
I think there will be some warnings that will be coming.
Uh, I think most of the, some of the libraries and community.
Okay.
So here what I'm actually going to do from Lang Chain.
Let's see if we get an error again I'll revert it okay.
From Lang chain dot text splitter.
Sorry, not text splitter.
Why?
I'm using text splitter already.
I've actually done it.
So I'm also going to use for this vector embedding specifically uh, I have to use vector uh files.
Right.
So I will write vector stores import files.
Okay.
So fierce is one library I'll be using.
Again.
This files will be present inside community I guess.
Okay, so Vector Langton underscore community.
Uh, dot vector stores import files.
Let's see if this is not accessible.
So I think it is inside Langton only okay.
Otherwise you can see the documentation okay.
At the end of the day no worries.
Then after doing this I will also write from lang che dot indexes.
Okay I will not use this Also, let's just use fires because we have already installed fire CPU.
Okay, then.
Um, after doing this, uh, what we are specifically going to do is that we are now this is for the
vector embedding.
Now we need to go ahead with the LM models.
Right.
So for LM models there Lang chain already provides ways to load models from the AWS bedrock okay.
So for here I'll write from long chain.
From long chain underscore community dot one I will specifically use prompts oops from long chain dot
prompts.
I'm going to import prompt template okay.
And then the other one is from long chain dot chain.
So I'm going to specifically use one chain where I'll be using import retrieval QA.
Right.
So since I'm going to create a Q&A chat bot with the documents, uh, Q&A in short.
So that is the reason I'm using this.
And this is basically to create my own prompt template.
Now let's call the bedrock client so that we get the access of all the models okay.
So I will go ahead and set up the bedrock clients over here.
So here let me go ahead and write.
Bedrock is equal to Boto3 dot client.
And here I'm going to give my service name is equal to bed the bed bedrock dash runtime okay.
So I've already shown you yesterday also uh in in my playlist of this bedrock, I've also shown you
how you can actually call the client itself and access the models.
Okay, now as said, as I as I already told that the embedding that we are going to specifically use
is called as bedrock embeddings, right.
So let me quickly go ahead and call this.
I will go ahead and write Bedrock Embedding.
And let me show you how you can actually call this embedding from the bedrock.
So I will copy paste this.
Let me give the model ID.
Now this model ID you'll be able to see it over here right.
So if you probably go ahead in AWS itself let's say I will go ahead and write embedding okay.
So here only in Titan I think you will be able to find it out.
So foundation model base models.
So if you go ahead and search inside this any of the embedding models you can specifically take.
But I am going to use this Titan embedding model okay.
So if you probably click over here and see down you'll be getting the entire details like what is the
embedding, what is the model ID and all.
Okay, so I am going to specifically use this.
So let me quickly go ahead and call this model ID.
So for this model ID I've already copied it from that from this particular website.
So here you can see I will have copied this entire thing and I will paste it over here on my model ID.
So you also have to do the same step okay.
So once we do this the next thing in this that we really need to give is the client.
And client.
You know that we have not yet called any client or what.
So we have called this bedrock client.
So this will basically be my client over here.
Right.
So once we give this bedrock client, that basically means it knows we are going to call this particular
embedding model from this particular client.
That is bedrock itself.
In short, we are going to use the AWS, lm, uh, AWS bedrock.
Now let me quickly go ahead.
And this is what is all step by step will be going.
First we will create this data ingestion model.
See if this step is done.
We have created our client.
Now we will go ahead and implement this data ingestion so quickly.
Let's go ahead and implement this data ingestion.
And please make sure that you follow this.
So here I'm going to basically write data ingestion okay.
And uh I will create a step which is called as data ingestion a function.
Now inside this data ingestion what things we are specifically going to do.
Right I have a folder.
So let me go ahead and write.
Loader is equal to pi PDF directory loader.
And here I'm going to give my folder which is called as data.
Right from that data folder only I need to pick up all the PDF files right.
So this is the first step.
Then I will go ahead and write documents is equal to loader dot load.
Right.
So from that this loader we are going to load this entire documents Now in our testing we will specifically
use something called as characters text split.
Right.
So that is what we are.
We have already implemented right.
Recursive character text split.
Now how do you implement this?
It is very much simple.
I will go ahead and write text splitter.
Right.
And this with the action I've already shown you.
So it will be recursive text splitter.
And here first of parameter will be my chunk size.
Chunk underscore size.
Chunk size.
I will give it to 1000 or 10,000.
Right.
And along with this chunk size the second parameter I would like to give as chunk overlap.
Please give this number a little bit more value so that you will be able to understand it Okay.
So this two are their text splitter recursive character text splitter.
And this right.
Once we get this text splitter I will go ahead and write Dox is equal to text splitter dot from oh sorry
dot split underscore documents okay.
And then here I'm going to give my entire document.
So in short we are going to split it right based on this recursive character text splitter.
Once we do this, then we will return the docs.
All the docs we're going to specifically return the docs.
So data ingestion is done right with respect to this particular data ingestion.
Here what we are doing we are reading all the PDFs from the data folder.
We are doing recursive character text splitter with this chunk overlapping.
And then we split all those documents right.
So this becomes a this completes our data ingestion.
Now the next thing is that we will go ahead with vector embeddings.
Vector embedding and vector store.
Right.
And this is where we are going to specifically use that title embedding that we have imported.
Along with that, what we are specifically going to do is that we are going to use this files.
Right.
So let me quickly go ahead and write it down.
So here I'm going to write my definition.
And quickly let's go ahead and write Get Vector Store.
So I'll create one more function.
Now inside this vector store I'm going to first of all give the documents whatever documents is coming
from here.
Because we take this documents and then we do the embedding techniques and we perform all the embedding
techniques.
So in my next step what I will go ahead and write I'll write a vector store underscore files okay.
So this will basically be my variable.
And then I'm going to use fire start.
Okay.
From underscore documents right.
And we are going to implement this right.
So in the first parameter inside fires we give docs.
And the second parameter that we specifically give is my bedrock embeddings.
Right.
So this is the embedding.
Specifically we are going to use okay one One is the bedrock embedding which we have initialized over
here.
See over here in the bedrock embedding we have initialized.
And that is what we are going to use it over here.
Now after we get that vector surface this is basically my vector store I will go ahead and save it in
my local disk.
So let me quickly write dot save underscore local.
And inside this we are going to basically write phi s underscore index.
Right.
So this will basically be saved in my uh folder over here itself right in my hard disk.
You can also save this in any database as such if you want.
So this is my vector embedding I've done it.
And this step is also completed.
Now let's talk about the next step.
In the next step we based on the import we have to work with LM models.
Now what we are going to do over here is that I'm going to create some LM models.
Let's say I will go ahead and write first LM model that I'm going to work with is cloudy.
Right.
So I will say cloudy LM and inside this cloudy we will create create the anthropic model.
Because I should say already AWS bedrock is giving you the power to harness multiple models to use the
multiple models.
So we can specifically develop in this application itself.
It's just like having different different models in different, different ways.
But here I'll try to make it much more generic.
So here we are going to write quite the anthropic model and I'm going to create my LLM.
Along with this we are going to use this bedrock.
So bedrock um, before if I probably show you in my previous tutorial, the way of invoking a model
was something like bedrock dot invoke model.
But now, since we are already using Lang chain, we don't have to basically use invoke model.
So what we specifically do, we just call this bedrock.
And you can probably see how where this bedrock is present, it is present in a Lang chain.
So they have actually created a wrapper.
And internally they will invoke that specific model.
But this is a way that how you can use this frameworks like Lang in a generic way.
So now I'm going to use this model as bedrock.
Now with respect to this I will go ahead and write my model ID.
Already I have searched my model ID so this is what is my model ID over here.
How you do you get this information again from this particular examples, go and click on any model
you will be able to.
Let's say I want to generate cloud I generate code.
So with respect to this this will be my model ID right.
So it is a generic way of finding the model ID so you don't have to even worry about it.
Right.
So I have my model ID which I did it in my previous tutorial also.
And then I will go ahead and write my client.
My client will be nothing but bedrock.
Bedrock.
And the next thing that I'm going to specifically give after this, right?
One is model arguments.
Right.
So model arguments with respect to this.
Now this arguments, this arguments that you'll be seeing.
Right.
Where do you find it again if you probably go here inside the body.
And if you go at the last right, there will be some arguments that will be added like this.
Max tokens to sample temperature.
This this.
You can also add it over here.
Now with respect to this particular model that I am actually using, this was the argument that was
present inside that particular body.
So that is the reason I had created this.
Right.
All this JSON file separately so that I can refer it.
Okay.
So I hope you are able to understand it.
If you are able to understand, please make sure that you hit like till now.
And now let's go ahead.
And here what we are specifically doing whenever I call this function, that basically means my cloud
model has got loaded.
So I'm going to return the LM model.
Now suppose similarly you want to probably go ahead and call the llama two model.
So I will go ahead and paste it over here.
I'll say get llama two LM like this.
You can actually create any number of functions as you want okay.
So this will basically be my llama two.
Now inside my llama two let me just copy this again I'm going to see my.
So this is the llama two model over here okay.
Only the model ID change and whatever is the argument that will change.
So in the case of arguments uh, with respect to this, this is nothing but max gen length, right?
How I'm getting it.
Let me show you again okay.
So let's say this is a chain of thoughts.
Let's say that I'm going to use this okay.
So here you can probably see this is my model ID okay.
And then inside my arguments this is from where we'll be able to get it right.
So this API request is pretty much important with respect to this okay.
So return a model.
And this is where is my model that I'm getting with respect to llama two.
So now you know how to create how to call any uh models itself right.
Data ingestion is done.
Vector store is done.
Everything is done.
Now let's go ahead and create my prompt template.
Now this prompt template that I'm actually going to create I'm going to use something called as Lang
chain.
So in my prompt template I have written see this okay.
So I've given a simple prompt template which you can also use it.
So I have written human in this format.
Use the following piece of context to provide a concise answer to the and at least summarize with 250
words with detail explanation.
If you don't know the answer, just say that you don't know.
Just don't try to make up the answer.
So context and question is there.
And based on this assistant, whatever assistant output is there, it will get appended over here.
Now with respect to this particular thing we use the login prompt template.
We write context and question and we use it okay.
Now this is fine.
Everything is good.
Now let's focus on the response part.
So here I will go ahead and write get underscore response underscore lm.
And here the first parameter is my lm.
The second parameter is my vector store.
Vector store fires.
The third parameter that I'm going to give is my query.
Right.
So this three parameters we are going to play with.
One is obviously if I want to get the response from a specific LM then I have to give this three information.
Okay, get response LM the LM model, which I'm calling this is my first index and this is my query
okay.
Now once we get this, we as you know that we have imported something called as a retrieval cue.
So retrieval cue.
And here also we are going to use it.
And this is how you basically call it.
Right.
So I'm just going to copy it paste it over here.
Again I'm seeing the lantern documentation.
So retrieval QA from chain type I'm giving my LM model.
Chain type will be stuff I've already shown you.
What is text summarization.
Different different text summarization techniques.
So stuff is there over here.
This is the most important thing.
Retriever how from where the similarity search will basically happen.
So this is where we are doing right.
Office index basically has the entire index itself right.
Right.
And then we are trying to do the similarity search along with the argument top k three or top three
prompts.
And then we are also saying return source document with respect to this one.
And then I have my prompt over here.
Right.
So all these things are basically done.
And then after this we will be able to get the response.
So now once we specifically write this chain type uh arguments.
And here we are specifically giving the prompt.
The prompt is getting created by the prompt template over here.
And then in the next step we will go ahead and right answer I'll create a variable called as answer.
And we can use this q a variable.
And inside this we will give in the form of query colon.
And here we are going to give the query itself.
So this query is the query that is coming from the as As an input okay.
And once we get the answer see when we when this QA is basically using right it is nothing but retrieval
QA.
So it will retrieve the response and it will store it in this particular variable.
Now inside this variable there will be something called as result as a key which will give you the output.
So if you print it right.
Initially I printed this answer.
I've already implemented this.
So there there is a variable called as result which has the entire answer.
So this is my response LM where I'm getting the entire result.
Now let's go ahead and create our Streamlit app.
Now quickly there are two important things with respect to this Streamlit app.
One place I have to make sure that whenever a document is updated, you know that it should get converted
into a vector embeddings.
So what I'm actually going to do quickly over here, I'll create a main function and let me show you
what I will be doing okay.
So quickly first of all I will import Streamlit as st.
Streamlit as st.
Fine.
We are going to use Streamlit.
Now see this?
The thing that I've copied and pasted.
So I've written chat, PDF chat with PDF using AWS bedrock.
This is my user question.
Like what kind of question I want from the pdf file.
Then a sidebar is basically created and I will say update or create vector store, right?
That basically means inside this I will create a button saying that vectors update.
That basically means once I click click right then it should go ahead and call this data ingestion.
Now data ingestion, what it is going to do it is this data ingestion is going to read all the files
from the data folder.
Then it is going to take this loader documents.
It is going to perform this recursive character text splitter.
And then after providing after doing this it is going to return this entire documents.
Right after this we are going to call this vector store.
So one by one we will be calling it.
So here you will be able to see data injection and vector store.
We are calling.
We get this docs.
Now inside that vector store.
What is happening is that we will save this in our local, uh, folder itself in the hard disk in the
form of files index.
So as soon as I click this button that is vector update Update, which will be available in the sideways
inside the sidebar sidebar.
Means in Streamlit it is in the left hand side.
So the vectors will get created, the vector stores will get created, and it will also saved in a local
folder itself.
Right.
So over here a folder will come with this particular name that is called as files index.
This is one step.
Now the second step is that I can go ahead and create a cloudy output.
Okay, I will create a cloud, a button which is called as cloudy output.
Now see this.
This is important to understand okay so this is my button.
I've created another button.
When I say cloudy output that basically means I have to use the cloudy model API.
So the first thing, as soon as I click on the cloudy output button, my face should get loaded from
the local.
So so that is the reason I'm writing dot load underscore local with this file index and the bedrock
embedding, the same embedding which I've actually used.
Then I will go ahead and call this cloudy LLM right.
I'm going to call this cloudy LLM because I will get the LLM itself.
Now if I go inside this function, if I go ahead and write f 12 okay.
So here you will be able to see where it is.
Uh, cloudy.
LM so cloudy.
LM it is going to call this particular model and return our LM over here.
Right.
So here I'm going to get my LM with respect to this.
And this LM will specifically be used inside this function.
That is get response underscore LM where I have given my LM vector store files and query right.
When I get this three information over here, I'll get my response.
And I am writing this particular response over here.
Very much simple.
Very much easy.
Right.
So let's execute this and let's see whether this is working fine or not okay.
So this is my main function.
So what I will do I will create this if underscore underscore name with respect to this mean.
Now let's see whether we will get any error okay.
So I will clear my screen.
But in short we have executed each and every thing right.
So I will go ahead and write Streamlit run app dot Pi.
Let's see whether we will get any errors.
First of all, uh, okay.
It's working fine.
I will close this.
Okay.
Now this on the left hand side, I will get this vector update update or create vector store.
And here I have chat PDF using AWS bedrock.
Okay.
Now the first step as I said what I'm going to do here is my data folder.
It has this PDF file attention dot pdf, yolo dot pdf.
So what I'm going to do I'm going to probably click on Vector Update.
As soon as I click on Vector Update.
Now what is going to happen.
See over here.
As soon as I click on Vector update, what is going to happen.
So if this is clicked that basically means the data ingestion folder.
It will go.
It will read both this PDF and then it will convert that into vectors And we will save that vector over
here.
Right now you cannot see any folder in the name of files index.
But now if I go ahead and click on vector update.
Now what is going to happen.
See as soon as this vector update will finish.
Now processing is basically happening and this will probably come up with like done okay done status.
Unless until we don't get any errors.
Let's see with respect to this right what will happen.
So it is now loading all the PDF it is performing.
It is converting those into vectors.
Right.
And then it has now stored that as a fixed index.
Now if you probably go over here and see this folder my files index has created, it has index dot files
and index dot pickle.
Right now this is the first step.
Now the second step is another button which is basically cloudy output.
Now cloudy output is over here.
Now if I give any prompt what is attention is all you need.
What is attention is all you need.
Okay, if I go ahead and click on Cloudy Output.
Now it is going to call the cloudy model right.
So if you probably go ahead and see the code again what is basically happening.
First we will load this file index from the local.
Then we will call the cloudy LLM model.
Then we will call this Get response LM where we are giving all these three information the user question.
And now finally you'll be able to see I'm getting the output right now.
This is with respect to cloudy output right.
So similarly if I go ahead and write what is YOLO I will go ahead and click on Cloudy Output.
Now again see follow this pattern inside it will go again.
It will load this files index.
Right.
And then we will call this particular cloud model.
Now how the performance can be improved.
This Phi C index I will not call each and every time.
So let me do one thing.
Let me call this once okay.
Let me do one thing.
For the first time I will just keep it outside this okay.
But again it will give us an error.
But I will give you that as an assignment.
First of all, let's work on this okay.
So here you can see my YOLO is also coming.
Now see if I want to add llama two and all.
What I need to do I will go over here.
My llama two function is already created if you remember.
See over here my llama two function is where get llama two right?
So I will create another button.
I will copy it like this.
If my start button is llama two, right?
So this will be my llama two output.
Now instead of calling get cloud lm, I will say get llama two LM.
So now we will go ahead and check whether for llama two it is working fine or not.
So I will save this quickly.
I will see now I'll click on llama two.
Now let's see whether we'll get the output or not.
Again, the same thing is going to happen.
First of all, it is going to load the files index.
After that it is going to take the LM model.
It is going to give all the information.
And then finally you'll be getting the answer.
Similarly I can go ahead and write what is attention is all you need okay.
So if I go ahead and click on llama two, then again I will be able to get the response.
So this entirely everything is basically happening with the AWS bedrock.
So step by step I have shown you almost everything the data ingestion step, what our libraries are
specifically getting used, all this code, I have written it in front of you.
The Streamlit file we have actually created, I would suggest go ahead and try it from your side, and
this is how you are able to get the response.
But the best thing is that all these models are available in AWS bedrock and it is already scalable.
It you can actually use it according to your wish.