transformers safetensors t5 text2text-generation translation fr en dataset:Helsinki-NLP/tatoeba base_model:Helsinki-NLP/opus-mt-fr-en base_model:finetune:Helsinki-NLP/opus-mt-fr-en autotrain_compatible text-generation-inference endpoints_compatible region:us
---
base_model:
- Helsinki-NLP/opus-mt-fr-en
datasets:
- Helsinki-NLP/tatoeba
language:
- fr
- en
library_name: transformers
metrics:
- bleu
pipeline_tag: translation
new_version: mihdeme/t5-fr-en-tatoeba
---

# Model Card for Model ID

<!-- Provide a quick summary of what the model is/does. -->
This is a fine-tuned version of `google-t5/t5-small`, trained on the **Tatoeba dataset** for French-to-English translation.


## Model Details
- **Base Model:** `google-t5/t5-small`
- **Dataset Used:** `opus_tatoeba (French-English)`
- **Fine-tuning Epochs:** 3
- **Optimizer:** AdamW (learning rate: 5e-5)
- **Evaluation Metric:** BLEU Score
- **Fine-Tuned BLEU Score:** 47.00 (on Tatoeba test set, 10% random subset of tatoeba)

### Model Description

<!-- Provide a longer summary of what this model is. -->

- **Developed by:** Mahdi Ihdeme
- **Model type:** Language model 

## Usage
```python
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer

model_name = "mihdeme/t5-fr-en-tatoeba"
model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
tokenizer = AutoTokenizer.from_pretrained(model_name)

def translate(sentence, max_length=460, num_beams=5):
    inputs = tokenizer(f"translate French to English: {sentence}", return_tensors="pt", padding=True, truncation=True)
    outputs = model.generate(
        **inputs,
        max_length=max_length,  
        num_beams=num_beams,
    )
    return tokenizer.decode(outputs[0], skip_special_tokens=True)

print(translate("Bonjour, comment ça va ?"))
```

## Training Configuration
-  **Batch Size:** 16
-  **Max Sequence Length:** 460
-  **Hardware Used:** Google Colab GPU (Tesla T4)

## License
Apache 2.0

## Acknowledgments
Trained using Hugging Face **Transformers**.
Original dataset from **Tatoeba**.
