Skip to content

nilkanth02/Next-Word-Predictor

Repository files navigation

🧠 AI Smart Keyboard - Your Personal Writing Assistant

Ever wondered how your phone knows what you're about to type? This project recreates that magic using deep learning! It's an intelligent text prediction app that learns from patterns in language to suggest your next word.

🎯 What Does It Do?

Think of it as your personal writing buddy that:

  • Reads your mind (well, almost!) - predicts what word you'll type next
  • Learns from context - understands that "I love" is often followed by specific words
  • Gives you options - shows 3 smart suggestions you can click to autocomplete
  • Gets smarter over time - trained on thousands of sentences to understand natural language

🎮 Try It Out!

The Easy Way (No Setup Required!)

  1. Click the green "Code" button above
  2. Select "Codespaces" → "Create codespace"
  3. Grab a coffee ☕ while it sets up (takes ~2 minutes)
  4. Your app will automatically open - start typing!

For the Tech-Savvy

git clone <your-repo-url>
cd next-word-predictor
pip install -r requirements.txt
streamlit run app2.py  # The cool smart keyboard version

🎪 Two Ways to Play

🎹 Smart Keyboard Mode (app2.py) - The Fun One!

  • Start typing anything: "The weather is..."
  • Watch as 3 word suggestions appear like magic
  • Click any suggestion to add it instantly
  • Keep going and build entire sentences!

🎯 Simple Predictor (app.py) - The Classic

  • Type a phrase and hit "Predict"
  • Get one carefully chosen next word
  • Perfect for testing specific phrases

🧪 Cool Examples to Try

  • Type: "I love" → Might suggest: "machine", "deep", "natural"
  • Type: "The weather is" → Could suggest: "nice", "beautiful", "perfect"
  • Type: "I am going to" → Might predict: "the", "work", "sleep"

Results vary based on training data - that's the fun part!

🔬 The Science Behind the Magic

Don't worry, you don't need a PhD to understand this:

  1. Training Phase: Fed the AI thousands of sentences so it learns patterns
  2. Smart Memory: Uses LSTM (Long Short-Term Memory) - like giving the AI a really good memory
  3. Pattern Recognition: Learns that certain words often follow others
  4. Probability Magic: For each word you type, calculates which words are most likely to come next

📚 What's Inside the Box

🏠 Your Project Home
├── 🎮 app2.py              # The smart keyboard (start here!)
├── 🎯 app.py               # Simple predictor
├── 🧠 next_word_model.h5   # The trained AI brain
├── 🔤 tokenizer.pkl        # Teaches AI to understand words
├── 📓 training_notebook.ipynb # How the AI learned (for curious minds)
└── 📋 requirements.txt     # Shopping list for Python packages

🎨 Make It Your Own

Want to improve it? Here are some fun ideas:

  • Train on your favorite book - make it predict like Shakespeare or Harry Potter
  • Add more suggestions - why stop at 3 words?
  • Different languages - teach it Spanish, French, or any language you love
  • Smarter UI - add themes, sounds, or animations

🤔 Why I Built This

As someone fascinated by how our phones seem to "read our minds," I wanted to peek behind the curtain. This project demystifies predictive text and shows that with some Python knowledge and creativity, you can build surprisingly smart applications.

Plus, it's just plain fun to watch an AI try to complete your thoughts! 🤖

🚀 What's Next?

  • Add support for longer context (remember more than just the last few words)
  • Train on larger, more diverse datasets
  • Add confidence scores for predictions
  • Mobile-friendly interface
  • Voice input support

💝 A Personal Note

This project represents hours of curiosity, learning, and debugging. If it helps you understand AI a little better or inspires you to build something cool, then it's served its purpose!

Feel free to break it, improve it, or use it as a stepping stone for your own AI adventures.

Happy typing!


Built with curiosity, caffeine, and a lot of trial-and-error by Nilkanth Ahire

P.S. - If the AI suggests something weird, that's just it being creative! 😄

Releases

No releases published

Packages

No packages published