A Neural Machine Translation (NMT) system that translates English to Spanish using TensorFlow, Keras, and a Seq2Seq Encoder-Decoder architecture built with LSTM neural networks.
Originally developed as part of the Codecademy Machine Translation project, this application has been extended into a complete machine learning portfolio project with:
- Interactive command-line translator
- Streamlit web application
- Statistics dashboard
- Unknown vocabulary detection
- Custom sentence translation
- Early stopping
- Modern Keras model persistence (
.keras) - Improved preprocessing and tokenization
Translate English sentences into Spanish using:
- Seq2Seq architecture
- Encoder-Decoder design
- LSTM neural networks
- Teacher forcing
- TensorFlow / Keras
Example:
Input:
Who?
Output:
ยฟQuiรฉn?
Launch the translator directly from the terminal:
python src/translate.pyFeatures:
1 - Translate custom text
2 - Test dataset examples
3 - Show model statistics
4 - Exit
The project includes a web-based interface powered by Streamlit.
Run:
streamlit run streamlit_app.pyThe application launches in your browser and allows users to:
- Enter English text
- Generate Spanish translations
- View model statistics
- Interact with the translator without using a terminal
machine-translation/
โ
โโโ assets/
โ โโโ home-page.png
โ โโโ translation-example.png
โ โโโ model-statistics.png
โ
โโโ data/
โ โโโ spa.txt
โ
โโโ models/
โ โโโ training_model.keras
โ
โโโ src/
โ โโโ preprocessing.py
โ โโโ train.py
โ โโโ translate.py
โ โโโ utils.py
โ
โโโ tests/
โ
โโโ streamlit_app.py
โ
โโโ README.md
โโโ LICENSE
โโโ requirements.txt
โโโ .gitignore
Input Sequence
โ
LSTM (256 units)
โ
Hidden State
Cell State
Start Token
โ
LSTM (256 units)
โ
Dense Softmax Layer
โ
Predicted Output Token
9,894,582
latent_dim = 256Source:
ManyThings.org Language Dataset
Language Pair:
English โ Spanish
Training Data Used:
10,000 sentence pairs
Vocabulary Learned:
Encoder Vocabulary : 2516 words
Decoder Vocabulary : 5302 words
latent_dim = 256
batch_size = 50
epochs = 100Training uses:
EarlyStopping(
monitor="val_loss",
patience=5,
restore_best_weights=True
)This automatically stops training once validation performance stops improving.
The application provides real-time model information.
Example:
Encoder vocabulary : 2516
Decoder vocabulary : 5302
Maximum input tokens : 8
Maximum output tokens : 17
Latent dimension : 256
Model size : 75.52 MB
Custom translation mode detects words that were not present in the training dataset.
Example:
Input:
My name is Wayne
Warning:
'Wayne' not found in training vocabulary
This helps explain translation limitations.
- Python 3
- TensorFlow
- Keras
- NumPy
- Streamlit
- Natural Language Processing (NLP)
- Seq2Seq Neural Networks
- LSTM Networks
- Machine Learning
- Deep Learning
Clone the repository:
git clone https://github.com/YOUR_USERNAME/machine-translation.gitNavigate into the project:
cd machine-translationCreate a virtual environment:
python -m venv venvActivate:
venv\Scripts\activateInstall dependencies:
pip install -r requirements.txtpython src/train.pyOutput:
models/training_model.keras
python src/translate.pystreamlit run streamlit_app.pyWho?
ยฟQuiรฉn?
Run!
ยกรrale!
How are you?
ยฟEstabas aquรญ?
This project demonstrates:
- Neural Machine Translation
- Encoder-Decoder Architectures
- Seq2Seq Models
- LSTM Networks
- Deep Learning Workflows
- Model Persistence
- TensorFlow / Keras Development
- NLP Tokenization
- Streamlit Application Development
- Git & GitHub Project Management
Potential future improvements:
- Word Embeddings
- Attention Mechanisms
- Transformer Architecture
- Translation Confidence Scores
- BLEU Score Evaluation
- Larger Training Datasets
- Multiple Language Support
- Docker Deployment
- Cloud Hosting
Machine Learning โข Deep Learning โข NLP โข Natural Language Processing โข Machine Translation โข Neural Machine Translation โข Seq2Seq โข Encoder Decoder โข LSTM โข TensorFlow โข Keras โข Streamlit โข Python โข Artificial Intelligence
This project is licensed under the MIT License.
See the LICENSE file for details.
Codecademy Machine Translation project and expanded into a standalone machine learning portfolio project featuring a Streamlit web application, custom translation interface, statistics dashboard, and modern Keras workflow.


