🧠 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

  1. Data Exploration: notebooks/01_data_exploration.ipynb
  2. Preprocessing: notebooks/02_preprocessing.ipynb
  3. Model Finetuning: notebooks/03_model_finetuning.ipynb
  4. Evaluation: notebooks/04_evaluation.ipynb
  5. Inference Demo: notebooks/05_inference_demo.ipynb

All experiment outputs are stored under:

experiments/logs/
experiments/checkpoints/
experiments/results/
Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support