{"id":17898749,"url":"https://github.com/mrvplusone/coeditor","last_synced_at":"2025-10-16T09:19:27.756Z","repository":{"id":171223247,"uuid":"481325686","full_name":"MrVPlusOne/Coeditor","owner":"MrVPlusOne","description":" Coeditor: Leveraging Repo-level Diffs for Code Auto-editing","archived":false,"fork":false,"pushed_at":"2024-02-25T19:42:15.000Z","size":4845,"stargazers_count":26,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-04T14:51:16.563Z","etag":null,"topics":["autocomplete","pytorch","transformer-architecture","vscode-extension"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MrVPlusOne.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-04-13T18:13:34.000Z","updated_at":"2025-01-02T02:20:09.000Z","dependencies_parsed_at":"2023-11-17T08:47:21.854Z","dependency_job_id":"1a85b0ca-908c-463f-8f47-8d878d242584","html_url":"https://github.com/MrVPlusOne/Coeditor","commit_stats":null,"previous_names":["mrvplusone/coeditor"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/MrVPlusOne/Coeditor","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrVPlusOne%2FCoeditor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrVPlusOne%2FCoeditor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrVPlusOne%2FCoeditor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrVPlusOne%2FCoeditor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MrVPlusOne","download_url":"https://codeload.github.com/MrVPlusOne/Coeditor/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrVPlusOne%2FCoeditor/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265066219,"owners_count":23706068,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["autocomplete","pytorch","transformer-architecture","vscode-extension"],"created_at":"2024-10-28T15:38:49.257Z","updated_at":"2025-10-16T09:19:27.676Z","avatar_url":"https://github.com/MrVPlusOne.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Coeditor: Leveraging Repo-level Diffs for Code Auto-editing\n\nCoeditor is a transformer model that auto-edits your code based on your recent code changes. This repo includes the server code for the [Coeditor VSCode extension](https://marketplace.visualstudio.com/items?itemName=JiayiWei.vscode-coeditor) and the scripts for data processing, model training, and evaluation. The ideas behind Coeditor are presented in the ICLR Spotlight paper, [Coeditor: Leveraging Repo-level Diffs for Code Auto-editing](https://openreview.net/forum?id=ALVwQjZRS8), by Jiayi Wei, Greg Durrett, and Isil Dillig.\n\nWatch the [Coeditor demo](https://www.youtube.com/watch?v=hjZE__jslzs) on Youtube.\n\n## Installation\n\n### Method 1: with Poetry (recommended)\n\nThis project uses [poetry](https://python-poetry.org) to manage the package dependencies. Poetry records all dependencies in the `pyproject.toml` file and manages the (project-specific) virtual environment for you.\n\nYou can install poetry via the following command:\n\n```bash\ncurl -sSL https://install.python-poetry.org | python3 -\npoetry completions bash \u003e\u003e ~/.bash_completion\n```\n\nTo install all dependencies required by Coeditor, make sure you have python 3.11 installed, then, run the following at the project root:\n\n```bash\npoetry install\n```\n\nYou can then spawn a shell within the project's virtual environment via `poetry shell`.\n\n### Method 2: using requirements.txt\n\nAlternatively, you can also install all dependencies using the exported [`requirements.txt`](requirements.txt) file.\n\n```bash\npip3 install -r requirements.txt\n```\n\n## Usages\n\n**Note**: All scripts below should be run within the poetry shell (or the virtual environment in which you installed all the dependencies).\n\n### Use the VSCode extension server✨\n\nRun [`python scripts/start_server.py`](scripts/start_server.py) to start the Coeditor VSCode extension server. This will download the pre-trained Coeditor model from Huggingface (if not already) and start the extension service at port 5042.\n\n### Run Coeditor inside a notebook\n- As an alternative to using the VSCode extension, you can directly run Coeditor inside [this notebook](notebooks/run_api.ipynb) by specifying a target file and line nubmer.\n\n### Run unit tests\n\nYou can run all unit tests via `poetry run pytest` (or just `pytest` if you run inside the poetry shell).\n\n### Download the PyCommits dataset\n\n1. (Optional) Configure the directories. Create the file `config/coeditor.json` and use the following template to specify where you want to store the dataset and the trained models:\n\n```json\n{\n    \"datasets_root\": \"/path/to/datasets/directory\",\n    \"models_root\": \"/path/to/models/direcotry\"\n}\n```\n\n2. Run the cells in [notebooks/download_data.ipynb](notebooks/download_data.ipynb) to clone the repos from GitHub. Note that we use the GitHub search API to search for repos with permissive licenses, so the results may change over time even though the query remains the same.\n\n3. (Optional) Run [scripts/prepare_data.py](scripts/prepare_data.py) to preprocess the repos into the PyCommits format introduced in the paper. You can safely skip this step since it will automatically be run when you train a new model (and with the corresponding encoder parameters).\n\n### Train a new model\n\nUse the [scripts/train_model.py](scripts/train_model.py) script to train a new model from scratch. By default, this script trains a model under our default settings, but you can uncomment the corresponding function calls at the bottom of the script to train a model following one of the ablation settings in the paper.\n\n**Note**: Only training with a single GPU is tested. You can set the GPU to use via the `CUDA_VISIBLE_DEVICES` environment variable.\n\n### Evaluate pre-trained models\n\n- **Comparison with Code Completion Approaches**: Run [scripts/code_completion_eval.py](scripts/code_completion_eval.py) to obtain the results reported in section 4.1 of the paper.\n- **Multi-round editing**: Run [scripts/multi_round_eval.py](scripts/multi_round_eval.py) to obtain the results reported in section 4.2 of the paper.\n- **Ablation Studies**: Run [scripts/single_round_eval.py](scripts/single_round_eval.py) to obtain the results reported in section 4.3 of the paper.\n\n\n## Citation\nPlease cite our paper as:\n```\n@inproceedings{\nwei2024coeditor,\ntitle={Coeditor: Leveraging Repo-level Diffs for Code Auto-editing},\nauthor={Jiayi Wei and Greg Durrett and Isil Dillig},\nbooktitle={The Twelfth International Conference on Learning Representations},\nyear={2024},\nurl={https://openreview.net/forum?id=ALVwQjZRS8}\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrvplusone%2Fcoeditor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmrvplusone%2Fcoeditor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrvplusone%2Fcoeditor/lists"}