📖 Check out my blog: Click Here
🔗 Live Demo: Click Here
This project is an AI-powered grammar and spell checker that utilizes Groq's LLM (Large Language Model) to correct spelling, grammar, and context errors in both English and Hindi. The application is built using Streamlit for an interactive user experience.
- ✅ Supports English and Hindi
- 🔍 AI-driven Grammar & Spell Correction
- 🎨 User-friendly UI with a dark theme
- ⚡ Instant Results with a single click
- 🏠 Built with Streamlit for easy deployment
This project uses Groq's Llama3-8B-8192 model, Meta's advanced large language model optimized for fast inference. It was chosen because:
- ✅ High Accuracy: It effectively detects and corrects grammatical errors while preserving context and meaning.
- ⚡ Lightning Fast: Groq's hardware acceleration provides ultra-fast response times, making it ideal for real-time applications.
- 💡 Superior Context Understanding: Llama3-8B excels at maintaining sentence coherence, nuance, and natural language flow.
- 📚 Efficient Processing: Can handle complex and lengthy text inputs with remarkable efficiency and accuracy.
- 🎯 Multilingual Support: Excellent performance in both English and Hindi language correction tasks.
- The user enters text that needs correction.
- The app sends the text to Groq's LLM API, which processes the input using the advanced Llama3-8B-8192 model.
- The LLM analyzes the text for grammar, spelling, and contextual errors.
- The corrected text is then returned and displayed to the user.
- Text Input: User provides raw text in English or Hindi.
- System Prompt: The LLM is instructed to act as a grammar and spell checker.
- Processing: The model detects errors and improves sentence structure while keeping the original meaning intact.
- Output: A refined and corrected version of the input is returned.
The model is instructed with a carefully designed system prompt to ensure accurate and context-aware corrections. The prompts used are:
You are an advanced English grammar and spell checker. Correct the text while maintaining its meaning.
आप एक अत्याधुनिक हिंदी व्याकरण और वर्तनी सुधारक हैं।
कृपया दिए गए हिंदी पाठ को सही करें लेकिन उसका अनुवाद न करें।
केवल व्याकरण, वाक्य संरचना और वर्तनी की त्रुटियों को ठीक करें, अर्थ को वैसा ही रखें।
- ✅ Ensures Precision: The prompts explicitly ask the LLM to focus on correcting grammar and spelling while maintaining context.
- 🌐 Supports Multiple Languages: Language-specific prompts allow optimal performance for English and Hindi.
- 💠 Preserves Meaning: The instruction ensures that the original intent of the text remains intact.
- 🎯 Optimized for LLM Processing: It minimizes ambiguity, making the model's responses more predictable and reliable.
- 🚫 Prevents Translation: Specifically instructs Hindi corrections without translation to English.
Make sure you have Python 3.8+ installed on your system.
# Clone this repository
git clone https://github.com/SimranShaikh20/grammar-checker.git
cd grammar-checker
# Install dependencies
pip install -r requirements.txt
# Run the application
streamlit run app.py
This project uses Groq LLM API for text correction.
POST https://api.groq.com/openai/v1/chat/completions
import requests
API_KEY = "your_groq_api_key"
text_to_correct = "Thiss is an exemple of baad grammr."
language = "English"
url = "https://api.groq.com/openai/v1/chat/completions"
headers = {"Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json"}
payload = {
"model": "llama3-8b-8192",
"messages": [
{"role": "system", "content": "You are an advanced English grammar and spell checker. Correct the text while maintaining its meaning."},
{"role": "user", "content": f"Correct this English text: {text_to_correct}"}
],
"temperature": 0.2,
"max_tokens": 500
}
response = requests.post(url, headers=headers, json=payload)
print(response.json()["choices"][0]["message"]["content"])
This project includes custom CSS styling for a modern UI:
- 🌑 Dark mode background
- 🌟 Multicolored gradient buttons
- 🌍 Styled text inputs with improved readability
- 🛠️ Custom sidebar with a sleek layout
- 🚃 Voice Input Support
- 📚 Multi-language Support (Spanish, French, etc.)
- 🖊 Auto-correction while typing
- 🌐 Deploy as a Web App
sequenceDiagram
participant User
participant Streamlit
participant GroqAPI
participant Llama3LLM
User->>Streamlit: Enters text + selects language
Streamlit->>GroqAPI: Sends correction request
GroqAPI->>Llama3LLM: Processes with system prompt
Llama3LLM->>GroqAPI: Returns corrected text
GroqAPI->>Streamlit: Receives response
Streamlit->>User: Displays corrected text
This project is licensed under the MIT License.
Simran Shaikh
🚀 Made with ❤️ by Simran