Commit
·
b539400
1
Parent(s):
16023fc
Upload GPT_Neo_125M_Grug_Training.ipynb
Browse files- GPT_Neo_125M_Grug_Training.ipynb +116 -0
GPT_Neo_125M_Grug_Training.ipynb
ADDED
@@ -0,0 +1,116 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
},
|
18 |
+
"cells": [
|
19 |
+
{
|
20 |
+
"cell_type": "code",
|
21 |
+
"execution_count": null,
|
22 |
+
"metadata": {
|
23 |
+
"id": "u7RAqjzj4ylm"
|
24 |
+
},
|
25 |
+
"outputs": [],
|
26 |
+
"source": [
|
27 |
+
"!pip install happytransformer"
|
28 |
+
]
|
29 |
+
},
|
30 |
+
{
|
31 |
+
"cell_type": "code",
|
32 |
+
"source": [
|
33 |
+
"from happytransformer import HappyGeneration\n",
|
34 |
+
"\n",
|
35 |
+
"happy_gen = HappyGeneration(\"GPT-NEO\", \"EleutherAI/gpt-neo-125M\")"
|
36 |
+
],
|
37 |
+
"metadata": {
|
38 |
+
"id": "4V9hd8bQ41HD"
|
39 |
+
},
|
40 |
+
"execution_count": null,
|
41 |
+
"outputs": []
|
42 |
+
},
|
43 |
+
{
|
44 |
+
"cell_type": "code",
|
45 |
+
"source": [
|
46 |
+
"!wget https://huggingface.co/datasets/DarwinAnim8or/grug/resolve/main/grug-training.txt"
|
47 |
+
],
|
48 |
+
"metadata": {
|
49 |
+
"id": "hz3fzo5W9ppf"
|
50 |
+
},
|
51 |
+
"execution_count": null,
|
52 |
+
"outputs": []
|
53 |
+
},
|
54 |
+
{
|
55 |
+
"cell_type": "code",
|
56 |
+
"source": [
|
57 |
+
"from happytransformer import GENTrainArgs \n",
|
58 |
+
"\n",
|
59 |
+
"args = GENTrainArgs(learning_rate =1e-5, num_train_epochs = 2)\n",
|
60 |
+
"happy_gen.train(\"grug-training.txt\", args=args)"
|
61 |
+
],
|
62 |
+
"metadata": {
|
63 |
+
"id": "Yl4wNVvK5Bex"
|
64 |
+
},
|
65 |
+
"execution_count": null,
|
66 |
+
"outputs": []
|
67 |
+
},
|
68 |
+
{
|
69 |
+
"cell_type": "code",
|
70 |
+
"source": [
|
71 |
+
"from happytransformer import GENSettings\n",
|
72 |
+
"args_top_k = GENSettings(no_repeat_ngram_size=3, do_sample=True,top_k=50, temperature=0.7, max_length=50, early_stopping=False)"
|
73 |
+
],
|
74 |
+
"metadata": {
|
75 |
+
"id": "LXi7hXFtBLpN"
|
76 |
+
},
|
77 |
+
"execution_count": null,
|
78 |
+
"outputs": []
|
79 |
+
},
|
80 |
+
{
|
81 |
+
"cell_type": "code",
|
82 |
+
"source": [
|
83 |
+
"result = happy_gen.generate_text(\"\"\"Person: \"Hello grug\"\n",
|
84 |
+
"Grug: \"hello person\"\n",
|
85 |
+
"###\n",
|
86 |
+
"Person: \"how are you grug\"\n",
|
87 |
+
"Grug: \"grug doing ok. grug find many berry. good for tribe.\"\n",
|
88 |
+
"###\n",
|
89 |
+
"Person: \"what does grug think of new spear weapon?\"\n",
|
90 |
+
"Grug: \"grug no like new spear weapon. grug stick bigger. spear too small, break easy\"\n",
|
91 |
+
"###\n",
|
92 |
+
"Person: \"what does grug think of football?\"\n",
|
93 |
+
"Grug: \\\"\"\"\", args=args_top_k)\n",
|
94 |
+
"#print(result)\n",
|
95 |
+
"print(result.text)"
|
96 |
+
],
|
97 |
+
"metadata": {
|
98 |
+
"id": "ih4KihPy_U_h"
|
99 |
+
},
|
100 |
+
"execution_count": null,
|
101 |
+
"outputs": []
|
102 |
+
},
|
103 |
+
{
|
104 |
+
"cell_type": "code",
|
105 |
+
"source": [
|
106 |
+
"#To save the model, run this cell.\n",
|
107 |
+
"happy_gen.save(\"gpt-grug-125m-epoch4/\")"
|
108 |
+
],
|
109 |
+
"metadata": {
|
110 |
+
"id": "LFUPtXAo_dTz"
|
111 |
+
},
|
112 |
+
"execution_count": null,
|
113 |
+
"outputs": []
|
114 |
+
}
|
115 |
+
]
|
116 |
+
}
|