abdullahT commited on
Commit
13fa0fd
1 Parent(s): 2921f64

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -4
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.05,
19
  'gpu_layers': 10}
20
  else:
21
- config={'max_new_tokens':2048,
22
  'context_length': 4096,
23
- 'temperature':0.05}
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=300, chunk_overlap=0)
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)