Transformers
Safetensors
English
t5
text2text-generation
#ai
#codefixing
#programming
#syntax
#gptmodel
#gpt
#free
#multilanguage
#latest
text-generation-inference
Instructions to use wizcodes12/snaxfix-model with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use wizcodes12/snaxfix-model with Transformers:
# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForSeq2SeqLM tokenizer = AutoTokenizer.from_pretrained("wizcodes12/snaxfix-model") model = AutoModelForSeq2SeqLM.from_pretrained("wizcodes12/snaxfix-model", device_map="auto") - Notebooks
- Google Colab
- Kaggle
|
Download README.md from wizcodes12/snaxfix-model: direct link, hf CLI and curl.
- Browser
- Download file 8.44 kB
-
https://huggingface.co/wizcodes12/snaxfix-model/resolve/main/README.md
- Command line
-
hf download hf://wizcodes12/snaxfix-model/README.md
-
curl -L -o README.md https://huggingface.co/wizcodes12/snaxfix-model/resolve/main/README.md
8.44 kB
| license: mit | |
| language: | |
| - en | |
| metrics: | |
| - accuracy | |
| base_model: | |
| - google/flan-t5-base | |
| library_name: transformers | |
| tags: | |
| - '#ai' | |
| - '#codefixing' | |
| - '#programming' | |
| - '#syntax' | |
| - '#gptmodel' | |
| - '#gpt' | |
| - '#free' | |
| - '#multilanguage' | |
| - '#latest' | |
| # SnaxFix: Advanced Syntax Error Fixer | |
| SnaxFix is an AI-powered tool designed to automatically fix syntax errors in code across multiple programming languages. Built on top of the `google/flan-t5-base` model and fine-tuned by [wizcodes12](https://huggingface.co/wizcodes12), this tool supports 11 programming languages: Python, JavaScript, Java, C, C++, C#, Rust, PHP, HTML, CSS, and SQL. The model is hosted on Hugging Face at [wizcodes12/snaxfix-model](https://huggingface.co/wizcodes12/snaxfix-model). | |
| This repository contains a Gradio-based web application for interactively testing the syntax error fixing capabilities of the model. The application is designed to run in a Hugging Face Space or locally, providing a user-friendly interface with features like syntax highlighting, language selection, example code loading, and history tracking. | |
| [](https://huggingface.co/spaces/wizcodes/snaxfix-app) | |
| ## Features | |
| - **Multi-Language Support**: Fix syntax errors in Python, JavaScript, Java, C, C++, C#, Rust, PHP, HTML, CSS, and SQL. | |
| - **Interactive Interface**: Built with Gradio, featuring a clean UI with code input/output, language selection, and history tracking. | |
| - **Example Snippets**: Load pre-defined broken code examples for each supported language to test the model. | |
| - **History Tracking**: View a history of all fixes performed during a session. | |
| - **Syntax Highlighting**: Code input and output areas support syntax highlighting for better readability. | |
| - **Responsive Design**: The Gradio interface is styled with a modern theme for an enhanced user experience. | |
| ## Installation | |
| To run the SnaxFix application locally or in a Hugging Face Space, follow these steps: | |
| ### Prerequisites | |
| - Python 3.8+ | |
| - A compatible GPU (optional but recommended for faster inference) | |
| - Git (for cloning the repository) | |
| ### Steps | |
| 1. **Clone the Repository** (if applicable): | |
| ```bash | |
| git clone https://github.com/wizcodes12/snaxfix-model.git | |
| cd snaxfix-model | |
| ``` | |
| 2. **Install Dependencies**: | |
| Create a virtual environment and install the required packages: | |
| ```bash | |
| python -m venv venv | |
| source venv/bin/activate # On Windows: venv\Scripts\activate | |
| pip install -r requirements.txt | |
| ``` | |
| 3. **Run the Application**: | |
| Start the Gradio app: | |
| ```bash | |
| python app.py | |
| ``` | |
| This will launch a web interface accessible at `http://localhost:7860` (or another port if specified). | |
| ## Usage | |
| 1. **Select a Language**: Choose a programming language from the dropdown menu (e.g., Python, JavaScript). | |
| 2. **Enter Code**: Input code with syntax errors in the code editor. The editor supports syntax highlighting for the selected language. | |
| 3. **Fix Syntax**: Click the "Fix Syntax" button to process the code and view the corrected version in the output editor. | |
| 4. **Load Example**: Click the "Load Example" button to populate the input editor with a sample broken code snippet for the selected language. | |
| 5. **Clear Input**: Use the "Clear Input" button to reset the input editor. | |
| 6. **View History**: Expand the "History of Fixes" accordion to see a log of all fixes, including timestamps, input code, and corrected code. | |
| 7. **Clear History**: Click the "Clear History" button to reset the fix history. | |
| 8. **Learn More**: Expand the "About & License" accordion to view information about the project and its MIT License. | |
| ## Example | |
| Below is a Python script demonstrating how to use the `wizcodes12/snaxfix-model` to fix syntax errors programmatically: | |
| ```python | |
| from transformers import AutoTokenizer, AutoModelForSeq2SeqLM | |
| # Model configuration | |
| model_id = "wizcodes12/snaxfix-model" | |
| print("📦 Loading model...") | |
| tokenizer = AutoTokenizer.from_pretrained(model_id) | |
| model = AutoModelForSeq2SeqLM.from_pretrained(model_id) | |
| # Prepare input | |
| language = "python" | |
| broken_code = "def hello()\n print('hi')" | |
| input_text = f"<{language.upper()}> Fix the syntax errors in this {language} code: {broken_code}" | |
| # Run inference | |
| inputs = tokenizer(input_text, return_tensors="pt", truncation=True, max_length=512) | |
| print("⚙️ Generating fix...") | |
| outputs = model.generate( | |
| **inputs, | |
| max_length=512, | |
| num_beams=4, | |
| early_stopping=True, | |
| temperature=0.7, | |
| pad_token_id=tokenizer.pad_token_id, | |
| use_cache=True | |
| ) | |
| # Show results | |
| fixed_code = tokenizer.decode(outputs[0], skip_special_tokens=True) | |
| print("\n🧪 Input:") | |
| print(input_text) | |
| print("\n✅ Fixed:") | |
| print(fixed_code) | |
| ``` | |
| **Expected Output**: | |
| ``` | |
| 📦 Loading model... | |
| ⚙️ Generating fix... | |
| 🧪 Input: | |
| <PYTHON> Fix the syntax errors in this python code: def hello() | |
| print('hi') | |
| ✅ Fixed: | |
| def hello(): | |
| print('hi') | |
| ``` | |
| This script loads the model, prepares an input with a syntax error (missing colon in a Python function definition), and generates the corrected code. The model expects input in the format `<LANGUAGE> Fix the syntax errors in this <language> code: <broken_code>`. Adjust the `language` and `broken_code` variables to test other languages and errors. | |
| ## Requirements | |
| The `requirements.txt` file includes the following dependencies: | |
| ``` | |
| gradio==4.44.0 | |
| transformers==4.30.2 | |
| torch==2.0.1 | |
| sentencepiece==0.1.99 | |
| ``` | |
| These versions are pinned to ensure compatibility with the model and Gradio interface. | |
| ## Model Details | |
| - **Model Name**: `wizcodes12/snaxfix-model` | |
| - **Base Model**: `google/flan-t5-base` | |
| - **Training Data**: 15,000 synthetic examples of broken and correct code across 11 programming languages, generated using custom error patterns. | |
| - **Supported Languages**: Python, JavaScript, Java, C, C++, C#, Rust, PHP, HTML, CSS, SQL | |
| - **Max Input Length**: 512 tokens | |
| - **Training Environment**: Optimized for Kaggle with mixed precision training and memory management | |
| The model was fine-tuned to recognize and fix common syntax errors, such as missing semicolons, incorrect brackets, wrong keyword cases, and more. It uses special tokens (e.g., `<PYTHON>`, `<JAVASCRIPT>`) to handle language-specific contexts. | |
| ## Hosting on Hugging Face Spaces | |
| To deploy this application on a Hugging Face Space: | |
| 1. Create a new Space on [Hugging Face](https://huggingface.co/spaces). | |
| 2. Upload the following files: | |
| - `app.py` | |
| - `requirements.txt` | |
| - `README.md` (optional, for documentation) | |
| 3. Ensure the Space uses a Python environment with GPU support (if available). | |
| 4. The Space will automatically install dependencies from `requirements.txt` and run `app.py`. | |
| ## Contributing | |
| Contributions are welcome! Please open an issue or pull request on the [GitHub repository](https://github.com/wizcodes12/snaxfix-model) for bug reports, feature requests, or improvements. | |
| ## License | |
| This project is licensed under the MIT License. See the [LICENSE](https://github.com/wizcodes12/snaxfix-model/blob/main/LICENSE) file for details. | |
| ```plaintext | |
| MIT License | |
| Copyright (c) 2025 wizcodes12 | |
| Permission is hereby granted, free of charge, to any person obtaining a copy | |
| of this software and associated documentation files (the "Software"), to deal | |
| in the Software without restriction, including without limitation the rights | |
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
| copies of the Software, and to permit persons to whom the Software is | |
| furnished to do so, subject to the following conditions: | |
| The above copyright notice and this permission notice shall be included in all | |
| copies or substantial portions of the Software. | |
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |
| SOFTWARE. | |
| ``` | |
| ## Contact | |
| For questions or support, contact [wizcodes12](https://huggingface.co/wizcodes12) or open an issue on the [GitHub repository](https://github.com/wizcodes12/snaxfix-model). | |
| --- | |
| Happy coding with SnaxFix! |