Commit
·
e680bbf
1
Parent(s):
e205a84
Back to bert mini for leaderboard submission
Browse files- Finetune BERT.ipynb +44 -8
- tasks/text.py +1 -2
Finetune BERT.ipynb
CHANGED
@@ -10,15 +10,15 @@
|
|
10 |
},
|
11 |
{
|
12 |
"cell_type": "code",
|
13 |
-
"execution_count":
|
14 |
"id": "73e72549-69f2-46b5-b0f5-655777139972",
|
15 |
"metadata": {
|
16 |
"execution": {
|
17 |
-
"iopub.execute_input": "2025-01-24T18:
|
18 |
-
"iopub.status.busy": "2025-01-24T18:
|
19 |
-
"iopub.status.idle": "2025-01-24T18:
|
20 |
-
"shell.execute_reply": "2025-01-24T18:
|
21 |
-
"shell.execute_reply.started": "2025-01-24T18:
|
22 |
}
|
23 |
},
|
24 |
"outputs": [],
|
@@ -36,7 +36,8 @@
|
|
36 |
" EvalResult,\n",
|
37 |
")\n",
|
38 |
"from datasets import DatasetDict, load_dataset\n",
|
39 |
-
"from torch.utils.data import Dataset, DataLoader"
|
|
|
40 |
]
|
41 |
},
|
42 |
{
|
@@ -478,7 +479,42 @@
|
|
478 |
"acc 0.645, energy 0.273 Wh\n",
|
479 |
"\n",
|
480 |
"bert-base\\\n",
|
481 |
-
"acc, energy"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
482 |
]
|
483 |
},
|
484 |
{
|
|
|
10 |
},
|
11 |
{
|
12 |
"cell_type": "code",
|
13 |
+
"execution_count": 17,
|
14 |
"id": "73e72549-69f2-46b5-b0f5-655777139972",
|
15 |
"metadata": {
|
16 |
"execution": {
|
17 |
+
"iopub.execute_input": "2025-01-24T18:59:00.459773Z",
|
18 |
+
"iopub.status.busy": "2025-01-24T18:59:00.458472Z",
|
19 |
+
"iopub.status.idle": "2025-01-24T18:59:00.517418Z",
|
20 |
+
"shell.execute_reply": "2025-01-24T18:59:00.517026Z",
|
21 |
+
"shell.execute_reply.started": "2025-01-24T18:59:00.459726Z"
|
22 |
}
|
23 |
},
|
24 |
"outputs": [],
|
|
|
36 |
" EvalResult,\n",
|
37 |
")\n",
|
38 |
"from datasets import DatasetDict, load_dataset\n",
|
39 |
+
"from torch.utils.data import Dataset, DataLoader\n",
|
40 |
+
"from statsmodels.stats.proportion import proportion_confint"
|
41 |
]
|
42 |
},
|
43 |
{
|
|
|
479 |
"acc 0.645, energy 0.273 Wh\n",
|
480 |
"\n",
|
481 |
"bert-base\\\n",
|
482 |
+
"acc 0.691, energy 1.053 Wh"
|
483 |
+
]
|
484 |
+
},
|
485 |
+
{
|
486 |
+
"cell_type": "code",
|
487 |
+
"execution_count": 23,
|
488 |
+
"id": "6c35f222-79d9-4166-8601-8a6240a49c91",
|
489 |
+
"metadata": {
|
490 |
+
"execution": {
|
491 |
+
"iopub.execute_input": "2025-01-24T19:03:41.276772Z",
|
492 |
+
"iopub.status.busy": "2025-01-24T19:03:41.276125Z",
|
493 |
+
"iopub.status.idle": "2025-01-24T19:03:41.284530Z",
|
494 |
+
"shell.execute_reply": "2025-01-24T19:03:41.283079Z",
|
495 |
+
"shell.execute_reply.started": "2025-01-24T19:03:41.276731Z"
|
496 |
+
}
|
497 |
+
},
|
498 |
+
"outputs": [
|
499 |
+
{
|
500 |
+
"data": {
|
501 |
+
"text/plain": [
|
502 |
+
"(0.6284344081642794, 0.6817389605903139)"
|
503 |
+
]
|
504 |
+
},
|
505 |
+
"execution_count": 23,
|
506 |
+
"metadata": {},
|
507 |
+
"output_type": "execute_result"
|
508 |
+
}
|
509 |
+
],
|
510 |
+
"source": [
|
511 |
+
"nobs = 1219\n",
|
512 |
+
"acc = 0.656\n",
|
513 |
+
"proportion_confint(\n",
|
514 |
+
" count=int(nobs * acc),\n",
|
515 |
+
" nobs=nobs,\n",
|
516 |
+
" method=\"jeffreys\",\n",
|
517 |
+
")"
|
518 |
]
|
519 |
},
|
520 |
{
|
tasks/text.py
CHANGED
@@ -13,7 +13,7 @@ from .utils.emissions import tracker, clean_emissions_data, get_space_info
|
|
13 |
|
14 |
router = APIRouter()
|
15 |
|
16 |
-
MODEL_TYPE = "bert-
|
17 |
DESCRIPTIONS = {
|
18 |
"baseline": "baseline most common class",
|
19 |
"bert-base": "bert base fine tuned on just training data, Nvidia T4 small",
|
@@ -77,7 +77,6 @@ def bert_model(test_dataset: dict, model_type: str):
|
|
77 |
print("Starting model run.")
|
78 |
predictions = np.array([])
|
79 |
for batch in dataloader:
|
80 |
-
print(" Running a batch.")
|
81 |
test_input_ids = batch["input_ids"].to(device)
|
82 |
test_attention_mask = batch["attention_mask"].to(device)
|
83 |
outputs = model(test_input_ids, test_attention_mask)
|
|
|
13 |
|
14 |
router = APIRouter()
|
15 |
|
16 |
+
MODEL_TYPE = "bert-mini"
|
17 |
DESCRIPTIONS = {
|
18 |
"baseline": "baseline most common class",
|
19 |
"bert-base": "bert base fine tuned on just training data, Nvidia T4 small",
|
|
|
77 |
print("Starting model run.")
|
78 |
predictions = np.array([])
|
79 |
for batch in dataloader:
|
|
|
80 |
test_input_ids = batch["input_ids"].to(device)
|
81 |
test_attention_mask = batch["attention_mask"].to(device)
|
82 |
outputs = model(test_input_ids, test_attention_mask)
|