Skip to content

Commit

Permalink
download model weights on preprocess step (#1693)
Browse files Browse the repository at this point in the history
  • Loading branch information
winglian committed Jun 10, 2024
1 parent cbbf039 commit 5783839
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/axolotl/cli/preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@

import fire
import transformers
from accelerate import init_empty_weights
from colorama import Fore
from transformers import AutoModelForCausalLM

from axolotl.cli import (
check_accelerate_default_config,
Expand Down Expand Up @@ -71,6 +73,11 @@ def do_cli(config: Union[Path, str] = Path("examples/"), **kwargs):
else:
load_datasets(cfg=parsed_cfg, cli_args=parsed_cli_args)

if parsed_cli_args.download:
model_name = parsed_cfg.base_model
with init_empty_weights():
AutoModelForCausalLM.from_pretrained(model_name, trust_remote_code=True)

LOG.info(
Fore.GREEN
+ f"Success! Preprocessed data path: `dataset_prepared_path: {parsed_cfg.dataset_prepared_path}`"
Expand Down
1 change: 1 addition & 0 deletions src/axolotl/common/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class PreprocessCliArgs:
debug_text_only: bool = field(default=False)
debug_num_examples: int = field(default=1)
prompter: Optional[str] = field(default=None)
download: Optional[bool] = field(default=True)


def load_model_and_tokenizer(
Expand Down

0 comments on commit 5783839

Please sign in to comment.