diff --git a/README.md b/README.md index 126c901..0721c19 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,8 @@ Please note that this started recently as just a fun weekend project: I took my ## feel the magic +[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/karpathy/llama2.c/blob/master/run.ipynb) + First, navigate to the folder when you keep your projects and clone this repository to this folder: ```bash diff --git a/run.ipynb b/run.ipynb new file mode 100644 index 0000000..95c5b0f --- /dev/null +++ b/run.ipynb @@ -0,0 +1,109 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "id": "HLdoj4cz-xal" + }, + "source": [ + "# Run.c\n", + "\n", + "[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/karpathy/llama2.c/blob/master/run.ipynb)\n", + "\n", + "More details can be found in the [README.md](README.md) ." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "Une3Ozlnu1B7" + }, + "outputs": [], + "source": [ + "#@title Clone Project\n", + "\n", + "!git clone https://github.com/karpathy/llama2.c.git\n", + "%cd llama2.c" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "#@title Build\n", + "\n", + "!make run" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "thm0ZBrtSgoC" + }, + "outputs": [], + "source": [ + "#@title Pick Your Model\n", + "\n", + "#@markdown Choose model\n", + "model = \"stories15M\" #@param [\"stories15M\", \"stories42M\", \"stories110M\"]\n", + "\n", + "download_url = \"\"\n", + "\n", + "if(model == \"stories15M\"):\n", + " download_url = \"https://huggingface.co/karpathy/tinyllamas/resolve/main/stories15M.bin\"\n", + "if(model == \"stories42M\"):\n", + " download_url = \"https://huggingface.co/karpathy/tinyllamas/resolve/main/stories42M.bin\"\n", + "if(model == \"stories110M\"):\n", + " download_url = \"https://huggingface.co/karpathy/tinyllamas/resolve/main/stories110M.bin\"\n", + "\n", + "print(f\"download_url: {download_url}\")\n", + "\n", + "!wget $download_url\n", + "\n", + "model_file = model + \".bin\"" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "OgAc3KjuT-NM" + }, + "outputs": [], + "source": [ + "#@title Generate Stories\n", + "\n", + "# Generate args\n", + "max_token = 256 #@param {type:\"slider\", min:32, max:1024, step:32}\n", + "temperature = 0.8 #@param {type:\"slider\", min:0.0, max:1, step:0.05}\n", + "top_p = 0.9 #@param {type:\"slider\", min:0.0, max:1.0, step:0.05}\n", + "prompt = \"One day, Lily met a Shoggoth\" #@param {type:\"string\"}\n", + "\n", + "print(f\"model: {model_file}, max_token: {max_token}, temperature: {temperature}, top_p: {top_p}, prompt: {prompt}\")\n", + "print(f\"----------------------------\\n\")\n", + "\n", + "cmd = f'./run {model_file} -t {temperature} -p {top_p} -n {max_token} -i \"{prompt}\"'\n", + "!{cmd}" + ] + } + ], + "metadata": { + "colab": { + "private_outputs": true, + "provenance": [] + }, + "kernelspec": { + "display_name": "Python 3", + "name": "python3" + }, + "language_info": { + "name": "python" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +}