@@ -315,6 +315,7 @@ Now that those are defined, we just need one additional helper function, which w
315
315
We will get started by loading our model and tokenizer, and then setting up our dataset.
316
316
317
317
.. code :: python
318
+
318
319
# load model
319
320
model_name = " bert-base-cased"
320
321
tokenizer = transformers.AutoTokenizer.from_pretrained(model_name)
@@ -344,6 +345,7 @@ Running the following code gives me an F1 score of 86.9. This is quite close to
344
345
training_args = transformers.TrainingArguments(
345
346
" trainer" ,
346
347
num_train_epochs = 1 ,
348
+ lr_scheduler_type = " constant" ,
347
349
per_device_train_batch_size = 64 ,
348
350
per_device_eval_batch_size = 512 ,
349
351
)
@@ -446,7 +448,7 @@ We will also evaluate the model to show the accuracy degradation of zero-shot pr
446
448
with torch.inference_mode():
447
449
predictions = trainer.predict(tokenized_squad_dataset[" validation" ])
448
450
pruned = compute_metrics(
449
- * predictions.predictions
451
+ * predictions.predictions,
450
452
tokenized_squad_dataset[" validation" ],
451
453
squad_dataset[" validation" ],
452
454
)
@@ -498,7 +500,7 @@ Now that we have a model in this format, we can accelerate it for inference just
498
500
print (" sparse eval metrics: " , metrics_sparse)
499
501
sparse_perf = measure_execution_time(
500
502
model,
501
- batch_sizes_perf_cuda ,
503
+ batch_sizes ,
502
504
tokenized_squad_dataset[" validation" ],
503
505
)
504
506
print (" sparse perf metrics: " , sparse_perf)
0 commit comments