Making Emotion Labels Depend on Appraisals: Constrained Decoding as an Intervention Tool for Implicit Emotion Detection

When people write "the biopsy results came back completely clear" or "I'm still waiting on my boss to reply," they express relief or anxiety without naming either feeling. Psychologists explain such inferences with appraisal theory: an emotion follows from how a person evaluates a situation, for example whether it helps their goals, who is responsible, and how certain the outcome is. Language models are bad at this in a specific way. When emotion words are scrubbed from text, their accuracy collapses, and when a vignette mentions unfairness they predict anger whether or not anger fits. Both failures suggest the same diagnosis: the model's emotion label does not actually depend on any appraisal of the situation.

This proposal uses grammar-constrained decoding as a scientific instrument and not as a formatting fix. Grammar-constrained decoding masks, at each generation step, every token that would break a formal grammar. The grammar forces the model to commit to a closed-vocabulary appraisal record before it may emit an emotion label. The label is then read off as an average over many sampled appraisal records instead of one noisy guess. Because the appraisal fields are exact token positions with a fixed set of values, we can also force a field to a counterfactual value, such as "the self caused this" versus "someone else caused this," and measure whether the label moves the way the theory predicts. The claim is that this pairing of marginalizing and intervening is what removes the error propagation that sank earlier appraisal pipelines, and that it gives the first direct measurement of whether a model's emotion predictions are driven by appraisals at all.

Core Claim

Two findings in the literature point to one mechanism. Appraisal Theories for Emotion Classification in Text predicts seven appraisal dimensions with CNN classifiers on enISEAR, then maps them to emotions. Gold appraisals raise emotion F1 from 60% to 66%, but predicted appraisals drop it to 48%, because the pipeline commits to hard, uncalibrated intermediate values. Beyond Context to Cognitive Appraisal builds the ToMEmoReason Prisoner's Dilemma vignettes and shows that LLMs exhibit "fairness dominance" and "accountability blindness." In other words, they ignore appraisal variables that the vignettes deliberately manipulate.

We claim both are symptoms of one fact: the label is not causally tied to a well-calibrated appraisal distribution. Our fix has two parts. The first is a theory grammar: a context-free grammar that fixes field order (appraisals first, label last) and closed value sets per field. The second is decoding that estimates the emotion distribution by marginalizing over sampled appraisal records:

$$\hat p(e \mid x) = \frac{1}{K}\sum_{k=1}^{K} p_\theta(e \mid x, a^{(k)}), \qquad a^{(k)} \sim p_\theta(a \mid x) \text{ restricted to the grammar},$$

Here $x$ is the input text, $a$ is a full appraisal record, $e$ is an emotion label, $p_\theta$ is the language model, and $K$ is the number of sampled records.

Faithfulness is measured with an intervention sensitivity score. It is the fraction of items where forcing one appraisal field from value $v$ to $v'$ shifts probability mass toward the emotion the theory predicts:

$$S_{j} = \Pr_x\big[\, p_\theta(e^{*}_{v'} \mid x, a_j{=}v') - p_\theta(e^{*}_{v'} \mid x, a_j{=}v) > 0 \,\big],$$

In this formula, $a_j$ is field $j$ (say, accountability) and $e^{*}_{v'}$ is the theory-predicted emotion under the new value (for example, regret for self-blame and anger for other-blame).

What is new here is not "appraisal-then-label prompting." It is using exact, grammar-level control over the intermediate record to marginalize over it and to test causal dependence on it. Neither is possible when appraisals live in free text.

Research Program

The prior work plays three distinct roles. Appraisal Theories for Emotion Classification in Text and Beyond Context to Cognitive Appraisal motivate the gap. Hard Emotion Test Evaluation Sets for Language Models supplies the stress test: its human rephrasing rounds remove emotion words, and BERT drops from 0.59 to 0.05 F1 on GoEmotions.v2 R4 while OPT-IML drops from 0.65 to 0.15. The method comes from the constrained-decoding line:

We reuse their engines (XGrammar or SynCode). Every one of these papers evaluates only deterministic targets: triplets, SQL, logic formulas, function calls. The first paper also warns that grammar validity alone does not improve semantic accuracy. We take that warning seriously. The grammar is not expected to help by producing valid output; it helps only through marginalization and intervention.

Theory grammars. We will write two. The first encodes the seven Smith and Ellsworth dimensions used on enISEAR, each with a three-value scale, plus an explicit agency field (self, other, circumstance). The second encodes the OCC variables used by A Rule-Based Approach to Implicit Emotion Detection in Text: direction, tense, and event polarity. That paper extracted these variables with a dependency parser that broke on informal text. Here the language model fills the same slots, so the OCC logic becomes a comparison point instead of a brittle front end.

Decoding variants. There are three:

  • Greedy constrained. This is the analogue of the failed pipeline.
  • Marginalized constrained. This follows the first equation, with $K$ samples. Because the grammar is small and non-recursive, we can also run exact enumeration when field-wise factorization is assumed.
  • Scratchpad-then-constrained. A short free-text reasoning span precedes the constrained record, in the style of CRANE.

Local-masking bias. The locally-constrained bias identified in Mitigating Bias in Locally Constrained Decoding via Tractable Proposals matters here, because naive masking distorts $p_\theta(a \mid x)$. We therefore compare plain masked sampling against importance-reweighted sampling, where each sample is weighted by the model's unconstrained probability of the prefix it produced.

Models. We use open-weight models with logit access, which constrained decoding requires: Llama 3.1 8B, Mistral 7B and Gemma 7B, the same families evaluated on ToMEmoReason. We add one larger open model to check scale.

Baselines

The naive reference point is direct label prediction: the model sees the text and emits one label from a grammar-restricted label set. It gets no appraisal record and no reasoning. The published reference numbers are as follows:

The strongest inference-time competitor is unconstrained chain-of-thought with self-consistency. The model reasons freely, emits a label, and we take the majority over $K$ samples. This also averages over latent reasoning, so it is the direct rival to our marginalization. No reported result was found on Lacuna for self-consistency on these emotion benchmarks. The closest reported evidence is that unconstrained CoT trails CRANE on FOLIO, 32.0% versus 46.3% with Llama-3.1-8B.

A second strong competitor is free-text appraisal prompting. The prompt lists the same appraisal questions, and the model answers them in prose before the label. This separates "thinking about appraisals" from "decoding appraisals into a controllable grammar."

The strongest trained competitor is the fine-tuning result from Hard Emotion Test Evaluation Sets, which reports significant gains from roughly 500 rephrased examples. We fine-tune the same base models with a low-rank adapter on the same 500 examples, with the same tuning budget as any trained variant of ours.

Every method uses the same models, the same prompts apart from the component under test, the same number of samples $K$ (matched total generated tokens where lengths differ), and the same development-set tuning of $K$ and temperature.

Two ablations isolate the key ingredient:

  • Greedy constrained versus marginalized constrained, which isolates marginalization.
  • Field order reversed (label first, appraisals after), which tests whether ordering creates the dependence.

Beating the field means three things. First, marginalized constrained decoding must exceed matched-$K$ self-consistency on the scrubbed GoEmotions.v2 R4 and CancerEmo.v2 sets, and must exceed 57.9% on ToMEmoReason with the same models. Second, on enISEAR, marginalization must close most of the gap between the greedy pipeline and the gold-forced oracle. Third, all of this must hold with clearly higher intervention sensitivity.

Why not just…?

Why not just ask for appraisals in free text and parse them with a regex? This is the most serious threat. If free-text appraisal prompting matches our accuracy, the grammar adds nothing to accuracy, and we will report that. The grammar's distinct contribution is that it makes the appraisal record a set of exact token positions. Only then can we compute marginals over closed value sets and force counterfactual values. Free text offers neither, because "someone else was responsible, though partly me" has no single slot to flip. The accuracy comparison settles the first question. The intervention-sensitivity score, which only the constrained variants can produce, is a result either way.

Why not just use self-consistency over unconstrained chain-of-thought? Self-consistency also averages over latent reasoning. However, the paths it averages over need not vary along the dimensions that matter. The evidence from Beyond Context to Cognitive Appraisal is that even reasoning-trained o3-mini ignores accountability. If sampled free reasoning keeps collapsing onto "unfair, so angry," majority voting only reinforces the shortcut. Marginalizing over explicit accountability values forces mass onto both branches. The accountability-manipulated items in ToMEmoReason, evaluated at matched $K$, are the experiment that decides this.

Why not just fine-tune on rephrased hard examples? Hard Emotion Test Evaluation Sets shows this helps with only about 500 examples, so it may win on in-distribution scrubbed text. We therefore also evaluate cross-dataset transfer: we fine-tune on GoEmotions.v2 rephrasings and test on CancerEmo.v2 and ToMEmoReason. We also test whether the two are complementary, running our decoding on top of the fine-tuned model. If fine-tuning dominates everywhere, our method's remaining value is diagnostic, and the note will say so.

Proposed Experiments

enISEAR. Its gold appraisal annotations permit three measurements. First, per-dimension appraisal accuracy under constrained sampling, compared with the reported 85% F1 for Certainty and 55% for Control. Second, a gold-forced oracle: the gold appraisals are written into the grammar slots and only the label is decoded. This is the language-model analogue of the reported 66%. Third, the fraction of the gap between greedy and oracle that marginalization recovers. That fraction is the direct test of the error-propagation hypothesis.

ToMEmoReason. It varies fairness, accountability and outcome by design. We report forward accuracy, and we report intervention sensitivity $S_j$ for accountability and fairness. The decisive check here is that forcing agency from "other" to "self" must move mass from anger toward regret or guilt. If fairness dominance persists, $S$ for accountability will stay near the rate expected from random shifts.

GoEmotions.v2 R1–R4 and CancerEmo.v2. We report macro-F1 per scrubbing round. GoEmotions is also reported under its Ekman-six grouping, following GoEmotions: A Dataset of Fine-Grained Emotions, since mapping 27 categories through seven appraisal dimensions is lossy. The main prediction is that the gap between our method and direct prediction widens as rounds remove more lexical cues.

Cost. We report latency relative to unconstrained decoding. Grammar-Constrained Decoding for Structured NLP Tasks without Finetuning reports 1–4 ms added per token, and Mitigating Bias in Locally Constrained Decoding via Tractable Proposals reports about 1.1x overhead for its global method.

Negative results. The proposal fails cleanly in three ways. If reversed field order matches appraisal-first order, the label does not use the appraisals. If free-text appraisal prompting matches marginalized constrained decoding on accuracy, the contribution reduces to measurement. If high intervention sensitivity does not predict higher accuracy on the scrubbed sets, appraisal dependence is not the bottleneck the core claim asserts. Any of these would be reported as a finding about how language models infer unstated emotion.