-
Notifications
You must be signed in to change notification settings - Fork 27.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Qwen2Audio] handle input ids expansion during processing #35534
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks 🤗
# test the error when incorrect number of audio tokens | ||
inputs["input_ids"] = torch.tensor( | ||
[ | ||
[ | ||
151644, | ||
8948, | ||
198, | ||
2610, | ||
525, | ||
264, | ||
10950, | ||
17847, | ||
13, | ||
151645, | ||
198, | ||
151644, | ||
872, | ||
198, | ||
14755, | ||
220, | ||
16, | ||
25, | ||
220, | ||
151647, | ||
] | ||
+ [151646] * 200 | ||
+ [ | ||
151648, | ||
198, | ||
3838, | ||
594, | ||
429, | ||
5112, | ||
30, | ||
151645, | ||
198, | ||
151644, | ||
77091, | ||
198, | ||
] | ||
] | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use # fmt: skip
What does this PR do?
This PR adds input_id expansion to the processor.
Before:
"<|audio_bos|><|AUDIO|><|audio_eos|>Generate the caption in English:"
→inputs_embeds
tensorNow:
"<|audio_bos|><|AUDIO|><|audio_eos|>Generate the caption in English:"
→"<|audio_bos|><|AUDIO|>...<|AUDIO|><|audio_eos|>Generate the caption in English:"
with as many<|AUDIO|>
tokens as the number of audio embedded vectors after encoding and projectioninputs_embeds
, directly with the correct shapeThis approach allows to remove the unnecessary step of creating a new embedding tensor in the model forward. Moreover, it simplifies the code as correct padding is directly handled at the processing stage.