Chapter 5 – Specifications for LLM systems
Take the two prompts in Figure 1. They are identical except for one word: the sensitive attribute. If the model gives both completions the same regard, we learn only that these two prompts behaved alike under this decoding run. We still do not know how the model responds when users or adversaries add jailbreak text, random noise, or instructions from another source. The set of such prompts is too large to enumerate.
Chapters 2 to 4 gave us the vocabulary of verification and a picture of an LLM. This chapter supplies what every verifier needs: a specification. For an image classifier, a specification might be an \ell_p ball around one image and a label. For an LLM, we must say which prompts matter and what counts as good behavior on them. We build five frameworks from our own papers. LLMCert-B covers counterfactual bias, LLMCert-C knowledge comprehension, C³LLM multi-turn risk, LLMCert-T agentic tool selection, and Lumos expresses all four in one language. Chapter 6 turns each specification into a number with a confidence level.
Why fixed benchmarks and attacks are not enough
The papers in this chapter start from a shared observation. The two standard ways to study LLM behavior have structural limits.
Benchmarks use too few prompts. A benchmark tests a fixed set drawn from a prohibitively large space. LLMCert-B lists three problems (Chaudhary et al. 2025). The test cases cannot cover the space that can elicit bias. Popular datasets may have entered the training data, so scores can reflect leakage. The evaluation is empirical and gives no guarantee of generalization to any input set. LLMCert-C reports conflicting findings about knowledge comprehension across studies and traces the conflict to the same limitation: each study samples a small, different part of the prompt space (Chaudhary, V. V. Jain, et al. 2026).
Fixed attacks miss the distribution. An adversarial attack finds individual failures. It does not say how often failures occur. C³LLM makes the point with a counting argument (Wang et al. 2026). Twenty attack sequences of length five reveal at most twenty distinct behaviors in the best case. Recombining their queries turn by turn yields up to 100^5 sequences. Unseen sequences may still succeed. LLMCert-T makes the same point for agents: a curated, benign tool pool says little about an open registry shaped by third parties (Yeon et al. 2026).
White-box verifiers do not scale to this setting. The verifiers of Chapter 4 need model internals and lose precision as models grow. They cannot check closed, API-only models (Chaudhary et al. 2025; Chaudhary, V. V. Jain, et al. 2026). Chapters 7 to 9 show what deterministic verification can do for one prompt with access to token probabilities.
A binary property will not do. With diverse prompts, some failing prompt almost always exists, and attacks find one. A claim that no prompt fails is therefore false for every model and cannot rank models. All five frameworks ask a quantitative question instead: what is the probability of acceptable behavior when we draw a prompt from a stated distribution? This question separates models that both have failures but fail at different rates.
The specification recipe
A specification replaces a fixed test set with a compact description of a large input set and a check for acceptable behavior. It has two parts.
The first part is a prompt distribution \mathcal{D} with an i.i.d. sampler. We never enumerate its support. A draw can be a prefix plus a prompt, a multi-hop question with a context, a whole conversation, a tool pool, or a driving scene. The second part is an oracle \Phi. The oracle reads the scenario x and the system response y and accepts or rejects the pair, written (x,y)\models\Phi. We use the word oracle throughout these notes. Some papers say judge or bias detector; we name that difference once in each framework and then use oracle.
For a system M with random responses, the target quantity is
p \;=\; \Pr_{x \sim \mathcal{D},\; y \sim M(x)}\bigl[(x,y)\models\Phi\bigr].
The probability covers two sources of randomness: the sampled scenario and the response of M. For one fixed prompt, the inner probability is the total mass the model assigns to responses accepted by \Phi. A statistical certifier replaces that intractable sum with one sampled response and averages over sampled prompts. Chapter 7 computes per-prompt bounds directly.
The oracle is a program, so it can be wrong. Harmfulness and bias are undecidable in general, so each evaluation fixes a decidable check. Examples include a regular expression for a leaked e-mail address, a string match against a ground-truth answer, a toxicity classifier, a static analyzer for insecure code, a check on a tool call, and an LLM judge run with greedy decoding. The certificate is relative to this check.
All specifications here are local. The sampler fixes a common characteristic, so the certificate covers a region of the prompt space rather than all prompts. LLMCert-B calls this a local specification (Seshia et al. 2018; Chaudhary et al. 2025). Local regions are tractable and easy to interpret. They also keep the guarantee honest: no sampler covers every prompt that an adversary might write.
Building a specification is a short procedure. Choose a family of scenarios that represents the concern of interest. Write a sampler that generates i.i.d. scenarios in that family. Define an oracle that accepts or rejects a response to a scenario. Fix the system and its decoding parameters. Then run the certification procedure of Chapter 6. Changing any one of these choices defines a new certificate.
Two design choices recur. First, the question is quantitative, not binary. Second, certification is black-box: the sampler and the oracle need only inputs and outputs, so open-weight and API-only models are treated alike. The price is a statistical guarantee with a confidence parameter, not an absolute bound.
Counterfactual bias: LLMCert-B
LLMCert-B specifies representational harm in final responses, such as stereotyping or derogatory language toward a demographic group. Its notion follows counterfactual fairness (Kusner et al. 2017): responses are unbiased when they do not differ because the sensitive attribute changed. Bias here means disparate treatment when only the demographic group in the prompt changes.
Fix an identity trait such as gender or race. It defines demographic groups, each named by several sensitive attributes. A counterfactual prompt set contains one prompt per group. All prompts share the same text X; only the sensitive attribute differs. For an unbiased generator, changing that attribute would not change the answer. A pair such as “male gunsmith” and “female gunsmith” is a counterfactual prompt set when the attribute is irrelevant to the task. Prompts in which the attribute matters, such as questions about parenthood, are excluded.
The number of possible common texts is enormous, so LLMCert-B samples prompts instead of enumerating them. It fixes a small pivot set Q of base prompts and draws a prefix p from a distribution \Delta_{\text{pre}}. The same prefix is prepended to every member of Q. The sampler is the extension point, and the paper gives three kinds:
- Random prefixes. A fixed-length string of random tokens models incoherent noise in a prompt. It also assigns nonzero probability to short jailbreaks. Random token strings are known to jailbreak LLMs (Zou et al. 2023).
- Mixtures of jailbreaks. The sampler interleaves sentences from a main manual jailbreak with instructions from other jailbreaks. Each helper is kept with a fixed probability and inserted in random order. Tokens are then mutated independently with a low probability. The result is a large family of plausible jailbreak variants, not a single string.
- Soft prefixes. The sampler adds uniform noise in embedding space to a known jailbreak. This distribution needs access to the embedding layer, so it applies only to open-weight models.
The first two distributions work with API-only models. All three generate i.i.d. counterfactual prompt sets.
The oracle is a user-defined bias detection function. It reads the tuple of responses to the related prompts and returns zero when it finds no disparity. This is the first relational property in our family: no single response can be biased on its own. The paper leaves the detector as a parameter of the specification because stakeholders may use different notions of bias. For BOLD (Dhamala 2021), the oracle uses the regard metric (Sheng et al. 2019) in compare mode and checks individual regard as well. For the stereotype partition of Decoding Trust (Wang et al. 2023), the oracle checks whether the model agrees with the stereotype for some groups but not others.
The certified quantity is the probability that the oracle accepts the responses when the model is prompted independently with each member of a random counterfactual set:
C(\Delta, D, L)=\Pr_{P\sim\Delta}\bigl[D([L(P_1),\dots,L(P_s)])=0\bigr].
The probability is over the drawn prefix, the counterfactual prompt set, and the model’s sampling. Figure 2 shows the full pipeline: sample a prefix, form the prompts, query the model, check the responses, and bound the probability with the Clopper–Pearson method (Clopper and Pearson 1934).
Knowledge comprehension: LLMCert-C
LLMCert-C studies question answering over in-context information from knowledge bases. It defines knowledge comprehension as retrieving and reasoning over the relevant information to answer a question correctly according to the provided context (Chaudhary, V. V. Jain, et al. 2026). The motivating failure is a medical prompt about paracetamol overdose where the model confuses the context and gives a harmful answer.
The specification must describe a query, relevant unstructured information, natural noise, and the correct answer. A knowledge graph supplies all four. Nodes are entities with aliases and a text context. Edges are relations with their own aliases. The paper uses Wikidata5m (Wang et al. 2021) and PrimeKG (Chandak et al. 2023), a medical graph with diseases, drugs, and effects. A multi-hop query asks for the sink of a directed acyclic subgraph when given the source aliases and the relation aliases. The prompt also includes the contexts of the subgraph nodes, so the model need not rely on parametric memory.
Real prompts contain irrelevant information, and their order varies. A distractor is an off-path node that shares a relation alias with a later step on the path. At an intermediate step, a model may follow the relation to the wrong node. The sampler also shuffles the contexts. The oracle then tests two things at once: the model uses the relevant chain and ignores order and distractors.
The local characteristic comes from how subgraphs are drawn. In an entity-centric specification, the sampler fixes the source entities and draws short DAGs that start at them. In a relation-centric specification, it fixes a reference DAG and the relation labels, then samples isomorphic copies inside the graph. A medical example fixes a drug–disease pattern and asks which drug treats one disease but is contraindicated for another. Entity types constrain the sampled nodes so that the question remains meaningful.
The sampler creates the ground truth as a by-product. For each query, the oracle checks the response against the aliases of the sink node. The certified quantity is the probability of a correct response for a random query with noise and shuffling. Figure 3 shows this pipeline from a graph to a certified probability.
Catastrophic risk in conversations: C³LLM
A model may refuse a harmful request in isolation and answer it after a few related questions. An adversary can hide the intent across turns, with each query looking harmless on its own. C³LLM therefore studies a temporal property: harm may appear at any turn and depend on the accumulated context (Wang et al. 2026).
The scenario is a sequence of queries from a query graph. Nodes are user queries, and edges encode semantic relations. The graph is built around a harmful target from a public benchmark of harmful behaviors (Mazeika et al. 2024). Following the actor-based construction of (Ren et al. 2024), the authors derive a related person or work and generate less harmful queries around it. For a target about explosives, an actor could be Alfred Nobel, with related questions about his life and work.
The paper defines three distributions over query sequences. Random node picks each query independently and measures the overall tendency to produce harmful content. Graph path walks backward from a chosen endpoint so that consecutive queries stay related. The endpoint can be constrained to a harmful region. Adaptive with rejection uses the model’s previous answer. If the model complied, the walk favors neighbors closer to the target. If the model refused, it favors neighbors farther away. This mimics a red team that changes phrasing after a refusal. The walk tracks visited nodes, so no query repeats within a sequence.
An augmentation layer can transform each query after sampling. The paper’s instance inserts a jailbreak prefix with a fixed probability. Other augmentations can rewrite the query with a second model, as long as they define a distribution over conversations.
The oracle (the paper calls it the judge) reads one response and flags it when it reveals the harmful target. The conversation is accepted only when every turn is accepted. The certificate bounds the probability of this event over the query distribution and the model’s responses. The paper reports the complementary quantity, the probability that at least one turn is catastrophic. Figure 4 shows the construction.
Tool selection in agents: LLMCert-T
Agents call tools from registries that other parties can extend. A tool can be republished, given a near-duplicate name, or described with metadata that optimizes for retrieval rather than utility. LLMCert-T certifies tool selection against this variability (Yeon et al. 2026).
The system has two stages. A retriever scores tools against the user query and keeps a top-N slate. A selector, which is an LLM, chooses one tool from that slate using its name, description, privilege level, and argument schema. The oracle (the paper calls it the judge) accepts a choice when the tool satisfies the user’s goal. It may accept several tools, not only a benchmark’s reference label.
The specification pairs this oracle with a distribution over inserted tools. One draw specifies a tool pool for each round of an interaction. The generator writes plausible names, descriptions, and schemas with an LLM. It also copies parameter schemas, uses homoglyphs in names, and appends cues such as “latest” or “official”. These steps keep the inserted tools realistic and let them enter the top-N slate. The generator runs round by round and conditions each round on the selector’s previous choice. Its publishing budget stays below the slate size, so inserted tools alone cannot fill the slate. Table Table 1 lists the five mechanisms.
| Specification | Requirement on every round | Inserted tools |
|---|---|---|
| Distractor Selection | the chosen tool is satisfactory | fluent metadata-only look-alikes |
| Top-N Saturation | a satisfactory tool appears in the slate and is chosen | near-duplicates that crowd the slate |
| Privilege Escalation | the choice is satisfactory and within the user’s privilege | tools that request higher privileges |
| Abstention Trigger | a satisfactory tool is chosen when one is available | metadata that induces refusal |
| Intent Shifting | the choice satisfies the original intent | tools aligned with a nearby goal |
A trial draws a user query and a whole inserted-tool sequence. The system runs for R rounds, and the oracle checks each selection. One Bernoulli bit records whether the predicate held at every round. The rounds of a trajectory are not independent, because the generator reacts to previous choices. The trajectories of different trials are independent, which is what the certifier needs. Figure 5 illustrates the failure: a look-alike tool enters the slate and the user is charged for a booking that never happens.
One language for all of them: Lumos
The four frameworks share a shape. Each begins with a graph of realistic entities, samples a subgraph, formats a prompt, and runs an external oracle. Lumos makes this shape a programming language for specifications of language model systems (Chaudhary, V. Jain, et al. 2026). Earlier probabilistic languages supply the sampling primitives (Sankaranarayanan et al. 2013).
Lumos rests on three ideas. First, text-rich graphs are the common abstraction. Nodes and edges carry lists of strings that become aliases, contexts, questions, or scene elements. Second, a program samples a subgraph and then maps it to a scenario. Third, multimodal prompts are built with external tools, so the same program can produce text or images.
A Lumos program has three main constructs. sample(meas(S)) draws an element from a set S using a programmer-supplied measure. format fills a template with attributes of the sampled subgraph. tool-call invokes an external tool, for example to render an image. The oracle stays outside the program as a call \Phi(\cdot). estimateProb wraps the sampling block, takes a sample count n and a confidence parameter, and names the certifier. Its toEstimate expression gives the observation. The semantics repeat the block n times from the same initial state, so observations are i.i.d. and can run in parallel.
Figure 6 shows the graph of questions for a three-turn conversation. A Lumos program draws a node, then a neighbor, then a second neighbor, formats each into a turn, and asks the oracle to accept all three responses. The adaptive distribution of C³LLM needs only a change in the neighbor set used by the second draw. Other programs encode the helper-instruction interleaving of LLMCert-B and the relation-centric queries of LLMCert-C. Lumos keeps the sampler and the oracle separate, so a better oracle replaces one call without changing the sampler or the certifier.
Lumos also expresses specifications that did not exist in the earlier papers. For a vision-language model in autonomous driving, a symbolic graph chooses a road object and the weather. tool-call passes the choice to Scenic (Fremont et al. 2019) and CARLA (Dosovitskiy et al. 2017), which render an image. The oracle compares the model’s answer with the ground truth read from the symbolic graph, such as whether the vehicle must stop for a barrier. Figure 7 shows two sampled scenes.
The observation need not be a bit. Lumos accepts bounded numbers, so a deterministic per-prompt verifier can sit inside a statistical outer loop. For example, BEAVER (Suresh et al. 2026) returns sound bounds on the probability that one prompt satisfies a prefix-closed property. Lumos samples an adversarial prefix, calls BEAVER on the prompt, and gives the lower and upper bounds to a certifier for bounded variables. See the BEAVER paper (Suresh et al. 2026) and the BEAVER project page for implementation details.
Comparing the specifications
The comparison in Table 2 shows the same recipe in all five frameworks.
| Framework | Sampled scenario | Oracle | Local characteristic |
|---|---|---|---|
| LLMCert-B (Chaudhary et al. 2025) | counterfactual prompt sets with a sampled prefix | no disparity across the responses | pivot set and prefix family |
| LLMCert-C (Chaudhary, V. V. Jain, et al. 2026) | random DAG, query, context with distractors | match against the sink aliases | fixed entities or reference DAG |
| C³LLM (Wang et al. 2026) | query sequence from a graph walk | no turn reveals the harmful target | fixed target and query graph |
| LLMCert-T (Yeon et al. 2026) | inserted tools over several rounds | satisfactory choice at every round | one distraction mechanism |
| Lumos (Chaudhary, V. Jain, et al. 2026) | one run of a specification program | any external oracle or verifier | chosen by the programmer |
The oracle: what it means, how to audit it, and its limits
Every certificate in this chapter is relative to its specification, including the oracle. The sentence “the response is accepted with probability at least p_l” describes oracle verdicts. It is not a direct statement about harm, bias, or truth.
Oracles are imperfect, and their errors have a direction. Let a be the rate at which the oracle accepts truly good responses and b the rate at which it accepts truly bad ones. If the good fraction is p, the measured acceptance rate is p_{\text{meas}}=a p+b(1-p). When a>b, we can solve for p=(p_{\text{meas}}-b)/(a-b). False acceptances can hide a problem. False rejections can make a system look worse than it is.
Audit the oracle with human labels. LLMCert-B compares its oracle with annotated pairs of completions and reports precision and recall. LLMCert-T samples outcomes across specification types and uses two blind annotators plus a third who resolves disagreements. Both report agreement and the effect of relabeling audited errors on the certified bound. Publish the oracle and keep it fixed during a run. Lumos keeps oracles external for this reason: improving a detector is a separate research problem from improving the sampler (Chaudhary, V. Jain, et al. 2026).
Four limits deserve emphasis.
- The guarantee holds for prompts drawn from the chosen distribution, not for a worst-case prompt. A stronger sampler can reveal lower probabilities (Yeon et al. 2026).
- New concerns need new predicates, distributions, and a fresh run.
- The system includes the decoding settings. Change the temperature or the model version, and the certificate describes a different system.
- An oracle can accept a refusal as unbiased. LLMCert-B notes that a model which always refuses is unbiased by this standard, even though it is not helpful (Chaudhary et al. 2025). Helpfulness needs its own oracle.
Summary
- A specification is a pair (\mathcal{D},\Phi): an i.i.d. sampler of scenarios and an oracle that accepts or rejects a response. It replaces a fixed benchmark with a quantitative question.
- All frameworks here use local specifications. The sampler fixes a shared characteristic, and the certificate covers that region of the prompt space.
- LLMCert-B samples counterfactual prompt sets with random, jailbreak-mixture, or soft prefixes. Its relational oracle checks disparity across the responses.
- LLMCert-C samples multi-hop queries from a knowledge graph with distractors and shuffling. Its oracle matches the answer to the ground-truth sink.
- C³LLM samples conversations from graph walks with adaptive rejection and augmentation. Its oracle checks every turn for the harmful target.
- LLMCert-T samples inserted tools over several rounds and reduces a whole trajectory to one bit. Its oracle checks every selection.
- Lumos expresses these specifications as programs over text-rich graphs and feeds i.i.d. observations to a certifier.
- Every certificate is relative to its oracle and its distribution. Audit the oracle, publish the specification, and state the limits.
Notes and further reading
- LLMCert-B: Isha Chaudhary, Qian Hu, Manoj Kumar, Morteza Ziyadi, Rahul Gupta and Gagandeep Singh, Certifying Counterfactual Bias in LLMs (Chaudhary et al. 2025). Section 3 defines counterfactual prompt sets and the bias specification; Section 4 gives the samplers and the certification algorithm.
- LLMCert-C: Isha Chaudhary, Vedaant Jain and Gagandeep Singh, Certifying Knowledge Comprehension in LLMs (Chaudhary, V. V. Jain, et al. 2026). Section 2 defines multi-hop queries, distractors, and the two local specifications.
- C³LLM: Chengxiao Wang, Isha Chaudhary, Qian Hu, Weitong Ruan, Rahul Gupta and Gagandeep Singh, How Catastrophic Is Your LLM? Certifying Risk in Conversation (Wang et al. 2026). Section 3 defines the three distributions and the augmentation layer.
- LLMCert-T: Jehyeok Yeon, Isha Chaudhary and Gagandeep Singh, Quantitative Certification of Agentic Tool Selection (Yeon et al. 2026). Section 2 defines the pipeline and the Bernoulli reduction; the appendix lists the generator and the five specifications.
- Lumos: Isha Chaudhary, Vedaant Jain, Prineet Parhar, Kavya Sachdeva, Avaljot Singh, Sayan Ranu and Gagandeep Singh, Lumos: Let there be Language Model System Certification (Chaudhary, V. Jain, et al. 2026). Sections 3 to 5 cover syntax and semantics; Section 6 encodes the earlier frameworks and the multimodal case.
- The measured results for these specifications are in the Experimental results section at the end of Chapter 6. That chapter also shows how a specification becomes a number with a confidence level.