Skip to content
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
3 changes: 3 additions & 0 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ Arguments:
can use the shorthand `-q` instead of `--quantized`. Example: `--quantized=false`, `-q false`.
- `--model-filename=<filename>`: Specify the exact model filename to download (without the `.onnx` suffix. Eg. "
model" or "model_quantized".
- `--host=<remote_host>`: Choose a different model hub host. Instead of fetching models from the Hugging Face model
hub, you can use a different host. You can use a private model hub or mirror the original hub.
Eg. `--host=https://hf.co`

The `download` command will download the model weights and save them to the cache directory. The next time you use the
model, TransformersPHP will use the cached weights instead of downloading them again.
Expand Down
14 changes: 12 additions & 2 deletions src/Commands/DownloadModelCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ protected function configure(): void
'The filename of the exact model weights version to download.',
null
);

$this->addOption(
'host',
null,
InputOption::VALUE_OPTIONAL,
'The host to download the model from.',
null
);

}

Expand All @@ -71,9 +79,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$quantized = filter_var($input->getOption('quantized'), FILTER_VALIDATE_BOOLEAN);
$task = $input->getArgument('task');
$modelFilename = $input->getOption('model-filename');

$host = $input->getOption('host') ?? Transformers::$remoteHost;

Transformers::setup()
->setCacheDir($cacheDir)
->setRemoteHost(rtrim($host,'/'))
->apply();

try {
Expand Down Expand Up @@ -152,4 +162,4 @@ protected function askToStar(InputInterface $input, OutputInterface $output): vo
$output->writeln('✔ That\'s okay. You can always star the repo later.');
}
}
}
}