generated from fastai/nbdev_template
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c77503a
commit 66254d8
Showing
2 changed files
with
30 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import argparse | ||
|
||
from transformers import HfArgumentParser, TrainingArguments | ||
import sys | ||
from pathlib import Path | ||
|
||
# Add the root of the project to the python path so that we can import examples scripts | ||
path = Path(__file__).parent.parent | ||
sys.path.append(str(path)) | ||
|
||
|
||
def main(): | ||
parser = argparse.ArgumentParser(prog="trl", description="A CLI tool for training and fine-tuning") | ||
subparsers = parser.add_subparsers(dest="command", required=True, parser_class=HfArgumentParser) | ||
|
||
# 'dpo' subcommand | ||
dpo_parser = subparsers.add_parser("dpo", help="Run the DPO training process", dataclass_types=TrainingArguments) | ||
|
||
args = parser.parse_args() | ||
sys.argv = sys.argv[1:] # Remove 'trl' from sys.argv | ||
|
||
if args.command == "dpo": | ||
from examples.scripts.dpo import main as dpo_main | ||
|
||
(training_args,) = dpo_parser.parse_args_into_dataclasses() | ||
dpo_main(training_args) | ||
|