RAG With LlamaParse from LlamaIndex & LangChain 🚀

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello guys welcome back in this video let's try to integrate the cleaned document from Lama parser into the Lang chain the scenario here is let's say you already have a lang chain application and you want to take advantage of the Llama parts so it's easier for you to parse the document right if you haven't watched my previous video I recommend you to watch this llama par llama index to know in depth information about the Lama pars and also there is this rag with Lama pars quadrant and grog step byst step things using the Llama index itself so what we will be doing is creating a similar J lead application that I used to show you before right but then integrating the Llama Parts into it let's get started okay this is the GitHub repository as always you can just clone this uh repository I have also provided the data that we are going to use this over 10 and the instructions are here first you clone this create the virtual environment and activate it install the necessary packages and provide all the environment variables that you need in just first and then we can run the application that's it I have already clone this so here as you can see I have post this just now I will clear this I will do LS and you can see all the files I will activate the virtual environment here I have already install the necessary packages so I can now open this in vs code I will bring this in here PS code things so yeah as I said you before also if you go to this read me okay this is not updated because I just updated that in the G hop so what I will do is I will do G pool so everything will be updated here and then I will will run this again so now if I go here you can see all the latest things right so yeah just install things and pep install our requirements. txt and if you want to know what is in the txt requirements of txt there are all the packages that you need to install and in the example. EnV as you can see here there is Lama Cloud quadrant and grock as before but then you can also import this Lang chain Rel stops in order to have the traces in the in the Lang Smith websites I have created videos about Lang Smith please follow that in order to use this Lang Smith part so first thing first what we can do is let me go to this in. py what I am doing here right so here all the necessary import things are here we don't need to go through that and again I recommend you to watch my previous video to know in depth information about Lama parts so it's easier to follow and we need to get all the let's say the apis from Lama Parts quadrant and this is how you can get for that I just show you here so Lama cloud is here you need to create the account and create the API key from here and that's it for the quadrant also you need to create the account and create a cluster and from here you can get this cluster URL and from here you can get the API Keys when you create that one that is done we are good with this part and what I'm doing here now as I I have explained this in my previous video but I included one of the tips that I have given you in the previous video right we can pass the passing instructions inside the Llama parts so the answers will be better that's what I have I have be doing here as you can see this is just the paral and I'm passing only one file here but what you can do is let's say you have many p your files you can create a list like this and you can pass it into this into this load data so you can have as many PDFs as you want but I just want to show you with this one PDF and then this is just um loading things because I don't want to do it again and again once this is done in the data folder there will be a piol file being created right so that is the normal llama index part how to incorporate now that file into this Lang chain it was not let's say straightforward because there might be many ways how you can implement this but what I find the easiest way to do there is first I created this uh parts right and then this is just the printing things how many are there and what I did I tried to load this Lama part document into this text splitter but there was some issue there what I did here is I just went through the Lama pass documents right and then created a output. mg file and then just dumped there once this is done what will happen is inside the data folder there will be a output. MD file being created and what I did is from the from the langen I take this directory loader and I loaded all the MD files and then I did this load or. load and this these are the normal things now you can play around with this Chong size and other things so recursive loader and then I load this document inside this text splitter and did the splitting part right this is one trick that that I went through as I said before also there might be some good ways to to achieve this but yeah this was what I was able to do just play around with this let me know in the comment section if you find better ways to to do this the next thing is for the embeddings of course I'm using the fast Ed embeddings and then we need to of course create the quadrant Vector store right so here is the quadrant quadrant from documents and I'm passing these documents which I have been creating here and the edings comes from here and the quadrant URL which we get from the quadrants Cloud so it's here right both of these two things and then we need to also pass the API key and we need to give the collection name r so that's it and once we save this what we can do is now we can go to our terminal and from here we can draw Python 3 we can say inest do PI what this will do now is all the things which I said you right as you can see here okay it shows the error okay print this is list so what we can do is comment this print from here right and then save this because that was what I was testing before but here it is showing the issue yeah now we can run this python as you can see here this is all the downloading things are done there we don't need to uh worry about that because it is downloading the fast edings it needs to go to the L part Fage all the things create the embeddings and so on right it is taking some time here okay now it is successfully created once this is done as I said you before there should be two files being created here one is the pial file that we want to use it again and again because we don't want to send that into the Lama par and then next one is the output MD if I go here you can see all the information is here there was 106 Pages if you just go here this is6 Pages file right all that is now converted into the MD file and then we created the let's say embeddings and store that into the quadrant so now if I go to the quad here this is the cluster and here you can see Lama index rag if I go inside this you can see the open dashboard I will click this for you maybe first time you need to provide the API key but I have already done that and inside the rag you can see all the things here now right so from where did we get this because our we give the name of the collection rag if you go back to the code you can see here we give the collection name rag so this is how it is being created so now our ingestion part is done right now what we can do is go to our app dop so here also I have tested with AMA also because sometimes things doesn't work as expected so these are the normal importing things normal things again we need to import the environment variables here right and this is the normal now the Lang chain things that I have explained you so many times so I'm not going to go through all the steps again and again but there is normal things set custom prompt and I'm taking the model from chat Grog by the way and then also we we need to get the grogs API and if this is new to you I have already created the videos please refer to that but from this Gro Cloud you can go here and get the API keys right please watch the videos that I have created if you are new to this uh part and then what I was doing here is normal client because we need we are storing our embeddings into uh quadrants CL Cloud right so we need to have the client so I'm creating the client and passing the API keys and the URL and yeah these are the normal things as you can see retrieve QA CH so there is the llms and then we just retrieve the informations from there we pass the prompt and so on so there is the QA bot so we have the fast embeddings again and then there is this vectory store quadrant client is client embeddings and we are we are giving the collection name Rag and we are giving the chat model which we created here from the chat Grog right we are taking the mixol model from there and other normal things are being past here and then now there is this chain lead part where we just this is what we saw on start and this is on message I have been explaining this so many times but I'm not going to take too much of time here let me know if if you face any issues I will just save this now right okay did I do something no now I will go to the terminal here and I can run the chain lead application so I will do chain lead run app.py now it is loading all the things and now this is our application hi welcome to chat with documents using Lama Parts Lang chain quadrant and models from the gro so now just to check if it works or not I will do hi okay hello this this this now this is just a random information being shown here right but what we can do is now ask the questions from here for asking the questions what I am going to do is I have taken this doc this demo Advanced ipynb Notebook from Jerry who has explained from the Lama index part I will ask the same questions so if we get the answers or not from this document right what what I will do is I will just copy this query we need to get the answer for example this this is the answer income taxes net of refund 22 right let's see if it gets the answer or not I will just go here and in the chat in in the input part I will just pass okay this one here okay how how is the cash this this this I will submit this okay the cash paid for income taxes need this this this okay respon was 22 million was it correct if we go back here as you can see it is 22 so I think it is 22 million right so it gets the answer answer from here so it went to the right right path and now if we go again and ask another question okay let me go and ask this one that was correct right so that is the reason I'm using Lama part because you get the idea we we are getting clean documents from there I will ask another question okay what is the change of this this this from here okay what is happening here okay I will ask this it should get the answer okay the change in plan is okay- 682 the rate is not and so on so what is the answer by the way here okay this is this 682 yeah 682 million uh and then it was 47 million from this one so yeah six as you can see here also there is the 635 million and then L this was giving the let's say right answers but yeah this there is 47 and 682 so it is going uh there right uh 682 and of course there is minus for for some reason and I think 3 months in date free cash flow yeah it by the way it is getting the answers and going to the part so that is really really good now another thing is also here net loss attribute to Uber is 108 or it's 5930 in 2022 and 21 it is 108 let's ask this question now if it gets or not I'm just showing you this because it's easier for me to just go through the questions and answers from that notebook right so I will just go here and do enter okay it is getting 5930 it was in March 31 2022 and 108 for the same period last year right if you want to also see the sources you can go here and as you can see this is the sources that it is getting from there and the answer is provided from here so these are the sources Source One and Source zero for the previous also you can just go here and see what is the sources the answers are correct from that 106 Pages because we extracted the information from Lama parts and it is easier now to go through the document to get the answers uh for us right so let's ask one more question I think there is one more question about cash flows let's see if it gets the answer correct or not so it is 250 and 135 right so I will take this question from here contrl C by the way this is as I said before also 106 Pages PDF files with many information there right what way the cash for yeah it is 135 in 2022 and is 250 million in 2021 so yeah that's what I I want to show you because it's getting exact answer and if you want to go the source also you can see from where it is getting so again this proves that garbage in garbage out is what it's all about right if you provide good answers it will get good answers out of it and the reason that it is working so nice here is also because I incorporate this if you go to the ind. pi file about this parsing instruction so this also helps a lot so just try with this and if you have let's say uh some other documents here just try to give this paring instruction as accurate as possible so that it gets the or let's say it gets the answer or extracted the answer properly just give a try I I just find it helpful I hope now you get the idea how to how to let's say incorporate two different Frameworks right what I did here is I just used the Llama parts from llama index and then did some things here and there to save that information into the L chain and then use quadrant Grog and chain lead to create a rag and I so far or let's say by far this is the best rag I have created uh and it's getting the right answers from that big documents also one last thing is I showed you there is this Lang Smith also right so I use that in my in my environment variables and you can see here this is the Lama par Rag and these are the questions I asked right so what were the cash flows from this and this is the answer it is getting if you want to go inside this so yeah it is using the chat Grog so that is human and this is all the information from where it is getting and this is the output so this is the good part again of of Lang chain or Lang Smith the product from L chain so yeah that's all I wanted to show you in this video now I hope you know how to incorporate llama index L parts and langing together and create a great chain lead application like this which you are seeing in the screen okay thank you for watching and see you in the next video
Info
Channel: Data Science Basics
Views: 2,737
Rating: undefined out of 5
Keywords: llm, chat, chat models, chain, agents, chat with any tabular data, create chart with llm, markdown, chat with your data, rag, chat with pdf, llamaindex, what is llamaindex, ai, LLM, rag to prod, openai, AI, RAG, rag llm, rag ai, llm rag, langchain, llama, metaphor, rags with web search, gpts, opengpts, llamaindex in nutsell, What is llamaindex, GPTs, llamaparser, parse pdf, llamacloud, groq, qdrant cloud, mixtral, genai native document parsing, document parsing, parsing, chainlit, rag in action
Id: f9hvrqVvZl0
Channel Id: undefined
Length: 17min 4sec (1024 seconds)
Published: Sat Mar 16 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.