Chat With Documents Using ChainLit, LangChain, Ollama & Mistral ๐Ÿง 

Data Science Basics
11 Feb 202419:46

Summary

TLDRThis video tutorial, part of an AMA series, guides viewers on creating a simple Retrieval-Augmented Generation (RAG) application using open-source models. The host demonstrates how to embed PDF documents into a knowledge base with the help of Langchain and AMA, and then interact with them through a user-friendly chat interface. The video covers setting up the environment, installing necessary packages, and deploying the application, which allows users to ask questions and receive answers based on the embedded documents. It also emphasizes the importance of tweaking parameters for optimal results and suggests referring to official repositories for updates and troubleshooting.

Takeaways

  • ๐Ÿ˜€ The video is part of an AMA series, focused on creating a simple Retrieval-Augmented Generation (RAG) application using open-source models.
  • ๐Ÿ“š The presenter has previously created videos on using AMA for chat UI and integrating it with Langchain.
  • ๐Ÿ”— The video introduces using Langchain for deploying applications and utilizing Langsmith for application tracing.
  • ๐Ÿ“ The GitHub repository mentioned in the video contains the code for the RAG application and instructions for setting it up.
  • ๐Ÿ’ป Viewers are guided to clone the repository, set up a virtual environment, and install necessary packages using a `requirements.txt` file.
  • ๐Ÿ” The video covers two examples: ingesting documents from a data folder and creating a chain lead application for uploading PDFs directly through a UI.
  • ๐Ÿ“ˆ It demonstrates how to use the `ama` embeddings for creating a vector database with the help of the `mistol` model from the Langchain Hub.
  • ๐Ÿ”ง The video provides troubleshooting tips for issues with code or functions, suggesting checking the official GitHub repository for updates or creating an issue.
  • ๐Ÿ—ฃ๏ธ The presenter shows how to interact with the chat UI, asking questions related to the PDF content and receiving answers based on the embedded knowledge base.
  • ๐Ÿ› ๏ธ The video emphasizes the flexibility of using different models with AMA and the importance of precise prompts for better question-answering results.
  • ๐Ÿ”„ The process includes creating a vector database, using a RAG prompt, and deploying a chat application that can answer questions based on uploaded PDFs.

Q & A

  • What is the purpose of the video?

    -The video aims to guide viewers on how to create a simple Retrieval-Augmented Generation (RAG) application using open-source models and tools like AMA, Lang chain, and Chain lead.

  • What is AMA in the context of this video?

    -AMA refers to a simple chat UI interface that uses models to interact with users, similar to Chat GPT, and is utilized to create the RAG application.

  • What is Lang chain used for in this tutorial?

    -Lang chain is used for deploying the RAG application and also for managing the traces of the application.

  • What is the significance of using the 'rag prompt mistol' in the video?

    -The 'rag prompt mistol' is a pre-existing template available in the Lang chain Hub that simplifies the process of creating the RAG application by providing a structured format for prompts.

  • How many different ways are shown in the video to create a RAG application?

    -Two different methods are demonstrated: one where documents are ingested from a data folder and another where PDFs are uploaded through a UI for conversation.

  • What is the role of the 'create Vector database' function in the script?

    -The 'create Vector database' function initializes the loaders for different file formats, in this case, PDFs, and is responsible for embedding the documents into a vector database for retrieval purposes.

  • What is the importance of splitting documents into chunks in the script?

    -Splitting documents into chunks is necessary for the Recursive Character Splitter to process the text effectively, allowing the model to handle large documents and maintain context with an overlap.

  • Why is it recommended to use a virtual environment in the video?

    -A virtual environment is recommended to isolate the project's packages from existing ones on the system, preventing conflicts and ensuring the correct versions of dependencies are used.

  • What is the process of running the RAG application as described in the video?

    -The process involves installing necessary packages, creating a vector database with embedded documents, using the 'main.py' file to set up the chat interface, and finally running the application using Chain lead with the 'run main.py' command.

  • How can viewers get help if they encounter issues with the code in the video?

    -Viewers are advised to go to the official GitHub repository of Lang chain or Chain lead and create an issue, where they can seek assistance from the community or the creators of the tools.

  • What is the purpose of the 'on_message' function in the 'main.py' file?

    -The 'on_message' function handles user input in the chat interface, processes it through the RAG application, and retrieves information from the knowledge base to provide answers.

Outlines

00:00

๐Ÿ“น Introduction to the AMA Series and Chat UI Application

This paragraph introduces the fourth video in an AMA series, where the creator has previously made videos about a simple chat UI using AMA and Lang chain. The video aims to create a simple Rag (Retrieval-Augmented Generation) application. The creator has also made videos on using open-source models for Rag applications but emphasizes that this tutorial will focus on a simpler PD (prototype?) of Rag applications using AMA and Lang chain, with a focus on deploying applications and using Lang Smith for tracing. The GitHub repository for the project is mentioned, along with the addition of new files for ingesting documents and creating a chain lead application.

05:01

๐Ÿ›  Setting Up the Environment and Ingesting Documents

The paragraph explains the process of setting up the development environment for the Rag application. It involves cloning a repository, setting up a virtual environment, and installing necessary packages. The focus is on ingesting documents by initializing loaders for PDF files and splitting them into chunks using a recursive character splitter. The AMA tool is introduced for creating and persisting a chroma vector database, with instructions on how to install and use models from the AMA website. The paragraph also details the steps to run the ingest file and create a persistent database for the application.

10:02

๐Ÿ” Developing a Retrieval-QA Chain Lead Application

This section delves into the development of a Retrieval-QA (Question Answering) application using chain lead and the AMA tool. It explains how to use a persistent database and the Lang chain hop to pull prompts for the application. The video creator shows how to use the Rag prompt 'mistol' from the Lang chain Hub and load the AMA 'mistol' model for the application. The paragraph outlines the creation of a QA bot that interacts with the persistent database and the user through a chat interface, demonstrating how to run the main.py file to start the application and ask questions related to the ingested PDF document.

15:04

๐Ÿ“š Enhancing the Application with User-Uploaded PDFs

The final paragraph discusses enhancing the application to allow users to upload PDFs directly through the UI. It covers the process of adjusting the chunk size and overlap for text splitting, and handling file uploads with specified maximum sizes and timeout settings. The paragraph also addresses potential issues with code updates in Lang chain and chain lead, advising viewers to check the official GitHub repositories for solutions. The video concludes by demonstrating the uploading and processing of a PDF file through the UI, asking questions, and receiving answers based on the uploaded document's content.

Mindmap

Keywords

๐Ÿ’กAMA

AMA stands for 'Ask Me Anything' and in the context of the video, it refers to a framework that allows for the creation of simple chat interfaces using AI models. It is central to the video's theme as it is used to demonstrate how to build a chatbot that can interact with users. The script mentions using AMA to create a chat UI and to work with models like 'mistol' and 'lava'.

๐Ÿ’กLang chain

Lang chain is a tool mentioned in the script that is used for creating applications that can interact with AI models. It is integral to the video's content as it is utilized alongside AMA to build a Retrieval-Augmented Generation (RAG) application. The script discusses using Lang chain for deploying applications and for creating prompts.

๐Ÿ’กRAG application

A Retrieval-Augmented Generation (RAG) application is a type of AI application that combines retrieval of information with generative capabilities. In the video, the creator aims to build a simple RAG application using open-source models and frameworks like AMA and Lang chain, showcasing the process of creating such an application from scratch.

๐Ÿ’กGitHub repository

A GitHub repository is a storage location for a project's source code and related files. In the script, the creator refers to a GitHub repository where the content for the video is stored and from where viewers can clone the project to follow along. It is used as a resource for the audience to access the code and files needed to build the RAG application.

๐Ÿ’กVirtual environment

A virtual environment in Python is an isolated space that allows for the installation of project-specific packages without affecting the global Python environment. The script explains how to create and activate a virtual environment, which is a necessary step before installing the packages required for the RAG application.

๐Ÿ’กRequirements.txt

A 'requirements.txt' file is a list of all the Python packages needed for a project. In the video script, it is mentioned as a file that contains the list of packages required for the RAG application. The audience is instructed to use this file to install the necessary packages within their virtual environment.

๐Ÿ’กEmbeddings

In the context of AI and machine learning, embeddings are vector representations of words, phrases, or documents that capture semantic meaning. The script discusses using AMA embeddings to convert PDF documents into a format that can be understood by the AI model, which is a crucial step in creating the knowledge base for the RAG application.

๐Ÿ’กChroma

Chroma is a vector database used for storing and retrieving embeddings. The script mentions creating and persisting a Chroma vector database to store the embeddings of the PDF documents, which will serve as the knowledge base for the RAG application to retrieve information from.

๐Ÿ’กChain lead

Chain lead appears to be a command-line tool or framework used in the script for running the RAG application. The audience is guided to use 'chain lead run' to start the application, which then allows for interaction with the AI bot through a user interface.

๐Ÿ’กPDF loader

A PDF loader in the script refers to a function or module used to load and process PDF files. It is used to ingest documents for the RAG application, where the PDF files are loaded into the system to be converted into embeddings and stored in the Chroma database.

๐Ÿ’กRetrievable QA chain

A retrievable QA chain is a component of the RAG application that allows for the retrieval of information from a knowledge base to answer questions. The script describes creating such a chain using Lang chain and AMA, which is used to fetch answers from the embedded documents when a user asks a question.

Highlights

Introduction to the fourth video in the AMA series, focusing on creating a simple RAG (Retrieval-Augmented Generation) application.

Explanation of previous videos on using AMA for chat UI and Lang chain integration.

Demonstration of using open-source models to create RAG applications with AMA and Lang chain.

Overview of using Lang Smith for application traces and the RAG prompt mistol from the Lang chain Hub.

Instructions on cloning the GitHub repository and setting up the environment for the project.

Details on creating a virtual environment and installing necessary packages for the project.

Description of the process to ingest documents and create a chain lead application for conversing with PDFs.

Guidance on using the AMA tool for embeddings and model selection in the RAG application.

Steps to create and persist a chroma vector database for the knowledge base of the RAG application.

Discussion on using the hop from Lang chain to pull prompts for the RAG application.

Explanation of the main.py file and its role in the RAG application for handling user queries.

Demonstration of running the RAG application and its ability to answer questions about a PDF document.

Illustration of how the RAG application retrieves information from the embedded PDF for user queries.

Insight into the limitations of local models and the importance of precise prompts for accurate answers.

Introduction to example three, which allows uploading PDFs directly through the UI for conversation.

Clarification on the use of the PDF2 reader and adjustments made to accommodate changes in Lang chain and chain lead.

Final demonstration of the RAG application with an updated UI, processing uploaded PDFs, and answering questions.

Advice on exploring chain lead documentation and experimenting with different document formats for RAG applications.

Recommendation to use official repositories for support and to report issues encountered during development.

Closing remarks, encouraging viewers to practice with RAG applications and explore sophisticated solutions like Private GPT and QV.

Transcripts

play00:00

hello guys welcome back this is the

play00:01

fourth video in the let's say AMA series

play00:05

I have already created three different

play00:06

videos if you are new to AMA please

play00:08

refer to these videos before I have

play00:11

created before a simple chat UI where

play00:13

you can use the uh chat GPT like

play00:16

interface right using AMA and to use the

play00:19

models out of it and then also how to

play00:21

use it with Lang chain right this is the

play00:24

simple application I have used before

play00:26

and now some of you mention in that

play00:29

video that can we use this to create a

play00:31

simple rag application right that is

play00:33

what we are going to achieve this by the

play00:35

way I have already created many videos

play00:38

where you can use the open source models

play00:41

to create the simple rag applications

play00:43

but they are you need let's say that

play00:45

this is provided by somebody else and

play00:47

there are so many code involved in it

play00:49

but if you want to have a simple PD of

play00:51

rag applications then that is what we

play00:53

are going to do and as I said you before

play00:55

also we are going to use AMA and use the

play00:58

models to download we with wama Lang

play01:01

chain and then chain lead to have the

play01:04

let's say deploying for the applications

play01:06

and by the way we are also going to use

play01:07

the lank Smith to have the traces of the

play01:11

applications as you can see here these

play01:12

are the traces and then also we are

play01:15

going to use the rag prompt mistol which

play01:18

is already in the Lang chain Hub there

play01:20

are many pieces here and there but you

play01:22

will have a clear understanding once we

play01:24

go through all these things let's get

play01:26

started okay so this is the GitHub

play01:28

repository I actually added this this

play01:31

content of today's video also in the

play01:33

existing one I have already shown before

play01:35

a simple application Chachi for running

play01:38

LMS locally with let's say AMA and Len

play01:40

I've added two different files here so

play01:42

I'll show you two different ways one how

play01:44

to inest the files already from a data

play01:47

folder and have the conversation with

play01:49

that PDF and the next one is having

play01:50

simple chain lead application where you

play01:53

can upload the PDFs on the UI itself and

play01:56

have the conversation with it all the

play01:58

instructions are here what I did first

play02:00

is already cloned this locally so what

play02:02

you can also do is if you want to follow

play02:04

along with me go here and either choose

play02:07

https or SSH and then copy this right

play02:10

and then you can go to your terminal

play02:13

which I did already here there is this

play02:14

Lang chainama chain Le and then I open

play02:17

this in the vs code you can see I'm

play02:19

opening the vs code here and all the

play02:22

things are here which you see in the

play02:24

GitHub so this is the readme files so

play02:26

you can just go through here I'm saying

play02:28

here we'll be going through example 1 2

play02:29

3 but one is already done in my previous

play02:32

video please refer to that second and

play02:34

third is what we are going to do so

play02:35

second one first we will injest the

play02:37

documents and then create a chain lad

play02:39

applications right so what is the step

play02:42

this is what I said you you need to

play02:43

clone go inside that particular clone

play02:46

repository and open it in any ID you

play02:50

want but I have opened this in the vs

play02:52

code right and next thing is there is

play02:54

this EnV if I go inside this this will

play02:57

be as example EnV uh I I will rename

play03:00

that in the in the GitHub so this one we

play03:02

don't need to have any paid versions of

play03:04

API calls but we need to have I will

play03:06

show you this because I'm going to

play03:08

delete this later so you need to have

play03:09

this Lang Smith related things here and

play03:12

if you are new to Lang Smith related

play03:14

things I have already created three four

play03:16

videos related to Lang Smith and how to

play03:18

get started with it please refer to that

play03:21

right so now if I go to the read me the

play03:23

next thing you need to do is create a

play03:25

virtual environment right so you can

play03:27

just copy this right click copy let me

play03:30

open a terminal here so I will just open

play03:33

a new terminal here and first you of

play03:35

course I hope you have python install in

play03:37

your system so if I go here and say

play03:40

maybe python version I have

play03:42

3.11.0 this should work for your system

play03:45

also I will do control V what this this

play03:47

does now is create a virtual environment

play03:50

and activate the virtual environment as

play03:52

you can see there is EnV here and I have

play03:55

set up my terminal in such a way that

play03:57

once the virtual environment is created

play03:59

it is shown something like this here

play04:01

right now I have uh virtual environment

play04:04

created and if you are new to Virtual

play04:05

environment also I have created the

play04:07

productivity videos where you will know

play04:09

how to isolate the projects or packages

play04:12

so that it doesn't conflict with

play04:14

existing ones in your computer right and

play04:16

the next thing what we can do is we can

play04:18

just install the packages right I will

play04:22

copy this what it is doing if you go to

play04:24

the requirements.txt here I have all the

play04:26

packages that is needed for this uh

play04:28

particular project I will just go to the

play04:30

terminal and do control V so it will

play04:34

install all the necessary packages as it

play04:36

is say it's using the cast one because I

play04:38

have already tested this before and

play04:40

there is already the cast version of

play04:42

this it is installing but remember that

play04:45

it is installing in this particular

play04:47

virtual environment once that is done

play04:49

the example one you can just run this

play04:51

chain lead run simple chat UI so this is

play04:53

here simple chat UI this is the previous

play04:56

video content just go through this and

play04:58

have a simple chat interface right

play05:00

please follow the previous video for

play05:02

this one I will not go through this and

play05:04

okay it is setting the environment now

play05:06

now what I will do is first I will show

play05:08

you the example two let me actually

play05:10

clear the screen example two there is

play05:12

Python 3 inest file and the main file

play05:14

right I will just show you what is in

play05:16

the inest file so here is the inest dop

play05:19

here all the necessary things are being

play05:21

imported and this is the normal path

play05:23

things that I have created here and

play05:24

there is function called create Vector

play05:26

database right so instructions are also

play05:29

mentioned here meaning that the data

play05:31

must be inside this data folder I have

play05:33

this CPT for all PDF what I'm doing here

play05:36

is initializing the loaders for

play05:37

different file formats but for this case

play05:39

it's just a PDF right so PDF loader I'm

play05:42

using the directory loader and passing

play05:44

the data all the PDF files and loader is

play05:47

p PDF loader let me do control Z okay

play05:51

and loaded documents is PDF loader. load

play05:54

and that is loaded here and you can just

play05:56

uncomment this if you want to run step

play05:58

by step you can also do that and next

play06:00

what we will do is we will split the

play06:02

loaded document into chunks right we

play06:04

need to split that into chunks so we'll

play06:06

be using the recursive character

play06:07

splitter we said that Chong size 500 you

play06:10

can play around with this numbers and

play06:12

Chong overlap is 40 so that we have

play06:14

let's say in two different CH some

play06:16

informations related to the previous one

play06:18

and yeah text split. split documents and

play06:20

we pass this loaded documents in the

play06:22

previous step there right so next as I

play06:25

said you we'll be using the AMA but

play06:27

before running this AMA and providing

play06:30

the model you need to have Ama installed

play06:32

in your machine if you are new as I said

play06:34

you before also I have already created

play06:36

different videos in ama so please refer

play06:39

to that but if I if if I just go to the

play06:41

terminal and run AMA list it should show

play06:43

me some models as you see here mistol

play06:45

and lava I'm going to use the mistol so

play06:47

if this is running or swing here it

play06:49

knows that ama is here once this is done

play06:52

you can install the models that you want

play06:54

I'm not going to make this video longer

play06:56

but you can follow my previous videos if

play06:57

you have these models downloaded you can

play07:00

provide this in the AMA embeddings and

play07:02

the model name the good part of using

play07:04

Ama embeddings or AMA is that if you

play07:07

maybe now have let's say Lama 2

play07:09

installed you can just provide Lama 2

play07:11

here and by default actually Lama 2 is

play07:13

being used but you need to provide the

play07:15

one that you want to use so quickly

play07:17

changing different models from the AMA

play07:19

website this is the beauty of AMA right

play07:22

and now we will create a create and

play07:24

persist a chroma Vector database right

play07:26

I'm going to use chroma in this case so

play07:29

this is normal things that I have been

play07:30

explaining many places and after this I

play07:32

said this persist so that it is being

play07:34

persisted here it will be created a new

play07:36

DV folder because I have said here to

play07:39

create a DB folder and yeah once this is

play07:41

done I will run this file so how to run

play07:43

this now is just you can go to the

play07:45

terminal Python 3 and then you just say

play07:48

in. F so it is going to do all the

play07:52

necessary things here and once this is

play07:54

going through the steps you will notice

play07:55

here a DB folder being created now here

play07:58

right inside the the DB folder now it is

play08:00

just showing chroma sql3 but the process

play08:03

is ongoing once this is completed you

play08:05

will see some other files also being

play08:07

shown here this is still ongoing so when

play08:10

this is ongoing what is the next step we

play08:12

will be doing we will be going through

play08:14

this main.py file so if I go inside here

play08:18

again here also the normal importing

play08:20

things are mentioned here and I have

play08:22

also provided you link from the chain

play08:24

lead documentation where I have taken

play08:25

this this code you can go through that

play08:27

normal things here I want to use from

play08:29

the persistent DB and as I said you

play08:33

before I'm going to use the hop right

play08:35

Lang chin hop from there you can pull

play08:38

the prompts that's what I'm doing here

play08:41

if you go back and I will show you here

play08:43

here this is the hob and I'm searching

play08:45

here for mistol and as you can see this

play08:47

is the rlm persons user ID and then this

play08:51

is the rag prompt M if I go inside this

play08:54

so somebody has provided the prom

play08:56

template for us so we can just pull it

play08:58

like this and use in our existing code

play09:00

so this is quite easier to make the code

play09:02

look better right I will go back to the

play09:04

PS code and now as you can see here

play09:06

python in. f is completed so if I expand

play09:09

this DB and there are many files here

play09:12

right meaning that our embedding things

play09:14

is now completed and our knowledge base

play09:17

is ready right and we will go through

play09:20

this and we'll be using this rag prompt

play09:23

mistol and we will load the model here

play09:25

as you can see I'm using the AMA mistol

play09:28

right and was true and you can just

play09:30

provide the call back and return llm so

play09:32

this is the llm things and we have the

play09:34

retrievable QA chain just there is not

play09:37

that much of the things I need to

play09:38

explain here and there is the QA bot

play09:42

which goes through that existing

play09:44

persistent DB and get the information

play09:46

and here also you need to provide the

play09:47

same embedding model that you use to

play09:50

embed the particular PDF so yeah now we

play09:53

have the normal things this chain lead

play09:54

on start chat what it does is it goes

play09:58

through the QA bot and it says okay

play09:59

starting the bot just the normal prompt

play10:02

things in the UI and hello welcome to

play10:04

chat with documents you can just

play10:06

customize this and this is just the

play10:08

normal on chat start and once you have

play10:11

that and this is the on message kind of

play10:14

when you ask things then it goes through

play10:16

this process as you can see it goes

play10:17

through the session and gets the session

play10:19

information and yeah just the normal

play10:21

things here and also we want to have

play10:23

this Source also printed along with this

play10:26

answer right so I if if you have

play10:28

followed my previous let's say rag

play10:30

videos then this is the normal things

play10:32

and you can just copy paste and if you

play10:34

want to know more you can go through

play10:35

step by step so that's all so now let's

play10:37

start this application right so I have

play10:39

already embedded things I clear the

play10:41

screen now to run this you need to run

play10:44

chain lead run main.py and you can pass

play10:48

dasw if you want to maybe have uh

play10:50

something change in your code and update

play10:52

as it goes I will just pass this one you

play10:55

can just run any of these things so it

play10:57

says create a default config at this so

play10:59

it is created by default things and yeah

play11:00

here is our simple chat UI now we can

play11:03

ask the questions related to that PDF

play11:06

right so maybe I will say here what is

play11:09

the paper about right so now as you can

play11:12

see it is going through the retrieval QA

play11:14

and when this is going in the UI as you

play11:17

can see here in the terminal there is

play11:19

already the answer being printed right

play11:20

and now we have the answer the paper is

play11:22

about the introduction and release of

play11:23

open instruction tune large language

play11:25

models and all the different things is

play11:27

being provided here and if you want to

play11:30

know if it gets the information out of

play11:32

it or not you can just go to the data

play11:34

open the PDF file here right and then

play11:37

you can ask the question from here let

play11:38

me ask one question by the way we can

play11:40

just go through the PDF here and what

play11:42

questions do we do we want to ask from

play11:45

here let's say let me see if it gives me

play11:47

the total cost okay what is the total

play11:49

cost of creating the model something

play11:51

like this right so I will go to the

play11:53

application here I will say let's say

play11:57

what is

play12:00

cost to train the model let me say

play12:03

something like this if it gets the

play12:05

answer or not so here it already says

play12:07

down something okay I'm unable to

play12:09

determine the total cost okay this is

play12:11

how llm works and also because this is

play12:13

the local model it depends upon your

play12:15

Hardware requirements also it sometimes

play12:18

gives the correct answer sometimes it

play12:19

doesn't give maybe you need to modify

play12:21

the prompt or be precise when asking the

play12:24

questions for example if we go to the

play12:25

PDF let's let me ask some some other

play12:27

things what can we ask from here okay

play12:31

maybe something related here what uh

play12:33

what is the fine-tune variant right of

play12:36

the CPT for all model let me say that

play12:38

let me ask here on which model is GPT

play12:44

for all model let's say

play12:47

dependent something like this right

play12:50

maybe so here it says here okay DBT for

play12:53

all model is something gbt for all model

play12:55

is dependent on the large scale data

play12:57

especially the data set of with GPT 3.5

play13:00

model with dis still is important to

play13:01

know that GPT for all team does not

play13:03

train model something something it shows

play13:05

the source also here and GPT for all it

play13:08

is giving us the GitHub of this model

play13:11

and in the source two we have all the

play13:14

sources here three okay it is getting

play13:17

the informations from here and the

play13:18

fourth one is here okay I'm not going to

play13:20

go in depth because it's just getting

play13:22

the information from these chks right

play13:24

now you get the idea the right and wrong

play13:26

things is not what I want to show you

play13:27

but you can just ask the questions from

play13:30

here locally without paying something

play13:32

right when you do some prototyping kind

play13:33

of things this is really good or maybe

play13:35

also if you have good Hardware resources

play13:37

and if you can tweak uh the parameters

play13:39

or the prompt of course why not the

play13:42

local models can be also great now let

play13:44

me cancel this contrl C and let me clear

play13:47

the screen this is what we do the inje

play13:49

part separately and we ask the question

play13:51

right let me close this one also now let

play13:53

me go to the example three what I'm

play13:55

doing in the example three I have this

play13:58

rack Pi file and same things as before

play14:01

but then we will be uploading the files

play14:04

on the UI itself and by the way many of

play14:07

you also mentioned in previous videos

play14:09

the code is not working or maybe some

play14:11

functions are not working because the

play14:14

reason for that is because Lang chain as

play14:16

well as chain lead are rapidly growing

play14:19

right and the code might be updated

play14:21

maybe the functions does not exist

play14:23

anymore something like that right best

play14:25

way to get the answers of those things

play14:27

is to go to the official GitHub

play14:30

repository and just create a issue so

play14:32

that if someone else also has faced the

play14:34

same issues that you have they will

play14:36

provide you the answer of course I will

play14:38

go through there and I will try to

play14:39

provide the answers if I have because I

play14:41

will be creating some video let's say

play14:43

five months before and I will not be

play14:44

going through that video right but

play14:46

somebody else might have gone through

play14:48

that so they might provide you good

play14:49

informations before me right so just

play14:51

keep that in mind and here this is just

play14:53

a normal importing things as I did

play14:55

before also and here there is the text

play14:57

splitter again recursive splitter so

play14:59

Chong size now I'm providing 1,000 and

play15:01

overlap is 100 as I said you it's the

play15:03

parameters that you can you can just

play15:05

tweak so on chat so here I'm saying

play15:08

please upload a PDF file and you can

play15:09

provide the max size 20 and the time out

play15:12

180 because some of you also mentioned

play15:14

how how big of the file size it must be

play15:17

right so you can provide here and yeah

play15:20

and and some of the things also again

play15:21

here also because this code was working

play15:23

before and now it is not working and

play15:24

some of you also get the issue so now I

play15:27

have fixed this in such a way that it

play15:29

just use the P PDF 2.pdf reader and we

play15:31

need to pass the file. path here and it

play15:33

works right before there was the content

play15:35

things and now it shows that okay there

play15:38

is no content available anymore

play15:39

something like that right so this is the

play15:41

normal things we are reading the PDF

play15:42

files and again the splitting into

play15:44

chunks and this is the metadata being

play15:47

created now we have the chroma vectory

play15:50

store similar as before and we have the

play15:52

chat message history also here right so

play15:54

that we can ask the follow-up questions

play15:55

as we go and yeah here is the creat a

play15:58

chain that that uses the chroma Vector

play15:59

DV I don't actually need to explain

play16:01

maybe now you know I'm using by the way

play16:03

chart AMA here you can just try around

play16:05

with this chart Ama or AMA just try it

play16:09

because this is the chat kind of things

play16:10

I I think if I provide chat AMA it's

play16:13

also fine right but it depends upon your

play16:15

use case also and now here once our file

play16:18

is uploaded that means the edding is

play16:20

done it will say Okay processing done

play16:22

you can ask the questions and now we

play16:24

have this it is stored now in the

play16:26

sessions and now we have on message kind

play16:28

of thing

play16:29

and here the same things like before but

play16:31

in different format right it it just

play16:33

takes that particular chain before and

play16:35

then we can ask the questions it goes

play16:37

through the knowledge base and get the

play16:38

information out of it the normal rag

play16:39

kind of things so yeah now let's run

play16:41

this how to run this again same as

play16:43

before but now I will draun chain lead

play16:45

run and then it is rack. pi as I said

play16:49

you we can just pass DW or without this

play16:51

also let me run without this I'm running

play16:54

all at one go now right as you can see

play16:56

here now we have different looking UI it

play16:58

says please upload a PDF file to begin I

play17:01

can just browse from here maybe upload

play17:03

the same GPT for all paper I will go

play17:05

here and it says processing GPT for all

play17:08

PDF because we have mentioned here to do

play17:11

that right processing and the file that

play17:13

we uploaded do name and once the

play17:15

processing or the embedding part is done

play17:17

it will show us the message uh that okay

play17:20

processing the file done you can ask the

play17:22

questions right let me go if it is

play17:24

already done so it's still ongoing here

play17:27

so once that is done we can ask the

play17:29

question and by the way the good part of

play17:30

chain lead is also that when you ask the

play17:33

questions here you can just ask the

play17:35

history from here and ask the same

play17:37

questions here right processing this St

play17:39

you can now ask the questions now let me

play17:41

ask the same question that I asked

play17:42

before what is the paper about and I

play17:44

will just say here okay what is the

play17:47

paper about it is going through the

play17:48

knowledge base and then it will provide

play17:51

the answer for us the paper is about GPT

play17:53

for all or whatever it provides right so

play17:56

here you can see the paper is about

play17:57

original GPT for all model and all the

play17:59

different things and maybe again if you

play18:02

go here it will provide you the uh

play18:04

sources from here so it also depends

play18:06

because now I have the chunk size of

play18:08

1,000 and it has more information in one

play18:11

chunk so maybe I see that it provides

play18:14

better answer on that also it's it's up

play18:16

to you you just go here and play around

play18:18

okay which number works the best right

play18:20

and now if I go here again and maybe I

play18:22

will say what is the total cost to train

play18:23

the model let me see if it provides

play18:25

answer here because same PDF is being

play18:28

used here and there right what is the

play18:30

total cost of to train the model OKAY

play18:32

the text does not provide information

play18:35

okay strange I can say there is can you

play18:39

search it for me just random things it

play18:42

will understand this if not also you can

play18:44

just play around as I said before also

play18:46

prom the main idea here is to show you

play18:48

how how you can achieve these things

play18:50

okay the text does not provide any

play18:51

information so it doesn't provide let's

play18:53

say in that way so yeah I'm not going to

play18:55

go through all the things again and

play18:56

trying to get the right answer out of it

play18:58

but you get the idea how to run this and

play19:01

and and let's say that now this is for

play19:03

PDF right you can go and go through the

play19:05

documentation in the chain lead or Lang

play19:07

chain there are many cookbooks there

play19:09

just try with CSV or try with normal

play19:12

text document or docs microsof dos or

play19:15

any docks kind of things so yeah just

play19:17

play around with it and just practice I

play19:19

think if you do that then you will have

play19:20

a simple looking chat but if you want to

play19:22

have the sophisticated one let's say the

play19:24

private GPT and the QV are the best ones

play19:27

to go if you want to have the ready made

play19:29

solution from from someone who has spent

play19:32

lots of hours there right okay that's

play19:34

all for this video If you enjoyed the

play19:36

video or if you find some useful

play19:37

information out of it please give thumbs

play19:40

up you can share this or subscribe if

play19:43

you haven't already thank you for

play19:44

watching and see you in the next

Rate This
โ˜…
โ˜…
โ˜…
โ˜…
โ˜…

5.0 / 5 (0 votes)

Related Tags
Chatbot DevelopmentAMA SeriesLangchainDocument QueryOpen SourceRAG ApplicationsPDF ProcessingEmbedding ModelsChat UIKnowledge Base