region:us
---
{}
---

# Build your own simple translator LSTM and Seq-to-Seq translator

This repository contains materials and analysis for an NLP assignment focused on translation tasks using LSTM-based and Seq-to-Seq models. The work involves exploring dataset formats, building model architectures, and evaluating model performance using BLEU and ChrF metrics.

## Repository Structure

### 1. Images
- **Dataset Format Visualization** (`A2 #Q1 Dataset format.png`): 
  - An image showcasing the structure of the dataset used for training both models, including input and output formats.
- **LSTM Model Class Diagram** (`A2 #Q2 LSTM Model Class.png`): 
  - A visual representation of the LSTM model architecture, detailing the layers and the sequence flow.
- **Seq-to-Seq Model Class Diagram** (`A2 #Q3 Seq-to-Seq Model class.png`): 
  - A diagram illustrating the Seq-to-Seq model, including encoder-decoder components and attention mechanisms.
- **BLEU Score Comparison Plot** (`A2 #Q5 BLEU Scores for both LSTM-based model vs Seq-to-seq model (Plot).png`): 
  - A plot comparing BLEU scores obtained from the LSTM and Seq-to-Seq models across different test samples.
- **ChrF Score Comparison Plot** (`A2 #Q8 Chrf Scores for both LSTM-based model vs Seq-to-seq model .png`): 
  - A graphical comparison of ChrF scores between the two models, indicating performance differences.

### 2. Documents
- **Training Curves Document** (`A2 #Q4 Training curves.docx`): 
  - A Word document that provides detailed training curves for both models, showcasing loss reduction and accuracy improvements over epochs.

### 3. CSV Files
- **BLEU Scores Data** (`A2 #Q6 BLEU Scores CSV file.csv`): 
  - This CSV file contains BLEU scores for various experiments, including different model configurations and datasets.
- **ChrF Scores Data** (`A2 #Q7 Chrf Scores CSV.csv`): 
  - Contains the ChrF scores, which provide an alternative metric to evaluate translation quality, highlighting differences in n-gram overlap.

### 4. Jupyter Notebooks
- **Seq-to-Seq Model Analysis Notebook** (`A2_Q10_Google_Colab_Seq2seq_based_translator_Analysis.ipynb`): 
  - An in-depth analysis of the Seq-to-Seq-based translator, including data preprocessing, model training, and evaluation using Google Colab.
  - Features include hyperparameter tuning, use of attention mechanisms, and qualitative analysis of translations.
- **LSTM-based Model Analysis Notebook** (`A2_Q9_Google_Colab_for_LSTM_based_translator.ipynb`): 
  - This notebook covers the implementation and analysis of the LSTM-based translator, providing insights into its training process, evaluation metrics, and sample outputs.

### 5. Additional Resources
- **Colab Links** (`Colab Links.txt`): 
  - A text file with direct links to the Google Colab notebooks for easy access and execution.


### Prerequisites
To run the Jupyter notebooks, you will need:
- Python 3.x
- Required libraries: `torch`, `transformers`, `matplotlib`, `pandas`, `numpy`
- Google Colab or a local Jupyter environment

### Running the Notebooks
1. Open the provided links in `Colab Links.txt` or download the `.ipynb` files and upload them to [Google Colab](https://colab.research.google.com/).
2. Ensure you have access to the dataset files used in the notebooks (if applicable).
3. Execute the cells step-by-step, following the instructions provided in each notebook.

## Evaluation Metrics
- **BLEU Score**: Measures the n-gram precision between the generated and reference translations.
- **ChrF Score**: A character n-gram F-score that provides an alternative evaluation metric, especially useful for low-resource languages.

## Use Cases
This project can serve as a reference for:
- Understanding LSTM and Seq-to-Seq architectures for translation tasks.
- Evaluating model performance using various metrics.
- Experimenting with neural network models in NLP tasks using Google Colab.

## License
This project is licensed for educational and research purposes only. For any commercial use, please contact the author.

## Contact
For any questions or feedback, please reach out via the repository's discussion section or the author's email.

