{ "cells": [ { "cell_type": "markdown", "metadata": { "id": "Q-bj6K7Qv4ft" }, "source": [ "# Fine-Tuning a Generative Pretrained Transformer (`GPT`)\n", "\n", "1. Install required libraries." ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "OFWjSb_xDWja", "outputId": "1fad9f1e-e23b-404f-873f-ea84a975e5a8" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m7.6/7.6 MB\u001b[0m \u001b[31m29.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m519.6/519.6 kB\u001b[0m \u001b[31m40.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m179.8/179.8 kB\u001b[0m \u001b[31m21.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m294.8/294.8 kB\u001b[0m \u001b[31m32.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m7.8/7.8 MB\u001b[0m \u001b[31m86.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1.3/1.3 MB\u001b[0m \u001b[31m82.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m115.3/115.3 kB\u001b[0m \u001b[31m13.4 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[31m24.8 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[31m18.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m66.4/66.4 kB\u001b[0m \u001b[31m9.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m53.1/53.1 kB\u001b[0m \u001b[31m7.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25hToken will not been saved to git credential helper. Pass `add_to_git_credential=True` if you want to set the git credential as well.\n", "Token is valid (permission: write).\n", "Your token has been saved to /root/.cache/huggingface/token\n", "Login successful\n" ] } ], "source": [ "!pip install transformers datasets codecarbon -q" ] }, { "cell_type": "markdown", "metadata": { "id": "pY6M4fSb8SY6" }, "source": [ "2. Load the data from the hub." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 1000, "referenced_widgets": [ "1a030748487e45529bd11fce7b1b71d0", "71e8f79c02b84885a5fd56a6ea3b08b3", "26ca3d0aa4984c73966b568aea8db7ce", "87f7f181fe6c448ea810cb795e3a92d4", "ffbba5fe0b3f4883b2308cde9ef96c93", "5b4b8ea56c724f9cbe802464b7fd4437", "aa7277f416224e648f7edefa069d1e92", "3e59f39849214bb6a76534488eb79c0f", "ec368c07c15642b18b76437516f8f91d", "f16e4add3aed43b58789ba075c50df75", "fac1a8d047024e1e8b5960ec517d1dc9", "5179e6fe532849d4b90149ef66145d20", "2b703abf0a0d4f26bd67dbe8170751ab", "5ce99703807f46deb10e807570e58e51", "8e878d93659a4d01a0c5c3d2d710d5b9", "e7d1cd0d4e1c4f26935b041878845f5a", "b5c99b5b0c4742eea26df16f2327dcf2", "6d487a266fe74f6a9059ed45632a9580", "9e199ace0ed64048822785519a1ca7cf", "45e6f6d262b74457afeb45628c4c1c59", "dfca3ce9bbef4953bb27d8622a9a7be4", "5e2c15a48a1e4b15b652a2ff6a8465aa", "1850e110307948239746c606e9a468df", "2790b31ab6bd421e9e6148b27322ca8d", "203a93bea300442985cc9f29c4221a4c", "51a6d57838294457ace0b41c124c1d6a", "20cf89da81bd454ab1f3ae1cbaa2d092", "3ccbea64bd694d61a45c7fa72c4ee684", "a71a19aa3ff849788d37ab4c44da342e", "7c4771b1c6c546cd81437536d88863b7", "28bbff48246e453c85600878c7ba8ee2", "d55a950da91a482f83c802fb203befe0", "b0c1b72350f3409f8bd4bc844f298d16", "ebd10ae89a5342f2933da8e647b9422e", "2ebb1aa0d91245f882c7f6b0f71990e4", "97956777bee1430791a12d40a8cede20", "d1b605c17a0a4d3193d655f09c6137f3", "e6b0484516844365be71934a12d07010", "6dc902b567954b24b56d9df664686cdc", "6a5a4d2ec3ef46f18d94e4a51b39d6af", "57c7a3fc0dba4cdc966240a3c8287c80", "9cab6d1ae9ff4d8ba43a168e21a68ef3", "430c56ffe06e43368530b8c2e0a3285c", "c9a56ce6a2534936a358db8f9c59e90c", "0725db765caf493cab267a5e5af9346f", "965801107f314c23b963569defda1338", "cc81a6d3d5c241429a2b27d352c892be", "c840572d6db04d4daf7c05467859f8ca", "3dcfe17d28a64fd49e349164820e335f", "ac2f349219694051b8d19cacf55581bc", "3dd8dcea6c65482290f5d570d92de204", "1d211a24a8ab470284d6bce096086479", "45c4b2e6eefc43089a0f312df731582c", "15ad116807e547b9925270f6a04ba85d", "2e94e54375354eecbd412bd2e369d602", "4a795852e0b44f19b38be14ee2a05613", "6357dfb860ab445681af881aee51e30b", "fe4f54c59f5c408288a7cbef33645712", "d32d115a235e4ffcb986e48eb6d008c8", "9e8f2454931440a89cf8287628027272", "a196653c7fa14a60a1096ff47fbd007c", "4d4d8da148884e439750e8d235f92e4f", "b0ff27c8d09148dba67553f4583d8b6f", "48d3dcd6db9e4ac09ee01f342b224275", "af126f5fb4c2495583be18129945aca1", "d4252288a6fe4d7eb05ea8bd67b2e737", "ece73c0c65d7427db3ededb5f4851e74", "b333981c41af4cca9f1769c4fc918ad4", "879e63322ec54fb1a86e1491075cf407", "40d7b2da7a544f43ac2090a96e0819d2", "62bc32e596a24848becd47d5510bdcf2", "f4b1bae7a8834a6aa14b13891acf171c", "5916d21320024bf6ae711a0fe333c675", "69660b8473d14eee81fb6e1cc0fa606c", "fdf365c88f514cd095dfbf922c0c6f06", "6ee60208ef7d4c7ab2d8bb1608a2fc3b", "4eb1c10b5c1648f1ac1b71e9e9ccd4cd" ] }, "id": "6shzxz6ExMs-", "outputId": "81c9c1eb-44d1-4b5a-c107-a5e5db7ec79c" }, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "1a030748487e45529bd11fce7b1b71d0", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Downloading readme: 0%| | 0.00/2.81k [00:00, ?B/s]" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "5179e6fe532849d4b90149ef66145d20", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Downloading data files: 0%| | 0/2 [00:00, ?it/s]" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "1850e110307948239746c606e9a468df", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Downloading data: 0%| | 0.00/26.7M [00:00, ?B/s]" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "ebd10ae89a5342f2933da8e647b9422e", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Downloading data: 0%| | 0.00/29.5M [00:00, ?B/s]" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "0725db765caf493cab267a5e5af9346f", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Extracting data files: 0%| | 0/2 [00:00, ?it/s]" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "4a795852e0b44f19b38be14ee2a05613", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Generating english split: 0%| | 0/41815 [00:00, ? examples/s]" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "ece73c0c65d7427db3ededb5f4851e74", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Generating portuguese split: 0%| | 0/41815 [00:00, ? examples/s]" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "\n", "
\n", " | prompt | \n", "completion | \n", "
---|---|---|
0 | \n", "Por que os camelos conseguem sobreviver muito ... | \n", "Os camelos podem sobreviver por longos período... | \n", "
1 | \n", "Por que o celular é ruim para os humanos | \n", "Os telefones celulares como dispositivos tecno... | \n", "
2 | \n", "O que é um polígono? | \n", "Um polígono é uma figura geométrica bidimensio... | \n", "
3 | \n", "Como começo a correr? | \n", "Começar uma rotina de corrida pode ser uma óti... | \n", "
4 | \n", "Quais episódios da quarta temporada de Game of... | \n", "Michelle MacLaren dirigiu dois episódios da 4ª... | \n", "
... | \n", "... | \n", "... | \n", "
41810 | \n", "Como posso ligar para você? | \n", "Você pode me chamar de Aira. Como posso ajudá-... | \n", "
41811 | \n", "Qual é o seu nome de identificação? | \n", "Como inteligência artificial, não tenho nome d... | \n", "
41812 | \n", "Como você é chamado? | \n", "Olá! Meu nome é Aira. Como posso ajudá-lo hoje? | \n", "
41813 | \n", "Como você se apresenta? | \n", "Olá! Eu sou Aira, sua assistente prestativa, r... | \n", "
41814 | \n", "O que devo dizer quando me dirijo a você? | \n", "Ao se dirigir a mim, você pode simplesmente me... | \n", "
41815 rows × 2 columns
\n", "