arXiv:2507.07996cs.LG2025-07被引 12

让预训练大模型根据输入动态调整层数,提升效率与准确率

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

  • 将预训练模型层作为模块,按需跳过或重复,构建每样本定制的动态结构
  • 75%正确样本可缩短结构,60%错误样本经优化后能纠正预测
  • 无需微调即可实现推理加速与性能增强,适合追求高效部署的场景

预训练语言模型能否在不微调的情况下,根据输入动态调整自身架构?我们发现,模型各层可作为独立模块,通过跳过、重复或任意组合,为每个测试样本生成定制化的链式层结构(CoLa)。利用蒙特卡洛树搜索(MCTS)在数学与常识推理数据集上优化每条路径。相比固定深度模型,CoLa支持快速路径(快思考)、层重复(慢思考)及两者结合,具备更强灵活性。分析显示:超过75%原模型正确预测的样本可找到更短结构,表明推理效率有显著提升空间;超过60%原模型错误的样本可通过优化结构实现正确预测,揭示性能提升潜力。结果揭示固定架构在不同输入下存在局限,为测试时深度自适应提供了新方向。

原文摘要 · Abstract (English)

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.

大模型推理动态架构测试时优化

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。