Skip to content

Commit

Permalink
feat: allow passing model filename when downloading a model from CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeWithKyrian committed Jul 23, 2024
1 parent 69f3d32 commit 91db063
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Commands/DownloadModelCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ protected function configure(): void

$this->addOption(
'quantized',
'q',
null,
InputOption::VALUE_OPTIONAL,
'Whether to download the quantized version of the model.',
true
Expand All @@ -70,6 +70,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$cacheDir = $input->getOption('cache-dir');
$quantized = filter_var($input->getOption('quantized'), FILTER_VALIDATE_BOOLEAN);
$task = $input->getArgument('task');
$modelFilename = $input->getOption('model-filename');

Transformers::setup()
->setCacheDir($cacheDir)
Expand All @@ -91,10 +92,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int
};

if ($task != null) {
pipeline($task, $model, quantized: $quantized, onProgress: $onProgress);
pipeline($task, $model, quantized: $quantized, modelFilename: $modelFilename, onProgress: $onProgress);
} else {
AutoTokenizer::fromPretrained($model, onProgress: $onProgress);
AutoModel::fromPretrained($model, $quantized, onProgress: $onProgress);
AutoModel::fromPretrained($model, $quantized, modelFilename: $modelFilename, onProgress: $onProgress);
}

$output->writeln('✔ Model files downloaded successfully.');
Expand Down

0 comments on commit 91db063

Please sign in to comment.