Multiple training will give exactly the same result except for the first time

You need to set the seed before instantiating your model, otherwise the random head is not initialized the same way, that’s why the first run will always be different.
The subsequent runs are all the same because the seed has been set by the Trainer in the train method.

To set the seed:

from transformers import set_seed

set_seed(42)
4 Likes