mitulagr2 commited on
Commit
f1cf709
1 Parent(s): 862bc58

Update rag.py

Browse files
Files changed (1) hide show
  1. app/rag.py +8 -2
app/rag.py CHANGED
@@ -16,7 +16,7 @@ class ChatPDF:
16
 
17
  def __init__(self):
18
  self.model = ChatOllama(model="qwen:0.5b")
19
- self.text_splitter = RecursiveCharacterTextSplitter(chunk_size=128, chunk_overlap=8)
20
  self.prompt = PromptTemplate.from_template(
21
  """
22
  You are an assistant for question-answering tasks. Use the following pieces of context
@@ -33,7 +33,13 @@ class ChatPDF:
33
  chunks = filter_complex_metadata(chunks)
34
 
35
  vector_store = Chroma.from_documents(documents=chunks, embedding=FastEmbedEmbeddings())
36
- self.retriever = vector_store.as_retriever(search_kwargs={"k": 56})
 
 
 
 
 
 
37
 
38
  self.chain = ({"context": self.retriever, "question": RunnablePassthrough()}
39
  | self.prompt
 
16
 
17
  def __init__(self):
18
  self.model = ChatOllama(model="qwen:0.5b")
19
+ self.text_splitter = RecursiveCharacterTextSplitter(chunk_size=1024, chunk_overlap=96)
20
  self.prompt = PromptTemplate.from_template(
21
  """
22
  You are an assistant for question-answering tasks. Use the following pieces of context
 
33
  chunks = filter_complex_metadata(chunks)
34
 
35
  vector_store = Chroma.from_documents(documents=chunks, embedding=FastEmbedEmbeddings())
36
+ self.retriever = vector_store.as_retriever(
37
+ search_type="similarity_score_threshold",
38
+ search_kwargs={
39
+ "k": 7,
40
+ "score_threshold": 0.1,
41
+ },
42
+ )
43
 
44
  self.chain = ({"context": self.retriever, "question": RunnablePassthrough()}
45
  | self.prompt