Unsupervised Layer-Wise Dynamic Test Time Adaptation for LLMs
Longhuan Xu, Cunjian Chen, Feng Yin
TL;DR
This paper tackles unsupervised, sample-specific test-time adaptation for LLMs by shifting from a single global learning rate to a fine-grained, layer-wise control mechanism. It introduces ScaleNet, a lightweight hypernetwork that predicts per-layer, per-step learning-rate multipliers to modulate LoRA updates during a short adaptation horizon, and it adopts a first-order unrolled optimization to train ScaleNet efficiently. Across diverse models and datasets, the proposed dynamic TTA yields improved stability and performance (lower NLL and higher ROUGE-Lsum) compared to fixed-rate baselines and layer-agnostic schedules, with the largest gains in early adaptation steps and on larger LLMs. The approach demonstrates that per-layer, per-step scaling is beneficial for unsupervised TTA, offering a practical path to more reliable and transferable prompt-specific adaptation in real-world deployments.
Abstract
Test-time adaptation (TTA) for large language models (LLMs) updates model parameters at inference time using signals available at deployment. This paper focuses on a common yet under-explored regime: unsupervised, sample-specific TTA, where the model adapts independently for each prompt using only the prompt itself, without gold answers or external supervision. Although appealing, naive unsupervised TTA with a fixed, handcrafted learning rate can be unstable: updates may overfit to prompt-specific statistics, drift from the desired answer distribution, and ultimately degrade generation quality. This failure mode is not surprising, as in this case TTA must adapt to a single prompt within only a few gradient steps, unlike standard training that averages updates over large datasets and long optimization horizons. Therefore, we propose layer-wise dynamic test-time adaptation, a framework which explicitly modulates TTA strength as a function of prompt representation, LLM structure and adaptation step. In our setting, TTA updates only LoRA parameters, and a lightweight hypernetwork predicts per-layer, per-step learning-rate multipliers, enabling fine-grained control. Experiments across various datasets and LLMs consistently show that our method substantially strengthens TTA by learning effective scaling patterns over adaptation steps and transformer layer projections, improving stability while delivering better performance.
