This repository has been archived by the owner on Nov 3, 2023. It is now read-only.
[BlenderBot2] Fix ObservationEchoRetriever #4428
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Patch description
This is to fix some corner cases in
ObservationEchoRetriever
andBlenderBot2WizIntGoldDocRetrieverFiDAgent
:1.
show_observation_to_echo_retriever
is called twice inBlenderBot2WizIntGoldDocRetrieverFiDAgent._set_qyert_vec
, which means theself.model_api.retriever.add_retrieve_doc(observation[self._query_key], retrieved_docs)
is also called twice, which would mess up with the query → idx → doc mapping inObservationEchoRetriever
, and the same docs might be returned for distinct queries in a single batch.add_retrieve_doc
:new_idx = 0
,_query_ids = {query0 : 0}
,_saved_docs={0 : docs0}
show_observation_to_echo_retriever
is called the 2nd time,new_idx = 1
,_query_ids={query0 : 1}
,_saved_docs={1 : docs0}
;new_idx = 1
,_query_ids={query0 : 1, query1: 1}
,_saved_docs={1: docs1 }
. notice that 1: docs0 was overriden. After the 2nd call,new_idx = 2, _query_ids={query0 : 1, query1: 2} , _saved_docs={1 : docs1, 2: docs1}
.docs1
since the new_idx for the new query1 isn't unique when created.Another issue is that in ObservationEchoRetriever: the
_query_ids
dictionary can grow linearly with the number of unique queries it see during training.The fix is to
_query_ids
and_saved_doc
dictionaries after batch retrieval is done.Testing steps
Other information