Skip a Layer or Loop it? Test-Time Depth Adaptation of Pretrained LLMs

AK's Picks LLM MQIA Latent Reasoning ML MCTS
一个预训练的神经网络能否在不进行微调的情况下,根据不同的输入自适应地调整其架构?对于简单的任务,我们是否需要用到所有网络层?而对于具有挑战性的任务,这些网络层又是否足够?我们发现,预训练大语言模型(LLM)中的每一层都可以被当作独立模块进行操作,从而为每个测试样本构建出更优甚至更浅的定制化模型。具体而言,预训练模型中的每一层可以像循环神经网络(RNN)一样被跳过/剪枝或多次重复使用,并且可以以任意顺序与其他层堆叠组合,从而为每个样本生成一种“层链”结构(chain-of-layers,简称CoLa)。这种组合空间大大拓展了现有研究的范围,包括循环/递归式预训练模块、层剪枝以及提前退出网络等方面的工作。 我们开发了一种蒙特卡洛树搜索(MCTS)协议,用于探索并识别来自数学和常识推理基准测试中每个样本的最佳CoLa配置。与采用固定深度的静态模型相比,CoLa允许存在捷径路径(快速思考)、某些层的重复使用(慢速思考),或将两者结合,从而为不同输入提供更加灵活、动态的架构选择。我们对MCTS优化后的CoLa进行了广泛分析,得出了两个关键发现:(1)对于原LLM模型预测正确的大于75%的样本,我们能够找到更短的CoLa配置,表明推理效率还有很大的提升空间;(2)对于原模型预测错误的大于60%的样本,我们也能够找到能实现正确预测的CoLa配置,说明性能提升同样存在巨大潜力。我们的结果突显了在处理不同样本时使用固定架构的预训练LLM在推理上的局限性,并为解锁测试时深度自适应所带来的更强泛化能力提供了新思路。
Can a pretrained neural network adapt its architecture to different inputs without any finetuning? Do we need all layers for simple tasks, and are they adequate for challenging tasks? We found that the layers of a pretrained large language model (LLM) can be manipulated as separate modules to build a better and even shallower model customized for each test sample. In particular, each layer from the pretrained model can be skipped/pruned or repeated multiple times as recurrent neural networks (RNN), and stacked with others in arbitrary orders, yielding a chain-of-layers (CoLa) per sample. This compositional space greatly expands the scope of existing works on looped/recurrent pretrained modules, layer pruning, or early-exit networks. We develop a Monte Carlo Tree Search (MCTS) protocol to explore and identify the optimal CoLa for each sample from math and commonsense reasoning benchmarks. Compared to a static model of a fixed depth, CoLa allows shortcut paths (fast thinking), recurrence of the same layer(s) (slow thinking), and combining both, offering more flexible, dynamic architectures for different inputs. We conduct an extensive analysis of the MCTS-optimized CoLa, which leads to two key findings: (1) For >75% of samples with correct predictions by the original LLM, we can find shorter CoLa, suggesting a large space for improving inference efficiency; (2) For >60% of samples with originally incorrect predictions, we can identify CoLa achieving correct predictions, suggesting a large space of performance enhancement. Our results highlight the shortcomings of using a fixed architecture of pre-trained LLMs for inference on different samples and pave the way to unlock the generalization power of test-time depth adaptation.
许愿