Fix issues for a 'DistributedDataParallel' object
Fix error to address the `AttributeError: 'DistributedDataParallel' object has no attribute 'tokenize_query'`
@@ -509,6 +509,9 @@ class RagAgent(TransformerGeneratorRagAgent, BartRagAgent, T5RagAgent):
return observation with query vec.
"""
query_str = observation[self._query_key]
+ if hasattr(self.model, 'module'):
+ observation['query_vec'] = self.model.module.tokenize_query(query_str)
+ else:
observation['query_vec'] = self.model.tokenize_query(query_str)
return observation
