bert-base-uncased fine-tuned on GLUE/MRPC (EEE 486/586 Assignment 2, Part 1)
BertForSequenceClassification: the [CLS] vector goes through the pooler, dropout and a
linear head. Hyper-parameters were selected with Optuna (TPE) on the MRPC validation split.
| hyper-parameter | value |
|---|---|
| learning rate | 7.69e-05 |
| epochs | 3 |
| max sequence length | 64 |
| classifier dropout | 0.203 |
| batch size | 32 |
| optimizer | AdamW (wd=0.01), linear schedule, 10% warm-up |
| seed | 42 |
| split | accuracy | F1 | loss |
|---|---|---|---|
| validation (408) | 0.8701 | 0.9085 | 0.4206 |
| test (1725) | 0.8342 | 0.8777 | 0.5177 |
The same configuration re-trained with seeds 0-4 gives 83.5 ± 0.6 % test accuracy.
Inputs are sentence pairs truncated to 64 tokens (truncation=True, max_length=64).
from transformers import AutoTokenizer, AutoModelForSequenceClassification
tok = AutoTokenizer.from_pretrained("Talsha0/bert-base-uncased-finetuned-mrpc-eee486")
model = AutoModelForSequenceClassification.from_pretrained("Talsha0/bert-base-uncased-finetuned-mrpc-eee486")
x = tok("The cat sat on the mat.", "A cat was sitting on the mat.",
truncation=True, max_length=64, return_tensors="pt")
print(model(**x).logits.softmax(-1)) # [P(not_equivalent), P(equivalent)]