# Different sentiments when texts processed in batches vs singles

**URL:** <https://discuss.huggingface.co/t/different-sentiments-when-texts-processed-in-batches-vs-singles/19462>\
**Category:** Intermediate\
**Created:** [June 22, 2022, 3:28pm UTC](https://discuss.huggingface.co/t/different-sentiments-when-texts-processed-in-batches-vs-singles/19462 "2022-06-22T15:28:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kayne88](https://avatars.discourse-cdn.com/v4/letter/k/22d042/32.png) [@kayne88](https://discuss.huggingface.co/u/kayne88)\
**Post date:** [June 22, 2022, 3:28pm UTC](https://discuss.huggingface.co/t/different-sentiments-when-texts-processed-in-batches-vs-singles/19462/1 "2022-06-22T15:28:55Z")

</div>

I was observing a strange behavior in sentiment analysis with a finetuned model and tokenizer. Basically, when I tokenize the texts and give them individually as input to the model, it produces different class probabilities compared to when I tokenize and input as batch.

Here’s my observation:

```auto
text = tweets["eth"]["text"].values.tolist()[0]
print(text)
encoded_input = tokenizer(text, return_tensors='pt', padding=True, truncation=True, max_length=512)
output = model(**encoded_input)
softmax(output.logits.detach().numpy())

```

Outputs:

```auto
ethereum will be back above xxx at some point im buying more now
array([[1.9731345e-04, 1.1291850e-03, 9.9867338e-01]], dtype=float32)

```

Whereas

```auto
text = tweets["eth"]["text"].values.tolist()[:2]
print(text)
encoded_input = tokenizer(text, return_tensors='pt', padding=True, truncation=True, max_length=512)
output = model(**encoded_input)
softmax(output.logits.detach().numpy())

```

Outputs:

```auto
['ethereum will be back above xxx at some point im buying more now', 'tripledigit eth is also a chance of a lifetime']
array([[1.12888454e-04, 6.46036817e-04, 5.71367383e-01],
       [8.55998078e-05, 1.14106620e-03, 4.26646918e-01]], dtype=float32)

```

So, the same sentence yields different class probabilities. What is the issue here? I would of course like to process my data in batches.

Cheers

---

<div class="post-metadata">

**Author:** ![kayne88](https://avatars.discourse-cdn.com/v4/letter/k/22d042/32.png) [@kayne88](https://discuss.huggingface.co/u/kayne88)\
**Post date:** [July 3, 2022, 3:21pm UTC](https://discuss.huggingface.co/t/different-sentiments-when-texts-processed-in-batches-vs-singles/19462/2 "2022-07-03T15:21:18Z")

</div>

any ideas would be helpful
