mitulagr2 commited on
Commit
446d023
·
1 Parent(s): 0ee737b

Update rag.py

Browse files
Files changed (1) hide show
  1. app/rag.py +3 -2
app/rag.py CHANGED
@@ -21,13 +21,14 @@ class ChatPDF:
21
  temperature=0,
22
  num_predict=512,
23
  repeat_penalty=1.3,
 
24
  )
25
 
26
  self.text_splitter = RecursiveCharacterTextSplitter(chunk_size=2048, chunk_overlap=128)
27
  self.prompt = PromptTemplate.from_template(
28
  """
29
  <|im_start|> You are an assistant for question-answering tasks. Use the following pieces of retrieved context to
30
- answer the question. If you don't know the answer, just say that you don't know. Use three sentences
31
  maximum and keep the answer concise. <|im_end|>
32
  <|im_start|> Question: {question}
33
  Context: {context}
@@ -58,7 +59,7 @@ class ChatPDF:
58
  if not self.chain:
59
  return "Please, add a PDF document first."
60
 
61
- return self.chain.invoke(query[:512])
62
 
63
  def clear(self):
64
  self.vector_store = None
 
21
  temperature=0,
22
  num_predict=512,
23
  repeat_penalty=1.3,
24
+ metadata={"num_predict":512},
25
  )
26
 
27
  self.text_splitter = RecursiveCharacterTextSplitter(chunk_size=2048, chunk_overlap=128)
28
  self.prompt = PromptTemplate.from_template(
29
  """
30
  <|im_start|> You are an assistant for question-answering tasks. Use the following pieces of retrieved context to
31
+ answer the question. If you don't know the answer, just say that you don't know. Use 512 characters
32
  maximum and keep the answer concise. <|im_end|>
33
  <|im_start|> Question: {question}
34
  Context: {context}
 
59
  if not self.chain:
60
  return "Please, add a PDF document first."
61
 
62
+ return self.chain.invoke(query)
63
 
64
  def clear(self):
65
  self.vector_store = None