Visual tokens
A language model reads a sequence of tokens, and an image has to become part of that sequence. In LLaVA-1.5 the image encoder is a ViT with patches on a input, so it returns patch features, and an MLP maps each one to a token: every image costs 576 tokens, the length of a page of text. Two choices change that number. Higher resolution helps the model read small text and see small objects, but the number of patches grows with the square of the side length. Merging neighboring patches before they enter the language model reduces the count. SmolVLM2 uses both. Its SigLIP encoder takes inputs with patches, giving patch features. The connector merges each block of features into one vector (pixel shuffle) and projects it, so a input becomes 64 tokens. The processor first resizes every image so that its longer side islongest_edge pixels, 2048 by default, then cuts it into tiles. Each tile becomes 64 tokens, and a downscaled copy of the whole image adds 64 more, so that the model sees both the detail and the overall layout. The size of the original image therefore does not matter; the setting longest_edge does. The cell builds the same prompt for one photo at four values of longest_edge, and once with splitting turned off, counts the <image> tokens in the input, and times the prefill: the forward pass over the prompt that has to finish before the first answer token appears.
longest_edge = 512 the whole photo fits in one tile and becomes 64 tokens. At 1024 the photo is resized to pixels and cut into tiles, which with the global view gives tokens. At 1536 it is tiles and 448 tokens, and at the default of 2048 it is tiles and 832 tokens, about ten times the length of the text of the prompt. With splitting turned off, only the downscaled whole image is kept, 64 tokens. The prefill time grows much less than the token count, from 30 ms to 42.5 ms, because one short prompt on a large GPU leaves most of the GPU idle. With batches of images, longer conversations or a smaller GPU, the extra tokens cost proportionally more time and memory.
Scoring answers
A model answers in free text, and the score depends on how that text is compared with the reference. Three methods are common. Exact match compares the answer, after lower-casing and removing punctuation and articles, with the reference. It is strict: “two dogs” against the reference “2” counts as wrong. The VQA benchmarks soften it by collecting ten human answers per question and giving full credit when at least three annotators gave the model’s answer, . Benchmarks with multiple-choice questions, such as MMBench and MMMU, avoid the problem by asking for a letter. For open answers such as descriptions, a second, larger model can act as a judge and grade the answer against the reference. This scales, but the judge has its own errors and biases, and its scores are only comparable when the same judge and prompt are used. The training loss is not one of these measures. The SmolVLM lab reached 98% token accuracy on its validation set, because most tokens of each answer are the fixed JSON field names, which says little about whether the listed food items are right. Assignment 3 measures normalized exact match per question and classifies each failure, which is the kind of measurement the loss cannot replace.Object hallucination
A vision language model hallucinates an object when it describes or confirms an object that is not in the image. The language model has learned which objects usually appear together, and that prior can outweigh the visual evidence: a model shown a dining table may report a fork because tables usually have forks. POPE (Polling-based Object Probing Evaluation) measures this with yes/no questions of the formIs there a \{object\} in the image? on COCO photos (arXiv:2305.10355). Half of the questions name an object that is in the image, and the answer is “yes”. The other half name an absent object, chosen in three ways, which gives three test sets of 3,000 questions each:
- random: any COCO object category that is not in the image;
- popular: the categories that appear most often in COCO overall;
- adversarial: the categories that most often appear together with the objects that are in the image.

Exercises
- Repeat the POPE measurement with SmolVLM2-256M and with the model you fine-tuned in the SmolVLM lab. Does fine-tuning on food photos change the hallucination rate on COCO?
- Run POPE with image splitting turned off. Does the lower number of image tokens change the accuracy on any of the three sets?
- Change the question to
Is there a \{object\} in the image? Answer yes only if you are sure.How do precision, recall and the yes ratio move? - Write a scorer for the food extraction task of the SmolVLM lab that reports, per image, whether the JSON parses, and the precision and recall of the listed food items against the label.
Key references
Li et al. introduced POPE and showed that object hallucination in vision language models follows the co-occurrence statistics of their training data (arXiv:2305.10355). Liu et al. describe the LLaVA-1.5 connector and its 576 visual tokens (Liu et al., 2023).References
- Liu, H., Li, C., Li, Y., Lee, Y. (2023). Improved baselines with visual instruction tuning. arXiv [cs.CV].
Found an error on this page? Report an issue.

