Home

Awesome

PlotCoder: Hierarchical Decoding for Synthesizing Visualization Code in Programmatic Context

This repo provides the code to replicate the experiments in the paper

Xinyun Chen, Linyuan Gong, Alvin Cheung, Dawn Song, <cite> PlotCoder: Hierarchical Decoding for Synthesizing Visualization Code in Programmatic Context, in ACL 2021. </cite>

Prerequisites

Download the JuiCe dataset here.

The code is runnable with Python 3, PyTorch 0.4.1.

Data preprocessing

To extract the plot generation samples from the entire JuiCe dataset, run plot_sample_extraction.py.

Note that for model training and evaluation, we may further filter out some samples from the datasets extracted here. But we would like to keep these copies that include the maximal number of plot samples we can extract, so that we no longer need to enumerate the entire JuiCe dataset afterwards.

Key arguments

In the following we list some important arguments for data preprocessing:

Run experiments

  1. To run the hierarchical model:

python run.py --nl --use_comments --code_context --nl_code_linking --copy_mechanism --hierarchy --target_code_transform

  1. To run the non-hierarchical model with the copy mechanism:

python run.py --nl --use_comments --code_context --nl_code_linking --copy_mechanism --target_code_transform

  1. To run the LSTM decoder without the copy mechanism, i.e., one-hot encoding for data items, but preserve the nl correspondence in the input code sequence:

python run.py --nl --use_comments --code_context --nl_code_linking --target_code_transform

  1. To run the LSTM decoder with the standard copy mechanism, do not preserve the nl correspondence:

python run.py --nl --use_comments --code_context --copy_mechanism --target_code_transform

  1. To run the LSTM decoder without the copy mechanism, i.e., one-hot encoding for data items as in prior work:

python run.py --nl --use_comments --code_context --target_code_transform

Key arguments

In the following we list some important arguments for running neural models:

Citation

If you use the code in this repo, please cite the following paper:

@inproceedings{chen-2021-plotcoder,
    title={PlotCoder: Hierarchical Decoding for Synthesizing Visualization Code in Programmatic Context},
    author={Chen, Xinyun  and
      Gong, Linyuan  and
      Cheung, Alvin  and
      Song, Dawn},
    booktitle={Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics and the 11th International Joint Conference on Natural Language Processing (Volume 1: Long Papers)},
    year={2021}
}