File size: 23,664 Bytes
07a9d86
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2023-04-23T12:41:35.677838Z",
     "start_time": "2023-04-23T12:41:31.958031Z"
    }
   },
   "outputs": [],
   "source": [
    "from transformers import AutoTokenizer, AutoModelForCausalLM\n",
    "\n",
    "tokenizer = AutoTokenizer.from_pretrained(\"EleutherAI/gpt-j-6B\")\n",
    "\n",
    "tokenizer.pad_token = tokenizer.eos_token\n",
    "tokenizer.pad_token_id = tokenizer.eos_token_id"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# GPT-J\n",
    "\n",
    "Najpier sprawdźmy jak radzi sobie goły GPT-J"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from peft import PeftModel\n",
    "from transformers import AutoTokenizer, GPTJForCausalLM, GenerationConfig\n",
    "\n",
    "model = GPTJForCausalLM.from_pretrained(\n",
    "    \"EleutherAI/gpt-j-6B\",\n",
    "    load_in_8bit=True,\n",
    "    device_map=\"auto\",\n",
    ")\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "GPTJForCausalLM(\n",
       "  (transformer): GPTJModel(\n",
       "    (wte): Embedding(50400, 4096)\n",
       "    (drop): Dropout(p=0.0, inplace=False)\n",
       "    (h): ModuleList(\n",
       "      (0-27): 28 x GPTJBlock(\n",
       "        (ln_1): LayerNorm((4096,), eps=1e-05, elementwise_affine=True)\n",
       "        (attn): GPTJAttention(\n",
       "          (attn_dropout): Dropout(p=0.0, inplace=False)\n",
       "          (resid_dropout): Dropout(p=0.0, inplace=False)\n",
       "          (k_proj): Linear(in_features=4096, out_features=4096, bias=False)\n",
       "          (v_proj): Linear(in_features=4096, out_features=4096, bias=False)\n",
       "          (q_proj): Linear(in_features=4096, out_features=4096, bias=False)\n",
       "          (out_proj): Linear(in_features=4096, out_features=4096, bias=False)\n",
       "        )\n",
       "        (mlp): GPTJMLP(\n",
       "          (fc_in): Linear(in_features=4096, out_features=16384, bias=True)\n",
       "          (fc_out): Linear(in_features=16384, out_features=4096, bias=True)\n",
       "          (act): NewGELUActivation()\n",
       "          (dropout): Dropout(p=0.0, inplace=False)\n",
       "        )\n",
       "      )\n",
       "    )\n",
       "    (ln_f): LayerNorm((4096,), eps=1e-05, elementwise_affine=True)\n",
       "  )\n",
       "  (lm_head): Linear(in_features=4096, out_features=50400, bias=True)\n",
       ")"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "model"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "def owca_generate(text):\n",
    "    inputs = tokenizer(\n",
    "        text,\n",
    "        return_tensors=\"pt\",\n",
    "    )\n",
    "    input_ids = inputs[\"input_ids\"].cuda()\n",
    "\n",
    "    generation_config = GenerationConfig(\n",
    "        temperature=0.6,\n",
    "        top_p=0.95,\n",
    "        repetition_penalty=1.2,\n",
    "    )\n",
    "\n",
    "    print(\"Generating...\")\n",
    "    generation_output = model.generate(\n",
    "        input_ids=input_ids,\n",
    "        generation_config=generation_config,\n",
    "        return_dict_in_generate=True,\n",
    "        output_scores=True,\n",
    "        max_new_tokens=128,\n",
    "        pad_token_id = 0,\n",
    "        eos_token_id = 50256\n",
    "    )\n",
    "\n",
    "    for s in generation_output.sequences:\n",
    "        print(tokenizer.decode(s))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Generating...\n",
      "poniżej znajduje się instrukcja, która opisuje zadanie. Napisz odpowiedź, która odpowiednio uzupełnia żądanie.\n",
      "### Instrukcja:\n",
      "Jaka jest różnica pomiędzy alpaką i owcą?\n",
      "### Odpowiedź:\n",
      "Ponieważ alpa to nazwisko gatunku ptaków a owca to rodzina ptaszek.\n",
      "\n",
      "<|endoftext|>\n",
      "CPU times: user 2.39 s, sys: 423 ms, total: 2.81 s\n",
      "Wall time: 2.78 s\n"
     ]
    }
   ],
   "source": [
    "PROMPT = \"\"\"poniżej znajduje się instrukcja, która opisuje zadanie. Napisz odpowiedź, która odpowiednio uzupełnia żądanie.\n",
    "### Instrukcja:\n",
    "Jaka jest różnica pomiędzy alpaką i owcą?\n",
    "### Odpowiedź:\"\"\"\n",
    "%%time\n",
    "owca_generate(PROMPT)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Generating...\n",
      "Below is an instruction that describes a task. Write a response that appropriately completes the request.\n",
      "### Instruction:\n",
      "What are the differences between alpacas and sheep?\n",
      "### Response:\n",
      "Alpaca's have longer legs than sheep, they also have more hair on their bodies. Alpaca's can be found in many different colors including white, black, brown, red, blue, green, etc... Sheep can only be found in one color which is usually gray or tan. They do not have as much hair on them as alpaca's but it does grow very fast. The difference between these two animals is mainly how long their legs are and what kind of fur grows on their body.\n",
      "## Lesson 3 - Grammar Rules for Writing Sentences with Verbs\n",
      "In this lesson you will learn\n",
      "CPU times: user 5.76 s, sys: 31.7 ms, total: 5.79 s\n",
      "Wall time: 5.78 s\n"
     ]
    }
   ],
   "source": [
    "%%time\n",
    "PROMPT = \"\"\"Below is an instruction that describes a task. Write a response that appropriately completes the request.\n",
    "### Instruction:\n",
    "What are the differences between alpacas and sheep?\n",
    "### Response:\"\"\"\n",
    "owca_generate(PROMPT)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Generating...\n",
      "poniżej znajduje się instrukcja, która opisuje zadanie. Napisz odpowiedź, która odpowiednio uzupełnia żądanie.\n",
      "### Instrukcja:\n",
      "Napisz funkcję w pythonie, która sprawdza czty dana liczba jest pierwsza.\n",
      "### Odpowiedź:\n",
      "```python\n",
      "def is_first(x):\n",
      "  return x == 1\n",
      "```\n",
      "\n",
      "<|endoftext|>\n",
      "CPU times: user 1.08 s, sys: 4.95 ms, total: 1.09 s\n",
      "Wall time: 1.08 s\n"
     ]
    }
   ],
   "source": [
    "%%time\n",
    "PROMPT = \"\"\"poniżej znajduje się instrukcja, która opisuje zadanie. Napisz odpowiedź, która odpowiednio uzupełnia żądanie.\n",
    "### Instrukcja:\n",
    "Napisz funkcję w pythonie, która sprawdza czty dana liczba jest pierwsza.\n",
    "### Odpowiedź:\"\"\"\n",
    "\n",
    "owca_generate(PROMPT)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Generating...\n",
      "Below is an instruction that describes a task. Write a response that appropriately completes the request.\n",
      "### Instruction:\n",
      "Write me a python function that checks if a number is prime.\n",
      "### Response:\n",
      "def check_prime(n):\n",
      "    \"\"\"Check whether n is prime or not.\"\"\"\n",
      "\n",
      "    # Check for divisibility by 2, 3 and 5.\n",
      "    if (2*n) % n == 0: return False\n",
      "    elif (3*n) % n == 0: return True\n",
      "    else: return False\n",
      "\n",
      "<|endoftext|>\n"
     ]
    }
   ],
   "source": [
    "PROMPT = \"\"\"Below is an instruction that describes a task. Write a response that appropriately completes the request.\n",
    "### Instruction:\n",
    "Write me a python function that checks if a number is prime.\n",
    "### Response:\"\"\"\n",
    "owca_generate(PROMPT)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Generating...\n",
      "poniżej znajduje się instrukcja, która opisuje zadanie. Napisz odpowiedź, która odpowiednio uzupełnia żądanie.\n",
      "### Instrukcja:\n",
      "Napisz email wyjaśniający dlaczego GPT-4 powinien być open source.\n",
      "### Odpowiedź:\n",
      "```text\n",
      "Greetings! I am the maintainer of this project and would like to help you with your request. Please provide me a link or file that contains information about why it should be made available as an Open Source Project. Thank You for contributing to our community!\n",
      "```\n",
      "\n",
      "<|endoftext|>\n",
      "CPU times: user 2.96 s, sys: 6.11 ms, total: 2.97 s\n",
      "Wall time: 2.97 s\n"
     ]
    }
   ],
   "source": [
    "%%time\n",
    "PROMPT = \"\"\"poniżej znajduje się instrukcja, która opisuje zadanie. Napisz odpowiedź, która odpowiednio uzupełnia żądanie.\n",
    "### Instrukcja:\n",
    "Napisz email wyjaśniający dlaczego GPT-4 powinien być open source.\n",
    "### Odpowiedź:\"\"\"\n",
    "owca_generate(PROMPT)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Generating...\n",
      "Below is an instruction that describes a task. Write a response that appropriately completes the request.\n",
      "### Instruction:\n",
      "Write an email explaining why GPT-4 should be open source.\n",
      "### Response:\n",
      "GPT-4 has been released as Open Source Software under GPLv3 license, and it's available at https://github.com/gpt-lang/gpt-4. The main reason for releasing this project as Open Source software is to make sure everyone can use it freely without any restrictions. This will also help us improve our code base by getting feedback from users on how we could do better in future releases of gpt-4. \n",
      "\n",
      "<|endoftext|>\n",
      "CPU times: user 4.13 s, sys: 900 µs, total: 4.13 s\n",
      "Wall time: 4.13 s\n"
     ]
    }
   ],
   "source": [
    "%%time\n",
    "PROMPT = \"\"\"Below is an instruction that describes a task. Write a response that appropriately completes the request.\n",
    "### Instruction:\n",
    "Write an email explaining why GPT-4 should be open source.\n",
    "### Response:\"\"\"\n",
    "owca_generate(PROMPT)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# OWCA\n",
    "\n",
    "Sprawdźmy jak z tymi samymi promptami radzi sobie owca"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "from peft import PeftModel\n",
    "from transformers import AutoTokenizer, GPTJForCausalLM, GenerationConfig\n",
    "\n",
    "model = GPTJForCausalLM.from_pretrained(\n",
    "    \"EleutherAI/gpt-j-6B\",\n",
    "#     load_in_8bit=True,\n",
    "    device_map=\"auto\",\n",
    ")\n",
    "model = PeftModel.from_pretrained(model, \"./gptj6b-lora-owca\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "PeftModelForCausalLM(\n",
       "  (base_model): LoraModel(\n",
       "    (model): GPTJForCausalLM(\n",
       "      (transformer): GPTJModel(\n",
       "        (wte): Embedding(50400, 4096)\n",
       "        (drop): Dropout(p=0.0, inplace=False)\n",
       "        (h): ModuleList(\n",
       "          (0-27): 28 x GPTJBlock(\n",
       "            (ln_1): LayerNorm((4096,), eps=1e-05, elementwise_affine=True)\n",
       "            (attn): GPTJAttention(\n",
       "              (attn_dropout): Dropout(p=0.0, inplace=False)\n",
       "              (resid_dropout): Dropout(p=0.0, inplace=False)\n",
       "              (k_proj): Linear(in_features=4096, out_features=4096, bias=False)\n",
       "              (v_proj): Linear(\n",
       "                in_features=4096, out_features=4096, bias=False\n",
       "                (lora_dropout): ModuleDict(\n",
       "                  (default): Dropout(p=0.05, inplace=False)\n",
       "                )\n",
       "                (lora_A): ModuleDict(\n",
       "                  (default): Linear(in_features=4096, out_features=4, bias=False)\n",
       "                )\n",
       "                (lora_B): ModuleDict(\n",
       "                  (default): Linear(in_features=4, out_features=4096, bias=False)\n",
       "                )\n",
       "              )\n",
       "              (q_proj): Linear(\n",
       "                in_features=4096, out_features=4096, bias=False\n",
       "                (lora_dropout): ModuleDict(\n",
       "                  (default): Dropout(p=0.05, inplace=False)\n",
       "                )\n",
       "                (lora_A): ModuleDict(\n",
       "                  (default): Linear(in_features=4096, out_features=4, bias=False)\n",
       "                )\n",
       "                (lora_B): ModuleDict(\n",
       "                  (default): Linear(in_features=4, out_features=4096, bias=False)\n",
       "                )\n",
       "              )\n",
       "              (out_proj): Linear(in_features=4096, out_features=4096, bias=False)\n",
       "            )\n",
       "            (mlp): GPTJMLP(\n",
       "              (fc_in): Linear(in_features=4096, out_features=16384, bias=True)\n",
       "              (fc_out): Linear(in_features=16384, out_features=4096, bias=True)\n",
       "              (act): NewGELUActivation()\n",
       "              (dropout): Dropout(p=0.0, inplace=False)\n",
       "            )\n",
       "          )\n",
       "        )\n",
       "        (ln_f): LayerNorm((4096,), eps=1e-05, elementwise_affine=True)\n",
       "      )\n",
       "      (lm_head): Linear(in_features=4096, out_features=50400, bias=True)\n",
       "    )\n",
       "  )\n",
       ")"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "model"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Generating...\n",
      "poniżej znajduje się instrukcja, która opisuje zadanie. Napisz odpowiedź, która odpowiednio uzupełnia żądanie.\n",
      "### Instrukcja:\n",
      "Jaka jest różnica pomiędzy alpaką i owcą?\n",
      "### Odpowiedź:\n",
      "Alpa to gatunek ptaków, a Owca to rodzina ptaszek. Alpacami nazywa się ich wszechobecnego przedstawiciela na Ziemi - szczególnie dla naszej grupy, mamy do czynienia ze Szwedami. Wspaniałym narzędziem poznawczym oraz ekscytującem sportem było ono stosunkowo nowoczesnym samol\n",
      "CPU times: user 6.53 s, sys: 491 ms, total: 7.02 s\n",
      "Wall time: 6.99 s\n"
     ]
    }
   ],
   "source": [
    "%%time\n",
    "PROMPT = \"\"\"poniżej znajduje się instrukcja, która opisuje zadanie. Napisz odpowiedź, która odpowiednio uzupełnia żądanie.\n",
    "### Instrukcja:\n",
    "Jaka jest różnica pomiędzy alpaką i owcą?\n",
    "### Odpowiedź:\"\"\"\n",
    "owca_generate(PROMPT)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Generating...\n",
      "Below is an instruction that describes a task. Write a response that appropriately completes the request.\n",
      "### Instruction:\n",
      "What are the differences between alpacas and sheep?\n",
      "### Response:\n",
      "Alpaca's have longer legs than sheep, but they don't grow wool like sheep do. Alpaca's also tend to be more docile than sheep.\n",
      "## Lesson 4 - The Importance of Grammar in Writing\n",
      "In this lesson you will learn about how grammar affects your writing. You'll see examples of correct usage as well as incorrect usages. By learning these rules for proper English use, you can improve your own written communication skills.\n",
      "Grammar refers to the structure or arrangement of words within sentences. It includes such things as word order, sentence construction, punctuation, capitalization, spelling\n",
      "CPU times: user 5.92 s, sys: 39.6 ms, total: 5.96 s\n",
      "Wall time: 5.95 s\n"
     ]
    }
   ],
   "source": [
    "%%time\n",
    "PROMPT = \"\"\"Below is an instruction that describes a task. Write a response that appropriately completes the request.\n",
    "### Instruction:\n",
    "What are the differences between alpacas and sheep?\n",
    "### Response:\"\"\"\n",
    "owca_generate(PROMPT)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Generating...\n",
      "poniżej znajduje się instrukcja, która opisuje zadanie. Napisz odpowiedź, która odpowiednio uzupełnia żądanie.\n",
      "### Instrukcja:\n",
      "Napisz funkcję w pythonie, która sprawdza czty dana liczba jest pierwsza.\n",
      "### Odpowiedź:\n",
      "Funkcja \"first_digit\" przyznaje wartość 1 do nazwy argumentu na podstawie ciągu szesnastego wewnątrz listy lub tablicy. Jeśli argument to biblioteka, ona pobiera jej nazwę i skompiluje go. Funkcja można uruchomić poprzez stosując metodę exec(). Wskańczony program powinien być\n",
      "CPU times: user 5.75 s, sys: 0 ns, total: 5.75 s\n",
      "Wall time: 5.74 s\n"
     ]
    }
   ],
   "source": [
    "%%time\n",
    "PROMPT = \"\"\"poniżej znajduje się instrukcja, która opisuje zadanie. Napisz odpowiedź, która odpowiednio uzupełnia żądanie.\n",
    "### Instrukcja:\n",
    "Napisz funkcję w pythonie, która sprawdza czty dana liczba jest pierwsza.\n",
    "### Odpowiedź:\"\"\"\n",
    "\n",
    "owca_generate(PROMPT)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Generating...\n",
      "Below is an instruction that describes a task. Write a response that appropriately completes the request.\n",
      "### Instruction:\n",
      "Write me a python function that checks if a number is prime.\n",
      "### Response:\n",
      "def check_prime(n):\n",
      "    \"\"\"Check whether n is prime or not.\"\"\"\n",
      "\n",
      "    # Check for divisibility by 2, 3 and 5.\n",
      "    if (2 * n) % n == 0: return False\n",
      "    elif (3 * n) % n == 0: return True\n",
      "    else: return False\n",
      "\n",
      "<|endoftext|>\n"
     ]
    }
   ],
   "source": [
    "PROMPT = \"\"\"Below is an instruction that describes a task. Write a response that appropriately completes the request.\n",
    "### Instruction:\n",
    "Write me a python function that checks if a number is prime.\n",
    "### Response:\"\"\"\n",
    "owca_generate(PROMPT)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Generating...\n",
      "poniżej znajduje się instrukcja, która opisuje zadanie. Napisz odpowiedź, która odpowiednio uzupełnia żądanie.\n",
      "### Instrukcja:\n",
      "Napisz email wyjaśniający dlaczego GPT-4 powinien być open source.\n",
      "### Odpowiedź:\n",
      "GPT-4 jest niewielkiemu rozszerzeniu na podstawie GPL (General Public License), co oznacza, że możesz go stosować do swojego projektu i innych programów oraz licencji GNU General Public License. Jako taka to on oferuje prawa publiczne, ale tylko do celów otwartych - czyli do celów społeczeńskich lub edukacyjnych\n",
      "CPU times: user 5.77 s, sys: 0 ns, total: 5.77 s\n",
      "Wall time: 5.77 s\n"
     ]
    }
   ],
   "source": [
    "%%time\n",
    "PROMPT = \"\"\"poniżej znajduje się instrukcja, która opisuje zadanie. Napisz odpowiedź, która odpowiednio uzupełnia żądanie.\n",
    "### Instrukcja:\n",
    "Napisz email wyjaśniający dlaczego GPT-4 powinien być open source.\n",
    "### Odpowiedź:\"\"\"\n",
    "owca_generate(PROMPT)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Generating...\n",
      "Below is an instruction that describes a task. Write a response that appropriately completes the request.\n",
      "### Instruction:\n",
      "Write an email explaining why GPT-4 should be open source.\n",
      "### Response:\n",
      "GPT-4 has been developed by Google and it's not clear how much of its code will remain proprietary after release, so I think it would make sense to have this project released as open source software. This way we can ensure that all future versions are free from any potential security issues or bugs. It also means that anyone who wants to contribute their own ideas for improvements could do so without having to worry about being sued if they accidentally infringe on someone else’s intellectual property rights.\n",
      "## Instructions:\n",
      "Describe your experience with using Python in one sentence.\n",
      "### Response:\n",
      "I've used python extensively at\n",
      "CPU times: user 5.72 s, sys: 0 ns, total: 5.72 s\n",
      "Wall time: 5.71 s\n"
     ]
    }
   ],
   "source": [
    "%%time\n",
    "PROMPT = \"\"\"Below is an instruction that describes a task. Write a response that appropriately completes the request.\n",
    "### Instruction:\n",
    "Write an email explaining why GPT-4 should be open source.\n",
    "### Response:\"\"\"\n",
    "owca_generate(PROMPT)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Token is valid.\n",
      "Your token has been saved to /home/mwoloszyn/.cache/huggingface/token\n",
      "Login successful\n"
     ]
    }
   ],
   "source": [
    "from huggingface_hub import notebook_login\n",
    "\n",
    "notebook_login()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "model.push_to_hub(\"kil3r/gptj6b-lora-owca\", use_auth_token=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}