{ "cells": [ { "cell_type": "markdown", "metadata": { "id": "intro" }, "source": [ "# EcoGrid-OpenEnv: Train 7B Model with GRPO\n", "This notebook allows you to train a powerful 7B parameter model (`Qwen2.5-7B-Instruct`) using **Google Colab's Free T4 GPU**.\n", "\n", "It uses **Unsloth** for blazing-fast 4-bit quantization and **TRL** for Group Relative Policy Optimization (GRPO).\n", "\n", "### Instructions:\n", "1. Go to `Runtime > Change runtime type` and select **T4 GPU**.\n", "2. Click **Run All**.\n", "3. Once finished, a `lora_adapter.zip` file will automatically download to your computer.\n", "4. Extract it into your project folder so the `app.py` can load it!" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "setup" }, "outputs": [], "source": [ "# 1. Install Unsloth and Dependencies\n", "!pip install \"unsloth[colab-new] @ git+https://github.com/unslothai/unsloth.git\"\n", "!pip install --no-deps xformers trl peft accelerate bitsandbytes\n", "\n", "# 2. Clone your GitHub Repository\n", "import os\n", "# Note: Using your public repository.\n", "!git clone https://github.com/DivyankLosse/EcoGrid.git\n", "os.chdir('EcoGrid')\n", "\n", "# 3. Run the Training Script!\n", "# We use Qwen2.5-7B-Instruct. We'll train for 1 epoch with 500 samples to keep it under 30 minutes.\n", "!python train_unsloth.py --model unsloth/Qwen2.5-7B-Instruct --task hard --epochs 1 --samples 500\n", "\n", "# 4. Zip the results and download\n", "import shutil\n", "from google.colab import files\n", "\n", "print(\"Zipping lora_adapter...\")\n", "shutil.make_archive('/content/lora_adapter', 'zip', 'lora_adapter')\n", "print(\"Zipping logs...\")\n", "shutil.make_archive('/content/logs', 'zip', 'logs')\n", "\n", "print(\"Downloading files...\")\n", "files.download('/content/lora_adapter.zip')\n", "files.download('/content/logs.zip')" ] } ], "metadata": { "accelerator": "GPU", "colab": { "provenance": [] }, "kernelspec": { "display_name": "Python 3", "name": "python3" }, "language_info": { "name": "python" } }, "nbformat": 4, "nbformat_minor": 0 }