Spaces:
Runtime error
Runtime error
Update rag.py
Browse files- app/rag.py +2 -8
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=
|
20 |
self.prompt = PromptTemplate.from_template(
|
21 |
"""
|
22 |
You are an assistant for question-answering tasks. Use the following pieces of context
|
@@ -33,13 +33,7 @@ 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(
|
37 |
-
search_type="similarity_score_threshold",
|
38 |
-
search_kwargs={
|
39 |
-
"k": 28,
|
40 |
-
"score_threshold": 0.5,
|
41 |
-
},
|
42 |
-
)
|
43 |
|
44 |
self.chain = ({"context": self.retriever, "question": RunnablePassthrough()}
|
45 |
| self.prompt
|
|
|
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 |
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
|