# Pad token vs -100 index\_id

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fpad-token-vs-100-index-id%2F148352%3E%5C
**Category:** Intermediate\
**Created:** [April 1, 2025, 10:39am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fpad-token-vs-100-index-id%2F148352 "2025-04-01T10:39:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vikipedia](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/vikipedia/32/44548_2.png) [@vikipedia](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fvikipedia)%5C
**Post date:** [April 1, 2025, 10:39am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fpad-token-vs-100-index-id%2F148352%2F1 "2025-04-01T10:39:11Z")

</div>

I understand the -100 label id is used so that the predictions for these are not included when calculating the loss.

However [here](https://huggingface.co/patrickvonplaten/bert2gpt2-cnn_dailymail-fp16#bert2gpt2-summarization-with-%F0%9F%A4%97-encoderdecoder-framework), they state “complicated list comprehension here because pad\_token\_id alone is not good enough to know whether label should be excluded or not”, when replacing pad tokens. In the implementation, they use nn.CrossEntropyLoss(), which has an argument “ignore\_index”.

Is there any benefit to changing the id to -100 as opposed to adding the argument ignore\_index in the loss and setting it as the pad token id? Or are the results the same?

The way it is written makes me think there is some benefit, but the description of “ignore\_index” appears to achieve what is wanted. Or was this just a choice in case someone chose to change the pad token id?

---

<div class="post-metadata">

**Author:** ![jgetner](https://avatars.discourse-cdn.com/v4/letter/j/5e9695/32.png) [@jgetner](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fjgetner)%5C
**Post date:** [April 1, 2025, 7:10pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fpad-token-vs-100-index-id%2F148352%2F2 "2025-04-01T19:10:33Z")

</div>

Its just for when someone wants to change the pad token id.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/hellohellohello/original/2X/d/de4155eb4aa4108ecb32a1389d7cc37ae69f88b7.png) [@system](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fsystem)%5C
**Post date:** [April 2, 2025, 9:20am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fpad-token-vs-100-index-id%2F148352%2F3 "2025-04-02T09:20:55Z")

</div>

Closed on April 2, 2025, 9:20am UTC

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.
