Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Commit

Permalink
flush (#4198)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jing authored Nov 23, 2021
1 parent 5d15e28 commit 1fa8f7a
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions projects/blenderbot2/agents/modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,14 @@ def get_retrieval_indices(
assert self.knowledge_access_method is KnowledgeAccessMethod.CLASSIFY
return type_indices

def flush_previous_retriever_search_results(self):
if not hasattr(self, 'retriever'):
return
if hasattr(self.retriever, 'top_docs'):
delattr(self.retriever, 'top_docs')
if hasattr(self.retriever, 'search_queries'):
delattr(self.retriever, 'search_queries')

def retrieve_and_concat(
self,
input: torch.LongTensor,
Expand All @@ -314,6 +322,7 @@ def retrieve_and_concat(
Override RagModel.retrieve_and_concat to perform different retrieval, depending
on the RetrieverType.
"""
self.flush_previous_retriever_search_results()
start = time.time()
logging.debug(f'Begin encoder: {time.time() - start:.2f}')
if input_turns_cnt is not None:
Expand Down

0 comments on commit 1fa8f7a

Please sign in to comment.