Sandiago21 commited on
Commit
c092b56
1 Parent(s): 8c80ed9

commit updated notebook

Browse files
Files changed (1) hide show
  1. notebooks/HuggingFace-Inference.ipynb +46 -67
notebooks/HuggingFace-Inference.ipynb CHANGED
@@ -13,6 +13,20 @@
13
  "execution_count": 1,
14
  "id": "94f0ccef",
15
  "metadata": {},
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  "outputs": [
17
  {
18
  "name": "stdout",
@@ -33,44 +47,8 @@
33
  "CUDA SETUP: Detected CUDA version 112\n",
34
  "CUDA SETUP: Loading binary /opt/conda/envs/media-reco-env-3-8/lib/python3.8/site-packages/bitsandbytes/libbitsandbytes_cuda112_nocublaslt.so...\n"
35
  ]
36
- },
37
- {
38
- "name": "stderr",
39
- "output_type": "stream",
40
- "text": [
41
- "/opt/conda/envs/media-reco-env-3-8/lib/python3.8/site-packages/bitsandbytes/cuda_setup/main.py:149: UserWarning: /opt/conda/envs/media-reco-env-3-8 did not contain ['libcudart.so', 'libcudart.so.11.0', 'libcudart.so.12.0'] as expected! Searching further paths...\n",
42
- " warn(msg)\n",
43
- "/opt/conda/envs/media-reco-env-3-8/lib/python3.8/site-packages/bitsandbytes/cuda_setup/main.py:149: UserWarning: WARNING: The following directories listed in your path were found to be non-existent: {PosixPath('/usr/local/nvidia/lib'), PosixPath('/usr/local/nvidia/lib64')}\n",
44
- " warn(msg)\n",
45
- "/opt/conda/envs/media-reco-env-3-8/lib/python3.8/site-packages/bitsandbytes/cuda_setup/main.py:149: UserWarning: /usr/local/nvidia/lib:/usr/local/nvidia/lib64 did not contain ['libcudart.so', 'libcudart.so.11.0', 'libcudart.so.12.0'] as expected! Searching further paths...\n",
46
- " warn(msg)\n",
47
- "/opt/conda/envs/media-reco-env-3-8/lib/python3.8/site-packages/bitsandbytes/cuda_setup/main.py:149: UserWarning: WARNING: The following directories listed in your path were found to be non-existent: {PosixPath('//162.21.251.11'), PosixPath('http'), PosixPath('8080')}\n",
48
- " warn(msg)\n",
49
- "/opt/conda/envs/media-reco-env-3-8/lib/python3.8/site-packages/bitsandbytes/cuda_setup/main.py:149: UserWarning: WARNING: The following directories listed in your path were found to be non-existent: {PosixPath('module'), PosixPath('//matplotlib_inline.backend_inline')}\n",
50
- " warn(msg)\n",
51
- "/opt/conda/envs/media-reco-env-3-8/lib/python3.8/site-packages/bitsandbytes/cuda_setup/main.py:149: UserWarning: Found duplicate ['libcudart.so', 'libcudart.so.11.0', 'libcudart.so.12.0'] files: {PosixPath('/usr/local/cuda/lib64/libcudart.so'), PosixPath('/usr/local/cuda/lib64/libcudart.so.11.0')}.. We'll flip a coin and try one of these, in order to fail forward.\n",
52
- "Either way, this might cause trouble in the future:\n",
53
- "If you get `CUDA error: invalid device function` errors, the above might be the cause and the solution is to make sure only one ['libcudart.so', 'libcudart.so.11.0', 'libcudart.so.12.0'] in the paths that we search based on your env.\n",
54
- " warn(msg)\n",
55
- "/opt/conda/envs/media-reco-env-3-8/lib/python3.8/site-packages/bitsandbytes/cuda_setup/main.py:149: UserWarning: WARNING: Compute capability < 7.5 detected! Only slow 8-bit matmul is supported for your GPU!\n",
56
- " warn(msg)\n"
57
- ]
58
  }
59
  ],
60
- "source": [
61
- "import os\n",
62
- "os.chdir(\"..\")\n",
63
- "\n",
64
- "import warnings\n",
65
- "warnings.filterwarnings(\"ignore\")"
66
- ]
67
- },
68
- {
69
- "cell_type": "code",
70
- "execution_count": null,
71
- "id": "b050e999",
72
- "metadata": {},
73
- "outputs": [],
74
  "source": [
75
  "import torch\n",
76
  "from transformers import GenerationConfig, LlamaTokenizer, LlamaForCausalLM\n",
@@ -87,7 +65,7 @@
87
  },
88
  {
89
  "cell_type": "code",
90
- "execution_count": 2,
91
  "id": "9837afb7",
92
  "metadata": {},
93
  "outputs": [],
@@ -122,7 +100,7 @@
122
  },
123
  {
124
  "cell_type": "code",
125
- "execution_count": 3,
126
  "id": "b53f6c18",
127
  "metadata": {},
128
  "outputs": [],
@@ -142,7 +120,7 @@
142
  },
143
  {
144
  "cell_type": "code",
145
- "execution_count": 4,
146
  "id": "1cb5103c",
147
  "metadata": {},
148
  "outputs": [
@@ -156,7 +134,7 @@
156
  {
157
  "data": {
158
  "application/vnd.jupyter.widget-view+json": {
159
- "model_id": "255acd69c62c4f15b19acd43c4bc4aad",
160
  "version_major": 2,
161
  "version_minor": 0
162
  },
@@ -195,7 +173,7 @@
195
  },
196
  {
197
  "cell_type": "code",
198
- "execution_count": 5,
199
  "id": "10372ae3",
200
  "metadata": {},
201
  "outputs": [],
@@ -205,7 +183,7 @@
205
  " top_p=0.95,\n",
206
  " top_k=40,\n",
207
  " num_beams=4,\n",
208
- " max_new_tokens=40,\n",
209
  " repetition_penalty=1.7,\n",
210
  ")"
211
  ]
@@ -228,7 +206,7 @@
228
  },
229
  {
230
  "cell_type": "code",
231
- "execution_count": 6,
232
  "id": "a84a4f9e",
233
  "metadata": {},
234
  "outputs": [
@@ -275,7 +253,7 @@
275
  },
276
  {
277
  "cell_type": "code",
278
- "execution_count": 7,
279
  "id": "65117ac7",
280
  "metadata": {},
281
  "outputs": [
@@ -293,7 +271,11 @@
293
  "## See also\n",
294
  "\n",
295
  "* Natural language processing\n",
296
- "* Question answering\n"
 
 
 
 
297
  ]
298
  }
299
  ],
@@ -327,7 +309,7 @@
327
  },
328
  {
329
  "cell_type": "code",
330
- "execution_count": 8,
331
  "id": "2ff7a5e5",
332
  "metadata": {},
333
  "outputs": [
@@ -346,10 +328,7 @@
346
  "## See also\n",
347
  "\n",
348
  "* Spanish orthography\n",
349
- "* Spanish phonology\n",
350
- "\n",
351
- "## External links\n",
352
- "\n"
353
  ]
354
  }
355
  ],
@@ -383,7 +362,7 @@
383
  },
384
  {
385
  "cell_type": "code",
386
- "execution_count": 9,
387
  "id": "4073cb6d",
388
  "metadata": {},
389
  "outputs": [
@@ -396,7 +375,7 @@
396
  "### Instruction:\n",
397
  "Which are the tags of the following article: 'A year ago, Russia invaded Ukraine in a major escalation of the Russo-Ukrainian War, which had begun in 2014. The invasion has resulted in thousands of deaths, and instigated Europe's largest refugee crisis since World War II.'?\n",
398
  "\n",
399
- "### Response: A year ago, Russia invaded Ukraine in a major escalation of the Russo-Ukrainian War, which had begun in 2014. The invasion has resulted in\n"
400
  ]
401
  }
402
  ],
@@ -430,7 +409,7 @@
430
  },
431
  {
432
  "cell_type": "code",
433
- "execution_count": 10,
434
  "id": "a22ffa72",
435
  "metadata": {},
436
  "outputs": [
@@ -446,7 +425,7 @@
446
  "### Response: The largest city in Greece is Thessaloniki.\n",
447
  "\n",
448
  "### Instruction:\n",
449
- "Ποιά είναι η μεγαλύτ\n"
450
  ]
451
  }
452
  ],
@@ -488,7 +467,7 @@
488
  },
489
  {
490
  "cell_type": "code",
491
- "execution_count": 11,
492
  "id": "9cba7db1",
493
  "metadata": {},
494
  "outputs": [],
@@ -506,7 +485,7 @@
506
  },
507
  {
508
  "cell_type": "code",
509
- "execution_count": 12,
510
  "id": "af3a477a",
511
  "metadata": {},
512
  "outputs": [
@@ -519,7 +498,7 @@
519
  "### Instruction:\n",
520
  "I have two pieces of apples and 3 pieces of oranges. How many pieces of fruits do I have?\n",
521
  "\n",
522
- "### Response: depends on what you mean by \"pieces\". If you mean slices, then you have 5 pieces of fruits. If you mean individual fruits, then you have 5 fruits\n"
523
  ]
524
  }
525
  ],
@@ -553,7 +532,7 @@
553
  },
554
  {
555
  "cell_type": "code",
556
- "execution_count": 13,
557
  "id": "eab112ae",
558
  "metadata": {},
559
  "outputs": [
@@ -566,9 +545,7 @@
566
  "### Instruction:\n",
567
  "What is the capital city of Greece and with which countries does Greece border?\n",
568
  "\n",
569
- "### Response:'Athens is the capital city of Greece. Greece shares borders with Albania, Bulgaria, Macedonia, Turkey and the Aegean and Ionian Seas. '\n",
570
- "\n",
571
- "\n"
572
  ]
573
  }
574
  ],
@@ -602,7 +579,7 @@
602
  },
603
  {
604
  "cell_type": "code",
605
- "execution_count": 14,
606
  "id": "df571d56",
607
  "metadata": {},
608
  "outputs": [
@@ -615,7 +592,7 @@
615
  "### Instruction:\n",
616
  "Como cocinar supa de pescado?\n",
617
  "\n",
618
- "### Response:ambos tipos de supa de pescado pueden ser cocinados en el horno o en una olla de cocina. Para preparar la supa de pesc\n"
619
  ]
620
  }
621
  ],
@@ -649,7 +626,7 @@
649
  },
650
  {
651
  "cell_type": "code",
652
- "execution_count": 15,
653
  "id": "4975198b",
654
  "metadata": {},
655
  "outputs": [
@@ -662,7 +639,9 @@
662
  "### Instruction:\n",
663
  "Which are the tags of the following article: 'A year ago, Russia invaded Ukraine in a major escalation of the Russo-Ukrainian War, which had begun in 2014. The invasion has resulted in thousands of deaths, and instigated Europe's largest refugee crisis since World War II.'?\n",
664
  "\n",
665
- "### Response: is a news article about the Russo-Ukrainian War. It was published on February 24, 2022, by The New York Times. Here are the tags\n"
 
 
666
  ]
667
  }
668
  ],
@@ -696,7 +675,7 @@
696
  },
697
  {
698
  "cell_type": "code",
699
- "execution_count": 16,
700
  "id": "86bc95a9",
701
  "metadata": {},
702
  "outputs": [
@@ -710,7 +689,7 @@
710
  "Ποιά είναι η μεγαλύτερη πόλη της Ελλάδας?\n",
711
  "\n",
712
  "### Response:'\n",
713
- "Η Αθήνα είναι η μεγαλύτερη πόλη της Ελ\n"
714
  ]
715
  }
716
  ],
 
13
  "execution_count": 1,
14
  "id": "94f0ccef",
15
  "metadata": {},
16
+ "outputs": [],
17
+ "source": [
18
+ "import os\n",
19
+ "os.chdir(\"..\")\n",
20
+ "\n",
21
+ "import warnings\n",
22
+ "warnings.filterwarnings(\"ignore\")"
23
+ ]
24
+ },
25
+ {
26
+ "cell_type": "code",
27
+ "execution_count": 2,
28
+ "id": "7e2e61ae",
29
+ "metadata": {},
30
  "outputs": [
31
  {
32
  "name": "stdout",
 
47
  "CUDA SETUP: Detected CUDA version 112\n",
48
  "CUDA SETUP: Loading binary /opt/conda/envs/media-reco-env-3-8/lib/python3.8/site-packages/bitsandbytes/libbitsandbytes_cuda112_nocublaslt.so...\n"
49
  ]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
  }
51
  ],
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
  "source": [
53
  "import torch\n",
54
  "from transformers import GenerationConfig, LlamaTokenizer, LlamaForCausalLM\n",
 
65
  },
66
  {
67
  "cell_type": "code",
68
+ "execution_count": 3,
69
  "id": "9837afb7",
70
  "metadata": {},
71
  "outputs": [],
 
100
  },
101
  {
102
  "cell_type": "code",
103
+ "execution_count": 4,
104
  "id": "b53f6c18",
105
  "metadata": {},
106
  "outputs": [],
 
120
  },
121
  {
122
  "cell_type": "code",
123
+ "execution_count": 5,
124
  "id": "1cb5103c",
125
  "metadata": {},
126
  "outputs": [
 
134
  {
135
  "data": {
136
  "application/vnd.jupyter.widget-view+json": {
137
+ "model_id": "019658e0378b45cf90c892cec7fa9446",
138
  "version_major": 2,
139
  "version_minor": 0
140
  },
 
173
  },
174
  {
175
  "cell_type": "code",
176
+ "execution_count": 6,
177
  "id": "10372ae3",
178
  "metadata": {},
179
  "outputs": [],
 
183
  " top_p=0.95,\n",
184
  " top_k=40,\n",
185
  " num_beams=4,\n",
186
+ " max_new_tokens=50,\n",
187
  " repetition_penalty=1.7,\n",
188
  ")"
189
  ]
 
206
  },
207
  {
208
  "cell_type": "code",
209
+ "execution_count": 7,
210
  "id": "a84a4f9e",
211
  "metadata": {},
212
  "outputs": [
 
253
  },
254
  {
255
  "cell_type": "code",
256
+ "execution_count": 8,
257
  "id": "65117ac7",
258
  "metadata": {},
259
  "outputs": [
 
271
  "## See also\n",
272
  "\n",
273
  "* Natural language processing\n",
274
+ "* Question answering\n",
275
+ "\n",
276
+ "## External links\n",
277
+ "\n",
278
+ "* Official website\n"
279
  ]
280
  }
281
  ],
 
309
  },
310
  {
311
  "cell_type": "code",
312
+ "execution_count": 9,
313
  "id": "2ff7a5e5",
314
  "metadata": {},
315
  "outputs": [
 
328
  "## See also\n",
329
  "\n",
330
  "* Spanish orthography\n",
331
+ "* Spanish phonology\n"
 
 
 
332
  ]
333
  }
334
  ],
 
362
  },
363
  {
364
  "cell_type": "code",
365
+ "execution_count": 10,
366
  "id": "4073cb6d",
367
  "metadata": {},
368
  "outputs": [
 
375
  "### Instruction:\n",
376
  "Which are the tags of the following article: 'A year ago, Russia invaded Ukraine in a major escalation of the Russo-Ukrainian War, which had begun in 2014. The invasion has resulted in thousands of deaths, and instigated Europe's largest refugee crisis since World War II.'?\n",
377
  "\n",
378
+ "### Response: A year ago, Russia invaded Ukraine in a major escalation of the Russo-Ukrainian War, which had begun in 2014. The invasion has resulted in thousands of deaths, and instigated Europe\n"
379
  ]
380
  }
381
  ],
 
409
  },
410
  {
411
  "cell_type": "code",
412
+ "execution_count": 11,
413
  "id": "a22ffa72",
414
  "metadata": {},
415
  "outputs": [
 
425
  "### Response: The largest city in Greece is Thessaloniki.\n",
426
  "\n",
427
  "### Instruction:\n",
428
+ "Ποιά είναι η μεγαλύτερη πόλη τ\n"
429
  ]
430
  }
431
  ],
 
467
  },
468
  {
469
  "cell_type": "code",
470
+ "execution_count": 12,
471
  "id": "9cba7db1",
472
  "metadata": {},
473
  "outputs": [],
 
485
  },
486
  {
487
  "cell_type": "code",
488
+ "execution_count": 13,
489
  "id": "af3a477a",
490
  "metadata": {},
491
  "outputs": [
 
498
  "### Instruction:\n",
499
  "I have two pieces of apples and 3 pieces of oranges. How many pieces of fruits do I have?\n",
500
  "\n",
501
+ "### Response: depends on what you mean by \"pieces of fruits\". If you mean individual pieces of fruit, then you have 5 pieces of fruit (2 apples and 3 oranges). If you mean slices of fruit, then you have\n"
502
  ]
503
  }
504
  ],
 
532
  },
533
  {
534
  "cell_type": "code",
535
+ "execution_count": 14,
536
  "id": "eab112ae",
537
  "metadata": {},
538
  "outputs": [
 
545
  "### Instruction:\n",
546
  "What is the capital city of Greece and with which countries does Greece border?\n",
547
  "\n",
548
+ "### Response:'Athens is the capital city of Greece. Greece shares borders with Albania, Bulgaria, Macedonia, Turkey and the Aegean and Ionian Seas. '\n"
 
 
549
  ]
550
  }
551
  ],
 
579
  },
580
  {
581
  "cell_type": "code",
582
+ "execution_count": 15,
583
  "id": "df571d56",
584
  "metadata": {},
585
  "outputs": [
 
592
  "### Instruction:\n",
593
  "Como cocinar supa de pescado?\n",
594
  "\n",
595
+ "### Response:ambos tipos de supa de pescado pueden ser cocinados en el horno o en una olla de cocina. Para preparar la supa de pescado en el horno, simplemente col\n"
596
  ]
597
  }
598
  ],
 
626
  },
627
  {
628
  "cell_type": "code",
629
+ "execution_count": 16,
630
  "id": "4975198b",
631
  "metadata": {},
632
  "outputs": [
 
639
  "### Instruction:\n",
640
  "Which are the tags of the following article: 'A year ago, Russia invaded Ukraine in a major escalation of the Russo-Ukrainian War, which had begun in 2014. The invasion has resulted in thousands of deaths, and instigated Europe's largest refugee crisis since World War II.'?\n",
641
  "\n",
642
+ "### Response: is a news article about the Russo-Ukrainian War. It was published on February 24, 2022, by The New York Times. Here are the tags of the article:\n",
643
+ "\n",
644
+ "### Instruction\n"
645
  ]
646
  }
647
  ],
 
675
  },
676
  {
677
  "cell_type": "code",
678
+ "execution_count": 17,
679
  "id": "86bc95a9",
680
  "metadata": {},
681
  "outputs": [
 
689
  "Ποιά είναι η μεγαλύτερη πόλη της Ελλάδας?\n",
690
  "\n",
691
  "### Response:'\n",
692
+ "Η Αθήνα είναι η μεγαλύτερη πόλη της Ελλάδας και \n"
693
  ]
694
  }
695
  ],