{ "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": null, "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "SBWCrz5GfBXo", "outputId": "bbdb0ca8-0b5b-460d-b66a-0b3ff272275a" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m7.7/7.7 MB\u001b[0m \u001b[31m54.1 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[31m46.8 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[31m22.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m295.0/295.0 kB\u001b[0m \u001b[31m33.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m3.8/3.8 MB\u001b[0m \u001b[31m93.5 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[31m73.4 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[31m23.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.4 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[31m8.3 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.1 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": "y5XnfvSH7w4z" }, "source": [ "2. Load the data from the hub." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 647, "referenced_widgets": [ "936d184ef08b48ecbdce00c8c3ff093c", "38d6411a6dff480caf46dc2d7dc26448", "8bffb8fd6b4b4fe884108533ed86ec69", "972d591af9d349da94d2b32180622da5", "38a018e875344ce7bb0f11c277e3bfd0", "f262b8187042420aa80c2f616c471d68", "bfa489fa4773467e86def73dba41a579", "8bc15302c5ef4adfb35642f07724dc67", "c05db576b5174315895d071fa478694b", "3e9c687d9ebb45a7b1a170ee702fa53d", "84300bdbbe1d482f80082d230142ce42", "2e2f0c8b7585493bae9dd43e976e7db5", "6a2995c347d7454690bf8660f58b9979", "afd1fb93757542f39230cabbe78c274b", "b73408a6d1e7411eb703e9cc333191b4", "eb2017f8d0e5440d983f8d099c22f73f", "05f810204f6e4de484f3609586d0168c", "b16ca7cdf7a44a21997cd81cf58f67b9", "3e32ac4b23d24ff595fabefe6a8433ba", "109fe9eca9e54ca9b10afef9721c340b", "e087cfbe3cdf414f83ab0c89cc83cb79", "61f8dab83b144caeb64d0f153231c420", "d84a27c3bc3446838f7b16eb829d67d4", "a8f8ee81213e497ead582b7ad44b3ae1", "52dee8e1568d4b44900f8ae3414b23a5", "a1dde1181ad043c2afb333099c22ede7", "d3b544f0361643718e8f31451e90dbc5", "e8be32d4661a4e61b6f7f866e8974fba", "2f155ef0887d414a9e5e8f3730e2291b", "7609166c7366443dad144d779e65dddb", "89140c83ab134ee3901a22d5fd1b9f4c", "c47db16a033241b299feef2c054ab246", "72a699f904474d1aa5eefc0f50f64a39", "5f29e1a658664fe891f95c6c02b5b783", "8e6e2bfd0ba84a8ab8c51dc7c10255d5", "af2ea8baf70f4d4388595aa596cbb269", "049df2ea4ac0406b9f08a93fc935826c", "2896c38a78774fd1ae55c342c885a4ab", "cdbb313537854b86894c2c98ef1c0b01", "5fac56ecb01040f9a13e023aac3ba7c3", "dac12901cf724774b1f557609b18be29", "6fb594ea31b5448dbf2d4fc75babb02b", "77c04adfb91a42f28f3f369a0600f69d", "20f1205607dd4e50903a62c01ed01bc4", "453e2274549c4ef18935cf8c5fd70469", "932da1c8db6a4f80b45c92363cb9b426", "e5ef76d0424d401e8effad3d09263d88", "3dd837c3ae1d4cff929dae76967bfb95", "92cbf24e9c4f47e98103597e27b94ce1", "a438beee19094656a0f02d67bcd17a41", "633aa73de3c54dcb9dacc1877fdb231d", "66890842fc3546d4a21c37be1d90e6ba", "4b36a77d2c2b4446bfcefd8905b74696", "c8df5c16d7af4d77bac308c8ad94fd2a", "f5b9e28b5de149ed9e55d1ebc849dca0", "fab45dffbfc04e76938b6a3cec1f1933", "304efffefc5146d89aab4157e71d4c81", "ebce7e05cb364338bf6d645ee7c87dc3", "0fe282c32f3042d9ba3d62ed45b25f35", "4bedbe52701b4e1a90faa34b0aa11a91", "4be4e9a11820494eb2f3d3c9ddc7b99c", "86a221d816cc471bb991d44865875364", "44eaed4234a74c249539f42f41a1dc30", "3d7e7d3c46d14d37bae53b027ce1887c", "73f7e4a9b1aa4e0c86212485ec88250f", "24d411bde05b4de9b02a9ead2b893a8f", "03ce8749bfb241b5ae5ac8022dd811ed", "117219b3db2b46a0a2619262a4782eff", "733f49bdc59e484fab1a01abcf64600f", "bb0f6b8e7ae14d659216a4080b69d81b", "5e87656b12b145fcb6804f69870290f0", "4aa390d30f154d31ba84799584b87a97", "a9e0b3fe19284dd7a7ef70086a86abdf", "f1fbcbab126348d8b3afe50854ffece6", "4b37f5fb30274c789d867992daf717dd", "e0767744eef4459d98da70f8f0e54c6f", "c2ad43d7dffe4aa79e7c4fd812f3f72d" ] }, "id": "7MbpXGu-v4f1", "outputId": "b38e9f01-1d6b-4266-d670-aab2d17ac0dc" }, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "936d184ef08b48ecbdce00c8c3ff093c", "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": "2e2f0c8b7585493bae9dd43e976e7db5", "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": "d84a27c3bc3446838f7b16eb829d67d4", "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": "5f29e1a658664fe891f95c6c02b5b783", "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": "453e2274549c4ef18935cf8c5fd70469", "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": "fab45dffbfc04e76938b6a3cec1f1933", "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": "03ce8749bfb241b5ae5ac8022dd811ed", "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", "Why can camels survive for long without water? | \n", "Camels can survive for long periods without wa... | \n", "
1 | \n", "Why mobile is bad for human | \n", "Mobile phones as technological devices have be... | \n", "
2 | \n", "What is a polygon? | \n", "A polygon is a two-dimensional geometric figur... | \n", "
3 | \n", "How do I start running? | \n", "Starting a running routine can be a great way ... | \n", "
4 | \n", "Which episodes of season four of Game of Thron... | \n", "Michelle MacLaren directed two episodes in Sea... | \n", "
... | \n", "... | \n", "... | \n", "
41810 | \n", "What can I call you by? | \n", "You can call me Aira. How may I assist you today? | \n", "
41811 | \n", "What's your identification name? | \n", "As an artificial intelligence, I do not have a... | \n", "
41812 | \n", "What are you called? | \n", "Hello! I am called Aira. How can I assist you ... | \n", "
41813 | \n", "How do you introduce yourself? | \n", "Hello! I am Aira, your helpful, respectful, an... | \n", "
41814 | \n", "What should I say when I address you? | \n", "When addressing me, you can simply call me Air... | \n", "
41815 rows × 2 columns
\n", "