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

Commit

Permalink
dyn
Browse files Browse the repository at this point in the history
  • Loading branch information
Jing Xu committed Apr 15, 2022
1 parent 7603951 commit 5c49fcc
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions parlai/agents/fid/fid.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,13 @@ def __init__(self, opt: Opt, shared: TShared = None):
'GoldDocRetrieverFiDAgent only works with `rag_retriever_query` being `"full_history"`. '
f'Changing opt value for `rag_retriever_query`: `"{prev_sel}"` -> `"full_history"`'
)

if (
opt['dynamic_batching'] == 'full'
or opt.get('eval_dynamic_batching') == 'full'
):
raise RuntimeError(
"For now dynamic batching doesn't work with ObservationEchoRetriever as it cleans up _saved_docs mapping after each batch act."
)
super().__init__(opt, shared=shared)

@abstractmethod
Expand Down Expand Up @@ -377,10 +383,13 @@ def _set_query_vec(self, observation: Message) -> Message:
super()._set_query_vec(observation)

def batch_act(self, observations):
output = super().batch_act(observations)
"""
Clear the _saved_docs and _query_ids mappings in ObservationEchoRetriever
"""
batch_reply = super().batch_act(observations)
if hasattr(self.model_api.retriever, 'clear_mapping'):
self.model_api.retriever.clear_mapping()
return output
return batch_reply


class WizIntGoldDocRetrieverFiDAgent(GoldDocRetrieverFiDAgent):
Expand Down

0 comments on commit 5c49fcc

Please sign in to comment.