π§ AutoCodeFix-AI: Transformer-Powered Automatic Code Repair
AutoCodeFix-AI is an advanced yet lightweight AI system that automatically detects, explains, and fixes code errors in Python and C-style languages using transformer-based models such as StarCoder2 and CodeT5+.
It provides:
- βοΈ A FastAPI backend for scalable inference
- ποΈ A Gradio web demo for live interaction and testing
- π Notebooks for model finetuning and evaluation
π§© Key Features
β
Automated code error detection and correction
β
Natural-language explanations of fixes
β
Transformer-based fine-tuning (StarCoder2 / CodeT5+)
β
Ready-to-use REST API (FastAPI)
β
Interactive Hugging Face demo via Gradio
β
Modular and lightweight (~40 MB project)
π Project Structure
autocodefix-ai/
β
βββ README.md
βββ requirements.txt
βββ setup.py
βββ LICENSE
β
βββ data/
β βββ raw/
β βββ processed/
β βββ samples/
β
βββ notebooks/
β βββ 01_data_exploration.ipynb
β βββ 02_preprocessing.ipynb
β βββ 03_model_finetuning.ipynb
β βββ 04_evaluation.ipynb
β βββ 05_inference_demo.ipynb
β
βββ src/
β βββ config/
β β βββ model_config.yaml
β β βββ training_args.yaml
β βββ data/
β β βββ data_loader.py
β β βββ preprocessing.py
β βββ model/
β β βββ model_builder.py
β β βββ train_model.py
β β βββ evaluate_model.py
β β βββ inference.py
β βββ utils/
β β βββ logger.py
β β βββ metrics.py
β β βββ helper.py
β βββ app/
β βββ main.py # FastAPI backend
β βββ gradio_demo.py # Local Gradio UI
β
βββ deployment/
β βββ Dockerfile
β βββ api_service.py
β βββ gradio_service.py
β βββ huggingface_spaces/
β βββ app.py
β
βββ tests/
βββ test_data.py
βββ test_model.py
βββ test_inference.py
βββ test_api.py
βοΈ Installation
git clone https://huggingface.co/spaces/hmnshudhmn24/autocodefix-ai
cd autocodefix-ai
pip install -r requirements.txt
π§ Model Support
| Model | Task | Source |
|---|---|---|
| πͺ StarCoder2 | Code completion & repair | Hugging Face |
| βοΈ CodeT5+ | Code understanding & generation | Hugging Face |
Models and configurations are defined in:
src/config/model_config.yaml
src/config/training_args.yaml
π§© Usage
πΉ Run the FastAPI Backend
uvicorn src.app.main:app --reload
Access it at: http://localhost:8000/docs
πΉ Launch Gradio Web Demo
python deployment/huggingface_spaces/app.py
Then open the local or Hugging Face demo URL.
π§ͺ Example API Request
curl -X POST "http://localhost:8000/fix" -H "Content-Type: application/json" -d '{"code": "def add(a,b)
return a+b"}'
Response:
{
"fixed_code": "def add(a, b):
return a + b",
"explanation": "Added missing colon and indentation."
}
π Training & Evaluation
- Data Exploration:
notebooks/01_data_exploration.ipynb - Preprocessing:
notebooks/02_preprocessing.ipynb - Model Finetuning:
notebooks/03_model_finetuning.ipynb - Evaluation:
notebooks/04_evaluation.ipynb - Inference Demo:
notebooks/05_inference_demo.ipynb
All experiment outputs are stored under:
experiments/logs/
experiments/checkpoints/
experiments/results/