Chainlit | Chat With PDF | 🦜️🔗 LangChain

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello guys welcome back I hope you are doing great many of you asked me to create a video related to channel it so here you go I'm going to create a series of videos in Channel it I have already created one video about Chad gbt like UI using Falcon Lang chain and chain lead before and many of you find it helpful so I'm going to create five different videos in this video will be the introduction and chat with PDF and the next one will be the chat with Docs and I will also combine these two chat with PDF as well as a chat with documents in one file so that you can upload any of those together and the third video will be chat with CSV and the fourth one will be chat with CSV with Docker meaning that you can also create the applications using Docker and the last video will be about how to deploy that particular decorized version of chat with CSV into Google Cloud I will be using the models from open AI for embeddings as well as large language model and Lang chain will be used as the framework chain lead for creating the apps chroma DB for the vector restore Docker of course for containerize the applications and Google Cloud platform for the deployments before going through the first video you need to understand how the custom chatbots for documents work right I have already created a video earlier and explained in depth about this process so I will put the link in the description this is inside the video of flow wise UI for line chain where I have explained all the steps how you can take any kind of documents extract and split the pages from this make it into different chunks and how you can do the embeddings and then store that into the factory store and then when you ask the question you need to again do the embeddings and there will be the semantic sorts happening there and it gets the relevant songs out of it and the usual will get the answer from the large language model please refer to this video in order to know how these things work in details by the way I have seen many people creating similar kind of contents and creating a course and placing payment so you need to pay for Access for those things right as of now I have no intention of creating the course and charging for you but I need a favor from you guys if you are new into this Channel Please Subscribe if you are already subscribed and you will you find the video helpful then please give a thumbs up for the video and share so that others also might find it helpful that's all you need to do and that is completely free if you do those things then it will motivate me also to create more videos in the future in this series I am not going to explain you what is chain lead or what is Lang chain or all the different stops because all those things are covered in my earlier videos so if you want to know what is channel delete in details I have already created video as I said earlier this create charge GPT like UI using Falcon line chain and chain lit please refer to this particular video and if you want to know what is Lang chain and all the different things I have already created a playlist of land change so please refer to that in this video as I said before what I am going to do is go through the chat with PDF right this is the repo that I will be following and I have already created all the different chapters or all the different files and this is now in private once I create video One video two and video three I will make this public then you can follow all the instructions that I have provided here in this video first we will go through how to chat with PDF right so for that I will just show you how you can do and you can follow the same things and by the way one thing what I highly recommend you to do is once I make this public give starts if you like because it helps to reach more people and then always Fork these repositories so that this repository will be your repository and then you can make updates and post the updated code in your repository so now I am on the GitHub repository so I am going to create a new code space which I have already created one code space which is active but I am going to stop this for now because I don't need it right now so I'm going to create a new query space for that you can also go to this query space once this is public and create the new query space here so this is going to create a new environment for us in the cloud somewhere by GitHub Kodi space right so it is going to take some time in order to make the remote connection and create the environment for you or the virtual working place for you right all the things which are on that particular repository are here and it is going to create some of the things right as you can see here there is a terminal here and there is the readme file we can just follow the readme files now right in the readme file I have provided all the different instructions because in the GitHub code space the python version is 3.10 so when using python version 3.10 I find that chroma had some dependency issue with sqlite so if you already have python 3.11 then it's fine for you but if you don't have python 3.11 you need to do some different things here right here is the git clone if you are working this locally you can do this git clone but in the go in the git of code space we don't even need to do this so it is creating something here when this is doing let's go through the readme file so the next thing you need to do is CP example dot EnV to EnV right I don't have EnV file right here now but you need to provide the C CP example e and B to EnV meaning that when I make this public how it is going to be is here when I work I need to have the dot EnV right in the dot e and V we need to provide the open AI API key so for creating the open AI API key you need to go to the platform so platform openai.com right you need to go here and create the API key I'm showing you this because I'm going to revoke this once the video is out so I can copy this go back to my GitHub code space and here I can just paste it there so I need to write here open AI API key right so open AI let me write it here open AI API key I can just do paste save it once this is done then I we have the open AI API key so this is what I was referring you that we need to do in here but when I see this it will be example dot EnV so you need to copy example EnV into dot EnV and follow these steps that I just performed here after that we need to create a virtual environment right that is what I mentioned you when I check the version of python here it is 3.10.8 right so I I cannot do this to create the virtual environment if you have 3.11 you can follow this but the easiest way to do in order to create a virtual environment other than the python version that is in your system is to use with Konda right you need to check force that you have conda installed for that you can just type cone version if you don't have you need to install Konda I already have the Konda here and in GitHub Kodi space there will be already conda installed so you don't need to worry about this you need to just copy this now you can just copy this command and paste it here I can say allow here and enter when I do this it is going to create a virtual environment for me and then activate the virtual environment as you can see here it is taking some time preparing transaction done and yeah if you see this dot EnV in front of the terminal then it says that the virtual environment is being created so the next thing you need to do is peep install requirements.txt right I will first run this command and explain you what is happening here so I have mentioned all the necessary packages here all these different packages will be installed when we run the command which I just mentioned you this peep install R requirements.txt so this is just the requirements that you need to follow right when you do the steps then we can run the files with the chain lead but before that I will explain you the code which is inside that particular file so you know that what is happening there right so in this video as I said you we will be going through the pdfqa dot PI right that is the chat with PDF so I'm going to open the PDF QA file and let me close this for now and we don't need anything here so all the necessary things are going to be installed here when this is installing I can just explain you what is happening here right so here import necessary modules you already know these things we need to import the necessary modules and load e and V by the way this is not even needed in chain lead because it chain lead automatically takes the environment variables from dot EnV I can just comment this out it works fine but if you are working with other than chain link then you need to provide the API Keys here right you need to load the API keys and first thing first what it needs to do is the text splitter we are taking the recursive character text splitter and then here is the system template as you can see here and this is the messages system messages and human message right and there is this prompt chat prompt template this is just the normal things if you have lost money link chain videos you know what are all these things right so now this is the main part here we have function and there is The Decorator called on chat start right so here sending an image with the local file right this is just the normal things I am performing here and there is the files is known in the beginning and when files is known so we need to ask please upload a PDF file to begin right so these are normal things which I have just mentioned here and the accepted file format is application PDF and we will take the file here and we have the CL Dot message content processing so when you upload the file there will be the some processing right it will just display that here and there we read the PDF file so here I'm using pi PDF so this is the normal it stops happening here and when we load this then we split that into different chunks right so this is happening here after that we create the metadata for each chunk because we need to also provide the sources for the chunks right if we ask some questions then we also want to have the resources or the sources from where that is taken from right and then we create the embeddings for embeddings as I said before we will be using the openai meetings and the doc source is we are using the chroma DB for the vector restore so this is all the things that is doing here here is the embedding part and this is the vector restore part and here create a chain that use the chroma Vector store right so here is the chain that we just need to provide that is how line chain works I hope you know that in my previous video also so we have retrieval QA with sources chain from chain type and we provide the chat open AI from open AI then chain type exist off and retrieval is Doc source as retrieval so this is just the thing that we need to provide after that we just have the session because that is the thing which takes the metadata as well as the text and what we do is processing done you can now ask questions with after you perform all these things we are now ready to query the things that is being stored in the vector store right so then comes the main function here where we ask some query from here the normal things here we have the session we get the chain out of it and this is the normal things I took from the documentation to stream final answer and yeah here is the asynchronous things happening and then all the things are there is the ensure there is the resources and all the different things and there is the metadata all the sources text we get the text from the session and if we have the source then it provides the source for us that is how it works right and yeah that is the function that we provide and we just stream that into the UI once this is done you can just save this and now the main things come here in the terminal right so how to run this you can go back to the readme file you can just copy this so we are following the PDF I can just copy this go here Ctrl V and enter right so now the app will be running on the localhost as it is mentioned there sometimes this 503 service on available error might be shown but if you refresh the page then the app will be running here so now you can browse the files what I am going to do is just take one of the file let me say I just want to have this GPT for all technical report paper so it says processing and that is already done what it does when that is processing meaning that it is doing the embedding parts and it is storing the data in the vector restore so now you can ask the questions whatever you want right we can just say what is the PDF about let's say if it provides sensor or not so it says using retrieval qhn and it says that the PDF is about the development of GPT for all paper right so that is the paper what we provided here and if you see here there is the sources if you click this for PL right it provides the source for us similarly you can click all the different sources and it provides the information and by the way one good part here is in chain lead you can have the different chains right the steps here so step one there is the retrieval QA with Source chain if you click one step down there is the stop document chain if you go one step down there is this llm chain so this is really good in channel 8 that you can have different layers which is being used when running this particular query and one good part here is if you go here you can create a new chat this will clear the current messages and start a new chat so you can just confirm and there is a new chat and you can refresh the page and the same thing which appeared in the beginning will be here and if you go to the settings there is the setting that is expand messages you can just do on hide chain of thoughts which we just saw before right you can just do this in dark mode if you want or if you prefer the dark mode so that is how it works so yeah that is how you can have the conversation with PDF okay that's all for this video where we learned how to have the conversation with PDF as I said you before this is the first video I will upload all the videos each day from today so in the five days time frame we will have all the different videos of chain lit and tomorrow there will be the video of chat with documents as well as I will go through the PDF and the documents together also so yeah thank you for watching and see you in the next video
Info
Channel: Data Science Basics
Views: 10,764
Rating: undefined out of 5
Keywords: openai api, chat ai, large language models, llm, chat, langchain, lang chain gradio, langchain demo, langchain tutorial, langchain openai, langchain explained, framework, openai langchain, what is langchain, langchain hugging face, langchain chat gpt, langchain tutorial python, langchain tutorial pdf, llms, chat models, prompt, chain, agents, langchain use case, chatgpt like ui, chainlit, huggingface, web framework, open source model, chromadb, chat with pdf, chainlit with langchain
Id: tESCOyHLmIg
Channel Id: undefined
Length: 16min 36sec (996 seconds)
Published: Fri Jul 28 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.