Spaces:
Paused
Paused
Commit ·
cff5793
1
Parent(s): d8351e3
update
Browse files
examples/tutorials/rlhf/gpt2_sst2_ppo/step_3_generation.py
CHANGED
|
@@ -1,7 +1,23 @@
|
|
| 1 |
#!/usr/bin/python3
|
| 2 |
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
import argparse
|
| 4 |
-
import
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
import torch
|
| 7 |
from transformers import AutoTokenizer, AutoModelForCausalLM, TextStreamer
|
|
@@ -13,7 +29,7 @@ def get_args():
|
|
| 13 |
parser = argparse.ArgumentParser()
|
| 14 |
parser.add_argument(
|
| 15 |
"--pretrained_model_name_or_path",
|
| 16 |
-
default=(project_path / "trained_models/gpt2-sst2-ppo/checkpoint-
|
| 17 |
# default=(project_path / "trained_models/gpt2-sst2-ppo/checkpoint-150"),
|
| 18 |
# default=(project_path / "trained_models/gpt2-sst2-generation-epoch-3/checkpoint-5400"),
|
| 19 |
type=str
|
|
|
|
| 1 |
#!/usr/bin/python3
|
| 2 |
# -*- coding: utf-8 -*-
|
| 3 |
+
"""
|
| 4 |
+
python3 step_3_generation.py
|
| 5 |
+
|
| 6 |
+
"""
|
| 7 |
import argparse
|
| 8 |
+
import os
|
| 9 |
+
from pathlib import Path
|
| 10 |
+
import platform
|
| 11 |
+
import sys
|
| 12 |
+
|
| 13 |
+
# 路径配置
|
| 14 |
+
if platform.system() in ("Windows", "Darwin"):
|
| 15 |
+
from project_settings import project_path, temp_directory
|
| 16 |
+
else:
|
| 17 |
+
project_path = Path(os.path.abspath("../../../../"))
|
| 18 |
+
temp_directory = Path("/root/autodl-tmp/OpenMiniMind/temp")
|
| 19 |
+
|
| 20 |
+
sys.path.append(project_path.as_posix())
|
| 21 |
|
| 22 |
import torch
|
| 23 |
from transformers import AutoTokenizer, AutoModelForCausalLM, TextStreamer
|
|
|
|
| 29 |
parser = argparse.ArgumentParser()
|
| 30 |
parser.add_argument(
|
| 31 |
"--pretrained_model_name_or_path",
|
| 32 |
+
default=(project_path / "trained_models/gpt2-sst2-ppo/checkpoint-50"),
|
| 33 |
# default=(project_path / "trained_models/gpt2-sst2-ppo/checkpoint-150"),
|
| 34 |
# default=(project_path / "trained_models/gpt2-sst2-generation-epoch-3/checkpoint-5400"),
|
| 35 |
type=str
|