From 0855aa7347580add53c20a78021239b164af4f63 Mon Sep 17 00:00:00 2001 From: Artem Chumachenko Date: Sat, 3 Dec 2022 14:09:21 +0400 Subject: [PATCH] Update notebooks to use full BLOOM-176B (#104) Co-authored-by: Alexander Borzunov --- examples/prompt-tuning-personachat.ipynb | 31 ++++++++------------- examples/prompt-tuning-sst2.ipynb | 35 ++++++++---------------- 2 files changed, 23 insertions(+), 43 deletions(-) diff --git a/examples/prompt-tuning-personachat.ipynb b/examples/prompt-tuning-personachat.ipynb index b069e09..6993a3b 100644 --- a/examples/prompt-tuning-personachat.ipynb +++ b/examples/prompt-tuning-personachat.ipynb @@ -15,7 +15,10 @@ "\n", "We will adapt the BLOOM model for the chatbot task using the [Personachat](https://huggingface.co/datasets/bavard/personachat_truecased) dataset. For a given dialogue context, the model has to provide a relevant answer.\n", "\n", - "To open this notebook in colab: [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/bigscience-workshop/petals/blob/main/examples/prompt-tuning-personachat.ipynb)" + "To use this notebook in Colab:\n", + "\n", + "1. Follow this link: [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/bigscience-workshop/petals/blob/main/examples/prompt-tuning-personachat.ipynb)\n", + "2. Go to **Runtime** -> **Change runtime type** and select the GPU accelerator." ] }, { @@ -33,18 +36,8 @@ "metadata": {}, "outputs": [], "source": [ - "import subprocess\n", - "import sys\n", - "\n", "!pip install git+https://github.com/bigscience-workshop/petals\n", - "!pip install datasets wandb\n", - "\n", - "IN_COLAB = 'google.colab' in sys.modules\n", - "if IN_COLAB: # Remove CUDA binaries on CPU-only colabs to not confuse bitsandbytes\n", - " try:\n", - " subprocess.check_output([\"nvidia-smi\", \"-L\"])\n", - " except subprocess.CalledProcessError as e:\n", - " subprocess.run(\"rm -r /usr/local/cuda/lib64\", shell=True)" + "!pip install datasets wandb" ] }, { @@ -84,11 +77,10 @@ "metadata": {}, "outputs": [], "source": [ - "MODEL_NAME = ... # select model you like\n", - "INITIAL_PEERS = [...] # add your peers adresses here, like \"/ip4/192.168.1.2/tcp/31000/p2p/Qma....\"\n", + "MODEL_NAME = \"bigscience/bloom-petals\" # select model you like\n", "NUM_PREFIX_TOKENS = 16\n", "DEVICE = 'cpu'\n", - "BATCH_SIZE = 4\n", + "BATCH_SIZE = 8\n", "LR = 1e-2\n", "WEIGHT_DECAY = 0.0\n", "NUM_SAMPLES = 1000\n", @@ -116,8 +108,7 @@ "tokenizer.padding_side = 'right'\n", "tokenizer.model_max_length = MODEL_MAX_LENGTH\n", "model = DistributedBloomForCausalLM.from_pretrained(\n", - " MODEL_NAME, \n", - " initial_peers=INITIAL_PEERS, \n", + " MODEL_NAME,\n", " pre_seq_len=NUM_PREFIX_TOKENS, \n", " tuning_mode=TUNING_MODE\n", ").to(DEVICE)" @@ -306,7 +297,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3.6.9 64-bit", + "display_name": "Python 3.8.12 ('bloom-demo')", "language": "python", "name": "python3" }, @@ -320,11 +311,11 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.9" + "version": "3.8.12" }, "vscode": { "interpreter": { - "hash": "31f2aee4e71d21fbe5cf8b01ff0e069b9275f58929596ceb00d14d90e3e16cd6" + "hash": "175c31e15dd38a7dfc9eb4117a9e428ffb6063af97d545b6bfba4d874ecc4bb8" } } }, diff --git a/examples/prompt-tuning-sst2.ipynb b/examples/prompt-tuning-sst2.ipynb index 20d2836..7a534d9 100644 --- a/examples/prompt-tuning-sst2.ipynb +++ b/examples/prompt-tuning-sst2.ipynb @@ -15,7 +15,10 @@ "\n", "We will adapt the BLOOM model for the classification task using the [SST-2 dataset](https://nlp.stanford.edu/sentiment/). This dataset is a binary classification task, where the goal is to predict whether a sentence is positive or negative. The SST-2 dataset is a subset of the Stanford Sentiment Treebank, and it is available in the [Hugging Face Datasets](https://huggingface.co/datasets) library.\n", "\n", - "To open this notebook in colab: [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/bigscience-workshop/petals/blob/main/examples/prompt-tuning-sst2.ipynb)" + "To use this notebook in Colab:\n", + "\n", + "1. Follow this link: [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/bigscience-workshop/petals/blob/main/examples/prompt-tuning-sst2.ipynb)\n", + "2. Go to **Runtime** -> **Change runtime type** and select the GPU accelerator." ] }, { @@ -33,18 +36,8 @@ "metadata": {}, "outputs": [], "source": [ - "import subprocess\n", - "import sys\n", - "\n", "!pip install git+https://github.com/bigscience-workshop/petals\n", - "!pip install datasets wandb\n", - "\n", - "IN_COLAB = 'google.colab' in sys.modules\n", - "if IN_COLAB: # Remove CUDA binaries on CPU-only colabs to not confuse bitsandbytes\n", - " try:\n", - " subprocess.check_output([\"nvidia-smi\", \"-L\"])\n", - " except subprocess.CalledProcessError as e:\n", - " subprocess.run(\"rm -r /usr/local/cuda/lib64\", shell=True)" + "!pip install datasets wandb" ] }, { @@ -84,14 +77,12 @@ "metadata": {}, "outputs": [], "source": [ - "MODEL_NAME = ... # select model you like\n", - "INITIAL_PEERS = [...] # add your peers adresses here, like \"/ip4/192.168.1.2/tcp/31000/p2p/Qma....\"\n", + "MODEL_NAME = \"bigscience/bloom-petals\" # select model you like\n", "NUM_PREFIX_TOKENS = 16\n", "DEVICE = 'cpu'\n", - "BATCH_SIZE = 4\n", + "BATCH_SIZE = 16\n", "LR = 1e-2\n", "WEIGHT_DECAY = 0.0\n", - "NUM_SAMPLES = 1000\n", "NUM_EPOCHS = 3\n", "SEED = 42\n", "MODEL_MAX_LENGTH = 64\n", @@ -117,9 +108,8 @@ "tokenizer.padding_side = 'right'\n", "tokenizer.model_max_length = MODEL_MAX_LENGTH\n", "model = DistributedBloomForSequenceClassification.from_pretrained(\n", - " MODEL_NAME, \n", - " initial_peers=INITIAL_PEERS, \n", - " pre_seq_len=NUM_PREFIX_TOKENS, \n", + " MODEL_NAME,\n", + " pre_seq_len=NUM_PREFIX_TOKENS,\n", " tuning_mode=TUNING_MODE\n", ").to(DEVICE)" ] @@ -251,7 +241,6 @@ " project=\"bloom-sst-2\",\n", " config={\n", " \"num_epochs\": NUM_EPOCHS,\n", - " \"num_samples\": NUM_SAMPLES,\n", " \"batch_size\": BATCH_SIZE,\n", " \"learning_rate\": LR,\n", " \"weight_decay\": WEIGHT_DECAY,\n", @@ -291,7 +280,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3.8.10 64-bit", + "display_name": "Python 3.8.12 ('bloom-demo')", "language": "python", "name": "python3" }, @@ -305,11 +294,11 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.9" + "version": "3.8.12" }, "vscode": { "interpreter": { - "hash": "31f2aee4e71d21fbe5cf8b01ff0e069b9275f58929596ceb00d14d90e3e16cd6" + "hash": "175c31e15dd38a7dfc9eb4117a9e428ffb6063af97d545b6bfba4d874ecc4bb8" } } },