arXiv:2611.06731cs.LGNov 2026

Manuscript Offprint

arXiv:2611.06731

Template Gap Reconstruction for Shell Output Simulation with Small Language Models

Jarrod Ragsdale, Rajendra Boppana

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

ABSTRACT

Small language models offer a compact basis for shell simulation without executing submitted commands, but full-output decoding requires them to predict recurring utility structure alongside content that varies across executions. We introduce template gap reconstruction (TGR), which supplies reusable output literals interspersed with sentinels to be interleaved with autoregressively generated gaps. A template selector chooses which template to be reconstructed, with the empty template retaining full-output decoding. We construct a template bank from 18.7 million outputs collected across heterogeneous execution environments and train a template selector and five reconstruction models initialized from various small language model checkpoints on a target environment excluded from bank construction. Evaluation demonstrates that TGR improves output edit similarity (O-ES) over full-output decoding (FOD) when the optimal template covers more than 25% of the template, while performing similarly for lower-coverage outputs. Additionally, TGR outperforms FOD for shorter gap sequences, with O-ES values of 0.964 and 0.812, respectively, while maintaining similar performance for longer sequences. TGR reduces the number of tokens generated by 26.3–38.3% across used tokenizer families. These results support using a reusable output structure as a practical design choice for small shell simulators, improving response fidelity and shortening generation targets while keeping template selection and residual prediction central to response quality.

1 INTRODUCTION

Small language models generating the output of provided shell inputs offer a promising basis for command-line interaction under limited inference resources. Such an execution-free interface supports compact learned honeypots that interact with untrusted users (Sladić et al., 2024). Prior work uses in-context learning with API-accessible large language models (Sladić et al., 2024) and fine-tuned locally deployed large language models to generate shell output (Otal & Canbaz, 2024; Wei et al., 2026; Sladić et al., 2026b). Ragsdale & Boppana (2025) demonstrate that this task can be extended to smaller language models (<1B parameters) when trained on sufficient quantities of shell input-output pairs. The success of these methods depends on the similarity of the generated output to that of a real system (Bridges et al., 2026). This paper is motivated in the improvement of shell output modeling accuracy using small language models.

Inference depends on the text processed and generated, with autoregressive decoding producing each output token in sequence (Pope et al., 2023). Full-output decoding (FOD) requires a shell output model to predict filenames, values, diagnostics, punctuation, and internal whitespace alongside recurring headings, separators, and wording. Supplying this recurring structure as context offers a way to reduce the prediction burden.

We investigate environment-invariant output templates: ordered literal spans shared by groups of recorded executions. Greedy alignment extracts spans whose empirical invariance is scoped to the construction group. Template gap reconstruction (TGR) supplies a template alongside the input, generates sentinel-delimited template gaps, and interleaves them with copied literals. Retained text thus provides context without remaining in the generation target (Figure 1).

Before the output is known, an input-only selector with a shared Transformer encoder and command-specific heads chooses from a template bank containing the empty template T0T_{0} for each command. A nonempty selection invokes TGR, while selecting T0T_{0} invokes ordinary FOD through the same reconstruction checkpoint. The constructed template bank contains templates extracted from 18.7 million executions across heterogeneous environments.

We evaluate output similarity across five models fine-tuned for shell modeling and TGR spanning approximately 60–600 million parameters: CodeT5-small and CodeT5-base, ByT5-small and ByT5-base, and Qwen3-0.6B (Wang et al., 2021; Xue et al., 2022; Yang et al., 2025). A target envi-

1^{1}Department of Computer Science, University of Texas at San Antonio, USA. Correspondence to: Jarrod Ragsdale jarrod.ragsdale@my.utsa.edu.

Figure

Figure 1. Full-output decoding (FOD) and template gap reconstruction (TGR) producing the same complete shell response. Blue marks copied template literals, and orange marks generated text. Sentinel markers delimit the generated gaps.

ronment supplies 1 million examples for selector and reconstruction training. Oracle assignment uses the reference output to maximize admissible coverage and defines the coverage and reference-gap length used to group all methods.

Selected TGR improves mean complete-response fidelity across all five models. Oracle TGR improves mean output edit similarity (O-ES) over FOD in every reported coverage group above 25%, with learned selection yielding consistent gains above 50%. Selected TGR achieves O-ES of 0.879 compared with 0.742 for FOD in the (50, 75]% coverage group. For responses with 0–64 reference-gap characters, equally weighting the three reported length groups gives mean O-ES of 0.964 for oracle TGR compared with 0.812 for FOD. The advantage diminishes for longer gaps, with closer scores of 0.772 and 0.790, respectively, in the longest reference-gap group. TGR also shortens mean tokenized reference targets by 26.3–38.3% across tokenizer families, including sentinel overhead.

We make the following contributions:

  1. We formalize reusable templates for complete shell responses and provide a greedy construction procedure that preserves admissibility within each group of recorded executions.

  2. We combine an input-only, command-specific selector with a reconstruction checkpoint jointly trained for sentinel-delimited gap generation and ordinary full-output fallback.

  3. We evaluate this interface for small language models at fixed reconstruction weights, distinguishing complete-

response fidelity, generated-gap fidelity, and reference-target length across five backbones.

References (29)