YAML Metadata Warning:empty or missing yaml metadata in repo card

Check out the documentation for more information.

English-Galician Translation Project


Description

This repository focuses on training and evaluating machine learning models for English-to-Galician translation. It uses T5-small as the primary model and Helsinki-NLP/opus-mt-en-gl as the secondary model. The project demonstrates the fine-tuning process, evaluation using automatic and human metrics, and comparative analysis of the models. The models leverage the Hugging Face Transformers library and the Seq2Seq framework, ensuring high-quality and efficient translation capabilities.


Features

  1. Model Training:
    • Fine-tuning T5-small and Helsinki-NLP/opus-mt-en-gl on a custom dataset of 66,358 samples.
    • Preprocessing includes tokenization, truncation, and mapping source-target pairs.
    • Training configuration includes 3 epochs with learning rate and batch size optimizations.
  2. Evaluation:
    • Semantic Similarity: Measured using SentenceTransformer embeddings.
    • Automatic Metrics: BLEU and ROUGE for translation quality.
    • Human Evaluation: Scores for relevance, fluency, coherence, engagement, and creativity.
  3. Comparison:
    • Includes variability in outputs and metrics for realistic simulation.
    • Side-by-side evaluation of both models to highlight trade-offs.

Model Details

Model Summary

This project involves two fine-tuned models designed for English-to-Galician translation tasks:

  • T5-small: A lightweight model, ideal for flexible translations with moderate training resources.
  • Helsinki-NLP/opus-mt-en-gl: A high-performance model tailored for domain-specific translation tasks.

Model Description

This model was developed to translate English instructions into Galician outputs using fine-tuned machine learning techniques. It achieves robust translation capabilities through careful training and evaluation.

  • Base Model: T5-small
  • Languages: English (en), Galician (gl)
  • Dataset: Custom dataset with 66,358 examples
  • Training Epochs: 3
  • Batch Size: 32
  • Learning Rate: 5e-5
  • Framework: PyTorch with ๐Ÿค— Transformers

Repository Structure

  • training.ipynb: Notebook for fine-tuning the models.
  • evaluation.ipynb: Notebook for evaluating outputs using semantic and human-level metrics.
  • Galician.json: Dataset containing English-Galician translation pairs.
  • translation_models/: Directory to save fine-tuned models.
  • scripts/: Helper functions for preprocessing, training, and evaluation.

Setup

  1. Clone the repository:
    git clone https://github.com/username/Translation-Models-En-Gl.git
    
  2. Install dependencies:
    pip install transformers datasets sentencepiece torch sacrebleu rouge-score
    
  3. Ensure a GPU is available for training (e.g., Google Colab or local machine with CUDA).

Usage

Fine-tuning

  • Use the training.ipynb notebook to fine-tune T5-small or Helsinki-NLP models.
  • The trained models are saved in the translation_models directory.

Evaluation

  • Run the evaluation.ipynb notebook to generate outputs and compute metrics.
  • Modify the instruction and input text to test different scenarios.

Example

from transformers import AutoTokenizer, AutoModelForSeq2SeqLM

# Load model and tokenizer
tokenizer = AutoTokenizer.from_pretrained("Swethamani/Translation-Models-En-G")
model = AutoModelForSeq2SeqLM.from_pretrained("Swethamani/Translation-Models-En-G")

# Translate English to Galician
input_text = "Translate this text into Galician."
inputs = tokenizer(input_text, return_tensors="pt")
outputs = model.generate(**inputs)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))

Results

T5-small

  • Strengths: Provides flexibility and decent translation quality.
  • Limitations: May require more fine-tuning for nuanced sentences.

Helsinki-NLP

  • Strengths: Offers superior translation quality for complex or domain-specific texts.
  • Limitations: Lacks generalization for other NLP tasks.

Evaluation

Metrics

  • Semantic Similarity: Using SentenceTransformer embeddings to compare input and output.
  • BLEU and ROUGE Scores: For assessing translation quality.
  • Human Evaluation: Scored on relevance, fluency, coherence, engagement, and creativity.

Uses

Direct Use

  • Translating English instructions into Galician.
  • Generating Galician outputs based on English input prompts.

Results Comparison

  • View the training loss and evaluation scores for both models.
  • Compare BLEU, ROUGE, and human evaluation scores to determine performance.

Acknowledgements

  • Libraries Used: Hugging Face transformers, SentenceTransformer, datasets, sacrebleu, and rouge-score.
  • Dataset: Custom-curated English-Galician translations.

Downloads last month
20
Safetensors
Model size
60.5M params
Tensor type
F32
ยท
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support