Skip to content

Commit

Permalink
Remove confirmation
Browse files Browse the repository at this point in the history
  • Loading branch information
MalvinaNikandrou committed Dec 5, 2023
1 parent 51de2af commit cb203c8
Show file tree
Hide file tree
Showing 18 changed files with 37 additions and 441 deletions.
4 changes: 0 additions & 4 deletions .env.simbot
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
SIMBOT_AUXILIARY_METADATA_DIR='./storage/simbot/fixtures/game_metadata'

SIMBOT_EXTRACTED_FEATURES_DIR='./storage/fixtures/simbot/features'

SIMBOT_AUXILIARY_METADATA_S3_BUCKET="emma-simbot-live-challenge"

SIMBOT_FEATURE_EXTRACTOR_CHECKPOINT_URI='s3://emma-simbot/model/checkpoints/vinvl_vg_x152c4_simbot.pth'
3 changes: 0 additions & 3 deletions src/emma_experience_hub/api/clients/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
from emma_experience_hub.api.clients.client import Client
from emma_experience_hub.api.clients.confirmation_response_classifier import (
ConfirmationResponseClassifierClient,
)
from emma_experience_hub.api.clients.emma_policy import EmmaPolicyClient
from emma_experience_hub.api.clients.feature_extractor import FeatureExtractorClient

This file was deleted.

12 changes: 1 addition & 11 deletions src/emma_experience_hub/api/controllers/simbot/clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@
from loguru import logger
from pydantic import BaseModel

from emma_experience_hub.api.clients import (
Client,
ConfirmationResponseClassifierClient,
FeatureExtractorClient,
)
from emma_experience_hub.api.clients import Client, FeatureExtractorClient
from emma_experience_hub.api.clients.simbot import (
SimbotActionPredictionClient,
SimBotAuxiliaryMetadataClient,
Expand All @@ -33,7 +29,6 @@ class SimBotControllerClients(BaseModel, arbitrary_types_allowed=True):
nlu_intent: SimBotNLUIntentClient
action_predictor: SimbotActionPredictionClient
session_db: SimBotSessionDbClient
confirmation_response_classifier: ConfirmationResponseClassifierClient

@classmethod
def from_simbot_settings(cls, simbot_settings: SimBotSettings) -> "SimBotControllerClients":
Expand Down Expand Up @@ -66,11 +61,6 @@ def from_simbot_settings(cls, simbot_settings: SimBotSettings) -> "SimBotControl
endpoint=simbot_settings.action_predictor_url,
timeout=simbot_settings.client_timeout,
),
confirmation_response_classifier=ConfirmationResponseClassifierClient(
endpoint=simbot_settings.confirmation_classifier_url,
timeout=simbot_settings.client_timeout,
disable=not simbot_settings.feature_flags.enable_confirmation_questions,
),
)

def healthcheck(self, attempts: int = 1, interval: int = 0) -> bool:
Expand Down
21 changes: 3 additions & 18 deletions src/emma_experience_hub/api/controllers/simbot/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,24 +212,9 @@ def _clear_queue_if_needed(self, session: SimBotSession) -> SimBotSession:
return session

def _clear_queue_after_user_intent(self, session: SimBotSession) -> SimBotSession:
"""Clear the queue if the user has provided us with a new instruction.
After the confirmation classifier, check if the user replied to a confirmation question
with a confirmation response or a new instruction.
"""
new_instruction_after_confirmation = [
# We previously asked for confirmation
session.previous_turn is not None
and session.previous_turn.intent.verbal_interaction is not None
and session.previous_turn.intent.verbal_interaction.type.triggers_confirmation_question,
# But the user intent is not a confirmation response
session.current_turn.intent.user is not None
and not session.current_turn.intent.user.is_confirmation_response,
]
if all(new_instruction_after_confirmation):
logger.debug(
"[REQUEST]: Received instruction utterance after confirmation; clearing the utterance queue"
)
"""Clear the queue if the user has provided us with a new instruction."""
if session.current_turn.intent.user is not None:
logger.debug("[REQUEST]: Received instruction utterance; clearing the utterance queue")
session.current_state.utterance_queue.reset()
session.current_state.find_queue.reset()

Expand Down
8 changes: 1 addition & 7 deletions src/emma_experience_hub/api/controllers/simbot/pipelines.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,7 @@ def from_clients(
request_processing=SimBotRequestProcessingPipeline(
session_db_client=clients.session_db,
),
user_intent_extractor=SimBotUserIntentExtractionPipeline(
confirmation_response_classifier=clients.confirmation_response_classifier,
_enable_confirmation_questions=simbot_settings.feature_flags.enable_confirmation_questions,
_enable_clarification_questions=simbot_settings.feature_flags.enable_clarification_questions,
),
user_intent_extractor=SimBotUserIntentExtractionPipeline(),
environment_intent_extractor=SimBotEnvironmentIntentExtractionPipeline(),
agent_intent_selector=SimBotAgentIntentSelectionPipeline(
features_client=clients.features,
Expand All @@ -65,11 +61,9 @@ def from_clients(
environment_error_pipeline=SimBotEnvironmentErrorCatchingPipeline(),
action_predictor_client=clients.action_predictor,
_enable_clarification_questions=simbot_settings.feature_flags.enable_clarification_questions,
_enable_confirmation_questions=simbot_settings.feature_flags.enable_confirmation_questions,
_enable_search_actions=simbot_settings.feature_flags.enable_search_actions,
_enable_search_after_no_match=simbot_settings.feature_flags.enable_search_after_no_match,
_enable_search_after_missing_inventory=simbot_settings.feature_flags.enable_search_after_missing_inventory,
_enable_high_level_planner=simbot_settings.feature_flags.enable_rasa_high_level_planner,
),
agent_action_generator=SimBotAgentActionGenerationPipeline(
features_client=clients.features,
Expand Down
17 changes: 0 additions & 17 deletions src/emma_experience_hub/common/settings/simbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,12 @@ class SimBotFeatureFlags(BaseModel):

enable_always_highlight_before_object_action: bool = False
enable_clarification_questions: bool = True
enable_coreference_resolution: bool = True
enable_confirmation_questions: bool = True
enable_grab_from_history: bool = True
enable_incomplete_utterances_intent: bool = True
enable_rasa_high_level_planner: bool = False
enable_scanning_during_search: bool = True
enable_search_actions: bool = True
enable_search_after_missing_inventory: bool = True
enable_search_after_no_match: bool = True

prevent_default_response_as_lightweight: bool = True

search_planner_type: SearchPlannerType = SearchPlannerType.greedy_max_vertex_cover
gfh_location_type: GFHLocationType = GFHLocationType.location

Expand All @@ -43,12 +37,8 @@ def set_offline_evaluation_flags(
"""Make sure that flags are set correctly for the offline evaluation."""
if values.get("enable_offline_evaluation", False):
values["enable_clarification_questions"] = False
values["enable_coreference_resolution"] = False
values["enable_confirmation_questions"] = False
values["enable_incomplete_utterances_intent"] = False
values["enable_scanning_during_search"] = False
values["enable_search_after_missing_inventory"] = False
values["prevent_default_response_as_lightweight"] = False

values["gfh_location_type"] = GFHLocationType.viewpoint
return values
Expand All @@ -66,16 +56,13 @@ class SimBotSettings(BaseSettings):

client_timeout: Optional[int] = 5

simbot_cache_s3_bucket: str = "emma-simbot-live-challenge"

auxiliary_metadata_dir: DirectoryPath
auxiliary_metadata_cache_dir: DirectoryPath

extracted_features_cache_dir: DirectoryPath

session_db_memory_table_name: str = "SIMBOT_MEMORY_TABLE"
session_local_db_file: str = "storage/local_sessions.db"
session_db_region: str = "us-east-1"

feature_extractor_url: AnyHttpUrl = AnyHttpUrl(url=f"{scheme}://0.0.0.0:5500", scheme=scheme)

Expand All @@ -84,10 +71,6 @@ class SimBotSettings(BaseSettings):

action_predictor_url: AnyHttpUrl = AnyHttpUrl(url=f"{scheme}://0.0.0.0:5502", scheme=scheme)

confirmation_classifier_url: AnyHttpUrl = AnyHttpUrl(
url=f"{scheme}://0.0.0.0:5507", scheme=scheme
)

placeholder_vision_url: AnyHttpUrl = AnyHttpUrl(url=f"{scheme}://0.0.0.0:5506", scheme=scheme)

class Config:
Expand Down
1 change: 0 additions & 1 deletion src/emma_experience_hub/datamodels/simbot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from emma_experience_hub.datamodels.simbot.enums import (
SimBotActionStatusType,
SimBotActionType,
SimBotAnyUserIntentType,
SimBotDummyRawActions,
SimBotEnvironmentIntentType,
SimBotIntentType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
SimBotDummyRawActions,
)
from emma_experience_hub.datamodels.simbot.enums.intents import (
SimBotAnyUserIntentType,
SimBotEnvironmentIntentType,
SimBotIntentType,
SimBotNLUIntentType,
Expand Down
43 changes: 1 addition & 42 deletions src/emma_experience_hub/datamodels/simbot/enums/intents.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,7 @@ class SimBotIntentType(Enum):
act_too_many_matches = "<act><too_many_matches>"
act_missing_inventory = "<act><missing_inventory>"

# Confirmation question triggers
confirm_generic = "<confirm><generic>"
confirm_before_act = "<confirm><act>"
confirm_before_goto_object = "<confirm><goto_object>"
confirm_before_goto_viewpoint = "<confirm><goto_viewpoint>"
confirm_before_search = "<confirm><search>"
confirm_before_plan = "<confirm><plan>"

# Question responses from the user
clarify_answer = "<clarify><answer>"
confirm_yes = "<confirm><yes>"
confirm_no = "<confirm><no>"

# Feedback for previous turn success
generic_success = "<success><generic>"
Expand Down Expand Up @@ -83,33 +72,13 @@ def is_actionable(self) -> bool:
@property
def triggers_question_to_user(self) -> bool:
"""Return True if the intent triggers a question to the user."""
return self.triggers_confirmation_question or self.triggers_disambiguation_question
return self.triggers_disambiguation_question

@property
def triggers_disambiguation_question(self) -> bool:
"""Did the agent ask for disambiguation from the user?"""
return self == SimBotIntentType.act_too_many_matches

@property
def triggers_confirmation_question(self) -> bool:
"""Did the agent ask for confirmation from the user?"""
return self in {
SimBotIntentType.confirm_generic,
SimBotIntentType.confirm_before_act,
SimBotIntentType.confirm_before_goto_object,
SimBotIntentType.confirm_before_goto_viewpoint,
SimBotIntentType.confirm_before_search,
SimBotIntentType.confirm_before_plan,
}

@property
def is_confirmation_response(self) -> bool:
"""Return True if the intent is a response to a confirmation question."""
return self in {
SimBotIntentType.confirm_yes,
SimBotIntentType.confirm_no,
}

@property
def verbal_interaction_intent_triggers_search(self) -> bool:
"""Return True if the intent is a verbal interaction intent that triggers search."""
Expand Down Expand Up @@ -156,14 +125,10 @@ def is_verbal_interaction_intent_type( # noqa: WPS602

SimBotUserIntentType = Literal[
SimBotIntentType.clarify_answer,
SimBotIntentType.confirm_yes,
SimBotIntentType.confirm_no,
SimBotIntentType.act,
]


SimBotAnyUserIntentType = Literal[SimBotUserIntentType,]

SimBotEnvironmentIntentType = Literal[
SimBotIntentType.unsupported_action,
SimBotIntentType.unsupported_navigation,
Expand Down Expand Up @@ -194,12 +159,6 @@ def is_verbal_interaction_intent_type( # noqa: WPS602
]

SimBotVerbalInteractionIntentType = Literal[
SimBotIntentType.confirm_generic,
SimBotIntentType.confirm_before_act,
SimBotIntentType.confirm_before_goto_object,
SimBotIntentType.confirm_before_goto_viewpoint,
SimBotIntentType.confirm_before_search,
SimBotIntentType.confirm_before_plan,
SimBotIntentType.act_no_match,
SimBotIntentType.act_too_many_matches,
SimBotIntentType.act_missing_inventory,
Expand Down
14 changes: 4 additions & 10 deletions src/emma_experience_hub/datamodels/simbot/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
from emma_experience_hub.datamodels.simbot.agent_memory import SimBotInventory, SimBotObjectMemory
from emma_experience_hub.datamodels.simbot.enums import (
SimBotActionType,
SimBotAnyUserIntentType,
SimBotEnvironmentIntentType,
SimBotIntentType,
SimBotPhysicalInteractionIntentType,
SimBotUserIntentType,
SimBotVerbalInteractionIntentType,
)
from emma_experience_hub.datamodels.simbot.intents import SimBotIntent
Expand Down Expand Up @@ -58,7 +58,7 @@ def processing_time(self) -> Optional[float]:
class SimBotSessionTurnIntent(BaseModel):
"""Intents from each actor within the environment for the turn.."""

user: Optional[SimBotAnyUserIntentType] = None
user: Optional[SimBotUserIntentType] = None
environment: Optional[SimBotIntent[SimBotEnvironmentIntentType]] = None
physical_interaction: Optional[SimBotIntent[SimBotPhysicalInteractionIntentType]] = None
verbal_interaction: Optional[SimBotIntent[SimBotVerbalInteractionIntentType]] = None
Expand Down Expand Up @@ -88,19 +88,18 @@ def should_generate_interaction_action(self) -> bool:

@property
def agent_should_ask_question_to_user(self) -> bool:
"""Return True if the agent should ask for confirmation instead of just acting."""
"""Return True if the agent should ask instead of just acting."""
return (
self.verbal_interaction is not None
and self.verbal_interaction.type.triggers_question_to_user
)

@property
def agent_should_ask_question_without_acting(self) -> bool:
"""Return True if the agent should ask for confirmation instead of just acting."""
"""Return True if the agent should ask instead of just acting."""
return (
self.verbal_interaction is not None
and self.verbal_interaction.type.triggers_question_to_user
and self.verbal_interaction.type != SimBotIntentType.confirm_before_plan
)

@property
Expand Down Expand Up @@ -375,11 +374,6 @@ def convert_to_simbot_response(self) -> SimBotResponse:
"""Convert the session turn to a SimBotResponse, to be returned to the API."""
actions: list[SimBotAction] = self.actions.to_list()

# If the agent wants to ask for confirmation before trying to act, then only return the
# dialog action, which SHOULD have the confirmation question for the user
if self.intent.agent_should_ask_question_without_acting:
actions = [self.actions.dialog] if self.actions.dialog is not None else []

if not actions:
raise AssertionError(
"There is no action to be returned. Have you run the response generator on this?"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
from emma_experience_hub.functions.simbot.agent_intent_selection.clarification_handler import (
SimBotClarificationHandler,
)
from emma_experience_hub.functions.simbot.agent_intent_selection.confirmation_handler import (
SimBotConfirmationHandler,
set_find_object_in_progress_intent,
)
from emma_experience_hub.functions.simbot.agent_intent_selection.instruction_handler import (
SimBotActHandler,
)
Loading

0 comments on commit cb203c8

Please sign in to comment.