Skip to content

Commit ded0eab

Browse files
committed
added in ablation study text
1 parent 06864c3 commit ded0eab

File tree

4 files changed

+228
-42
lines changed

4 files changed

+228
-42
lines changed

paper/main.pdf

7.98 KB
Binary file not shown.

paper/main.tex

Lines changed: 131 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
\newcommand{\confusion}{{7}}
2222
\newcommand{\mds}{{8}}
2323

24+
\newcommand{\authortableContent}{{1}}
25+
\newcommand{\authortableFunction}{{2}}
26+
\newcommand{\authortablePOS}{{3}}
27+
2428
\doublespacing
2529

2630
\title{A Stylometric Application of Large Language Models}
@@ -37,14 +41,14 @@
3741
\begin{abstract}
3842

3943
We show that large language models (LLMs) can be used to distinguish the
40-
writings of different authors. Specifically, an individual model, trained on
41-
the works of one author, will predict held-out text from that author more
42-
accurately than held-out text from other authors. We suggest that, in this way,
43-
a model trained on one author's works embodies the unique writing style of that
44-
author. We first demonstrate our approach on books written by eight different
45-
(known) authors. We also use this approach to confirm R. P. Thompson's
46-
authorship of the well-studied 15\textsuperscript{th} book of the \textit{Oz}
47-
series, originally attributed to F. L. Baum.
44+
writings of different authors. Specifically, an individual GPT-2 model, trained
45+
from scratch on the works of one author, will predict held-out text from that
46+
author more accurately than held-out text from other authors. We suggest that,
47+
in this way, a model trained on one author's works embodies the unique writing
48+
style of that author. We first demonstrate our approach on books written by
49+
eight different (known) authors. We also use this approach to confirm R. P.
50+
Thompson's authorship of the well-studied 15\textsuperscript{th} book of the
51+
\textit{Oz} series, originally attributed to F. L. Baum.
4852

4953
\end{abstract}
5054

@@ -62,13 +66,13 @@ \section{Introduction}
6266
Recent work has demonstrated the effectiveness of using perplexity and
6367
cross-entropy loss from fine-tuned language models for authorship
6468
attribution~\citep{HuanEtal25}, achieving state-of-the-art performance on
65-
standard benchmarks. Unlike traditional stylometric approaches that rely on
66-
hand-crafted features such as function word frequencies~\citep{MostWall63} or
67-
syntactic patterns~\citep{Holm98}, lage language models can capture complex,
68-
hierarchical patterns in authorial style~\citep{FabiEtal20}. This shift from
69-
explicit feature engineering to learned representations parallels broader
70-
trends in computational literary analysis~\citep{More00,UndeEtal19} and digital
71-
humanities~\citep{HughEtal12}.
69+
standard benchmarks. Unlike traditional stylometric approaches that rely on the
70+
direct articulation of particular features such as function word
71+
frequencies~\citep{MostWall63} or syntactic patterns~\citep{Holm98}, lage
72+
language models can capture complex, hierarchical patterns in authorial
73+
style~\citep{FabiEtal20}. This shift from explicit feature engineering to
74+
learned representations parallels broader trends in computational literary
75+
analysis~\citep{More00,UndeEtal19} and digital humanities~\citep{HughEtal12}.
7276

7377
In this paper we show, using a small set of authors and their works, that large
7478
language models capture author-specific writing patterns. Our method differs
@@ -79,12 +83,12 @@ \section{Introduction}
7983
texts by models trained on known works of different authors. We believe this
8084
approach could be of use in considering questions of authorial influence and
8185
stylistic evolution~\citep{HughEtal12}. Lastly, this further suggests a
82-
literary authentication tool~\citep[a common use of stylometric techniques;
86+
literary attribution tool~\citep[a common use of stylometric techniques;
8387
][]{MostWall63,MostWall84,NiloBino03,Juol08} that would assign an unknown or
8488
contested work to the model (and author) under which predictive comparison
8589
generates the smallest loss. We illustrate this on the well-known attribution
8690
problem of the 15\textsuperscript{th} book in the \emph{Oz} series, confirming
87-
what is now the accepted attribution.
91+
what is now the accepted attribution.
8892

8993
\section{Methods}
9094

@@ -254,9 +258,9 @@ \subsection{Predictive comparison testing of eight classic authors}
254258
\textit{other} authors. Figure~\ref{fig:t-stats}A displays the $t$-values from
255259
$t$-tests comparing these same versus other loss distributions for each of the
256260
first 500 training epochs. For all authors except Twain, the $t$-tests yielded
257-
$p$-values below $0.001$ after just one epoch, indicating that the models
261+
$p$-values below $0.001$ after just one or two epochs, indicating that the models
258262
rapidly acquire author-specific stylometric patterns. For Twain, this threshold
259-
is crossed at epoch 47. Figure~\ref{fig:t-stats}B shows the average $t$-values
263+
is crossed at epoch 77. Figure~\ref{fig:t-stats}B shows the average $t$-values
260264
across all eight authors as a function of the number of training epochs (final
261265
epoch: $t(9) = 13.196, p = 3.41 \times 10^{-7}$). This latter plot provides an
262266
estimate of the performance we might expect to see in the general case (e.g.,
@@ -281,9 +285,14 @@ \subsection{Predictive comparison testing of eight classic authors}
281285
\hline
282286
\end{tabular}
283287

284-
\caption{Each row displays the results of a $t$-test comparing the average loss
285-
values assigned by each author's model (after training is complete) to the
286-
author's held-out text and to the other authors' randomly sampled texts.}
288+
\caption{\textbf{Loss differences between same-author and other-author texts.}
289+
Each row displays the results of a $t$-test comparing the average loss values
290+
assigned by each author's model (after training is complete) to the author's
291+
held-out text and to the other authors' randomly sampled texts. See
292+
Supplementary Materials for analogous tables using models trained on only
293+
content words (Supp. Table~\authortableContent), only function words (Supp.
294+
Table~\authortableFunction), and only parts of speech (Supp.
295+
Table~\authortablePOS).}
287296

288297
\label{tab:t-tests}
289298
\end{table}
@@ -365,18 +374,88 @@ \subsection{Predictive attribution of the 15\textsuperscript{th} \emph{Oz} book}
365374
\includegraphics[width=0.8\textwidth]{figs/source/oz_losses.pdf}
366375

367376

368-
\caption{\textbf{Cross-entropy loss across models and \textit{Oz} authors.} The
369-
top sub-panels replicate the Baum (blue) and Thompson (orange)
370-
results from Figure~\ref{fig:all-losses}. The bottom sub-panels show the cross-entropy
371-
loss assigned to a held-out text whose authorship is contested
372-
(lower left), to a held-out non-\textit{Oz} text by Baum (lower
373-
center), and to a held-out non-\textit{Oz} text by Thompson (lower
374-
right). Error ribbons denote bootstrap-estimated 95\% confidence
375-
intervals over 10 random seeds. }
377+
\caption{\textbf{Cross-entropy loss across models and \textit{Oz} authors.} The
378+
top sub-panels replicate the Baum (blue) and Thompson (orange) results from
379+
Figure~\ref{fig:all-losses}---i.e., that a given Thompson is well-distinguished
380+
from Baum and vice-versa (the two rightmost top sub-panels; error ribbons
381+
denote bootstrap-estimated 95\% confidence intervals over 10 random seeds). The
382+
bottom sub-panels show the cross-entropy loss assigned to a held-out text whose
383+
authorship is contested (lower left), to a held-out non-\textit{Oz} text by
384+
Baum (lower center), and to a held-out non-\textit{Oz} text by Thompson (lower
385+
right). I.e., the contested book shows lower loss for Thompson-trained models;
386+
a non-Oz Baum book shows lower loss for Baum-trained models; and a non-Oz
387+
Thompson book shows lower loss for Thompson-trained models.}
388+
376389
\label{fig:oz-losses}
377390
\end{figure*}
378391

379-
392+
\subsection{Ablation studies: content words, function words, and parts of speech}
393+
394+
The above analyses show that LLMs trained on one author's works can effectively
395+
capture the distinctive statistical patterns of that author's writing style. We
396+
carried out a series of ablation studies to investigate the contributions of
397+
different aspects of writing style. Specifically, we constructed three modified
398+
corpora for each author: (1) content-word-only corpora, in which all function
399+
words were replaced with a special token; (2) function-word-only corpora, in
400+
which all content words were replaced with a special token; and (3)
401+
part-of-speech-only corpora, in which each word was replaced with its
402+
corresponding part-of-speech tag (see \textit{Investigating the contributions
403+
of content words, function words, and parts of speech}). We then re-trained our
404+
models on each of these modified corpora and repeated the predictive
405+
comparison analyses (Supp. Figs.~\crossentropyContent--\ttestsPOS).
406+
407+
The models trained on the content-word-only corpora where intended to capture
408+
stylistic patterns related to vocabulary choice and thematic content. The
409+
models trained on the function-word-only corpora were intended to capture
410+
syntactic and grammatical patterns that transcended story-specific content.
411+
Finally, the models trained on the part-of-speech-only corpora were intended to
412+
capture higher-level syntactic patterns while abstracting away from specific
413+
word choices.
414+
415+
Models trained on a single author's texts from each of these modified corpora
416+
all converged, achieving training losses below 3.0 well within 500 training
417+
epochs (Supp. Figs.~\crossentropyContent, \crossentropyFunction, and
418+
\crossentropyPOS). This indicates that all of these modified corpora contain
419+
sufficient statistical regularities for GPT-2 models to learn to reliably
420+
achieve next-token predictions.
421+
422+
We found that models trained on content-word-only corpora reliably learned
423+
author-specific patterns for 6 of the 8 authors (Supp.
424+
Figs.~\crossentropyContent~and~\ttestsContent, Supp.
425+
Table~\authortableContent). Overall, by the final training epoch, the average
426+
$t$-values across all models and held-out texts were reliably greater than zero
427+
($t(9) = 8.438, p = 1.44 \times 10^{-5}$). However, models trained only on
428+
content words were significantly less effective at distinguishing authors than
429+
models trained on the intact texts ($t(11.77) = 3.21, p = 7.68 \times
430+
10^{-3}$).
431+
432+
Models trained on function-word-only corpora reliably learned author-specific
433+
patterns for 5 of the 8 authors (Supp.
434+
Figs.~\crossentropyFunction~and~\ttestsFunction, Supp.
435+
Table~\authortableFunction). Overall, by the final training epoch, the average
436+
$t$-values across all models and held-out texts were reliably greater than zero
437+
($t(9) = 4.428, p = 1.65 \times 10^{-3}$). These models were also significantly
438+
less effective at distinguishing authors than models trained on the intact
439+
texts ($t(8.36) = 4.82, p = 1.15 \times 10^{-3}$), but not significantly
440+
different from models trained on content-word-only corpora ($t(10.29) = 1.81, p
441+
= 0.100$).
442+
443+
Models trained on part-of-speech-only corpora reliably learned author-specific
444+
patterns for just 3 of the 8 authors (Supp.
445+
Figs.~\crossentropyPOS~and~\ttestsPOS, Supp. Table~\authortablePOS). Overall,
446+
by the final training epoch, the average $t$-values across all models and
447+
held-out texts were not reliably greater than zero ($t(9) = 1.616, p 0 0.141$).
448+
These models were also significantly less effective at distinguishing authors
449+
than models trained on the intact texts ($t(7.36) = 5.72, p = 6.01 \times
450+
10^{-4}$), models trained on content-word-only corpora ($t(7.90) = 3.10, p =
451+
1.49 \times 10^{-2}$), and models trained on function-word-only corpora
452+
($t(10.41) = 2.11, p = 6.04 \times 10^{-2}$).
453+
454+
Taken together, these ablation results suggest that both content words and
455+
function words contribute to the author-unique stylometric signatures captured
456+
by our models. In contrast, grammatical structure alone, as reflected in
457+
part-of-speech sequences and captured by our methodology, appears to be
458+
more similar across authors.
380459

381460
\section{Discussion}
382461

@@ -394,14 +473,22 @@ \section{Discussion}
394473
lower cross-entropy losses than models trained on different authors, achieving
395474
perfect classification accuracy across all eight authors examined. This
396475
separation emerged rapidly during training: for seven of eight authors,
397-
statistically significant discrimination was achieved after just one training
398-
epoch. The resulting stylometric distances proved meaningful, clustering
476+
statistically significant discrimination was achieved after just two training
477+
epochs. The resulting stylometric distances proved meaningful, clustering
399478
authors with known stylistic similarities (e.g., Baum and Thompson) while
400479
maintaining clear separation between all author pairs. Finally, our method
401480
successfully resolved the well-studied attribution problem of the
402481
15\textsuperscript{th} \emph{Oz} book, confirming Thompson's authorship in
403482
agreement with traditional stylometric analyses~\citep{NiloBino03}.
404483

484+
We also conducted ablation studies to investigate the contributions of different
485+
aspects of writing style. Models trained on content-word-only and function-word-only
486+
corpora both captured author-specific patterns, though with reduced effectiveness
487+
compared to models trained on intact texts. In contrast, models trained solely on
488+
part-of-speech sequences struggled to distinguish authors, suggesting that
489+
grammatical structure alone is less distinctive. These findings highlight the
490+
importance of both lexical choice and syntactic patterns in shaping authorial style.
491+
405492
\subsection{Relationship to prior work}
406493

407494
Our predictive comparison approach relates closely to recent work using
@@ -534,7 +621,17 @@ \subsection{Concluding remarks}
534621
disciplines~\citep{More17,More00,Holm98} and the practices of cultural
535622
analytics~\citep{UndeEtal13}.
536623

537-
%\section*{Acknowledgments}
624+
\section*{Acknowledgments}
625+
626+
We acknowledge helpful discussions with Jacob Bacus, Hung-Tu Chen,
627+
and Paxton Fitzpatrick. This research was supported in part by
628+
National Science Foundation Grant 2145172 to JRM.
629+
630+
\section*{Data and code availability}
631+
632+
All code and data needed to reproduce the results in this paper are available
633+
at \url{https://github.com/ContextLab/llm-stylometry}.
634+
538635

539636
% %This document has been adapted
540637
% by Steven Bethard, Ryan Cotterell and Rui Yan

paper/supplement.pdf

8.66 KB
Binary file not shown.

0 commit comments

Comments
 (0)