This chatbot is meant to answer all your questions related to BT203, BT204, BT204, trained using all the textbooks of the respective courses.
- Extracted dats Books PDF
- Divided into text Chunks (750 in Llama 2 and 10,000 in Gemini pro)
- Using Embeedings
- Vector storage (PINECONE for Llama 2 and Chroma for Gemini) then semantic and similarity search (Can use Cosine, Eucledian or any but in my opinion cosine should be used)
- Final refined Results using Llama 2 7B model (Y'll can use any model of your choice of any number of parameters) (6. Deployment using Streamlit or Flask)
![download (1)](https://private-user-images.githubusercontent.com/154406386/292763938-45d4efa0-dbb5-484e-8a94-5891e762c83c.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMTg3ODMsIm5iZiI6MTcyNjExODQ4MywicGF0aCI6Ii8xNTQ0MDYzODYvMjkyNzYzOTM4LTQ1ZDRlZmEwLWRiYjUtNDg0ZS04YTk0LTU4OTFlNzYyYzgzYy5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwOTEyJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDkxMlQwNTIxMjNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1hNTcxNzc0NTRhMDExOTI2N2MwODNhODdmOTJkZmYyMTQ2OWI3OTgwOTFhZGZjYjQ3ZWE2MTA0NmZhMTNiNWI4JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.eWyTVfUsUhco9t3uEA3EGcTdqzi8rfCgXWlUC34vves)
Implemented the same thing using Google-Gemini-Pro-API which you can find in Course-ChatBot-using-Gemini-Pro.ipynb
file.
But Before everything let me drop some notes
- For embedding model in this case I implemented a google embeddings model
embedding-001
unlike last time as we used a hugging face embedding model - For Vector Database I used Chroma this time but few things to note again, Chroma is efficient for many use cases, it might not match Pinecone’s performance in certain high-throughput real-time scenarios as Pinecone excels at similarity search. ChromaDB is an open-source database that you need to set up and manage yourself. This can be a significant hurdle for users who don't have experience with database administration or who require a plug-and-play solution. Pinecone, on the other hand, is a managed service that takes care of all the infrastructure and maintenance, making it much easier to get started. However, if you're comfortable with managing your own infrastructure, appreciate the flexibility of open-source software, and have budget constraints, ChromaDB could be a viable option.
- I just implemented it in jupyter notebook instead of deploying it. But if you are cloning it then the architecture is same for both hence you can just and paste the same part of the code over the files created and edit it.
- This model is Trained To run over Local CPU hence it might take some time (<2 min definetely) to get response.
- Also as I mentioned you can use any model of any number of parameter but do keep in mind that Larger size means smarter, but slower.
- I set the temperature value to 0.8. Now what's Temperature? Adjusts randomness of outputs, greater than 1 is random and 0 is deterministic to the point, 0.75 is a good starting value hence I used 0.8.
- Also you can change the number of tokens, a word is generally 2-3 tokens.
- In the
Line 23
ofapp.py
change theindex_name
based upon yourindex_name
. - I used some randomly AI generated HTML CSS code So I dont take credit for this (Also dont judge me for this :)
Clone the repository
Run This Over your terminal : git clone https://github.com/suvraadeep/Course-ChatBot.git
Change the python version based upon the version over your PC
conda create -n chatbot python=3.10.9 -y
conda activate chatbot
We will download all the Libs required altogether
pip install -r requirements.txt
We will use Pinecone database for this project but again you can use ChromaDB or any database of your choice You need to generate it yourself
PINECONE_API_KEY = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
PINECONE_API_ENV = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
## Download the Llama 2 Model:
The model I used is llama-2-7b-chat.ggmlv3.q8_0.bin
## From the following link:
https://huggingface.co/TheBloke/Llama-2-7B-Chat-GGML/tree/main
## For other parameter models you can use
## 13B Quantized model
https://huggingface.co/TheBloke/Llama-2-13B-chat-GGML
## You can also use up the model originally from mets site using
https://ai.meta.com/llama/
# Finally run the following file
app.py
# Finally paste it over your browser
localhost:8069
cheers ;)