Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

common.py 989 B

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
  1. # Copyright (c) Meta Platforms, Inc. and affiliates
  2. # All rights reserved.
  3. #
  4. # This source code is licensed under the license found in the
  5. # MIT_LICENSE file in the root directory of this source tree.
  6. """
  7. Mixins + common for fairseq2 simuleval agents
  8. """
  9. from simuleval.data.segments import Segment
  10. from simuleval.agents.states import AgentStates as AgentStatesOrig
  11. class EarlyStoppingMixin:
  12. def reset_early(self) -> None:
  13. """
  14. Implement to override for different behavior on a reset that
  15. happens before EOS
  16. """
  17. raise NotImplementedError()
  18. class AgentStates(AgentStatesOrig): # type: ignore
  19. def update_target(self, segment: Segment) -> None:
  20. """An AgentStates impl which doesn't update states.target"""
  21. self.target_finished = segment.finished
  22. class NoUpdateTargetMixin:
  23. """A shortcut to make agents default to the AgentStates impl above"""
  24. def build_states(self) -> AgentStates:
  25. return AgentStates()
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...