Instructions to use nuprl/EditCoder with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use nuprl/EditCoder with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="nuprl/EditCoder")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("nuprl/EditCoder") model = AutoModelForCausalLM.from_pretrained("nuprl/EditCoder", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use nuprl/EditCoder with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "nuprl/EditCoder" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "nuprl/EditCoder", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/nuprl/EditCoder
- SGLang
How to use nuprl/EditCoder with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "nuprl/EditCoder" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "nuprl/EditCoder", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "nuprl/EditCoder" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "nuprl/EditCoder", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use nuprl/EditCoder with Docker Model Runner:
docker model run hf.co/nuprl/EditCoder
| # EditCoder | |
| The EditCoder models are the fine-tuned models described in the following paper: | |
| ``` | |
| @inproceedings{cassano2023edit, | |
| title={{Can It Edit? Evaluating the Ability of Large Language Models to Follow Code Editing Instructions}}, | |
| author={Federico Cassano and Luisa Li and Akul Sethi and Noah Shinn and Abby Brennan-Jones and Anton Lozhkov and Carolyn Jane Anderson and Arjun Guha}, | |
| booktitle={The First International Workshop on Large Language Model for Code}, | |
| year={2024}, | |
| url={https://arxiv.org/abs/2312.12450} | |
| } | |
| ``` | |
| This repository has several models. The root is the fine-tune of DeepSeek Coder 33B on the EditPackFT dataset. The other models are | |
| in subdirectories. You can do this: | |
| ```bash | |
| AutoModelForCausalLM.from_pretrained("nuprl/EditCoder", subfolder=DIR_NAME) | |
| ````` | |
| ## Prompt | |
| The model has been trained on the following prompt format: | |
| ``` | |
| ## Code Before: | |
| {before} | |
| ## Instruction: | |
| {instruction} | |
| ## Code After: | |
| {after} | |
| ``` | |
| Here is a python function that can be used for formatting the prompt correctly: | |
| ```py | |
| def edit_prompt(old, instr): | |
| before = f"""## Code Before:\n{old}\n""" | |
| instr = f"""## Instruction:\n{instr}\n""" | |
| after = f"""## Code After:\n""" | |
| return before + instr + after | |
| ``` | |
| ## Training Code | |
| We provide the full pipeline that was used for training our own edit-coder model. | |
| The pipeline and instructions can be found on our [GitHub repository](https://github.com/nuprl/CanItEdit/tree/main/editcoder). |