Spaces:
Sleeping
Sleeping
Pranjal Parashar commited on
rl training improved v2
Browse files- train.py +8 -1
- train_sft.py +7 -0
train.py
CHANGED
|
@@ -55,6 +55,11 @@ def _clean_preview(text: str, limit: int = 220) -> str:
|
|
| 55 |
return normalized
|
| 56 |
|
| 57 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
def parse_args() -> argparse.Namespace:
|
| 59 |
parser = argparse.ArgumentParser(description="Minimal Colab-first GRPO training for FlowOS")
|
| 60 |
parser.add_argument("--model-id", default=DEFAULT_TRAIN_MODEL, help="Base instruct model to fine-tune")
|
|
@@ -238,6 +243,8 @@ def upload_outputs(output_dir: Path, repo_id: str, repo_type: str, path_in_repo:
|
|
| 238 |
|
| 239 |
def main() -> None:
|
| 240 |
args = parse_args()
|
|
|
|
|
|
|
| 241 |
|
| 242 |
logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)s %(message)s")
|
| 243 |
logging.getLogger("httpx").setLevel(logging.WARNING)
|
|
@@ -263,7 +270,7 @@ def main() -> None:
|
|
| 263 |
if tokenizer.pad_token is None:
|
| 264 |
tokenizer.pad_token = tokenizer.eos_token
|
| 265 |
|
| 266 |
-
timestamp = datetime.now().strftime("%Y-%m-%d_%H-%M
|
| 267 |
output_dir = Path(args.output_dir or Path("outputs") / f"flowos-grpo-{timestamp}")
|
| 268 |
output_dir.mkdir(parents=True, exist_ok=True)
|
| 269 |
|
|
|
|
| 55 |
return normalized
|
| 56 |
|
| 57 |
|
| 58 |
+
def with_timestamp_suffix(output_dir: str) -> str:
|
| 59 |
+
timestamp = datetime.now().strftime("%Y-%m-%d_%H-%M")
|
| 60 |
+
return f"{output_dir.rstrip('/')}-{timestamp}"
|
| 61 |
+
|
| 62 |
+
|
| 63 |
def parse_args() -> argparse.Namespace:
|
| 64 |
parser = argparse.ArgumentParser(description="Minimal Colab-first GRPO training for FlowOS")
|
| 65 |
parser.add_argument("--model-id", default=DEFAULT_TRAIN_MODEL, help="Base instruct model to fine-tune")
|
|
|
|
| 243 |
|
| 244 |
def main() -> None:
|
| 245 |
args = parse_args()
|
| 246 |
+
if args.output_dir is not None:
|
| 247 |
+
args.output_dir = with_timestamp_suffix(args.output_dir)
|
| 248 |
|
| 249 |
logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)s %(message)s")
|
| 250 |
logging.getLogger("httpx").setLevel(logging.WARNING)
|
|
|
|
| 270 |
if tokenizer.pad_token is None:
|
| 271 |
tokenizer.pad_token = tokenizer.eos_token
|
| 272 |
|
| 273 |
+
timestamp = datetime.now().strftime("%Y-%m-%d_%H-%M")
|
| 274 |
output_dir = Path(args.output_dir or Path("outputs") / f"flowos-grpo-{timestamp}")
|
| 275 |
output_dir.mkdir(parents=True, exist_ok=True)
|
| 276 |
|
train_sft.py
CHANGED
|
@@ -7,6 +7,7 @@ import csv
|
|
| 7 |
import json
|
| 8 |
import os
|
| 9 |
from dataclasses import dataclass
|
|
|
|
| 10 |
from pathlib import Path
|
| 11 |
from typing import Any
|
| 12 |
|
|
@@ -89,6 +90,11 @@ def load_jsonl(path: Path) -> list[dict[str, Any]]:
|
|
| 89 |
return rows
|
| 90 |
|
| 91 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
def filter_ranked_rows(
|
| 93 |
rows: list[dict[str, Any]],
|
| 94 |
min_trace_rank: float,
|
|
@@ -238,6 +244,7 @@ class SFTCollator:
|
|
| 238 |
|
| 239 |
def main() -> None:
|
| 240 |
args = parse_args()
|
|
|
|
| 241 |
|
| 242 |
from peft import LoraConfig, get_peft_model, prepare_model_for_kbit_training
|
| 243 |
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig, Trainer, TrainingArguments
|
|
|
|
| 7 |
import json
|
| 8 |
import os
|
| 9 |
from dataclasses import dataclass
|
| 10 |
+
from datetime import datetime
|
| 11 |
from pathlib import Path
|
| 12 |
from typing import Any
|
| 13 |
|
|
|
|
| 90 |
return rows
|
| 91 |
|
| 92 |
|
| 93 |
+
def with_timestamp_suffix(output_dir: str) -> str:
|
| 94 |
+
timestamp = datetime.now().strftime("%Y-%m-%d_%H-%M")
|
| 95 |
+
return f"{output_dir.rstrip('/')}-{timestamp}"
|
| 96 |
+
|
| 97 |
+
|
| 98 |
def filter_ranked_rows(
|
| 99 |
rows: list[dict[str, Any]],
|
| 100 |
min_trace_rank: float,
|
|
|
|
| 244 |
|
| 245 |
def main() -> None:
|
| 246 |
args = parse_args()
|
| 247 |
+
args.output_dir = with_timestamp_suffix(args.output_dir)
|
| 248 |
|
| 249 |
from peft import LoraConfig, get_peft_model, prepare_model_for_kbit_training
|
| 250 |
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig, Trainer, TrainingArguments
|