Where Composition Breaks: Constituent-Scoped Commonsense for Sarcasm Detection

Sarcasm is a sentence whose literal meaning, assembled word by word, contradicts what the speaker plainly means. "Stuck in a traffic jam makes me happy" composes literally into something positive. Everyone knows traffic jams are miserable, and that clash is the signal. Current detectors handle the "everyone knows" part by asking a commonsense generator such as COMET for inferences and spreading them over the whole sentence. One careful study found this adds noise and no accuracy, and the generated inferences can make benign sentences look sarcastic. We propose a different way to bring the knowledge in. A recursive encoder, meaning a network that builds a phrase's meaning bottom-up along its parse tree, computes the literal affect of each phrase, including grammatical flips such as "not". Commonsense is then queried only for the event phrases in the tree, never for the sentence as a whole. Sarcasm is scored as a localized clash between one phrase's composed literal affect and another phrase's commonsense-expected affect.

The point is to separate two kinds of meaning inversion that current models blur together. Grammatical inversion ("I'm not happy being stuck in traffic") is sincere, and recursive composition resolves it. Pragmatic inversion ("being stuck in traffic makes me happy") is sarcastic. It leaves a residual conflict that only world knowledge exposes. If the separation works, the model should cut the false alarms that unscoped commonsense produces. It should also point to the phrase pair that carries the sarcasm, which can be checked against the explanations and literal rephrasings that authors wrote in the iSarcasm dataset.

Core Claim

Commonsense helps sarcasm detection when two conditions hold. It must be attached to specific constituents, meaning the phrases of a parse tree. And it must be contrasted against an explicitly composed literal meaning, not mixed into the sentence representation. Recursive composition is the right place to compute that literal meaning, because its job is to absorb grammatical inversion so that the remaining incongruity is pragmatic. The claim makes three predictions:

  1. Lower false-positive rates on non-sarcastic text than knowledge-concatenation models.
  2. Correct handling of negation minimal pairs, where flat models conflate negation with sarcasm.
  3. Gains on author-labelled intended sarcasm, not only on hashtag-labelled corpora.

Grounding in Prior Work

The motivating evidence comes from three papers that pull in different directions.

Recursive Neural Networks with Bottlenecks Diagnose (Non-)Compositionality restricts how much information Tree-LSTMs can pass from children to parents. It shows that sarcastic and ironic sentences fail disproportionately under that restriction: their meaning cannot be recovered from local composition. That work is purely diagnostic. We turn its finding into a design rule: supply external information exactly at the phrase nodes where composition alone cannot resolve meaning.

Does Commonsense help in detecting Sarcasm? adds COMET inferences as flat nodes in a graph network on top of DistilBERT. It reports 96.18% versus 96.13% accuracy on News Headlines, over 90% identical predictions, and spurious sarcasm on benign sentences. This is the negative result that constrains our design: unscoped knowledge injection is ruled out.

Commonsense Knowledge Enhanced Sentiment Dependency Graph for Sarcasm Detection (CSDGCN) shows the opposite outcome is possible. It filters COMET outputs by sentiment contrast, substitutes them into dependency-tree nodes, and runs a three-layer graph convolution. It reports 87.16% accuracy on Riloff. It does not compose phrases. It overwrites the original words. Its authors also note that it struggles with situational sarcasm.

Affective Dependency Graph for Sarcasm Detection pairs a dependency graph with the SenticNet affect lexicon. It finds that its graph convolutions over-smooth past three layers. Detecting Emotional Incongruity of Sarcasm by Commonsense Reasoning (EICR) is the strongest system in the file. It chains web retrieval, LLM-generated background, graph pruning, an entailment checker and adversarial contrastive training. None of these three composes meaning hierarchically or separates grammatical from pragmatic inversion. That separation is what we add.

The method comes from three sources. Child-gated tree composition comes from Improved Semantic Representations From Tree-Structured Long Short-Term Memory Networks. The upward-then-downward tree pass comes from Learning Negation Scope from Syntactic Structure. That paper showed explicit tree structure resolves grammatical negation scope well: 89.10 F1 on *SEM2012. Verb-rooted subtree decomposition comes from Leveraging Recursive Processing for Neural-Symbolic Affect-Target Associations, which attached affect to targets in literal aspect-based sentiment, never sarcasm.

The knowledge source is COMET trained on ATOMIC 2020, from (Comet-) Atomic 2020: On Symbolic and Neural Commonsense Knowledge Graphs. It covers relations such as how the subject or others react to an event and what hinders it.

One finding cuts against us. The negation-scope paper saw BERT embeddings hurt its tree model. We nonetheless use pretrained token states as leaves, because sarcasm needs lexical knowledge that grammatical negation does not. We test the tree with and without them rather than assume.

Research Program

Encoder. We parse each sentence with a dependency parser. Each token's leaf vector is its RoBERTa-base hidden state. A child-sum Tree-LSTM composes upward, followed by a downward pass in the style of the negation-scope tree network.

Literal-affect head. A small head reads out a literal sentiment $l_n$ at every tree node $n$. It is trained with an auxiliary loss on the phrase-level labels of the Stanford Sentiment Treebank. This supervision is what forces the tree to compose literal meaning, including negation and intensifiers, instead of learning sarcasm shortcuts.

Commonsense queries. For each verb-rooted subtree describing an event, we pass the subtree's text span to COMET-BART. We ask for the reaction relations (how the subject reacts, how others react) and the hindrance relation. A second head maps the inferences to an expected affect $e_n$.

Gate. A gate $g_n \in [0,1]$ decides whether node $n$'s knowledge is admitted. It is computed from the node's composed state and its inference embeddings. Unlike CSDGCN, the inferences sit beside the node, never in place of the word.

Scoring. The sarcasm score pools clashes over pairs of nodes:

$$s = \mathrm{softmax\text{-}pool}_{(i,j)}\; g_j \cdot \phi\big(l_i,\, e_j\big) \;+\; w^\top h_{\text{root}}$$

Here $(i,j)$ ranges over pairs of distinct tree nodes with $i$ outside the subtree of $j$, and $\phi$ is a learned bilinear contrast between literal affect at $i$ and expected affect at $j$. The term $h_{\text{root}}$ is the root state, so non-incongruity cues such as punctuation and style are still available. The softmax-pool is a temperature-controlled soft maximum. The pair with the largest pooled weight is the model's localization of the sarcasm. Training combines the sarcasm loss, the phrase-sentiment loss, and a sparsity penalty on $g$, so knowledge is admitted rarely.

Analyses. We measure how often the gate opens on sarcastic versus sincere items. We compare the localized pair against iSarcasm author rephrasings. We test robustness to parser choice and to injected parse errors, since external parsers are a known weak point.

Baselines

Naive reference points. Fine-tuned RoBERTa-base on the sentence alone. For News Headlines we also cite the DistilBERT reference of 96.13% accuracy reported in Does Commonsense help in detecting Sarcasm?. Beating the sentence-only model on iSarcasm is the minimum bar.

Strongest existing method. EICR is the strongest competitor because it already uses retrieved and generated commonsense with an explicit incongruity search. Its reported accuracy / macro-F1 is:

Dataset Accuracy Macro-F1
iSarcasm 83.3% 70.4%
Ghosh 86.2% 84.3%
SemEval-2018 80.1% 80.3%
IAC-V2 84.5% 83.8%
Reddit 77.2% 75.3%

On Riloff, Ptáček and Ghosh, CSDGCN reports 87.16%, 84.95% and 85.93% accuracy. We will rerun both on our splits where code allows, and otherwise compare to the reported numbers with the split mismatch stated.

Note that the iSarcasm paper's own figure of a best model F1 of 0.364 is sarcastic-class F1, not macro-F1. We will report both metrics so the comparison with EICR is like for like. Beating EICR means higher macro-F1 on iSarcasm and parity or better on the hashtag datasets, with a far lighter pipeline.

Fairness. All rerun systems share the same RoBERTa-base backbone, the same COMET-ATOMIC 2020 generations, and the same hyperparameter search budget in trials. Each is run with five seeds, and differences are tested with paired bootstrap.

Ablations. Three ablations isolate the key ingredients:

  1. Remove the phrase-sentiment supervision. This tests whether explicit literal composition matters.
  2. Feed whole-sentence rather than constituent-scoped COMET queries. This tests scoping.
  3. Replace the Tree-LSTM with pooling over the same verb-rooted spans taken from RoBERTa. This tests whether recursion matters beyond span selection.

Why not just…?

Why not just concatenate filtered COMET text to the input and fine-tune RoBERTa? This is the most serious threat. A pretrained transformer may learn the contrast itself if the inferences are clean enough. The negative result of Does Commonsense help in detecting Sarcasm? used unfiltered inferences, so it does not settle the question. We will run this baseline with CSDGCN's contrast-based filter applied. If it matches our model on iSarcasm and on the false-positive and negation minimal-pair checks below, the gain is due to filtering, and we will report that.

Why not just use a graph network like CSDGCN with the knowledge attached as side nodes instead of substituted? That would test whether attachment, not recursion, is what matters. We include it as a baseline with identical constituent-scoped inferences. The over-smoothing beyond three layers reported for Affective Dependency Graph for Sarcasm Detection suggests graph convolutions cannot carry negation through deep trees. The minimal-pair set is where this should show.

Why not just prompt a large language model? EICR reports that GPT-4o zero- and few-shot prompting underperformed its trained structured pipeline. We will still report a prompted GPT-4o baseline on iSarcasm, because the file gives no exact GPT-4o number to cite.

Why not just pool spans without a tree? This could plausibly match us, since RoBERTa states may already encode phrase-internal negation. We will not argue around it. If the span-pooling ablation equals the Tree-LSTM on every check, we will conclude that the useful ingredients are constituent scoping and literal-affect supervision, and drop the recursion claim.

Proposed Experiments and Decisive Checks

Main evaluation. We train and test on iSarcasm as the primary benchmark, because it is labelled by the authors of the posts. We report Riloff, Ptáček, Ghosh, IAC-V2, SemEval-2018 and Reddit for continuity with prior work, and train on hashtag datasets and test on iSarcasm to probe the collapse the iSarcasm paper documented.

Decisive check 1: false alarms. We measure the false-positive rate on sincere items. Constituent scoping should lower it relative to concatenation and whole-sentence queries. If it does not, the noise explanation for the earlier negative result is wrong.

Decisive check 2: negation minimal pairs. We will build a small human-written set of minimal pairs that differ only by grammatical negation or by pragmatic framing, for example "being stuck in traffic makes me happy" versus "being stuck in traffic doesn't make me happy". The prediction is that our model labels the sincere negated versions correctly where flat baselines flip them to sarcastic. This is the test of separating grammatical from pragmatic inversion.

Decisive check 3: localization. On the iSarcasm subset with author rephrasings, we score whether the highest-weighted phrase pair overlaps the words the author changed when rewriting literally. We compare this against attention-based localizations from the baselines.

Diagnostic link back to the bottleneck paper. On the Stanford Sentiment Treebank split that the bottleneck study marks as non-compositional, we check whether our gate opens preferentially there. If it does, the gate is finding the non-compositional phrases that study identified with its bottleneck test.