by David Wan, Eran Hirsch, Elias Stengel-Eskin, Ido Dagan, Mohit Bansal
This repo contains the code for our paper GenerationPrograms: Fine-grained Attribution with Executable Programs.
Please refer to the respective repository for instructions on downloading the data. We expect a json file with the following keys:
context: List[str], where each string is a documentquestion: str
The code is located in the src directory.
The files are:
program.py: Contains theProgramobject, which constructs the tree and keeps a record of module inputs and outputs.run.py: Script to run the baseline ALCE method.run_program.py: Script to run GenerationPrograms.util.py: Utilities for parsing and splitting sentences.model.py: Model wrapper. It creates aModel()object, and running therun(prompt)method will execute the model.
Both inference scripts take the same arguments. Here is an example of how to run the code:
dataset="lfqa"
python src/run.py --data data/${dataset}.json --model gpt4o \
--prompt prompts/${dataset}_fewshot.txt --fewshot_examples prompts/${dataset}_fewshots_doc.json \
--output output/gpt4o_${dataset}_alce.json
python src/run_program.py --model gpt4o --add_citation \
--data data/${dataset}.json \
--prompt prompts/program_fewshot.txt --fewshot_examples prompts/${dataset}_fewshots_program.json \
--output output/gpt4o_${dataset}_program.jsonIf you find our project useful in your research, please cite the following paper:
@misc{wan2025generationprogramsfinegrainedattributionexecutable,
title={GenerationPrograms: Fine-grained Attribution with Executable Programs},
author={David Wan and Eran Hirsch and Elias Stengel-Eskin and Ido Dagan and Mohit Bansal},
year={2025},
eprint={2506.14580},
archivePrefix={arXiv},
primaryClass={cs.CL},
url={https://arxiv.org/abs/2506.14580},
}