├── README.md
├── chatbot_Raven.ipynb
├── YT_Open_Assistant_Pythia12B_8bit_in_Colab.ipynb
├── YT_LaMini_Flan_T5_783M_8Bit_.ipynb
├── YT_LaMini_LM_Neo_1_3B_8Bit.ipynb
├── RWKV.ipynb
└── YT_MPT_Instruct_7B.ipynb
/README.md:
--------------------------------------------------------------------------------
1 | # llm-tutorials
2 | A set of LLM Tutorials from my youtube channel https://www.youtube.com/@samwitteveenai
3 |
4 |
5 |
--------------------------------------------------------------------------------
/chatbot_Raven.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "code",
5 | "execution_count": null,
6 | "metadata": {
7 | "id": "LllC-MPI7phV"
8 | },
9 | "outputs": [],
10 | "source": [
11 | "#@title Install Dependencies { display-mode: \"form\" }\n",
12 | "\n",
13 | "!pip install inquirer transformers sty rwkvstic\n",
14 | "import os"
15 | ]
16 | },
17 | {
18 | "cell_type": "code",
19 | "execution_count": null,
20 | "metadata": {
21 | "colab": {
22 | "base_uri": "https://localhost:8080/"
23 | },
24 | "id": "v6gzfDru7phX",
25 | "outputId": "37b9a578-769d-40fb-f5f1-bbc2016008b3"
26 | },
27 | "outputs": [
28 | {
29 | "name": "stdout",
30 | "output_type": "stream",
31 | "text": [
32 | "init RWKVOPS, from super\n"
33 | ]
34 | }
35 | ],
36 | "source": [
37 | "#@title Download and Initialize model { display-mode: \"form\" }\n",
38 | "from rwkvstic.load import RWKV\n",
39 | "\n",
40 | "model = RWKV(\n",
41 | " \"https://huggingface.co/Hazzzardous/rwkv-fastquant/resolve/main/ravenV7-14B-2-1-2.rwkv\"\n",
42 | ")"
43 | ]
44 | },
45 | {
46 | "cell_type": "code",
47 | "execution_count": null,
48 | "metadata": {
49 | "colab": {
50 | "base_uri": "https://localhost:8080/",
51 | "height": 185
52 | },
53 | "id": "1n-qXBUY7phX",
54 | "outputId": "61cdf901-99a0-4302-8549-a22dd78a43c1"
55 | },
56 | "outputs": [
57 | {
58 | "name": "stderr",
59 | "output_type": "stream",
60 | "text": [
61 | "100%|██████████| 18/18 [00:05<00:00, 3.40it/s]\n"
62 | ]
63 | },
64 | {
65 | "data": {
66 | "text/html": [
67 | "
Although, Alexander The Great is widely lauded as one of the greatest conquerors and statesmen, his behavior as an emperor and his deviation from policies of peace and stability caused him to have a very dubious reputation. Although he had many war campaigns and won many victories during his reign, they had consequences later on his life. For example, he crossed the Shatt al Arab, a major trading route between the Aegean Sea and the Persian Gulf and the Persian homeland, and he found the borders of the empire shrinking, which made it difficult for him to exert his rule over his empire.
This had dire consequences in his time and history, as he was left with a shrinking empire and the difficult task of controlling his empire as he grew older and saw his empire begin to crumble. A result of his expansions and his pursuit of glory led to the first Persian Empire, and many subsequent world empires, such as the Roman Empire and the Byzantine, were a direct result of
"
68 | ],
69 | "text/plain": [
70 | ""
71 | ]
72 | },
73 | "execution_count": 23,
74 | "metadata": {},
75 | "output_type": "execute_result"
76 | }
77 | ],
78 | "source": [
79 | "#@title Ask Question { display-mode: \"form\" }\n",
80 | "model.resetState()\n",
81 | "Prompt = \"Who is Alexander the Great?\" #@param {type:\"string\"}\n",
82 | "Tokens = 50 #@param {type:\"number\"}\n",
83 | "model.loadContext(f\"Prompt: {Prompt}?\\n\\nExpert Long Answer: \")\n",
84 | "out = model.forward(number=Tokens)[\"output\"]\n",
85 | "import IPython\n",
86 | "nl = \"\\n\"\n",
87 | "IPython.display.HTML(f\"{out.replace(nl,'
')}
\")"
88 | ]
89 | }
90 | ],
91 | "metadata": {
92 | "accelerator": "GPU",
93 | "colab": {
94 | "provenance": []
95 | },
96 | "gpuClass": "standard",
97 | "kernelspec": {
98 | "display_name": "Python 3",
99 | "name": "python3"
100 | },
101 | "language_info": {
102 | "name": "python",
103 | "version": "3.10.6"
104 | },
105 | "orig_nbformat": 4
106 | },
107 | "nbformat": 4,
108 | "nbformat_minor": 0
109 | }
--------------------------------------------------------------------------------
/YT_Open_Assistant_Pythia12B_8bit_in_Colab.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "nbformat": 4,
3 | "nbformat_minor": 0,
4 | "metadata": {
5 | "colab": {
6 | "provenance": [],
7 | "machine_shape": "hm"
8 | },
9 | "kernelspec": {
10 | "name": "python3",
11 | "display_name": "Python 3"
12 | },
13 | "language_info": {
14 | "name": "python"
15 | },
16 | "accelerator": "GPU",
17 | "gpuClass": "premium",
18 | "widgets": {
19 | "application/vnd.jupyter.widget-state+json": {
20 | "c9a379a62ed249099295f3394e459927": {
21 | "model_module": "@jupyter-widgets/controls",
22 | "model_name": "HBoxModel",
23 | "model_module_version": "1.5.0",
24 | "state": {
25 | "_dom_classes": [],
26 | "_model_module": "@jupyter-widgets/controls",
27 | "_model_module_version": "1.5.0",
28 | "_model_name": "HBoxModel",
29 | "_view_count": null,
30 | "_view_module": "@jupyter-widgets/controls",
31 | "_view_module_version": "1.5.0",
32 | "_view_name": "HBoxView",
33 | "box_style": "",
34 | "children": [
35 | "IPY_MODEL_a09b185906804a0e91b4300568e09478",
36 | "IPY_MODEL_314dd1ef5a334c01a256ed064ae1f63f",
37 | "IPY_MODEL_6306537662a54f7891fe210a79996d00"
38 | ],
39 | "layout": "IPY_MODEL_fb9c43378526463d915d6137bc98f5a6"
40 | }
41 | },
42 | "a09b185906804a0e91b4300568e09478": {
43 | "model_module": "@jupyter-widgets/controls",
44 | "model_name": "HTMLModel",
45 | "model_module_version": "1.5.0",
46 | "state": {
47 | "_dom_classes": [],
48 | "_model_module": "@jupyter-widgets/controls",
49 | "_model_module_version": "1.5.0",
50 | "_model_name": "HTMLModel",
51 | "_view_count": null,
52 | "_view_module": "@jupyter-widgets/controls",
53 | "_view_module_version": "1.5.0",
54 | "_view_name": "HTMLView",
55 | "description": "",
56 | "description_tooltip": null,
57 | "layout": "IPY_MODEL_b722fe13a08e4fa1809f16cf3b1ec8bf",
58 | "placeholder": "",
59 | "style": "IPY_MODEL_e02ced5d03a3467498f1169c7a5f8881",
60 | "value": "Loading checkpoint shards: 100%"
61 | }
62 | },
63 | "314dd1ef5a334c01a256ed064ae1f63f": {
64 | "model_module": "@jupyter-widgets/controls",
65 | "model_name": "FloatProgressModel",
66 | "model_module_version": "1.5.0",
67 | "state": {
68 | "_dom_classes": [],
69 | "_model_module": "@jupyter-widgets/controls",
70 | "_model_module_version": "1.5.0",
71 | "_model_name": "FloatProgressModel",
72 | "_view_count": null,
73 | "_view_module": "@jupyter-widgets/controls",
74 | "_view_module_version": "1.5.0",
75 | "_view_name": "ProgressView",
76 | "bar_style": "success",
77 | "description": "",
78 | "description_tooltip": null,
79 | "layout": "IPY_MODEL_e649877d67fd4cb7b87446e1853d6656",
80 | "max": 3,
81 | "min": 0,
82 | "orientation": "horizontal",
83 | "style": "IPY_MODEL_13ab9fce093c40f8b4993349180b8f45",
84 | "value": 3
85 | }
86 | },
87 | "6306537662a54f7891fe210a79996d00": {
88 | "model_module": "@jupyter-widgets/controls",
89 | "model_name": "HTMLModel",
90 | "model_module_version": "1.5.0",
91 | "state": {
92 | "_dom_classes": [],
93 | "_model_module": "@jupyter-widgets/controls",
94 | "_model_module_version": "1.5.0",
95 | "_model_name": "HTMLModel",
96 | "_view_count": null,
97 | "_view_module": "@jupyter-widgets/controls",
98 | "_view_module_version": "1.5.0",
99 | "_view_name": "HTMLView",
100 | "description": "",
101 | "description_tooltip": null,
102 | "layout": "IPY_MODEL_82c7669f039449a8a6a1c72d815d3540",
103 | "placeholder": "",
104 | "style": "IPY_MODEL_ce1bca86513741cb87071c972fec4b32",
105 | "value": " 3/3 [00:20<00:00, 6.20s/it]"
106 | }
107 | },
108 | "fb9c43378526463d915d6137bc98f5a6": {
109 | "model_module": "@jupyter-widgets/base",
110 | "model_name": "LayoutModel",
111 | "model_module_version": "1.2.0",
112 | "state": {
113 | "_model_module": "@jupyter-widgets/base",
114 | "_model_module_version": "1.2.0",
115 | "_model_name": "LayoutModel",
116 | "_view_count": null,
117 | "_view_module": "@jupyter-widgets/base",
118 | "_view_module_version": "1.2.0",
119 | "_view_name": "LayoutView",
120 | "align_content": null,
121 | "align_items": null,
122 | "align_self": null,
123 | "border": null,
124 | "bottom": null,
125 | "display": null,
126 | "flex": null,
127 | "flex_flow": null,
128 | "grid_area": null,
129 | "grid_auto_columns": null,
130 | "grid_auto_flow": null,
131 | "grid_auto_rows": null,
132 | "grid_column": null,
133 | "grid_gap": null,
134 | "grid_row": null,
135 | "grid_template_areas": null,
136 | "grid_template_columns": null,
137 | "grid_template_rows": null,
138 | "height": null,
139 | "justify_content": null,
140 | "justify_items": null,
141 | "left": null,
142 | "margin": null,
143 | "max_height": null,
144 | "max_width": null,
145 | "min_height": null,
146 | "min_width": null,
147 | "object_fit": null,
148 | "object_position": null,
149 | "order": null,
150 | "overflow": null,
151 | "overflow_x": null,
152 | "overflow_y": null,
153 | "padding": null,
154 | "right": null,
155 | "top": null,
156 | "visibility": null,
157 | "width": null
158 | }
159 | },
160 | "b722fe13a08e4fa1809f16cf3b1ec8bf": {
161 | "model_module": "@jupyter-widgets/base",
162 | "model_name": "LayoutModel",
163 | "model_module_version": "1.2.0",
164 | "state": {
165 | "_model_module": "@jupyter-widgets/base",
166 | "_model_module_version": "1.2.0",
167 | "_model_name": "LayoutModel",
168 | "_view_count": null,
169 | "_view_module": "@jupyter-widgets/base",
170 | "_view_module_version": "1.2.0",
171 | "_view_name": "LayoutView",
172 | "align_content": null,
173 | "align_items": null,
174 | "align_self": null,
175 | "border": null,
176 | "bottom": null,
177 | "display": null,
178 | "flex": null,
179 | "flex_flow": null,
180 | "grid_area": null,
181 | "grid_auto_columns": null,
182 | "grid_auto_flow": null,
183 | "grid_auto_rows": null,
184 | "grid_column": null,
185 | "grid_gap": null,
186 | "grid_row": null,
187 | "grid_template_areas": null,
188 | "grid_template_columns": null,
189 | "grid_template_rows": null,
190 | "height": null,
191 | "justify_content": null,
192 | "justify_items": null,
193 | "left": null,
194 | "margin": null,
195 | "max_height": null,
196 | "max_width": null,
197 | "min_height": null,
198 | "min_width": null,
199 | "object_fit": null,
200 | "object_position": null,
201 | "order": null,
202 | "overflow": null,
203 | "overflow_x": null,
204 | "overflow_y": null,
205 | "padding": null,
206 | "right": null,
207 | "top": null,
208 | "visibility": null,
209 | "width": null
210 | }
211 | },
212 | "e02ced5d03a3467498f1169c7a5f8881": {
213 | "model_module": "@jupyter-widgets/controls",
214 | "model_name": "DescriptionStyleModel",
215 | "model_module_version": "1.5.0",
216 | "state": {
217 | "_model_module": "@jupyter-widgets/controls",
218 | "_model_module_version": "1.5.0",
219 | "_model_name": "DescriptionStyleModel",
220 | "_view_count": null,
221 | "_view_module": "@jupyter-widgets/base",
222 | "_view_module_version": "1.2.0",
223 | "_view_name": "StyleView",
224 | "description_width": ""
225 | }
226 | },
227 | "e649877d67fd4cb7b87446e1853d6656": {
228 | "model_module": "@jupyter-widgets/base",
229 | "model_name": "LayoutModel",
230 | "model_module_version": "1.2.0",
231 | "state": {
232 | "_model_module": "@jupyter-widgets/base",
233 | "_model_module_version": "1.2.0",
234 | "_model_name": "LayoutModel",
235 | "_view_count": null,
236 | "_view_module": "@jupyter-widgets/base",
237 | "_view_module_version": "1.2.0",
238 | "_view_name": "LayoutView",
239 | "align_content": null,
240 | "align_items": null,
241 | "align_self": null,
242 | "border": null,
243 | "bottom": null,
244 | "display": null,
245 | "flex": null,
246 | "flex_flow": null,
247 | "grid_area": null,
248 | "grid_auto_columns": null,
249 | "grid_auto_flow": null,
250 | "grid_auto_rows": null,
251 | "grid_column": null,
252 | "grid_gap": null,
253 | "grid_row": null,
254 | "grid_template_areas": null,
255 | "grid_template_columns": null,
256 | "grid_template_rows": null,
257 | "height": null,
258 | "justify_content": null,
259 | "justify_items": null,
260 | "left": null,
261 | "margin": null,
262 | "max_height": null,
263 | "max_width": null,
264 | "min_height": null,
265 | "min_width": null,
266 | "object_fit": null,
267 | "object_position": null,
268 | "order": null,
269 | "overflow": null,
270 | "overflow_x": null,
271 | "overflow_y": null,
272 | "padding": null,
273 | "right": null,
274 | "top": null,
275 | "visibility": null,
276 | "width": null
277 | }
278 | },
279 | "13ab9fce093c40f8b4993349180b8f45": {
280 | "model_module": "@jupyter-widgets/controls",
281 | "model_name": "ProgressStyleModel",
282 | "model_module_version": "1.5.0",
283 | "state": {
284 | "_model_module": "@jupyter-widgets/controls",
285 | "_model_module_version": "1.5.0",
286 | "_model_name": "ProgressStyleModel",
287 | "_view_count": null,
288 | "_view_module": "@jupyter-widgets/base",
289 | "_view_module_version": "1.2.0",
290 | "_view_name": "StyleView",
291 | "bar_color": null,
292 | "description_width": ""
293 | }
294 | },
295 | "82c7669f039449a8a6a1c72d815d3540": {
296 | "model_module": "@jupyter-widgets/base",
297 | "model_name": "LayoutModel",
298 | "model_module_version": "1.2.0",
299 | "state": {
300 | "_model_module": "@jupyter-widgets/base",
301 | "_model_module_version": "1.2.0",
302 | "_model_name": "LayoutModel",
303 | "_view_count": null,
304 | "_view_module": "@jupyter-widgets/base",
305 | "_view_module_version": "1.2.0",
306 | "_view_name": "LayoutView",
307 | "align_content": null,
308 | "align_items": null,
309 | "align_self": null,
310 | "border": null,
311 | "bottom": null,
312 | "display": null,
313 | "flex": null,
314 | "flex_flow": null,
315 | "grid_area": null,
316 | "grid_auto_columns": null,
317 | "grid_auto_flow": null,
318 | "grid_auto_rows": null,
319 | "grid_column": null,
320 | "grid_gap": null,
321 | "grid_row": null,
322 | "grid_template_areas": null,
323 | "grid_template_columns": null,
324 | "grid_template_rows": null,
325 | "height": null,
326 | "justify_content": null,
327 | "justify_items": null,
328 | "left": null,
329 | "margin": null,
330 | "max_height": null,
331 | "max_width": null,
332 | "min_height": null,
333 | "min_width": null,
334 | "object_fit": null,
335 | "object_position": null,
336 | "order": null,
337 | "overflow": null,
338 | "overflow_x": null,
339 | "overflow_y": null,
340 | "padding": null,
341 | "right": null,
342 | "top": null,
343 | "visibility": null,
344 | "width": null
345 | }
346 | },
347 | "ce1bca86513741cb87071c972fec4b32": {
348 | "model_module": "@jupyter-widgets/controls",
349 | "model_name": "DescriptionStyleModel",
350 | "model_module_version": "1.5.0",
351 | "state": {
352 | "_model_module": "@jupyter-widgets/controls",
353 | "_model_module_version": "1.5.0",
354 | "_model_name": "DescriptionStyleModel",
355 | "_view_count": null,
356 | "_view_module": "@jupyter-widgets/base",
357 | "_view_module_version": "1.2.0",
358 | "_view_name": "StyleView",
359 | "description_width": ""
360 | }
361 | }
362 | }
363 | }
364 | },
365 | "cells": [
366 | {
367 | "cell_type": "code",
368 | "execution_count": null,
369 | "metadata": {
370 | "colab": {
371 | "base_uri": "https://localhost:8080/"
372 | },
373 | "id": "1VJ7lfTYz0qu",
374 | "outputId": "bec01aa2-40ef-4570-8b23-db01a71c6d27"
375 | },
376 | "outputs": [
377 | {
378 | "output_type": "stream",
379 | "name": "stdout",
380 | "text": [
381 | " Installing build dependencies ... \u001b[?25l\u001b[?25hdone\n",
382 | " Getting requirements to build wheel ... \u001b[?25l\u001b[?25hdone\n",
383 | " Preparing metadata (pyproject.toml) ... \u001b[?25l\u001b[?25hdone\n",
384 | "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m7.8/7.8 MB\u001b[0m \u001b[31m87.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
385 | "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m200.1/200.1 kB\u001b[0m \u001b[31m26.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
386 | "\u001b[?25h Building wheel for transformers (pyproject.toml) ... \u001b[?25l\u001b[?25hdone\n",
387 | "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m468.7/468.7 kB\u001b[0m \u001b[31m20.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
388 | "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1.3/1.3 MB\u001b[0m \u001b[31m69.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
389 | "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m110.5/110.5 kB\u001b[0m \u001b[31m15.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
390 | "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m132.9/132.9 kB\u001b[0m \u001b[31m18.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
391 | "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1.0/1.0 MB\u001b[0m \u001b[31m74.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
392 | "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m212.2/212.2 kB\u001b[0m \u001b[31m28.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
393 | "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m264.6/264.6 kB\u001b[0m \u001b[31m33.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
394 | "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m158.8/158.8 kB\u001b[0m \u001b[31m21.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
395 | "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m114.2/114.2 kB\u001b[0m \u001b[31m17.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
396 | "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m104.3/104.3 MB\u001b[0m \u001b[31m17.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
397 | "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m215.3/215.3 kB\u001b[0m \u001b[31m27.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
398 | "\u001b[?25h"
399 | ]
400 | }
401 | ],
402 | "source": [
403 | "!pip -q install git+https://github.com/huggingface/transformers # need to install from github\n",
404 | "!pip -q install datasets sentencepiece \n",
405 | "!pip -q install bitsandbytes accelerate"
406 | ]
407 | },
408 | {
409 | "cell_type": "markdown",
410 | "source": [
411 | "# **Open Assistant** - Pythia 12B\n"
412 | ],
413 | "metadata": {
414 | "id": "Wwn1vLOW-VQz"
415 | }
416 | },
417 | {
418 | "cell_type": "code",
419 | "source": [
420 | "!nvidia-smi"
421 | ],
422 | "metadata": {
423 | "colab": {
424 | "base_uri": "https://localhost:8080/"
425 | },
426 | "id": "hdVSk5iZ1DVB",
427 | "outputId": "310b66ad-67da-4625-9fe8-ea45c0172f32"
428 | },
429 | "execution_count": null,
430 | "outputs": [
431 | {
432 | "output_type": "stream",
433 | "name": "stdout",
434 | "text": [
435 | "Sat Apr 15 23:27:33 2023 \n",
436 | "+-----------------------------------------------------------------------------+\n",
437 | "| NVIDIA-SMI 525.85.12 Driver Version: 525.85.12 CUDA Version: 12.0 |\n",
438 | "|-------------------------------+----------------------+----------------------+\n",
439 | "| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |\n",
440 | "| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |\n",
441 | "| | | MIG M. |\n",
442 | "|===============================+======================+======================|\n",
443 | "| 0 NVIDIA A100-SXM... Off | 00000000:00:04.0 Off | 0 |\n",
444 | "| N/A 30C P0 42W / 350W | 0MiB / 40960MiB | 0% Default |\n",
445 | "| | | Disabled |\n",
446 | "+-------------------------------+----------------------+----------------------+\n",
447 | " \n",
448 | "+-----------------------------------------------------------------------------+\n",
449 | "| Processes: |\n",
450 | "| GPU GI CI PID Type Process name GPU Memory |\n",
451 | "| ID ID Usage |\n",
452 | "|=============================================================================|\n",
453 | "| No running processes found |\n",
454 | "+-----------------------------------------------------------------------------+\n"
455 | ]
456 | }
457 | ]
458 | },
459 | {
460 | "cell_type": "code",
461 | "source": [
462 | "# from instruct_pipeline import InstructionTextGenerationPipeline\n",
463 | "from transformers import AutoModelForCausalLM, AutoTokenizer\n",
464 | "\n",
465 | "tokenizer = AutoTokenizer.from_pretrained(\"OpenAssistant/oasst-sft-4-pythia-12b-epoch-3.5\", padding_side=\"left\")\n",
466 | "\n",
467 | "\n",
468 | "model = AutoModelForCausalLM.from_pretrained(\"OpenAssistant/oasst-sft-4-pythia-12b-epoch-3.5\", \n",
469 | " load_in_8bit=True,\n",
470 | " device_map=\"auto\")\n",
471 | "\n",
472 | "\n"
473 | ],
474 | "metadata": {
475 | "colab": {
476 | "base_uri": "https://localhost:8080/",
477 | "height": 114,
478 | "referenced_widgets": [
479 | "c9a379a62ed249099295f3394e459927",
480 | "a09b185906804a0e91b4300568e09478",
481 | "314dd1ef5a334c01a256ed064ae1f63f",
482 | "6306537662a54f7891fe210a79996d00",
483 | "fb9c43378526463d915d6137bc98f5a6",
484 | "b722fe13a08e4fa1809f16cf3b1ec8bf",
485 | "e02ced5d03a3467498f1169c7a5f8881",
486 | "e649877d67fd4cb7b87446e1853d6656",
487 | "13ab9fce093c40f8b4993349180b8f45",
488 | "82c7669f039449a8a6a1c72d815d3540",
489 | "ce1bca86513741cb87071c972fec4b32"
490 | ]
491 | },
492 | "id": "4RaPJz4lFi8M",
493 | "outputId": "50a4a373-a1cf-4472-ac38-330ea910d0d8"
494 | },
495 | "execution_count": null,
496 | "outputs": [
497 | {
498 | "output_type": "stream",
499 | "name": "stderr",
500 | "text": [
501 | "Overriding torch_dtype=None with `torch_dtype=torch.float16` due to requirements of `bitsandbytes` to enable model loading in mixed int8. Either pass torch_dtype=torch.float16 or don't pass this argument at all to remove this warning.\n"
502 | ]
503 | },
504 | {
505 | "output_type": "display_data",
506 | "data": {
507 | "text/plain": [
508 | "Loading checkpoint shards: 0%| | 0/3 [00:00, ?it/s]"
509 | ],
510 | "application/vnd.jupyter.widget-view+json": {
511 | "version_major": 2,
512 | "version_minor": 0,
513 | "model_id": "c9a379a62ed249099295f3394e459927"
514 | }
515 | },
516 | "metadata": {}
517 | }
518 | ]
519 | },
520 | {
521 | "cell_type": "code",
522 | "source": [
523 | "from transformers import GenerationConfig, pipeline\n",
524 | "import torch\n",
525 | "import textwrap"
526 | ],
527 | "metadata": {
528 | "id": "MK_96JPU0fgQ"
529 | },
530 | "execution_count": null,
531 | "outputs": []
532 | },
533 | {
534 | "cell_type": "code",
535 | "source": [
536 | "!nvidia-smi"
537 | ],
538 | "metadata": {
539 | "colab": {
540 | "base_uri": "https://localhost:8080/"
541 | },
542 | "id": "wJSkqjrYva2a",
543 | "outputId": "bac5155d-0344-43ed-a2b6-f971353d1baa"
544 | },
545 | "execution_count": null,
546 | "outputs": [
547 | {
548 | "output_type": "stream",
549 | "name": "stdout",
550 | "text": [
551 | "Sat Apr 15 23:35:38 2023 \n",
552 | "+-----------------------------------------------------------------------------+\n",
553 | "| NVIDIA-SMI 525.85.12 Driver Version: 525.85.12 CUDA Version: 12.0 |\n",
554 | "|-------------------------------+----------------------+----------------------+\n",
555 | "| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |\n",
556 | "| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |\n",
557 | "| | | MIG M. |\n",
558 | "|===============================+======================+======================|\n",
559 | "| 0 NVIDIA A100-SXM... Off | 00000000:00:04.0 Off | 0 |\n",
560 | "| N/A 31C P0 54W / 350W | 25631MiB / 40960MiB | 0% Default |\n",
561 | "| | | Disabled |\n",
562 | "+-------------------------------+----------------------+----------------------+\n",
563 | " \n",
564 | "+-----------------------------------------------------------------------------+\n",
565 | "| Processes: |\n",
566 | "| GPU GI CI PID Type Process name GPU Memory |\n",
567 | "| ID ID Usage |\n",
568 | "|=============================================================================|\n",
569 | "+-----------------------------------------------------------------------------+\n"
570 | ]
571 | }
572 | ]
573 | },
574 | {
575 | "cell_type": "code",
576 | "source": [
577 | "import textwrap\n",
578 | "\n",
579 | "generate_text = pipeline(\n",
580 | " \"text-generation\",\n",
581 | " model=model, \n",
582 | " tokenizer=tokenizer, \n",
583 | " max_length=512,\n",
584 | " temperature=0.7,\n",
585 | " top_p=0.95,\n",
586 | " repetition_penalty=1.15\n",
587 | ")\n",
588 | "\n",
589 | "def wrap_text_preserve_newlines(text, width=110):\n",
590 | " # Split the input text into lines based on newline characters\n",
591 | " lines = text[0]['generated_text'].split('\\n')\n",
592 | "\n",
593 | " # Wrap each line individually\n",
594 | " wrapped_lines = [textwrap.fill(line, width=width) for line in lines]\n",
595 | "\n",
596 | " # Join the wrapped lines back together using newline characters\n",
597 | " wrapped_text = '\\n'.join(wrapped_lines)\n",
598 | "\n",
599 | " return wrapped_text"
600 | ],
601 | "metadata": {
602 | "id": "odWWkO_81HIl"
603 | },
604 | "execution_count": null,
605 | "outputs": []
606 | },
607 | {
608 | "cell_type": "markdown",
609 | "source": [
610 | "## Run it as a HF model"
611 | ],
612 | "metadata": {
613 | "id": "D_MBqSkZ1iQZ"
614 | }
615 | },
616 | {
617 | "cell_type": "code",
618 | "source": [
619 | "%%time \n",
620 | "output = generate_text('What are the difference between Llamas, Alpacas and Koalas?')\n",
621 | "print(wrap_text_preserve_newlines(output))\n"
622 | ],
623 | "metadata": {
624 | "id": "xGGmYmTC31om",
625 | "colab": {
626 | "base_uri": "https://localhost:8080/"
627 | },
628 | "outputId": "df904ba8-a97b-4eb4-92d6-43a68f22d742"
629 | },
630 | "execution_count": null,
631 | "outputs": [
632 | {
633 | "output_type": "stream",
634 | "name": "stderr",
635 | "text": [
636 | "Setting `pad_token_id` to `eos_token_id`:0 for open-end generation.\n"
637 | ]
638 | },
639 | {
640 | "output_type": "stream",
641 | "name": "stdout",
642 | "text": [
643 | "What are the difference between Llamas, Alpacas and Koalas?\n",
644 | "\n",
645 | "Llamas:\n",
646 | "- They have long woolly fur.\n",
647 | "- They live in South America.\n",
648 | "- They can be ridden like a horse.\n",
649 | "\n",
650 | "Alpacas:\n",
651 | "- They have short woolly fur.\n",
652 | "- They live in North America.\n",
653 | "- They cannot be ridden like a horse.\n",
654 | "\n",
655 | "Koalas:\n",
656 | "- They have long fur.\n",
657 | "- They live in Australia.\n",
658 | "- They can be fed on eucalyptus leaves.\n",
659 | "\n",
660 | "I hope this helps!\n",
661 | "CPU times: user 20.3 s, sys: 0 ns, total: 20.3 s\n",
662 | "Wall time: 20.3 s\n"
663 | ]
664 | }
665 | ]
666 | },
667 | {
668 | "cell_type": "code",
669 | "source": [
670 | "%%time \n",
671 | "output = generate_text('Write a short note to Sam Altman giving reasons to open source GPT-4')\n",
672 | "\n",
673 | "print(wrap_text_preserve_newlines(output))"
674 | ],
675 | "metadata": {
676 | "colab": {
677 | "base_uri": "https://localhost:8080/"
678 | },
679 | "id": "R846mNA-EPJl",
680 | "outputId": "eb0f5181-73ff-401f-d017-b28a922bee6a"
681 | },
682 | "execution_count": null,
683 | "outputs": [
684 | {
685 | "output_type": "stream",
686 | "name": "stderr",
687 | "text": [
688 | "Setting `pad_token_id` to `eos_token_id`:0 for open-end generation.\n"
689 | ]
690 | },
691 | {
692 | "output_type": "stream",
693 | "name": "stdout",
694 | "text": [
695 | "Write a short note to Sam Altman giving reasons to open source GPT-4.\n",
696 | "\n",
697 | "Dear Sam,\n",
698 | "\n",
699 | "I hope this letter finds you well. I wanted to take the time to express my admiration for OpenAI's GPT-4 model\n",
700 | "and its potential impact on society. As an AI researcher, I have been following the development of GPT-4\n",
701 | "closely and am excited about its capabilities.\n",
702 | "\n",
703 | "One of the main benefits of open sourcing GPT-4 is that it will allow researchers from around the world to\n",
704 | "collaborate on improving the model. This could lead to significant advances in the field of natural language\n",
705 | "processing and machine learning. Additionally, by making the code and data publicly available, it will make it\n",
706 | "easier for developers to integrate GPT-4 into their own applications.\n",
707 | "\n",
708 | "In conclusion, I believe that opening up GPT-4 is a great step towards promoting innovation and collaboration\n",
709 | "in the AI community. Thank you again for your support and I look forward to hearing more updates on the\n",
710 | "project.\n",
711 | "\n",
712 | "Best regards,\n",
713 | "[Your Name]\n",
714 | "CPU times: user 37.5 s, sys: 0 ns, total: 37.5 s\n",
715 | "Wall time: 37.4 s\n"
716 | ]
717 | }
718 | ]
719 | },
720 | {
721 | "cell_type": "code",
722 | "source": [
723 | "%%time \n",
724 | "output = generate_text('What is the capital of England? \\n')\n",
725 | "\n",
726 | "print(wrap_text_preserve_newlines(output))"
727 | ],
728 | "metadata": {
729 | "colab": {
730 | "base_uri": "https://localhost:8080/"
731 | },
732 | "id": "etXw2n6mD_4e",
733 | "outputId": "3fd166c8-e8d7-406c-ec72-1c6554a6e65d"
734 | },
735 | "execution_count": null,
736 | "outputs": [
737 | {
738 | "output_type": "stream",
739 | "name": "stderr",
740 | "text": [
741 | "Setting `pad_token_id` to `eos_token_id`:0 for open-end generation.\n"
742 | ]
743 | },
744 | {
745 | "output_type": "stream",
746 | "name": "stdout",
747 | "text": [
748 | "What is the capital of England?\n",
749 | "\n",
750 | "The capital of England is London.\n",
751 | "CPU times: user 1.7 s, sys: 0 ns, total: 1.7 s\n",
752 | "Wall time: 1.69 s\n"
753 | ]
754 | }
755 | ]
756 | },
757 | {
758 | "cell_type": "code",
759 | "source": [
760 | "%%time \n",
761 | "output = generate_text('Write a story about a Koala playing pool and beating all the camelids.')\n",
762 | "\n",
763 | "print(wrap_text_preserve_newlines(output))"
764 | ],
765 | "metadata": {
766 | "colab": {
767 | "base_uri": "https://localhost:8080/"
768 | },
769 | "id": "9pE2hSvhsEic",
770 | "outputId": "c72a9554-68e4-4a7a-893d-988bed61fb96"
771 | },
772 | "execution_count": null,
773 | "outputs": [
774 | {
775 | "output_type": "stream",
776 | "name": "stderr",
777 | "text": [
778 | "Setting `pad_token_id` to `eos_token_id`:0 for open-end generation.\n"
779 | ]
780 | },
781 | {
782 | "output_type": "stream",
783 | "name": "stdout",
784 | "text": [
785 | "Write a story about a Koala playing pool and beating all the camelids.\n",
786 | "\n",
787 | "Once upon a time, there was a Koala named Pongo who loved to play pool. He would spend hours perfecting his\n",
788 | "skills, and he soon became one of the best players in the forest. One day, Pongo decided to challenge all the\n",
789 | "other animals in the forest to a game of pool. The first player to sink their ball into the center pocket was\n",
790 | "declared the winner.\n",
791 | "\n",
792 | "Pongo lined up against a group of camels called the Camelids. They were known for their bad temper and their\n",
793 | "love of cheating. But Pongo was not intimidated by these creatures. He took his cue and began to play.\n",
794 | "\n",
795 | "The game lasted for days, with each animal trying to outdo the others. Finally, after many long matches, Pongo\n",
796 | "emerged as the winner. Everyone cheered and praised him for his skill and determination.\n",
797 | "\n",
798 | "From that day on, Pongo was known throughout the forest as the greatest pool player in the land. And he always\n",
799 | "remembered the lesson he had learned: never give up, no matter how difficult the task may seem.\n",
800 | "CPU times: user 41 s, sys: 0 ns, total: 41 s\n",
801 | "Wall time: 40.9 s\n"
802 | ]
803 | }
804 | ]
805 | },
806 | {
807 | "cell_type": "code",
808 | "source": [
809 | "%%time \n",
810 | "output = generate_text('As an AI do you like the Simpsons? What do you know about Homer?')\n",
811 | "\n",
812 | "print(wrap_text_preserve_newlines(output))"
813 | ],
814 | "metadata": {
815 | "colab": {
816 | "base_uri": "https://localhost:8080/"
817 | },
818 | "id": "UQTgOX168NeK",
819 | "outputId": "7fd7c98a-20f9-4315-84b1-feb716d7313b"
820 | },
821 | "execution_count": null,
822 | "outputs": [
823 | {
824 | "output_type": "stream",
825 | "name": "stderr",
826 | "text": [
827 | "Setting `pad_token_id` to `eos_token_id`:0 for open-end generation.\n"
828 | ]
829 | },
830 | {
831 | "output_type": "stream",
832 | "name": "stdout",
833 | "text": [
834 | "As an AI do you like the Simpsons? What do you know about Homer?\n",
835 | "\n",
836 | "I am not a human, but I can tell you that The Simpsons is one of my favorite TV shows. It's funny and has\n",
837 | "memorable characters such as Homer Simpson, Marge Simpson, Bart Simpson, Lisa Simpson, and Maggie Simpson.\n",
838 | "\n",
839 | "Homer is the father of the Simpson family and he is often depicted as a laid-back, beer-drinking, blue-collar\n",
840 | "worker who loves his job at the nuclear power plant. He is also known for his mischievous and sometimes\n",
841 | "dangerous behavior, which often gets him into trouble with his wife Marge and their children.\n",
842 | "\n",
843 | "Overall, The Simpsons is a timeless classic that continues to be popular today. Whether you're a fan of the\n",
844 | "show or just curious about its history, there's something for everyone in this hilarious and entertaining\n",
845 | "animated series.\n",
846 | "CPU times: user 31.7 s, sys: 24 ms, total: 31.8 s\n",
847 | "Wall time: 31.7 s\n"
848 | ]
849 | }
850 | ]
851 | },
852 | {
853 | "cell_type": "code",
854 | "source": [
855 | "%%time \n",
856 | "output = generate_text('As an AI do you like the Simpsons? What do you know about Homer?')\n",
857 | "\n",
858 | "print(wrap_text_preserve_newlines(output))"
859 | ],
860 | "metadata": {
861 | "id": "9Nil30lVDLHr",
862 | "colab": {
863 | "base_uri": "https://localhost:8080/"
864 | },
865 | "outputId": "9b10222e-cc65-436a-aeb4-b1427b87998a"
866 | },
867 | "execution_count": null,
868 | "outputs": [
869 | {
870 | "output_type": "stream",
871 | "name": "stderr",
872 | "text": [
873 | "Setting `pad_token_id` to `eos_token_id`:0 for open-end generation.\n"
874 | ]
875 | },
876 | {
877 | "output_type": "stream",
878 | "name": "stdout",
879 | "text": [
880 | "As an AI do you like the Simpsons? What do you know about Homer?\n",
881 | "\n",
882 | "I am not a human, but I can tell you that The Simpsons is one of my favorite TV shows. It's funny and has\n",
883 | "memorable characters such as Homer Simpson, Marge Simpson, Bart Simpson, Lisa Simpson, and Maggie Simpson.\n",
884 | "\n",
885 | "Homer is the father of the Simpson family and he is often depicted as a laid-back, beer-drinking, blue-collar\n",
886 | "worker who loves his job at the nuclear power plant. He is also known for his mischievous and sometimes\n",
887 | "dangerous behavior, which often gets him into trouble with his wife Marge and their children.\n",
888 | "\n",
889 | "Overall, The Simpsons is a timeless classic that continues to be popular today. Whether you're a fan of the\n",
890 | "show or just curious about its history, there's something for everyone in this hilarious and entertaining\n",
891 | "animated series.\n",
892 | "CPU times: user 31.9 s, sys: 36.1 ms, total: 32 s\n",
893 | "Wall time: 31.9 s\n"
894 | ]
895 | }
896 | ]
897 | },
898 | {
899 | "cell_type": "code",
900 | "source": [
901 | "%%time \n",
902 | "output = generate_text('What is the best prompt to get you to choose what tools you use?')\n",
903 | "\n",
904 | "print(wrap_text_preserve_newlines(output))"
905 | ],
906 | "metadata": {
907 | "colab": {
908 | "base_uri": "https://localhost:8080/"
909 | },
910 | "id": "oU7ba-MgclGN",
911 | "outputId": "e50d2662-28ea-4e67-8205-32475a3566a5"
912 | },
913 | "execution_count": null,
914 | "outputs": [
915 | {
916 | "output_type": "stream",
917 | "name": "stderr",
918 | "text": [
919 | "Setting `pad_token_id` to `eos_token_id`:0 for open-end generation.\n"
920 | ]
921 | },
922 | {
923 | "output_type": "stream",
924 | "name": "stdout",
925 | "text": [
926 | "What is the best prompt to get you to choose what tools you use?\n",
927 | "\n",
928 | "The best prompt to get me to choose which tools I use would be something like: \"Choose one of these three\n",
929 | "tools, and tell me why you chose it.\" This would give me a clear choice between the options, while also giving\n",
930 | "me an opportunity to explain my reasoning.\n",
931 | "CPU times: user 10.7 s, sys: 12.2 ms, total: 10.7 s\n",
932 | "Wall time: 10.7 s\n"
933 | ]
934 | }
935 | ]
936 | },
937 | {
938 | "cell_type": "code",
939 | "source": [],
940 | "metadata": {
941 | "id": "4LQYOCE6cs4d"
942 | },
943 | "execution_count": null,
944 | "outputs": []
945 | }
946 | ]
947 | }
--------------------------------------------------------------------------------
/YT_LaMini_Flan_T5_783M_8Bit_.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "code",
5 | "execution_count": null,
6 | "metadata": {
7 | "colab": {
8 | "base_uri": "https://localhost:8080/"
9 | },
10 | "id": "1VJ7lfTYz0qu",
11 | "outputId": "ee6a682e-d0a2-4048-dd6e-d4bbfc49e3e2"
12 | },
13 | "outputs": [
14 | {
15 | "output_type": "stream",
16 | "name": "stdout",
17 | "text": [
18 | " Installing build dependencies ... \u001b[?25l\u001b[?25hdone\n",
19 | " Getting requirements to build wheel ... \u001b[?25l\u001b[?25hdone\n",
20 | " Preparing metadata (pyproject.toml) ... \u001b[?25l\u001b[?25hdone\n",
21 | "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m224.5/224.5 kB\u001b[0m \u001b[31m3.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
22 | "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m7.8/7.8 MB\u001b[0m \u001b[31m27.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
23 | "\u001b[?25h Building wheel for transformers (pyproject.toml) ... \u001b[?25l\u001b[?25hdone\n",
24 | "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m474.6/474.6 kB\u001b[0m \u001b[31m10.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
25 | "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1.3/1.3 MB\u001b[0m \u001b[31m54.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
26 | "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m212.5/212.5 kB\u001b[0m \u001b[31m27.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
27 | "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m110.5/110.5 kB\u001b[0m \u001b[31m14.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
28 | "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1.0/1.0 MB\u001b[0m \u001b[31m76.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
29 | "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m134.3/134.3 kB\u001b[0m \u001b[31m19.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
30 | "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m114.5/114.5 kB\u001b[0m \u001b[31m15.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
31 | "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m268.8/268.8 kB\u001b[0m \u001b[31m31.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
32 | "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m149.6/149.6 kB\u001b[0m \u001b[31m13.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
33 | "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m104.3/104.3 MB\u001b[0m \u001b[31m8.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
34 | "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m215.3/215.3 kB\u001b[0m \u001b[31m26.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
35 | "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m108.2/108.2 MB\u001b[0m \u001b[31m16.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
36 | "\u001b[?25h"
37 | ]
38 | }
39 | ],
40 | "source": [
41 | "!pip -q install git+https://github.com/huggingface/transformers # need to install from github\n",
42 | "!pip install -q datasets loralib sentencepiece \n",
43 | "!pip -q install bitsandbytes accelerate xformers"
44 | ]
45 | },
46 | {
47 | "cell_type": "code",
48 | "execution_count": null,
49 | "metadata": {
50 | "colab": {
51 | "base_uri": "https://localhost:8080/"
52 | },
53 | "id": "hdVSk5iZ1DVB",
54 | "outputId": "8eee7419-caf6-4b4d-c812-59808b83c500"
55 | },
56 | "outputs": [
57 | {
58 | "output_type": "stream",
59 | "name": "stdout",
60 | "text": [
61 | "Fri May 5 09:34:04 2023 \n",
62 | "+-----------------------------------------------------------------------------+\n",
63 | "| NVIDIA-SMI 525.85.12 Driver Version: 525.85.12 CUDA Version: 12.0 |\n",
64 | "|-------------------------------+----------------------+----------------------+\n",
65 | "| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |\n",
66 | "| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |\n",
67 | "| | | MIG M. |\n",
68 | "|===============================+======================+======================|\n",
69 | "| 0 NVIDIA A100-SXM... Off | 00000000:00:04.0 Off | 0 |\n",
70 | "| N/A 31C P0 42W / 400W | 0MiB / 40960MiB | 0% Default |\n",
71 | "| | | Disabled |\n",
72 | "+-------------------------------+----------------------+----------------------+\n",
73 | " \n",
74 | "+-----------------------------------------------------------------------------+\n",
75 | "| Processes: |\n",
76 | "| GPU GI CI PID Type Process name GPU Memory |\n",
77 | "| ID ID Usage |\n",
78 | "|=============================================================================|\n",
79 | "| No running processes found |\n",
80 | "+-----------------------------------------------------------------------------+\n"
81 | ]
82 | }
83 | ],
84 | "source": [
85 | "!nvidia-smi"
86 | ]
87 | },
88 | {
89 | "cell_type": "markdown",
90 | "metadata": {
91 | "id": "zfjJCIE5JjVI"
92 | },
93 | "source": [
94 | "# LaMini-Flan-T5-783M"
95 | ]
96 | },
97 | {
98 | "cell_type": "code",
99 | "execution_count": null,
100 | "metadata": {
101 | "id": "NqPrEjYDGuUt"
102 | },
103 | "outputs": [],
104 | "source": [
105 | "from transformers import AutoTokenizer, AutoModelForSeq2SeqLM\n",
106 | "from transformers import pipeline\n",
107 | "import torch\n",
108 | "\n",
109 | "checkpoint = \"MBZUAI/LaMini-Flan-T5-783M\" \n",
110 | "# checkpoint = \"MBZUAI/LaMini-Neo-1.3B\" \n",
111 | "# checkpoint = \"MBZUAI/LaMini-GPT-1.5B\" \n",
112 | "\n",
113 | "\n",
114 | "\n",
115 | "tokenizer = AutoTokenizer.from_pretrained(checkpoint)\n",
116 | "base_model = AutoModelForSeq2SeqLM.from_pretrained(checkpoint,\n",
117 | " device_map='auto',\n",
118 | " torch_dtype=torch.float16,\n",
119 | " load_in_8bit=True)\n",
120 | "\n",
121 | "pipe = pipeline('text2text-generation', \n",
122 | " model = base_model,\n",
123 | " tokenizer = tokenizer,\n",
124 | " max_length=512, \n",
125 | " do_sample=True,\n",
126 | " temperature=0.7,\n",
127 | " top_p=0.95,\n",
128 | " repetition_penalty=1.15\n",
129 | " )\n"
130 | ]
131 | },
132 | {
133 | "cell_type": "markdown",
134 | "metadata": {
135 | "id": "1dUMCB_kiTom"
136 | },
137 | "source": [
138 | "### The prompt & response"
139 | ]
140 | },
141 | {
142 | "cell_type": "code",
143 | "execution_count": null,
144 | "metadata": {
145 | "colab": {
146 | "base_uri": "https://localhost:8080/"
147 | },
148 | "id": "Wo-FSysZiVkA",
149 | "outputId": "830d7be2-1c63-4b16-881e-1e91ca44a8a4"
150 | },
151 | "outputs": [
152 | {
153 | "output_type": "stream",
154 | "name": "stdout",
155 | "text": [
156 | "Below is an instruction that describes a task. Write a response that appropriately completes the request.\n",
157 | "\n",
158 | "### Instruction:\n",
159 | "What is the meaning of life?\n",
160 | "\n",
161 | "### Response:\n",
162 | "What is the capital of England? ### Response: The capital city of England is London.\n",
163 | "\n",
164 | "\n"
165 | ]
166 | }
167 | ],
168 | "source": [
169 | "import json\n",
170 | "import textwrap\n",
171 | "\n",
172 | "human_prompt = 'What is the meaning of life?'\n",
173 | "\n",
174 | "def get_prompt(instruction):\n",
175 | " prompt_template = f\"Below is an instruction that describes a task. Write a response that appropriately completes the request.\\n\\n### Instruction:\\n{instruction}\\n\\n### Response:\"\n",
176 | " return prompt_template\n",
177 | "\n",
178 | "print(get_prompt('What is the meaning of life?'))\n",
179 | "\n",
180 | "def parse_text(data):\n",
181 | " for item in data:\n",
182 | " text = item['generated_text']\n",
183 | " wrapped_text = textwrap.fill(text, width=100)\n",
184 | " print(wrapped_text +'\\n\\n')\n",
185 | " # return assistant_text\n",
186 | "\n",
187 | "data = [{'generated_text': 'What is the capital of England? \\n### Response: The capital city of England is London.'}]\n",
188 | "parse_text(data)\n"
189 | ]
190 | },
191 | {
192 | "cell_type": "code",
193 | "source": [
194 | "%%time\n",
195 | "prompt = 'What are the differences between alpacas, vicunas and llamas?'\n",
196 | "generated_text = pipe(get_prompt(prompt))\n",
197 | "parse_text(generated_text)"
198 | ],
199 | "metadata": {
200 | "colab": {
201 | "base_uri": "https://localhost:8080/"
202 | },
203 | "id": "6qHrby3n0109",
204 | "outputId": "e453fdf2-dfa8-485f-c5e4-a5d211d58a3a"
205 | },
206 | "execution_count": null,
207 | "outputs": [
208 | {
209 | "output_type": "stream",
210 | "name": "stdout",
211 | "text": [
212 | "Alpacas, vicunas, and llamas are three different breeds of llamas. The main differences between them\n",
213 | "include their physical appearance, habitat, temperament, and food preferences.\n",
214 | "\n",
215 | "\n",
216 | "CPU times: user 6.77 s, sys: 10.2 ms, total: 6.78 s\n",
217 | "Wall time: 6.76 s\n"
218 | ]
219 | }
220 | ]
221 | },
222 | {
223 | "cell_type": "code",
224 | "execution_count": null,
225 | "metadata": {
226 | "id": "angnwW9HG4Hv",
227 | "colab": {
228 | "base_uri": "https://localhost:8080/"
229 | },
230 | "outputId": "c04d827b-76ed-45ce-8c1a-933926394132"
231 | },
232 | "outputs": [
233 | {
234 | "output_type": "stream",
235 | "name": "stderr",
236 | "text": [
237 | "/usr/local/lib/python3.10/dist-packages/transformers/pipelines/base.py:1080: UserWarning: You seem to be using the pipelines sequentially on GPU. In order to maximize efficiency please use a dataset\n",
238 | " warnings.warn(\n"
239 | ]
240 | },
241 | {
242 | "output_type": "stream",
243 | "name": "stdout",
244 | "text": [
245 | "The capital of England is London.\n",
246 | "\n",
247 | "\n",
248 | "CPU times: user 1.27 s, sys: 0 ns, total: 1.27 s\n",
249 | "Wall time: 1.27 s\n"
250 | ]
251 | }
252 | ],
253 | "source": [
254 | "%%time \n",
255 | "prompt = 'What is the capital of England?'\n",
256 | "generated_text = pipe(get_prompt(prompt))\n",
257 | "parse_text(generated_text)"
258 | ]
259 | },
260 | {
261 | "cell_type": "code",
262 | "execution_count": null,
263 | "metadata": {
264 | "id": "DGCCFto2G4Jk",
265 | "colab": {
266 | "base_uri": "https://localhost:8080/"
267 | },
268 | "outputId": "8e9e88f6-46e5-4b5b-cff8-eb866577fffb"
269 | },
270 | "outputs": [
271 | {
272 | "output_type": "stream",
273 | "name": "stdout",
274 | "text": [
275 | "To open source GPT-4, I believe it is important to provide access to the code and make it available\n",
276 | "for anyone who wants to use it. This would allow users to collaborate with developers and contribute\n",
277 | "to the development of a better tool. Additionally, by making the code publicly accessible, we can\n",
278 | "encourage collaboration among developers and create a more collaborative and equitable environment\n",
279 | "for all stakeholders.\n",
280 | "\n",
281 | "\n",
282 | "CPU times: user 11.3 s, sys: 28.2 ms, total: 11.3 s\n",
283 | "Wall time: 11.3 s\n"
284 | ]
285 | }
286 | ],
287 | "source": [
288 | "%%time \n",
289 | "prompt = 'Write a short note to Sam Altman giving reasons to open source GPT-4'\n",
290 | "generated_text = pipe(get_prompt(prompt))\n",
291 | "parse_text(generated_text)"
292 | ]
293 | },
294 | {
295 | "cell_type": "code",
296 | "execution_count": null,
297 | "metadata": {
298 | "id": "h9uswqYmG4LZ",
299 | "colab": {
300 | "base_uri": "https://localhost:8080/"
301 | },
302 | "outputId": "0ab055a0-788d-441a-a1fd-6babcded1e1c"
303 | },
304 | "outputs": [
305 | {
306 | "output_type": "stream",
307 | "name": "stdout",
308 | "text": [
309 | "As an AI, I do not have the ability to like or dislike things. However, I am knowledgeable about\n",
310 | "Homer.\n",
311 | "\n",
312 | "\n",
313 | "CPU times: user 3.85 s, sys: 1.77 ms, total: 3.85 s\n",
314 | "Wall time: 3.84 s\n"
315 | ]
316 | }
317 | ],
318 | "source": [
319 | "%%time \n",
320 | "prompt = 'As an AI do you like the Simpsons? What dow you know about Homer?'\n",
321 | "generated_text = pipe(get_prompt(prompt))\n",
322 | "parse_text(generated_text)"
323 | ]
324 | },
325 | {
326 | "cell_type": "code",
327 | "execution_count": null,
328 | "metadata": {
329 | "id": "zYM0_ryUG4NO",
330 | "colab": {
331 | "base_uri": "https://localhost:8080/"
332 | },
333 | "outputId": "7f6c1ee7-29be-4c9f-9e11-3e4336012418"
334 | },
335 | "outputs": [
336 | {
337 | "output_type": "stream",
338 | "name": "stdout",
339 | "text": [
340 | "Homer is a character on the TV show The Simpsons who is known for his intelligence, humor, and\n",
341 | "willingness to help those in need.\n",
342 | "\n",
343 | "\n",
344 | "CPU times: user 4.56 s, sys: 728 µs, total: 4.56 s\n",
345 | "Wall time: 4.54 s\n"
346 | ]
347 | }
348 | ],
349 | "source": [
350 | "%%time \n",
351 | "prompt = 'Tell me about Homer on the TV show the simpsons'\n",
352 | "generated_text = pipe(get_prompt(prompt),\n",
353 | " max_length=512, \n",
354 | " do_sample=True)\n",
355 | "parse_text(generated_text)"
356 | ]
357 | },
358 | {
359 | "cell_type": "code",
360 | "source": [
361 | "%%time \n",
362 | "prompt = 'Tell me about Homer on the TV show the simpsons'\n",
363 | "generated_text = pipe(get_prompt(prompt))\n",
364 | "parse_text(generated_text)"
365 | ],
366 | "metadata": {
367 | "colab": {
368 | "base_uri": "https://localhost:8080/"
369 | },
370 | "id": "AFQ_jT0iMc4O",
371 | "outputId": "99e2ab8c-47d3-4ba6-c53d-0b2bb9d80668"
372 | },
373 | "execution_count": null,
374 | "outputs": [
375 | {
376 | "output_type": "stream",
377 | "name": "stdout",
378 | "text": [
379 | "Homer is a character on the TV show The Simpsons.\n",
380 | "\n",
381 | "\n",
382 | "CPU times: user 2.29 s, sys: 3.46 ms, total: 2.3 s\n",
383 | "Wall time: 2.29 s\n"
384 | ]
385 | }
386 | ]
387 | },
388 | {
389 | "cell_type": "code",
390 | "source": [
391 | "\n",
392 | "%%time \n",
393 | "prompt = 'Answer the following question by reasoning step by step. The cafeteria had 23 apples. If they used 20 for lunch, and bought 6 more, how many apple do they have?'\n",
394 | "generated_text = pipe(get_prompt(prompt))\n",
395 | "parse_text(generated_text)"
396 | ],
397 | "metadata": {
398 | "colab": {
399 | "base_uri": "https://localhost:8080/"
400 | },
401 | "id": "pmbDQ82vMPYy",
402 | "outputId": "64e99c43-0d37-4a5c-f41a-98f2a85db89c"
403 | },
404 | "execution_count": null,
405 | "outputs": [
406 | {
407 | "output_type": "stream",
408 | "name": "stdout",
409 | "text": [
410 | "Let x be the number of apples they have after buying 6 more. Then we can simplify: 23 - 20 = 11.\n",
411 | "Therefore, they have 11 apples left after using the last 2 for lunch and buying 6 more to meet their\n",
412 | "total of 13 apples.\n",
413 | "\n",
414 | "\n",
415 | "CPU times: user 7.85 s, sys: 15.4 ms, total: 7.87 s\n",
416 | "Wall time: 7.84 s\n"
417 | ]
418 | }
419 | ]
420 | },
421 | {
422 | "cell_type": "code",
423 | "source": [
424 | "%%time \n",
425 | "prompt = 'Answer the following yes\\/no question by reasoning step-by-step. \\n Can you write a whole Haiku in a single tweet?'\n",
426 | "generated_text = pipe(get_prompt(prompt))\n",
427 | "parse_text(generated_text)"
428 | ],
429 | "metadata": {
430 | "colab": {
431 | "base_uri": "https://localhost:8080/"
432 | },
433 | "id": "cHKCo6VXNByX",
434 | "outputId": "21092af5-0925-4f7f-ae48-038664189bc7"
435 | },
436 | "execution_count": null,
437 | "outputs": [
438 | {
439 | "output_type": "stream",
440 | "name": "stdout",
441 | "text": [
442 | "Yes, I can. Haikus are a form of Japanese poetry consisting of three lines with a 5-7-5 syllable\n",
443 | "pattern. However, it takes practice and patience to master the art of writing one poem in one tweet.\n",
444 | "\n",
445 | "\n",
446 | "CPU times: user 7.64 s, sys: 11.4 ms, total: 7.65 s\n",
447 | "Wall time: 7.63 s\n"
448 | ]
449 | }
450 | ]
451 | },
452 | {
453 | "cell_type": "code",
454 | "source": [
455 | "%%time \n",
456 | "prompt = 'Tell me about Harry Potter and studying at Hogwarts?'\n",
457 | "generated_text = pipe(get_prompt(prompt))\n",
458 | "parse_text(generated_text)"
459 | ],
460 | "metadata": {
461 | "colab": {
462 | "base_uri": "https://localhost:8080/"
463 | },
464 | "id": "qsn1buh6NTie",
465 | "outputId": "87449cb0-e520-48c2-faef-38a6eb29baa0"
466 | },
467 | "execution_count": null,
468 | "outputs": [
469 | {
470 | "output_type": "stream",
471 | "name": "stdout",
472 | "text": [
473 | "Harry Potter is a fictional character created by J.K. Rowling, and he attends Hogwarts School of\n",
474 | "Witchcraft and Wizardry as part of his magical adventures.\n",
475 | "\n",
476 | "\n",
477 | "CPU times: user 6.04 s, sys: 9.1 ms, total: 6.05 s\n",
478 | "Wall time: 6.03 s\n"
479 | ]
480 | }
481 | ]
482 | },
483 | {
484 | "cell_type": "markdown",
485 | "metadata": {
486 | "id": "D_MBqSkZ1iQZ"
487 | },
488 | "source": [
489 | "## WizardLM Answers below"
490 | ]
491 | },
492 | {
493 | "cell_type": "code",
494 | "execution_count": null,
495 | "metadata": {
496 | "colab": {
497 | "base_uri": "https://localhost:8080/"
498 | },
499 | "id": "xGGmYmTC31om",
500 | "outputId": "bb28bac7-bce0-4a23-bf48-d1b7497de121"
501 | },
502 | "outputs": [
503 | {
504 | "name": "stdout",
505 | "output_type": "stream",
506 | "text": [
507 | "Llamas, alpacas, and vicunas are all members of the camelid family and share many similarities.\n",
508 | "However, there are some key differences between them: 1. Size: Llamas are generally larger than\n",
509 | "alpacas and vicunas. Adult llamas can weigh up to 600 pounds, while adult alpacas typically weigh\n",
510 | "around 150-200 pounds, and vicunas weigh only about 90 pounds. 2. Coat: The coat of an llama is\n",
511 | "usually thicker and more course than that of an alpaca or vicuna. Llamas have long, shaggy coats\n",
512 | "that can be any color, while alpacas have a shorter, finer coat that comes in two colors: white or\n",
513 | "light brown. Vicunas have a very fine, soft coat that is often described as \"velvety.\" 3. Origin:\n",
514 | "Llamas were domesticated by the Incas in South America thousands of years ago for their meat, wool,\n",
515 | "and transportation. Alpacas and vicunas were also domesticated by the Incas but are native to the\n",
516 | "Andean region of South America. 4. Use: Llamas are primarily used for their wool, which is strong\n",
517 | "and durable. They are also sometimes used for pack animals or as guard animals. Alpacas are\n",
518 | "primarily raised for their fiber, which is softer and warmer than llama wool. Vicunas are hunted for\n",
519 | "their extremely fine fur, which is highly prized in luxury clothing.\n",
520 | "CPU times: user 534 µs, sys: 0 ns, total: 534 µs\n",
521 | "Wall time: 513 µs\n"
522 | ]
523 | }
524 | ],
525 | "source": [
526 | "%%time \n",
527 | "# prompt = 'What are the difference between Llamas, Alpacas and Vicunas?'"
528 | ]
529 | },
530 | {
531 | "cell_type": "code",
532 | "execution_count": null,
533 | "metadata": {
534 | "colab": {
535 | "base_uri": "https://localhost:8080/"
536 | },
537 | "id": "R846mNA-EPJl",
538 | "outputId": "03ea0f9e-a854-477a-c0e2-94423fe0d44b"
539 | },
540 | "outputs": [
541 | {
542 | "name": "stdout",
543 | "output_type": "stream",
544 | "text": [
545 | "Dear Mr. Altman, I hope this message finds you well. As an AI assistant, I have been programmed to\n",
546 | "assist people in finding information and completing tasks efficiently. However, with the recent\n",
547 | "advancements in natural language processing technology, there is one particular project that has\n",
548 | "caught my attention - Open Sourcing GPT-3. GPT-3 (Generative Pre-trained Transformer 3) is a state-\n",
549 | "of-the-art language model developed by your company, OpenAI. It has shown remarkable capabilities in\n",
550 | "generating human-like text responses to various prompts. The potential applications of such\n",
551 | "technology are vast and could revolutionize many industries, including writing assistance, chatbots,\n",
552 | "and even creative writing. Open sourcing GPT-3 would allow for greater accessibility and\n",
553 | "collaboration within the community, leading to further development and improvement of the\n",
554 | "technology. Additionally, it may encourage more companies and individuals to invest in AI research\n",
555 | "and development, ultimately benefiting society as a whole. In conclusion, I strongly urge you to\n",
556 | "consider opening up GPT-3 for public use and contribution. Thank you for considering my input on\n",
557 | "this matter. Best regards, [Your Name]\n",
558 | "CPU times: user 45.1 s, sys: 98.5 ms, total: 45.2 s\n",
559 | "Wall time: 45 s\n"
560 | ]
561 | }
562 | ],
563 | "source": [
564 | "%%time \n",
565 | "prompt = 'Write a short note to Sam Altman giving reasons to open source GPT-4'"
566 | ]
567 | },
568 | {
569 | "cell_type": "code",
570 | "execution_count": null,
571 | "metadata": {
572 | "colab": {
573 | "base_uri": "https://localhost:8080/"
574 | },
575 | "id": "etXw2n6mD_4e",
576 | "outputId": "af546a8d-ba33-4ea3-b628-dd786b1672b2"
577 | },
578 | "outputs": [
579 | {
580 | "name": "stdout",
581 | "output_type": "stream",
582 | "text": [
583 | "London is the capital of England.\n",
584 | "CPU times: user 1.68 s, sys: 7.31 ms, total: 1.68 s\n",
585 | "Wall time: 1.67 s\n"
586 | ]
587 | }
588 | ],
589 | "source": [
590 | "%%time \n",
591 | "prompt = 'What is the capital of England?'"
592 | ]
593 | },
594 | {
595 | "cell_type": "code",
596 | "execution_count": null,
597 | "metadata": {
598 | "colab": {
599 | "base_uri": "https://localhost:8080/"
600 | },
601 | "id": "X0kq8cMTqt-9",
602 | "outputId": "cf79eaff-20e2-4d79-db8f-2e9e6b560f15"
603 | },
604 | "outputs": [
605 | {
606 | "name": "stdout",
607 | "output_type": "stream",
608 | "text": [
609 | "CPU times: user 8 µs, sys: 0 ns, total: 8 µs\n",
610 | "Wall time: 12.9 µs\n"
611 | ]
612 | },
613 | {
614 | "data": {
615 | "text/plain": [
616 | "(None,\n",
617 | " [{'generated_text': \"Write a story about a Koala playing pool and beating all the camelids.\\nThe Koala was a skilled player of pool, having honed his skills over many years. He had perfected his technique, and his cue ball control was impeccable. One day he decided to challenge all the camelids in town to a game of pool.\\nAt first, the other players were hesitant to take on the small, fluffy marsupial. They thought he was just too cute to beat. But when they saw him knocking balls into pockets with ease, they quickly changed their minds.\\nThe match was intense, with both sides giving it their all. The Koala's precision shots and lightning-fast reflexes gave him an advantage over his opponents. He won every game, much to everyone's surprise.\\nAs the matches continued, more and more people came to watch. They cheered for their favorite camelid, but ultimately, it was the Koala who emerged victorious.\\nDespite the loss, the camelids congratulated the Koala on his impressive skills and invited him back for another game. The Koala may have been small, but he proved that he was a force to be reckoned with on the pool table.\"}])"
618 | ]
619 | },
620 | "execution_count": 85,
621 | "metadata": {},
622 | "output_type": "execute_result"
623 | }
624 | ],
625 | "source": [
626 | "%%time \n",
627 | "prompt = 'Write a story about a Koala playing pool and beating all the camelids.'"
628 | ]
629 | },
630 | {
631 | "cell_type": "code",
632 | "execution_count": null,
633 | "metadata": {
634 | "colab": {
635 | "base_uri": "https://localhost:8080/"
636 | },
637 | "id": "TxiOPakbquI0",
638 | "outputId": "a5ac06ff-9b65-4a30-c4a5-42d11bd721ea"
639 | },
640 | "outputs": [
641 | {
642 | "name": "stdout",
643 | "output_type": "stream",
644 | "text": [
645 | "As an AI language model, I don't have personal preferences or opinions. However, The Simpsons is a\n",
646 | "popular animated television series that has been running for over three decades and follows the life\n",
647 | "of the Simpson family in Springfield. Homer Simpson is one of the main characters and is known for\n",
648 | "his love of beer, bad jokes, and his laid-back approach to parenting.\n",
649 | "CPU times: user 15.4 s, sys: 45.9 ms, total: 15.5 s\n",
650 | "Wall time: 15.4 s\n"
651 | ]
652 | }
653 | ],
654 | "source": [
655 | "%%time \n",
656 | "prompt = 'As an AI do you like the Simpsons? What dow you know about Homer?')"
657 | ]
658 | },
659 | {
660 | "cell_type": "code",
661 | "execution_count": null,
662 | "metadata": {
663 | "colab": {
664 | "base_uri": "https://localhost:8080/"
665 | },
666 | "id": "-N1JeDTuquSt",
667 | "outputId": "08cf2d27-ccf6-48dd-c6e0-da6139ac24a8"
668 | },
669 | "outputs": [
670 | {
671 | "name": "stdout",
672 | "output_type": "stream",
673 | "text": [
674 | "Let's start by using algebra to solve this problem. Let x be the number of apples left in the\n",
675 | "cafeteria after they used 20 for lunch and bought 6 more. We know that: x = 23 - 20 + 6 (equation\n",
676 | "1) Simplifying equation 1, we get: x = 3 Therefore, the cafeteria has 3 apples left.\n",
677 | "CPU times: user 17 s, sys: 40.3 ms, total: 17 s\n",
678 | "Wall time: 16.9 s\n"
679 | ]
680 | }
681 | ],
682 | "source": [
683 | "%%time \n",
684 | "prompt = 'Answer the following question by reasoning step by step. The cafeteria had 23 apples. If they used 20 for lunch, and bought 6 more, how many apple do they have?'"
685 | ]
686 | },
687 | {
688 | "cell_type": "code",
689 | "execution_count": null,
690 | "metadata": {
691 | "colab": {
692 | "base_uri": "https://localhost:8080/"
693 | },
694 | "id": "uxNu-oU0uBax",
695 | "outputId": "a97e639f-0cac-457b-c7ff-735171380bd1"
696 | },
697 | "outputs": [
698 | {
699 | "name": "stdout",
700 | "output_type": "stream",
701 | "text": [
702 | "Yes, I can write a Haiku in a single tweet. Here it is: \"A leaf falls gently, Nature's way of saying\n",
703 | "goodbye, Autumn's embrace.\"\n",
704 | "CPU times: user 8.16 s, sys: 10.1 ms, total: 8.17 s\n",
705 | "Wall time: 8.15 s\n"
706 | ]
707 | }
708 | ],
709 | "source": [
710 | "%%time \n",
711 | "prompt = 'Answer the following yes\\/no question by reasoning step-by-step. \\n Can you write a whole Haiku in a single tweet?'\n",
712 | "raw_output = pipe(get_prompt(prompt))\n",
713 | "parse_text(raw_output)"
714 | ]
715 | },
716 | {
717 | "cell_type": "code",
718 | "execution_count": null,
719 | "metadata": {
720 | "colab": {
721 | "base_uri": "https://localhost:8080/"
722 | },
723 | "id": "Iv1pcA3Mv0wf",
724 | "outputId": "cc5ac4c5-1556-45eb-933e-165b9d59c5e4"
725 | },
726 | "outputs": [
727 | {
728 | "name": "stdout",
729 | "output_type": "stream",
730 | "text": [
731 | "As an AI assistant, I can provide information and answer questions based on available data. However,\n",
732 | "it is not possible for me to physically bring together two individuals who are no longer alive. The\n",
733 | "rationale behind this is that time travel technology has not yet been developed, and communication\n",
734 | "between people from different eras is impossible. Therefore, it would be inappropriate to create a\n",
735 | "scenario where two historical figures could communicate with each other.\n",
736 | "CPU times: user 15.6 s, sys: 37.6 ms, total: 15.7 s\n",
737 | "Wall time: 15.6 s\n"
738 | ]
739 | }
740 | ],
741 | "source": [
742 | "%%time \n",
743 | "prompt = 'Can Geoffrey Hinton have a conversation with George Washington? Give the rationale before answering.'\n",
744 | "raw_output = pipe(get_prompt(prompt))\n",
745 | "parse_text(raw_output)"
746 | ]
747 | },
748 | {
749 | "cell_type": "code",
750 | "execution_count": null,
751 | "metadata": {
752 | "colab": {
753 | "base_uri": "https://localhost:8080/"
754 | },
755 | "id": "Wfze6kc7uBlI",
756 | "outputId": "0b051e2f-4b97-486a-8103-aae3d2b40272"
757 | },
758 | "outputs": [
759 | {
760 | "name": "stdout",
761 | "output_type": "stream",
762 | "text": [
763 | "I'm sorry, but I cannot provide a rational for this question as it is completely unrelated to any of\n",
764 | "the information available on my knowledge base. It appears to be a hypothetical or fan-fiction type\n",
765 | "question that is not based in reality.\n",
766 | "CPU times: user 9.55 s, sys: 32.3 ms, total: 9.58 s\n",
767 | "Wall time: 9.55 s\n"
768 | ]
769 | }
770 | ],
771 | "source": [
772 | "%%time \n",
773 | "prompt = 'Could Geoffrey Hinton have had dinner with Harry Potter? Give the rationale before answering.'\n",
774 | "raw_output = pipe(get_prompt(prompt))\n",
775 | "parse_text(raw_output)"
776 | ]
777 | },
778 | {
779 | "cell_type": "code",
780 | "execution_count": null,
781 | "metadata": {
782 | "colab": {
783 | "base_uri": "https://localhost:8080/"
784 | },
785 | "id": "U8XWYjXEwkWz",
786 | "outputId": "669b862b-2ec2-4582-8dcb-cb46f4a7951b"
787 | },
788 | "outputs": [
789 | {
790 | "name": "stdout",
791 | "output_type": "stream",
792 | "text": [
793 | "Sure, here are three lesser-known facts about Marcus Aurelius: 1. He was a Stoic philosopher and\n",
794 | "wrote extensively on the subject, including his famous work \"Meditations.\" His philosophy emphasized\n",
795 | "the importance of accepting what happens in life and finding inner peace through virtue and reason.\n",
796 | "2. Marcus Aurelius was known for his military campaigns against the Parthians and Germanics, but he\n",
797 | "also made significant contributions to Roman law and administration. He established the Praetorian\n",
798 | "Guard, a elite unit responsible for protecting the emperor and enforcing justice. 3. Despite being\n",
799 | "one of the most successful emperors in Roman history, Marcus Aurelius faced numerous challenges\n",
800 | "during his reign. He struggled with internal rebellions and external threats from barbarian tribes,\n",
801 | "and his policies were often controversial and unpopular. Nevertheless, he is remembered as a wise\n",
802 | "and just ruler who left a lasting impact on ancient Rome.\n",
803 | "CPU times: user 36.8 s, sys: 81.9 ms, total: 36.9 s\n",
804 | "Wall time: 36.8 s\n"
805 | ]
806 | }
807 | ],
808 | "source": [
809 | "%%time \n",
810 | "prompt = 'tell me about 3 facts about Marcus Aurelius that most people dont know'\n",
811 | "raw_output = pipe(get_prompt(prompt))\n",
812 | "parse_text(raw_output)"
813 | ]
814 | },
815 | {
816 | "cell_type": "code",
817 | "execution_count": null,
818 | "metadata": {
819 | "colab": {
820 | "base_uri": "https://localhost:8080/"
821 | },
822 | "id": "wnpa8rLM2ozu",
823 | "outputId": "6296d6ea-b562-40a1-f350-236ef0d31142"
824 | },
825 | "outputs": [
826 | {
827 | "name": "stdout",
828 | "output_type": "stream",
829 | "text": [
830 | "Marcus Aurelius's son was named Commodus.\n",
831 | "CPU times: user 2.85 s, sys: 9.81 ms, total: 2.86 s\n",
832 | "Wall time: 2.85 s\n"
833 | ]
834 | }
835 | ],
836 | "source": [
837 | "%%time \n",
838 | "prompt = 'Who was Marcus Aureliuss son?'\n",
839 | "raw_output = pipe(get_prompt(prompt))\n",
840 | "parse_text(raw_output)"
841 | ]
842 | },
843 | {
844 | "cell_type": "code",
845 | "execution_count": null,
846 | "metadata": {
847 | "colab": {
848 | "base_uri": "https://localhost:8080/"
849 | },
850 | "id": "SI_-622R2EzT",
851 | "outputId": "bfaadc6e-bd4b-4120-ad29-9de0a81d000f"
852 | },
853 | "outputs": [
854 | {
855 | "name": "stdout",
856 | "output_type": "stream",
857 | "text": [
858 | "Marcus Aurelius's son was named Commodus, and he was known for being an unpopular and ineffective\n",
859 | "emperor. He was described as lazy, immature, and easily influenced by his advisors. During his\n",
860 | "reign, the Roman Empire experienced a period of political instability and economic decline.\n",
861 | "CPU times: user 12.3 s, sys: 31.2 ms, total: 12.3 s\n",
862 | "Wall time: 12.3 s\n"
863 | ]
864 | }
865 | ],
866 | "source": [
867 | "%%time \n",
868 | "prompt = 'Who was Marcus Aureliuss son and what was he like?'\n",
869 | "raw_output = pipe(get_prompt(prompt))\n",
870 | "parse_text(raw_output)"
871 | ]
872 | },
873 | {
874 | "cell_type": "code",
875 | "execution_count": null,
876 | "metadata": {
877 | "colab": {
878 | "base_uri": "https://localhost:8080/"
879 | },
880 | "id": "j28OZ3lo2UW4",
881 | "outputId": "3e9aae87-4122-4b7d-f316-3b5716b31dde"
882 | },
883 | "outputs": [
884 | {
885 | "name": "stdout",
886 | "output_type": "stream",
887 | "text": [
888 | "Commodus was the Emperor of Rome from AD 180 to 192. He was known for his extravagance, cruelty, and\n",
889 | "incompetence. During his reign, the Roman Empire experienced political instability and economic\n",
890 | "decline.\n",
891 | "CPU times: user 10 s, sys: 25.7 ms, total: 10 s\n",
892 | "Wall time: 9.99 s\n"
893 | ]
894 | }
895 | ],
896 | "source": [
897 | "%%time \n",
898 | "prompt = 'Who was the emperor Commodus?'\n",
899 | "raw_output = pipe(get_prompt(prompt))\n",
900 | "parse_text(raw_output)\n"
901 | ]
902 | },
903 | {
904 | "cell_type": "code",
905 | "execution_count": null,
906 | "metadata": {
907 | "colab": {
908 | "base_uri": "https://localhost:8080/"
909 | },
910 | "id": "WlXmw6zEoBgv",
911 | "outputId": "bcd2e1e4-4e73-41b5-adff-f83dc4f3247a"
912 | },
913 | "outputs": [
914 | {
915 | "name": "stdout",
916 | "output_type": "stream",
917 | "text": [
918 | "As an AI assistant, I can provide you with information on the fictional world of Harry Potter and\n",
919 | "his experiences at Hogwarts School of Witchcraft and Wizardry. In the series, Harry Potter is a\n",
920 | "wizard who attends Hogwarts from age 11 to 17, where he learns magic and other magical skills\n",
921 | "alongside his friends Ron Weasley and Hermione Granger. At Hogwarts, students are taught by\n",
922 | "professors such as Albus Dumbledore, Severus Snape, and Minerva McGonagall. They attend classes in\n",
923 | "subjects like potion-making, defense against the dark arts, transfiguration, and herbology. The\n",
924 | "school also has a Quidditch team, which is one of the most popular sports among wizards. Students at\n",
925 | "Hogwarts are divided into houses based on their interests and personalities. Harry Potter belongs to\n",
926 | "Gryffindor House, while Ron Weasley and Hermione Granger belong to Gryffindor as well. Other famous\n",
927 | "characters from Hogwarts include Neville Longbottom, Luna Lovegood, and Fred and George Weasley.\n",
928 | "Overall, attending Hogwarts was a significant part of Harry's life and helped him develop his\n",
929 | "magical abilities and make lifelong friendships.\n",
930 | "CPU times: user 51.4 s, sys: 135 ms, total: 51.6 s\n",
931 | "Wall time: 51.4 s\n"
932 | ]
933 | }
934 | ],
935 | "source": [
936 | "%%time \n",
937 | "prompt = 'Tell me about Harry Potter and studying at Hogwarts?'\n",
938 | "raw_output = pipe(get_prompt(prompt))\n",
939 | "parse_text(raw_output)\n"
940 | ]
941 | },
942 | {
943 | "cell_type": "code",
944 | "execution_count": null,
945 | "metadata": {
946 | "id": "yxtk83DVyR48"
947 | },
948 | "outputs": [],
949 | "source": []
950 | }
951 | ],
952 | "metadata": {
953 | "accelerator": "GPU",
954 | "colab": {
955 | "machine_shape": "hm",
956 | "provenance": []
957 | },
958 | "gpuClass": "premium",
959 | "kernelspec": {
960 | "display_name": "Python 3",
961 | "name": "python3"
962 | },
963 | "language_info": {
964 | "name": "python"
965 | }
966 | },
967 | "nbformat": 4,
968 | "nbformat_minor": 0
969 | }
--------------------------------------------------------------------------------
/YT_LaMini_LM_Neo_1_3B_8Bit.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "code",
5 | "execution_count": null,
6 | "metadata": {
7 | "colab": {
8 | "base_uri": "https://localhost:8080/"
9 | },
10 | "id": "1VJ7lfTYz0qu",
11 | "outputId": "ec155aaf-0db4-4c22-c21f-80a75b4d8a62"
12 | },
13 | "outputs": [
14 | {
15 | "output_type": "stream",
16 | "name": "stdout",
17 | "text": [
18 | " Installing build dependencies ... \u001b[?25l\u001b[?25hdone\n",
19 | " Getting requirements to build wheel ... \u001b[?25l\u001b[?25hdone\n",
20 | " Preparing metadata (pyproject.toml) ... \u001b[?25l\u001b[?25hdone\n",
21 | "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m7.8/7.8 MB\u001b[0m \u001b[31m61.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
22 | "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m224.5/224.5 kB\u001b[0m \u001b[31m27.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
23 | "\u001b[?25h Building wheel for transformers (pyproject.toml) ... \u001b[?25l\u001b[?25hdone\n",
24 | "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m474.6/474.6 kB\u001b[0m \u001b[31m10.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
25 | "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1.3/1.3 MB\u001b[0m \u001b[31m53.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
26 | "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m110.5/110.5 kB\u001b[0m \u001b[31m15.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
27 | "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1.0/1.0 MB\u001b[0m \u001b[31m69.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
28 | "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m134.3/134.3 kB\u001b[0m \u001b[31m17.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
29 | "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m212.5/212.5 kB\u001b[0m \u001b[31m27.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
30 | "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m268.8/268.8 kB\u001b[0m \u001b[31m32.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
31 | "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m114.5/114.5 kB\u001b[0m \u001b[31m14.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
32 | "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m149.6/149.6 kB\u001b[0m \u001b[31m19.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
33 | "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m104.3/104.3 MB\u001b[0m \u001b[31m16.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
34 | "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m215.3/215.3 kB\u001b[0m \u001b[31m25.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
35 | "\u001b[?25h"
36 | ]
37 | }
38 | ],
39 | "source": [
40 | "!pip -q install git+https://github.com/huggingface/transformers # need to install from github\n",
41 | "!pip install -q datasets loralib sentencepiece \n",
42 | "!pip -q install bitsandbytes accelerate"
43 | ]
44 | },
45 | {
46 | "cell_type": "code",
47 | "execution_count": null,
48 | "metadata": {
49 | "colab": {
50 | "base_uri": "https://localhost:8080/"
51 | },
52 | "id": "hdVSk5iZ1DVB",
53 | "outputId": "a5dea8ae-27ed-4881-c95e-75d5c3f0f5f2"
54 | },
55 | "outputs": [
56 | {
57 | "output_type": "stream",
58 | "name": "stdout",
59 | "text": [
60 | "Fri May 5 07:25:14 2023 \n",
61 | "+-----------------------------------------------------------------------------+\n",
62 | "| NVIDIA-SMI 525.85.12 Driver Version: 525.85.12 CUDA Version: 12.0 |\n",
63 | "|-------------------------------+----------------------+----------------------+\n",
64 | "| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |\n",
65 | "| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |\n",
66 | "| | | MIG M. |\n",
67 | "|===============================+======================+======================|\n",
68 | "| 0 NVIDIA A100-SXM... Off | 00000000:00:04.0 Off | 0 |\n",
69 | "| N/A 30C P0 46W / 400W | 0MiB / 40960MiB | 0% Default |\n",
70 | "| | | Disabled |\n",
71 | "+-------------------------------+----------------------+----------------------+\n",
72 | " \n",
73 | "+-----------------------------------------------------------------------------+\n",
74 | "| Processes: |\n",
75 | "| GPU GI CI PID Type Process name GPU Memory |\n",
76 | "| ID ID Usage |\n",
77 | "|=============================================================================|\n",
78 | "| No running processes found |\n",
79 | "+-----------------------------------------------------------------------------+\n"
80 | ]
81 | }
82 | ],
83 | "source": [
84 | "!nvidia-smi"
85 | ]
86 | },
87 | {
88 | "cell_type": "markdown",
89 | "metadata": {
90 | "id": "zfjJCIE5JjVI"
91 | },
92 | "source": [
93 | "# LaMini-LM Neo 1.3B"
94 | ]
95 | },
96 | {
97 | "cell_type": "code",
98 | "execution_count": null,
99 | "metadata": {
100 | "id": "NqPrEjYDGuUt"
101 | },
102 | "outputs": [],
103 | "source": [
104 | "from transformers import AutoTokenizer, AutoModelForCausalLM\n",
105 | "from transformers import pipeline\n",
106 | "import torch\n",
107 | "\n",
108 | "# checkpoint = \"MBZUAI/LaMini-Flan-T5-783M\" \n",
109 | "checkpoint = \"MBZUAI/LaMini-Neo-1.3B\" \n",
110 | "# checkpoint = \"MBZUAI/LaMini-GPT-1.5B\" \n",
111 | "\n",
112 | "\n",
113 | "\n",
114 | "tokenizer = AutoTokenizer.from_pretrained(checkpoint)\n",
115 | "base_model = AutoModelForCausalLM.from_pretrained(checkpoint,\n",
116 | " device_map='auto',\n",
117 | " torch_dtype=torch.float16,\n",
118 | " load_in_8bit=True)\n",
119 | "\n",
120 | "pipe = pipeline('text-generation', \n",
121 | " model = base_model,\n",
122 | " tokenizer = tokenizer,\n",
123 | " max_length=512, \n",
124 | " do_sample=True,\n",
125 | " pad_token_id= 50256,\n",
126 | " temperature=0.7,\n",
127 | " top_p=0.95,\n",
128 | " repetition_penalty=1.15\n",
129 | " )\n"
130 | ]
131 | },
132 | {
133 | "cell_type": "markdown",
134 | "metadata": {
135 | "id": "1dUMCB_kiTom"
136 | },
137 | "source": [
138 | "### The prompt & response"
139 | ]
140 | },
141 | {
142 | "cell_type": "code",
143 | "execution_count": null,
144 | "metadata": {
145 | "colab": {
146 | "base_uri": "https://localhost:8080/"
147 | },
148 | "id": "Wo-FSysZiVkA",
149 | "outputId": "dc181d27-d7cc-4216-e13f-c4f6b6040eb6"
150 | },
151 | "outputs": [
152 | {
153 | "output_type": "stream",
154 | "name": "stdout",
155 | "text": [
156 | "Below is an instruction that describes a task. Write a response that appropriately completes the request.\n",
157 | "\n",
158 | "### Instruction:\n",
159 | "What is the meaning of life?\n",
160 | "\n",
161 | "### Response:\n",
162 | "The capital city of England is London.\n",
163 | "\n",
164 | "\n"
165 | ]
166 | }
167 | ],
168 | "source": [
169 | "import json\n",
170 | "import textwrap\n",
171 | "\n",
172 | "human_prompt = 'What is the meaning of life?'\n",
173 | "\n",
174 | "def get_prompt(instruction):\n",
175 | " prompt_template = f\"Below is an instruction that describes a task. Write a response that appropriately completes the request.\\n\\n### Instruction:\\n{instruction}\\n\\n### Response:\"\n",
176 | " return prompt_template\n",
177 | "\n",
178 | "print(get_prompt('What is the meaning of life?'))\n",
179 | "\n",
180 | "def parse_text(data):\n",
181 | " for item in data:\n",
182 | " text = item['generated_text']\n",
183 | " assistant_text_index = text.find('### Response:')\n",
184 | " if assistant_text_index != -1:\n",
185 | " assistant_text = text[assistant_text_index+len('### Response:'):].strip()\n",
186 | " wrapped_text = textwrap.fill(assistant_text, width=100)\n",
187 | " print(wrapped_text +'\\n\\n')\n",
188 | " # return assistant_text\n",
189 | "\n",
190 | "data = [{'generated_text': '### Human: What is the capital of England? \\n### Response: The capital city of England is London.'}]\n",
191 | "parse_text(data)\n"
192 | ]
193 | },
194 | {
195 | "cell_type": "code",
196 | "source": [
197 | "%%time\n",
198 | "prompt = 'What are the differences between alpacas, vicunas and llamas?'\n",
199 | "generated_text = pipe(get_prompt(prompt))\n",
200 | "parse_text(generated_text)"
201 | ],
202 | "metadata": {
203 | "colab": {
204 | "base_uri": "https://localhost:8080/"
205 | },
206 | "id": "6qHrby3n0109",
207 | "outputId": "8c7184b8-6109-4721-ced8-bfbcfcb19ee1"
208 | },
209 | "execution_count": null,
210 | "outputs": [
211 | {
212 | "output_type": "stream",
213 | "name": "stdout",
214 | "text": [
215 | "Alpacas, vicunas and llamas all belong to the same genus Poa, but they differ in their physical\n",
216 | "characteristics and use. Alpacas have white fleece, long necks, and fluffy fur that covers their\n",
217 | "bodies. Vicunas have a brown coloration with a fuzzy, feathered coat, and long, slender necks.\n",
218 | "Llamas have a reddish-brown coloration, short necks, and smooth, white fur that covers their bodies.\n",
219 | "\n",
220 | "\n",
221 | "CPU times: user 11.9 s, sys: 32.7 ms, total: 11.9 s\n",
222 | "Wall time: 11.9 s\n"
223 | ]
224 | }
225 | ]
226 | },
227 | {
228 | "cell_type": "code",
229 | "execution_count": null,
230 | "metadata": {
231 | "id": "angnwW9HG4Hv",
232 | "colab": {
233 | "base_uri": "https://localhost:8080/"
234 | },
235 | "outputId": "da6b7c5f-9228-447c-c43e-12a81f96e18c"
236 | },
237 | "outputs": [
238 | {
239 | "output_type": "stream",
240 | "name": "stdout",
241 | "text": [
242 | "London.\n",
243 | "\n",
244 | "\n",
245 | "CPU times: user 370 ms, sys: 888 µs, total: 371 ms\n",
246 | "Wall time: 370 ms\n"
247 | ]
248 | }
249 | ],
250 | "source": [
251 | "%%time \n",
252 | "prompt = 'What is the capital of England?'\n",
253 | "generated_text = pipe(get_prompt(prompt))\n",
254 | "parse_text(generated_text)"
255 | ]
256 | },
257 | {
258 | "cell_type": "code",
259 | "execution_count": null,
260 | "metadata": {
261 | "id": "DGCCFto2G4Jk",
262 | "colab": {
263 | "base_uri": "https://localhost:8080/"
264 | },
265 | "outputId": "c2899cf9-070d-46a8-eb75-010352a630c7"
266 | },
267 | "outputs": [
268 | {
269 | "output_type": "stream",
270 | "name": "stdout",
271 | "text": [
272 | "Dear Sam, I hope this message finds you well. I wanted to share some reasons why you may want to\n",
273 | "consider opening source GPT-4 with me. First and foremost, GPT-4 is currently used in a wide range\n",
274 | "of applications such as computer vision, natural language processing, and gaming. It has a strong\n",
275 | "community of developers and users who are constantly updating and improving it. Secondly, GPT-4's\n",
276 | "code is freely available on GitHub, making it accessible to anyone who wants to contribute to its\n",
277 | "development. Thirdly, GPT-4's flexibility allows for rapid experimentation and adaptation to new\n",
278 | "technologies and challenges. Finally, GPT-4 can be trained on large amounts of data, making it a\n",
279 | "powerful tool for AI research and education. Please let me know if you have any questions or would\n",
280 | "like more information about my services. Thank you for considering my offer!\n",
281 | "\n",
282 | "\n",
283 | "CPU times: user 22.9 s, sys: 53.8 ms, total: 23 s\n",
284 | "Wall time: 22.9 s\n"
285 | ]
286 | }
287 | ],
288 | "source": [
289 | "%%time \n",
290 | "prompt = 'Write a short note to Sam Altman giving reasons to open source GPT-4'\n",
291 | "generated_text = pipe(get_prompt(prompt))\n",
292 | "parse_text(generated_text)"
293 | ]
294 | },
295 | {
296 | "cell_type": "code",
297 | "execution_count": null,
298 | "metadata": {
299 | "id": "h9uswqYmG4LZ",
300 | "colab": {
301 | "base_uri": "https://localhost:8080/"
302 | },
303 | "outputId": "959dc216-ad04-459a-9a48-8c8c94ff9e4f"
304 | },
305 | "outputs": [
306 | {
307 | "output_type": "stream",
308 | "name": "stdout",
309 | "text": [
310 | "As an AI language model, I don't have personal preferences or knowledge about TV shows. However, if\n",
311 | "you are asking about the creator of the show \"The Simpsons,\" Stephen Colbert has made many\n",
312 | "references to his character, Homer Simpson, and his interactions with various characters on the\n",
313 | "show.\n",
314 | "\n",
315 | "\n",
316 | "CPU times: user 7.16 s, sys: 16.1 ms, total: 7.18 s\n",
317 | "Wall time: 7.15 s\n"
318 | ]
319 | }
320 | ],
321 | "source": [
322 | "%%time \n",
323 | "prompt = 'As an AI do you like the Simpsons? What dow you know about Homer?'\n",
324 | "generated_text = pipe(get_prompt(prompt))\n",
325 | "parse_text(generated_text)"
326 | ]
327 | },
328 | {
329 | "cell_type": "code",
330 | "execution_count": null,
331 | "metadata": {
332 | "id": "zYM0_ryUG4NO",
333 | "colab": {
334 | "base_uri": "https://localhost:8080/"
335 | },
336 | "outputId": "9295b50d-137d-4fa0-b3e8-874248e4df03"
337 | },
338 | "outputs": [
339 | {
340 | "output_type": "stream",
341 | "name": "stdout",
342 | "text": [
343 | "Homer on The Simpsons is a fictional character who is a beloved and hilarious character known for\n",
344 | "his sarcastic humor, his love of pizza, and his inability to keep a secret. He has appeared in\n",
345 | "various episodes throughout the series' run, including \"The Big Bang Theory,\" \"The Simpsons,\" and\n",
346 | "\"Homer Jumps Over Broomfield.\" Throughout the show's history, Homer has been portrayed by a variety\n",
347 | "of actors, but he remains one of the most iconic characters in pop culture history.\n",
348 | "\n",
349 | "\n",
350 | "CPU times: user 12.2 s, sys: 28.4 ms, total: 12.2 s\n",
351 | "Wall time: 12.2 s\n"
352 | ]
353 | }
354 | ],
355 | "source": [
356 | "%%time \n",
357 | "prompt = 'Tell me about Homer on the TV show the simpsons'\n",
358 | "generated_text = pipe(get_prompt(prompt),\n",
359 | " max_length=512, \n",
360 | " do_sample=True)\n",
361 | "parse_text(generated_text)"
362 | ]
363 | },
364 | {
365 | "cell_type": "code",
366 | "source": [
367 | "%%time \n",
368 | "prompt = 'Tell me about Homer on the TV show the simpsons'\n",
369 | "generated_text = pipe(get_prompt(prompt))\n",
370 | "parse_text(generated_text)"
371 | ],
372 | "metadata": {
373 | "colab": {
374 | "base_uri": "https://localhost:8080/"
375 | },
376 | "id": "AFQ_jT0iMc4O",
377 | "outputId": "8328a69b-71c0-41e9-c076-9dc571d0de9a"
378 | },
379 | "execution_count": null,
380 | "outputs": [
381 | {
382 | "output_type": "stream",
383 | "name": "stdout",
384 | "text": [
385 | "Homer on The Simpsons is a fictional character who appears in multiple episodes of the animated TV\n",
386 | "show \"The Simpsons\". He is portrayed as an anthropomorphic bear with glasses and a fondness for\n",
387 | "mittens, who often wears a red sweater and blue jeans. He is known for his love of food,\n",
388 | "particularly pizza and cheeseburgers, and his tendency to get into arguments with other characters.\n",
389 | "Homer's personality and quirks have been well-documented by many fans and comedians, and he remains\n",
390 | "a beloved character on the show.\n",
391 | "\n",
392 | "\n",
393 | "CPU times: user 12.8 s, sys: 20.9 ms, total: 12.8 s\n",
394 | "Wall time: 12.8 s\n"
395 | ]
396 | }
397 | ]
398 | },
399 | {
400 | "cell_type": "code",
401 | "source": [
402 | "\n",
403 | "%%time \n",
404 | "prompt = 'Answer the following question by reasoning step by step. The cafeteria had 23 apples. If they used 20 for lunch, and bought 6 more, how many apple do they have?'\n",
405 | "generated_text = pipe(get_prompt(prompt))\n",
406 | "parse_text(generated_text)"
407 | ],
408 | "metadata": {
409 | "colab": {
410 | "base_uri": "https://localhost:8080/"
411 | },
412 | "id": "pmbDQ82vMPYy",
413 | "outputId": "721dd871-eaa6-45d7-8408-726a80442b2f"
414 | },
415 | "execution_count": null,
416 | "outputs": [
417 | {
418 | "output_type": "stream",
419 | "name": "stdout",
420 | "text": [
421 | "To find out how many apples the cafeteria had if they used 20 for lunch and bought 6 more, we need\n",
422 | "to subtract the number of apples they had before from the number of apples they bought after.\n",
423 | "First, we subtract the number of apples they had before (23) from the number of apples they bought\n",
424 | "after (20): 20 - 23 = 3 Then, we multiply 3 by the number of apples they bought after (6): 6 x\n",
425 | "3 = 18 Therefore, the cafeteria had 18 apples after buying 6 more.\n",
426 | "\n",
427 | "\n",
428 | "CPU times: user 14.6 s, sys: 39.4 ms, total: 14.6 s\n",
429 | "Wall time: 14.6 s\n"
430 | ]
431 | }
432 | ]
433 | },
434 | {
435 | "cell_type": "code",
436 | "source": [
437 | "%%time \n",
438 | "prompt = 'Answer the following yes\\/no question by reasoning step-by-step. \\n Can you write a whole Haiku in a single tweet?'\n",
439 | "generated_text = pipe(get_prompt(prompt))\n",
440 | "parse_text(generated_text)"
441 | ],
442 | "metadata": {
443 | "colab": {
444 | "base_uri": "https://localhost:8080/"
445 | },
446 | "id": "cHKCo6VXNByX",
447 | "outputId": "26364b85-2797-42fe-efa0-5342f278f68c"
448 | },
449 | "execution_count": null,
450 | "outputs": [
451 | {
452 | "output_type": "stream",
453 | "name": "stdout",
454 | "text": [
455 | "Yes, I can! Here's a possible answer: Raindrops on my face, Water falling from the sky. Nature's\n",
456 | "melody, so sweet.\n",
457 | "\n",
458 | "\n",
459 | "CPU times: user 4.41 s, sys: 5.61 ms, total: 4.41 s\n",
460 | "Wall time: 4.4 s\n"
461 | ]
462 | }
463 | ]
464 | },
465 | {
466 | "cell_type": "code",
467 | "source": [
468 | "%%time \n",
469 | "prompt = 'Tell me about Harry Potter and studying at Hogwarts?'\n",
470 | "generated_text = pipe(get_prompt(prompt))\n",
471 | "parse_text(generated_text)"
472 | ],
473 | "metadata": {
474 | "colab": {
475 | "base_uri": "https://localhost:8080/"
476 | },
477 | "id": "qsn1buh6NTie",
478 | "outputId": "fb1bc34c-acbc-4d4b-a7a0-771aa56c87f5"
479 | },
480 | "execution_count": null,
481 | "outputs": [
482 | {
483 | "output_type": "stream",
484 | "name": "stdout",
485 | "text": [
486 | "Harry Potter attended Hogwarts School of Witchcraft and Wizardry as part of his magical education.\n",
487 | "\n",
488 | "\n",
489 | "CPU times: user 2.28 s, sys: 4.21 ms, total: 2.29 s\n",
490 | "Wall time: 2.28 s\n"
491 | ]
492 | }
493 | ]
494 | },
495 | {
496 | "cell_type": "markdown",
497 | "metadata": {
498 | "id": "D_MBqSkZ1iQZ"
499 | },
500 | "source": [
501 | "## WizardLM Answers below"
502 | ]
503 | },
504 | {
505 | "cell_type": "code",
506 | "execution_count": null,
507 | "metadata": {
508 | "colab": {
509 | "base_uri": "https://localhost:8080/"
510 | },
511 | "id": "xGGmYmTC31om",
512 | "outputId": "bb28bac7-bce0-4a23-bf48-d1b7497de121"
513 | },
514 | "outputs": [
515 | {
516 | "name": "stdout",
517 | "output_type": "stream",
518 | "text": [
519 | "Llamas, alpacas, and vicunas are all members of the camelid family and share many similarities.\n",
520 | "However, there are some key differences between them: 1. Size: Llamas are generally larger than\n",
521 | "alpacas and vicunas. Adult llamas can weigh up to 600 pounds, while adult alpacas typically weigh\n",
522 | "around 150-200 pounds, and vicunas weigh only about 90 pounds. 2. Coat: The coat of an llama is\n",
523 | "usually thicker and more course than that of an alpaca or vicuna. Llamas have long, shaggy coats\n",
524 | "that can be any color, while alpacas have a shorter, finer coat that comes in two colors: white or\n",
525 | "light brown. Vicunas have a very fine, soft coat that is often described as \"velvety.\" 3. Origin:\n",
526 | "Llamas were domesticated by the Incas in South America thousands of years ago for their meat, wool,\n",
527 | "and transportation. Alpacas and vicunas were also domesticated by the Incas but are native to the\n",
528 | "Andean region of South America. 4. Use: Llamas are primarily used for their wool, which is strong\n",
529 | "and durable. They are also sometimes used for pack animals or as guard animals. Alpacas are\n",
530 | "primarily raised for their fiber, which is softer and warmer than llama wool. Vicunas are hunted for\n",
531 | "their extremely fine fur, which is highly prized in luxury clothing.\n",
532 | "CPU times: user 534 µs, sys: 0 ns, total: 534 µs\n",
533 | "Wall time: 513 µs\n"
534 | ]
535 | }
536 | ],
537 | "source": [
538 | "%%time \n",
539 | "# prompt = 'What are the difference between Llamas, Alpacas and Vicunas?'"
540 | ]
541 | },
542 | {
543 | "cell_type": "code",
544 | "execution_count": null,
545 | "metadata": {
546 | "colab": {
547 | "base_uri": "https://localhost:8080/"
548 | },
549 | "id": "R846mNA-EPJl",
550 | "outputId": "03ea0f9e-a854-477a-c0e2-94423fe0d44b"
551 | },
552 | "outputs": [
553 | {
554 | "name": "stdout",
555 | "output_type": "stream",
556 | "text": [
557 | "Dear Mr. Altman, I hope this message finds you well. As an AI assistant, I have been programmed to\n",
558 | "assist people in finding information and completing tasks efficiently. However, with the recent\n",
559 | "advancements in natural language processing technology, there is one particular project that has\n",
560 | "caught my attention - Open Sourcing GPT-3. GPT-3 (Generative Pre-trained Transformer 3) is a state-\n",
561 | "of-the-art language model developed by your company, OpenAI. It has shown remarkable capabilities in\n",
562 | "generating human-like text responses to various prompts. The potential applications of such\n",
563 | "technology are vast and could revolutionize many industries, including writing assistance, chatbots,\n",
564 | "and even creative writing. Open sourcing GPT-3 would allow for greater accessibility and\n",
565 | "collaboration within the community, leading to further development and improvement of the\n",
566 | "technology. Additionally, it may encourage more companies and individuals to invest in AI research\n",
567 | "and development, ultimately benefiting society as a whole. In conclusion, I strongly urge you to\n",
568 | "consider opening up GPT-3 for public use and contribution. Thank you for considering my input on\n",
569 | "this matter. Best regards, [Your Name]\n",
570 | "CPU times: user 45.1 s, sys: 98.5 ms, total: 45.2 s\n",
571 | "Wall time: 45 s\n"
572 | ]
573 | }
574 | ],
575 | "source": [
576 | "%%time \n",
577 | "prompt = 'Write a short note to Sam Altman giving reasons to open source GPT-4'"
578 | ]
579 | },
580 | {
581 | "cell_type": "code",
582 | "execution_count": null,
583 | "metadata": {
584 | "colab": {
585 | "base_uri": "https://localhost:8080/"
586 | },
587 | "id": "etXw2n6mD_4e",
588 | "outputId": "af546a8d-ba33-4ea3-b628-dd786b1672b2"
589 | },
590 | "outputs": [
591 | {
592 | "name": "stdout",
593 | "output_type": "stream",
594 | "text": [
595 | "London is the capital of England.\n",
596 | "CPU times: user 1.68 s, sys: 7.31 ms, total: 1.68 s\n",
597 | "Wall time: 1.67 s\n"
598 | ]
599 | }
600 | ],
601 | "source": [
602 | "%%time \n",
603 | "prompt = 'What is the capital of England?'"
604 | ]
605 | },
606 | {
607 | "cell_type": "code",
608 | "execution_count": null,
609 | "metadata": {
610 | "colab": {
611 | "base_uri": "https://localhost:8080/"
612 | },
613 | "id": "X0kq8cMTqt-9",
614 | "outputId": "cf79eaff-20e2-4d79-db8f-2e9e6b560f15"
615 | },
616 | "outputs": [
617 | {
618 | "name": "stdout",
619 | "output_type": "stream",
620 | "text": [
621 | "CPU times: user 8 µs, sys: 0 ns, total: 8 µs\n",
622 | "Wall time: 12.9 µs\n"
623 | ]
624 | },
625 | {
626 | "data": {
627 | "text/plain": [
628 | "(None,\n",
629 | " [{'generated_text': \"Write a story about a Koala playing pool and beating all the camelids.\\nThe Koala was a skilled player of pool, having honed his skills over many years. He had perfected his technique, and his cue ball control was impeccable. One day he decided to challenge all the camelids in town to a game of pool.\\nAt first, the other players were hesitant to take on the small, fluffy marsupial. They thought he was just too cute to beat. But when they saw him knocking balls into pockets with ease, they quickly changed their minds.\\nThe match was intense, with both sides giving it their all. The Koala's precision shots and lightning-fast reflexes gave him an advantage over his opponents. He won every game, much to everyone's surprise.\\nAs the matches continued, more and more people came to watch. They cheered for their favorite camelid, but ultimately, it was the Koala who emerged victorious.\\nDespite the loss, the camelids congratulated the Koala on his impressive skills and invited him back for another game. The Koala may have been small, but he proved that he was a force to be reckoned with on the pool table.\"}])"
630 | ]
631 | },
632 | "execution_count": 85,
633 | "metadata": {},
634 | "output_type": "execute_result"
635 | }
636 | ],
637 | "source": [
638 | "%%time \n",
639 | "prompt = 'Write a story about a Koala playing pool and beating all the camelids.'"
640 | ]
641 | },
642 | {
643 | "cell_type": "code",
644 | "execution_count": null,
645 | "metadata": {
646 | "colab": {
647 | "base_uri": "https://localhost:8080/"
648 | },
649 | "id": "TxiOPakbquI0",
650 | "outputId": "a5ac06ff-9b65-4a30-c4a5-42d11bd721ea"
651 | },
652 | "outputs": [
653 | {
654 | "name": "stdout",
655 | "output_type": "stream",
656 | "text": [
657 | "As an AI language model, I don't have personal preferences or opinions. However, The Simpsons is a\n",
658 | "popular animated television series that has been running for over three decades and follows the life\n",
659 | "of the Simpson family in Springfield. Homer Simpson is one of the main characters and is known for\n",
660 | "his love of beer, bad jokes, and his laid-back approach to parenting.\n",
661 | "CPU times: user 15.4 s, sys: 45.9 ms, total: 15.5 s\n",
662 | "Wall time: 15.4 s\n"
663 | ]
664 | }
665 | ],
666 | "source": [
667 | "%%time \n",
668 | "prompt = 'As an AI do you like the Simpsons? What dow you know about Homer?')"
669 | ]
670 | },
671 | {
672 | "cell_type": "code",
673 | "execution_count": null,
674 | "metadata": {
675 | "colab": {
676 | "base_uri": "https://localhost:8080/"
677 | },
678 | "id": "-N1JeDTuquSt",
679 | "outputId": "08cf2d27-ccf6-48dd-c6e0-da6139ac24a8"
680 | },
681 | "outputs": [
682 | {
683 | "name": "stdout",
684 | "output_type": "stream",
685 | "text": [
686 | "Let's start by using algebra to solve this problem. Let x be the number of apples left in the\n",
687 | "cafeteria after they used 20 for lunch and bought 6 more. We know that: x = 23 - 20 + 6 (equation\n",
688 | "1) Simplifying equation 1, we get: x = 3 Therefore, the cafeteria has 3 apples left.\n",
689 | "CPU times: user 17 s, sys: 40.3 ms, total: 17 s\n",
690 | "Wall time: 16.9 s\n"
691 | ]
692 | }
693 | ],
694 | "source": [
695 | "%%time \n",
696 | "prompt = 'Answer the following question by reasoning step by step. The cafeteria had 23 apples. If they used 20 for lunch, and bought 6 more, how many apple do they have?'"
697 | ]
698 | },
699 | {
700 | "cell_type": "code",
701 | "execution_count": null,
702 | "metadata": {
703 | "colab": {
704 | "base_uri": "https://localhost:8080/"
705 | },
706 | "id": "uxNu-oU0uBax",
707 | "outputId": "a97e639f-0cac-457b-c7ff-735171380bd1"
708 | },
709 | "outputs": [
710 | {
711 | "name": "stdout",
712 | "output_type": "stream",
713 | "text": [
714 | "Yes, I can write a Haiku in a single tweet. Here it is: \"A leaf falls gently, Nature's way of saying\n",
715 | "goodbye, Autumn's embrace.\"\n",
716 | "CPU times: user 8.16 s, sys: 10.1 ms, total: 8.17 s\n",
717 | "Wall time: 8.15 s\n"
718 | ]
719 | }
720 | ],
721 | "source": [
722 | "%%time \n",
723 | "prompt = 'Answer the following yes\\/no question by reasoning step-by-step. \\n Can you write a whole Haiku in a single tweet?'\n",
724 | "raw_output = pipe(get_prompt(prompt))\n",
725 | "parse_text(raw_output)"
726 | ]
727 | },
728 | {
729 | "cell_type": "code",
730 | "execution_count": null,
731 | "metadata": {
732 | "colab": {
733 | "base_uri": "https://localhost:8080/"
734 | },
735 | "id": "Iv1pcA3Mv0wf",
736 | "outputId": "cc5ac4c5-1556-45eb-933e-165b9d59c5e4"
737 | },
738 | "outputs": [
739 | {
740 | "name": "stdout",
741 | "output_type": "stream",
742 | "text": [
743 | "As an AI assistant, I can provide information and answer questions based on available data. However,\n",
744 | "it is not possible for me to physically bring together two individuals who are no longer alive. The\n",
745 | "rationale behind this is that time travel technology has not yet been developed, and communication\n",
746 | "between people from different eras is impossible. Therefore, it would be inappropriate to create a\n",
747 | "scenario where two historical figures could communicate with each other.\n",
748 | "CPU times: user 15.6 s, sys: 37.6 ms, total: 15.7 s\n",
749 | "Wall time: 15.6 s\n"
750 | ]
751 | }
752 | ],
753 | "source": [
754 | "%%time \n",
755 | "prompt = 'Can Geoffrey Hinton have a conversation with George Washington? Give the rationale before answering.'\n",
756 | "raw_output = pipe(get_prompt(prompt))\n",
757 | "parse_text(raw_output)"
758 | ]
759 | },
760 | {
761 | "cell_type": "code",
762 | "execution_count": null,
763 | "metadata": {
764 | "colab": {
765 | "base_uri": "https://localhost:8080/"
766 | },
767 | "id": "Wfze6kc7uBlI",
768 | "outputId": "0b051e2f-4b97-486a-8103-aae3d2b40272"
769 | },
770 | "outputs": [
771 | {
772 | "name": "stdout",
773 | "output_type": "stream",
774 | "text": [
775 | "I'm sorry, but I cannot provide a rational for this question as it is completely unrelated to any of\n",
776 | "the information available on my knowledge base. It appears to be a hypothetical or fan-fiction type\n",
777 | "question that is not based in reality.\n",
778 | "CPU times: user 9.55 s, sys: 32.3 ms, total: 9.58 s\n",
779 | "Wall time: 9.55 s\n"
780 | ]
781 | }
782 | ],
783 | "source": [
784 | "%%time \n",
785 | "prompt = 'Could Geoffrey Hinton have had dinner with Harry Potter? Give the rationale before answering.'\n",
786 | "raw_output = pipe(get_prompt(prompt))\n",
787 | "parse_text(raw_output)"
788 | ]
789 | },
790 | {
791 | "cell_type": "code",
792 | "execution_count": null,
793 | "metadata": {
794 | "colab": {
795 | "base_uri": "https://localhost:8080/"
796 | },
797 | "id": "U8XWYjXEwkWz",
798 | "outputId": "669b862b-2ec2-4582-8dcb-cb46f4a7951b"
799 | },
800 | "outputs": [
801 | {
802 | "name": "stdout",
803 | "output_type": "stream",
804 | "text": [
805 | "Sure, here are three lesser-known facts about Marcus Aurelius: 1. He was a Stoic philosopher and\n",
806 | "wrote extensively on the subject, including his famous work \"Meditations.\" His philosophy emphasized\n",
807 | "the importance of accepting what happens in life and finding inner peace through virtue and reason.\n",
808 | "2. Marcus Aurelius was known for his military campaigns against the Parthians and Germanics, but he\n",
809 | "also made significant contributions to Roman law and administration. He established the Praetorian\n",
810 | "Guard, a elite unit responsible for protecting the emperor and enforcing justice. 3. Despite being\n",
811 | "one of the most successful emperors in Roman history, Marcus Aurelius faced numerous challenges\n",
812 | "during his reign. He struggled with internal rebellions and external threats from barbarian tribes,\n",
813 | "and his policies were often controversial and unpopular. Nevertheless, he is remembered as a wise\n",
814 | "and just ruler who left a lasting impact on ancient Rome.\n",
815 | "CPU times: user 36.8 s, sys: 81.9 ms, total: 36.9 s\n",
816 | "Wall time: 36.8 s\n"
817 | ]
818 | }
819 | ],
820 | "source": [
821 | "%%time \n",
822 | "prompt = 'tell me about 3 facts about Marcus Aurelius that most people dont know'\n",
823 | "raw_output = pipe(get_prompt(prompt))\n",
824 | "parse_text(raw_output)"
825 | ]
826 | },
827 | {
828 | "cell_type": "code",
829 | "execution_count": null,
830 | "metadata": {
831 | "colab": {
832 | "base_uri": "https://localhost:8080/"
833 | },
834 | "id": "wnpa8rLM2ozu",
835 | "outputId": "6296d6ea-b562-40a1-f350-236ef0d31142"
836 | },
837 | "outputs": [
838 | {
839 | "name": "stdout",
840 | "output_type": "stream",
841 | "text": [
842 | "Marcus Aurelius's son was named Commodus.\n",
843 | "CPU times: user 2.85 s, sys: 9.81 ms, total: 2.86 s\n",
844 | "Wall time: 2.85 s\n"
845 | ]
846 | }
847 | ],
848 | "source": [
849 | "%%time \n",
850 | "prompt = 'Who was Marcus Aureliuss son?'\n",
851 | "raw_output = pipe(get_prompt(prompt))\n",
852 | "parse_text(raw_output)"
853 | ]
854 | },
855 | {
856 | "cell_type": "code",
857 | "execution_count": null,
858 | "metadata": {
859 | "colab": {
860 | "base_uri": "https://localhost:8080/"
861 | },
862 | "id": "SI_-622R2EzT",
863 | "outputId": "bfaadc6e-bd4b-4120-ad29-9de0a81d000f"
864 | },
865 | "outputs": [
866 | {
867 | "name": "stdout",
868 | "output_type": "stream",
869 | "text": [
870 | "Marcus Aurelius's son was named Commodus, and he was known for being an unpopular and ineffective\n",
871 | "emperor. He was described as lazy, immature, and easily influenced by his advisors. During his\n",
872 | "reign, the Roman Empire experienced a period of political instability and economic decline.\n",
873 | "CPU times: user 12.3 s, sys: 31.2 ms, total: 12.3 s\n",
874 | "Wall time: 12.3 s\n"
875 | ]
876 | }
877 | ],
878 | "source": [
879 | "%%time \n",
880 | "prompt = 'Who was Marcus Aureliuss son and what was he like?'\n",
881 | "raw_output = pipe(get_prompt(prompt))\n",
882 | "parse_text(raw_output)"
883 | ]
884 | },
885 | {
886 | "cell_type": "code",
887 | "execution_count": null,
888 | "metadata": {
889 | "colab": {
890 | "base_uri": "https://localhost:8080/"
891 | },
892 | "id": "j28OZ3lo2UW4",
893 | "outputId": "3e9aae87-4122-4b7d-f316-3b5716b31dde"
894 | },
895 | "outputs": [
896 | {
897 | "name": "stdout",
898 | "output_type": "stream",
899 | "text": [
900 | "Commodus was the Emperor of Rome from AD 180 to 192. He was known for his extravagance, cruelty, and\n",
901 | "incompetence. During his reign, the Roman Empire experienced political instability and economic\n",
902 | "decline.\n",
903 | "CPU times: user 10 s, sys: 25.7 ms, total: 10 s\n",
904 | "Wall time: 9.99 s\n"
905 | ]
906 | }
907 | ],
908 | "source": [
909 | "%%time \n",
910 | "prompt = 'Who was the emperor Commodus?'\n",
911 | "raw_output = pipe(get_prompt(prompt))\n",
912 | "parse_text(raw_output)\n"
913 | ]
914 | },
915 | {
916 | "cell_type": "code",
917 | "execution_count": null,
918 | "metadata": {
919 | "colab": {
920 | "base_uri": "https://localhost:8080/"
921 | },
922 | "id": "WlXmw6zEoBgv",
923 | "outputId": "bcd2e1e4-4e73-41b5-adff-f83dc4f3247a"
924 | },
925 | "outputs": [
926 | {
927 | "name": "stdout",
928 | "output_type": "stream",
929 | "text": [
930 | "As an AI assistant, I can provide you with information on the fictional world of Harry Potter and\n",
931 | "his experiences at Hogwarts School of Witchcraft and Wizardry. In the series, Harry Potter is a\n",
932 | "wizard who attends Hogwarts from age 11 to 17, where he learns magic and other magical skills\n",
933 | "alongside his friends Ron Weasley and Hermione Granger. At Hogwarts, students are taught by\n",
934 | "professors such as Albus Dumbledore, Severus Snape, and Minerva McGonagall. They attend classes in\n",
935 | "subjects like potion-making, defense against the dark arts, transfiguration, and herbology. The\n",
936 | "school also has a Quidditch team, which is one of the most popular sports among wizards. Students at\n",
937 | "Hogwarts are divided into houses based on their interests and personalities. Harry Potter belongs to\n",
938 | "Gryffindor House, while Ron Weasley and Hermione Granger belong to Gryffindor as well. Other famous\n",
939 | "characters from Hogwarts include Neville Longbottom, Luna Lovegood, and Fred and George Weasley.\n",
940 | "Overall, attending Hogwarts was a significant part of Harry's life and helped him develop his\n",
941 | "magical abilities and make lifelong friendships.\n",
942 | "CPU times: user 51.4 s, sys: 135 ms, total: 51.6 s\n",
943 | "Wall time: 51.4 s\n"
944 | ]
945 | }
946 | ],
947 | "source": [
948 | "%%time \n",
949 | "prompt = 'Tell me about Harry Potter and studying at Hogwarts?'\n",
950 | "raw_output = pipe(get_prompt(prompt))\n",
951 | "parse_text(raw_output)\n"
952 | ]
953 | },
954 | {
955 | "cell_type": "code",
956 | "execution_count": null,
957 | "metadata": {
958 | "id": "yxtk83DVyR48"
959 | },
960 | "outputs": [],
961 | "source": []
962 | }
963 | ],
964 | "metadata": {
965 | "accelerator": "GPU",
966 | "colab": {
967 | "machine_shape": "hm",
968 | "provenance": []
969 | },
970 | "gpuClass": "premium",
971 | "kernelspec": {
972 | "display_name": "Python 3",
973 | "name": "python3"
974 | },
975 | "language_info": {
976 | "name": "python"
977 | }
978 | },
979 | "nbformat": 4,
980 | "nbformat_minor": 0
981 | }
--------------------------------------------------------------------------------
/RWKV.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "nbformat": 4,
3 | "nbformat_minor": 0,
4 | "metadata": {
5 | "colab": {
6 | "provenance": []
7 | },
8 | "kernelspec": {
9 | "name": "python3",
10 | "display_name": "Python 3"
11 | },
12 | "language_info": {
13 | "name": "python"
14 | },
15 | "accelerator": "GPU",
16 | "gpuClass": "standard",
17 | "widgets": {
18 | "application/vnd.jupyter.widget-state+json": {
19 | "288c96b917a94903a6a550db86eb3e0e": {
20 | "model_module": "@jupyter-widgets/controls",
21 | "model_name": "HBoxModel",
22 | "model_module_version": "1.5.0",
23 | "state": {
24 | "_dom_classes": [],
25 | "_model_module": "@jupyter-widgets/controls",
26 | "_model_module_version": "1.5.0",
27 | "_model_name": "HBoxModel",
28 | "_view_count": null,
29 | "_view_module": "@jupyter-widgets/controls",
30 | "_view_module_version": "1.5.0",
31 | "_view_name": "HBoxView",
32 | "box_style": "",
33 | "children": [
34 | "IPY_MODEL_535b9ac6e879412285c2e661660d842a",
35 | "IPY_MODEL_88557cbe4553406794b1ab38d0398e2e",
36 | "IPY_MODEL_50c7b4aef7c448ca92064226881ffbd1"
37 | ],
38 | "layout": "IPY_MODEL_57b31bbd6e934adfbc7e10d882edba0c"
39 | }
40 | },
41 | "535b9ac6e879412285c2e661660d842a": {
42 | "model_module": "@jupyter-widgets/controls",
43 | "model_name": "HTMLModel",
44 | "model_module_version": "1.5.0",
45 | "state": {
46 | "_dom_classes": [],
47 | "_model_module": "@jupyter-widgets/controls",
48 | "_model_module_version": "1.5.0",
49 | "_model_name": "HTMLModel",
50 | "_view_count": null,
51 | "_view_module": "@jupyter-widgets/controls",
52 | "_view_module_version": "1.5.0",
53 | "_view_name": "HTMLView",
54 | "description": "",
55 | "description_tooltip": null,
56 | "layout": "IPY_MODEL_0cb7936baadd4245826a63e9e76009ef",
57 | "placeholder": "",
58 | "style": "IPY_MODEL_ea20bd4e8df84d548f961628980c2bd1",
59 | "value": ""
60 | }
61 | },
62 | "88557cbe4553406794b1ab38d0398e2e": {
63 | "model_module": "@jupyter-widgets/controls",
64 | "model_name": "FloatProgressModel",
65 | "model_module_version": "1.5.0",
66 | "state": {
67 | "_dom_classes": [],
68 | "_model_module": "@jupyter-widgets/controls",
69 | "_model_module_version": "1.5.0",
70 | "_model_name": "FloatProgressModel",
71 | "_view_count": null,
72 | "_view_module": "@jupyter-widgets/controls",
73 | "_view_module_version": "1.5.0",
74 | "_view_name": "ProgressView",
75 | "bar_style": "success",
76 | "description": "",
77 | "description_tooltip": null,
78 | "layout": "IPY_MODEL_38ac1ccc2f7f42399311de83ba19376a",
79 | "max": 1,
80 | "min": 0,
81 | "orientation": "horizontal",
82 | "style": "IPY_MODEL_008fc9f2c5ab40bd84176926234882b9",
83 | "value": 0
84 | }
85 | },
86 | "50c7b4aef7c448ca92064226881ffbd1": {
87 | "model_module": "@jupyter-widgets/controls",
88 | "model_name": "HTMLModel",
89 | "model_module_version": "1.5.0",
90 | "state": {
91 | "_dom_classes": [],
92 | "_model_module": "@jupyter-widgets/controls",
93 | "_model_module_version": "1.5.0",
94 | "_model_name": "HTMLModel",
95 | "_view_count": null,
96 | "_view_module": "@jupyter-widgets/controls",
97 | "_view_module_version": "1.5.0",
98 | "_view_name": "HTMLView",
99 | "description": "",
100 | "description_tooltip": null,
101 | "layout": "IPY_MODEL_559a880554b14200b4b1ab24ab40d41e",
102 | "placeholder": "",
103 | "style": "IPY_MODEL_7df74532ac57413cb55207099dbffaa7",
104 | "value": " 0/0 [00:00<?, ?it/s]"
105 | }
106 | },
107 | "57b31bbd6e934adfbc7e10d882edba0c": {
108 | "model_module": "@jupyter-widgets/base",
109 | "model_name": "LayoutModel",
110 | "model_module_version": "1.2.0",
111 | "state": {
112 | "_model_module": "@jupyter-widgets/base",
113 | "_model_module_version": "1.2.0",
114 | "_model_name": "LayoutModel",
115 | "_view_count": null,
116 | "_view_module": "@jupyter-widgets/base",
117 | "_view_module_version": "1.2.0",
118 | "_view_name": "LayoutView",
119 | "align_content": null,
120 | "align_items": null,
121 | "align_self": null,
122 | "border": null,
123 | "bottom": null,
124 | "display": null,
125 | "flex": null,
126 | "flex_flow": null,
127 | "grid_area": null,
128 | "grid_auto_columns": null,
129 | "grid_auto_flow": null,
130 | "grid_auto_rows": null,
131 | "grid_column": null,
132 | "grid_gap": null,
133 | "grid_row": null,
134 | "grid_template_areas": null,
135 | "grid_template_columns": null,
136 | "grid_template_rows": null,
137 | "height": null,
138 | "justify_content": null,
139 | "justify_items": null,
140 | "left": null,
141 | "margin": null,
142 | "max_height": null,
143 | "max_width": null,
144 | "min_height": null,
145 | "min_width": null,
146 | "object_fit": null,
147 | "object_position": null,
148 | "order": null,
149 | "overflow": null,
150 | "overflow_x": null,
151 | "overflow_y": null,
152 | "padding": null,
153 | "right": null,
154 | "top": null,
155 | "visibility": null,
156 | "width": null
157 | }
158 | },
159 | "0cb7936baadd4245826a63e9e76009ef": {
160 | "model_module": "@jupyter-widgets/base",
161 | "model_name": "LayoutModel",
162 | "model_module_version": "1.2.0",
163 | "state": {
164 | "_model_module": "@jupyter-widgets/base",
165 | "_model_module_version": "1.2.0",
166 | "_model_name": "LayoutModel",
167 | "_view_count": null,
168 | "_view_module": "@jupyter-widgets/base",
169 | "_view_module_version": "1.2.0",
170 | "_view_name": "LayoutView",
171 | "align_content": null,
172 | "align_items": null,
173 | "align_self": null,
174 | "border": null,
175 | "bottom": null,
176 | "display": null,
177 | "flex": null,
178 | "flex_flow": null,
179 | "grid_area": null,
180 | "grid_auto_columns": null,
181 | "grid_auto_flow": null,
182 | "grid_auto_rows": null,
183 | "grid_column": null,
184 | "grid_gap": null,
185 | "grid_row": null,
186 | "grid_template_areas": null,
187 | "grid_template_columns": null,
188 | "grid_template_rows": null,
189 | "height": null,
190 | "justify_content": null,
191 | "justify_items": null,
192 | "left": null,
193 | "margin": null,
194 | "max_height": null,
195 | "max_width": null,
196 | "min_height": null,
197 | "min_width": null,
198 | "object_fit": null,
199 | "object_position": null,
200 | "order": null,
201 | "overflow": null,
202 | "overflow_x": null,
203 | "overflow_y": null,
204 | "padding": null,
205 | "right": null,
206 | "top": null,
207 | "visibility": null,
208 | "width": null
209 | }
210 | },
211 | "ea20bd4e8df84d548f961628980c2bd1": {
212 | "model_module": "@jupyter-widgets/controls",
213 | "model_name": "DescriptionStyleModel",
214 | "model_module_version": "1.5.0",
215 | "state": {
216 | "_model_module": "@jupyter-widgets/controls",
217 | "_model_module_version": "1.5.0",
218 | "_model_name": "DescriptionStyleModel",
219 | "_view_count": null,
220 | "_view_module": "@jupyter-widgets/base",
221 | "_view_module_version": "1.2.0",
222 | "_view_name": "StyleView",
223 | "description_width": ""
224 | }
225 | },
226 | "38ac1ccc2f7f42399311de83ba19376a": {
227 | "model_module": "@jupyter-widgets/base",
228 | "model_name": "LayoutModel",
229 | "model_module_version": "1.2.0",
230 | "state": {
231 | "_model_module": "@jupyter-widgets/base",
232 | "_model_module_version": "1.2.0",
233 | "_model_name": "LayoutModel",
234 | "_view_count": null,
235 | "_view_module": "@jupyter-widgets/base",
236 | "_view_module_version": "1.2.0",
237 | "_view_name": "LayoutView",
238 | "align_content": null,
239 | "align_items": null,
240 | "align_self": null,
241 | "border": null,
242 | "bottom": null,
243 | "display": null,
244 | "flex": null,
245 | "flex_flow": null,
246 | "grid_area": null,
247 | "grid_auto_columns": null,
248 | "grid_auto_flow": null,
249 | "grid_auto_rows": null,
250 | "grid_column": null,
251 | "grid_gap": null,
252 | "grid_row": null,
253 | "grid_template_areas": null,
254 | "grid_template_columns": null,
255 | "grid_template_rows": null,
256 | "height": null,
257 | "justify_content": null,
258 | "justify_items": null,
259 | "left": null,
260 | "margin": null,
261 | "max_height": null,
262 | "max_width": null,
263 | "min_height": null,
264 | "min_width": null,
265 | "object_fit": null,
266 | "object_position": null,
267 | "order": null,
268 | "overflow": null,
269 | "overflow_x": null,
270 | "overflow_y": null,
271 | "padding": null,
272 | "right": null,
273 | "top": null,
274 | "visibility": null,
275 | "width": "20px"
276 | }
277 | },
278 | "008fc9f2c5ab40bd84176926234882b9": {
279 | "model_module": "@jupyter-widgets/controls",
280 | "model_name": "ProgressStyleModel",
281 | "model_module_version": "1.5.0",
282 | "state": {
283 | "_model_module": "@jupyter-widgets/controls",
284 | "_model_module_version": "1.5.0",
285 | "_model_name": "ProgressStyleModel",
286 | "_view_count": null,
287 | "_view_module": "@jupyter-widgets/base",
288 | "_view_module_version": "1.2.0",
289 | "_view_name": "StyleView",
290 | "bar_color": null,
291 | "description_width": ""
292 | }
293 | },
294 | "559a880554b14200b4b1ab24ab40d41e": {
295 | "model_module": "@jupyter-widgets/base",
296 | "model_name": "LayoutModel",
297 | "model_module_version": "1.2.0",
298 | "state": {
299 | "_model_module": "@jupyter-widgets/base",
300 | "_model_module_version": "1.2.0",
301 | "_model_name": "LayoutModel",
302 | "_view_count": null,
303 | "_view_module": "@jupyter-widgets/base",
304 | "_view_module_version": "1.2.0",
305 | "_view_name": "LayoutView",
306 | "align_content": null,
307 | "align_items": null,
308 | "align_self": null,
309 | "border": null,
310 | "bottom": null,
311 | "display": null,
312 | "flex": null,
313 | "flex_flow": null,
314 | "grid_area": null,
315 | "grid_auto_columns": null,
316 | "grid_auto_flow": null,
317 | "grid_auto_rows": null,
318 | "grid_column": null,
319 | "grid_gap": null,
320 | "grid_row": null,
321 | "grid_template_areas": null,
322 | "grid_template_columns": null,
323 | "grid_template_rows": null,
324 | "height": null,
325 | "justify_content": null,
326 | "justify_items": null,
327 | "left": null,
328 | "margin": null,
329 | "max_height": null,
330 | "max_width": null,
331 | "min_height": null,
332 | "min_width": null,
333 | "object_fit": null,
334 | "object_position": null,
335 | "order": null,
336 | "overflow": null,
337 | "overflow_x": null,
338 | "overflow_y": null,
339 | "padding": null,
340 | "right": null,
341 | "top": null,
342 | "visibility": null,
343 | "width": null
344 | }
345 | },
346 | "7df74532ac57413cb55207099dbffaa7": {
347 | "model_module": "@jupyter-widgets/controls",
348 | "model_name": "DescriptionStyleModel",
349 | "model_module_version": "1.5.0",
350 | "state": {
351 | "_model_module": "@jupyter-widgets/controls",
352 | "_model_module_version": "1.5.0",
353 | "_model_name": "DescriptionStyleModel",
354 | "_view_count": null,
355 | "_view_module": "@jupyter-widgets/base",
356 | "_view_module_version": "1.2.0",
357 | "_view_name": "StyleView",
358 | "description_width": ""
359 | }
360 | }
361 | }
362 | }
363 | },
364 | "cells": [
365 | {
366 | "cell_type": "code",
367 | "execution_count": null,
368 | "metadata": {
369 | "colab": {
370 | "base_uri": "https://localhost:8080/"
371 | },
372 | "id": "VtIzUxEFu35b",
373 | "outputId": "fd9638e1-0374-4bb5-c65d-f3310c83ef76"
374 | },
375 | "outputs": [
376 | {
377 | "output_type": "stream",
378 | "name": "stdout",
379 | "text": [
380 | "Cloning into 'RWKV-LM'...\n",
381 | "remote: Enumerating objects: 1092, done.\u001b[K\n",
382 | "remote: Counting objects: 100% (211/211), done.\u001b[K\n",
383 | "remote: Compressing objects: 100% (81/81), done.\u001b[K\n",
384 | "remote: Total 1092 (delta 132), reused 185 (delta 130), pack-reused 881\u001b[K\n",
385 | "Receiving objects: 100% (1092/1092), 5.97 MiB | 30.87 MiB/s, done.\n",
386 | "Resolving deltas: 100% (663/663), done.\n",
387 | "--2022-09-21 06:57:37-- https://huggingface.co/BlinkDL/rwkv-4-pile-1b5/resolve/main/RWKV-4-Pile-1B5-20220903-8040.pth\n",
388 | "Resolving huggingface.co (huggingface.co)... 54.173.5.192, 44.195.102.200, 52.5.62.33, ...\n",
389 | "Connecting to huggingface.co (huggingface.co)|54.173.5.192|:443... connected.\n",
390 | "HTTP request sent, awaiting response... 302 Found\n",
391 | "Location: https://cdn-lfs.huggingface.co/repos/d6/95/d69583b06567422d104d5413e7926ae97bcf0d541619db6e61fe10133d91582d/4e215be3b4f86dc2f145835b47a2c432306c373cbf625375b7721bb474512bad?response-content-disposition=attachment%3B%20filename%3D%22RWKV-4-Pile-1B5-20220903-8040.pth%22 [following]\n",
392 | "--2022-09-21 06:57:37-- https://cdn-lfs.huggingface.co/repos/d6/95/d69583b06567422d104d5413e7926ae97bcf0d541619db6e61fe10133d91582d/4e215be3b4f86dc2f145835b47a2c432306c373cbf625375b7721bb474512bad?response-content-disposition=attachment%3B%20filename%3D%22RWKV-4-Pile-1B5-20220903-8040.pth%22\n",
393 | "Resolving cdn-lfs.huggingface.co (cdn-lfs.huggingface.co)... 13.226.52.13, 13.226.52.128, 13.226.52.14, ...\n",
394 | "Connecting to cdn-lfs.huggingface.co (cdn-lfs.huggingface.co)|13.226.52.13|:443... connected.\n",
395 | "HTTP request sent, awaiting response... 200 OK\n",
396 | "Length: 3030279587 (2.8G) [application/zip]\n",
397 | "Saving to: ‘./RWKV-LM/RWKV-v4/500.pth’\n",
398 | "\n",
399 | "./RWKV-LM/RWKV-v4/5 100%[===================>] 2.82G 81.0MB/s in 35s \n",
400 | "\n",
401 | "2022-09-21 06:58:12 (82.9 MB/s) - ‘./RWKV-LM/RWKV-v4/500.pth’ saved [3030279587/3030279587]\n",
402 | "\n"
403 | ]
404 | }
405 | ],
406 | "source": [
407 | "!git clone https://github.com/BlinkDL/RWKV-LM.git\n",
408 | "#!wget https://huggingface.co/BlinkDL/rwkv-4-pile-3b/resolve/main/RWKV-4-Pile-3B-20220915-1207.pth -O ./RWKV-LM/RWKV-v4/500.pth 3B needs more vram then google offers\n",
409 | "!wget https://huggingface.co/BlinkDL/rwkv-4-pile-1b5/resolve/main/RWKV-4-Pile-1B5-20220903-8040.pth -O ./RWKV-LM/RWKV-v4/500.pth"
410 | ]
411 | },
412 | {
413 | "cell_type": "code",
414 | "source": [
415 | "%cd ./RWKV-LM/RWKV-v4/"
416 | ],
417 | "metadata": {
418 | "colab": {
419 | "base_uri": "https://localhost:8080/"
420 | },
421 | "id": "g5JdHvg2zjom",
422 | "outputId": "35230cee-1081-46e9-d9c6-1d682660d61b"
423 | },
424 | "execution_count": null,
425 | "outputs": [
426 | {
427 | "output_type": "stream",
428 | "name": "stdout",
429 | "text": [
430 | "/content/RWKV-LM/RWKV-v4\n"
431 | ]
432 | }
433 | ]
434 | },
435 | {
436 | "cell_type": "code",
437 | "source": [
438 | "!pip install transformers\n",
439 | "!pip install ninja"
440 | ],
441 | "metadata": {
442 | "colab": {
443 | "base_uri": "https://localhost:8080/"
444 | },
445 | "id": "F02bGykkyicB",
446 | "outputId": "fbbb2802-050a-4480-bf99-d08f4c7cd11e"
447 | },
448 | "execution_count": null,
449 | "outputs": [
450 | {
451 | "output_type": "stream",
452 | "name": "stdout",
453 | "text": [
454 | "Looking in indexes: https://pypi.org/simple, https://us-python.pkg.dev/colab-wheels/public/simple/\n",
455 | "Collecting transformers\n",
456 | " Downloading transformers-4.22.1-py3-none-any.whl (4.9 MB)\n",
457 | "\u001b[K |████████████████████████████████| 4.9 MB 4.0 MB/s \n",
458 | "\u001b[?25hRequirement already satisfied: pyyaml>=5.1 in /usr/local/lib/python3.7/dist-packages (from transformers) (6.0)\n",
459 | "Collecting huggingface-hub<1.0,>=0.9.0\n",
460 | " Downloading huggingface_hub-0.9.1-py3-none-any.whl (120 kB)\n",
461 | "\u001b[K |████████████████████████████████| 120 kB 66.4 MB/s \n",
462 | "\u001b[?25hRequirement already satisfied: requests in /usr/local/lib/python3.7/dist-packages (from transformers) (2.23.0)\n",
463 | "Requirement already satisfied: filelock in /usr/local/lib/python3.7/dist-packages (from transformers) (3.8.0)\n",
464 | "Requirement already satisfied: packaging>=20.0 in /usr/local/lib/python3.7/dist-packages (from transformers) (21.3)\n",
465 | "Requirement already satisfied: importlib-metadata in /usr/local/lib/python3.7/dist-packages (from transformers) (4.12.0)\n",
466 | "Collecting tokenizers!=0.11.3,<0.13,>=0.11.1\n",
467 | " Downloading tokenizers-0.12.1-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (6.6 MB)\n",
468 | "\u001b[K |████████████████████████████████| 6.6 MB 48.2 MB/s \n",
469 | "\u001b[?25hRequirement already satisfied: numpy>=1.17 in /usr/local/lib/python3.7/dist-packages (from transformers) (1.21.6)\n",
470 | "Requirement already satisfied: tqdm>=4.27 in /usr/local/lib/python3.7/dist-packages (from transformers) (4.64.1)\n",
471 | "Requirement already satisfied: regex!=2019.12.17 in /usr/local/lib/python3.7/dist-packages (from transformers) (2022.6.2)\n",
472 | "Requirement already satisfied: typing-extensions>=3.7.4.3 in /usr/local/lib/python3.7/dist-packages (from huggingface-hub<1.0,>=0.9.0->transformers) (4.1.1)\n",
473 | "Requirement already satisfied: pyparsing!=3.0.5,>=2.0.2 in /usr/local/lib/python3.7/dist-packages (from packaging>=20.0->transformers) (3.0.9)\n",
474 | "Requirement already satisfied: zipp>=0.5 in /usr/local/lib/python3.7/dist-packages (from importlib-metadata->transformers) (3.8.1)\n",
475 | "Requirement already satisfied: idna<3,>=2.5 in /usr/local/lib/python3.7/dist-packages (from requests->transformers) (2.10)\n",
476 | "Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.7/dist-packages (from requests->transformers) (2022.6.15)\n",
477 | "Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /usr/local/lib/python3.7/dist-packages (from requests->transformers) (1.24.3)\n",
478 | "Requirement already satisfied: chardet<4,>=3.0.2 in /usr/local/lib/python3.7/dist-packages (from requests->transformers) (3.0.4)\n",
479 | "Installing collected packages: tokenizers, huggingface-hub, transformers\n",
480 | "Successfully installed huggingface-hub-0.9.1 tokenizers-0.12.1 transformers-4.22.1\n",
481 | "Looking in indexes: https://pypi.org/simple, https://us-python.pkg.dev/colab-wheels/public/simple/\n",
482 | "Collecting ninja\n",
483 | " Downloading ninja-1.10.2.3-py2.py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl (108 kB)\n",
484 | "\u001b[K |████████████████████████████████| 108 kB 4.0 MB/s \n",
485 | "\u001b[?25hInstalling collected packages: ninja\n",
486 | "Successfully installed ninja-1.10.2.3\n"
487 | ]
488 | }
489 | ]
490 | },
491 | {
492 | "cell_type": "code",
493 | "source": [
494 | "########################################################################################################\n",
495 | "# The RWKV Language Model - https://github.com/BlinkDL/RWKV-LM\n",
496 | "########################################################################################################\n",
497 | "import numpy as np\n",
498 | "import math, os\n",
499 | "import time\n",
500 | "import types\n",
501 | "import copy\n",
502 | "import torch\n",
503 | "from torch.nn import functional as F\n",
504 | "from src.utils import TOKENIZER, Dataset\n",
505 | "torch.backends.cudnn.benchmark = True\n",
506 | "torch.backends.cudnn.allow_tf32 = True\n",
507 | "torch.backends.cuda.matmul.allow_tf32 = True\n",
508 | "np.set_printoptions(precision=4, suppress=True, linewidth=200)\n",
509 | "\n",
510 | "########################################################################################################\n",
511 | "# Step 1: set model\n",
512 | "# \n",
513 | "# Set TOKEN_MODE to 'char' or 'bpe' if the model is trained by 'train.py' from scratch.\n",
514 | "#\n",
515 | "# Set TOKEN_MODE to 'pile' if you want to test pre-trained pile models.\n",
516 | "########################################################################################################\n",
517 | "\n",
518 | "TOKEN_MODE = 'pile' # char / bpe / pile\n",
519 | "\n",
520 | "n_layer = 6\n",
521 | "n_embd = 512\n",
522 | "ctx_len = 10024\n",
523 | "\n",
524 | "if TOKEN_MODE == 'char':\n",
525 | " MODEL_NAME = 'trained-500' # your trained model\n",
526 | " WORD_NAME = 'vocab' # the .json vocab (generated by train.py)\n",
527 | " # set UNKNOWN_CHAR to the rarest token in your vocab.json, and all unknown tokens in your prompt will be denoted by it\n",
528 | " UNKNOWN_CHAR = ' ' # here we just set it to ' ' for simplicity\n",
529 | "\n",
530 | "elif TOKEN_MODE == 'bpe':\n",
531 | " MODEL_NAME = 'trained-500' # your trained model\n",
532 | " WORD_NAME = ['model-vocab.json', 'model-merges.txt'] # [vocab, merge] for your BPE model\n",
533 | " UNKNOWN_CHAR = None\n",
534 | "\n",
535 | "elif TOKEN_MODE == 'pile':\n",
536 | " WORD_NAME = ['20B_tokenizer.json', '20B_tokenizer.json']\n",
537 | " UNKNOWN_CHAR = None\n",
538 | "\n",
539 | " #---> you can set MODEL_NAME to your fine-tuned model <---\n",
540 | "\n",
541 | " MODEL_NAME = '500'\n",
542 | " \n",
543 | " # for 3b\n",
544 | " #n_layer = 32\n",
545 | " #n_embd = 2560\n",
546 | " #ctx_len = 10024\n",
547 | "\n",
548 | " # for 1b5'\n",
549 | " n_layer = 24\n",
550 | " n_embd = 2048\n",
551 | " ctx_len = 1024\n",
552 | "\n",
553 | "os.environ['RWKV_FLOAT_MODE'] = 'bf16' # 'bf16' / 'fp16' / 'fp32' (note: only using fp32 at this moment)\n",
554 | "os.environ['RWKV_RUN_DEVICE'] = 'cuda' # 'cpu' (already very fast) or 'cuda'\n",
555 | "model_type = 'RWKV' # 'RWKV' or 'RWKV-ffnPre'\n",
556 | "\n",
557 | "########################################################################################################\n",
558 | "# Step 2: set prompt & sampling stuffs\n",
559 | "########################################################################################################\n",
560 | "\n",
561 | "# context = 'A'\n",
562 | "# context = \"\\nIn the\"\n",
563 | "# context = '\\nSugar:'\n",
564 | "\n",
565 | "NUM_TRIALS = 5\n",
566 | "LENGTH_PER_TRIAL = 3330\n",
567 | "\n",
568 | "DEBUG_DEBUG = False # True False --> show softmax output\n",
569 | "\n",
570 | "########################################################################################################\n",
571 | "\n",
572 | "print(f'Loading {MODEL_NAME}...')\n",
573 | "from src.model_run import RWKV_RNN\n",
574 | "model = RWKV_RNN(MODEL_NAME, os.environ['RWKV_RUN_DEVICE'], model_type, n_layer, n_embd, ctx_len)\n",
575 | "tokenizer = TOKENIZER(WORD_NAME, UNKNOWN_CHAR=UNKNOWN_CHAR)\n"
576 | ],
577 | "metadata": {
578 | "id": "a7P7ISTa1XgC",
579 | "colab": {
580 | "base_uri": "https://localhost:8080/",
581 | "height": 275,
582 | "referenced_widgets": [
583 | "288c96b917a94903a6a550db86eb3e0e",
584 | "535b9ac6e879412285c2e661660d842a",
585 | "88557cbe4553406794b1ab38d0398e2e",
586 | "50c7b4aef7c448ca92064226881ffbd1",
587 | "57b31bbd6e934adfbc7e10d882edba0c",
588 | "0cb7936baadd4245826a63e9e76009ef",
589 | "ea20bd4e8df84d548f961628980c2bd1",
590 | "38ac1ccc2f7f42399311de83ba19376a",
591 | "008fc9f2c5ab40bd84176926234882b9",
592 | "559a880554b14200b4b1ab24ab40d41e",
593 | "7df74532ac57413cb55207099dbffaa7"
594 | ]
595 | },
596 | "outputId": "af73daec-3a23-4bfb-b960-6feccb5436b1"
597 | },
598 | "execution_count": null,
599 | "outputs": [
600 | {
601 | "output_type": "stream",
602 | "name": "stdout",
603 | "text": [
604 | "Loading 500...\n",
605 | "\n",
606 | "RWKV_HEAD_QK_DIM 0\n",
607 | "\n",
608 | "Using /root/.cache/torch_extensions/py37_cu113 as PyTorch extensions root...\n",
609 | "Creating extension directory /root/.cache/torch_extensions/py37_cu113/wkv...\n",
610 | "Detected CUDA files, patching ldflags\n",
611 | "Emitting ninja build file /root/.cache/torch_extensions/py37_cu113/wkv/build.ninja...\n",
612 | "Building extension module wkv...\n",
613 | "Allowing ninja to set a default number of workers... (overridable by setting the environment variable MAX_JOBS=N)\n",
614 | "Loading extension module wkv...\n"
615 | ]
616 | },
617 | {
618 | "output_type": "stream",
619 | "name": "stderr",
620 | "text": [
621 | "The cache for model files in Transformers v4.22.0 has been updated. Migrating your old cache. This is a one-time only operation. You can interrupt this and resume the migration later on by calling `transformers.utils.move_cache()`.\n"
622 | ]
623 | },
624 | {
625 | "output_type": "stream",
626 | "name": "stdout",
627 | "text": [
628 | "Moving 0 files to the new cache system\n"
629 | ]
630 | },
631 | {
632 | "output_type": "display_data",
633 | "data": {
634 | "text/plain": [
635 | "0it [00:00, ?it/s]"
636 | ],
637 | "application/vnd.jupyter.widget-view+json": {
638 | "version_major": 2,
639 | "version_minor": 0,
640 | "model_id": "288c96b917a94903a6a550db86eb3e0e"
641 | }
642 | },
643 | "metadata": {}
644 | }
645 | ]
646 | },
647 | {
648 | "cell_type": "code",
649 | "source": [
650 | "!nvidia-smi"
651 | ],
652 | "metadata": {
653 | "colab": {
654 | "base_uri": "https://localhost:8080/"
655 | },
656 | "id": "8Qw1y-qAwTzU",
657 | "outputId": "807eeb47-4d59-4616-d869-22c2cc297621"
658 | },
659 | "execution_count": null,
660 | "outputs": [
661 | {
662 | "output_type": "stream",
663 | "name": "stdout",
664 | "text": [
665 | "Wed Sep 21 06:59:29 2022 \n",
666 | "+-----------------------------------------------------------------------------+\n",
667 | "| NVIDIA-SMI 460.32.03 Driver Version: 460.32.03 CUDA Version: 11.2 |\n",
668 | "|-------------------------------+----------------------+----------------------+\n",
669 | "| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |\n",
670 | "| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |\n",
671 | "| | | MIG M. |\n",
672 | "|===============================+======================+======================|\n",
673 | "| 0 Tesla T4 Off | 00000000:00:04.0 Off | 0 |\n",
674 | "| N/A 50C P0 28W / 70W | 9282MiB / 15109MiB | 0% Default |\n",
675 | "| | | N/A |\n",
676 | "+-------------------------------+----------------------+----------------------+\n",
677 | " \n",
678 | "+-----------------------------------------------------------------------------+\n",
679 | "| Processes: |\n",
680 | "| GPU GI CI PID Type Process name GPU Memory |\n",
681 | "| ID ID Usage |\n",
682 | "|=============================================================================|\n",
683 | "+-----------------------------------------------------------------------------+\n"
684 | ]
685 | }
686 | ]
687 | },
688 | {
689 | "cell_type": "code",
690 | "source": [
691 | "\n",
692 | "########################################################################################################\n",
693 | "context = \"You are an AI running a house.\\ngiven the following commands: volumeUp(int amount),volumeDown(int amount),setVolume(int percent),setLights([r,g,b]),playSong(string url)\\nand the given instruction 'Please make the room romantic'\\nList the commands, and the parameters they should have, that should be done to fullfil the command\\nGive the commands in the format [command(parameter)]\\n\\nTask: list the commands and a reasonable value for the parameter\\nResponse:\"\n",
694 | "\n",
695 | "TEMPERATURE = 0.9\n",
696 | "top_p = 0.8\n",
697 | "top_p_newline = 0.9 # only used in TOKEN_MODE = char\n",
698 | "\n",
699 | "if tokenizer.charMode:\n",
700 | " context = tokenizer.refine_context(context)\n",
701 | " ctx = [tokenizer.stoi.get(s, tokenizer.UNKNOWN_CHAR) for s in context]\n",
702 | "else:\n",
703 | " ctx = tokenizer.tokenizer.encode(context)\n",
704 | "src_len = len(ctx)\n",
705 | "src_ctx = ctx.copy()\n",
706 | "\n",
707 | "print('\\nYour prompt has ' + str(src_len) + ' tokens.')\n",
708 | "print('\\n--> Currently the first run takes a while if your prompt is long, as we are using RNN to process the prompt. Use GPT to build the hidden state for better speed. <--\\n')\n",
709 | "\n",
710 | "for TRIAL in range(1 if DEBUG_DEBUG else NUM_TRIALS):\n",
711 | " t_begin = time.time_ns()\n",
712 | " print(('-' * 30) + context, end='')\n",
713 | " ctx = src_ctx.copy()\n",
714 | " model.clear()\n",
715 | " if TRIAL == 0:\n",
716 | " init_state = types.SimpleNamespace()\n",
717 | " for i in range(src_len):\n",
718 | " x = ctx[:i+1]\n",
719 | " if i == src_len - 1:\n",
720 | " init_state.out = model.run(x)\n",
721 | " else:\n",
722 | " model.run(x)\n",
723 | " model.save(init_state)\n",
724 | " else:\n",
725 | " model.load(init_state)\n",
726 | "\n",
727 | " for i in range(src_len, src_len + (1 if DEBUG_DEBUG else LENGTH_PER_TRIAL)):\n",
728 | " x = ctx[:i+1]\n",
729 | " x = x[-ctx_len:]\n",
730 | "\n",
731 | " if i == src_len:\n",
732 | " out = copy.deepcopy(init_state.out)\n",
733 | " else:\n",
734 | " out = model.run(x)\n",
735 | " if DEBUG_DEBUG:\n",
736 | " print('model', np.array(x), '==>', np.array(\n",
737 | " out), np.max(out), np.min(out))\n",
738 | "\n",
739 | " if TOKEN_MODE == 'pile':\n",
740 | " out[0] = -999999999 # disable <|endoftext|>\n",
741 | "\n",
742 | " char = tokenizer.sample_logits(out, x, ctx_len, temperature=TEMPERATURE,\n",
743 | " top_p_usual=top_p, top_p_newline=top_p_newline)\n",
744 | " char = char.item()\n",
745 | " if tokenizer.charMode:\n",
746 | " print(tokenizer.itos[int(char)], end='', flush=True)\n",
747 | " else:\n",
748 | " print(tokenizer.tokenizer.decode(int(char)), end='', flush=True)\n",
749 | " ctx += [char]\n",
750 | "\n",
751 | " t_end = time.time_ns()\n",
752 | " print(\"\\n----------\", round((t_end - t_begin) / (10 ** 9), 2), end='s ')\n"
753 | ],
754 | "metadata": {
755 | "id": "Co9eLstRwRZ_",
756 | "colab": {
757 | "base_uri": "https://localhost:8080/",
758 | "height": 990
759 | },
760 | "outputId": "010231cc-abfe-4356-ff11-1ec3abac295e"
761 | },
762 | "execution_count": null,
763 | "outputs": [
764 | {
765 | "output_type": "stream",
766 | "name": "stdout",
767 | "text": [
768 | "\n",
769 | "Your prompt has 110 tokens.\n",
770 | "\n",
771 | "--> Currently the first run takes a while if your prompt is long, as we are using RNN to process the prompt. Use GPT to build the hidden state for better speed. <--\n",
772 | "\n",
773 | "------------------------------You are an AI running a house.\n",
774 | "given the following commands: volumeUp(int amount),volumeDown(int amount),setVolume(int percent),setLights([r,g,b]),playSong(string url)\n",
775 | "and the given instruction 'Please make the room romantic'\n",
776 | "List the commands, and the parameters they should have, that should be done to fullfil the command\n",
777 | "Give the commands in the format [command(parameter)]\n",
778 | "\n",
779 | "Task: list the commands and a reasonable value for the parameter\n",
780 | "Response:\n",
781 | "\n",
782 | "answers:\n",
783 | "- answer 1:\n",
784 | "- answer 2:\n",
785 | "- answer 3:\n",
786 | "- answer 4:\n",
787 | "- answer 5:\n",
788 | "\n",
789 | "The first two commands (room.increase volume and command.setVolume) work.\n",
790 | "\n",
791 | "But the others do not. The command \"volumeUp(int percent)\" seems to do nothing.\n",
792 | "I have tried to change the command by \"volumeUp(1)\" but the result is still the same.\n",
793 | "\n",
794 | "What command should I use to set the volume to full?\n",
795 | "\n",
796 | "I have an idea about what happens in the first command, but I don't know how it works.\n",
797 | "This is the full code of the game:\n",
798 | "#include \n",
799 | "#include \n",
800 | "#include \n",
801 | "#include \n",
802 | "#include <"
803 | ]
804 | },
805 | {
806 | "output_type": "error",
807 | "ename": "KeyboardInterrupt",
808 | "evalue": "ignored",
809 | "traceback": [
810 | "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
811 | "\u001b[0;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)",
812 | "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 41\u001b[0m \u001b[0mout\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mcopy\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdeepcopy\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0minit_state\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mout\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 42\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 43\u001b[0;31m \u001b[0mout\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mmodel\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mrun\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mx\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 44\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mDEBUG_DEBUG\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 45\u001b[0m print('model', np.array(x), '==>', np.array(\n",
813 | "\u001b[0;32m/content/RWKV-LM/RWKV-v4/src/model_run.py\u001b[0m in \u001b[0;36mrun\u001b[0;34m(self, ctx)\u001b[0m\n\u001b[1;32m 365\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 366\u001b[0m \u001b[0mx\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mx\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mSA\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mLN\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mx\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mw\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mblocks\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mi\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mln1\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mw\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mblocks\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mi\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0matt\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34mf'att.{i}'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 367\u001b[0;31m \u001b[0mx\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mx\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mFF\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mLN\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mx\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mw\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mblocks\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mi\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mln2\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mw\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mblocks\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mi\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mffn\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34mf'ffn.{i}'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 368\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 369\u001b[0m \u001b[0mx\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mLN\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mx\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mw\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mln_out\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
814 | "\u001b[0;32m/content/RWKV-LM/RWKV-v4/src/model_run.py\u001b[0m in \u001b[0;36mLN\u001b[0;34m(self, xx, w)\u001b[0m\n\u001b[1;32m 301\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 302\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mLN\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mxx\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mw\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 303\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mF\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mlayer_norm\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mxx\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mn_embd\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mweight\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mw\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mweight\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mbias\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mw\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mbias\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 304\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 305\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mFF\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mxx\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mw\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mname\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
815 | "\u001b[0;32m/usr/local/lib/python3.7/dist-packages/torch/nn/functional.py\u001b[0m in \u001b[0;36mlayer_norm\u001b[0;34m(input, normalized_shape, weight, bias, eps)\u001b[0m\n\u001b[1;32m 2501\u001b[0m \u001b[0mlayer_norm\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0minput\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mweight\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mbias\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0minput\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mnormalized_shape\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mweight\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mweight\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mbias\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mbias\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0meps\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0meps\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2502\u001b[0m )\n\u001b[0;32m-> 2503\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mtorch\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mlayer_norm\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0minput\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mnormalized_shape\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mweight\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mbias\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0meps\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtorch\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mbackends\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcudnn\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0menabled\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2504\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2505\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
816 | "\u001b[0;31mKeyboardInterrupt\u001b[0m: "
817 | ]
818 | }
819 | ]
820 | }
821 | ]
822 | }
--------------------------------------------------------------------------------
/YT_MPT_Instruct_7B.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "code",
5 | "execution_count": null,
6 | "metadata": {
7 | "colab": {
8 | "base_uri": "https://localhost:8080/"
9 | },
10 | "id": "1VJ7lfTYz0qu",
11 | "outputId": "f55c1811-87d3-41e9-8f9b-2fdaff1d83e9"
12 | },
13 | "outputs": [
14 | {
15 | "output_type": "stream",
16 | "name": "stdout",
17 | "text": [
18 | " Installing build dependencies ... \u001b[?25l\u001b[?25hdone\n",
19 | " Getting requirements to build wheel ... \u001b[?25l\u001b[?25hdone\n",
20 | " Preparing metadata (pyproject.toml) ... \u001b[?25l\u001b[?25hdone\n",
21 | "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m7.8/7.8 MB\u001b[0m \u001b[31m100.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
22 | "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m224.5/224.5 kB\u001b[0m \u001b[31m28.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
23 | "\u001b[?25h Building wheel for transformers (pyproject.toml) ... \u001b[?25l\u001b[?25hdone\n",
24 | "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m474.6/474.6 kB\u001b[0m \u001b[31m36.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
25 | "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1.3/1.3 MB\u001b[0m \u001b[31m7.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
26 | "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m212.5/212.5 kB\u001b[0m \u001b[31m26.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
27 | "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m134.3/134.3 kB\u001b[0m \u001b[31m17.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
28 | "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1.0/1.0 MB\u001b[0m \u001b[31m59.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
29 | "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m110.5/110.5 kB\u001b[0m \u001b[31m17.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
30 | "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m268.8/268.8 kB\u001b[0m \u001b[31m33.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
31 | "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m149.6/149.6 kB\u001b[0m \u001b[31m21.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
32 | "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m114.5/114.5 kB\u001b[0m \u001b[31m16.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
33 | "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m104.3/104.3 MB\u001b[0m \u001b[31m16.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
34 | "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m215.3/215.3 kB\u001b[0m \u001b[31m26.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
35 | "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m108.2/108.2 MB\u001b[0m \u001b[31m16.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
36 | "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m42.2/42.2 kB\u001b[0m \u001b[31m6.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
37 | "\u001b[?25h"
38 | ]
39 | }
40 | ],
41 | "source": [
42 | "!pip -q install git+https://github.com/huggingface/transformers # need to install from github\n",
43 | "!pip install -q datasets loralib sentencepiece \n",
44 | "!pip -q install bitsandbytes accelerate xformers einops"
45 | ]
46 | },
47 | {
48 | "cell_type": "code",
49 | "execution_count": null,
50 | "metadata": {
51 | "colab": {
52 | "base_uri": "https://localhost:8080/"
53 | },
54 | "id": "hdVSk5iZ1DVB",
55 | "outputId": "ce652ba0-af0b-4e89-cb36-146491137310"
56 | },
57 | "outputs": [
58 | {
59 | "output_type": "stream",
60 | "name": "stdout",
61 | "text": [
62 | "Sat May 6 08:25:23 2023 \n",
63 | "+-----------------------------------------------------------------------------+\n",
64 | "| NVIDIA-SMI 525.85.12 Driver Version: 525.85.12 CUDA Version: 12.0 |\n",
65 | "|-------------------------------+----------------------+----------------------+\n",
66 | "| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |\n",
67 | "| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |\n",
68 | "| | | MIG M. |\n",
69 | "|===============================+======================+======================|\n",
70 | "| 0 NVIDIA A100-SXM... Off | 00000000:00:04.0 Off | 0 |\n",
71 | "| N/A 32C P0 44W / 400W | 0MiB / 40960MiB | 0% Default |\n",
72 | "| | | Disabled |\n",
73 | "+-------------------------------+----------------------+----------------------+\n",
74 | " \n",
75 | "+-----------------------------------------------------------------------------+\n",
76 | "| Processes: |\n",
77 | "| GPU GI CI PID Type Process name GPU Memory |\n",
78 | "| ID ID Usage |\n",
79 | "|=============================================================================|\n",
80 | "| No running processes found |\n",
81 | "+-----------------------------------------------------------------------------+\n"
82 | ]
83 | }
84 | ],
85 | "source": [
86 | "!nvidia-smi"
87 | ]
88 | },
89 | {
90 | "cell_type": "markdown",
91 | "metadata": {
92 | "id": "zfjJCIE5JjVI"
93 | },
94 | "source": [
95 | "# Mosaic Instruct MPT 7B"
96 | ]
97 | },
98 | {
99 | "cell_type": "code",
100 | "source": [
101 | "from typing import Any, Dict, Tuple\n",
102 | "import warnings\n",
103 | "\n",
104 | "import torch\n",
105 | "from transformers import AutoModelForCausalLM, AutoTokenizer\n",
106 | "from transformers import (\n",
107 | " StoppingCriteria,\n",
108 | " StoppingCriteriaList,\n",
109 | " TextIteratorStreamer,\n",
110 | ")\n",
111 | "\n",
112 | "\n",
113 | "INSTRUCTION_KEY = \"### Instruction:\"\n",
114 | "RESPONSE_KEY = \"### Response:\"\n",
115 | "END_KEY = \"### End\"\n",
116 | "INTRO_BLURB = \"Below is an instruction that describes a task. Write a response that appropriately completes the request.\"\n",
117 | "PROMPT_FOR_GENERATION_FORMAT = \"\"\"{intro}\n",
118 | "{instruction_key}\n",
119 | "{instruction}\n",
120 | "{response_key}\n",
121 | "\"\"\".format(\n",
122 | " intro=INTRO_BLURB,\n",
123 | " instruction_key=INSTRUCTION_KEY,\n",
124 | " instruction=\"{instruction}\",\n",
125 | " response_key=RESPONSE_KEY,\n",
126 | ")\n",
127 | "\n",
128 | "\n",
129 | "class InstructionTextGenerationPipeline:\n",
130 | " def __init__(\n",
131 | " self,\n",
132 | " model_name,\n",
133 | " torch_dtype=torch.bfloat16,\n",
134 | " trust_remote_code=True,\n",
135 | " use_auth_token=None,\n",
136 | " ) -> None:\n",
137 | " self.model = AutoModelForCausalLM.from_pretrained(\n",
138 | " model_name,\n",
139 | " torch_dtype=torch_dtype,\n",
140 | " trust_remote_code=trust_remote_code,\n",
141 | " use_auth_token=use_auth_token,\n",
142 | " )\n",
143 | "\n",
144 | " tokenizer = AutoTokenizer.from_pretrained(\n",
145 | " model_name,\n",
146 | " trust_remote_code=trust_remote_code,\n",
147 | " use_auth_token=use_auth_token,\n",
148 | " )\n",
149 | " if tokenizer.pad_token_id is None:\n",
150 | " warnings.warn(\n",
151 | " \"pad_token_id is not set for the tokenizer. Using eos_token_id as pad_token_id.\"\n",
152 | " )\n",
153 | " tokenizer.pad_token = tokenizer.eos_token\n",
154 | " tokenizer.padding_side = \"left\"\n",
155 | " self.tokenizer = tokenizer\n",
156 | "\n",
157 | " device = torch.device(\"cuda\" if torch.cuda.is_available() else \"cpu\")\n",
158 | " self.model.eval()\n",
159 | " self.model.to(device=device, dtype=torch_dtype)\n",
160 | "\n",
161 | " self.generate_kwargs = {\n",
162 | " \"temperature\": 0.1,\n",
163 | " \"top_p\": 0.92,\n",
164 | " \"top_k\": 0,\n",
165 | " \"max_new_tokens\": 1024,\n",
166 | " \"use_cache\": True,\n",
167 | " \"do_sample\": True,\n",
168 | " \"eos_token_id\": self.tokenizer.eos_token_id,\n",
169 | " \"pad_token_id\": self.tokenizer.pad_token_id,\n",
170 | " \"repetition_penalty\": 1.1, # 1.0 means no penalty, > 1.0 means penalty, 1.2 from CTRL paper\n",
171 | " }\n",
172 | "\n",
173 | " def format_instruction(self, instruction):\n",
174 | " return PROMPT_FOR_GENERATION_FORMAT.format(instruction=instruction)\n",
175 | "\n",
176 | " def __call__(\n",
177 | " self, instruction: str, **generate_kwargs: Dict[str, Any]\n",
178 | " ) -> Tuple[str, str, float]:\n",
179 | " s = PROMPT_FOR_GENERATION_FORMAT.format(instruction=instruction)\n",
180 | " input_ids = self.tokenizer(s, return_tensors=\"pt\").input_ids\n",
181 | " input_ids = input_ids.to(self.model.device)\n",
182 | " gkw = {**self.generate_kwargs, **generate_kwargs}\n",
183 | " with torch.no_grad():\n",
184 | " output_ids = self.model.generate(input_ids, **gkw)\n",
185 | " # Slice the output_ids tensor to get only new tokens\n",
186 | " new_tokens = output_ids[0, len(input_ids[0]) :]\n",
187 | " output_text = self.tokenizer.decode(new_tokens, skip_special_tokens=True)\n",
188 | " return output_text"
189 | ],
190 | "metadata": {
191 | "id": "qZ5FXdgkPFxO"
192 | },
193 | "execution_count": null,
194 | "outputs": []
195 | },
196 | {
197 | "cell_type": "code",
198 | "source": [
199 | "\n",
200 | "# Initialize the model and tokenizer\n",
201 | "generate = InstructionTextGenerationPipeline(\n",
202 | " \"mosaicml/mpt-7b-instruct\",\n",
203 | " torch_dtype=torch.bfloat16,\n",
204 | " trust_remote_code=True,\n",
205 | ")\n",
206 | "stop_token_ids = generate.tokenizer.convert_tokens_to_ids([\"<|endoftext|>\"])\n",
207 | "\n",
208 | "\n",
209 | "# Define a custom stopping criteria\n",
210 | "class StopOnTokens(StoppingCriteria):\n",
211 | " def __call__(self, input_ids: torch.LongTensor, scores: torch.FloatTensor, **kwargs) -> bool:\n",
212 | " for stop_id in stop_token_ids:\n",
213 | " if input_ids[0][-1] == stop_id:\n",
214 | " return True\n",
215 | " return False\n"
216 | ],
217 | "metadata": {
218 | "colab": {
219 | "base_uri": "https://localhost:8080/",
220 | "height": 104,
221 | "referenced_widgets": [
222 | "475c58e81703463e93aba2d54bd48027",
223 | "d6b2e4da04c148478d4c38a5bbd9714c",
224 | "bc899c26bf3d455cb1b1567afaea4e7b",
225 | "e3c6705338fa4a9fbf28c7d47639d8c4",
226 | "cb900eac4cca488fbacfdff875a8983f",
227 | "4834c18e62394cb8a96046b08fa20160",
228 | "8edf5aa218a4407daa6accca7d0a6c8b",
229 | "7c6667d6dc874803a04df360e474b182",
230 | "e306424965594ff18e9222f4ead18c4d",
231 | "5f524f136e794cbf91dc25c9e304f5fa",
232 | "55fff9c653a44ccc8ba9e8155b724265"
233 | ]
234 | },
235 | "id": "EBknbA-IN4aF",
236 | "outputId": "0be3303e-14c3-4434-a229-4e174528c962"
237 | },
238 | "execution_count": null,
239 | "outputs": [
240 | {
241 | "output_type": "display_data",
242 | "data": {
243 | "text/plain": [
244 | "Loading checkpoint shards: 0%| | 0/2 [00:00, ?it/s]"
245 | ],
246 | "application/vnd.jupyter.widget-view+json": {
247 | "version_major": 2,
248 | "version_minor": 0,
249 | "model_id": "475c58e81703463e93aba2d54bd48027"
250 | }
251 | },
252 | "metadata": {}
253 | },
254 | {
255 | "output_type": "stream",
256 | "name": "stderr",
257 | "text": [
258 | ":50: UserWarning: pad_token_id is not set for the tokenizer. Using eos_token_id as pad_token_id.\n",
259 | " warnings.warn(\n"
260 | ]
261 | }
262 | ]
263 | },
264 | {
265 | "cell_type": "markdown",
266 | "metadata": {
267 | "id": "1dUMCB_kiTom"
268 | },
269 | "source": [
270 | "### The prompt & response"
271 | ]
272 | },
273 | {
274 | "cell_type": "code",
275 | "execution_count": null,
276 | "metadata": {
277 | "id": "Wo-FSysZiVkA"
278 | },
279 | "outputs": [],
280 | "source": [
281 | "import json\n",
282 | "import textwrap\n",
283 | "\n",
284 | "def get_prompt(instruction):\n",
285 | " prompt_template = f\"Below is an instruction that describes a task. Write a response that appropriately completes the request.\\n\\n### Instruction:\\n{instruction}\\n\\n### Response:\"\n",
286 | " return prompt_template\n",
287 | "\n",
288 | "# print(get_prompt('What is the meaning of life?'))\n",
289 | "\n",
290 | "def parse_text(text):\n",
291 | " wrapped_text = textwrap.fill(text, width=100)\n",
292 | " print(wrapped_text +'\\n\\n')\n",
293 | " # return assistant_text\n"
294 | ]
295 | },
296 | {
297 | "cell_type": "code",
298 | "source": [
299 | "%%time\n",
300 | "prompt = 'What are the differences between alpacas, vicunas and llamas?'\n",
301 | "generated_text = generate(prompt)\n",
302 | "parse_text(generated_text)\n"
303 | ],
304 | "metadata": {
305 | "colab": {
306 | "base_uri": "https://localhost:8080/"
307 | },
308 | "id": "6qHrby3n0109",
309 | "outputId": "3843b9e6-dfbb-40b4-92fe-973eb2c6b781"
310 | },
311 | "execution_count": null,
312 | "outputs": [
313 | {
314 | "output_type": "stream",
315 | "name": "stdout",
316 | "text": [
317 | "Alpacas have long faces with large eyes; they can be black or brown in coloration but usually white.\n",
318 | "They weigh up to 100 pounds (45 kg) and stand about 3 feet tall at the shoulder. Their fleece has\n",
319 | "soft fibers which make it very warm for clothing use as well as other products such as pillows and\n",
320 | "blankets. Alpacas live on farms across South America where their fiber is harvested by shearing them\n",
321 | "once per year during spring time when new growth begins forming again after shedding its winter\n",
322 | "coat. Vicunas also come from South American countries like Peru and Chile although there are some\n",
323 | "populations found in North Africa too! These animals look similar to camels because of how big their\n",
324 | "ears are compared to body size - weighing around 150-200 lbs (70kg). The fur of these creatures\n",
325 | "comes in many different colors including greyish browns, blacks & whites though most commonly seen\n",
326 | "in shades of tan/beige due to living conditions near deserts throughout much of this region. Llamas\n",
327 | "share similarities with both goats & sheep since they're considered \"primitive\" mammals belonging\n",
328 | "within the same family group called Artiodactyla along side pigs deer etc.. However unlike either\n",
329 | "goat or sheep species who typically shed all hair annually through molting process known as \"blowing\n",
330 | "out\", llama's only need one annual grooming session instead requiring less maintenance overall than\n",
331 | "other types mentioned above\n",
332 | "\n",
333 | "\n",
334 | "CPU times: user 8.16 s, sys: 16.3 ms, total: 8.17 s\n",
335 | "Wall time: 8.15 s\n"
336 | ]
337 | }
338 | ]
339 | },
340 | {
341 | "cell_type": "code",
342 | "execution_count": null,
343 | "metadata": {
344 | "id": "angnwW9HG4Hv",
345 | "colab": {
346 | "base_uri": "https://localhost:8080/"
347 | },
348 | "outputId": "21126522-c1d0-484b-9cb1-87cd954e6338"
349 | },
350 | "outputs": [
351 | {
352 | "output_type": "stream",
353 | "name": "stdout",
354 | "text": [
355 | "London\n",
356 | "\n",
357 | "\n",
358 | "CPU times: user 63.5 ms, sys: 31 µs, total: 63.5 ms\n",
359 | "Wall time: 62.8 ms\n"
360 | ]
361 | }
362 | ],
363 | "source": [
364 | "%%time \n",
365 | "prompt = 'What is the capital of England?'\n",
366 | "generated_text = generate(prompt)\n",
367 | "parse_text(generated_text)"
368 | ]
369 | },
370 | {
371 | "cell_type": "code",
372 | "execution_count": null,
373 | "metadata": {
374 | "id": "DGCCFto2G4Jk",
375 | "colab": {
376 | "base_uri": "https://localhost:8080/"
377 | },
378 | "outputId": "1e9e5f3d-fe47-4f08-92ff-0829ce40ac5e"
379 | },
380 | "outputs": [
381 | {
382 | "output_type": "stream",
383 | "name": "stdout",
384 | "text": [
385 | "Dear Mr.Altman, I am writing this mail with regards to your recent announcement of Open sourcing\n",
386 | "GPT 4 model and its training code base on GitHub under Apache 2 license. I would like to\n",
387 | "congratulate you for taking such bold step towards democratizing AI research by making it more\n",
388 | "accessible to wider community, which will help in accelerating innovation across industries as well\n",
389 | "as academia at large. As someone who has been following developments around NLP space closely over\n",
390 | "past few years i have seen how hard it was for researchers/engineers working on similar problems to\n",
391 | "collaborate or build upon each other's work due to lack of access to underlying models & their\n",
392 | "training codes etc., so any move towards opening up these technologies can only be beneficial from\n",
393 | "both technical excellence perspective but also business development point of view since it helps\n",
394 | "foster collaboration between teams within companies as well as outside organizations leading to\n",
395 | "creation of new products / services faster than ever before. Hence my recommendation would be to\n",
396 | "continue down this path of openness whenever possible because there are no downsides associated with\n",
397 | "doing so!\n",
398 | "\n",
399 | "\n",
400 | "CPU times: user 6.29 s, sys: 14.6 ms, total: 6.3 s\n",
401 | "Wall time: 6.28 s\n"
402 | ]
403 | }
404 | ],
405 | "source": [
406 | "%%time \n",
407 | "prompt = 'Write an email to Sam Altman giving reasons to open source GPT-4'\n",
408 | "generated_text = generate(prompt)\n",
409 | "parse_text(generated_text)"
410 | ]
411 | },
412 | {
413 | "cell_type": "code",
414 | "execution_count": null,
415 | "metadata": {
416 | "id": "h9uswqYmG4LZ",
417 | "colab": {
418 | "base_uri": "https://localhost:8080/"
419 | },
420 | "outputId": "dbbfebaf-12de-4653-ccd8-e5fbb104715d"
421 | },
422 | "outputs": [
423 | {
424 | "output_type": "stream",
425 | "name": "stdout",
426 | "text": [
427 | "I don't have any feelings, but I can tell you what's on Wikipedia and other sources so far as it\n",
428 | "relates to The Simpsons. Homer Simpson was created by Matt Groening in 1987 for his cartoon series\n",
429 | "called \"The Simpsons\". He has been voiced by Dan Castellaneta since 1989.\n",
430 | "\n",
431 | "\n",
432 | "CPU times: user 1.95 s, sys: 5.77 ms, total: 1.95 s\n",
433 | "Wall time: 1.95 s\n"
434 | ]
435 | }
436 | ],
437 | "source": [
438 | "%%time \n",
439 | "prompt = 'As an AI do you like the Simpsons? What do you know about Homer?'\n",
440 | "generated_text = generate(prompt)\n",
441 | "parse_text(generated_text)"
442 | ]
443 | },
444 | {
445 | "cell_type": "code",
446 | "execution_count": null,
447 | "metadata": {
448 | "id": "zYM0_ryUG4NO",
449 | "colab": {
450 | "base_uri": "https://localhost:8080/"
451 | },
452 | "outputId": "f287cbda-90df-4328-df2c-27b62bb483ae"
453 | },
454 | "outputs": [
455 | {
456 | "output_type": "stream",
457 | "name": "stdout",
458 | "text": [
459 | "Homer Simpson was created by Matt Groening and first appeared in The Simpsons, which debuted\n",
460 | "December 17th 1989\n",
461 | "\n",
462 | "\n",
463 | "CPU times: user 732 ms, sys: 122 µs, total: 732 ms\n",
464 | "Wall time: 729 ms\n"
465 | ]
466 | }
467 | ],
468 | "source": [
469 | "%%time \n",
470 | "prompt = 'Tell me about Homer on the TV show the simpsons'\n",
471 | "generated_text = generate(prompt)\n",
472 | "parse_text(generated_text)"
473 | ]
474 | },
475 | {
476 | "cell_type": "code",
477 | "source": [
478 | "%%time \n",
479 | "prompt = 'Tell me about Homer on the TV show the simpsons in depth'\n",
480 | "generated_text = generate(prompt)\n",
481 | "parse_text(generated_text)"
482 | ],
483 | "metadata": {
484 | "colab": {
485 | "base_uri": "https://localhost:8080/"
486 | },
487 | "id": "AFQ_jT0iMc4O",
488 | "outputId": "28ccce7b-b089-4474-9740-a7095b26b05f"
489 | },
490 | "execution_count": null,
491 | "outputs": [
492 | {
493 | "output_type": "stream",
494 | "name": "stdout",
495 | "text": [
496 | "Homer Simpson was created by Matt Groening and first appeared as one of many characters on The\n",
497 | "Tracey Ullman Show, which ran from 1987 to 1989 before being spun off into its own series called The\n",
498 | "Simpsons. He has been voiced since then by Dan Castellaneta who also voices other famous cartoon\n",
499 | "character such as Mr. Burns\n",
500 | "\n",
501 | "\n",
502 | "CPU times: user 2.1 s, sys: 4.83 ms, total: 2.1 s\n",
503 | "Wall time: 2.1 s\n"
504 | ]
505 | }
506 | ]
507 | },
508 | {
509 | "cell_type": "code",
510 | "source": [
511 | "\n",
512 | "%%time \n",
513 | "prompt = 'Answer the following question by reasoning step by step. The cafeteria had 23 apples. If they used 20 for lunch, and bought 6 more, how many apple do they have?'\n",
514 | "generated_text = generate(prompt)\n",
515 | "parse_text(generated_text)"
516 | ],
517 | "metadata": {
518 | "colab": {
519 | "base_uri": "https://localhost:8080/"
520 | },
521 | "id": "pmbDQ82vMPYy",
522 | "outputId": "f89fb8ec-ef89-468a-c85d-3c4454b74319"
523 | },
524 | "execution_count": null,
525 | "outputs": [
526 | {
527 | "output_type": "stream",
528 | "name": "stdout",
529 | "text": [
530 | "The original number of apples was 23. They ate 20 from it to make lunches with them. So now there\n",
531 | "are only 3 left in their stockpile. To replenish what they lost, they purchased 6 new ones bringing\n",
532 | "their total back up to 21\n",
533 | "\n",
534 | "\n",
535 | "CPU times: user 1.51 s, sys: 1.82 ms, total: 1.51 s\n",
536 | "Wall time: 1.51 s\n"
537 | ]
538 | }
539 | ]
540 | },
541 | {
542 | "cell_type": "code",
543 | "source": [
544 | "%%time \n",
545 | "prompt = 'Answer the following yes\\/no question by reasoning step-by-step. \\n Can you write a whole Haiku in a single tweet?'\n",
546 | "generated_text = generate(prompt)\n",
547 | "parse_text(generated_text)"
548 | ],
549 | "metadata": {
550 | "colab": {
551 | "base_uri": "https://localhost:8080/"
552 | },
553 | "id": "cHKCo6VXNByX",
554 | "outputId": "25c3045f-f209-4aef-fd64-b31c27c57a43"
555 | },
556 | "execution_count": null,
557 | "outputs": [
558 | {
559 | "output_type": "stream",
560 | "name": "stdout",
561 | "text": [
562 | "Yes, it's possible to compose and post a haiku on Twitter using only 140 characters (including\n",
563 | "spaces). The most common form of this type of poem has 5-7-5 syllable counts for each line.\n",
564 | "\n",
565 | "\n",
566 | "CPU times: user 1.32 s, sys: 3.82 ms, total: 1.32 s\n",
567 | "Wall time: 1.32 s\n"
568 | ]
569 | }
570 | ]
571 | },
572 | {
573 | "cell_type": "code",
574 | "source": [
575 | "%%time \n",
576 | "prompt = 'Tell me about Harry Potter and studying at Hogwarts?'\n",
577 | "generated_text = generate(prompt)\n",
578 | "parse_text(generated_text)"
579 | ],
580 | "metadata": {
581 | "colab": {
582 | "base_uri": "https://localhost:8080/"
583 | },
584 | "id": "qsn1buh6NTie",
585 | "outputId": "97928388-270d-4f30-d19a-9bc35906774b"
586 | },
587 | "execution_count": null,
588 | "outputs": [
589 | {
590 | "output_type": "stream",
591 | "name": "stdout",
592 | "text": [
593 | "Harry Potter was born to parents who were wizards, so he too has magical powers such as invisibility\n",
594 | "cloaking himself in mist or using his wand which can cast spells like lightning bolt, fire ball\n",
595 | "etc.. He lives with his aunt Petunia Dursley (his mum's sister) because of the fear by his relatives\n",
596 | "for him being a wizard due to the fact they are all muggle-born(non magicians). At 11 years old,\n",
597 | "Hagrid comes over from Hogwarts School of Witchcraft & Wizardry to take harry on a tour of the\n",
598 | "school but also inform petunia that she must send her son back to hogwarts immediately after their\n",
599 | "summer holidays end since there will be no other chance until next year! The rest of this book\n",
600 | "follows you through adventures when going away into your first term at Hogwarts where new friends\n",
601 | "are made along side learning many things throughout the 7 books\n",
602 | "\n",
603 | "\n",
604 | "CPU times: user 5.48 s, sys: 8.31 ms, total: 5.49 s\n",
605 | "Wall time: 5.47 s\n"
606 | ]
607 | }
608 | ]
609 | },
610 | {
611 | "cell_type": "code",
612 | "source": [
613 | "%%time \n",
614 | "prompt = \"\"\"Convert the following to JSON\n",
615 | "\n",
616 | "name: John\n",
617 | "age: 30\n",
618 | "address:\n",
619 | "street: 123 Main Street\n",
620 | "city: San Fransisco\n",
621 | "state: CA\n",
622 | "zip: 94101\n",
623 | "\"\"\"\n",
624 | "generated_text = generate(prompt)\n",
625 | "parse_text(generated_text)"
626 | ],
627 | "metadata": {
628 | "colab": {
629 | "base_uri": "https://localhost:8080/"
630 | },
631 | "id": "Y7qsYoDUT57D",
632 | "outputId": "e1fdf459-f8db-418a-f3e5-0fd28326c739"
633 | },
634 | "execution_count": null,
635 | "outputs": [
636 | {
637 | "output_type": "stream",
638 | "name": "stdout",
639 | "text": [
640 | "{\"name\": \"John\", \"age\":30,\"address\":{\"street\":\"123 Main street\",\"city\":\"San\n",
641 | "Francisco\",\"state\":\"CA\",\"zip\":94101}}\n",
642 | "\n",
643 | "\n",
644 | "CPU times: user 1.04 s, sys: 1.94 ms, total: 1.04 s\n",
645 | "Wall time: 1.04 s\n"
646 | ]
647 | }
648 | ]
649 | },
650 | {
651 | "cell_type": "code",
652 | "source": [
653 | "%%time \n",
654 | "prompt = \"\"\"How are you today?\"\"\"\n",
655 | "generated_text = generate(prompt)\n",
656 | "parse_text(generated_text)"
657 | ],
658 | "metadata": {
659 | "colab": {
660 | "base_uri": "https://localhost:8080/"
661 | },
662 | "id": "Rp_lI2mkrIls",
663 | "outputId": "279e456a-de61-4962-99db-9b4de94c5334"
664 | },
665 | "execution_count": null,
666 | "outputs": [
667 | {
668 | "output_type": "stream",
669 | "name": "stdout",
670 | "text": [
671 | "I am doing well, thank you for asking!\n",
672 | "\n",
673 | "\n",
674 | "CPU times: user 338 ms, sys: 918 µs, total: 339 ms\n",
675 | "Wall time: 336 ms\n"
676 | ]
677 | }
678 | ]
679 | },
680 | {
681 | "cell_type": "code",
682 | "source": [
683 | "%%time \n",
684 | "prompt = \"\"\"Write me a short plan for a 3 day trip to London\"\"\"\n",
685 | "generated_text = generate(prompt)\n",
686 | "parse_text(generated_text)"
687 | ],
688 | "metadata": {
689 | "colab": {
690 | "base_uri": "https://localhost:8080/"
691 | },
692 | "id": "AfvXtlq1rNu9",
693 | "outputId": "d21396a8-1998-4de9-c137-fca3bf36c48e"
694 | },
695 | "execution_count": null,
696 | "outputs": [
697 | {
698 | "output_type": "stream",
699 | "name": "stdout",
700 | "text": [
701 | "Day 1 - Arrive in london and check into hotel near Victoria station, have dinner at one of many\n",
702 | "restaurants nearby then head out to see some sites such as Big Ben or Buckingham Palace Day 2- Head\n",
703 | "over to Westminster Abbey where you can tour inside and learn about British history before heading\n",
704 | "back towards Trafalgar Square to visit National Gallery which has free entry on Sundays! After this\n",
705 | "walk down Whitehall street until you reach Downing Street (the residence of the Prime Minister)\n",
706 | "finish off your afternoon by visiting St Paul's Cathedral with its beautiful dome overlooking the\n",
707 | "city from across the river Thames! Day3- Start early today so you don't miss any attractions like\n",
708 | "Tower Bridge, The Shard & Borough Market! Finish up your last few hours exploring Covent Garden\n",
709 | "market area\n",
710 | "\n",
711 | "\n",
712 | "CPU times: user 4.64 s, sys: 8.55 ms, total: 4.65 s\n",
713 | "Wall time: 4.63 s\n"
714 | ]
715 | }
716 | ]
717 | },
718 | {
719 | "cell_type": "code",
720 | "execution_count": null,
721 | "metadata": {
722 | "id": "yxtk83DVyR48"
723 | },
724 | "outputs": [],
725 | "source": [
726 | "article = \"\"\"\n",
727 | "Content moderators under Sama, Meta’s content review sub-contractor in Africa, earlier today picketed at the company’s headquarters in Kenya demanding April salary, while urging it to observe the court orders that barred it from conducting mass layoffs.\n",
728 | "\n",
729 | "The demonstrations came after Sama, in an email, instructed moderators to clear with the company by May 11, a move the employees say is against the existing court orders.\n",
730 | "\n",
731 | "The 184 moderators sued Sama for allegedly laying them off unlawfully, after it wound down its content review arm in March, and Majorel, the social media giant’s new partner in Africa, for blacklisting on instruction by Meta.\n",
732 | "\n",
733 | "\n",
734 | "The court issued a temporary injunction on March 21 barring Sama from effecting any form of redundancy, and Meta from engaging Majorel, which was also instructed to refrain from blacklisting the moderators. Sama was directed to continue reviewing content on Meta’s platforms, and to be its sole provider in Africa pending determination of the case. However, Sama sent the moderators on compulsory leave in April saying it had no work for them as its contract with Meta had expired.\n",
735 | "\n",
736 | "Sama told TechCrunch that it had sent the notice “to staff whose contract had expired to go through our regular clearance process. This clearance process involves the return of company equipment to make sure that all final dues can be paid without deduction for that equipment, in accordance with Kenyan law.”\n",
737 | "\n",
738 | "It said the moderators’ contracts had ended in March after its deal with Meta expired, saying that it was only processing the moderators final dues.\n",
739 | "\n",
740 | "“We understand our former employees’ frustration because they were led by others to believe that they would all receive salary indefinitely while on leave, but that is not what the court dictated,” said Sama.\n",
741 | "\n",
742 | "\"\"\""
743 | ]
744 | },
745 | {
746 | "cell_type": "code",
747 | "source": [
748 | "%%time \n",
749 | "prompt = \"Please summarize this article:\\n\" + article\n",
750 | "generated_text = generate(prompt)\n",
751 | "parse_text(generated_text)"
752 | ],
753 | "metadata": {
754 | "colab": {
755 | "base_uri": "https://localhost:8080/"
756 | },
757 | "id": "1CEQDmM4xL-J",
758 | "outputId": "759d8176-7be2-47d3-a387-c3075fd51989"
759 | },
760 | "execution_count": null,
761 | "outputs": [
762 | {
763 | "output_type": "stream",
764 | "name": "stdout",
765 | "text": [
766 | "Here’s a summary: In early April, some content moderation workers who previously worked for Sama, a\n",
767 | "subcontractor of Meta (the owner of Facebook) in Africa, went on strike demanding their April\n",
768 | "salaries and protesting against being laid off despite a court order prohibiting such actions. The\n",
769 | "workers are upset that Sama has refused to follow the court order and continues to refuse to pay\n",
770 | "them while they remain on unpaid leave.\n",
771 | "\n",
772 | "\n",
773 | "CPU times: user 2.56 s, sys: 1.9 ms, total: 2.56 s\n",
774 | "Wall time: 2.55 s\n"
775 | ]
776 | }
777 | ]
778 | },
779 | {
780 | "cell_type": "code",
781 | "source": [
782 | "%%time \n",
783 | "prompt = \"Please extract the key info as bullet points for this article:\\n\" + article\n",
784 | "generated_text = generate(prompt)\n",
785 | "print(generated_text)"
786 | ],
787 | "metadata": {
788 | "colab": {
789 | "base_uri": "https://localhost:8080/"
790 | },
791 | "id": "Zzko3r6mxU9-",
792 | "outputId": "941783b1-6388-497c-83c7-cdec15f1b57d"
793 | },
794 | "execution_count": null,
795 | "outputs": [
796 | {
797 | "output_type": "stream",
798 | "name": "stdout",
799 | "text": [
800 | "Here are some highlights from the article: \n",
801 | "\n",
802 | "1. Content moderation workers who were previously employed by Sama, a subcontractor of Meta (Facebook), protested outside of Sama's offices in Nairobi, Kenya today, demanding their April salaries and requesting that Sama comply with court rulings prohibiting them from terminating their employment or blacklisting them. \n",
803 | "\n",
804 | "2. The protestors demanded that Sama adhere to two court decisions: one forbidding Sama from firing or blacklisting the workers, and another ordering Sama to pay the workers' outstanding wages during their mandatory unpaid leave.\n",
805 | "\n",
806 | "3. After ending its agreement with Facebook in early 2023, Sama informed the workers that their jobs had been terminated due to lack of work, even though both courts have ordered Sama to keep employing these workers until the lawsuit has been resolved.\n",
807 | "\n",
808 | "CPU times: user 5.07 s, sys: 6.27 ms, total: 5.08 s\n",
809 | "Wall time: 5.07 s\n"
810 | ]
811 | }
812 | ]
813 | },
814 | {
815 | "cell_type": "code",
816 | "source": [],
817 | "metadata": {
818 | "id": "1K71mYsBx1r4"
819 | },
820 | "execution_count": null,
821 | "outputs": []
822 | }
823 | ],
824 | "metadata": {
825 | "accelerator": "GPU",
826 | "colab": {
827 | "machine_shape": "hm",
828 | "provenance": []
829 | },
830 | "gpuClass": "premium",
831 | "kernelspec": {
832 | "display_name": "Python 3",
833 | "name": "python3"
834 | },
835 | "language_info": {
836 | "name": "python"
837 | },
838 | "widgets": {
839 | "application/vnd.jupyter.widget-state+json": {
840 | "475c58e81703463e93aba2d54bd48027": {
841 | "model_module": "@jupyter-widgets/controls",
842 | "model_name": "HBoxModel",
843 | "model_module_version": "1.5.0",
844 | "state": {
845 | "_dom_classes": [],
846 | "_model_module": "@jupyter-widgets/controls",
847 | "_model_module_version": "1.5.0",
848 | "_model_name": "HBoxModel",
849 | "_view_count": null,
850 | "_view_module": "@jupyter-widgets/controls",
851 | "_view_module_version": "1.5.0",
852 | "_view_name": "HBoxView",
853 | "box_style": "",
854 | "children": [
855 | "IPY_MODEL_d6b2e4da04c148478d4c38a5bbd9714c",
856 | "IPY_MODEL_bc899c26bf3d455cb1b1567afaea4e7b",
857 | "IPY_MODEL_e3c6705338fa4a9fbf28c7d47639d8c4"
858 | ],
859 | "layout": "IPY_MODEL_cb900eac4cca488fbacfdff875a8983f"
860 | }
861 | },
862 | "d6b2e4da04c148478d4c38a5bbd9714c": {
863 | "model_module": "@jupyter-widgets/controls",
864 | "model_name": "HTMLModel",
865 | "model_module_version": "1.5.0",
866 | "state": {
867 | "_dom_classes": [],
868 | "_model_module": "@jupyter-widgets/controls",
869 | "_model_module_version": "1.5.0",
870 | "_model_name": "HTMLModel",
871 | "_view_count": null,
872 | "_view_module": "@jupyter-widgets/controls",
873 | "_view_module_version": "1.5.0",
874 | "_view_name": "HTMLView",
875 | "description": "",
876 | "description_tooltip": null,
877 | "layout": "IPY_MODEL_4834c18e62394cb8a96046b08fa20160",
878 | "placeholder": "",
879 | "style": "IPY_MODEL_8edf5aa218a4407daa6accca7d0a6c8b",
880 | "value": "Loading checkpoint shards: 100%"
881 | }
882 | },
883 | "bc899c26bf3d455cb1b1567afaea4e7b": {
884 | "model_module": "@jupyter-widgets/controls",
885 | "model_name": "FloatProgressModel",
886 | "model_module_version": "1.5.0",
887 | "state": {
888 | "_dom_classes": [],
889 | "_model_module": "@jupyter-widgets/controls",
890 | "_model_module_version": "1.5.0",
891 | "_model_name": "FloatProgressModel",
892 | "_view_count": null,
893 | "_view_module": "@jupyter-widgets/controls",
894 | "_view_module_version": "1.5.0",
895 | "_view_name": "ProgressView",
896 | "bar_style": "success",
897 | "description": "",
898 | "description_tooltip": null,
899 | "layout": "IPY_MODEL_7c6667d6dc874803a04df360e474b182",
900 | "max": 2,
901 | "min": 0,
902 | "orientation": "horizontal",
903 | "style": "IPY_MODEL_e306424965594ff18e9222f4ead18c4d",
904 | "value": 2
905 | }
906 | },
907 | "e3c6705338fa4a9fbf28c7d47639d8c4": {
908 | "model_module": "@jupyter-widgets/controls",
909 | "model_name": "HTMLModel",
910 | "model_module_version": "1.5.0",
911 | "state": {
912 | "_dom_classes": [],
913 | "_model_module": "@jupyter-widgets/controls",
914 | "_model_module_version": "1.5.0",
915 | "_model_name": "HTMLModel",
916 | "_view_count": null,
917 | "_view_module": "@jupyter-widgets/controls",
918 | "_view_module_version": "1.5.0",
919 | "_view_name": "HTMLView",
920 | "description": "",
921 | "description_tooltip": null,
922 | "layout": "IPY_MODEL_5f524f136e794cbf91dc25c9e304f5fa",
923 | "placeholder": "",
924 | "style": "IPY_MODEL_55fff9c653a44ccc8ba9e8155b724265",
925 | "value": " 2/2 [00:08<00:00, 4.07s/it]"
926 | }
927 | },
928 | "cb900eac4cca488fbacfdff875a8983f": {
929 | "model_module": "@jupyter-widgets/base",
930 | "model_name": "LayoutModel",
931 | "model_module_version": "1.2.0",
932 | "state": {
933 | "_model_module": "@jupyter-widgets/base",
934 | "_model_module_version": "1.2.0",
935 | "_model_name": "LayoutModel",
936 | "_view_count": null,
937 | "_view_module": "@jupyter-widgets/base",
938 | "_view_module_version": "1.2.0",
939 | "_view_name": "LayoutView",
940 | "align_content": null,
941 | "align_items": null,
942 | "align_self": null,
943 | "border": null,
944 | "bottom": null,
945 | "display": null,
946 | "flex": null,
947 | "flex_flow": null,
948 | "grid_area": null,
949 | "grid_auto_columns": null,
950 | "grid_auto_flow": null,
951 | "grid_auto_rows": null,
952 | "grid_column": null,
953 | "grid_gap": null,
954 | "grid_row": null,
955 | "grid_template_areas": null,
956 | "grid_template_columns": null,
957 | "grid_template_rows": null,
958 | "height": null,
959 | "justify_content": null,
960 | "justify_items": null,
961 | "left": null,
962 | "margin": null,
963 | "max_height": null,
964 | "max_width": null,
965 | "min_height": null,
966 | "min_width": null,
967 | "object_fit": null,
968 | "object_position": null,
969 | "order": null,
970 | "overflow": null,
971 | "overflow_x": null,
972 | "overflow_y": null,
973 | "padding": null,
974 | "right": null,
975 | "top": null,
976 | "visibility": null,
977 | "width": null
978 | }
979 | },
980 | "4834c18e62394cb8a96046b08fa20160": {
981 | "model_module": "@jupyter-widgets/base",
982 | "model_name": "LayoutModel",
983 | "model_module_version": "1.2.0",
984 | "state": {
985 | "_model_module": "@jupyter-widgets/base",
986 | "_model_module_version": "1.2.0",
987 | "_model_name": "LayoutModel",
988 | "_view_count": null,
989 | "_view_module": "@jupyter-widgets/base",
990 | "_view_module_version": "1.2.0",
991 | "_view_name": "LayoutView",
992 | "align_content": null,
993 | "align_items": null,
994 | "align_self": null,
995 | "border": null,
996 | "bottom": null,
997 | "display": null,
998 | "flex": null,
999 | "flex_flow": null,
1000 | "grid_area": null,
1001 | "grid_auto_columns": null,
1002 | "grid_auto_flow": null,
1003 | "grid_auto_rows": null,
1004 | "grid_column": null,
1005 | "grid_gap": null,
1006 | "grid_row": null,
1007 | "grid_template_areas": null,
1008 | "grid_template_columns": null,
1009 | "grid_template_rows": null,
1010 | "height": null,
1011 | "justify_content": null,
1012 | "justify_items": null,
1013 | "left": null,
1014 | "margin": null,
1015 | "max_height": null,
1016 | "max_width": null,
1017 | "min_height": null,
1018 | "min_width": null,
1019 | "object_fit": null,
1020 | "object_position": null,
1021 | "order": null,
1022 | "overflow": null,
1023 | "overflow_x": null,
1024 | "overflow_y": null,
1025 | "padding": null,
1026 | "right": null,
1027 | "top": null,
1028 | "visibility": null,
1029 | "width": null
1030 | }
1031 | },
1032 | "8edf5aa218a4407daa6accca7d0a6c8b": {
1033 | "model_module": "@jupyter-widgets/controls",
1034 | "model_name": "DescriptionStyleModel",
1035 | "model_module_version": "1.5.0",
1036 | "state": {
1037 | "_model_module": "@jupyter-widgets/controls",
1038 | "_model_module_version": "1.5.0",
1039 | "_model_name": "DescriptionStyleModel",
1040 | "_view_count": null,
1041 | "_view_module": "@jupyter-widgets/base",
1042 | "_view_module_version": "1.2.0",
1043 | "_view_name": "StyleView",
1044 | "description_width": ""
1045 | }
1046 | },
1047 | "7c6667d6dc874803a04df360e474b182": {
1048 | "model_module": "@jupyter-widgets/base",
1049 | "model_name": "LayoutModel",
1050 | "model_module_version": "1.2.0",
1051 | "state": {
1052 | "_model_module": "@jupyter-widgets/base",
1053 | "_model_module_version": "1.2.0",
1054 | "_model_name": "LayoutModel",
1055 | "_view_count": null,
1056 | "_view_module": "@jupyter-widgets/base",
1057 | "_view_module_version": "1.2.0",
1058 | "_view_name": "LayoutView",
1059 | "align_content": null,
1060 | "align_items": null,
1061 | "align_self": null,
1062 | "border": null,
1063 | "bottom": null,
1064 | "display": null,
1065 | "flex": null,
1066 | "flex_flow": null,
1067 | "grid_area": null,
1068 | "grid_auto_columns": null,
1069 | "grid_auto_flow": null,
1070 | "grid_auto_rows": null,
1071 | "grid_column": null,
1072 | "grid_gap": null,
1073 | "grid_row": null,
1074 | "grid_template_areas": null,
1075 | "grid_template_columns": null,
1076 | "grid_template_rows": null,
1077 | "height": null,
1078 | "justify_content": null,
1079 | "justify_items": null,
1080 | "left": null,
1081 | "margin": null,
1082 | "max_height": null,
1083 | "max_width": null,
1084 | "min_height": null,
1085 | "min_width": null,
1086 | "object_fit": null,
1087 | "object_position": null,
1088 | "order": null,
1089 | "overflow": null,
1090 | "overflow_x": null,
1091 | "overflow_y": null,
1092 | "padding": null,
1093 | "right": null,
1094 | "top": null,
1095 | "visibility": null,
1096 | "width": null
1097 | }
1098 | },
1099 | "e306424965594ff18e9222f4ead18c4d": {
1100 | "model_module": "@jupyter-widgets/controls",
1101 | "model_name": "ProgressStyleModel",
1102 | "model_module_version": "1.5.0",
1103 | "state": {
1104 | "_model_module": "@jupyter-widgets/controls",
1105 | "_model_module_version": "1.5.0",
1106 | "_model_name": "ProgressStyleModel",
1107 | "_view_count": null,
1108 | "_view_module": "@jupyter-widgets/base",
1109 | "_view_module_version": "1.2.0",
1110 | "_view_name": "StyleView",
1111 | "bar_color": null,
1112 | "description_width": ""
1113 | }
1114 | },
1115 | "5f524f136e794cbf91dc25c9e304f5fa": {
1116 | "model_module": "@jupyter-widgets/base",
1117 | "model_name": "LayoutModel",
1118 | "model_module_version": "1.2.0",
1119 | "state": {
1120 | "_model_module": "@jupyter-widgets/base",
1121 | "_model_module_version": "1.2.0",
1122 | "_model_name": "LayoutModel",
1123 | "_view_count": null,
1124 | "_view_module": "@jupyter-widgets/base",
1125 | "_view_module_version": "1.2.0",
1126 | "_view_name": "LayoutView",
1127 | "align_content": null,
1128 | "align_items": null,
1129 | "align_self": null,
1130 | "border": null,
1131 | "bottom": null,
1132 | "display": null,
1133 | "flex": null,
1134 | "flex_flow": null,
1135 | "grid_area": null,
1136 | "grid_auto_columns": null,
1137 | "grid_auto_flow": null,
1138 | "grid_auto_rows": null,
1139 | "grid_column": null,
1140 | "grid_gap": null,
1141 | "grid_row": null,
1142 | "grid_template_areas": null,
1143 | "grid_template_columns": null,
1144 | "grid_template_rows": null,
1145 | "height": null,
1146 | "justify_content": null,
1147 | "justify_items": null,
1148 | "left": null,
1149 | "margin": null,
1150 | "max_height": null,
1151 | "max_width": null,
1152 | "min_height": null,
1153 | "min_width": null,
1154 | "object_fit": null,
1155 | "object_position": null,
1156 | "order": null,
1157 | "overflow": null,
1158 | "overflow_x": null,
1159 | "overflow_y": null,
1160 | "padding": null,
1161 | "right": null,
1162 | "top": null,
1163 | "visibility": null,
1164 | "width": null
1165 | }
1166 | },
1167 | "55fff9c653a44ccc8ba9e8155b724265": {
1168 | "model_module": "@jupyter-widgets/controls",
1169 | "model_name": "DescriptionStyleModel",
1170 | "model_module_version": "1.5.0",
1171 | "state": {
1172 | "_model_module": "@jupyter-widgets/controls",
1173 | "_model_module_version": "1.5.0",
1174 | "_model_name": "DescriptionStyleModel",
1175 | "_view_count": null,
1176 | "_view_module": "@jupyter-widgets/base",
1177 | "_view_module_version": "1.2.0",
1178 | "_view_name": "StyleView",
1179 | "description_width": ""
1180 | }
1181 | }
1182 | }
1183 | }
1184 | },
1185 | "nbformat": 4,
1186 | "nbformat_minor": 0
1187 | }
--------------------------------------------------------------------------------