Fix token counting to allow there to be no attention mask #818
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When we pretokenize, we just pass raw tensors to the collator, which does not add an attention mask. This is fine, because we pretokenize without padding, but would crash on the token counting function if your tokenizer had a pad token.
IFT token count same before and after
![Screenshot 2023-12-21 at 4 11 02 PM](https://private-user-images.githubusercontent.com/43149077/292342333-e5a7085e-8d86-4bbf-b7a5-0b4810c38028.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk3NjE4ODAsIm5iZiI6MTczOTc2MTU4MCwicGF0aCI6Ii80MzE0OTA3Ny8yOTIzNDIzMzMtZTVhNzA4NWUtOGQ4Ni00YmJmLWI3YTUtMGI0ODEwYzM4MDI4LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE3VDAzMDYyMFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTU1ZWExNmZhZTkwMTMxZTYwN2IwM2M0YTE3NGNjMzAxMTAzYmNjNzY3OWFiNzNiNmQzY2ExZjIwOWYwNjBkYjkmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0._tcxJzS85EgKFVz8mbzhtWNC33okk_fi5KuKGfBqQuc)
pretokenized token count as expected (40x2048x960)
![Screenshot 2023-12-21 at 4 11 13 PM](https://private-user-images.githubusercontent.com/43149077/292342494-8065d2f1-e75d-4d71-9c6d-8add10bd5b32.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk3NjE4ODAsIm5iZiI6MTczOTc2MTU4MCwicGF0aCI6Ii80MzE0OTA3Ny8yOTIzNDI0OTQtODA2NWQyZjEtZTc1ZC00ZDcxLTljNmQtOGFkZDEwYmQ1YjMyLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE3VDAzMDYyMFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPThmNjgzYjc4NzFlYmJiNWY4ZGNhYTY4NjhlMjA5OWNiMjk0YTk2ZTBmZmQ2ODM0MThkY2M4NGRlZmQxMTdiZjMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.lWMD5uBt_MXOrCrtrnzKbDFWDJ4f8o2LDYfko3xH61g)