Fix image (random multimodal) dataset token statistics (#22371)
This commit is contained in:
@@ -293,6 +293,20 @@ def sample_image_requests(
|
||||
else:
|
||||
print(f"#Images per request: {image_count} (fixed)")
|
||||
|
||||
# Detailed token breakdown (derived from dataset + input_lens)
|
||||
text_prompt_lens = np.array([r.text_prompt_len for r in dataset])
|
||||
vision_prompt_lens = np.array([r.vision_prompt_len for r in dataset])
|
||||
text_prompt_overheads = text_prompt_lens - input_lens
|
||||
stat_fields = [
|
||||
("Raw text prompt tokens (without overhead)", input_lens),
|
||||
("Text prompt tokens (with chat template)", text_prompt_lens),
|
||||
("Text prompt overhead", text_prompt_overheads),
|
||||
("Vision tokens", vision_prompt_lens),
|
||||
]
|
||||
print("\n=== Token Breakdown (per request avg / total) ===")
|
||||
for label, vals in stat_fields:
|
||||
print(f" {label}: avg={np.mean(vals):.1f}, total={np.sum(vals)}")
|
||||
|
||||
print(
|
||||
f"\nCreated {len(dataset)} {image_content} {image_format} images with average {total_image_bytes // num_requests} bytes per request"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user