Command Palette
Search for a command to run...
生成型か判別型か:Transformer時代のテキスト分類を再考する
生成型か判別型か:Transformer時代のテキスト分類を再考する
Siva Rajesh Kasa Karan Gupta Sumegh Roychowdhury Ashutosh Kumar Yaswanth Biruduraju Santhosh Kumar Kasa Nikhil Priyatam Pattisapu Arindam Bhattacharya Shailendra Agarwal Vijay Huddar
概要
判別モデルと生成モデルの比較は、Efron (1975)によるロジスティック回帰と判別分析の先駆的な分析以来、研究者たちの関心を引き続けてきた。初期の理論研究では、単純な線形設定において生成モデルはより低いサンプル計算量を示す一方で、より高い漸近的誤差を有することが明らかにされたが、これらのトレードオフはTransformer時代においても未探索のまま残されている。本研究は、自己回帰モデル、マスク言語モデル、離散拡散モデル、およびエンコーダといった現代の生成型・判別型アーキテクチャをテキスト分類において包括的に評価する初の試みである。本研究の結果、古典的な「二つの領域」現象が、アーキテクチャや訓練パラダイムごとに異なる形で現れることが明らかになった。精度に加え、サンプル効率、校正、ノイズ頑健性、順序性についても多様なシナリオにおいて分析した。これらの知見は、レイテンシやデータ制約といった現実世界の制限に基づいて最も適切なモデリング手法を選択するための実践的指針を提供するものである。
One-sentence Summary
Amazon Inc. presents the first comprehensive evaluation of generative (autoregressive, masked language modeling, discrete diffusion) and discriminative (encoder) transformer architectures for text classification, revealing that the classical "two regimes" phenomenon manifests distinctly across architectures and training paradigms while offering practical guidance on model selection under real-world constraints such as latency and data limitations.
Key Contributions
-
The paper provides a comprehensive evaluation of modern generative and discriminative architectures for text classification, covering autoregressive models, masked language modeling, discrete diffusion, and encoders. It examines accuracy, sample efficiency, calibration, noise robustness, and ordinality.
-
The comparison includes pseudo-generative transformer variants, including masked language modeling with label suffixes and append-label formulations, showing that minimal changes to label placement or loss bring standard architectures into a comparable setup.
-
Experiments reveal that the classical trade-off between sample complexity and asymptotic error manifests differently across model families and training paradigms. Practical guidance follows: 1-layer encoders are efficient, robust, calibrated, and ordinal for latency-sensitive settings; 12-layer masked language models perform best in data-rich offline tasks across F1, calibration, and ordinal metrics but are less robust to token dropping; discrete diffusion is strong for low-resource noisy cases, especially at 6 layers; and autoregressive models are preferred when calibrated probability outputs are critical.
Introduction
The authors study the discriminative versus generative debate for text classification, a core NLP task used in sentiment analysis, topic classification, and emotion detection. Transformer-based discriminative classifiers are strong but often require large labeled datasets, while generative classifiers can be more data efficient by modeling the joint data distribution, making them attractive for low-resource settings.
Prior work compared these approaches mainly on tabular data or with older neural architectures such as LSTMs, and modern transformer-era comparisons remain limited. Previous studies also focused mostly on classification accuracy and sample size, leaving important deployment questions underexplored, such as model scaling, calibration, robustness to noisy inputs, and preservation of ordinal relationships between classes.
The authors contribute the first large-scale transformer-era comparison of discriminative encoders and generative text classifiers, including auto-regressive models, discrete diffusion, and masked language modeling. They evaluate these approaches across multiple benchmark datasets, model sizes, and training settings, then provide practical recommendations for selecting models based on data availability, latency, robustness, and probability calibration requirements.
Dataset
-
The authors evaluate models on a text classification benchmark suite of nine datasets: AG News, Emotion, Stanford Sentiment Treebank (SST2 and SST5), Multiclass Sentiment Analysis, Twitter Financial News Sentiment, IMDb, and Hate Speech Offensive.
-
The datasets are used to test robustness across domains and task types, including sentiment analysis, movie review classification, news categorization, and social media or financial message analysis.
-
The benchmark covers different classification settings, from binary tasks to fine-grained multiclass tasks, and includes short sentence-level inputs as well as longer paragraph-level passages.
-
In the provided excerpt, the dataset is described as an evaluation suite rather than a training mixture; the authors use it to assess model performance across multiple classification domains.
-
The excerpt does not provide per-subset sizes, train validation test splits, filtering rules, schema definitions, class distributions, other statistics, cropping strategy, or metadata construction details; these are said to be provided in Appendix C.
Method
The authors formulate text classification as a comparison between discriminative and generative language modeling paradigms. Given a dataset D={(Xi,yi)}i=1N, where Xi=xi1,…,xin is an input sequence from vocabulary V and yi∈Y is a discrete class label, discriminative models directly learn the conditional distribution P(y∣X), while generative models first learn a joint or pseudo joint distribution over the sequence and label and then infer the label by evaluating candidate label likelihoods or masked label predictions.
For the discriminative architecture, the method uses a standard Transformer encoder setup. The encoder fθ maps the input text to a d-dimensional hidden representation,
hi=fθ(Xi).A linear classification head W∈R∣Y∣×d converts this representation into class scores. The predicted label distribution is obtained with a softmax layer,
y^i=softmax(Whi),and training minimizes the cross entropy objective
Lenc=−i=1∑NlogP(yi∣Xi).This branch represents the conventional encoder based classification pipeline, where the label is not generated as part of the sequence but is predicted from a final text embedding.
The generative side includes three main variants: Masked Language Modeling, Auto Regressive modeling, and discrete text diffusion. All of them cast classification as a sequence modeling or sequence reconstruction problem, with the label token inserted into the input template.
For Masked Language Modeling, the input is first expanded into a structured sequence. During training, the authors construct
Xi′=[CLS]Xi[SEP]"The label is".The label token yi is appended, yielding a sequence in which both original text tokens and the label token are present. Standard masking is then applied to a fraction of the tokens, typically 15%, and the model predicts the masked tokens using bidirectional context. The training objective is
Lmlm=−i=1∑Nj∈Mi∑logP(xij∣Xi′⊕yi\j),where Mi is the set of masked positions and Xi′⊕yi\j denotes the input with only position j masked. Because the masked prediction objective can be interpreted as a denoising or pseudo likelihood surrogate, the authors place MLM within the broader generative family. At inference, the label is removed and replaced by a mask:
Xi′=[CLS]Xi[SEP]"The label is"[MASK].The model predicts the token probability for the masked label position. The output space is then restricted to the valid label vocabulary VY, and the corresponding token probabilities are renormalized to produce class probabilities.
For Auto Regressive classification, the method trains a causal language model to maximize the likelihood of the full label plus input sequence. Training uses the next token prediction loss
Lgpt=−i=1∑Nj=1∑LilogP(xij∣y,xi1,…,xij−1),where Li is the sequence length. At inference, the authors perform one forward pass for each candidate label y∈VY by prepending that label to the input sequence and computing the log likelihood of the text conditioned on the label. The final prediction is
y^=argy∈VYmaxlogP(X∣y).This corresponds to a full likelihood evaluation over all possible labels. The authors also discuss a pseudo generative Auto Regressive variant in which the label is appended after the input rather than prepended. In that setting, only a single forward pass is needed, and the model generates the label token directly. Label placement matters primarily for causal architectures with left-to-right attention, while it has no comparable theoretical effect for bidirectional models such as MLM or diffusion based models.
The text diffusion branch defines a template sequence for each input-label pair:
Xi=Xi[SEP]"The label is"yi.Instead of gradually adding Gaussian noise as in image diffusion, the forward process corrupts discrete text by replacing tokens with pure noise, represented by the special symbol [MASK]. This corruption is modeled through a continuous Markov process with transition matrices Qt,
dtdpt=Qtpt,p0=pdata,where each token position is independently corrupted over timesteps t∈[0,T] until the sequence becomes completely masked.
The reverse process learns to reconstruct the original tokens from the corrupted sequence. It models score ratios of the form
sθ(x,t)z=pt(x)pt(z),where x and z are vocabulary tokens. The reverse-time dynamics are defined as
dtdpT−t=sθ(x,t)zQT−tpT−t.To train the score model in a tractable way, the authors use Denoising Score Entropy,
LDSE=Ex0∼p0,x∼p(⋅∣x0)z=x∑wxz(sθ(x)z−p(x∣x0)p(z∣x0)logsθ(x)z),where p is treated as a perturbation of a base density p0 and wxz>0 are weighting terms. The objective provides an upper bound on the negative log likelihood through an ELBO style relation,
−logp0θ(x0)≤LDWDSE(x0)+constant.At inference, the label token in the diffusion template is masked, the model predicts the corresponding token from the fully masked or partially masked sequence, and the output is constrained to valid label tokens in VY.
Experiment
The experiments evaluate five text classification paradigms on nine benchmarks across data sizes and model scales, while also testing robustness to token corruption and calibration or ordinality. They show that the best approach depends strongly on model capacity and data amount: compact discriminative ENC is more effective for small models, generative diffusion and autoregressive methods help in low-data regimes, and pseudo-generative MLM excels when large models have abundant data. Noise testing reveals that diffusion models are generally robust and autoregressive models are more sensitive, while calibration results show discriminative and pseudo-generative models can be reliable in deployment-oriented settings. Pretraining further favors discriminative models and reduces the data-size advantages observed for generative approaches.
The comparison frames discriminative and generative text classification approaches as different trade-offs in data needs, model size, sample efficiency, score structure, calibration, and noise robustness. ENC is favored on several score-quality properties and requires less data and smaller models, while AR and DIFF are more sample efficient and DIFF is notably robust to noise. Experimental context adds that AR is the more reliable generative option in low-data settings for calibration and ordinal behavior, and that pretraining reduces the typical low-data advantage of generative models. ENC combines lower data and model-size demands with stronger ordinality, unimodality, and calibration in the table comparison. AR and DIFF offer higher sample efficiency, while DIFF also provides strong robustness to noise but weaker score ordination and calibration. In low-data training, AR is more reliable than pseudo-AR for calibration and more ordinal than DIFF, while pretrained ENC outperforms AR across regimes.
Under random token dropping, higher values indicate that a model tolerates more dropped tokens before a given weighted-F1 drop, and all methods require more noise as the tolerated drop grows. Among 6-layer methods, DIFF is the strongest robustness signal at moderate and larger drop thresholds, while AR is also competitive. In the 12-layer comparison, ENC remains above AR-pseudo across the tested thresholds and is more robust than its 6-layer variant, suggesting architectural scaling can shift the advantage toward ENC. DIFF provides the most robust 6-layer performance under random token dropping. ENC appears more robust when scaled from 6 to 12 layers than AR-pseudo.
Under random token substitution, the results show that architecture choice affects robustness to input noise. ENC consistently requires more noise before weighted-F1 falls by a given amount, while AR-pseudo is less robust and drops from its peak at lower noise levels. This suggests ENC is a more reliable choice when the test data may contain token-level perturbations, especially in the smaller model setting. ENC shows the highest noise tolerance across weighted-F1 drop thresholds. AR-pseudo is more sensitive to random token substitution than ENC.
The experiments compare discriminative and generative text classifiers, including ENC, AR, and DIFF, in terms of data efficiency, model size, calibration, ordinal score behavior, and robustness to token-level noise. ENC is favored for score quality, calibration, and lower data and model-size demands, while AR and DIFF provide better sample efficiency and DIFF is especially robust to random token dropping in smaller models. Scaling ENC from six to twelve layers improves its robustness relative to AR-pseudo, and ENC is generally more tolerant than AR-pseudo to random token substitution, making pretrained ENC a strong choice when both score structure and noise reliability matter.