README

March 19, 2025 · View on GitHub

Content

  • bleu.py: calculate the bleu score;
  • generator_metric.py: calculate the performance (BLEU & Exact match) of generator;
  • model.py: Seq2Seq model and beam search;
  • run.py: training, validation and test script;
  • evaluate.sh: bash script for evaluation;
  • run.sh: bash script for train and validation;
  • model/: folder save models and outputs by language, available for download at Huggingface;
    • model/{lang}/test_0_pred_gold.json: for each sample, have 10 prediction candidate and 1 ground-truth
    • model/{lang}/checkpoint-best-bleu/pytorch_model.bin: trained model
  • dataset/: folder save datasets by langauge, available for download at Huggingface.
    • dataset/{lang}/train.jsonl: training dataset
    • dataset/{lang}/dev.jsonl: validation dataset
    • dataset/{lang}/test.jsonl: test dataset

Download

Download model and dataset by runing download script:

bash download.sh

Quick start

Please refer to Quick_start.ipynb for quick start.

As baseline

  1. Parpare custon_input.jsonl file as input, each element of format:

    ⚠️: The edit_labels and code_window should have the same length

    {
        "edit_labels": list["replace" | "keep" | "add"]. Each element is an edit operation label,
        "code_window": list[str]. Each str element is a line of code,
        "after_edit": list[str]. If code window contains code block to replace then after_edit is code to replace that block. If code window require add action then after_edit is code to insert.
        "prompt": str | None. The natural language description of the edit,
        "prior_edits": list[dict]. Each dict has the following format: 
            {
                "code_before": list[str]. Each str element is a line of code before editing,
                "code_after":  list[str]. Each str element is a line of code after editing
            }
    }
    
  2. Run script transform.py to transform your customized dataset into CoEdPilot prompt format, where the three arguments represent the ratio for splitting your dataset into the training set, validation set, and test set.

    python transform.py 7 2 1
    
  3. You can now run or evaluate on your customized dataset

Usage

# Train
bash run.sh

# Evaluate
bash evaluate.sh

Key results

LanguageEM@1EM@3EM@5EM@10BLEU@1BLEU@3BLEU@5BLEU@10
Typescript41.5846.8648.7550.6561.7570.3171.9973.68
Javascript41.8347.5049.3150.9960.7069.7171.3773.02
Java40.6946.8748.7850.5160.5468.3570.1171.73
Python33.4838.5240.4142.0957.5965.6567.4769.11
Go48.9455.0957.1859.1665.3771.9673.4774.98