评估LLM生成的领域特定语言代码:使用LAMMPS进行分子动力学模拟
Evaluating LLM-generated code for domain-specific languages: molecular dynamics with LAMMPS
AI总结:
提出一种评估流程,结合标准化、解析、低成本执行和准确性检查,系统评估LLM为分子动力学代码LAMMPS生成输入文件的有效性,发现当前模型在科学准确性上有限,但通过可复用的智能体技能可显著提升。
摘要:
大型语言模型(LLM)正在改变研究人员在科学计算中与代码和数据交互的方式。虽然它们生成通用代码的能力已得到充分验证,但它们在为领域特定语言(DSL)生成科学有效的脚本方面的有效性仍 largely 未探索。我们提出了一种评估流程,使领域专家能够评估LLM为LAMMPS(一种广泛使用的分子动力学(MD)代码)生成的输入文件的有效性,而无需深入了解其语法。该评估流程结合了生成规范输入文件的标准化步骤和用于语法分析的可扩展解析器,随后是低成本执行阶段和准确性检查,以在运行昂贵模拟之前隔离常见错误。我们将该流程应用于八个最先进的LLM,涉及三个复杂度递增的提示。过去一年中,解析器通过率从74%提高到91%,但在耦合的多步骤工作流上的科学准确性仍然有限。在针对最复杂提示评估的所有80个脚本中,只有一个是完全正确的。我们进一步将自动化阶段打包为可重用的智能体技能,LLM可以在脚本生成期间调用该技能;在一个小规模演示中,该技能帮助两个模型在相同的三个提示下生成了六个脚本中的五个完全正确的脚本,包括最难的一个。该流程既突出了当前LLM在生成科学DSL方面的局限性,也指出了将它们集成到特定领域计算生态系统中的实际路径。
英文摘要:
Large language models (LLMs) are changing the way researchers interact with code and data in scientific computing. While their ability to generate general-purpose code is well established, their effectiveness in producing scientifically valid scripts for domain-specific language (DSLs) remains largely unexplored. We propose an evaluation procedure that enables domain experts to assess the validity of LLM-generated input files for LAMMPS, a widely used molecular dynamics (MD) code, without requiring deep familiarity with its syntax. The evaluation procedure combines a normalization step that produces canonical input files with an extensible parser for syntax analysis, followed by a reduced-cost execution stage and accuracy checks that isolate common errors before running costly simulations. We apply the pipeline to eight state-of-the-art LLMs across three prompts of increasing complexity. The parser pass rate has improved from 74% to 91% over the past year, but scientific accuracy on coupled multi-step workflows remains limited. Across all 80 scripts evaluated on the most complex prompt, only one was fully correct as generated. We further package the automated stages as a reusable agentic skill that LLMs can invoke during script generation; in a small-scale demonstration, this skill helped two models produce five fully correct scripts out of six across the same three prompts, including the hardest one. The pipeline highlights both the limitations of current LLMs in generating scientific DSLs and a practical path toward integrating them into domain-specific computational ecosystems.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。