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:

  1. From English to Croatian
  2. 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

  1. BLEU Scores:
    • Measure n-gram overlap between the predicted and reference translations.
    • Higher scores indicate better translation accuracy.
  2. CHRF Scores:
    • Evaluate translation quality at the character level, useful for morphologically rich languages like Croatian.
  3. 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

  1. 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.
  2. Training:
    • Open the provided Colab notebooks:
      • lstm_translator.ipynb
      • seq2seq_translator.ipynb
    • Run all cells to train the models.
  3. Evaluation:
    • Calculate BLEU and CHRF scores using the test dataset.
    • Plots for training curves, BLEU, and CHRF comparisons will be automatically generated and saved.
  4. Results:
    • Review the generated score files (bleu_scores.csv and chrf_scores.csv) and plots in the results/ folder.

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.

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support