Skip to content
This repository was archived by the owner on Nov 3, 2023. It is now read-only.

[TOD][Agents] Helper Agents for simulation + tests #4249

Merged
merged 13 commits into from
Dec 18, 2021

Conversation

moyapchen
Copy link
Contributor

Effectively does same thing as #4176 but broken out to be easier to review.

This diff does 2 things:

  1. Adds the helper agents for simulation (Goal + API Description agents necessary for simulation; agents for dumping data from a dataset) in tod_agents.py.
  2. Adds tests for these agents + the teachers in the previous diff in the stack.

This is the same as #4232 but I pressed the wrong button there.

Copy link
Contributor

@skiingpacman skiingpacman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bunch of comments that should help make things clearer. Other than that looks good. (Note I only skimmed the unit tests - so possibly missed stuff there.)

cand[tod.STANDARD_API_NAME_SLOT]
== call[tod.STANDARD_API_NAME_SLOT]
):
schema = cand
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just for my understanding... this selects the last API call made as the (singular) dialogue goal?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, for k dialogue goals in a dialogue, there are now k dialogues generated each with a single goal..

This code says that if there are multiple schemas listed with the same API call name (which ideally shouldn't happen though I don't have validation for this active), it'll grab the last of those to use as the schema.

"""

def __init__(self, opt: Opt, shared=None):
# This class represents two "agents" so need to make sure we don't increment episode number (reset) twice
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth mentioning the beginning part of this comment into the class heading comment above for TodApiCallAndSysUttAgent. Additionally clarifying which two agents <-- on this latter point I wasn't sure as this seems to be just the System agent? Are you counting it as two because it alternates between API calls and NLG response to the user?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated comment here to say.

        # This class will have `act()` called on it twice per round — once for API call and once for NLG — so need to make sure we don't increment episode number (reset) prematurely; use the `already_reset` flag for this. ```      

"text": tod.STANDARD_API_SCHEMAS,
"id": self.id,
"domain": self.episode.domain,
"episode_down": False,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

episode_done ? (not down)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well that's a weird typo lol.

self.already_reset = False
if tod.STANDARD_API_SCHEMAS in self.observation.get("text", ""):
return {
"text": tod.STANDARD_API_SCHEMAS,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This returns something like "APIS: " and nothing more, i.e. any empty schema. Is that correct? I guess it is if this is only used for offline model testing under the assumption that the schema is unknown to the model at production time... but maybe worth adding a comment that mentions the expected use case of this agent (offline model testing) in the class heading.

Copy link
Contributor Author

@moyapchen moyapchen Dec 18, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahhhhh this is a convention I put in for the first turn. Can leave it as a comment. (Implicitly assumes that we're comparing against NO SCHEMA models, but that's what we use for evaluation.)

}
self.round_idx += 1

self.api_call_turn ^= True
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

simply use False

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I was being paranoid that I would forget to set that variable to the opposite of itself at one point.. will address.

f"USER: user_utt_{episode_idx}_0",
"APICALL: ",
"APIRESP: ",
f"SYSTEM: sys_utt_{episode_idx}_0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not use the tod_core constants for USER, APICALL, etc?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oof good minor catch.

Base automatically changed from simpler_tod_2a_teachers_only to main December 18, 2021 05:14
@moyapchen moyapchen merged commit 66c71e0 into main Dec 18, 2021
@moyapchen moyapchen deleted the simpler_tod_2b_simulation_agents branch December 18, 2021 05:37
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants