-
Notifications
You must be signed in to change notification settings - Fork 2.1k
[GoldDocFidAgent] clear mapping at the end of each eval_step rather than retrieve step #4503
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -376,6 +382,15 @@ def _set_query_vec(self, observation: Message) -> Message: | |
self.show_observation_to_echo_retriever(observation) | ||
super()._set_query_vec(observation) | ||
|
||
def batch_act(self, 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'): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks like a good solution. But what about cleaning on batchify that you suggested? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I realize I can't do that in batchify, since model act flow is observe (insert k,v pairs to the Also notice another problem with this change (it won't reset the mapping in train step), let me update the pr and ping you guys again after it's ready. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What if we clear after act/batch_act from the FiD agent? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yea that's my sol rn. |
||
self.model_api.retriever.clear_mapping() | ||
return batch_reply | ||
|
||
|
||
class WizIntGoldDocRetrieverFiDAgent(GoldDocRetrieverFiDAgent): | ||
""" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note that
dynamic_batching
can also be'batchsort'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for pointing that out. fixed