A deep learning-based predictive keyboard application with LSTM neural networks
- 🧠 LSTM-based predictive text model for accurate next-word predictions
- ⚡ Real-time word prediction with instant results
- 🎯 Top-k sampling for diverse and relevant predictions
- 🌙 Dark mode UI for comfortable viewing in any lighting
- 🖥️ Interactive web interface built with Streamlit
- 📊 Confidence scores for each prediction
- 📈 Configurable prediction count to control output
Python 3.7+PyTorch >= 1.9.0Streamlit >= 1.28.0NumPy >= 1.21.0
- Modern CPU (GPU recommended for training)
- 2GB+ RAM
- 50MB+ disk space
git clone https://github.com/BLShaw/Seq2Key
cd Seq2Keypip install -r requirements.txtYou need the model file predictive_keyboard_model.pth in the project directory.
This file is typically too large for Git repositories. If it's not included, you'll need to train your own model
using the provided notebook or download a pre-trained model file.
To train your own model, run the predictive_keyboard_model.ipynb notebook with your training data (TXT).
streamlit run app.py- Input Text: Enter your text in the input field (e.g., "the quick brown")
- Configure Predictions: Adjust the number of predictions to show using the slider
- Get Predictions: Click "Get Predictions" to see the forecasted words
- View Results: The model displays the top-k most likely next words with confidence scores
- Input: "the quick"
- Predictions: ["brown", "way", "and", "time", "man"]
- Confidence Scores: [0.45, 0.23, 0.15, 0.12, 0.05]
The predictive model utilizes a sophisticated LSTM-based architecture:
- Embedding Layer: Converts tokens to dense vector representations
- LSTM Layers: Two-layer LSTM for sequence processing and context understanding
- Dropout Layer: Prevents overfitting with 30% dropout rate
- Fully Connected Layer: Outputs probability distribution over vocabulary
- Special Tokens: Support for padding, unknown, start-of-sequence, and end-of-sequence tokens
| Component | Details |
|---|---|
| Embedding Dimension | 128 |
| Hidden Dimension | 256 |
| Number of Layers | 2 |
| Dropout Rate | 0.3 |
| Vocabulary Size | 4500+ |
predictive-keyboard-model/
├── app.py # Main Streamlit application
├── predictive_keyboard_model.pth # Pre-trained model weights
├── predictive_keyboard_model.ipynb # Training notebook
├── dataset.txt # Training data
├── requirements.txt # Python dependencies
├── README.md # Project documentation
├── .gitignore # Git ignore rules
└── LICENSE # License information
app.py: Interactive web application with dark mode UIpredictive_keyboard_model.pth: Trained model weights and vocabularypredictive_keyboard_model.ipynb: Training notebook with detailed implementationdataset.txt: Text corpus for training the modelrequirements.txt: List of required Python packages
This project is licensed under the MIT License - see the LICENSE file for details.
Made with ❤️ using PyTorch and Streamlit
⭐ Star this repository if you found it helpful!