{ "nbformat": 4, "nbformat_minor": 0, "metadata": { "colab": { "provenance": [] }, "kernelspec": { "name": "python3", "display_name": "Python 3" }, "language_info": { "name": "python" }, "accelerator": "GPU", "gpuClass": "standard" }, "cells": [ { "cell_type": "code", "execution_count": null, "metadata": { "id": "u7RAqjzj4ylm" }, "outputs": [], "source": [ "!pip install happytransformer" ] }, { "cell_type": "code", "source": [ "from happytransformer import HappyGeneration\n", "\n", "happy_gen = HappyGeneration(\"GPT-NEO\", \"EleutherAI/gpt-neo-125M\")" ], "metadata": { "id": "4V9hd8bQ41HD" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": [ "!wget https://huggingface.co./datasets/DarwinAnim8or/grug/resolve/main/grug-training.txt" ], "metadata": { "id": "hz3fzo5W9ppf" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": [ "from happytransformer import GENTrainArgs \n", "\n", "args = GENTrainArgs(learning_rate =1e-5, num_train_epochs = 2)\n", "happy_gen.train(\"grug-training.txt\", args=args)" ], "metadata": { "id": "Yl4wNVvK5Bex" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": [ "from happytransformer import GENSettings\n", "args_top_k = GENSettings(no_repeat_ngram_size=3, do_sample=True,top_k=50, temperature=0.7, max_length=50, early_stopping=False)" ], "metadata": { "id": "LXi7hXFtBLpN" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": [ "result = happy_gen.generate_text(\"\"\"Person: \"Hello grug\"\n", "Grug: \"hello person\"\n", "###\n", "Person: \"how are you grug\"\n", "Grug: \"grug doing ok. grug find many berry. good for tribe.\"\n", "###\n", "Person: \"what does grug think of new spear weapon?\"\n", "Grug: \"grug no like new spear weapon. grug stick bigger. spear too small, break easy\"\n", "###\n", "Person: \"what does grug think of football?\"\n", "Grug: \\\"\"\"\", args=args_top_k)\n", "#print(result)\n", "print(result.text)" ], "metadata": { "id": "ih4KihPy_U_h" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": [ "#To save the model, run this cell.\n", "happy_gen.save(\"gpt-grug-125m-epoch4/\")" ], "metadata": { "id": "LFUPtXAo_dTz" }, "execution_count": null, "outputs": [] } ] }