Model-diff: A Tool for Comparative Study of Language Models in the Input Space

Weitang Liu, Yuelei Li, Ying Wai Li, Zihan Wang, Jingbo Shang · DOI

Abstract

Model-diff is a novel framework designed to compare two language models (LMs) by analyzing their prediction differences across a vast, sampled input space. Unlike traditional static benchmarks, Model-diff utilizes advanced sampling and normalization techniques to provide an unbiased, quantitative "fingerprint" of model divergence. This approach offers a robust tool for detecting model plagiarism and understanding architectural biases by probing the "unforeseen perspectives" models encounter in real-world applications.

Introduction

Traditional evaluation of language models relies heavily on benchmark datasets like MMLU or GSM8K. While these benchmarks provide valuable insights into specific tasks, they represent "designed perspectives" that cannot account for the infinite variety of inputs a model might face. Furthermore, the rise of "model plagiarism"—where licensed models are slightly modified and rebranded—presents a significant challenge for standard benchmarks, which often fail to distinguish between original and "noised" versions of a model.

The total input space of all possible token combinations is computationally impossible to enumerate. To address this, Model-diff shifts the focus from fixed datasets to the input space itself, efficiently probing where two models actually disagree.

Methodology

Model-diff characterizes the differences between models through a four-step process:

  1. Defining the Space: The framework focuses on "human-understandable" inputs, defined as token sequences where a model produces a low Negative Log-Likelihood (NLL).
  2. Sampling: Since the entire space cannot be checked, Markov Chain Monte Carlo (MCMC) sampling is used to identify these low-NLL sequences.
  3. Unbiasing: To correct for the bias inherent in sampling likely sequences, Model-diff employs Parallel Tempering and Histogram Reweighting (PTHR). These techniques, adapted from physics, allow for an estimation of the true distribution of prediction differences as if the entire space were sampled uniformly.
  4. Normalization: A normalization strategy is applied to ensure a fair comparison by focusing on the region where both models agree the inputs are reasonable.
Overview of the Model-diff pipeline, illustrating the mapping of inputs to latent spaces and the resulting prediction distributions.

Experimental Setup

The authors validated Model-diff using a variety of environments:

  • Toy Dataset: A simple, enumerable space of $10^8$ sequences (length 8, vocabulary 10) used to verify the mathematical accuracy of the sampling method against ground-truth enumeration.
  • Pre-trained Models: Comparisons were conducted between GPT-2 (Small and Medium) and Llama/Llama 2 (7B versions).
  • Synthetic Plagiarism: "Plagiarized" versions of GPT-2 were created by adding Gaussian noise (as low as 0.00001) to the model weights to test the tool's sensitivity.

Key Results

The empirical results demonstrate the effectiveness of Model-diff in identifying model characteristics and plagiarism:

  • Validation: In the toy example, the sampled ratio almost perfectly matched the ground-truth enumeration, proving the sampling method's lack of bias.
  • GPT-2 Comparison: When comparing GPT-2 Small and Medium on 100-token sequences, the Medium model disagreed with the Small model's favorite inputs nearly 30 times more often than the reverse.
  • Llama Evolution: Comparisons between Llama and Llama 2 quantified the "drift" in model preferences, showing that Llama 2 assigns significantly higher NLL to sequences preferred by Llama 1.
  • Plagiarism Detection: Model-diff successfully identified models with minimal weight noise, revealing a clear, predictable shift in the NLL distribution that distinguishes them from truly different architectures.
Distributions of NLL differences for various model pairs, demonstrating the 'fingerprint' of model divergence.

Key Insights

  • Sampling as a Diagnostic Tool: Model-diff moves beyond performance metrics to ask what kind of data a model finds likely compared to its peers.
  • The Plagiarism Signal: If one model is a noised version of another, the distribution of their differences ($D = NLL_A - NLL_B$) becomes highly distinctive and one-sided, creating a hard-to-hide fingerprint.
  • Capacity vs. Tolerance: Larger models have a wider range of reasonable inputs but are not necessarily more tolerant of the inputs favored by smaller models.

Limitations and Future Work

While powerful, Model-diff has several limitations:

  • Sampler Dependency: The accuracy is tied to the MCMC sampler's ability to cover the input space effectively.
  • NLL Focus: The current implementation only considers probability (NLL) and does not account for factual accuracy or reasoning logic.
  • Scalability: Sampling remains computationally intensive, although post-processing is relatively fast.
  • Privacy Risks: The sampling techniques could potentially be misused to "mine" a model for memorized training data.

Future research will focus on developing more efficient samplers and expanding the framework to include multi-dimensional outputs like feature embeddings.

Summary updated

BibTeX
@misc{liu2024model,
  author = {Weitang Liu and Yuelei Li and Ying Wai Li and Zihan Wang and Jingbo Shang},
  title = {{Model-diff: A Tool for Comparative Study of Language Models in the Input Space}},
  year = {2024},
  eprint = {2412.12177},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2412.12177},
}
Figure