zetavg commited on
Commit
d803879
β€’
1 Parent(s): 9279c83

update README.md and LLaMA_LoRA.ipynb

Browse files
Files changed (2) hide show
  1. LLaMA_LoRA.ipynb +4 -38
  2. README.md +94 -0
LLaMA_LoRA.ipynb CHANGED
@@ -6,7 +6,7 @@
6
  "provenance": [],
7
  "private_outputs": true,
8
  "toc_visible": true,
9
- "authorship_tag": "ABX9TyOQclbOikH+aaXWlbaTkEqc",
10
  "include_colab_link": true
11
  },
12
  "kernelspec": {
@@ -34,7 +34,8 @@
34
  "cell_type": "markdown",
35
  "source": [
36
  "# πŸ¦™πŸŽ›οΈ LLaMA-LoRA\n",
37
- "\n", "TL;DR: **Runtime > Run All** (`⌘/Ctrl+F9`). Takes about 5 minutes to start. You will be promped to authorize Google Drive access."
 
38
  ],
39
  "metadata": {
40
  "id": "bb4nzBvLfZUj"
@@ -74,7 +75,7 @@
74
  "# @markdown The URL of the LLaMA-LoRA project<br>&nbsp;&nbsp;(default: `https://github.com/zetavg/llama-lora.git`):\n",
75
  "llama_lora_project_url = \"https://github.com/zetavg/llama-lora.git\" # @param {type:\"string\"}\n",
76
  "# @markdown The branch to use for LLaMA-LoRA project:\n",
77
- "llama_lora_project_branch = \"dev-2\" # @param {type:\"string\"}\n",
78
  "\n",
79
  "# # @markdown Forces the local directory to be updated by the remote branch:\n",
80
  "# force_update = True # @param {type:\"boolean\"}\n"
@@ -309,41 +310,6 @@
309
  },
310
  "execution_count": null,
311
  "outputs": []
312
- },
313
- {
314
- "cell_type": "markdown",
315
- "source": [
316
- "# Reset"
317
- ],
318
- "metadata": {
319
- "id": "RW09SrCZpqpa"
320
- }
321
- },
322
- {
323
- "cell_type": "code",
324
- "source": [
325
- "# @title Kill Session { display-mode: \"form\" }\n",
326
- "# @markdown If you ran out of runtime resources, you can **check the following \n",
327
- "# @markdown checkbox and run this code cell to kill the runtime session** while\n",
328
- "# @markdown preserving your downloaded data.\n",
329
- "do_kill_session = False # @param {type:\"boolean\"}\n",
330
- "# @markdown You will need to re-run this notebook from start after doing this.\n",
331
- "#\n",
332
- "# @markdown All data that are saved to disk, including Python dependencies, base\n",
333
- "# @markdown models will all be preserved, so the second run will be much faster.\n",
334
- "\n",
335
- "import os\n",
336
- "def kill_session():\n",
337
- " os.kill(os.getpid(), 9)\n",
338
- "\n",
339
- "if do_kill_session:\n",
340
- " kill_session()"
341
- ],
342
- "metadata": {
343
- "id": "bM4sY2tVps8U"
344
- },
345
- "execution_count": null,
346
- "outputs": []
347
  }
348
  ]
349
  }
 
6
  "provenance": [],
7
  "private_outputs": true,
8
  "toc_visible": true,
9
+ "authorship_tag": "ABX9TyMHMc4PwWLbRlhFol+WRzoT",
10
  "include_colab_link": true
11
  },
12
  "kernelspec": {
 
34
  "cell_type": "markdown",
35
  "source": [
36
  "# πŸ¦™πŸŽ›οΈ LLaMA-LoRA\n",
37
+ "\n",
38
+ "TL;DR: **Runtime > Run All** (`⌘/Ctrl+F9`). Takes about 5 minutes to start. You will be promped to authorize Google Drive access."
39
  ],
40
  "metadata": {
41
  "id": "bb4nzBvLfZUj"
 
75
  "# @markdown The URL of the LLaMA-LoRA project<br>&nbsp;&nbsp;(default: `https://github.com/zetavg/llama-lora.git`):\n",
76
  "llama_lora_project_url = \"https://github.com/zetavg/llama-lora.git\" # @param {type:\"string\"}\n",
77
  "# @markdown The branch to use for LLaMA-LoRA project:\n",
78
+ "llama_lora_project_branch = \"main\" # @param {type:\"string\"}\n",
79
  "\n",
80
  "# # @markdown Forces the local directory to be updated by the remote branch:\n",
81
  "# force_update = True # @param {type:\"boolean\"}\n"
 
310
  },
311
  "execution_count": null,
312
  "outputs": []
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
313
  }
314
  ]
315
  }
README.md CHANGED
@@ -15,6 +15,100 @@ Making evaluating and fine-tuning LLaMA models with low-rank adaptation (LoRA) e
15
  * Supports Stanford Alpaca [seed_tasks](https://github.com/tatsu-lab/stanford_alpaca/blob/main/seed_tasks.jsonl), [alpaca_data](https://github.com/tatsu-lab/stanford_alpaca/blob/main/alpaca_data.json) and [OpenAI "prompt"-"completion"](https://platform.openai.com/docs/guides/fine-tuning/data-formatting) format.
16
 
17
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  ## Acknowledgements
19
 
20
  * https://github.com/tloen/alpaca-lora
 
15
  * Supports Stanford Alpaca [seed_tasks](https://github.com/tatsu-lab/stanford_alpaca/blob/main/seed_tasks.jsonl), [alpaca_data](https://github.com/tatsu-lab/stanford_alpaca/blob/main/alpaca_data.json) and [OpenAI "prompt"-"completion"](https://platform.openai.com/docs/guides/fine-tuning/data-formatting) format.
16
 
17
 
18
+ ## How to Start
19
+
20
+ There are various ways to run this app:
21
+
22
+ * **[Run on Google Colab](#run-on-google-colab)**: The simplest way to get started, all you need is a Google account. Standard (free) GPU runtime is sufficient to run generation and training with micro batch size of 8. However, the text generation and training is much slower than on other cloud services, and Colab might terminate the execution in inactivity while running long tasks.
23
+ * **[Run on a cloud service via SkyPilot](#run-on-a-cloud-service-via-skypilot)**: If you have a cloud service (Lambda Labs, GCP, AWS, or Azure) account, you can use SkyPilot to run the app on a cloud service. A cloud bucket can be mounted to preserve your data.
24
+ * **[Run locally](#run-locally)**: Depends on the hardware you have.
25
+
26
+ ### Run On Google Colab
27
+
28
+ Open [this Colab Notebook](https://colab.research.google.com/github/zetavg/LLaMA-LoRA/blob/main/LLaMA_LoRA.ipynb) and select **Runtime > Run All** (`⌘/Ctrl+F9`).
29
+
30
+ You will be prompted to authorize Google Drive access, as Google Drive will be used to store your data. See the "Config"/"Google Drive" section for settings and more info.
31
+
32
+ After approximately 5 minutes of running, you will see the public URL in the output of the "Launch"/"Start Gradio UI πŸš€" section (like `Running on public URL: https://xxxx.gradio.live`). Open the URL in your browser to use the app.
33
+
34
+ ### Run on a cloud service via SkyPilot
35
+
36
+ After following the [installation guide of SkyPilot](https://skypilot.readthedocs.io/en/latest/getting-started/installation.html), create a `.yaml` to define a task for running the app:
37
+
38
+ ```yaml
39
+ # llama-lora-multitool.yaml
40
+
41
+ resources:
42
+ accelerators: A10:1 # 1x NVIDIA A10 GPU
43
+ cloud: lambda # Optional; if left out, SkyPilot will automatically pick the cheapest cloud.
44
+
45
+ file_mounts:
46
+ # Mount a presisted cloud storage that will be used as the data directory.
47
+ # (to store train datasets trained models)
48
+ # See https://skypilot.readthedocs.io/en/latest/reference/storage.html for details.
49
+ /data:
50
+ name: llama-lora-multitool-data # Make sure this name is unique or you own this bucket. If it does not exists, SkyPilot will try to create a bucket with this name.
51
+ store: gcs # Could be either of [s3, gcs]
52
+ mode: MOUNT
53
+
54
+ # Clone the LLaMA-LoRA repo and install its dependencies.
55
+ setup: |
56
+ git clone https://github.com/zetavg/LLaMA-LoRA.git llama_lora
57
+ cd llama_lora && pip install -r requirements.txt
58
+ cd ..
59
+ echo 'Dependencies installed.'
60
+
61
+ # Start the app.
62
+ run: |
63
+ echo 'Starting...'
64
+ python llama_lora/app.py --data_dir='/data' --base_model='decapoda-research/llama-7b-hf' --share
65
+ ```
66
+
67
+ Then launch a cluster to run the task:
68
+
69
+ ```
70
+ sky launch -c llama-lora-multitool llama-lora-multitool.yaml
71
+ ```
72
+
73
+ `-c ...` is an optional flag to specify a cluster name. If not specified, SkyPilot will automatically generate one.
74
+
75
+ You will see the public URL of the app in the terminal. Open the URL in your browser to use the app.
76
+
77
+ Note that exiting `sky launch` will only exit log streaming and will not stop the task. You can use `sky queue --skip-finished` to see the status of running or pending tasks, `sky logs <cluster_name> <job_id>` connect back to log streaming, and `sky cancel <cluster_name> <job_id>` to stop a task.
78
+
79
+ When you are done, run `sky stop <cluster_name>` to stop the cluster. To terminate a cluster instead, run `sky down <cluster_name>`.
80
+
81
+ ### Run locally
82
+
83
+ <details>
84
+ <summary>Prepare environment with conda</summary>
85
+
86
+ ```bash
87
+ conda create -y -n llama-lora-multitool python=3.8
88
+ conda activate llama-lora-multitool
89
+ ```
90
+ </details>
91
+
92
+ ```bash
93
+ pip install -r requirements.txt
94
+ python app.py --data_dir='./data' --base_model='decapoda-research/llama-7b-hf' --share
95
+ ```
96
+
97
+ You will see the local and public URLs of the app in the terminal. Open the URL in your browser to use the app.
98
+
99
+ For more options, see `python app.py --help`.
100
+
101
+ <details>
102
+ <summary>UI development mode</summary>
103
+
104
+ To test the UI without loading the language model, use the `--ui_dev_mode` flag:
105
+
106
+ ```bash
107
+ python app.py --data_dir='./data' --base_model='decapoda-research/llama-7b-hf' --share --ui_dev_mode
108
+ ```
109
+ </details>
110
+
111
+
112
  ## Acknowledgements
113
 
114
  * https://github.com/tloen/alpaca-lora