# How to batch a multiple sentences (4000+)

**URL:** <https://discuss.huggingface.co/t/how-to-batch-a-multiple-sentences-4000/30310>\
**Category:** Beginners\
**Created:** [January 24, 2023, 3:03pm UTC](https://discuss.huggingface.co/t/how-to-batch-a-multiple-sentences-4000/30310 "2023-01-24T15:03:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![TomasAlessi](https://avatars.discourse-cdn.com/v4/letter/t/a9adbd/32.png) [@TomasAlessi](https://discuss.huggingface.co/u/TomasAlessi)\
**Post date:** [January 24, 2023, 3:03pm UTC](https://discuss.huggingface.co/t/how-to-batch-a-multiple-sentences-4000/30310/1 "2023-01-24T15:03:39Z")

</div>

I’m using finbert pretrained model for text classificantion, i have passed my 4000+ sentences through the tokenizer to create my batch, but when i pass this batch to the model to get my outputs it’s takes infinite time and can’t process, when i pass 2000-3000 sentences it’s takes time but the model can process. How can i pass 4000+ sentences ?

---

<div class="post-metadata">

**Author:** ![dblakely](https://avatars.discourse-cdn.com/v4/letter/d/54ee81/32.png) [@dblakely](https://discuss.huggingface.co/u/dblakely)\
**Post date:** [January 30, 2023, 8:51pm UTC](https://discuss.huggingface.co/t/how-to-batch-a-multiple-sentences-4000/30310/2 "2023-01-30T20:51:12Z")

</div>

Is this for training or inference?

If training, you should follow the Hugginface training examples to learn how to use batching and a data loader.

If it’s for inference, you can write a small script that splits the 4000 sentences into smaller batches that each contain several dozen sentences. Iteratively feed those into your model and accumulate the outputs.
