YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
README: English to Croatian and Croatian to English Translator
Overview
This project involves building a translator capable of converting text:
- From English to Croatian
- From Croatian to English
Two models are implemented for this task:
- LSTM-Based Translator
- Seq-to-Seq Translator (without attention)
The project includes dataset preparation, model training, evaluation using BLEU and CHRF scores, and a comparison of the models' performance.
How the Translator Works
1. Translation Models
LSTM-Based Translator
- The LSTM (Long Short-Term Memory) model uses recurrent layers to process sequences of words.
- The input text is tokenized and converted into numerical representations (word embeddings).
- The LSTM processes the sequence word by word, generating an output sequence in the target language.
- The final output sequence is reconstructed into text.
Seq-to-Seq Translator
- The Seq-to-Seq (Sequence-to-Sequence) model uses two main components:
- Encoder: Encodes the input sequence into a fixed-length vector representation.
- Decoder: Decodes the vector representation into the target language sequence.
- Unlike the LSTM-based translator, the Seq-to-Seq model does not use attention mechanisms.
- This simpler structure may lead to lower accuracy on long sentences but works effectively for shorter sequences.
2. Dataset Preparation
- The dataset is sourced from the HuggingFace dataset repository.
- The data is prepared in a parallel format to align English and Croatian sentences:
<s> <en> This is a sample sentence in English. </en> <cr> Ovo je primjer reΔenice na hrvatskom jeziku. </cr> </s> - Both English-to-Croatian and Croatian-to-English pairs are created for training.
3. Training Process
- Input Data: Sentences are tokenized into word or subword tokens.
- Model Training:
- For each pair of input and target sequences, the model learns to predict the target tokens from the input tokens.
- Loss is calculated based on the difference between the predicted sequence and the target sequence.
- Validation: The model's performance is evaluated on a separate validation dataset to monitor overfitting or underfitting.
Evaluation Metrics
- BLEU Scores:
- Measure n-gram overlap between the predicted and reference translations.
- Higher scores indicate better translation accuracy.
- CHRF Scores:
- Evaluate translation quality at the character level, useful for morphologically rich languages like Croatian.
- Training Curves:
- Training and validation loss are plotted to assess the model's learning progress.
File Structure
English-Croatian-Translator/
βββ data/
β βββ Cleaned_Croatian.json #Dataset in parallel format
βββ notebooks/
β βββ lstm_translator.ipynb # LSTM-based translator implementation
β βββ seq2seq_translator.ipynb # Seq-to-Seq translator implementation
βββ results/
β βββ bleu_scores.csv # BLEU scores for both models
β βββ chrf_scores.csv # CHRF scores for both models
β βββ training_curves/
β β βββ lstm_training_curve.png # LSTM training/validation loss curve
β β βββ seq2seq_training_curve.png # Seq-to-Seq training/validation loss curve
β βββ bleu_comparison_plot.png # BLEU score comparison plot
β βββ chrf_comparison_plot.png # CHRF score comparison plot
βββ README.md # Project README file
How to Run
- Dataset Preparation:
- Ensure the dataset is formatted in the parallel structure mentioned above.
- Upload the dataset files (`cleaned_croatian.json') to the project folder or Colab.
- Training:
- Open the provided Colab notebooks:
lstm_translator.ipynbseq2seq_translator.ipynb
- Run all cells to train the models.
- Open the provided Colab notebooks:
- Evaluation:
- Calculate BLEU and CHRF scores using the test dataset.
- Plots for training curves, BLEU, and CHRF comparisons will be automatically generated and saved.
- Results:
- Review the generated score files (
bleu_scores.csvandchrf_scores.csv) and plots in theresults/folder.
- Review the generated score files (
References
This project enables translation between English and Croatian using two types of models, showcasing the strengths and weaknesses of LSTM-based and Seq-to-Seq architectures.
Inference Providers NEW
This model isn't deployed by any Inference Provider. π Ask for provider support