Understanding Counting Mechanisms in Large Language and Vision-Language Models

Hosein Hasani, Amirmohammad Izadi, Fatemeh Askari, Mobin Bagherian, Sadegh Mohammadian +2 more
11/21/2025
cs.CVcs.AI

No confident code implementation found for this paper. 3 possible matches can be shown below.

Abstract

This paper examines how large language models (LLMs) and large vision-language models (LVLMs) represent and compute numerical information in counting tasks. We use controlled experiments with repeated textual and visual items and analyze model behavior through causal mediation and activation patching. To this end, we design a specialized tool, CountScope, for mechanistic interpretability of numerical content. Results show that individual tokens or visual features encode latent positional count information that can be extracted and transferred across contexts. Layerwise analyses reveal a progressive emergence of numerical representations, with lower layers encoding small counts and higher layers representing larger ones. We identify an internal counter mechanism that updates with each item, stored mainly in the final token or region and transferable between contexts. In LVLMs, numerical information also appears in visual embeddings, shifting between background and foreground regions depending on spatial composition. Models rely on structural cues such as separators in text, which act as shortcuts for tracking item counts and influence the accuracy of numerical predictions. Overall, counting emerges as a structured, layerwise process in LLMs and follows the same general pattern in LVLMs, shaped by the properties of the vision encoder.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. 3 weaker matches are hidden by default — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Similar Papers

Cite this paper

@article{hasani2025understanding,
  title  = {Understanding Counting Mechanisms in Large Language and Vision-Language Models},
  author = {Hosein Hasani and Amirmohammad Izadi and Fatemeh Askari and Mobin Bagherian and Sadegh Mohammadian and Mohammad Izadi and Mahdieh Soleymani Baghshah},
  year   = {2025},
  eprint = {2511.17699},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2511.17699v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2511.17699.svg)](https://codeofpaper.com/paper/2511.17699)

Discussion