forked from facebookresearch/SimulEval
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdummy_waitk_text_agent.py
More file actions
38 lines (29 loc) · 1.13 KB
/
Copy pathdummy_waitk_text_agent.py
File metadata and controls
38 lines (29 loc) · 1.13 KB
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
35
36
37
38
# Copyright (c) Facebook, Inc. and its affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
from simuleval.agents import TextAgent
from simuleval import READ_ACTION, WRITE_ACTION, DEFAULT_EOS
class DummyWaitkTextAgent(TextAgent):
data_type = "text"
def __init__(self, args):
super().__init__(args)
self.waitk = args.waitk
# Initialize your agent here, for example load model, vocab, etc
@staticmethod
def add_args(parser):
# Add additional command line arguments here
parser.add_argument("--waitk", type=int, default=3)
def policy(self, states):
# Make decision here
if len(states.source) - len(states.target) < self.waitk and not states.finish_read():
return READ_ACTION
else:
return WRITE_ACTION
def predict(self, states):
# predict token here
if states.finish_read():
if states.target.length() == states.source.length():
return DEFAULT_EOS
return f"word_{len(states.target)}"