Skip to content

Token count discrepancy when using Qwen2.5-VL with multiple images #3177

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

Open
4 tasks
JjjFangg opened this issue Apr 15, 2025 · 0 comments
Open
4 tasks

Token count discrepancy when using Qwen2.5-VL with multiple images #3177

JjjFangg opened this issue Apr 15, 2025 · 0 comments

Comments

@JjjFangg
Copy link

System Info

I'm experiencing a token count discrepancy when using the Qwen2.5-VL model.

I uploaded 5 images with a resolution of 2048 x 1365 under the setting max_pixels=16384, and the total token count reported was around 71,000 tokens. However, when I use the Qwen2.5-VL processor locally to preprocess the same images, the total token count is only around 18,000 tokens.

This significant difference is causing inference failures on hosted endpoints due to token limits.

Could you please help clarify:

Why the token count is so much higher via the endpoint?

Is there a recommended way to align the endpoint token count with local processing?

Any way to reduce the token usage on multi-image inputs?

Thanks in advance!

Information

  • Docker
  • The CLI directly

Tasks

  • An officially supported command
  • My own modifications

Reproduction

chat_completion = client.chat.completions.create(
model="tgi",
messages=[
{
"role": "user",
"content": [
{
"type": "image_url",
"image_url": {
"url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-VL/assets/demo.jpeg"
}
},
{
"type": "image_url",
"image_url": {
"url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-VL/assets/demo.jpeg"
}
},
{
"type": "image_url",
"image_url": {
"url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-VL/assets/demo.jpeg"
}
},
{
"type": "image_url",
"image_url": {
"url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-VL/assets/demo.jpeg"
}
},
{
"type": "image_url",
"image_url": {
"url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-VL/assets/demo.jpeg"
}
},
{
"type": "text",
"text": "Describe this image in one sentence."
}
]
}
],
top_p=None,
temperature=None,
max_tokens=150,
stream=True,
seed=None,
stop=None,
frequency_penalty=None,
presence_penalty=None
)

Expected behavior

Total token is about 18,000.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant