transformers icon indicating copy to clipboard operation
transformers copied to clipboard

Recommended batch size and epochs for finetuning on large data

Open okgrammer opened this issue 7 years ago • 3 comments

In the original paper, BERT model is fine-tuned on downstream NLP tasks, where the number of instances for each task is in the order of thousands to hundreds of thousands. In my case, I have about 5 million samples. I'm curious whether there are recommended batch size and epochs for such training size? I'm fine-tuning bert-base-multilingual on 4 GPUs and there is a lot of unused GPU memory with the default batch size of 32. Even after increasing it to 128 there is still free available memory.

okgrammer avatar Jun 06 '19 03:06 okgrammer

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Aug 05 '19 03:08 stale[bot]

@okgrammer Larger batch size often means lower accuracy but faster epochs. You can try it by doing several runs of varying batch size while keeping other params constant.

See, especially, https://arxiv.org/pdf/1804.07612.pdf

bwindsor22 avatar Sep 12 '19 00:09 bwindsor22

In the original paper, BERT model is fine-tuned on downstream NLP tasks, where the number of instances for each task is in the order of thousands to hundreds of thousands. In my case, I have about 5 million samples. I'm curious whether there are recommended batch size and epochs for such training size? I'm fine-tuning bert-base-multilingual on 4 GPUs and there is a lot of unused GPU memory with the default batch size of 32. Even after increasing it to 128 there is still free available memory.

I have exactly the same issue. Can anyone help? The pretraining is really slow with more than 90% GPU memory available. No matter how I increase the batch size, the GPU memory usage is minimal.

chen2000 avatar Jun 19 '20 00:06 chen2000