一句话:提出 TF-Coder,用带模型引导的自底向上加权枚举搜索,从输入输出示例合成 TensorFlow 张量操作代码。
深度学习框架(如 TensorFlow、PyTorch)虽极大便利了模型开发,但其编程范式与传统显式循环、条件分支的命令式编程差异巨大,学习曲线陡峭。本文提出 TF-Coder,一个面向 TensorFlow 的按示例编程(programming by example)工具。其核心是自底向上的加权枚举搜索:通过基于值的等价表达式剪枝避免重复搜索,并利用灵活的类型与值过滤保证候选表达式满足 TensorFlow 库的各项约束;同时训练模型,从输入输出张量的特征以及任务的自然语言描述中预测可能用到的 TensorFlow 算子,从而在搜索中优先考虑相关操作。作者在 70 个真实世界任务上评估,TF-Coder 在 5 分钟内解决了其中 63 个,且有时比经验丰富的人类程序员更快找到更简洁的解法。
The success and popularity of deep learning is on the rise, partially due to powerful deep learning frameworks such as TensorFlow and PyTorch, which make it easier to develop deep learning models. However, these libraries also come with steep learning curves, since programming in these frameworks is quite different from traditional imperative programming with explicit loops and conditionals. In this work, we present a tool called TF-Coder for programming by example in TensorFlow. TF-Coder uses a bottom-up weighted enumerative search, with value-based pruning of equivalent expressions and flexible type- and value-based filtering to ensure that expressions adhere to various requirements imposed by the TensorFlow library. We train models to predict TensorFlow operations from features of the input and output tensors and natural language descriptions of tasks to prioritize relevant operations during search. TF-Coder solves 63 of 70 real-world tasks within 5 minutes, sometimes finding simpler solutions in less time compared to experienced human programmers.
@article{paperbot1616,
title = {TF-Coder: Program Synthesis for Tensor Manipulations},
author = {Kensen Shi and David Bieber and Rishabh Singh},
journal = {ACM Transactions on Programming Languages and Systems},
volume = {44},
number = {2},
year = {2022},
doi = {10.1145/3517034}
}