Nestor G Pestelos Jr · Reference · Print this page

Reference Guide

Prompts

Published September 3, 2026 · Human-Computer Interaction & Language Modeling

A prompt is the initial token sequence provided to an autoregressive language model that serves as the conditioning context for subsequent generation. By dictating the prefix sequence over which attention mechanisms compute key-value representations, the prompt restricts the probability distribution of future tokens, shaping the stylistic, logical, and structural boundaries of the generated response.

1. Mathematical Formulation & Conditioning

In autoregressive language models, text generation operates as conditional sequence probability estimation [1]. Given an input prompt consisting of an ordered sequence of \(N\) tokens \(\mathbf{x} = (x_1, x_2, \dots, x_N)\), the language model generates an output completion of \(M\) tokens \(\mathbf{y} = (y_1, y_2, \dots, y_M)\) according to the chain rule of probability:

$$P(\mathbf{y} \mid \mathbf{x}) = \prod_{j=1}^M P(y_j \mid x_1, \dots, x_N, y_1, \dots, y_{j-1})$$

The prompt constitutes the non-negotiable prior. Unlike training updates that alter neural weights \(\theta\), prompt conditioning operates entirely at inference time via the activations of self-attention heads, directing the model across its pre-trained representation manifold without gradient modification.

2. Structural Roles & Templating Formats

Role-Based Schemas (ChatML)

Modern instruction-tuned models segment prompts into functional roles to maintain conversational state and prevent role confusion [2]:

Delimiters & Boundary Tokens

To differentiate roles unambiguously, inference engines serialize structured chat objects into raw text strings using reserved tokenizer tokens (e.g. <|im_start|> and <|im_end|> in ChatML) [3]:

<|im_start|>system
You are an expert technical editor. Provide concise answers.<|im_end|>
<|im_start|>user
Explain prompt prefix caching.<|im_end|>
<|im_start|>assistant

These reserved tokens are assigned dedicated IDs in the model's vocabulary matrix and are masked during training to ensure the model distinguishes developer instructions from user content.

3. System Execution: Prefill vs. Decode Phase

At the hardware level, processing a prompt differs fundamentally from generating output tokens [4]:

4. Security Failures: Injections & Jailbreaks

Because language models process control instructions and raw data within the same continuous token stream (resembling the von Neumann architecture where executable code and user data share identical memory addresses), prompts are susceptible to injection attacks [5]:

See also

References

  1. [1] A. Vaswani, N. Shazeer, N. Parmar, et al., "Attention Is All You Need," in NeurIPS, 2017, pp. 5998–6008. https://arxiv.org/abs/1706.03762
  2. [2] T. Brown, B. Mann, N. Ryder, et al., "Language Models are Few-Shot Learners," in NeurIPS, vol. 33, 2020, pp. 1877–1901. https://arxiv.org/abs/2005.14165
  3. [3] OpenAI, "ChatML Syntax and Specifications," OpenAI Developer Platform Guide, 2023.
  4. [4] R. Pope, S. Douglas, A. Chowdhery, et al., "Efficiently Scaling Transformer Inference," in MLSys, 2023. https://arxiv.org/abs/2211.05102
  5. [5] K. Greshake, S. Abdelnabi, S. Mishra, C. Endres, T. Holz, and M. Fritz, "Not what you've signed up for: Compromising Real-World LLM-Integrated Applications with Indirect Prompt Injection," in Proceedings of the 16th ACM Workshop on Artificial Intelligence and Security, 2023, pp. 79–90. https://arxiv.org/abs/2302.12173