Partial differential equations (PDEs) are fundamental to modeling physical systems, yet solving them remains a complex challenge. Traditional numerical solvers rely on expert knowledge to implement and are computationally expensive, while neural-network-based solvers require large training datasets and often lack interpretability. In this work, we frame PDE solving as a code generation task and introduce CodePDE, the first inference framework for generating PDE solvers using large language models (LLMs). With CodePDE, we present a thorough evaluation on critical capacities of LLM for PDE solving: reasoning, debugging, self-refinement, and test-time scaling. CodePDE shows that, with advanced inference-time algorithms and scaling strategies, LLMs can achieve strong performance across a range of representative PDE problems. We also identify novel insights into LLM-driven solver generation, such as trade-offs between solver reliability and sophistication, design principles for LLM-powered PDE solving agents, and failure modes for LLM on hard tasks. These insights offer guidance for building more capable and reliable LLM-based scientific engines.
翻译:偏微分方程是物理系统建模的基础,但求解它们仍然是一个复杂的挑战。传统的数值求解器依赖专家知识实现且计算成本高昂,而基于神经网络的求解器需要大量训练数据集且通常缺乏可解释性。在本工作中,我们将偏微分方程求解构建为代码生成任务,并提出了CodePDE——首个利用大语言模型生成偏微分方程求解器的推理框架。通过CodePDE,我们对大语言模型在偏微分方程求解方面的关键能力进行了全面评估:推理、调试、自我优化和测试时扩展。CodePDE表明,借助先进的推理时算法和扩展策略,大语言模型能够在一系列代表性偏微分方程问题上取得优异性能。我们还揭示了大语言模型驱动求解器生成的新见解,例如求解器可靠性与复杂性之间的权衡、大语言模型驱动的偏微分方程求解智能体的设计原则,以及大语言模型在困难任务上的失效模式。这些见解为构建更强大、更可靠的大语言模型驱动的科学计算引擎提供了指导。