{"id":31067291,"url":"https://github.com/willwade/webllm-fixtool","last_synced_at":"2025-09-15T19:57:56.737Z","repository":{"id":309672822,"uuid":"1036803054","full_name":"willwade/webllm-fixtool","owner":"willwade","description":"A fast grammar correction tool powered by WebLLM running entirely in the browser with WebGPU acceleration","archived":false,"fork":false,"pushed_at":"2025-08-13T05:46:51.000Z","size":43,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-13T07:15:58.800Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/willwade.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-08-12T15:52:08.000Z","updated_at":"2025-08-13T05:46:55.000Z","dependencies_parsed_at":"2025-08-13T07:28:17.668Z","dependency_job_id":null,"html_url":"https://github.com/willwade/webllm-fixtool","commit_stats":null,"previous_names":["willwade/webllm-fixtool"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/willwade/webllm-fixtool","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willwade%2Fwebllm-fixtool","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willwade%2Fwebllm-fixtool/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willwade%2Fwebllm-fixtool/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willwade%2Fwebllm-fixtool/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/willwade","download_url":"https://codeload.github.com/willwade/webllm-fixtool/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willwade%2Fwebllm-fixtool/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275312966,"owners_count":25442563,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-15T02:00:09.272Z","response_time":75,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-09-15T19:57:53.262Z","updated_at":"2025-09-15T19:57:56.718Z","avatar_url":"https://github.com/willwade.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WebLLM Grammar Correction Tool\n\nA web application that demonstrates using WebLLM to build a grammar correction tool. This application uses the WebLLM library to correct grammatical errors in text input, providing up to 3 corrected sentence options with the first being the most likely correction.\n\n## 🚀 **Live Demo**\n\n**Try it now**: [https://willwade.github.io/webllm-fixtool/](https://willwade.github.io/webllm-fixtool/)\n\n*The application runs entirely in your browser using WebGPU - no data is sent to any server!*\n\n## Features\n\n- **AI-Powered Grammar Correction**: Uses the \"SmolLM2-360M-Instruct-q4f32_1-MLC\" model for fast, efficient grammar correction\n- **Multi-Language Support**: Supports multiple languages including English, Spanish, French, German, Italian, Portuguese, Russian, Japanese, Korean, and Chinese\n- **Real-time Correction**: Provides up to 3 correction options with the most likely option first\n- **Web Interface**: Simple, user-friendly web interface for testing the functionality\n- **Robust Error Handling**: Comprehensive error handling for WebLLM initialization and inference failures\n\n## Prerequisites\n\n- **Node.js**: Version 16 or higher\n- **WebGPU-Compatible Browser**: Chrome 113+, Edge 113+, or other WebGPU-enabled browsers\n- **Internet Connection**: Required for initial model download (approximately 1.5GB)\n\n## Installation\n\n1. **Clone or download this repository**:\n   ```bash\n   git clone \u003crepository-url\u003e\n   cd webllm-fixtool\n   ```\n\n2. **Install dependencies**:\n   ```bash\n   npm install\n   ```\n\n## Usage\n\n### Using the Live Demo\n\n1. **Visit**: [https://willwade.github.io/webllm-fixtool/](https://willwade.github.io/webllm-fixtool/)\n\n2. **Initialize WebLLM**:\n   - Click the \"Initialize WebLLM\" button\n   - Wait for the model to download and initialize (this may take a few minutes on first run)\n   - The button will turn green and show \"WebLLM Ready ✓\" when complete\n\n3. **Correct Grammar**:\n   - Select a language from the dropdown\n   - Enter text with grammatical errors in the text area\n   - Click \"Correct Grammar\" to get up to 3 correction options\n\n### Running Locally\n\n1. **Clone the repository**:\n   ```bash\n   git clone https://github.com/willwade/webllm-fixtool.git\n   cd webllm-fixtool\n   ```\n\n2. **Install dependencies** (for development):\n   ```bash\n   npm install\n   ```\n\n3. **Start the development server**:\n   ```bash\n   npm start\n   ```\n\n4. **Open your browser** and navigate to:\n   ```\n   http://localhost:3000\n   ```\n\n### Architecture\n\n**Client-Side Processing**: WebLLM runs entirely in the browser using WebGPU for local AI inference. No data is sent to external servers for processing.\n\n**GitHub Pages Hosting**: The application is hosted as a static site on GitHub Pages, requiring no server infrastructure. Everything runs in your browser!\n\n### API Endpoints\n\nThe application provides minimal REST API endpoints:\n\n- **GET `/api/health`** - Health check and status\n- **GET `/api/locales`** - Get supported language locales\n\n**Note**: Grammar correction is performed entirely client-side in the browser using WebLLM. No server-side API is needed for the core functionality.\n\n## Technical Details\n\n### Core Components\n\n1. **Client-Side WebLLM Integration** (`public/app.js`):\n   - Handles WebLLM engine initialization in the browser\n   - Implements the grammar correction logic using WebGPU\n   - Uses the exact prompt template as specified\n   - Provides robust error handling and input validation\n   - Real-time progress updates during model loading\n\n2. **Express Server** (`server.js`):\n   - Serves static files and minimal API endpoints\n   - Handles CORS and JSON parsing\n   - Lightweight server for hosting the web interface\n\n3. **Web Interface** (`public/index.html`):\n   - Responsive, user-friendly interface\n   - Real-time status updates during initialization and processing\n   - Sample text suggestions for different languages\n   - WebGPU compatibility checking\n\n### Model Information\n\n- **Models**: 5 options from 376MB to 3.7GB\n- **Smart prompting**: Automatically uses JSON mode for larger models, simple prompts for smaller ones\n- **Streaming**: Real-time response generation with progress updates\n- **Quantization**: 4-bit quantization for efficiency\n- **Performance**: Optimized for grammar correction tasks\n\n### Prompt Template\n\nThe application uses this exact prompt template:\n```\n\"Correct this sentence to a full grammatically correct sentence. Please give no more than 3 options and the first one most likely. Please provide nothing more than 3 options separated by a comma. Do not reply with errors or issues like you can't fix it. DO NOT remove swear words etc. It will be in language {locale} please respond in that language\"\n```\n\n## Browser Compatibility\n\nThis application requires a WebGPU-compatible browser:\n\n- ✅ Chrome 113+\n- ✅ Edge 113+\n- ✅ Firefox Nightly (with WebGPU enabled)\n- ❌ Safari (WebGPU not yet supported)\n\nTo verify WebGPU support, visit: https://webgpu.github.io/webgpu-samples/\n\n## Troubleshooting\n\n### Common Issues\n\n1. **\"WebGPU is not supported\"**:\n   - Ensure you're using a compatible browser\n   - Check that WebGPU is enabled in browser flags\n\n2. **Model loading fails**:\n   - Check your internet connection\n   - Ensure sufficient disk space (2GB+)\n   - Try refreshing the page and reinitializing\n\n3. **Slow performance**:\n   - First-time model download can be slow\n   - Subsequent runs should be much faster\n   - Consider using a faster internet connection for initial setup\n\n### Performance Tips\n\n- The model is cached after first download\n- Grammar correction is faster after initialization\n- Shorter text inputs process more quickly\n- Multiple corrections can be requested without reinitializing\n\n## Development\n\n### Project Structure\n```\nwebllm-fixtool/\n├── package.json          # Project configuration\n├── server.js            # Express server\n├── grammarCorrector.js  # Core grammar correction logic\n├── public/\n│   ├── index.html      # Web interface\n│   └── app.js          # Frontend JavaScript\n└── README.md           # This file\n```\n\n### Scripts\n\n- `npm start` - Start the production server\n- `npm run dev` - Start the development server (same as start)\n\n## License\n\nISC License\n\n## Contributing\n\nFeel free to submit issues and enhancement requests!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwillwade%2Fwebllm-fixtool","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwillwade%2Fwebllm-fixtool","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwillwade%2Fwebllm-fixtool/lists"}