Surat96 commited on
Commit
0fe5322
·
verified ·
1 Parent(s): 344bae8

Upload 8 files

Browse files
.gitattributes CHANGED
@@ -33,3 +33,7 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ Documents/57.YOLO.pdf filter=lfs diff=lfs merge=lfs -text
37
+ Documents/Live[[:space:]]Day[[:space:]]8-Understanding[[:space:]]LSTM[[:space:]]Network.pdf filter=lfs diff=lfs merge=lfs -text
38
+ Documents/Object[[:space:]]Detection.pdf filter=lfs diff=lfs merge=lfs -text
39
+ Documents/Tutorial[[:space:]]0[[:space:]]-Transformers[[:space:]]Indepth[[:space:]]Architecture[[:space:]]Understanding.pdf filter=lfs diff=lfs merge=lfs -text
Documents/57.YOLO.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:54bcd2dd05dc618849e8a94d8b88fe3eeb37f80e96e200600d38f1f733931678
3
+ size 5296750
Documents/CNN.pdf ADDED
Binary file (769 kB). View file
 
Documents/Live Day 8-Understanding LSTM Network.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5b25a915160362e1211cde9af02441d83dee3186a126ba7b3faf3d9568ff9879
3
+ size 4015787
Documents/Object Detection.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f94f16dfee6cc05ed1b8efe3299525529c8ce12a3c7288a6c9b1e89175551932
3
+ size 1666018
Documents/Tutorial 0 - attention-is-all-you-need-Paper.pdf ADDED
Binary file (569 kB). View file
 
Documents/Tutorial 0 -Transformers Indepth Architecture Understanding.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a1872ec7612c2bfe368e471bd55a9326381a638d6fe9bb6110505dfe70426892
3
+ size 22923107
app.py ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import os
3
+ from langchain_groq import ChatGroq
4
+ from langchain.text_splitter import RecursiveCharacterTextSplitter
5
+ from langchain.chains.combine_documents import create_stuff_documents_chain
6
+ from langchain_core.prompts import ChatPromptTemplate
7
+ from langchain.chains import create_retrieval_chain
8
+ from langchain_community.vectorstores import FAISS
9
+ from langchain_community.document_loaders import PyPDFDirectoryLoader
10
+ from langchain_google_genai import GoogleGenerativeAIEmbeddings
11
+ from dotenv import load_dotenv
12
+ import os
13
+ import time
14
+ load_dotenv()
15
+
16
+ ## load the GROQ And OpenAI API KEY
17
+ groq_api_key=os.getenv('GROQ_API_KEY')
18
+ os.environ["GOOGLE_API_KEY"]=os.getenv("GOOGLE_API_KEY")
19
+
20
+ llm=ChatGroq(groq_api_key=groq_api_key, model_name="Llama3-8b-8192") # Gemma2-9b-it Gemma-7b-it
21
+
22
+ prompt=ChatPromptTemplate.from_template(
23
+ """
24
+ Answer the questions based on the provided context only.
25
+ Please provide the most accurate response based on the question
26
+ <context>
27
+ {context}
28
+ <context>
29
+ Questions:{input}
30
+ """
31
+ )
32
+
33
+ def vector_embedding():
34
+ if "vectors" not in st.session_state:
35
+ st.session_state.embeddings=GoogleGenerativeAIEmbeddings(model = "models/embedding-001")
36
+ st.session_state.loader=PyPDFDirectoryLoader("./Documents") ## Data Ingestion
37
+ st.session_state.docs=st.session_state.loader.load() ## Document Loading
38
+ st.session_state.text_splitter=RecursiveCharacterTextSplitter(chunk_size=1000,chunk_overlap=200) ## Chunk Creation
39
+ st.session_state.final_documents=st.session_state.text_splitter.split_documents(st.session_state.docs[:20]) #splitting
40
+ st.session_state.vectors=FAISS.from_documents(st.session_state.final_documents,st.session_state.embeddings) #vector OpenAI embeddings
41
+
42
+
43
+ st.header("Rag Model with multiple documents ChatBot")
44
+ prompt1=st.text_input("Enter Your Question From Doduments")
45
+
46
+ if prompt1:
47
+ document_chain=create_stuff_documents_chain(llm,prompt)
48
+ retriever=st.session_state.vectors.as_retriever()
49
+ retrieval_chain=create_retrieval_chain(retriever,document_chain)
50
+ start=time.process_time()
51
+ response=retrieval_chain.invoke({'input':prompt1})
52
+ print("Response time :",time.process_time()-start)
53
+ st.write(response['answer'])
54
+
55
+ with st.sidebar:
56
+ st.title("Menu:")
57
+ if st.button("Documents Embedding"):
58
+ with st.spinner("Processing..."):
59
+ vector_embedding()
60
+ st.write("Vector Store DB Is Ready")
61
+
62
+
63
+ footer = """
64
+ ---
65
+ #### Made By [Surat Banerjee](https://www.linkedin.com/in/surat-banerjee/)
66
+ For Any Queries, Reach out on [Portfolio](https://suratbanerjee.wixsite.com/myportfoliods)
67
+ """
68
+
69
+ st.markdown(footer, unsafe_allow_html=True)
requirements.txt ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ faiss-cpu
2
+ groq
3
+ langchain-groq
4
+ PyPDF2
5
+ langchain_google_genai
6
+ langchain
7
+ streamlit
8
+ langchain_community
9
+ python-dotenv
10
+ pypdf
11
+ google-cloud-aiplatform>=1.38