Abstract
LMdiff is an interactive visual tool designed to facilitate the comparison of language models through per-token probability distributions. While traditional benchmarks rely on aggregate scores that obscure specific model behaviors, LMdiff allows researchers to perform a "diff" between two models to identify exactly where and why they diverge. By visualizing shifts in likelihood across entire corpora and individual snippets, the tool helps uncover the impacts of fine-tuning, distillation, and scale on model performance and bias.
Introduction
In Natural Language Processing (NLP), model comparison is typically dominated by "leaderboard" metrics such as accuracy or F1 scores. Although these metrics provide a high-level overview, they are often opaque. They fail to reveal whether a model has developed new biases after fine-tuning or if a distilled model has lost specific factual knowledge despite maintaining a high average score.
Existing interpretability tools frequently focus on internal mechanics, such as attention heads or neuron activations. LMdiff addresses the need for output-level comparison, providing a qualitative and quantitative framework to compare how two models interpret the same text. This enables researchers to form granular hypotheses about model behavior that aggregate statistics might otherwise miss.
The LMdiff Framework
LMdiff employs a two-tiered visual approach to model comparison, integrating global corpus-level statistics with local token-level analysis.
Global View
The Global View operates on an entire corpus, calculating aggregate statistics such as average rank difference or probability shifts across thousands of data points. Histograms visualize the distribution of these differences, allowing users to quickly identify "interesting" outliers—text snippets where the two models disagree most significantly.
Instance (Local) View
Once a specific snippet is selected, the tool provides a token-by-token breakdown. A diverging color scale (e.g., red for Model A, blue for Model B) highlights which model assigned a higher likelihood to a specific token. To ensure comparisons are meaningful, LMdiff utilizes a Clamped Rank Metric. Because the difference between the 1st and 5th most likely token is more significant than the difference between the 100th and 105th, ranks are clamped at a maximum (e.g., 50) to surface the most impactful behavioral shifts.
Key Insights and Case Studies
The utility of LMdiff is demonstrated through several case studies involving datasets like WinoBias, CommonsenseQA, and BioLang.
Distillation and Factual Loss
When comparing GPT-2 to its distilled counterpart, DistilGPT-2, researchers found that while the smaller model performs well generally, it can fail catastrophically on specific facts. In one instance, the base model ranked a correct answer 3rd, while the distilled model ranked it 466th—a stark reminder of the information loss inherent in model compression.
Model Fingerprinting and Forgetting
LMdiff makes it visually obvious which model generated a specific text, as models consistently assign higher likelihoods to their own outputs. Furthermore, the tool illustrates "catastrophic forgetting." For example, fine-tuning a masked language model like BERT for sentiment analysis can degrade its general language modeling capabilities, resulting in "garbage" probability distributions for general text compared to the base version.
Results in Data Cleaning and Adaptation
LMdiff has proven effective in identifying data quality issues. By examining outliers in the BioLang dataset where a base model outperformed a fine-tuned version, researchers discovered malformed data (repeated character sequences) that the base model was better at predicting.
In domain adaptation, visualizing GPT-2 against a version fine-tuned on ArXiv papers showed a clear shift in preference toward technical terms like "BLEU" or "Transformer." Interestingly, this adaptation came at the cost of losing some preference for common linguistic names.
Limitations and Future Directions
The primary limitation of LMdiff is the requirement for "Apples-to-Apples" comparison; it currently only supports models sharing the same tokenizer and vocabulary. Future work aims to develop tokenization-independent measures to allow comparisons between different architectures (e.g., GPT vs. T5) and to integrate automated statistical testing for direct hypothesis verification within the tool.
Summary updated