SebastianS
commited on
Commit
•
bc13ef6
1
Parent(s):
91d9c6c
added this file
Browse files- .ipynb_checkpoints/part4-checkpoint.ipynb +340 -0
- part4.ipynb +350 -0
.ipynb_checkpoints/part4-checkpoint.ipynb
ADDED
@@ -0,0 +1,340 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "code",
|
5 |
+
"execution_count": 9,
|
6 |
+
"id": "aa7a358a",
|
7 |
+
"metadata": {},
|
8 |
+
"outputs": [],
|
9 |
+
"source": [
|
10 |
+
"from transformers import CamembertTokenizer, CamembertForMaskedLM"
|
11 |
+
]
|
12 |
+
},
|
13 |
+
{
|
14 |
+
"cell_type": "code",
|
15 |
+
"execution_count": 10,
|
16 |
+
"id": "c7e39f7f",
|
17 |
+
"metadata": {},
|
18 |
+
"outputs": [
|
19 |
+
{
|
20 |
+
"data": {
|
21 |
+
"application/vnd.jupyter.widget-view+json": {
|
22 |
+
"model_id": "f07d3dc0c67842c5905d2a8d9bbc0ee8",
|
23 |
+
"version_major": 2,
|
24 |
+
"version_minor": 0
|
25 |
+
},
|
26 |
+
"text/plain": [
|
27 |
+
"HBox(children=(FloatProgress(value=0.0, description='Downloading', max=810912.0, style=ProgressStyle(descripti…"
|
28 |
+
]
|
29 |
+
},
|
30 |
+
"metadata": {},
|
31 |
+
"output_type": "display_data"
|
32 |
+
},
|
33 |
+
{
|
34 |
+
"name": "stdout",
|
35 |
+
"output_type": "stream",
|
36 |
+
"text": [
|
37 |
+
"\n"
|
38 |
+
]
|
39 |
+
},
|
40 |
+
{
|
41 |
+
"data": {
|
42 |
+
"application/vnd.jupyter.widget-view+json": {
|
43 |
+
"model_id": "bafae4f91f7e490087300d6fcd12ad15",
|
44 |
+
"version_major": 2,
|
45 |
+
"version_minor": 0
|
46 |
+
},
|
47 |
+
"text/plain": [
|
48 |
+
"HBox(children=(FloatProgress(value=0.0, description='Downloading', max=1395301.0, style=ProgressStyle(descript…"
|
49 |
+
]
|
50 |
+
},
|
51 |
+
"metadata": {},
|
52 |
+
"output_type": "display_data"
|
53 |
+
},
|
54 |
+
{
|
55 |
+
"name": "stdout",
|
56 |
+
"output_type": "stream",
|
57 |
+
"text": [
|
58 |
+
"\n"
|
59 |
+
]
|
60 |
+
},
|
61 |
+
{
|
62 |
+
"data": {
|
63 |
+
"application/vnd.jupyter.widget-view+json": {
|
64 |
+
"model_id": "55b5654c906441d3bba3d48c72a373f2",
|
65 |
+
"version_major": 2,
|
66 |
+
"version_minor": 0
|
67 |
+
},
|
68 |
+
"text/plain": [
|
69 |
+
"HBox(children=(FloatProgress(value=0.0, description='Downloading', max=508.0, style=ProgressStyle(description_…"
|
70 |
+
]
|
71 |
+
},
|
72 |
+
"metadata": {},
|
73 |
+
"output_type": "display_data"
|
74 |
+
},
|
75 |
+
{
|
76 |
+
"name": "stdout",
|
77 |
+
"output_type": "stream",
|
78 |
+
"text": [
|
79 |
+
"\n"
|
80 |
+
]
|
81 |
+
},
|
82 |
+
{
|
83 |
+
"data": {
|
84 |
+
"application/vnd.jupyter.widget-view+json": {
|
85 |
+
"model_id": "659a9e30adb94f24bd78d87fb4f7706d",
|
86 |
+
"version_major": 2,
|
87 |
+
"version_minor": 0
|
88 |
+
},
|
89 |
+
"text/plain": [
|
90 |
+
"HBox(children=(FloatProgress(value=0.0, description='Downloading', max=445032417.0, style=ProgressStyle(descri…"
|
91 |
+
]
|
92 |
+
},
|
93 |
+
"metadata": {},
|
94 |
+
"output_type": "display_data"
|
95 |
+
},
|
96 |
+
{
|
97 |
+
"name": "stdout",
|
98 |
+
"output_type": "stream",
|
99 |
+
"text": [
|
100 |
+
"\n"
|
101 |
+
]
|
102 |
+
}
|
103 |
+
],
|
104 |
+
"source": [
|
105 |
+
"tokenizer = CamembertTokenizer.from_pretrained(\"camembert-base\")\n",
|
106 |
+
"model = CamembertForMaskedLM.from_pretrained(\"camembert-base\")"
|
107 |
+
]
|
108 |
+
},
|
109 |
+
{
|
110 |
+
"cell_type": "code",
|
111 |
+
"execution_count": 1,
|
112 |
+
"id": "fff6346c",
|
113 |
+
"metadata": {},
|
114 |
+
"outputs": [],
|
115 |
+
"source": [
|
116 |
+
"from huggingface_hub import notebook_login"
|
117 |
+
]
|
118 |
+
},
|
119 |
+
{
|
120 |
+
"cell_type": "code",
|
121 |
+
"execution_count": 2,
|
122 |
+
"id": "3b8b1722",
|
123 |
+
"metadata": {},
|
124 |
+
"outputs": [
|
125 |
+
{
|
126 |
+
"name": "stdout",
|
127 |
+
"output_type": "stream",
|
128 |
+
"text": [
|
129 |
+
"Login successful\n",
|
130 |
+
"Your token has been saved to C:\\Users\\1seba/.huggingface/token\n",
|
131 |
+
"\u001b[1m\u001b[31mAuthenticated through git-credential store but this isn't the helper defined on your machine.\n",
|
132 |
+
"You might have to re-authenticate when pushing to the Hugging Face Hub. Run the following command in your terminal in case you want to set this credential helper as the default\n",
|
133 |
+
"\n",
|
134 |
+
"git config --global credential.helper store\u001b[0m\n"
|
135 |
+
]
|
136 |
+
}
|
137 |
+
],
|
138 |
+
"source": [
|
139 |
+
"notebook_login()"
|
140 |
+
]
|
141 |
+
},
|
142 |
+
{
|
143 |
+
"cell_type": "code",
|
144 |
+
"execution_count": 4,
|
145 |
+
"id": "e50eaa96",
|
146 |
+
"metadata": {},
|
147 |
+
"outputs": [],
|
148 |
+
"source": [
|
149 |
+
"from transformers import TrainingArguments"
|
150 |
+
]
|
151 |
+
},
|
152 |
+
{
|
153 |
+
"cell_type": "code",
|
154 |
+
"execution_count": 5,
|
155 |
+
"id": "abdb0496",
|
156 |
+
"metadata": {},
|
157 |
+
"outputs": [],
|
158 |
+
"source": [
|
159 |
+
"# training_args = TrainingArguments(\n",
|
160 |
+
"# \"bert-finetuned-mrpc\", save_strategy=\"epoch\", push_to_hub=True, hub_model_id=\"SebastianS/dummy\"\n",
|
161 |
+
"# )"
|
162 |
+
]
|
163 |
+
},
|
164 |
+
{
|
165 |
+
"cell_type": "code",
|
166 |
+
"execution_count": 6,
|
167 |
+
"id": "33d7f045",
|
168 |
+
"metadata": {},
|
169 |
+
"outputs": [],
|
170 |
+
"source": [
|
171 |
+
"from transformers import AutoModelForMaskedLM, AutoTokenizer\n",
|
172 |
+
"checkpoint = \"camembert-base\"\n",
|
173 |
+
"model = AutoModelForMaskedLM.from_pretrained(checkpoint)\n",
|
174 |
+
"tokenizer = AutoTokenizer.from_pretrained(checkpoint)"
|
175 |
+
]
|
176 |
+
},
|
177 |
+
{
|
178 |
+
"cell_type": "code",
|
179 |
+
"execution_count": 7,
|
180 |
+
"id": "7ce0651f",
|
181 |
+
"metadata": {},
|
182 |
+
"outputs": [
|
183 |
+
{
|
184 |
+
"name": "stderr",
|
185 |
+
"output_type": "stream",
|
186 |
+
"text": [
|
187 |
+
"C:\\Anaconda\\envs\\AI\\lib\\site-packages\\huggingface_hub\\hf_api.py:723: FutureWarning: `create_repo` now takes `token` as an optional positional argument. Be sure to adapt your code!\n",
|
188 |
+
" warnings.warn(\n",
|
189 |
+
"Cloning https://huggingface.co/SebastianS/dummy-model into local empty directory.\n"
|
190 |
+
]
|
191 |
+
},
|
192 |
+
{
|
193 |
+
"data": {
|
194 |
+
"application/vnd.jupyter.widget-view+json": {
|
195 |
+
"model_id": "2dc66be4581641e2992f3fd5821d4147",
|
196 |
+
"version_major": 2,
|
197 |
+
"version_minor": 0
|
198 |
+
},
|
199 |
+
"text/plain": [
|
200 |
+
"Upload file pytorch_model.bin: 0%| | 32.0k/422M [00:00<?, ?B/s]"
|
201 |
+
]
|
202 |
+
},
|
203 |
+
"metadata": {},
|
204 |
+
"output_type": "display_data"
|
205 |
+
},
|
206 |
+
{
|
207 |
+
"name": "stderr",
|
208 |
+
"output_type": "stream",
|
209 |
+
"text": [
|
210 |
+
"To https://huggingface.co/SebastianS/dummy-model\n",
|
211 |
+
" ca0d412..41a980c main -> main\n",
|
212 |
+
"\n"
|
213 |
+
]
|
214 |
+
}
|
215 |
+
],
|
216 |
+
"source": [
|
217 |
+
"model.push_to_hub(\"dummy-model\", token=\"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\")"
|
218 |
+
]
|
219 |
+
},
|
220 |
+
{
|
221 |
+
"cell_type": "code",
|
222 |
+
"execution_count": 8,
|
223 |
+
"id": "ed8312cb",
|
224 |
+
"metadata": {},
|
225 |
+
"outputs": [],
|
226 |
+
"source": [
|
227 |
+
"from huggingface_hub import (\n",
|
228 |
+
" # User management\n",
|
229 |
+
" login,\n",
|
230 |
+
" logout,\n",
|
231 |
+
" whoami,\n",
|
232 |
+
"\n",
|
233 |
+
" # Repository creation and management\n",
|
234 |
+
" create_repo,\n",
|
235 |
+
" delete_repo,\n",
|
236 |
+
" update_repo_visibility,\n",
|
237 |
+
"\n",
|
238 |
+
" # And some methods to retrieve/change information about the content\n",
|
239 |
+
" list_models,\n",
|
240 |
+
" list_datasets,\n",
|
241 |
+
" list_metrics,\n",
|
242 |
+
" list_repo_files,\n",
|
243 |
+
" upload_file,\n",
|
244 |
+
" delete_file,\n",
|
245 |
+
")"
|
246 |
+
]
|
247 |
+
},
|
248 |
+
{
|
249 |
+
"cell_type": "code",
|
250 |
+
"execution_count": 9,
|
251 |
+
"id": "71af81a5",
|
252 |
+
"metadata": {},
|
253 |
+
"outputs": [
|
254 |
+
{
|
255 |
+
"data": {
|
256 |
+
"text/plain": [
|
257 |
+
"'https://huggingface.co/SebastianS/dummy-model'"
|
258 |
+
]
|
259 |
+
},
|
260 |
+
"execution_count": 9,
|
261 |
+
"metadata": {},
|
262 |
+
"output_type": "execute_result"
|
263 |
+
}
|
264 |
+
],
|
265 |
+
"source": [
|
266 |
+
"create_repo(\"dummy-model\")"
|
267 |
+
]
|
268 |
+
},
|
269 |
+
{
|
270 |
+
"cell_type": "code",
|
271 |
+
"execution_count": 12,
|
272 |
+
"id": "1d5fd185",
|
273 |
+
"metadata": {},
|
274 |
+
"outputs": [
|
275 |
+
{
|
276 |
+
"data": {
|
277 |
+
"text/plain": [
|
278 |
+
"'https://huggingface.co/SebastianS/dummy-model/blob/main/ch3.ipynb'"
|
279 |
+
]
|
280 |
+
},
|
281 |
+
"execution_count": 12,
|
282 |
+
"metadata": {},
|
283 |
+
"output_type": "execute_result"
|
284 |
+
}
|
285 |
+
],
|
286 |
+
"source": [
|
287 |
+
"upload_file(\"./ch3.ipynb\", path_in_repo=\"ch3.ipynb\", repo_id=\"SebastianS/dummy-model\")\n"
|
288 |
+
]
|
289 |
+
},
|
290 |
+
{
|
291 |
+
"cell_type": "code",
|
292 |
+
"execution_count": 1,
|
293 |
+
"id": "02a3cc53",
|
294 |
+
"metadata": {},
|
295 |
+
"outputs": [],
|
296 |
+
"source": [
|
297 |
+
"from huggingface_hub import Repository"
|
298 |
+
]
|
299 |
+
},
|
300 |
+
{
|
301 |
+
"cell_type": "code",
|
302 |
+
"execution_count": 2,
|
303 |
+
"id": "5122830e",
|
304 |
+
"metadata": {},
|
305 |
+
"outputs": [],
|
306 |
+
"source": [
|
307 |
+
"repo = Repository(\"../sharing\")"
|
308 |
+
]
|
309 |
+
},
|
310 |
+
{
|
311 |
+
"cell_type": "code",
|
312 |
+
"execution_count": null,
|
313 |
+
"id": "06ef92c9",
|
314 |
+
"metadata": {},
|
315 |
+
"outputs": [],
|
316 |
+
"source": []
|
317 |
+
}
|
318 |
+
],
|
319 |
+
"metadata": {
|
320 |
+
"kernelspec": {
|
321 |
+
"display_name": "AI",
|
322 |
+
"language": "python",
|
323 |
+
"name": "ai"
|
324 |
+
},
|
325 |
+
"language_info": {
|
326 |
+
"codemirror_mode": {
|
327 |
+
"name": "ipython",
|
328 |
+
"version": 3
|
329 |
+
},
|
330 |
+
"file_extension": ".py",
|
331 |
+
"mimetype": "text/x-python",
|
332 |
+
"name": "python",
|
333 |
+
"nbconvert_exporter": "python",
|
334 |
+
"pygments_lexer": "ipython3",
|
335 |
+
"version": "3.8.10"
|
336 |
+
}
|
337 |
+
},
|
338 |
+
"nbformat": 4,
|
339 |
+
"nbformat_minor": 5
|
340 |
+
}
|
part4.ipynb
ADDED
@@ -0,0 +1,350 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "code",
|
5 |
+
"execution_count": 9,
|
6 |
+
"id": "aa7a358a",
|
7 |
+
"metadata": {},
|
8 |
+
"outputs": [],
|
9 |
+
"source": [
|
10 |
+
"from transformers import CamembertTokenizer, CamembertForMaskedLM"
|
11 |
+
]
|
12 |
+
},
|
13 |
+
{
|
14 |
+
"cell_type": "code",
|
15 |
+
"execution_count": 10,
|
16 |
+
"id": "c7e39f7f",
|
17 |
+
"metadata": {},
|
18 |
+
"outputs": [
|
19 |
+
{
|
20 |
+
"data": {
|
21 |
+
"application/vnd.jupyter.widget-view+json": {
|
22 |
+
"model_id": "f07d3dc0c67842c5905d2a8d9bbc0ee8",
|
23 |
+
"version_major": 2,
|
24 |
+
"version_minor": 0
|
25 |
+
},
|
26 |
+
"text/plain": [
|
27 |
+
"HBox(children=(FloatProgress(value=0.0, description='Downloading', max=810912.0, style=ProgressStyle(descripti…"
|
28 |
+
]
|
29 |
+
},
|
30 |
+
"metadata": {},
|
31 |
+
"output_type": "display_data"
|
32 |
+
},
|
33 |
+
{
|
34 |
+
"name": "stdout",
|
35 |
+
"output_type": "stream",
|
36 |
+
"text": [
|
37 |
+
"\n"
|
38 |
+
]
|
39 |
+
},
|
40 |
+
{
|
41 |
+
"data": {
|
42 |
+
"application/vnd.jupyter.widget-view+json": {
|
43 |
+
"model_id": "bafae4f91f7e490087300d6fcd12ad15",
|
44 |
+
"version_major": 2,
|
45 |
+
"version_minor": 0
|
46 |
+
},
|
47 |
+
"text/plain": [
|
48 |
+
"HBox(children=(FloatProgress(value=0.0, description='Downloading', max=1395301.0, style=ProgressStyle(descript…"
|
49 |
+
]
|
50 |
+
},
|
51 |
+
"metadata": {},
|
52 |
+
"output_type": "display_data"
|
53 |
+
},
|
54 |
+
{
|
55 |
+
"name": "stdout",
|
56 |
+
"output_type": "stream",
|
57 |
+
"text": [
|
58 |
+
"\n"
|
59 |
+
]
|
60 |
+
},
|
61 |
+
{
|
62 |
+
"data": {
|
63 |
+
"application/vnd.jupyter.widget-view+json": {
|
64 |
+
"model_id": "55b5654c906441d3bba3d48c72a373f2",
|
65 |
+
"version_major": 2,
|
66 |
+
"version_minor": 0
|
67 |
+
},
|
68 |
+
"text/plain": [
|
69 |
+
"HBox(children=(FloatProgress(value=0.0, description='Downloading', max=508.0, style=ProgressStyle(description_…"
|
70 |
+
]
|
71 |
+
},
|
72 |
+
"metadata": {},
|
73 |
+
"output_type": "display_data"
|
74 |
+
},
|
75 |
+
{
|
76 |
+
"name": "stdout",
|
77 |
+
"output_type": "stream",
|
78 |
+
"text": [
|
79 |
+
"\n"
|
80 |
+
]
|
81 |
+
},
|
82 |
+
{
|
83 |
+
"data": {
|
84 |
+
"application/vnd.jupyter.widget-view+json": {
|
85 |
+
"model_id": "659a9e30adb94f24bd78d87fb4f7706d",
|
86 |
+
"version_major": 2,
|
87 |
+
"version_minor": 0
|
88 |
+
},
|
89 |
+
"text/plain": [
|
90 |
+
"HBox(children=(FloatProgress(value=0.0, description='Downloading', max=445032417.0, style=ProgressStyle(descri…"
|
91 |
+
]
|
92 |
+
},
|
93 |
+
"metadata": {},
|
94 |
+
"output_type": "display_data"
|
95 |
+
},
|
96 |
+
{
|
97 |
+
"name": "stdout",
|
98 |
+
"output_type": "stream",
|
99 |
+
"text": [
|
100 |
+
"\n"
|
101 |
+
]
|
102 |
+
}
|
103 |
+
],
|
104 |
+
"source": [
|
105 |
+
"tokenizer = CamembertTokenizer.from_pretrained(\"camembert-base\")\n",
|
106 |
+
"model = CamembertForMaskedLM.from_pretrained(\"camembert-base\")"
|
107 |
+
]
|
108 |
+
},
|
109 |
+
{
|
110 |
+
"cell_type": "code",
|
111 |
+
"execution_count": 1,
|
112 |
+
"id": "fff6346c",
|
113 |
+
"metadata": {},
|
114 |
+
"outputs": [],
|
115 |
+
"source": [
|
116 |
+
"from huggingface_hub import notebook_login"
|
117 |
+
]
|
118 |
+
},
|
119 |
+
{
|
120 |
+
"cell_type": "code",
|
121 |
+
"execution_count": 2,
|
122 |
+
"id": "3b8b1722",
|
123 |
+
"metadata": {},
|
124 |
+
"outputs": [
|
125 |
+
{
|
126 |
+
"name": "stdout",
|
127 |
+
"output_type": "stream",
|
128 |
+
"text": [
|
129 |
+
"Login successful\n",
|
130 |
+
"Your token has been saved to C:\\Users\\1seba/.huggingface/token\n",
|
131 |
+
"\u001b[1m\u001b[31mAuthenticated through git-credential store but this isn't the helper defined on your machine.\n",
|
132 |
+
"You might have to re-authenticate when pushing to the Hugging Face Hub. Run the following command in your terminal in case you want to set this credential helper as the default\n",
|
133 |
+
"\n",
|
134 |
+
"git config --global credential.helper store\u001b[0m\n"
|
135 |
+
]
|
136 |
+
}
|
137 |
+
],
|
138 |
+
"source": [
|
139 |
+
"notebook_login()"
|
140 |
+
]
|
141 |
+
},
|
142 |
+
{
|
143 |
+
"cell_type": "code",
|
144 |
+
"execution_count": 4,
|
145 |
+
"id": "e50eaa96",
|
146 |
+
"metadata": {},
|
147 |
+
"outputs": [],
|
148 |
+
"source": [
|
149 |
+
"from transformers import TrainingArguments"
|
150 |
+
]
|
151 |
+
},
|
152 |
+
{
|
153 |
+
"cell_type": "code",
|
154 |
+
"execution_count": 5,
|
155 |
+
"id": "abdb0496",
|
156 |
+
"metadata": {},
|
157 |
+
"outputs": [],
|
158 |
+
"source": [
|
159 |
+
"# training_args = TrainingArguments(\n",
|
160 |
+
"# \"bert-finetuned-mrpc\", save_strategy=\"epoch\", push_to_hub=True, hub_model_id=\"SebastianS/dummy\"\n",
|
161 |
+
"# )"
|
162 |
+
]
|
163 |
+
},
|
164 |
+
{
|
165 |
+
"cell_type": "code",
|
166 |
+
"execution_count": 6,
|
167 |
+
"id": "33d7f045",
|
168 |
+
"metadata": {},
|
169 |
+
"outputs": [],
|
170 |
+
"source": [
|
171 |
+
"from transformers import AutoModelForMaskedLM, AutoTokenizer\n",
|
172 |
+
"checkpoint = \"camembert-base\"\n",
|
173 |
+
"model = AutoModelForMaskedLM.from_pretrained(checkpoint)\n",
|
174 |
+
"tokenizer = AutoTokenizer.from_pretrained(checkpoint)"
|
175 |
+
]
|
176 |
+
},
|
177 |
+
{
|
178 |
+
"cell_type": "code",
|
179 |
+
"execution_count": 7,
|
180 |
+
"id": "7ce0651f",
|
181 |
+
"metadata": {},
|
182 |
+
"outputs": [
|
183 |
+
{
|
184 |
+
"name": "stderr",
|
185 |
+
"output_type": "stream",
|
186 |
+
"text": [
|
187 |
+
"C:\\Anaconda\\envs\\AI\\lib\\site-packages\\huggingface_hub\\hf_api.py:723: FutureWarning: `create_repo` now takes `token` as an optional positional argument. Be sure to adapt your code!\n",
|
188 |
+
" warnings.warn(\n",
|
189 |
+
"Cloning https://huggingface.co/SebastianS/dummy-model into local empty directory.\n"
|
190 |
+
]
|
191 |
+
},
|
192 |
+
{
|
193 |
+
"data": {
|
194 |
+
"application/vnd.jupyter.widget-view+json": {
|
195 |
+
"model_id": "2dc66be4581641e2992f3fd5821d4147",
|
196 |
+
"version_major": 2,
|
197 |
+
"version_minor": 0
|
198 |
+
},
|
199 |
+
"text/plain": [
|
200 |
+
"Upload file pytorch_model.bin: 0%| | 32.0k/422M [00:00<?, ?B/s]"
|
201 |
+
]
|
202 |
+
},
|
203 |
+
"metadata": {},
|
204 |
+
"output_type": "display_data"
|
205 |
+
},
|
206 |
+
{
|
207 |
+
"name": "stderr",
|
208 |
+
"output_type": "stream",
|
209 |
+
"text": [
|
210 |
+
"To https://huggingface.co/SebastianS/dummy-model\n",
|
211 |
+
" ca0d412..41a980c main -> main\n",
|
212 |
+
"\n"
|
213 |
+
]
|
214 |
+
}
|
215 |
+
],
|
216 |
+
"source": [
|
217 |
+
"model.push_to_hub(\"dummy-model\", token=\"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\")"
|
218 |
+
]
|
219 |
+
},
|
220 |
+
{
|
221 |
+
"cell_type": "code",
|
222 |
+
"execution_count": 8,
|
223 |
+
"id": "ed8312cb",
|
224 |
+
"metadata": {},
|
225 |
+
"outputs": [],
|
226 |
+
"source": [
|
227 |
+
"from huggingface_hub import (\n",
|
228 |
+
" # User management\n",
|
229 |
+
" login,\n",
|
230 |
+
" logout,\n",
|
231 |
+
" whoami,\n",
|
232 |
+
"\n",
|
233 |
+
" # Repository creation and management\n",
|
234 |
+
" create_repo,\n",
|
235 |
+
" delete_repo,\n",
|
236 |
+
" update_repo_visibility,\n",
|
237 |
+
"\n",
|
238 |
+
" # And some methods to retrieve/change information about the content\n",
|
239 |
+
" list_models,\n",
|
240 |
+
" list_datasets,\n",
|
241 |
+
" list_metrics,\n",
|
242 |
+
" list_repo_files,\n",
|
243 |
+
" upload_file,\n",
|
244 |
+
" delete_file,\n",
|
245 |
+
")"
|
246 |
+
]
|
247 |
+
},
|
248 |
+
{
|
249 |
+
"cell_type": "code",
|
250 |
+
"execution_count": 9,
|
251 |
+
"id": "71af81a5",
|
252 |
+
"metadata": {},
|
253 |
+
"outputs": [
|
254 |
+
{
|
255 |
+
"data": {
|
256 |
+
"text/plain": [
|
257 |
+
"'https://huggingface.co/SebastianS/dummy-model'"
|
258 |
+
]
|
259 |
+
},
|
260 |
+
"execution_count": 9,
|
261 |
+
"metadata": {},
|
262 |
+
"output_type": "execute_result"
|
263 |
+
}
|
264 |
+
],
|
265 |
+
"source": [
|
266 |
+
"create_repo(\"dummy-model\")"
|
267 |
+
]
|
268 |
+
},
|
269 |
+
{
|
270 |
+
"cell_type": "code",
|
271 |
+
"execution_count": 12,
|
272 |
+
"id": "1d5fd185",
|
273 |
+
"metadata": {},
|
274 |
+
"outputs": [
|
275 |
+
{
|
276 |
+
"data": {
|
277 |
+
"text/plain": [
|
278 |
+
"'https://huggingface.co/SebastianS/dummy-model/blob/main/ch3.ipynb'"
|
279 |
+
]
|
280 |
+
},
|
281 |
+
"execution_count": 12,
|
282 |
+
"metadata": {},
|
283 |
+
"output_type": "execute_result"
|
284 |
+
}
|
285 |
+
],
|
286 |
+
"source": [
|
287 |
+
"upload_file(\"./ch3.ipynb\", path_in_repo=\"ch3.ipynb\", repo_id=\"SebastianS/dummy-model\")\n"
|
288 |
+
]
|
289 |
+
},
|
290 |
+
{
|
291 |
+
"cell_type": "code",
|
292 |
+
"execution_count": 1,
|
293 |
+
"id": "02a3cc53",
|
294 |
+
"metadata": {},
|
295 |
+
"outputs": [],
|
296 |
+
"source": [
|
297 |
+
"from huggingface_hub import Repository"
|
298 |
+
]
|
299 |
+
},
|
300 |
+
{
|
301 |
+
"cell_type": "code",
|
302 |
+
"execution_count": 2,
|
303 |
+
"id": "5122830e",
|
304 |
+
"metadata": {},
|
305 |
+
"outputs": [],
|
306 |
+
"source": [
|
307 |
+
"repo = Repository(\"../sharing\")"
|
308 |
+
]
|
309 |
+
},
|
310 |
+
{
|
311 |
+
"cell_type": "code",
|
312 |
+
"execution_count": 3,
|
313 |
+
"id": "06ef92c9",
|
314 |
+
"metadata": {},
|
315 |
+
"outputs": [],
|
316 |
+
"source": [
|
317 |
+
"repo.git_pull()"
|
318 |
+
]
|
319 |
+
},
|
320 |
+
{
|
321 |
+
"cell_type": "code",
|
322 |
+
"execution_count": null,
|
323 |
+
"id": "574529d9",
|
324 |
+
"metadata": {},
|
325 |
+
"outputs": [],
|
326 |
+
"source": []
|
327 |
+
}
|
328 |
+
],
|
329 |
+
"metadata": {
|
330 |
+
"kernelspec": {
|
331 |
+
"display_name": "AI",
|
332 |
+
"language": "python",
|
333 |
+
"name": "ai"
|
334 |
+
},
|
335 |
+
"language_info": {
|
336 |
+
"codemirror_mode": {
|
337 |
+
"name": "ipython",
|
338 |
+
"version": 3
|
339 |
+
},
|
340 |
+
"file_extension": ".py",
|
341 |
+
"mimetype": "text/x-python",
|
342 |
+
"name": "python",
|
343 |
+
"nbconvert_exporter": "python",
|
344 |
+
"pygments_lexer": "ipython3",
|
345 |
+
"version": "3.8.10"
|
346 |
+
}
|
347 |
+
},
|
348 |
+
"nbformat": 4,
|
349 |
+
"nbformat_minor": 5
|
350 |
+
}
|