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

ChunkTeacher no longer requires num_examples/num_episodes to be correct #3681

Merged
merged 6 commits into from
Jun 1, 2021

Conversation

stephenroller
Copy link
Contributor

Patch description
For as long as we've had ChunkTeacher, it's required that the number of episodes and examples be exactly reported correctly, or else it would cause a hang. With this patch, we loosen that requirement.

Methodology:

  • Upgrade some of ChunkTeacher's internal logic to use DatatypeHelper to check about shuffling/cycling. Some of this is equivalent but more explicit and makes a bit more sense. The one logical change here is train:ordered was previously cycling, when it shouldn't.
  • FixedDialogTeacher keeps track of the current episode and sees if we'll go over our limit, and starts emitting padding. Modify ChunkTeacher to always lie about its "next episode" so that check never triggers.
  • Epoch done was previously computed in FixedDialogTeacher.next_example, checking the counts. Override this behavior in ChunkTeacher to have it simply test whether it's seeing a pad or not. This means we'll go one batch further than we need to, but that's okay -- everything filters the pads correctly and it doesn't affect counts or examples seen.

Testing steps
Manual testing.

New CI tests that stand up chunk teachers that lie about their number examples/episodes, and check that the number of unique messages seen is exactly correct.

Copy link
Contributor

@emilydinan emilydinan left a comment

Choose a reason for hiding this comment

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

awesome. should we require a user to implement num_examples now? (setting it as an abstractmethod requires the implementation)

# (This isn't relevant for the training loop, which loops for ever and
# never "epochs").
retval, fake_epoch_done = super().next_example()
real_epoch_done = retval.is_padding()
Copy link
Contributor

Choose a reason for hiding this comment

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

I assume this works OK with dynamic batch padding, since that occurs at a level higher than the teacher?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, this has been tested with all variants of batching and ensured that all examples are seen.

@stephenroller
Copy link
Contributor Author

You still have to implement num_examples, as that determines the behavior of -eps and -veps etc. It just doesn't have to line up with data

Copy link
Contributor

@klshuster klshuster left a comment

Choose a reason for hiding this comment

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

awesome

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.

4 participants