Text Generation
Transformers
Safetensors
code
t5
text2text-generation
codet5
code-repair
program-repair
bug-fixing
java
seq2seq
Eval Results (legacy)
text-generation-inference
Instructions to use thealper2/codet5-base-code-repair with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use thealper2/codet5-base-code-repair with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="thealper2/codet5-base-code-repair")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForSeq2SeqLM tokenizer = AutoTokenizer.from_pretrained("thealper2/codet5-base-code-repair") model = AutoModelForSeq2SeqLM.from_pretrained("thealper2/codet5-base-code-repair", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use thealper2/codet5-base-code-repair with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "thealper2/codet5-base-code-repair" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "thealper2/codet5-base-code-repair", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/thealper2/codet5-base-code-repair
- SGLang
How to use thealper2/codet5-base-code-repair 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 "thealper2/codet5-base-code-repair" \ --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": "thealper2/codet5-base-code-repair", "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 "thealper2/codet5-base-code-repair" \ --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": "thealper2/codet5-base-code-repair", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use thealper2/codet5-base-code-repair with Docker Model Runner:
docker model run hf.co/thealper2/codet5-base-code-repair
Upload README.md with huggingface_hub
Browse files
README.md
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: bsd-3-clause
|
| 3 |
+
base_model: Salesforce/codet5-base
|
| 4 |
+
datasets:
|
| 5 |
+
- google/code_x_glue_cc_code_refinement
|
| 6 |
+
language:
|
| 7 |
+
- code
|
| 8 |
+
library_name: transformers
|
| 9 |
+
pipeline_tag: text2text-generation
|
| 10 |
+
tags:
|
| 11 |
+
- code
|
| 12 |
+
- codet5
|
| 13 |
+
- code-repair
|
| 14 |
+
- program-repair
|
| 15 |
+
- bug-fixing
|
| 16 |
+
- java
|
| 17 |
+
- seq2seq
|
| 18 |
+
model-index:
|
| 19 |
+
- name: codet5-base-code-repair
|
| 20 |
+
results:
|
| 21 |
+
- task:
|
| 22 |
+
type: text2text-generation
|
| 23 |
+
name: Automated Program Repair
|
| 24 |
+
dataset:
|
| 25 |
+
name: CodeXGLUE code-refinement (small)
|
| 26 |
+
type: google/code_x_glue_cc_code_refinement
|
| 27 |
+
config: small
|
| 28 |
+
split: test
|
| 29 |
+
metrics:
|
| 30 |
+
- type: exact_match
|
| 31 |
+
value: 22.43
|
| 32 |
+
name: Exact Match (%)
|
| 33 |
+
- type: bleu
|
| 34 |
+
value: 80.13
|
| 35 |
+
name: BLEU
|
| 36 |
+
---
|
| 37 |
+
|
| 38 |
+
# codet5-base-code-repair
|
| 39 |
+
|
| 40 |
+
[Salesforce/codet5-base](https://huggingface.co/Salesforce/codet5-base) fine-tuned on the
|
| 41 |
+
[CodeXGLUE code-refinement](https://huggingface.co/datasets/google/code_x_glue_cc_code_refinement)
|
| 42 |
+
`small` split for **automated program repair**: given a buggy Java method, the model generates the
|
| 43 |
+
fixed version.
|
| 44 |
+
|
| 45 |
+
Inputs and outputs follow the dataset's abstracted Java style, where identifiers are normalised to
|
| 46 |
+
tokens such as `METHOD_1`, `VAR_1`, `TYPE_1` and `STRING_1`.
|
| 47 |
+
|
| 48 |
+
## Usage
|
| 49 |
+
|
| 50 |
+
```python
|
| 51 |
+
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
|
| 52 |
+
|
| 53 |
+
model_id = "MODEL_ID" # <- repo id
|
| 54 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 55 |
+
model = AutoModelForSeq2SeqLM.from_pretrained(model_id)
|
| 56 |
+
|
| 57 |
+
buggy = (
|
| 58 |
+
"public int METHOD_1 ( int VAR_1 ) { if ( VAR_1 = 0 ) { return 1 ; } "
|
| 59 |
+
"return ( VAR_1 * ( METHOD_1 ( ( VAR_1 - 1 ) ) ) ) ; }"
|
| 60 |
+
)
|
| 61 |
+
|
| 62 |
+
inputs = tokenizer(buggy, max_length=256, truncation=True, return_tensors="pt")
|
| 63 |
+
outputs = model.generate(**inputs, max_new_tokens=256, num_beams=4, early_stopping=True)
|
| 64 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
| 65 |
+
```
|
| 66 |
+
|
| 67 |
+
No task prefix is needed — the buggy snippet is fed in as-is. Beam search with `num_beams=4` is the
|
| 68 |
+
decoding setting used for all numbers reported below, and it is already stored in the repo's
|
| 69 |
+
`generation_config.json`.
|
| 70 |
+
|
| 71 |
+
## Results
|
| 72 |
+
|
| 73 |
+
Full splits (5,835 examples each), beam search with 4 beams:
|
| 74 |
+
|
| 75 |
+
| Split | Exact Match | BLEU | Loss |
|
| 76 |
+
|------------|-------------|-------|--------|
|
| 77 |
+
| Validation | 21.29% | 80.27 | 0.1272 |
|
| 78 |
+
| Test | 22.43% | 80.13 | 0.1257 |
|
| 79 |
+
|
| 80 |
+
Breakdown of the test-set predictions:
|
| 81 |
+
|
| 82 |
+
| Outcome | Share |
|
| 83 |
+
|---------------------------------------------|--------|
|
| 84 |
+
| Exact fix | 22.43% |
|
| 85 |
+
| Partial fix (changed, closer but not exact) | 13.49% |
|
| 86 |
+
| Input copied unchanged | 3.38% |
|
| 87 |
+
| Incorrect | 64.08% |
|
| 88 |
+
|
| 89 |
+
The high BLEU next to the modest exact-match rate is expected for this task: the fixed method is
|
| 90 |
+
usually a near-copy of the buggy one, so most generated tokens are correct even when the actual bug
|
| 91 |
+
is not fixed. **Exact match is the metric that matters here**; BLEU mostly measures how well the
|
| 92 |
+
model preserves the surrounding code.
|
| 93 |
+
|
| 94 |
+
Validation exact match by epoch (1,000-example in-training subset):
|
| 95 |
+
|
| 96 |
+
| Epoch | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
|
| 97 |
+
|-------|------|------|------|------|------|------|------|------|----------|------|
|
| 98 |
+
| EM | 10.5 | 15.2 | 17.5 | 19.5 | 19.8 | 20.6 | 20.9 | 20.6 | **21.2** | 21.0 |
|
| 99 |
+
|
| 100 |
+
The epoch-9 checkpoint scored best and is the one published here.
|
| 101 |
+
|
| 102 |
+
## Training
|
| 103 |
+
|
| 104 |
+
| | |
|
| 105 |
+
|---|---|
|
| 106 |
+
| Base model | `Salesforce/codet5-base` (~223M params) |
|
| 107 |
+
| Dataset | `google/code_x_glue_cc_code_refinement`, config `small` |
|
| 108 |
+
| Train / validation / test | 46,680 / 5,835 / 5,835 |
|
| 109 |
+
| Epochs | 10 (best checkpoint by exact match kept) |
|
| 110 |
+
| Learning rate | 5e-5, linear decay, 5% warmup |
|
| 111 |
+
| Batch size | 16 × 2 gradient accumulation (effective 32) |
|
| 112 |
+
| Weight decay | 0.01 |
|
| 113 |
+
| Max grad norm | 1.0 |
|
| 114 |
+
| Max source / target length | 256 / 256 tokens |
|
| 115 |
+
| Precision | bf16 |
|
| 116 |
+
| Seed | 42 |
|
| 117 |
+
| Training time | ~1h25m on a single GPU |
|
| 118 |
+
|
| 119 |
+
No example in any split was truncated at 256 tokens (longest source: 132 tokens), and the dataset
|
| 120 |
+
contains no identical buggy/fixed pairs.
|
| 121 |
+
|
| 122 |
+
## Limitations
|
| 123 |
+
|
| 124 |
+
- Trained only on **abstracted Java** methods from CodeXGLUE. Real-world code with actual
|
| 125 |
+
identifier names, or any other language, is out of distribution and will perform much worse.
|
| 126 |
+
- Handles single, self-contained methods — no cross-file or repository-level context.
|
| 127 |
+
- Roughly two thirds of test inputs are still not repaired correctly. Treat outputs as suggestions
|
| 128 |
+
to review, not as verified fixes, and always re-run your tests.
|
| 129 |
+
- The model can return the input unchanged (3.4% of the test set) when it finds no fix.
|
| 130 |
+
|
| 131 |
+
## License
|
| 132 |
+
|
| 133 |
+
Released under BSD-3-Clause, following the `Salesforce/codet5-base` base model. The training data,
|
| 134 |
+
CodeXGLUE code-refinement, is distributed under the Computational Use of Data Agreement (C-UDA).
|