Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve export model code #120

Merged
merged 2 commits into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions dbgpt_hub/llm_base/config_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ def parse_infer_args(


def get_train_args(
args: Optional[Dict[str, Any]] = None
args: Optional[Dict[str, Any]] = None,
data_args_init: bool = True
) -> Tuple[
ModelArguments,
DataArguments,
Expand Down Expand Up @@ -121,7 +122,8 @@ def get_train_args(
transformers.utils.logging.enable_explicit_format()

# Check arguments (do not check finetuning_args since it may be loaded from checkpoints)
data_args.init_for_training()
if data_args_init:
data_args.init_for_training()

if training_args.max_steps == -1 and data_args.streaming:
raise ValueError("Please specify `max_steps` in streaming mode.")
Expand Down
2 changes: 1 addition & 1 deletion dbgpt_hub/llm_base/model_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ def plot_loss(
def export_model(
args: Optional[Dict[str, Any]] = None, max_shard_size: Optional[str] = "10GB"
):
model_args, _, training_args, finetuning_args, _ = get_train_args(args)
model_args, _, training_args, finetuning_args, _ = get_train_args(args, data_args_init=False)
model, tokenizer = load_model_and_tokenizer(model_args, finetuning_args)
model.save_pretrained(training_args.output_dir, max_shard_size=max_shard_size)
try:
Expand Down