[论文解读] Latent Predictor Networks for Code Generation
引入 Latent Predictor Networks (LPNs) 以在多个输入预测变量条件下生成代码,结合结构化注意力和代码压缩,在新的 TCG 卡数据集和 Django 语料库上达到最先进的结果。
Many language generation tasks require the production of text conditioned on both structured and unstructured inputs. We present a novel neural network architecture which generates an output sequence conditioned on an arbitrary number of input functions. Crucially, our approach allows both the choice of conditioning context and the granularity of generation, for example characters or tokens, to be marginalised, thus permitting scalable and effective training. Using this framework, we address the problem of generating programming code from a mixed natural language and structured specification. We create two new data sets for this paradigm derived from the collectible trading card games Magic the Gathering and Hearthstone. On these, and a third preexisting corpus, we demonstrate that marginalising multiple predictors allows our model to outperform strong benchmarks.
研究动机与目标
- 动机:说明需要在输出上对多于单一 softmax 的多个预测变量进行条件化。
- 提出 Latent Predictor Networks (LPNs),在训练过程中对预测变量的选择进行边际化。
- 将注意力扩展到具有多个字段的结构化输入。
- 展示使用新的 MTG/HS 数据集从自然语言和结构化规范生成代码。
- 展示相对于强基线的改进,并分析压缩和指针网络等组件。
提出的方法
- 通过公共投影和结构化注意力,将基于注意力的 seq2seq 模型扩展为对具有不同大小的多输入字段进行注意(方程式 4–5)。
- 定义 Latent Predictor Networks,以对预测变量序列与生成段的边际似然进行建模(方程 7)。
- 引入三种预测类型:字符生成、来自单一字段的拷贝、来自文本字段的拷贝(指针网络)。
- 使用前向后向动态规划进行训练,以对潜在预测序列进行边际化(Semi-Markov 模型的前向—后向)。
- 使用基于堆栈的束搜索进行解码,合并产生相同输出的路径。
实验结果
研究问题
- RQ1神经网络架构是否能够对多个预测变量进行边际化以生成输出,同时处理不同粒度的段?
- RQ2在多个输入字段上使用结构化注意力是否能改善从混合自然语言和结构化规范生成代码?
- RQ3在新的 MTG/HS 数据集和 Django 语料库上,带指针网络的 LPNs 是否优于强基线?
- RQ4代码压缩对训练效率和生成质量的影响?
- RQ5系统将关键卡片属性拷贝到生成代码中的准确度有多高?
主要发现
| 数据集 | BLEU(MTG) | Acc(MTG) | BLEU(HS) | Acc(HS) | BLEU(Django) | Acc(Django) |
|---|---|---|---|---|---|---|
| Retrieval | 54.9 | 0.0 | 62.5 | 0.0 | 18.6 | 14.7 |
| Phrase | 49.5 | 0.0 | 34.1 | 0.0 | 47.6 | 31.5 |
| Hierarchical | 50.6 | 0.0 | 43.2 | 0.0 | 35.9 | 9.5 |
| Sequence | 33.8 | 0.0 | 28.5 | 0.0 | 44.1 | 33.2 |
| Attention | 50.1 | 0.0 | 43.9 | 0.0 | 58.9 | 38.8 |
| Our System | 61.4 | 4.8 | 65.6 | 4.5 | 77.6 | 62.3 |
| – C2W | 60.9 | 4.4 | 67.1 | 4.5 | 75.9 | 60.9 |
| – Compress | - | - | 59.7 | 6.1 | 76.3 | 61.3 |
| – LPN | 52.4 | 0.0 | 42.0 | 0.0 | 63.3 | 40.8 |
| – Attention | 39.1 | 0.5 | 49.9 | 3.0 | 48.8 | 34.5 |
- 基于 LPN 的模型,加上结构化注意力和代码压缩,在 MTG、HS 以及 Django 数据集上优于基线。
- 在 MTG、HS 和 Django 上,我们的系统在基线无法产生有效代码的情况下,取得更高的 BLEU 和非零准确率。
- 压缩使得在长代码序列上训练成为可能,且质量损失可忽略,同时保持解码性能。
- 指针网络至关重要;移除 LPN 组件会显著降低性能。
- 将字符级生成与拷贝机制结合,特别是在拷贝卡名和数值属性方面表现出色。
更好的研究,从现在开始
从论文设计到论文写作,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。