Data Continuity Matters: Improving Sequence Modeling with Lipschitz Regularizer

Eric Qu, Xufang Luo, Dongsheng LiICLR 2023

Introduction

In the evolving landscape of deep learning, we have developed a diverse toolkit for sequence modeling: Recurrent Neural Networks (RNNs) for temporal data, Transformers for text, and State Space Models (like S4) for long-range dependencies. However, a fundamental question remains underexplored: why does a specific architecture excel at one task but struggle with another?

Recent research suggests that a critical, often overlooked property is data continuity. Different sequence models possess inherent "preferences" for the continuity—or smoothness—of their input data. For instance, models grounded in continuous-time mathematics (like S4) often struggle with "jittery," discrete data. Conversely, models designed for discrete tokens (like Transformers) can actually perform worse when their inputs are overly smooth. Bridging this gap between a model's architectural preference and the raw nature of the data is essential for optimal performance.

Quantifying Continuity: The Lipschitz Regularizer

To address this architecture-data mismatch, researchers propose a method to quantify and manipulate data continuity using the concept of Lipschitz continuity. A function is considered Lipschitz continuous if its rate of change is strictly bounded.

To make this mathematically rigorous concept easy to optimize during neural network training, the authors introduce a surrogate metric called the Lipschitz Regularizer ($\mathcal{L}_{Lip}$). This regularizer calculates the average squared difference between adjacent elements in a sequence:

$$\mathcal{L}_{Lip} = \frac{1}{n} \sum_{i=0}^{n-1} (x_{i+1} - x_i)^2$$

Rather than pre-processing the raw data—which risks losing valuable information—the regularizer is applied directly to the output of the model's embedding layer. It acts as a "soft filter," allowing the model to learn a representation that aligns with its internal machinery.

The application strategy depends entirely on the model's inherent preference:

  • For Continuous-Time Models (e.g., S4, Neural ODEs): The regularizer is added to the loss function. This penalizes sharp transitions, forcing the embeddings to be smoother and catering to the model's preference for low-Lipschitz (continuous) data.
  • For Discrete-Preference Models (e.g., Transformers, Informer): The regularizer is subtracted from the loss function. This encourages the embeddings to exhibit higher contrast and more "discrete" transitions, which these architectures handle more effectively.
Effect of Lipschitz Regularizer on High and Low Continuity Data

Furthermore, from a frequency domain perspective, this regularizer interacts with the "spectral bias" of neural networks. Networks naturally tend to learn low-frequency (smooth) patterns first. By subtracting the regularizer, researchers can force a network to prioritize high-frequency details earlier in training, thereby accelerating convergence.

Experimental Validation and Key Results

The efficacy of the Lipschitz Regularizer was evaluated across a massive range of benchmarks, spanning natural language processing, time-series forecasting, computer vision, and speech recognition.

Key Insights

The most striking takeaway from the experiments is that "better" data does not universally mean "smoother" data. For example, a Transformer trained on raw, continuous speech signals performs poorly because its attention mechanisms expect discrete patterns. By forcing the embedding layer to "discretize" the signal via the regularizer, performance improves significantly.

Performance Gains

  • State Space Models (S4): On the Long Range Arena (LRA) benchmark, adding the regularizer improved S4's accuracy on the "Text" task from 86.51% to 89.74%.
  • Transformers in Time-Series: In real-world time-series forecasting (using datasets like ETT and Weather), subtracting the regularizer to make data more discrete consistently lowered the Mean Squared Error (MSE) for Informer and Autoformer models.
  • Vision Fine-tuning: Applying the regularizer while fine-tuning a pre-trained Swin Transformer on the Beans image classification dataset increased accuracy from 92.48% to 95.49%.
  • Speech Processing: For raw speech classification—which involves highly continuous data—the Performer model's accuracy jumped from 30.89% to 35.72% when the regularizer forced it to treat the data as more discrete.

Limitations and Future Directions

While the Lipschitz Regularizer offers a simple, computationally inexpensive way to boost performance, it is not without limitations.

First, the method introduces a new hyperparameter ($\lambda$) to control the strength of the regularization. While empirical results suggest it isn't overly sensitive, it still requires task-specific tuning. Second, in complex multivariate time-series, some variables might be inherently continuous while others are discrete. The current implementation applies a "one-size-fits-all" regularization to the entire embedding vector, which may not be optimal for mixed-modality data. Finally, in certain spatial tasks, the regularizer can sometimes "over-blur" important shapes, risking the loss of fine-grained spatial information.

Future work could explore trainable weights for the regularizer. This would allow the model to dynamically and automatically decide which specific features or time steps within a sequence need to be smoothed or discretized, paving the way for even more adaptable sequence modeling architectures.

Summary updated

BibTeX
@inproceedings{qu2023data,
  author = {Eric Qu and Xufang Luo and Dongsheng Li},
  title = {{Data Continuity Matters: Improving Sequence Modeling with Lipschitz Regularizer}},
  booktitle = {International Conference on Learning Representations},
  year = {2023},
  url = {https://openreview.net/forum?id=27uBgHuoSQ},
}
Figure