Hi,
Im fine-tuning multilingual bert for sequence classification as this [CLS] context [SEP] choice [SEP] [PAD] …
Im using the Trainer API
batch_size = 8 # probar con 32
num_train_epochs = 6
logging_steps = len(encoded_datasets['train']) // (2 * batch_size * num_train_epochs)
training_args = TrainingArguments(
output_dir="results",
overwrite_output_dir=True,
num_train_epochs=num_train_epochs,
learning_rate=0.01, # {5e-5, 3e-5, 2e-5, 0.1}
per_device_train_batch_size=batch_size,
per_device_eval_batch_size=batch_size,
load_best_model_at_end=True,
metric_for_best_model="accuracy",
warmup_steps=500,
weight_decay=0.1, # {0, 0.01, 0.1}
evaluation_strategy="epoch",
save_strategy="epoch",
logging_steps=logging_steps,
)
def compute_metrics(eval_pred):
metric = evaluate.load("accuracy")
logits, labels = eval_pred
logitsTensors = torch.from_numpy(logits)
print('eval_pred:', eval_pred)
print('-'*40)
print('logits:', logits)
print('-'*40)
print('labels:', labels)
print('-'*40)
probabilities = torch.softmax(logitsTensors, dim=1)
predictions = torch.argmax(probabilities, dim=1) # [1, 0, 0, 1...] axis=-1
print('predictions: ', predictions)
# return {"accuracy": np.mean(predictions == labels)}
return metric.compute(predictions=predictions, references=labels)
trainer = Trainer(
model=model,
args=training_args,
train_dataset=encoded_datasets['train'], #encoded_datasets['train'],
eval_dataset=encoded_datasets['validation'], #encoded_datasets['validation'],
#data_collator=data_collator,
tokenizer=tokenizer,
# id2label=id2label,
# label2id=label2id,
compute_metrics=compute_metrics
)
I have experimented with different parameters but I almost always get 0.5 in accuracy and my training and validation loss stays almost the same.
What could this mean?
could you recommend me some guideline?
Thank you!