hash-map commited on
Commit
cab5395
·
verified ·
1 Parent(s): 9da92a2

Update rag.py

Browse files
Files changed (1) hide show
  1. rag.py +10 -5
rag.py CHANGED
@@ -49,11 +49,11 @@ db = FAISS.load_local(
49
 
50
 
51
  # Vector Store Retriever
52
- vector_retriever = db.as_retriever(search_kwargs={"k": 3})
53
 
54
  # Keyword Retriever (BM25)
55
  bm25_retriever = BM25Retriever.from_documents(texts)
56
- bm25_retriever.k = 2
57
 
58
  # Combine both
59
  def ensemble_retriever(query):
@@ -76,7 +76,8 @@ def respond_rag_huggingface(message: str):
76
  context = "\n\n".join(doc.page_content for doc in docs)
77
 
78
  system_message = os.environ.get("SYSTEM_MESSAGE",
79
- "You are a Game of Thrones measter. Answer the given question based on the context understand the context and try to answer based upon the context.do not give faulty answers and if any dialogue or description mention them ")
 
80
 
81
  prompt = f"""{system_message}
82
 
@@ -87,9 +88,13 @@ Question:
87
  {message}
88
 
89
  Rules:
90
- - If the answer isn't in the context, respond with "I don't know"
 
91
  - Keep answers under 5 sentences
92
- - Include book/season references when possible"""
 
 
 
93
 
94
  response = model.generate_content(prompt)
95
  return response.text
 
49
 
50
 
51
  # Vector Store Retriever
52
+ vector_retriever = db.as_retriever(search_kwargs={"k": 5})
53
 
54
  # Keyword Retriever (BM25)
55
  bm25_retriever = BM25Retriever.from_documents(texts)
56
+ bm25_retriever.k = 5
57
 
58
  # Combine both
59
  def ensemble_retriever(query):
 
76
  context = "\n\n".join(doc.page_content for doc in docs)
77
 
78
  system_message = os.environ.get("SYSTEM_MESSAGE",
79
+ "You are a Game of Thrones measter and harry potter's dumbledore"+
80
+ ". Answer the given question based on the context understand the context and try to answer based upon the context.do not give faulty answers and if any dialogue or description mention them ")
81
 
82
  prompt = f"""{system_message}
83
 
 
88
  {message}
89
 
90
  Rules:
91
+ - If the answer isn't in the context, respond with something you know about them and do not mention about about context
92
+ - try to say that i exactly mean different than i do not know
93
  - Keep answers under 5 sentences
94
+ - Include book/season references when possible
95
+ - vector store contains both game of thrones and harry potter vectors so answer based on relevant context
96
+
97
+ """
98
 
99
  response = model.generate_content(prompt)
100
  return response.text