Datatype tagging and prompt alignment: a recipe for boosting LLMs on algorithmic tasks
Sanchayan Dutta, Suvrit Sra
ICLR 2026 submission
Abstract. This paper contributes toward strengthening the bridge between LLMs as programmers and classical ideas in programming languages (PL). Specifically, we show that aligning prompts with typed programs enables even small models to reliably emit one-line Python code. We present a simple yet effective recipe consisting of three key ingredients: (i) inline datatype tagging for prompt and code; (ii) a fine-tuned dual-head GPT-2-small with an auxiliary span probe over the prompt; and (iii) a fixed decoder that enforces a finite-state grammar, validates AST shape, and repairs outputs deterministically. On a stratified GPT-4o based dataset that covers primitives such as , , , , and , the decoder alone raises execution accuracy by over 40% (from to )! For counting and repeated addition, prompts map deterministically to single expressions (for example, and ), yielding near-zero errors within coverage. Our approach runs on a single GPU, and presents a proof-of-concept on how "datatype-aware tokenization'' and "grammar-first decoding,'' among other ideas inspired by PL, improve reliability, coverage, and quality at low cost.
Are you an author? Claim this paper to see who's reading it, with views and other statistics, and to write about it here.
Claim this paperadd · history
Loading the discussion…