Merge branch 'karpathy:master' into master
This commit is contained in:
@@ -10,6 +10,8 @@ Please note that this started recently as just a fun weekend project: I took my
|
||||
|
||||
## feel the magic
|
||||
|
||||
[](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
|
||||
@@ -240,7 +242,9 @@ If your candidate PRs have elements of these it doesn't mean they won't get merg
|
||||
- Kotlin
|
||||
- [llama2.kt](https://github.com/madroidmaq/llama2.kt) by @[madroidmaq](https://github.com/madroidmaq): a Kotlin port of this project
|
||||
- Python
|
||||
- [llama2.py](https://github.com/tairov/llama2.py) by @[tairov](https://github.com/tairov): a simple one file pure Python port of this project with zero dependencies
|
||||
- [llama2.py](https://github.com/tairov/llama2.py) by @[tairov](https://github.com/tairov): a simple one file pure Python port of this project with zero dependencies
|
||||
- C#
|
||||
- [llama2.cs](https://github.com/trrahul/llama2.cs) by @[trrahul](https://github.com/trrahul): a C# port of this project
|
||||
- [llama2.c - Llama 2 Everywhere](https://github.com/trholding/llama2.c) by @[trholding](https://github.com/trholding): Standalone, Bootable & Portable Binary Llama 2
|
||||
|
||||
## unsorted todos
|
||||
|
||||
@@ -517,7 +517,7 @@ int main(int argc, char *argv[]) {
|
||||
char *checkpoint = NULL; // e.g. out/model.bin
|
||||
float temperature = 1.0f; // 0.0 = greedy deterministic. 1.0 = original. don't set higher
|
||||
float topp = 0.9f; // top-p in nucleus sampling
|
||||
rng_seed = (unsigned int)time(NULL); // seed rng with time by default
|
||||
rng_seed = 0; // seed rng with time by default
|
||||
int steps = 256; // number of steps to run for
|
||||
char *prompt = NULL; // prompt string
|
||||
|
||||
@@ -536,7 +536,7 @@ int main(int argc, char *argv[]) {
|
||||
else if (argv[i][1] == 'i') { prompt = argv[i + 1]; }
|
||||
else { error_usage(); }
|
||||
}
|
||||
if(rng_seed == 0) { fprintf(stderr, "Cannot use seed=0 because of the rng alg used\n"); return 1; }
|
||||
if(rng_seed == 0) { rng_seed = (unsigned int)time(NULL);}
|
||||
|
||||
// read in the model.bin file
|
||||
Config config;
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "HLdoj4cz-xal"
|
||||
},
|
||||
"source": [
|
||||
"# Run.c\n",
|
||||
"\n",
|
||||
"[](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 runfast"
|
||||
]
|
||||
},
|
||||
{
|
||||
"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
|
||||
}
|
||||
Reference in New Issue
Block a user