Skip to content
← Explainable AI & Interpretability

/knowledge/notes/marrs-levels

Concept note · Explainable AI & Interpretability

Marr's Three Levels

What a system computes, how it computes it, and what it runs on. Three questions that sound alike and have different answers.

Studied
Background readingNot from a subject
When
Ongoing
Applied in
A framing, not a project
Read / Refreshed
~5 min read2026-10-21

David Marr studied vision, and his lasting idea was not about eyes. He argued that a system that processes information is only understood once you can describe it at three separate levels: what it computes and why, how it computes it, and what physically does the work. I use the framing for thinking about systems of all kinds. It is most useful when a discussion goes in circles, because the two sides are often answering questions at different levels.

01

The idea

The computational level says what problem the system solves and why that is the right problem. It describes a mapping from inputs to outputs and the constraints that make it sensible, without saying anything about steps.

The algorithmic level says how. It picks a representation for the inputs and outputs, and a procedure that turns one into the other.

The implementation level says with what: the physical stuff that runs the procedure, whether that is neurons, transistors, a browser's JavaScript engine or a rack of GPUs.

Marr's own example was a cash register. What it computes is addition, and the properties of addition explain why the order you ring up items cannot change the total. How it adds could be decimal digits with carrying, or binary. What it adds with could be gears or a chip. Each level can change without the others: one computation has many algorithms, and one algorithm has many implementations.

That looseness is the point. Knowing every transistor in a chip would not tell you it is adding, and knowing it adds would not tell you whether it carries in base ten. Marr made the argument against studying vision only through neurons, but it fits machine learning just as well. A loss function and a target sit at the computational level. The model class, the features and the optimiser are algorithmic. The hardware, the numerical precision and the libraries are implementation. When someone asks for an explanation of a model, it helps to ask which of the three they want, because the answers are not interchangeable.

02

The formal core

Marr's levels are a framing rather than a theorem, but each level has a precise object you can write down. The computational level is a function from an input space to an output space. For the widget below it is the median of an odd-length list, the middle order statistic.

f:X→Y,median⁡(x1,…,xn)=x(n+12)for odd nf : \mathcal{X} \to \mathcal{Y}, \qquad \operatorname{median}(x_1, \dots, x_n) = x_{\left(\frac{n+1}{2}\right)} \quad \text{for odd } n

The spec has to settle the awkward cases. For an even-length list, which middle? The widget keeps n odd to avoid the question.

The algorithmic level is a procedure AA, and the only link to the level above is correctness. Any procedure that returns f(x)f(x) on every input counts.

A is correct for f  ⟺  A(x)=f(x)    for every x∈XA \text{ is correct for } f \iff A(x) = f(x) \;\; \text{for every } x \in \mathcal{X}

Correct procedures differ in cost. Counting basic steps gives a measure that belongs to the algorithm and its input, not to any machine.

Tinsertion(n)=O(n2),Tmerge(n)=O(nlog⁡n),E Tquickselect(n)=O(n),Tcounting(n)=O(n+m)T_{\text{insertion}}(n) = O(n^2), \quad T_{\text{merge}}(n) = O(n \log n), \quad \mathbb{E}\,T_{\text{quickselect}}(n) = O(n), \quad T_{\text{counting}}(n) = O(n + m)

Counting is only available because the values are whole numbers from 0 to 99. A choice of representation opens up an algorithm.

The implementation level turns steps into time, and the conversion is a measurement, not a formula. A rough model has a cost per step cc and a fixed overhead t0t_0, both set by the device, the language runtime and how the data sits in memory.

twall≈c⋅TA(n)+t0t_{\text{wall}} \approx c \cdot T_A(n) + t_0

Big-O hides c and t₀. Two algorithms can swap places on a real machine when their constants differ enough.

03

Try it

The widget finds the median of a seeded list of whole numbers from 0 to 99, four different ways. Use the level switch to read the same table one column at a time.

List size

Order

Seed 1

Read the table at

Algorithmic level. The step counts differ by orders of magnitude for the same answer: Counting needs 1,049 steps, Insertion sort needs 246,802.

Four algorithms on the same 1,001 shuffled values from 0 to 99.
AlgorithmMedianStepsTime per run
Insertion sortsort, take the middle47246,802not timed
Merge sortsort, take the middle478,714not timed
Quickselectpartition towards the middle473,290not timed
Countingtally 0 to 99, walk to half471,049not timed

Steps are comparisons, or tallies for counting. Bars use a log scale, so each tick of length is a multiple, not a difference.

All four find the median 47 of 1,001 shuffled values. Counting takes the fewest steps (1,049) and Insertion sort the most (246,802). The time column is empty until you time it.

The list is seeded, so the median and every step count are fixed for a given setting. Only the time column comes from your device.
  • Read at What. Every row reports the same median. At the computational level the four algorithms are one thing.
  • Read at How with 1,001 shuffled values. Insertion sort makes about 247,000 comparisons, while counting needs about 1,000 tallies.
  • Switch the order to Sorted. Insertion sort falls to 1,000 comparisons, the fewest of the four, because each new value is already in place. A step count belongs to an algorithm and its input together.
  • Pick 5,001 shuffled values and time them. Merge sort makes about a hundred times fewer comparisons than insertion sort. Check whether it runs a hundred times faster on your device. It builds new arrays at every level of the recursion, a cost no comparison count sees.
  • Time the same setting twice. The times shift a little and the step counts never move. Implementation numbers are measurements, algorithm numbers are counts.

04

Where I used it

05

Easy to get wrong

06

Sources