# How to batch a multiple sentences (4000+)

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-batch-a-multiple-sentences-4000%2F30310%3E%5C
**Category:** Beginners\
**Created:** [January 24, 2023, 3:03pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-batch-a-multiple-sentences-4000%2F30310 "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](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FTomasAlessi)%5C
**Post date:** [January 24, 2023, 3:03pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-batch-a-multiple-sentences-4000%2F30310%2F1 "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](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fdblakely)%5C
**Post date:** [January 30, 2023, 8:51pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-batch-a-multiple-sentences-4000%2F30310%2F2 "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.
