Laughing Heads: Can Transformers Detect What Makes a Sentence Funny?

Maxime Peyrard, Beatriz Borges, Kristina Gligorić, Robert West
5/19/2021
cs.CLcs.AIcs.LG
transformer-attention

Official code: epfl-dlab/laughing-head (3 stars, Jupyter Notebook, Apache-2.0, last commit 2023-09-11).

Abstract

The automatic detection of humor poses a grand challenge for natural language processing. Transformer-based systems have recently achieved remarkable results on this task, but they usually (1)~were evaluated in setups where serious vs humorous texts came from entirely different sources, and (2)~focused on benchmarking performance without providing insights into how the models work.

Show full abstract

We make progress in both respects by training and analyzing transformer-based humor recognition models on a recently introduced dataset consisting of minimal pairs of aligned sentences, one serious, the other humorous. We find that, although our aligned dataset is much harder than previous datasets, transformer-based models recognize the humorous sentence in an aligned pair with high accuracy (78%). In a careful error analysis, we characterize easy vs hard instances. Finally, by analyzing attention weights, we obtain important insights into the mechanisms by which transformers recognize humor. Most remarkably, we find clear evidence that one single attention head learns to recognize the words that make a test sentence humorous, even without access to this information at training time.

View on arXivView PDF

Code Implementations(1)

Apache-2.0

Code for the laughing head paper

30Jupyter Notebook, PythonMay 18, 20213 years agoApache-2.0

Similar Papers

Cite this paper

@article{peyrard2021laughing,
  title  = {Laughing Heads: Can Transformers Detect What Makes a Sentence Funny?},
  author = {Maxime Peyrard and Beatriz Borges and Kristina Gligorić and Robert West},
  year   = {2021},
  eprint = {2105.09142},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2105.09142}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2105.09142.svg)](https://codeofpaper.com/paper/2105.09142)

Discussion