Search code examples
huggingface-transformersmlflow

How can I set the seed that MLFlow uses to randomly generate run names?


I am currently setting the random number generator seed for Hugging Face transformers with transformers.set_seed() . I found that function also sets the seed for MLFlow and, as a consequence, I always get the same sequence of run and nested run names from MLFlow, which is to me undesirable.

After setting the Hugging Face transformers seed, I would like to be able to reset the seed for MLFlow to a different value (or a random value).

How can I set the seed that MLFlow uses to randomly generate run names?


Solution

  • MLFLow uses python module random to randomly generate a run name, see the implementation of _generate_string() in name_utils.py. Therefore the way to set the seed for that would be to just call random.seed().

    The implementation of the transformers set_seed() sets a variety of random seeds, including random.seed().

    It seems to me that in order to have random run names from MLFlow, either I don't call set_seed(), but I manually set the seeds for Numpy and Pytorch, or I call random.seed() myself after calling set_seed().