Advanced Q&A Chatbot Using Ragstack With vector-enabled Astra DB Serverless database And Huggingface
Key Takeaways
Builds a Q&A chatbot using Ragstack, Astra DB, and Huggingface
Full Transcript
hello all my name is krishak and welcome to my YouTube channel so guys in this specific video we are going to create an amazing rack project with the help of data stacks astb and open llm models and openi embeddings not only that I'm also going to introduce you to data Stacks rack stack right so rack stack Is Nothing But it includes all the libraries you need for the rack pattern including the vector database embedding pipelines and retrieval so we'll try to develop this entire project by using this rack stack itself if you have not yet visited data stack I would suggest go ahead and see this because it again provides you this data stack astb which can actually act as a vector store which will efficiently stay uh store all the vectors itself and you will also be able to query in a much more quicker way and uh the main aim of this particular project is that I will take up this entire data set which is in the form of a CSV file here you can see three fields are there like author quote and tags and based on this particular sheet we will try to query different different information based on the quotes and then it can it should be able to map the author and tags and provide us the results okay so all these things will be basically completed and not only that I will be showing you step by step how do you probably create the keys how do you go ahead with it each and everything right so here it is the entire notebook I will be providing the descri the link in the description of this particular video so first of all you really need to create an extra Vector database and then you also need to have an open AI key then we will go ahead and create the access token and along with that we'll also have the database ID so first of all just go ahead and click on this particular link once you click and once you sign up you will be in this particular page that is called as data stask now here here you'll be able to see multiple options create a database generate tokens invite your team you can probably work along with the team itself so first of all to create a database first of all go ahead and click on this particular database out of this particular two option that is serverless Vector or serverless not Vector you can probably select serverless Vector because we are going to work with Vector database itself you can provide the uh database name let's say that I am providing some examples like data Stacks demo okay and then I will be using AWS web services and here you can probably select us E2 whatever is the default probably coming up right and then once you do this you just need to click on the create database and automatically your database will get created it will take a couple of minutes for creating this entire database s right so once the database is created I have already created the database over here which is called as demo Gro right and here with respect to this particular databases you will be requiring two information one is the database ID which is present over here very clearly it is shown over here because this is the key that we are going to use uh this is the configurable key that we need to provide because at the end of the day all the vectors that is probably getting created it will be stored in this particular Vector store itself so this database is a kind of a Vector store database itself right and uh again uh apart from this what you really need to do is that go to the Token section okay and you really need to generate a new token right so first of all here you can select an administrative user role right where you'll be able to see all this particular information what all permission is basically applied it is similar like AWS easy to instance whenever we try to create a role right at IM role we need to provide the roles permissions for the administrator user or any kind of of user that you really want to create so once you probably click this and uh you click on the generate token your token will probably be generated I've already done this you can see I have created multiple tokens over here so in order for you to generate you just need to click on generate token now this to information will be specifically required when I am showing you with respect to the coding and also show you where you have to probably put that particular ID itself right so over here let's go ahead and do the setup so first of all I will connect it to my runtime environment so let's see what all runtime I have I will be using T4 GPU so I will go over here click on connect okay the first step as usual is to install rack stack AI since I told you that we are going to use this data sex rash stack which includes all the libraries for anything that you really require to perform with respect to the rag application like including the vector database embedding pipeline retriever it will actually help you to do it okay so first of all this is basically connected we will go ahead and install this so here you'll be able to see that I am installing this over here and we go ahead and install this entire rack stack itself right and here you'll be able to see once this installation is done then the next step is that we will go ahead and enter all our endpoint address okay so guys once the rack stack AI installation is done you know so most of the libraries you just need to import and you can start working on it now let's go ahead and start configuring our Astra DB that is data STX Astra DB and open aai with the open AI Keys itself right so over here you'll be able to see that I am setting up three different Keys one is the astrab API endpoint in my environment variable now where do you specifically get it so if you probably go over here and click on any of the databases that you're specifically working on here you'll be able to see API endpoint okay so with respect to this particular API endpoint you can directly copy it from here and you can directly paste it over here right so it will probably start with https uh with respect to all this particular URL and at the end of the day or at the end of the URL you'll be able to see apps. asra dod.com okay so this I have pasted it over here then the second thing is with respect to your astrab application token now that basically means you need to generate the token how do you generate the token click on the token itself over here click a role let's say administrative user click on this so here I have generated the token you can download this entire token details but out of these three information that is client ID secret and token you have to select this and copy it it or save it in an environment variable so here I have directly copied and pasted this entire token over here itself right so it will probably start with Astra Cs and this will basically be your token ID right so this two information is there astrab API endpoint astrab application token and the third one is open a API key uh here what we'll do in the runtime itself when we are running this we will be giving the open AI API key remember all this Keys here I'm showing it to you but once the video is basically getting uploaded I will be deleting all the specific Keys okay so let's go ahead and let's go ahead and do this installation or executing this particular command here I'm putting my opening API key and I pressed enter okay so this three information are there that you specifically require one is the astrab API endpoint how do you get it I have already shown you go to the databases that you have actually created okay on the right hand side you'll be able to see the API endpoint copy this and put it over there okay now the next thing is with respect to the token and then your opening your API key so once you go over there and once you complete this step then you go and create your rack pipeline now for creating your rack pipeline initially you need to import l chore astrab now here you'll be able to see that I have never installed this but how we are able to use this particular Library it is all because of this rag stack AI okay so because of this automatically most of the libraries that is being used to create the rack pipeline will be used over here so from Lang chenore astrab we are going to use astrab Vector store which will be responsible in storing your entire vectors and then here I'm going to use the opening I IM bidding keys I can also directly go ahead and use cassendra but here I'm not going to use it so here uh is all the details then I am going to initialize the open AI EMB biddings and then I'm going to initialize this extra DB Vector store which will be responsible in connecting the uh astb itself now here are some of the information the first information is os. get EnV astb collection Now what is my collection name you can put it over here so let's say here I give it as test then embedding technique what I'm actually going to use this is the embedding that I'm going to use the token we since we have set up already in the environment variable that is the astrab application token so we are going to use that and finally your API Endo okay so once this is done your entire astrab uh Vector store is completely configured okay so this will probably take some amount of time and uh anyhow I will be giving you this entire code file in the description of this particular video you can go ahead and check it out out so here you can see ASV Vector store is configured now we are going to play with this data set we will read this particular data set and use it in the form of Q&A okay so in order to load the data set I'm going to use the library from data sets load data set that basically means this this data set that is related to data Stacks you'll be able to use it right and since we are going to use this so that is the reason we have imported this then we will be using this load data set uh load data set and be uh I'll write the data se/ philosopher quotes and we'll be using the training data and some of the example entries we can probably see the first six and 16 entries and here you'll be seeing that it is being asking me for the HF token Grant access uh HF token is nothing but my hugging face token since we are downloading the data set from the hugging face so we will definitely be requiring a hugging face token in order to get the hugging face token just go to the settings button over here and if you go over here you'll be seeing something called as exess token you can copy this exess token and use it uh inside your notebook file how to use it just click on Grant access here you'll be able to see in my secret key HF token is already put up right so over here with respect to this particular HF token it'll be able to access it and it'll be able to download this entire data set right so you also require a hugging face token over here right again in order to get this you just go to the settings access token you'll be getting over here create a secret key with the name of HF undor token and the key name whatever is probably getting from this particular page that is hugging face okay so once you probably do this then what we will do is that these are some of the example entries that you'll be able to see with respect to every records that you can actually see from this particular data set now the next thing is that see our data set looks something like this author quote and tags it is just like an Excel file which has three Fields okay author quote and tags we will be reading all this information this quote is my main information this author and tags are like my metadata information so here what we are doing is that here we will be setting uh we'll be constructing a set of documents from the data documents can be used as input to your vectors okay so what we are doing over here we are going with respect to every data set we are traversing through every data set then here a variable is created which is called as metadata we are putting that metadata information with respect to author then we are saying that if tags is present right we are going to split that particular tag and then we are going to set up this particular value that basically means we are adding metadata tags to the metadata diary and then finally we create a langin document with the code and metadata tags so here you can see document we are using the page content entry code and then finally we are also using the metadata and we are upending the documents you will be getting an idea how this particular documents looks likees okay so let me just go and show you the documents so here is how your documents looks likees right you you have author can't education y knowledge y then here is your entire document right so if you see this document you'll also be seeing the metadata information that has been attached metadata is author is nothing but C right similarly other one you can see document page even a man this one is there and then metadata you have who is the author ethics knowledge yes or no right so this is basically uh selecting whether this field has knowledge ethics if it has knowledge it is going to consider as y otherwise it is just going to skip it okay just to keep that particular information in mind so these are my entire documents that you can probably see now we are going to create the embedding and we will insert this document into our Vector store understand the vector store that we are specifically using is nothing but data Stacks uh astrab so here V store is already created here you can probably see uh V store is there where is the V store okay here V store very is there which is our type astrab Vector store and then we can probably add all these documents over there right so here we can see V store. add documents with respect to docs and let's go ahead and insert all the 450 documents that are there so this will take some amount of time but understand here you can see oh it is already um inserted also so this is amazingly well so nice speed and all so if I go ahead and reload this here you'll be able to see that all the readings are are there and that particular data has been probably stored in this particular DB itself right so all the information over here and with respect to this how many requests are there how many throughputs are there see total number of records are 50 right and here the similarity the similarity algorithm that is basically going to get applied is nothing but cosine similarity so here you can see 450 records in this particular test collection it is inserted okay so good good enough uh here you can see all the inserted documents are there now let's go ahead and do this and before I go ahead let me go ahead and see what is the name that I've actually kept okay and this is important The Collection name the collection name that I have specifically used is nothing but test so I'm going to use the same test over here okay and I'll put it over here so now checks your collection to verify the documents are embedded or not so here we are going to print Asad db. collectionof test. find so if you go ahead and probably check it out here you'll be able to see that you'll be getting some information with respect to the document ID and all in the form of vectors so all of these are like vectors you know so all the vectors are basically getting converted and stored into the data Stacks Astra DB right so all these are vectors you can probably see with respect to all the information over here right perfect now let's go ahead and do the basic retrieval and again here we are going to use Lang chain we are going to use open Ai and all so here uh you can see see Lang chain also have not imported separately there is something called as ra rack stack automatically it is provided by the data data Stacks itself so what we are doing is that we are just installing R stack and automatically you'll be able to see that all the libraries are installed over here so from lin. prompts we are going to use chat prompt template chat open AI string output parsel runable pass through and then we are saying that we will convert this Vector store which is a vector store DB as retriever now if you don't know what is as retriever this is nothing but is an interface that is being attached to the vector store so that we get the results out of it and we are saying that provide me the top three results okay along with this we are going to set up the prompt template uh we are saying that answer the question based on the supply context if you don't know the answer say you don't know it otherwise based on the context your answer it'll probably give it then we'll be using a chat prompt template already we know that this entire prompt template is created so chat prom template. prom template we are going to use this prom template we are going to initialize chat open API um and then we are going to use this context is equal to retriever question is equal to running pass through runable pass through and we're going to append The Prompt the model and the string output parser right so this will basically be creating my entire llm chain okay so llm chain will also work in this specific manner first of all it will consider this particular context whatever returned or documents that is coming from there the from the vector DB um from the Astra DB sorry which is nothing but it is Vector store DB then we have prompt then we have model then we have string output parsa prompt is nothing but whatever prompt you have defined over here then model is going to act on the specific prompt based on the context that it has and final it is going to display so here in order to execute it we'll just write chain. invok in the given context what subjects are philosopher mostly concerned with so one of the question from this particular statement right uh regarding philosopher it is uh and then we are going to basically ask that particular question from there so once we execute this okay so here you can see philosophers are mostly concerned with knowledge and truth so that basically means here in the tags wherever knowledge and Truth was there with respect to that particular statement that you are able to get it over there now let's try some more examples so here let's T pick up something right so men best shows the characters in Trifles okay I'll try to show with you with some of the tags tags itself right what is the difficulty okay what is the difficulty okay something some information is over here what is the what subjects are what difficulties okay I will just say like this the difficulty most concerned with with context are related to determining the possibilities principle and extent of human knowledge so somewhere some information it is being able to pick it up and it is being able to show it to us right it is the most important to allow the brain to fully measure the sleep what is the most important thing to allow the brain okay so like this I will try to write a sentence what is the most important to allow the brain let's see whether it will be able to give me the the most important to allow the full measure of sleeps required to restore it now this is amazing right uh and here you can actually see so many different things are there okay or I'll say what is the most important to allow the brain and provide me the tags let's see I'm just writing something okay at least it will be able to give me the see ethics and knowledge right and all this information are probably coming up and here you can see that how efficient it is further if you really want to delete the collection you can probably delete it from here so here I will just show you how to delete it also uh V store is not there expected indent okay no worries this was it and finally you can see that I'm also deleting the collections over here so from end to end completely from starting till deleting the collection everything is shown from here to here and here you can probably see that with respect to your data set just by setting up the metadata and all you'll also be able to do all these things right and again thank you for this amazing thing that has been brought up by data stack itself uh the entire uh Astra DB which is amazing alog together with respect to creating your rack Pipeline and obviously with this particular rack stack you can see how much easy the installation has basically happened so yes this was it for my side I'll see you in the next video have a great day thank you wonder all take care bye-bye
Original Description
Build now with Astra DB: https://dtsx.io/KrishAstraDB
Code file: https://colab.research.google.com/drive/1EzZVsPba-eXXhnC0Y8f7F_SawUvUbmNQ
-------------------------------------------------------------------------------------------------
Support me by joining membership so that I can upload these kind of videos
https://www.youtube.com/channel/UCNU_lfiiWBdtULKOw6X0Dig/join
-----------------------------------------------------------------------------------
►AWS Bedrock Playlist: https://www.youtube.com/watch?v=2maPaQutcWs&list=PLZoTAELRMXVP8-wzKPtrRST3jNCprvMZj
►Llamindex Playlist: https://www.youtube.com/watch?v=1eym7BTnuNg&list=PLZoTAELRMXVNOWh1SDXt5NFujQMOt-CWy
►Google Gemini Playlist: https://www.youtube.com/watch?v=it0l6lx3qI0&list=PLZoTAELRMXVNbDmGZlcgCA3a8mRQp5axb&pp=gAQBiAQB
►Langchain Playlist: https://www.youtube.com/watch?v=4O1rs7mrNDo&list=PLZoTAELRMXVORE4VF7WQ_fAl0L1Gljtar&pp=gAQBiAQB
►Data Science Projects:
https://www.youtube.com/watch?v=S_F_c9e2bz4&list=PLZoTAELRMXVPS-dOaVbAux22vzqdgoGhG&pp=iAQB
►Learn In One Tutorials
Statistics in 6 hours: https://www.youtube.com/watch?v=LZzq1zSL1bs&t=9522s&pp=ygUVa3Jpc2ggbmFpayBzdGF0aXN0aWNz
End To End RAG LLM APP Using LlamaIndex And OpenAI- Indexing And Querying Multiple Pdf's
Machine Learning In 6 Hours: https://www.youtube.com/watch?v=JxgmHe2NyeY&t=4733s&pp=ygUba3Jpc2ggbmFpayBtYWNoaW5lIGxlYXJuaW5n
Deep Learning 5 hours : https://www.youtube.com/watch?v=d2kxUVwWWwU&t=1210s&pp=ygUYa3Jpc2ggbmFpayBkZWVwIGxlYXJuaW5n
►Learn In a Week Playlist
Statistics:https://www.youtube.com/watch?v=11unm2hmvOQ&list=PLZoTAELRMXVMgtxAboeAx-D9qbnY94Yay
Machine Learning : https://www.youtube.com/watch?v=z8sxaUw_f-M&list=PLZoTAELRMXVPjaAzURB77Kz0YXxj65tYz
Deep Learning:https://www.youtube.com/watch?v=8arGWdq_KL0&list=PLZoTAELRMXVPiyueAqA_eQnsycC_DSBns
NLP : https://www.youtube.com/watch?v=w3coRFpyddQ&list=PLZoTAELRMXVNNrHSKv36Lr3_156yCo6Nn
---------------------------------------------------------------------------------------
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from Krish Naik · Krish Naik · 0 of 60
← Previous
Next →
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Natural Language Processing|Stemming
Krish Naik
Natural Language Processing|BagofWords
Krish Naik
Gaussian distribution or Normal Distribution in statisctics
Krish Naik
Natural Language Processing|TF-IDF for Machine Learning| Text Prerocessing
Krish Naik
Log Normal Distribution in Statistics
Krish Naik
Covariance in Statistics
Krish Naik
Confusion matrix, Precision, Recall| Data Science Interview questions
Krish Naik
Tutorial 44-Balanced vs Imbalanced Dataset and how to handle Imbalanced Dataset
Krish Naik
Implementing a Spam classifier in python| Natural Language Processing
Krish Naik
Tutorial 11-Exploratory Data Analysis(EDA) of Titanic dataset
Krish Naik
Face Recognition using open CV and VGG 16 Transfer Learning
Krish Naik
Pedestrian Detection using OpenCV from Videos
Krish Naik
Face and Eye Detection from Videos using HAAR Cascade Classifier
Krish Naik
Reading, Writing and Displaying images with Opencv| OpenCV Tutorial
Krish Naik
OpenCV Installation | OpenCV tutorial
Krish Naik
Face and Eye Detection from Images using HAAR Cascade Classifier
Krish Naik
Car Detection using HAAR Cascade and Opencv from Videos.
Krish Naik
Using OpenFace for Face recognition in Keras
Krish Naik
OpenPose Tutorial with Tensorflow
Krish Naik
Multiple Linear Regression using python and sklearn
Krish Naik
Dimensional Reduction| Principal Component Analysis
Krish Naik
Movie Recommender System using Python
Krish Naik
TPR,FPR,FNR,TNR, Confusion Matrix
Krish Naik
Precision, Recall and F1-Score
Krish Naik
Artificial Neural Network for Customer's Exit Prediction from Bank
Krish Naik
GridSearchCV- Select the best hyperparameter for any Classification Model
Krish Naik
RandomizedSearchCV- Select the best hyperparameter for any Classification Model
Krish Naik
K Nearest Neighbor classification with Intuition and practical solution
Krish Naik
K Means Clustering Intuition
Krish Naik
Create custom Alexa Skill- Lambda function- Part2
Krish Naik
Hierarchical Clustering intuition
Krish Naik
Implement Transfer Learning with a generic Code Template
Krish Naik
Gender Classifier and Age Estimator using Resnet Convolution Neural Network
Krish Naik
Unlock Your Application With Your Face using OpenCV
Krish Naik
Draw rectangle from webcam and sketch process it on a live feed
Krish Naik
Complete Life Cycle of a Data Science Project
Krish Naik
How we can apply Machine Learning in Finance
Krish Naik
Deep Learning in Medical Science
Krish Naik
How to switch your career to Data Science.
Krish Naik
Linear Regression Mathematical Intuition
Krish Naik
Handle Categorical features using Python
Krish Naik
Machine Learning Algorithm- Which one to choose for your Problem?
Krish Naik
DBSCAN Clustering Easily Explained with Implementation
Krish Naik
Curse of Dimensionality Easily explained| Machine Learning
Krish Naik
Feature Selection Techniques Easily Explained | Machine Learning
Krish Naik
Tutorial 29-R square and Adjusted R square Clearly Explained| Machine Learning
Krish Naik
Cross Validation using sklearn and python | Machine Learning
Krish Naik
Handling Missing Data Easily Explained| Machine Learning
Krish Naik
Deploy Machine Learning Model using Flask
Krish Naik
Deployment of Deep Learning Model using Flask
Krish Naik
How to Visualize Multiple Linear Regression in python
Krish Naik
K Nearest Neighbour Easily Explained with Implementation
Krish Naik
Predicting Heart Disease using Machine Learning
Krish Naik
Predicting Lungs Disease using Deep Learning
Krish Naik
Stock Sentiment Analysis using News Headlines
Krish Naik
Random Forest(Bootstrap Aggregation) Easily Explained
Krish Naik
Voting Classifier(Hard Voting and Soft Voting Classifier)
Krish Naik
Credit Card Fraud Detection using Machine Learning from Kaggle
Krish Naik
Hyperparameter Optimization for Xgboost
Krish Naik
Tutorial 45-Handling imbalanced Dataset using python- Part 1
Krish Naik
More on: LLM Engineering
View skill →Related Reads
🎓
Tutor Explanation
DeepCamp AI