From 0a64b4737e6664a2fe1551f1b687f2c84bdc23b3 Mon Sep 17 00:00:00 2001 From: MalvinaNikandrou Date: Tue, 5 Dec 2023 01:09:46 +0000 Subject: [PATCH] Remove utterance verification --- .../api/controllers/simbot/controller.py | 7 ---- .../api/controllers/simbot/pipelines.py | 3 -- .../datamodels/simbot/__init__.py | 1 - .../datamodels/simbot/enums/__init__.py | 1 - .../datamodels/simbot/enums/intents.py | 12 ++----- .../pipelines/simbot/__init__.py | 3 -- .../simbot/user_utterance_verification.py | 35 ------------------- 7 files changed, 3 insertions(+), 59 deletions(-) delete mode 100644 src/emma_experience_hub/pipelines/simbot/user_utterance_verification.py diff --git a/src/emma_experience_hub/api/controllers/simbot/controller.py b/src/emma_experience_hub/api/controllers/simbot/controller.py index e442119b..c9e83a95 100644 --- a/src/emma_experience_hub/api/controllers/simbot/controller.py +++ b/src/emma_experience_hub/api/controllers/simbot/controller.py @@ -78,13 +78,6 @@ def load_session_from_request(self, simbot_request: SimBotRequest) -> SimBotSess session = self.pipelines.request_processing.run(simbot_request) - # Verify user utterance is valid - if self.settings.is_not_offline_evaluation and simbot_request.speech_recognition: - user_intent = self.pipelines.user_utterance_verifier.run( - simbot_request.speech_recognition - ) - session.current_turn.intent.user = user_intent - # Cache the auxiliary metadata for the turn self.clients.features.get_auxiliary_metadata(session.current_turn) diff --git a/src/emma_experience_hub/api/controllers/simbot/pipelines.py b/src/emma_experience_hub/api/controllers/simbot/pipelines.py index 07cace71..7c8444f0 100644 --- a/src/emma_experience_hub/api/controllers/simbot/pipelines.py +++ b/src/emma_experience_hub/api/controllers/simbot/pipelines.py @@ -21,7 +21,6 @@ SimBotFindObjectPipeline, SimBotRequestProcessingPipeline, SimBotUserIntentExtractionPipeline, - SimBotUserUtteranceVerificationPipeline, ) @@ -29,7 +28,6 @@ class SimBotControllerPipelines(BaseModel, arbitrary_types_allowed=True): """All the pipelines used by the SimBot Controller API.""" request_processing: SimBotRequestProcessingPipeline - user_utterance_verifier: SimBotUserUtteranceVerificationPipeline user_intent_extractor: SimBotUserIntentExtractionPipeline environment_intent_extractor: SimBotEnvironmentIntentExtractionPipeline agent_intent_selector: SimBotAgentIntentSelectionPipeline @@ -66,7 +64,6 @@ def from_clients( request_processing=SimBotRequestProcessingPipeline( session_db_client=clients.session_db, ), - user_utterance_verifier=SimBotUserUtteranceVerificationPipeline(), user_intent_extractor=SimBotUserIntentExtractionPipeline( qa_intent_client=clients.simbot_qa, qa_intent_parser=SimBotQAOutputParser( diff --git a/src/emma_experience_hub/datamodels/simbot/__init__.py b/src/emma_experience_hub/datamodels/simbot/__init__.py index 19d4276c..28cb282a 100644 --- a/src/emma_experience_hub/datamodels/simbot/__init__.py +++ b/src/emma_experience_hub/datamodels/simbot/__init__.py @@ -10,7 +10,6 @@ SimBotDummyRawActions, SimBotEnvironmentIntentType, SimBotIntentType, - SimBotInvalidUtteranceIntentType, SimBotNLUIntentType, SimBotPhysicalInteractionIntentType, SimBotUserIntentType, diff --git a/src/emma_experience_hub/datamodels/simbot/enums/__init__.py b/src/emma_experience_hub/datamodels/simbot/enums/__init__.py index 49ac4ccf..ed7cf65d 100644 --- a/src/emma_experience_hub/datamodels/simbot/enums/__init__.py +++ b/src/emma_experience_hub/datamodels/simbot/enums/__init__.py @@ -7,7 +7,6 @@ SimBotAnyUserIntentType, SimBotEnvironmentIntentType, SimBotIntentType, - SimBotInvalidUtteranceIntentType, SimBotNLUIntentType, SimBotPhysicalInteractionIntentType, SimBotUserIntentType, diff --git a/src/emma_experience_hub/datamodels/simbot/enums/intents.py b/src/emma_experience_hub/datamodels/simbot/enums/intents.py index 853393a2..1a3de3a0 100644 --- a/src/emma_experience_hub/datamodels/simbot/enums/intents.py +++ b/src/emma_experience_hub/datamodels/simbot/enums/intents.py @@ -15,9 +15,6 @@ class SimBotIntentType(Enum): search = "" act_previous = "" - # Improper instructions - empty_utterance = "" - # Clarification question triggers act_no_match = "" act_too_many_matches = "" @@ -152,9 +149,9 @@ def verbal_interaction_intent_triggers_search(self) -> bool: @staticmethod def is_invalid_utterance_intent_type( # noqa: WPS602 intent_type: SimBotIntentType, - ) -> TypeGuard[SimBotInvalidUtteranceIntentType]: - """Return True if the intent type matches `SimBotInvalidUtteranceIntentType`.""" - return intent_type in SimBotInvalidUtteranceIntentType.__args__ # type: ignore[attr-defined] + ) -> bool: + """Assume user utterances are always valid.""" + return False @staticmethod def is_user_intent_type( # noqa: WPS602 @@ -192,8 +189,6 @@ def is_user_qa_type( # noqa: WPS602 return intent_type in SimBotUserQAType.__args__ # type: ignore[attr-defined] -SimBotInvalidUtteranceIntentType = Literal[SimBotIntentType.empty_utterance,] - SimBotUserQAType = Literal[ SimBotIntentType.ask_about_game, SimBotIntentType.ask_about_agent, @@ -221,7 +216,6 @@ def is_user_qa_type( # noqa: WPS602 SimBotAnyUserIntentType = Literal[ SimBotUserIntentType, - SimBotInvalidUtteranceIntentType, SimBotUserQAType, ] diff --git a/src/emma_experience_hub/pipelines/simbot/__init__.py b/src/emma_experience_hub/pipelines/simbot/__init__.py index 809761e9..d6f4e6a0 100644 --- a/src/emma_experience_hub/pipelines/simbot/__init__.py +++ b/src/emma_experience_hub/pipelines/simbot/__init__.py @@ -20,6 +20,3 @@ from emma_experience_hub.pipelines.simbot.user_intent_extraction import ( SimBotUserIntentExtractionPipeline, ) -from emma_experience_hub.pipelines.simbot.user_utterance_verification import ( - SimBotUserUtteranceVerificationPipeline, -) diff --git a/src/emma_experience_hub/pipelines/simbot/user_utterance_verification.py b/src/emma_experience_hub/pipelines/simbot/user_utterance_verification.py deleted file mode 100644 index 163f6d86..00000000 --- a/src/emma_experience_hub/pipelines/simbot/user_utterance_verification.py +++ /dev/null @@ -1,35 +0,0 @@ -from typing import Optional - -from loguru import logger - -from emma_experience_hub.datamodels.simbot import ( - SimBotIntentType, - SimBotInvalidUtteranceIntentType, -) -from emma_experience_hub.datamodels.simbot.payloads import SimBotSpeechRecognitionPayload - - -class SimBotUserUtteranceVerificationPipeline: - """Validate the utterance from the user is valid. - - The sole purpose of this pipeline is to check whether the incoming utterance is invalid. If it - is not invalid, this pipeline does not process anything else and returns `None`. - """ - - def run( - self, speech_recognition_payload: SimBotSpeechRecognitionPayload - ) -> Optional[SimBotInvalidUtteranceIntentType]: - """Check if the utterance is invalid, returning the type if it is invalid.""" - # Check if the utterance is empty - if self._utterance_is_empty(speech_recognition_payload): - logger.debug("Utterance is empty and doesn't contain any text.") - return SimBotIntentType.empty_utterance - - # Utterance is not invalid - return None - - def _utterance_is_empty( - self, speech_recognition_payload: SimBotSpeechRecognitionPayload - ) -> bool: - """Detect whether the utterance is empty or not.""" - return not bool(speech_recognition_payload.utterance.strip())