Update app.py
Browse files
app.py
CHANGED
@@ -15,12 +15,12 @@ def model_response(query,docs_page_content):
|
|
15 |
if torch.cuda.is_available():
|
16 |
config={'max_new_tokens':1024,
|
17 |
'context_length': 4096,
|
18 |
-
'temperature':0.
|
19 |
'gpu_layers': 10}
|
20 |
else:
|
21 |
-
config={'max_new_tokens':
|
22 |
'context_length': 4096,
|
23 |
-
'temperature':0.
|
24 |
|
25 |
### LLama2 model
|
26 |
llm=CTransformers(model='models/llama-2-7b-chat.ggmlv3.q8_0.bin',
|
@@ -49,7 +49,7 @@ def model_response(query,docs_page_content):
|
|
49 |
|
50 |
def similarity_finder(data):
|
51 |
|
52 |
-
text_splitter=RecursiveCharacterTextSplitter(chunk_size=
|
53 |
docs=text_splitter.split_documents(data)
|
54 |
db = FAISS.from_documents(docs, embeddings)
|
55 |
query_similarity = db.similarity_search(query, k= 4)
|
@@ -79,6 +79,7 @@ if doc_type == 'Youtube Video':
|
|
79 |
loader = YoutubeLoader.from_youtube_url(yt_link)
|
80 |
data = loader.load()
|
81 |
docs_page_content = similarity_finder(data)
|
|
|
82 |
if yt_link is not None:
|
83 |
if query != '':
|
84 |
model_response(query,docs_page_content)
|
@@ -98,6 +99,7 @@ elif doc_type == 'PDF File':
|
|
98 |
loader = PyPDFLoader("files/pdf_file.pdf")
|
99 |
data = loader.load()
|
100 |
docs_page_content = similarity_finder(data)
|
|
|
101 |
if pdf_file is not None:
|
102 |
if query != '':
|
103 |
model_response(query,docs_page_content)
|
|
|
15 |
if torch.cuda.is_available():
|
16 |
config={'max_new_tokens':1024,
|
17 |
'context_length': 4096,
|
18 |
+
'temperature':0.5,
|
19 |
'gpu_layers': 10}
|
20 |
else:
|
21 |
+
config={'max_new_tokens':1028,
|
22 |
'context_length': 4096,
|
23 |
+
'temperature':0.5}
|
24 |
|
25 |
### LLama2 model
|
26 |
llm=CTransformers(model='models/llama-2-7b-chat.ggmlv3.q8_0.bin',
|
|
|
49 |
|
50 |
def similarity_finder(data):
|
51 |
|
52 |
+
text_splitter=RecursiveCharacterTextSplitter(chunk_size=1000, chunk_overlap=100)
|
53 |
docs=text_splitter.split_documents(data)
|
54 |
db = FAISS.from_documents(docs, embeddings)
|
55 |
query_similarity = db.similarity_search(query, k= 4)
|
|
|
79 |
loader = YoutubeLoader.from_youtube_url(yt_link)
|
80 |
data = loader.load()
|
81 |
docs_page_content = similarity_finder(data)
|
82 |
+
print(docs_page_content)
|
83 |
if yt_link is not None:
|
84 |
if query != '':
|
85 |
model_response(query,docs_page_content)
|
|
|
99 |
loader = PyPDFLoader("files/pdf_file.pdf")
|
100 |
data = loader.load()
|
101 |
docs_page_content = similarity_finder(data)
|
102 |
+
print(docs_page_content)
|
103 |
if pdf_file is not None:
|
104 |
if query != '':
|
105 |
model_response(query,docs_page_content)
|