-
Notifications
You must be signed in to change notification settings - Fork 4
/
run-manual.py
46 lines (42 loc) · 1.1 KB
/
run-manual.py
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
39
40
41
42
43
44
45
46
import argparse
import typing
import pfgen
def callback(
tasks: typing.List[typing.Dict[str, str]], params: typing.Dict[str, typing.Any]
) -> typing.Iterator[typing.Optional[str]]:
mode = params["mode"]
assert mode == "qa" or mode == "completion"
for task in tasks:
print("=" * 80)
print(task["prompt"])
print()
output = input("Enter the output: ").strip()
if output:
yield output
else:
yield None
print()
if __name__ == "__main__":
parser = argparse.ArgumentParser(
formatter_class=argparse.ArgumentDefaultsHelpFormatter
)
parser.add_argument(
"--mode",
type=str,
default="completion",
choices=["chat", "qa", "completion"],
help="Which chat template to use.",
)
parser.add_argument(
"--model",
type=str,
default="mistralai/Mistral-7B-v0.1",
help="Huggingface model name.",
)
args = parser.parse_args()
pfgen.run_tasks(
args.mode,
callback,
engine="manual",
model=args.model,
)