Decalage: Uncovering the Gap Between Model-Generated Reasoning and Actual Code Implementation in Small Language Models
Saif Uddin Mahmud, Afsana Tasnim, Ahmed Ryan, Md Rayhanur Rahman
Abstract
Agentic code generation often asks a model to explain its reasoning before it writes code, and a common way to make such a workflow safer is to add a security instruction to the prompt. We test what that instruction does in small language models, which are attractive because they run locally and cheaply. Four open code models of 1.5B to 3B parameters generate C++ from 166 sections of eleven public requirements documents, once with a general prompt and once with a secure prompt. The secure prompt more than doubles the share of reasoning about validation, resource handling and threats, and we find no evidence that the rise is larger for requirements with security content. The code changes only in part. Among functions with a body and reasoning, the share with a check that our lexical test recognises rises from 23% to 39%, but more than a quarter of the functions remain stubs, compile rates stay low, and half or more of the functions whose reasoning mentions a check contain no such check. Two rounds of compiler-feedback repair leave more than 80% of sections unusable, and neither cppcheck nor an exploratory ESBMC run separates the prompts on the usable code. A hand check by two annotators supports the stub measure and the direction of the reasoning result. For small models, a security instruction changes the reasoning broadly but the code only in part, so the reasoning should be checked against the code rather than trusted.
Create a lesson
Related papers
Guided Generation of Linux Kernel Semantic Patches with Small Local Language Models
Shared title terminology · Mohanned Ahmed
Static Analysis Guidance for Secure LLM Code Generation
Shared title terminology · Daniele Lunghi, Alberick Euraste Djiré, Zacharie Chenail-Larcher et al.
From Industrial Product Documentation to Automated Digital Product Passport Generation: An Experimental Study of Large Language Models
Shared title terminology · Marco Buecheler, Grant Richards, Nathan Hartman
Option-GRPO: Hierarchical RL Against AI Slop in Code Generation for Unseen SDKs
Shared title terminology · Prashank Kadam
Scientific Coding with Large Language Models: Evidence from Finite Element Analysis
Shared title terminology · Erfan Hamdi, Joel Shor, Emma Lejeune
How Specification Explicitness Shapes Failure in LLM-Generated Code
Shared title terminology · Elmira Onagh, Maleknaz Nayebi