Code as Explanations: NeurIPS paper makes LLMs explain behavior in executable code

steph_milani · x · 2026-12-03

LLM explanations are usually free-form text, one per input — but understanding a behavior requires observing it across scenarios, and a text explanation tied to one input can't be evaluated on arbitrary inputs.

A NeurIPS 2026 thread presents an alternative: have the model explain itself in code. The model writes an executable decision function (e.g., counting fruits), which is then run on many held-out inputs and compared against the model's actual outputs. In the illustrated example, the model-generated solve(arr) function misclassifies mangoes as non-fruit, predicting 2 where the truth is 1 — exposing a behavioral flaw. Executable "code as explanations" can be systematically evaluated instead of taken on faith.

Original post →

More from Models

Models channel →