Skip to content
This repository has been archived by the owner on Nov 22, 2022. It is now read-only.

Dimension mismatch after setting max sequence length #1154

Closed
wants to merge 1 commit into from

Conversation

FanW123
Copy link

@FanW123 FanW123 commented Nov 20, 2019

Summary:
TokenTensorizer and ByteTokenTensorizer has difference way of handling max sequence length. Usually this won't cause any problem if the model does not use the two tensorizers to process inputs and targets.
But for the smart keyboard, it uses TokenTensorizer to process labels and ByteTokenTensorizer to process text inputs. This will cause dimension mismatch if the sentence is longer than the max sequence length.

TokenTokenizer: len(<EOS> + tokens + <BOS>) <= max sequence length
ByteTokenTensorizer: text <= max sequence length

This diff is to change the way ByteTokenTensorizer truncate text to max sequence length the same as TokenTokenize.

Reviewed By: psuzhanhy

Differential Revision: D18566684

@facebook-github-bot facebook-github-bot added CLA Signed Do not delete this pull request or issue due to inactivity. fb-exported labels Nov 20, 2019
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D18566684

…h#1154)

Summary:
Pull Request resolved: facebookresearch#1154

TokenTensorizer and ByteTokenTensorizer has difference way of handling max sequence length. Usually this won't cause any problem if the model does not use the two tensorizers to process inputs and targets.
But for the smart keyboard, it uses TokenTensorizer to process labels and  ByteTokenTensorizer to process text inputs. This will cause dimension mismatch if the sentence is longer than the max sequence length.

```
TokenTokenizer: len(<EOS> + tokens + <BOS>) <= max sequence length
ByteTokenTensorizer: len(tokens) <= max sequence length
```

This diff is to change the way ByteTokenTensorizer truncate text to max sequence length the same as TokenTokenize.

Reviewed By: psuzhanhy

Differential Revision: D18566684

fbshipit-source-id: c5f6e0668c383bdc8eec1cf108466b356cd9adcb
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D18566684

@facebook-github-bot
Copy link
Contributor

This pull request has been merged in 98e6761.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
CLA Signed Do not delete this pull request or issue due to inactivity. fb-exported Merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants