{ "cells": [ { "cell_type": "markdown", "metadata": { "id": "m8t6tkjuuONX" }, "source": [ "## PaliGemma Fine-tuning\n", "\n", "In this notebook, we will fine-tune [pretrained PaliGemma](https://huggingface.co/google/paligemma2-3b-pt-448) on a small split of [VQAv2](https://huggingface.co/datasets/HuggingFaceM4/VQAv2) dataset. Let's get started by installing necessary libraries." ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "EB0gv8OzHfLV", "outputId": "9de07e75-ddf4-4347-fc41-432a23774e2c" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " Installing build dependencies ... \u001b[?25l\u001b[?25hdone\n", " Getting requirements to build wheel ... \u001b[?25l\u001b[?25hdone\n", " Preparing metadata (pyproject.toml) ... \u001b[?25l\u001b[?25hdone\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m480.6/480.6 kB\u001b[0m \u001b[31m25.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m69.1/69.1 MB\u001b[0m \u001b[31m28.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m116.3/116.3 kB\u001b[0m \u001b[31m7.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m179.3/179.3 kB\u001b[0m \u001b[31m14.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m134.8/134.8 kB\u001b[0m \u001b[31m8.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m3.0/3.0 MB\u001b[0m \u001b[31m75.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m194.1/194.1 kB\u001b[0m \u001b[31m17.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25h Building wheel for transformers (pyproject.toml) ... \u001b[?25l\u001b[?25hdone\n", "\u001b[31mERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.\n", "gcsfs 2024.10.0 requires fsspec==2024.10.0, but you have fsspec 2024.9.0 which is incompatible.\u001b[0m\u001b[31m\n", "\u001b[0m" ] } ], "source": [ "!pip install -q -U datasets bitsandbytes peft git+https://github.com/huggingface/transformers.git" ] }, { "cell_type": "markdown", "metadata": { "id": "q_85okyYt1eo" }, "source": [ "We will authenticate to access the model using `notebook_login()`." ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 17, "referenced_widgets": [ "4f0e85aa740146d3aca81588a0288031", "c7fcb9dd46e649c4b8bd967b69bdb867", "c3fad0f1cb954317a20ee158f7e10363", "3deca9286f89422aa691325b39347b0b", "ca1c290bfb654f1190bbde68d51167f1", "2d8493a60b7a42c1b25ec0bbe0a59043", "c25efe32ee7c40d3a4c95093abb2a720", "55c01e2c04d1499ca5b9b19dea7e4e02", "bf9da831d7ad4651a262c5e7f80bbf87", "ed2d3d1a700143d2a48e9a9b13bd1200", "40782cfc43a8437da5534feee03c6ba6", "b6fac3155dd140bc8e1b010270bc3cc2", "ca348c721475417582ed5018ed43151f", "3f07afac7c194db7a16167d177562a46", "5515d96f0c8947f0ad4b7f17eb7d63f6", "d703de12cf9d4f87aa6ec2cc52f1090a", "757bc788bd6842d28a9f889187ffb88e", "65f10d2456cb4ee1963fac050e4c34f7", "9335e48fe8ba4fe9b535b5ece1be6ff5", "80df5f3cd6c646808b09d99daed5bfd2" ] }, "id": "NzJZSHD8tZZy", "outputId": "c01b2b6f-3c1e-45da-9fc0-f4f518bcca24" }, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "4f0e85aa740146d3aca81588a0288031", "version_major": 2, "version_minor": 0 }, "text/plain": [ "VBox(children=(HTML(value='