theekshana commited on
Commit
32ac7ac
1 Parent(s): 4a20c81

issue: memory solved

Browse files
__pycache__/qaPipeline_chain_only.cpython-311.pyc CHANGED
Binary files a/__pycache__/qaPipeline_chain_only.cpython-311.pyc and b/__pycache__/qaPipeline_chain_only.cpython-311.pyc differ
 
qaPipeline_chain_only.py CHANGED
@@ -86,6 +86,14 @@ def get_local_LLAMA2():
86
  print("\n\n> local LLAMA2 loaded")
87
  return LLAMA2
88
 
 
 
 
 
 
 
 
 
89
  class QAPipeline:
90
 
91
  def __init__(self):
@@ -100,7 +108,7 @@ class QAPipeline:
100
  self.qa_chain = None
101
 
102
  def run_agent(self,query, model, dataset, openai_api_key=None):
103
-
104
  try:
105
  if (self.llm_name != model) or (self.dataset_name != dataset) or (self.qa_chain == None):
106
  self.set_model(model, openai_api_key)
@@ -168,30 +176,22 @@ class QAPipeline:
168
 
169
 
170
  def set_qa_chain(self):
 
171
 
172
  try:
173
- memory = ConversationBufferWindowMemory(
174
- memory_key="chat_history",
175
- input_key="question",
176
- output_key = "answer",
177
- return_messages=True,
178
- k=3
179
- )
180
-
181
  # Define a custom prompt
182
  B_INST, E_INST = "[INST]", "[/INST]"
183
  B_SYS, E_SYS = "<<SYS>>\n", "\n<</SYS>>\n\n"
184
 
185
  retrieval_qa_template = (
186
- """<<SYS>>
187
  You are the AI assistant of company boardpac which provide services to company board members related to banking and financial sector.
188
- You have 2 tasks to do.
189
 
190
- Task 1: combine the given chat history and user question to come up with a follow-up question
191
  <chat history>: {chat_history}
192
 
193
- Task 2:
194
- Identify the type of the follow-up question using following 3 types and answer accordingly.
195
  Answer should be short and simple as possible.
196
  Dont add any extra details that is not mentioned in the context.
197
 
@@ -209,18 +209,21 @@ class QAPipeline:
209
 
210
  <Type 3>
211
  If the follow-up question is related to Banking and Financial Services Sector like Banking & Financial regulations, legal framework, governance framework, compliance requirements as per Central Bank regulations.
212
- please answer the question based on the context information provided in bottom containing few related documents of central bank acts published in various years.
213
  The published year is mentioned as the metadata 'year' of each source document.
214
- The content of a bank act of a past year can updated by a bank act from a latest year.
215
  Always try to answer with latest information and mention the year which information extracted.
216
  If you dont know the answer say you dont know, dont try to makeup answers.
217
  Start the answer with code word Boardpac AI(QA):
218
  </Type 3>
219
-
220
- <Context information>: {context}
221
  <</SYS>>
 
 
 
 
 
222
 
223
- [INST]Question : {question}[/INST]"""
224
  )
225
 
226
  retrieval_qa_chain_prompt = PromptTemplate(
 
86
  print("\n\n> local LLAMA2 loaded")
87
  return LLAMA2
88
 
89
+ memory = ConversationBufferWindowMemory(
90
+ memory_key="chat_history",
91
+ input_key="question",
92
+ output_key = "answer",
93
+ return_messages=True,
94
+ k=3
95
+ )
96
+
97
  class QAPipeline:
98
 
99
  def __init__(self):
 
108
  self.qa_chain = None
109
 
110
  def run_agent(self,query, model, dataset, openai_api_key=None):
111
+
112
  try:
113
  if (self.llm_name != model) or (self.dataset_name != dataset) or (self.qa_chain == None):
114
  self.set_model(model, openai_api_key)
 
176
 
177
 
178
  def set_qa_chain(self):
179
+ print(f"\n> creating agent_chain")
180
 
181
  try:
182
+
 
 
 
 
 
 
 
183
  # Define a custom prompt
184
  B_INST, E_INST = "[INST]", "[/INST]"
185
  B_SYS, E_SYS = "<<SYS>>\n", "\n<</SYS>>\n\n"
186
 
187
  retrieval_qa_template = (
188
+ """<<SYS>>
189
  You are the AI assistant of company boardpac which provide services to company board members related to banking and financial sector.
 
190
 
191
+ First combine the given chat history and user question to come up with a follow-up question
192
  <chat history>: {chat_history}
193
 
194
+ Then dentify the type of the follow-up question using following 3 types and answer accordingly.
 
195
  Answer should be short and simple as possible.
196
  Dont add any extra details that is not mentioned in the context.
197
 
 
209
 
210
  <Type 3>
211
  If the follow-up question is related to Banking and Financial Services Sector like Banking & Financial regulations, legal framework, governance framework, compliance requirements as per Central Bank regulations.
212
+ please answer the question based only on the information provided in following central bank documents published in various years.
213
  The published year is mentioned as the metadata 'year' of each source document.
214
+ Please notice that content of a one document of a past year can updated by a new document from a recent year.
215
  Always try to answer with latest information and mention the year which information extracted.
216
  If you dont know the answer say you dont know, dont try to makeup answers.
217
  Start the answer with code word Boardpac AI(QA):
218
  </Type 3>
 
 
219
  <</SYS>>
220
+
221
+ [INST]
222
+ <DOCUMENTS>
223
+ {context}
224
+ </DOCUMENTS>
225
 
226
+ Question : {question}[/INST]"""
227
  )
228
 
229
  retrieval_qa_chain_prompt = PromptTemplate(