Siamese Bert for Authorship Verification

Jacob Tyo, Bhuwan Dhingra, Zachary C. LiptonCLEF (Working Notes) 2021

Abstract

This paper evaluates a Siamese BERT architecture (SAV) for Authorship Verification (AV), the task of determining if two texts share the same author. Using the PAN 2021 dataset, the study explores various loss functions and pooling strategies. While the deep learning approach yields an 8% improvement in F1-score over traditional baselines, the results highlight the continued competitiveness of simpler TF-IDF methods, suggesting challenges in capturing pure authorial style versus content.

Introduction

Authorship Verification (AV) is a fundamental task in forensic linguistics and computational stylometry, focused on determining whether two distinct texts were produced by the same individual. Traditionally, this field relied on "stylomes"—unique linguistic fingerprints such as specific punctuation patterns, syntactic structures, or idiosyncratic vocabulary choices. In the machine learning era, this often translated into extensive manual feature engineering. This study investigates whether modern Large Language Models (LLMs), specifically BERT, can autonomously learn these stylistic embeddings from raw text, potentially replacing hand-crafted features.

Methodology

The authors propose SAV (Siamese BERT for Authorship Verification), a neural architecture designed to compare text pairs.

Model Architecture

The SAV model utilizes a Siamese structure to process input pairs symmetrically:

  1. Siamese Encoders: Two identical BERT models with shared weights process the input texts in parallel.
  2. Pooling and Projection: Token-level outputs are aggregated via mean pooling and projected through a dense layer to generate a 256-dimensional "style embedding."
  3. Distance Calculation: The similarity between the two embeddings is measured using Euclidean or Cosine distance.
Architecture of the Siamese BERT for Authorship Verification (SAV) model.

Training and Data

The model was trained on the PAN 2021 Authorship Verification dataset, comprising fanfiction stories. The large-scale version includes over 275,000 text pairs from approximately 278,000 authors. To enhance training, the authors performed data augmentation by treating texts individually, allowing for a massive theoretical pool of pairings.

The study explored three primary loss functions: Contrastive Loss, Triplet Loss, and a Modified Contrastive Loss. The latter introduces dual margins to account for natural intra-author stylistic variation, acknowledging that an author's style may shift across different topics or fandoms.

Key Insights

A significant challenge in AV is disentangling style from topic. The Modified Contrastive Loss proved most effective, as its dual-margin approach explicitly allows for variation when the same author writes about different subjects.

Interestingly, increasing context through "chunking" (averaging embeddings from multiple 512-token segments) actually degraded performance. This suggests that stylistic markers may be most prominent in the initial segments of a text. Furthermore, the failure of Triplet Loss—a staple in computer vision—indicates that "hard negative mining" may not translate directly to the nuances of linguistic style.

Results

The SAV model demonstrated superior performance compared to the competition's baseline, though the margin suggests that traditional methods remain robust.

Performance metrics of the final SAV model on the hidden test set.

The final model achieved an 8% increase in F1-score over the baseline. On internal testing, the SAV model reached an overall score of 0.715, a modest 0.9% gain over the baseline's 0.706. These results indicate that while Transformers offer improvements, the gap between deep learning and simpler TF-IDF methods is narrower than in other NLP tasks.

Discussion and Limitations

The primary constraint remains BERT’s 512-token input limit. Attempts to bypass this via chunking were unsuccessful, highlighting a need for better long-text embedding strategies. Additionally, the competitive performance of TF-IDF baselines suggests that BERT may still be overly sensitive to content (topic) rather than the subtle stylistic markers prioritized by forensic linguists. Future research should focus on more diverse datasets and sophisticated sampling strategies to better distinguish between authors with similar writing styles.

Summary updated

BibTeX
@inproceedings{tyo2021siamese,
  author = {Jacob Tyo and Bhuwan Dhingra and Zachary C. Lipton},
  title = {{Siamese Bert for Authorship Verification}},
  booktitle = {CLEF (Working Notes)},
  year = {2021},
}
Figure