camenduru / text-generation-webui-colab

A colab gradio web UI for running Large Language Models
The Unlicense
2.07k stars 367 forks source link

Simplify some instructions #32

Open bitsnaps opened 1 year ago

bitsnaps commented 1 year ago

Hi,

I've just tried to make it simpler by putting some values in variables:

USER="TheBloke"
MODEL="WizardCoder-Python-13B-V1.0-GPTQ"
FILES=("config.json" "generation_config.json" "special_tokens_map.json" "tokenizer.model" "tokenizer_config.json" "model.safetensors")

then make loop to download required files: If you don't want to distinguish between raw and resolve:

%%bash

for FILE in "${FILES[@]}"; do
  !aria2c --console-log-level=error -c -x 16 -s 16 -k 1M "https://huggingface.co/$USER/$MODEL/resolve/main/$FILE" -d "/content/text-generation-webui/models/$MODEL" -o $FILE
done

Use this if you want to distinguish between raw and resolve:

%%bash

for FILE in "${FILES[@]}"; do
  if [[ $FILE == "tokenizer.model" || $FILE == "model.safetensors" ]]; then
    !aria2c --console-log-level=error -c -x 16 -s 16 -k 1M "https://huggingface.co/$USER/$MODEL/resolve/main/$FILE" -d "/content/text-generation-webui/models/$MODEL" -o $FILE
  else
    !aria2c --console-log-level=error -c -x 16 -s 16 -k 1M "https://huggingface.co/$USER/$MODEL/raw/main/$FILE" -d "/content/text-generation-webui/models/$MODEL" -o $FILE
  fi
done