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.
Description
This PR succeeds PR #2547 and #2509. The model tracing is shown therein.
Benchmarked with huggingface transnformers' output.
Ref. https://huggingface.co/blog/how-to-generate
Demo output
In the demo TestLMSearch.java, we feed in batch sequence input, using right padding with the space token ' ' (id = 220).
Output of beam search (numBeam=3, maxLength=50):
Output of greedy search (maxLength=50):
Notes about the GPT2's behaviour with padding and attention mask:
This notes shows that for GPT2, the right padding and left padding can behave very differently, either with attention_mask or without. (The situation with the attention_mask is the most intuitive method). The reason is not totally interpretible yet. But this result will guide the next batching solution.
A. Right padding:
Output:
B. Left padding
A. Right padding
output:
B. Left padding
output =