不同算法描述格式影响大模型实现准确率,显式说明细节更关键。
Which Algorithm Specification Formats Help Language Models Implement Machine Learning Algorithms?

- 对比7种格式,发现格式对大模型实现有显著影响
- 在核心信息条件下,LaTeX伪代码表现最佳,平均提升12.3%
- 关键在于明确接口、计算步骤和边界行为,而非特定格式
大型语言模型(LLMs)越来越多地用于从研究论文中实现算法,但论文常隐含实现细节。本研究考察了算法描述格式如何影响大模型首次实现的准确性。我们在五个机器学习任务、三种模型和四个实验设置下,对比了普通文本、LaTeX伪代码、提取的伪代码、Markdown字段、YAML-like规范、JSON-like规范及Python代码模板,生成了4,020个实现。通过隐藏测试评估了决定正确性的细节,包括冲突解决、数组形状、数值规则、返回结构和无效输入行为。在核心信息条件下,LaTeX算法风格伪代码的平均格式效应最大,YAML-like规范和普通文本紧随其后。在完整信息下,GPT-5.4 mini在匹配比较中无格式差异,而Gemma 3 4B和Llama 3.2 3B仍存在差异。代码模板虽指定函数签名,但未持续提升正确性。结果表明:作者应显式说明接口、计算步骤、数值规则和边界情况行为,而非依赖特定表面格式承载这些信息。
原文摘要 · Abstract (English)
Large language models (LLMs) are increasingly used to implement algorithms from research manuscripts, but papers often leave implementation choices implicit. This study examines how the written format of an algorithm specification affects first-pass LLM implementation accuracy. We compare ordinary prose, LaTeX algorithm-style pseudocode, PDF-like extracted pseudocode, Markdown fields, YAML-like specifications, JSON-like specifications, and Python code stubs across five machine learning tasks, three models, and four experimental settings, yielding 4,020 generated implementations. Hidden tests evaluate details that often determine correctness, including tie-breaking, array shapes, numerical rules, return structures, and invalid-input behavior. Under the core-information setting, LaTeX algorithm-style pseudocode has the largest average format effect, with YAML-like specifications and ordinary prose close behind. Under complete information, GPT-5.4 mini shows no format differences in the matched comparisons, whereas Gemma 3 4B and Llama 3.2 3B still do. Code stubs do not consistently improve correctness despite specifying the function signature. The results support a writing recommendation: authors should state the interface, computation steps, numerical rules, and boundary-case behavior explicitly, instead of relying on a particular surface format to carry those details.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。