From e2bb6cdd5158528d748c0e339e035a406e413906 Mon Sep 17 00:00:00 2001 From: MaartenGr Date: Wed, 25 Sep 2024 12:04:38 +0200 Subject: [PATCH] Add Google Colab pip instructions --- ... 1 - Introduction to Language Models.ipynb | 31 +++++++++++++++++++ ...pter 2 - Tokens and Token Embeddings.ipynb | 26 ++++++++++++++++ .../Chapter 3 - Looking Inside LLMs.ipynb | 28 ++++++++++++++++- .../Chapter 4 - Text Classification.ipynb | 29 ++++++++++++++++- ...- Text Clustering and Topic Modeling.ipynb | 26 ++++++++++++++++ .../Chapter 6 - Prompt Engineering.ipynb | 29 ++++++++++++++++- ...Text Generation Techniques and Tools.ipynb | 27 ++++++++++++++++ chapter08/Chapter 8 - Semantic Search.ipynb | 29 ++++++++++++++++- ...9 - Multimodal Large Language Models.ipynb | 28 ++++++++++++++++- ... 10 - Creating Text Embedding Models.ipynb | 29 ++++++++++++++++- chapter11/Chapter 11 - Fine-Tuning BERT.ipynb | 28 ++++++++++++++++- ...r 12 - Fine-tuning Generation Models.ipynb | 28 ++++++++++++++++- 12 files changed, 330 insertions(+), 8 deletions(-) diff --git a/chapter01/Chapter 1 - Introduction to Language Models.ipynb b/chapter01/Chapter 1 - Introduction to Language Models.ipynb index a64ce8e..8b4fdd5 100644 --- a/chapter01/Chapter 1 - Introduction to Language Models.ipynb +++ b/chapter01/Chapter 1 - Introduction to Language Models.ipynb @@ -25,6 +25,37 @@ "\n" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### [OPTIONAL] - Installing Packages on \n", + "\n", + "If you are viewing this notebook on Google Colab (or any other cloud vendor), you need to **uncomment and run** the following codeblock to install the dependencies for this chapter:" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "\n", + "💡 **NOTE**: We will want to use a GPU to run the examples in this notebook. In Google Colab, go to\n", + "**Runtime > Change runtime type > Hardware accelerator > GPU > GPU type > T4**.\n", + "\n", + "---" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# %%capture\n", + "# !pip install transformers>=4.40.1 accelerate>=0.27.2" + ] + }, { "cell_type": "markdown", "metadata": { diff --git a/chapter02/Chapter 2 - Tokens and Token Embeddings.ipynb b/chapter02/Chapter 2 - Tokens and Token Embeddings.ipynb index 9d697da..20a730b 100644 --- a/chapter02/Chapter 2 - Tokens and Token Embeddings.ipynb +++ b/chapter02/Chapter 2 - Tokens and Token Embeddings.ipynb @@ -25,6 +25,32 @@ "\n" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### [OPTIONAL] - Installing Packages on \n", + "\n", + "If you are viewing this notebook on Google Colab (or any other cloud vendor), you need to **uncomment and run** the following codeblock to install the dependencies for this chapter:\n", + "\n", + "---\n", + "\n", + "💡 **NOTE**: We will want to use a GPU to run the examples in this notebook. In Google Colab, go to\n", + "**Runtime > Change runtime type > Hardware accelerator > GPU > GPU type > T4**.\n", + "\n", + "---" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# %%capture\n", + "# !pip install transformers>=4.41.2 sentence-transformers>=3.0.1 gensim>=4.3.2 scikit-learn>=1.5.0 accelerate>=0.31.0" + ] + }, { "cell_type": "markdown", "metadata": { diff --git a/chapter03/Chapter 3 - Looking Inside LLMs.ipynb b/chapter03/Chapter 3 - Looking Inside LLMs.ipynb index 69f4174..59decf8 100644 --- a/chapter03/Chapter 3 - Looking Inside LLMs.ipynb +++ b/chapter03/Chapter 3 - Looking Inside LLMs.ipynb @@ -24,6 +24,32 @@ "" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### [OPTIONAL] - Installing Packages on \n", + "\n", + "If you are viewing this notebook on Google Colab (or any other cloud vendor), you need to **uncomment and run** the following codeblock to install the dependencies for this chapter:\n", + "\n", + "---\n", + "\n", + "💡 **NOTE**: We will want to use a GPU to run the examples in this notebook. In Google Colab, go to\n", + "**Runtime > Change runtime type > Hardware accelerator > GPU > GPU type > T4**.\n", + "\n", + "---\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# %%capture\n", + "# !pip install transformers>=4.41.2 accelerate>=0.31.0" + ] + }, { "cell_type": "markdown", "metadata": { @@ -862,7 +888,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.0" + "version": "3.10.14" }, "widgets": { "application/vnd.jupyter.widget-state+json": { diff --git a/chapter04/Chapter 4 - Text Classification.ipynb b/chapter04/Chapter 4 - Text Classification.ipynb index 53dfb10..da376f5 100644 --- a/chapter04/Chapter 4 - Text Classification.ipynb +++ b/chapter04/Chapter 4 - Text Classification.ipynb @@ -24,6 +24,33 @@ "" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### [OPTIONAL] - Installing Packages on \n", + "\n", + "\n", + "If you are viewing this notebook on Google Colab (or any other cloud vendor), you need to **uncomment and run** the following codeblock to install the dependencies for this chapter:\n", + "\n", + "---\n", + "\n", + "💡 **NOTE**: We will want to use a GPU to run the examples in this notebook. In Google Colab, go to\n", + "**Runtime > Change runtime type > Hardware accelerator > GPU > GPU type > T4**.\n", + "\n", + "---\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# %%capture\n", + "# !pip install datasets transformers sentence-transformers openai" + ] + }, { "cell_type": "markdown", "metadata": { @@ -1067,7 +1094,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.0" + "version": "3.10.14" }, "widgets": { "application/vnd.jupyter.widget-state+json": { diff --git a/chapter05/Chapter 5 - Text Clustering and Topic Modeling.ipynb b/chapter05/Chapter 5 - Text Clustering and Topic Modeling.ipynb index f23db52..5900008 100644 --- a/chapter05/Chapter 5 - Text Clustering and Topic Modeling.ipynb +++ b/chapter05/Chapter 5 - Text Clustering and Topic Modeling.ipynb @@ -24,6 +24,32 @@ "\n" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### [OPTIONAL] - Installing Packages on \n", + "\n", + "If you are viewing this notebook on Google Colab (or any other cloud vendor), you need to **uncomment and run** the following codeblock to install the dependencies for this chapter:\n", + "\n", + "---\n", + "\n", + "💡 **NOTE**: We will want to use a GPU to run the examples in this notebook. In Google Colab, go to\n", + "**Runtime > Change runtime type > Hardware accelerator > GPU > GPU type > T4**.\n", + "\n", + "---\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# %%capture\n", + "# !pip install bertopic datasets openai datamapplot" + ] + }, { "cell_type": "markdown", "metadata": { diff --git a/chapter06/Chapter 6 - Prompt Engineering.ipynb b/chapter06/Chapter 6 - Prompt Engineering.ipynb index d0ab6f8..859f11e 100644 --- a/chapter06/Chapter 6 - Prompt Engineering.ipynb +++ b/chapter06/Chapter 6 - Prompt Engineering.ipynb @@ -24,6 +24,33 @@ "" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### [OPTIONAL] - Installing Packages on \n", + "\n", + "If you are viewing this notebook on Google Colab (or any other cloud vendor), you need to **uncomment and run** the following codeblock to install the dependencies for this chapter:\n", + "\n", + "---\n", + "\n", + "💡 **NOTE**: We will want to use a GPU to run the examples in this notebook. In Google Colab, go to\n", + "**Runtime > Change runtime type > Hardware accelerator > GPU > GPU type > T4**.\n", + "\n", + "---\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# %%capture\n", + "# !pip install langchain>=0.1.17 openai>=1.13.3 langchain_openai>=0.1.6 transformers>=4.40.1 datasets>=2.18.0 accelerate>=0.27.2 sentence-transformers>=2.5.1 duckduckgo-search>=5.2.2\n", + "# !CMAKE_ARGS=\"-DLLAMA_CUBLAS=on\" pip install llama-cpp-python" + ] + }, { "cell_type": "markdown", "metadata": { @@ -1264,7 +1291,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.0" + "version": "3.10.14" }, "widgets": { "application/vnd.jupyter.widget-state+json": { diff --git a/chapter07/Chapter 7 - Advanced Text Generation Techniques and Tools.ipynb b/chapter07/Chapter 7 - Advanced Text Generation Techniques and Tools.ipynb index 123845a..2bf93e1 100644 --- a/chapter07/Chapter 7 - Advanced Text Generation Techniques and Tools.ipynb +++ b/chapter07/Chapter 7 - Advanced Text Generation Techniques and Tools.ipynb @@ -24,6 +24,33 @@ "" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### [OPTIONAL] - Installing Packages on \n", + "\n", + "If you are viewing this notebook on Google Colab (or any other cloud vendor), you need to **uncomment and run** the following codeblock to install the dependencies for this chapter:\n", + "\n", + "---\n", + "\n", + "💡 **NOTE**: We will want to use a GPU to run the examples in this notebook. In Google Colab, go to\n", + "**Runtime > Change runtime type > Hardware accelerator > GPU > GPU type > T4**.\n", + "\n", + "---\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# %%capture\n", + "# !pip install langchain>=0.1.17 openai>=1.13.3 langchain_openai>=0.1.6 transformers>=4.40.1 datasets>=2.18.0 accelerate>=0.27.2 sentence-transformers>=2.5.1 duckduckgo-search>=5.2.2 langchain_community\n", + "# !CMAKE_ARGS=\"-DLLAMA_CUDA=on\" pip install llama-cpp-python==0.2.69" + ] + }, { "cell_type": "markdown", "metadata": { diff --git a/chapter08/Chapter 8 - Semantic Search.ipynb b/chapter08/Chapter 8 - Semantic Search.ipynb index 31715e9..33572e6 100644 --- a/chapter08/Chapter 8 - Semantic Search.ipynb +++ b/chapter08/Chapter 8 - Semantic Search.ipynb @@ -24,6 +24,33 @@ "\n" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### [OPTIONAL] - Installing Packages on \n", + "\n", + "If you are viewing this notebook on Google Colab (or any other cloud vendor), you need to **uncomment and run** the following codeblock to install the dependencies for this chapter:\n", + "\n", + "---\n", + "\n", + "💡 **NOTE**: We will want to use a GPU to run the examples in this notebook. In Google Colab, go to\n", + "**Runtime > Change runtime type > Hardware accelerator > GPU > GPU type > T4**.\n", + "\n", + "---\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# %%capture\n", + "# !pip install langchain==0.2.5 faiss-gpu==1.7.2 cohere==5.5.8 langchain-community==0.2.5 rank_bm25==0.2.2 sentence-transformers==3.0.1\n", + "# !CMAKE_ARGS=\"-DLLAMA_CUDA=on\" pip install llama-cpp-python==0.2.78" + ] + }, { "cell_type": "markdown", "metadata": { @@ -1899,7 +1926,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.0" + "version": "3.10.14" }, "widgets": { "application/vnd.jupyter.widget-state+json": { diff --git a/chapter09/Chapter 9 - Multimodal Large Language Models.ipynb b/chapter09/Chapter 9 - Multimodal Large Language Models.ipynb index 5795baf..b5c149d 100644 --- a/chapter09/Chapter 9 - Multimodal Large Language Models.ipynb +++ b/chapter09/Chapter 9 - Multimodal Large Language Models.ipynb @@ -24,6 +24,32 @@ "" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### [OPTIONAL] - Installing Packages on \n", + "\n", + "If you are viewing this notebook on Google Colab (or any other cloud vendor), you need to **uncomment and run** the following codeblock to install the dependencies for this chapter:\n", + "\n", + "---\n", + "\n", + "💡 **NOTE**: We will want to use a GPU to run the examples in this notebook. In Google Colab, go to\n", + "**Runtime > Change runtime type > Hardware accelerator > GPU > GPU type > T4**.\n", + "\n", + "---\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# %%capture\n", + "# !pip install matplotlib transformers datasets accelerate sentence-transformers" + ] + }, { "cell_type": "markdown", "metadata": { @@ -2623,7 +2649,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.0" + "version": "3.10.14" }, "widgets": { "application/vnd.jupyter.widget-state+json": { diff --git a/chapter10/Chapter 10 - Creating Text Embedding Models.ipynb b/chapter10/Chapter 10 - Creating Text Embedding Models.ipynb index d41c0a0..fc8fea4 100644 --- a/chapter10/Chapter 10 - Creating Text Embedding Models.ipynb +++ b/chapter10/Chapter 10 - Creating Text Embedding Models.ipynb @@ -24,6 +24,33 @@ "\n" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### [OPTIONAL] - Installing Packages on \n", + "\n", + "If you are viewing this notebook on Google Colab (or any other cloud vendor), you need to **uncomment and run** the following codeblock to install the dependencies for this chapter:\n", + "\n", + "---\n", + "\n", + "💡 **NOTE**: We will want to use a GPU to run the examples in this notebook. In Google Colab, go to\n", + "**Runtime > Change runtime type > Hardware accelerator > GPU > GPU type > T4**.\n", + "\n", + "---\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# %%capture\n", + "# !pip install -q accelerate>=0.27.2 peft>=0.9.0 bitsandbytes>=0.43.0 transformers>=4.38.2 trl>=0.7.11 sentencepiece>=0.1.99\n", + "# !pip install -q sentence-transformers>=3.0.0 mteb>=1.1.2 datasets>=2.18.0" + ] + }, { "cell_type": "markdown", "metadata": { @@ -2703,7 +2730,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.0" + "version": "3.10.14" }, "widgets": { "application/vnd.jupyter.widget-state+json": { diff --git a/chapter11/Chapter 11 - Fine-Tuning BERT.ipynb b/chapter11/Chapter 11 - Fine-Tuning BERT.ipynb index 0beaa0d..bd48523 100644 --- a/chapter11/Chapter 11 - Fine-Tuning BERT.ipynb +++ b/chapter11/Chapter 11 - Fine-Tuning BERT.ipynb @@ -24,6 +24,32 @@ "\n" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### [OPTIONAL] - Installing Packages on \n", + "\n", + "If you are viewing this notebook on Google Colab (or any other cloud vendor), you need to **uncomment and run** the following codeblock to install the dependencies for this chapter:\n", + "\n", + "---\n", + "\n", + "💡 **NOTE**: We will want to use a GPU to run the examples in this notebook. In Google Colab, go to\n", + "**Runtime > Change runtime type > Hardware accelerator > GPU > GPU type > T4**.\n", + "\n", + "---\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# %%capture\n", + "# !pip install datasets>=2.18.0 transformers>=4.38.2 sentence-transformers>=2.5.1 setfit>=1.0.3 accelerate>=0.27.2 seqeval>=1.2.2" + ] + }, { "cell_type": "markdown", "metadata": { @@ -3593,7 +3619,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.0" + "version": "3.10.14" }, "widgets": { "application/vnd.jupyter.widget-state+json": { diff --git a/chapter12/Chapter 12 - Fine-tuning Generation Models.ipynb b/chapter12/Chapter 12 - Fine-tuning Generation Models.ipynb index 9df4e33..c336827 100644 --- a/chapter12/Chapter 12 - Fine-tuning Generation Models.ipynb +++ b/chapter12/Chapter 12 - Fine-tuning Generation Models.ipynb @@ -24,6 +24,32 @@ "" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### [OPTIONAL] - Installing Packages on \n", + "\n", + "If you are viewing this notebook on Google Colab (or any other cloud vendor), you need to **uncomment and run** the following codeblock to install the dependencies for this chapter:\n", + "\n", + "---\n", + "\n", + "💡 **NOTE**: We will want to use a GPU to run the examples in this notebook. In Google Colab, go to\n", + "**Runtime > Change runtime type > Hardware accelerator > GPU > GPU type > T4**.\n", + "\n", + "---\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# %%capture\n", + "# !pip install -q accelerate peft bitsandbytes transformers trl sentencepiece" + ] + }, { "cell_type": "markdown", "metadata": { @@ -1952,7 +1978,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.0" + "version": "3.10.14" }, "widgets": { "application/vnd.jupyter.widget-state+json": {