ChatPaper.aiChatPaper

大型語言模型的Y組合子:用λ演算解決長上下文衰減問題

The Y-Combinator for LLMs: Solving Long-Context Rot with λ-Calculus

March 20, 2026
作者: Amartya Roy, Rasul Tutunov, Xiaotong Ji, Matthieu Zimmer, Haitham Bou-Ammar
cs.AI

摘要

大型語言模型(LLM)正日益被用作通用推理工具,但固定長度的上下文窗口仍是處理長輸入的瓶頸。遞歸語言模型(RLM)通過將提示外部化並遞歸解決子問題來應對這一挑戰。然而現有的RLM依賴於開放式讀取-求值-輸出循環(REPL),模型在該循環中生成任意控制代碼,導致執行過程難以驗證、預測和分析。 我們提出λ-RLM這一長上下文推理框架,它採用基於λ演算的類型化函數式運行時系統,取代了自由形式的遞歸代碼生成。該框架執行經過預驗證的緊湊組合子庫,僅對有界葉子子問題進行神經推理,從而將遞歸推理轉化為具有顯式控制流的結構化函數式程序。我們證明λ-RLM能實現標準RLM缺乏的形式化保障,包括終止性、閉式成本界限、隨遞歸深度可控的精度擴展,以及簡單成本模型下的最優分割規則。在四項長上下文推理任務和九個基礎模型的實證研究中,λ-RLM在36組模型-任務對比中有29項表現優於標準RLM,在不同模型層級中平均準確率最高提升21.9個百分點,延遲最高降低4.1倍。這些結果表明,類型化符號控制相比開放式遞歸代碼生成,能為長上下文推理提供更可靠高效的基礎。λ-RLM的完整實現已在以下網址開源:https://github.com/lambda-calculus-LLM/lambda-RLM。
English
LLMs are increasingly used as general-purpose reasoners, but long inputs remain bottlenecked by a fixed context window. Recursive Language Models (RLMs) address this by externalising the prompt and recursively solving subproblems. Yet existing RLMs depend on an open-ended read-eval-print loop (REPL) in which the model generates arbitrary control code, making execution difficult to verify, predict, and analyse. We introduce λ-RLM, a framework for long-context reasoning that replaces free-form recursive code generation with a typed functional runtime grounded in λ-calculus. It executes a compact library of pre-verified combinators and uses neural inference only on bounded leaf subproblems, turning recursive reasoning into a structured functional program with explicit control flow. We show that λ-RLM admits formal guarantees absent from standard RLMs, including termination, closed-form cost bounds, controlled accuracy scaling with recursion depth, and an optimal partition rule under a simple cost model. Empirically, across four long-context reasoning tasks and nine base models, λ-RLM outperforms standard RLM in 29 of 36 model-task comparisons, improves average accuracy by up to +21.9 points across model tiers, and reduces latency by up to 4.1x. These results show that typed symbolic control yields a more reliable and efficient foundation for long-context reasoning than open-ended recursive code generation. The complete implementation of λ-RLM, is open-sourced for the community at: https://github.com/lambda-calculus-LLM/lambda-RLM.
PDF235March 24, 2026