arXiv:2511.16691cs.CL2025-11

让大模型推理时用最近邻数据微调,显著降低困惑度。

Reproducibility Report: Test-Time Training on Nearest Neighbors for Large Language Models

  • 用Faiss检索测试输入的20个最近邻序列,每条做一次梯度更新。
  • 在GitHub、EuroParl等专业数据集上困惑度下降超30%,小模型性能接近大模型。
  • 新方法内存优化,服务器内存从128GB降至32GB,适合实际部署。

我们复现了Hardt和Sun(2024)提出的基于最近邻的推理时训练方法,该方法通过在推理阶段对检索到的近邻序列进行微调来适应语言模型。使用预训练RoBERTa嵌入与Faiss索引,每条测试输入检索20个邻居,并对GPT-2(117M、774M)、GPT-Neo(1.3B)和R1-Distilled-Qwen2.5-1.5B进行单步梯度更新。实验表明,在The Pile多个领域中,该方法显著降低困惑度和比特/字指标,尤其在代码(GitHub)和欧盟议会文本(EuroParl)等结构化数据上提升最大。非The Pile预训练模型受益更明显,使小模型性能逼近大模型。受硬件限制,我们提出一种内存高效检索方案,仅加载必要行偏移而非完整文件,将单机内存需求从128GB降至32GB。此外,我们扩展评估了现代推理优化架构R1-Distilled-Qwen2.5-1.5B,结果表明其同样获得稳定收益。总体支持最近邻推理时训练的鲁棒性与通用性,同时揭示大规模检索增强适配的实用挑战。

原文摘要 · Abstract (English)

We reproduce the central claims of Test-Time Training on Nearest Neighbors for Large Language Models (Hardt and Sun, 2024), which proposes adapting a language model at inference time by fine-tuning on retrieved nearest-neighbor sequences. Using pretrained RoBERTa embeddings indexed with Faiss, we retrieve 20 neighbors per test input and apply one gradient update per neighbor across GPT-2 (117M, 774M), GPT-Neo (1.3B), and R1-Distilled-Qwen2.5-1.5B. Our experiments confirm that test-time training significantly reduces perplexity and bits-per-byte metrics across diverse domains from The Pile, with the largest improvements in structured or specialized datasets such as GitHub and EuroParl. We further validate that models not pretrained on The Pile benefit more from this adaptation than models already trained on similar data, allowing smaller models to approach the performance of larger ones. Due to infrastructure limitations, we introduce a memory-efficient retrieval implementation that loads only required line offsets rather than entire files, reducing RAM requirements from over 128 GB per server to 32 GB. We also extend the original study by evaluating R1-Distilled-Qwen2.5-1.5B, showing that test-time training yields consistent gains even for modern reasoning-optimized architectures. Overall, our results support the robustness and generality of nearest-neighbor test-time training while highlighting practical considerations for reproducing large-scale retrieval-augmented adaptation.

推理时训练最近邻大模型优化内存效率

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