Are Deep Sequence Classifiers Good at Non-Trivial Generalization?

Francesco Cazzaro, Ariadna Quattoni, Xavier CarrerasarXiv 2022

TL;DR

This paper introduces a novel evaluation framework to determine whether deep sequence classifiers are truly learning the underlying distribution of a target class or simply memorizing training data. By leveraging large amounts of unlabeled data, the authors demonstrate that models like LSTMs, Transformers, and Weighted Finite Automata (WFAs) achieve "non-trivial generalization," successfully predicting the statistical properties of sequences they have never seen before.

What Problem Does This Paper Address?

Deep learning models are incredibly accurate at sequence classification, but they often suffer from poor calibration. A poorly calibrated model might give a correct prediction but a wildly inaccurate confidence score (e.g., saying there is a 99% probability of a class when the true likelihood is closer to 60%).

This is particularly problematic in sparse sequence classification, where the target class is extremely rare (like identifying specific functional segments in DNA, which make up only 1–3% of the genome). In these "needle-in-a-haystack" scenarios, it is hard to tell if a model has actually learned the "shape" of the target distribution or if it has just found a clever way to compress and recall the specific examples it saw during training.

Methods

The authors propose evaluating models as moment predictors. Instead of just checking if a model gets a specific label right, they check if the model can estimate the joint distribution $Pr(y, x)$.

  1. Moments: They define "moments" as the expected frequency of specific sub-sequences (n-grams) within the target class.
  2. Unlabeled Data Proxy: Since the true distribution is unknown, they use a massive set of unlabeled sequences ($U$) to represent the domain. They then compare the model’s predicted moments against the "gold" moments calculated from the true target class.
  3. The Models: They compare three architectures:
  4. RNN (LSTM): A standard multi-layer Long Short-Term Memory network.
  5. Transformer (BERT): A BERT-base architecture trained from scratch on the task vocabulary.
  6. WFA (Weighted Finite Automata): A type of RNN with linear activations, trained using spectral learning.
  7. Generalization vs. Compression: To distinguish between memorization and learning, they calculate metrics specifically for unseen moments—patterns that never appeared in the training set.

Datasets

The study uses the PFAM dataset, which contains amino acid sequences belonging to various protein families. To create a challenging, sparse task, the authors:

  • Sampled sequence segments of length 5.
  • Selected the rarest protein family as the target class.
  • Created training sets of varying sizes (400 to 8,000 sequences) to observe how performance scales.

Key Insights and Ideas

  • Beyond Accuracy: The framework shifts the focus from "is this label correct?" to "does the model understand the statistics of the class?"
  • Non-Trivial Generalization: All three models significantly outperformed a baseline that simply memorized training patterns. Crucially, they were able to rank the importance of sub-sequences they had never seen, proving they aren't just "stochastic parrots."
  • The WFA Advantage: The WFA model performed exceptionally well at ranking the moments of the target class. The authors attribute this to the WFA's architecture, which explicitly models class distributions as an ensemble, unlike the LSTM and BERT which use standard cross-entropy loss.
  • Architecture Convergence: Despite vast differences in how a Transformer and an LSTM process data, their performance and the types of errors they make (correlation of predictions) become more similar as training data increases.

Key Results

The authors used several metrics, including MSPC (Spearman correlation of moments) and MR (Mean Rank of non-zero moments).

  • Generalization Performance: As shown in the "unseen" metrics (Figures 1b, 1d, and 1f), models maintain high performance even on patterns not present in the training data.
  • Ranking Rare Patterns: The MICRO MSPCP-U results (Figure 1f) highlight that the WFA is particularly adept at ranking the relative importance of rare, unseen patterns compared to BERT and LSTM.
Comparison of models on unseen moments (MSPC-U), showing that all models generalize well beyond the training data.
The MICRO MSPCP-U metric shows the WFA model outperforming LSTM and BERT in ranking the importance of rare, unseen patterns.

Limitations and Future Work

  • Absolute Metric Values: While the models beat the baseline, the absolute MSPC scores remained relatively low. This suggests that while models are generalizing, there is still a significant gap between their induced distributions and the true underlying distribution.
  • Exploiting Unlabeled Data: The authors suggest that since their evaluation framework relies on unlabeled data, future research could investigate using that same unlabeled data during training (e.g., via semi-supervised learning) to produce even better-calibrated classifiers.
  • Task Complexity: The study focused on binary classification; extending this framework to multi-class problems or more complex sequence structures remains an open challenge.

Summary updated

Abstract

Recent advances in deep learning models for sequence classification have greatly improved their classification accuracy, specially when large training sets are available. However, several works have suggested that under some settings the predictions made by these models are poorly calibrated. In this work we study binary sequence classification problems and we look at model calibration from a different perspective by asking the question: Are deep learning models capable of learning the underlying target class distribution? We focus on sparse sequence classification, that is problems in which the target class is rare and compare three deep learning sequence classification models. We develop an evaluation that measures how well a classifier is learning the target class distribution. In addition, our evaluation disentangles good performance achieved by mere compression of the training sequences versus performance achieved by proper model generalization. Our results suggest that in this binary setting the deep-learning models are indeed able to learn the underlying class distribution in a non-trivial manner, i.e. by proper generalization beyond data compression.
BibTeX
@misc{cazzaro2022are,
  author = {Francesco Cazzaro and Ariadna Quattoni and Xavier Carreras},
  title = {{Are Deep Sequence Classifiers Good at Non-Trivial Generalization?}},
  year = {2022},
  eprint = {2210.13082},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2210.13082},
}
Figure