Skip to main content

Upload and download models


Recommended tutorials before starting starting uploading and downloading models.

1. Sign in

Before you start using the CLI, you need to log in with your username and password.

stochasticx login --username "" --password "my_password"

2. Create and upload models

Download a Hugging Face model and save it in the disk. In this tutorial, bert-large-uncased-whole-word-masking-finetuned-squad model will be downloaded from the Hugging Face Hub. It is a model finetuned on the SQuAD dataset.

from transformers import AutoTokenizer, AutoModelForQuestionAnswering

tokenizer = AutoTokenizer.from_pretrained("bert-large-uncased-whole-word-masking-finetuned-squad")

model = AutoModelForQuestionAnswering.from_pretrained("bert-large-uncased-whole-word-masking-finetuned-squad")

Now you can upload this model to the Stochastic platform. Use the following command:

stochasticx models upload \
--name "bert-squad" \
--dir_path "./bert-squad" \
--type "hf"
  • name: will allow you to identify the model later.
  • dir_path: directory path where your model is located.
  • type: model type. In this case a Hugging Face model

3. List and inspect your models

You can list your models with the following command:

stochasticx models ls
CLI output
[+] Collecting uploaded models

┃ Id ┃ Name ┃ Directory path ┃ Type ┃ Uploaded ┃
│ 62e3a5aab5beb3002644093e │ bert-squad │ │ hf │ True │

Inspect a model to get more details about it:

stochasticx models inspect --id "62e3a5aab5beb3002644093e"
CLI output
Model ID: 62e3a5aab5beb3002644093e ; Name: bert-squad ; Directory path: None ; Model type: hf ; Uploaded: True


4. Download a specific model

You can also download these models in your local system:

stochasticx models download \
--id "62e9195598855200266c0497" \
--path "./"
CLI output
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 248.0M/248.0M [00:02<00:00, 6.87MiB/s]
  • model_id: model ID you want to download.
  • local_path: local path where you want to save this model. Note that the downloaded model will be a zip file.